aboutsummaryrefslogtreecommitdiffstats
path: root/lib/widgets
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@it.gnome.org>2003-03-26 03:53:58 +0800
committerMarco Pesenti Gritti <mpeseng@src.gnome.org>2003-03-26 03:53:58 +0800
commitb3320ef7127e9fa0ca93c6c024466e1e1f0ae1c7 (patch)
tree2db543911c8a7d013d10f3475e3eab6135f9b8f6 /lib/widgets
parent4a0747542c21fa5660cbf09d4b3aca5520ef8ca9 (diff)
downloadgsoc2013-epiphany-b3320ef7127e9fa0ca93c6c024466e1e1f0ae1c7.tar
gsoc2013-epiphany-b3320ef7127e9fa0ca93c6c024466e1e1f0ae1c7.tar.gz
gsoc2013-epiphany-b3320ef7127e9fa0ca93c6c024466e1e1f0ae1c7.tar.bz2
gsoc2013-epiphany-b3320ef7127e9fa0ca93c6c024466e1e1f0ae1c7.tar.lz
gsoc2013-epiphany-b3320ef7127e9fa0ca93c6c024466e1e1f0ae1c7.tar.xz
gsoc2013-epiphany-b3320ef7127e9fa0ca93c6c024466e1e1f0ae1c7.tar.zst
gsoc2013-epiphany-b3320ef7127e9fa0ca93c6c024466e1e1f0ae1c7.zip
Make ids private
2003-03-25 Marco Pesenti Gritti <marco@it.gnome.org> * lib/ephy-dnd.c: * lib/ephy-dnd.h: Make ids private * lib/widgets/ephy-editable-toolbar.c: (impl_get_action_name), (impl_get_action), (drag_data_received_cb), (setup_toolbar), (setup_item), (ensure_action), (ephy_editable_toolbar_class_init), (update_editor_sheet), (ephy_editable_toolbar_get_action_name), (ephy_editable_toolbar_get_action): * lib/widgets/ephy-editable-toolbar.h: Rework special actions api. * lib/widgets/ephy-tree-model-sort.c: (ephy_tree_model_sort_init), (ephy_tree_model_sort_set_drag_property), (each_url_get_data_binder), (ephy_tree_model_sort_multi_drag_data_get): * lib/widgets/ephy-tree-model-sort.h: Support nodes dnd. Need more work, see FIXME * src/bookmarks/Makefile.am: * src/bookmarks/ephy-bookmarks-editor.c: (ephy_bookmarks_editor_construct): * src/bookmarks/ephy-bookmarks.c: (ephy_bookmarks_init), (ephy_bookmarks_finalize), (ephy_bookmarks_find_keyword): * src/bookmarks/ephy-node-view.c: (ephy_node_view_enable_drag_source): * src/bookmarks/ephy-node-view.h: * src/history-dialog.c: (history_dialog_setup_view): * src/toolbar.c: (toolbar_get_action_name), (toolbar_get_action), (toolbar_class_init): Support for topics dnd. The menu is still not implemented but the hard part is done. Cant finish it until the weekend :/
Diffstat (limited to 'lib/widgets')
-rwxr-xr-xlib/widgets/ephy-editable-toolbar.c77
-rwxr-xr-xlib/widgets/ephy-editable-toolbar.h25
-rw-r--r--lib/widgets/ephy-tree-model-sort.c54
-rw-r--r--lib/widgets/ephy-tree-model-sort.h6
4 files changed, 117 insertions, 45 deletions
diff --git a/lib/widgets/ephy-editable-toolbar.c b/lib/widgets/ephy-editable-toolbar.c
index 7307140c8..2af974a87 100755
--- a/lib/widgets/ephy-editable-toolbar.c
+++ b/lib/widgets/ephy-editable-toolbar.c
@@ -29,18 +29,12 @@
#include <libgnome/gnome-i18n.h>
#include <string.h>
-/* This is copied from gtkscrollbarwindow.c */
-#define DEFAULT_SCROLLBAR_SPACING 3
-
-#define SCROLLBAR_SPACING(w) \
- (GTK_SCROLLED_WINDOW_GET_CLASS (w)->scrollbar_spacing >= 0 ? \
- GTK_SCROLLED_WINDOW_GET_CLASS (w)->scrollbar_spacing : DEFAULT_SCROLLBAR_SPACING)
-
static GtkTargetEntry dest_drag_types [] =
{
{ "EPHY_TOOLBAR_BUTTON", 0, 0 },
/* FIXME generic way to add types */
- { EPHY_DND_URL_TYPE, 0, EPHY_DND_URL }
+ { EPHY_DND_URL_TYPE, 0, 1 },
+ { EPHY_DND_TOPIC_TYPE, 0, 2 }
};
static GtkTargetEntry source_drag_types [] =
@@ -180,23 +174,23 @@ find_action (EphyEditableToolbar *t, const char *name)
return action;
}
+static char *
+impl_get_action_name (EphyEditableToolbar *etoolbar,
+ const char *drag_type,
+ const char *data)
+{
+ return NULL;
+}
+
static EggAction *
impl_get_action (EphyEditableToolbar *etoolbar,
- const char *type,
const char *name)
{
EggAction *action;
g_return_val_if_fail (IS_EPHY_EDITABLE_TOOLBAR (etoolbar), NULL);
- if (type == NULL)
- {
- action = find_action (etoolbar, name);
- }
- else
- {
- action = NULL;
- }
+ action = find_action (etoolbar, name);
return action;
}
@@ -248,10 +242,12 @@ drag_data_received_cb (GtkWidget *widget,
EphyToolbarsItem *sibling;
const char *type = NULL;
GdkAtom target;
- EggAction *action;
+ EggAction *action = NULL;
g_return_if_fail (IS_EPHY_EDITABLE_TOOLBAR (etoolbar));
+ LOG ("Drag data received")
+
toolbar = (EphyToolbarsToolbar *)g_object_get_data (G_OBJECT (widget), "toolbar_data");
if (!toolbar)
@@ -273,8 +269,28 @@ drag_data_received_cb (GtkWidget *widget,
{
type = EPHY_DND_URL_TYPE;
}
+ else if (target == gdk_atom_intern (EPHY_DND_TOPIC_TYPE, FALSE))
+ {
+ type = EPHY_DND_TOPIC_TYPE;
+ }
+
+ if (type)
+ {
+ char *name;
+
+ name = ephy_editable_toolbar_get_action_name
+ (etoolbar, type, selection_data->data);
+ if (name != NULL)
+ {
+ action = ephy_editable_toolbar_get_action (etoolbar, name);
+ g_free (name);
+ }
+ }
+ else
+ {
+ action = ephy_editable_toolbar_get_action (etoolbar, selection_data->data);
+ }
- action = ephy_editable_toolbar_get_action (etoolbar, type, selection_data->data);
if (action)
{
ephy_toolbars_group_add_item (etoolbar->priv->group, parent, sibling,
@@ -540,7 +556,7 @@ setup_toolbar (EphyToolbarsToolbar *toolbar, EphyEditableToolbar *etoolbar)
g_object_set_data (G_OBJECT (widget), "drag_dest_set",
GINT_TO_POINTER (TRUE));
gtk_drag_dest_set (widget, GTK_DEST_DEFAULT_ALL,
- dest_drag_types, 2,
+ dest_drag_types, 3,
GDK_ACTION_MOVE | GDK_ACTION_COPY);
g_signal_connect (widget, "drag_data_received",
G_CALLBACK (drag_data_received_cb),
@@ -587,7 +603,7 @@ setup_item (EphyToolbarsItem *item, EphyEditableToolbar *etoolbar)
g_object_set_data (G_OBJECT (toolitem), "drag_dest_set",
GINT_TO_POINTER (TRUE));
gtk_drag_dest_set (toolitem, GTK_DEST_DEFAULT_ALL,
- dest_drag_types, 2,
+ dest_drag_types, 3,
GDK_ACTION_COPY | GDK_ACTION_MOVE);
g_signal_connect (toolitem, "drag_data_received",
G_CALLBACK (drag_data_received_cb),
@@ -676,7 +692,7 @@ ensure_action (EphyToolbarsItem *item, EphyEditableToolbar *t)
g_return_if_fail (IS_EPHY_EDITABLE_TOOLBAR (t));
g_return_if_fail (item != NULL);
- ephy_editable_toolbar_get_action (t, NULL, item->action);
+ ephy_editable_toolbar_get_action (t, item->action);
}
static void
@@ -774,6 +790,7 @@ ephy_editable_toolbar_class_init (EphyEditableToolbarClass *klass)
object_class->get_property = ephy_editable_toolbar_get_property;
klass->get_action = impl_get_action;
+ klass->get_action_name = impl_get_action_name;
g_object_class_install_property (object_class,
PROP_MENU_MERGE,
@@ -1033,7 +1050,7 @@ update_editor_sheet (EphyEditableToolbar *etoolbar)
gtk_scrolled_window_add_with_viewport
(GTK_SCROLLED_WINDOW (etoolbar->priv->scrolled_window), table);
gtk_drag_dest_set (table, GTK_DEST_DEFAULT_ALL,
- dest_drag_types, 2, GDK_ACTION_MOVE);
+ dest_drag_types, 3, GDK_ACTION_MOVE);
g_signal_connect (table, "drag_data_received",
G_CALLBACK (editor_drag_data_received_cb),
etoolbar);
@@ -1057,7 +1074,7 @@ update_editor_sheet (EphyEditableToolbar *etoolbar)
EggAction *action;
action = ephy_editable_toolbar_get_action
- (etoolbar, NULL, node->action);
+ (etoolbar, node->action);
g_return_if_fail (action != NULL);
event_box = gtk_event_box_new ();
@@ -1202,11 +1219,19 @@ ephy_editable_toolbar_edit (EphyEditableToolbar *etoolbar, GtkWidget *window)
show_editor (etoolbar);
}
+char *
+ephy_editable_toolbar_get_action_name (EphyEditableToolbar *etoolbar,
+ const char *drag_type,
+ const char *data)
+{
+ EphyEditableToolbarClass *klass = EPHY_EDITABLE_TOOLBAR_GET_CLASS (etoolbar);
+ return klass->get_action_name (etoolbar, drag_type, data);
+}
+
EggAction *
ephy_editable_toolbar_get_action (EphyEditableToolbar *etoolbar,
- const char *type,
const char *name)
{
EphyEditableToolbarClass *klass = EPHY_EDITABLE_TOOLBAR_GET_CLASS (etoolbar);
- return klass->get_action (etoolbar, type, name);
+ return klass->get_action (etoolbar, name);
}
diff --git a/lib/widgets/ephy-editable-toolbar.h b/lib/widgets/ephy-editable-toolbar.h
index 8c5f93932..68e6f39b5 100755
--- a/lib/widgets/ephy-editable-toolbar.h
+++ b/lib/widgets/ephy-editable-toolbar.h
@@ -48,21 +48,26 @@ struct EphyEditableToolbarClass
{
GObjectClass parent_class;
- EggAction * (* get_action) (EphyEditableToolbar *etoolbar,
- const char *type,
- const char *name);
+ char * (* get_action_name) (EphyEditableToolbar *etoolbar,
+ const char *drag_type,
+ const char *data);
+ EggAction * (* get_action) (EphyEditableToolbar *etoolbar,
+ const char *name);
};
-GType ephy_editable_toolbar_get_type (void);
+GType ephy_editable_toolbar_get_type (void);
-EphyEditableToolbar *ephy_editable_toolbar_new (EggMenuMerge *merge);
+EphyEditableToolbar *ephy_editable_toolbar_new (EggMenuMerge *merge);
-void ephy_editable_toolbar_edit (EphyEditableToolbar *etoolbar,
- GtkWidget *window);
+void ephy_editable_toolbar_edit (EphyEditableToolbar *etoolbar,
+ GtkWidget *window);
-EggAction *ephy_editable_toolbar_get_action (EphyEditableToolbar *etoolbar,
- const char *type,
- const char *name);
+char *ephy_editable_toolbar_get_action_name (EphyEditableToolbar *etoolbar,
+ const char *drag_type,
+ const char *data);
+
+EggAction *ephy_editable_toolbar_get_action (EphyEditableToolbar *etoolbar,
+ const char *name);
G_END_DECLS
diff --git a/lib/widgets/ephy-tree-model-sort.c b/lib/widgets/ephy-tree-model-sort.c
index 3c2377cf0..41369afd9 100644
--- a/lib/widgets/ephy-tree-model-sort.c
+++ b/lib/widgets/ephy-tree-model-sort.c
@@ -26,6 +26,7 @@
#include "eggtreemultidnd.h"
#include "ephy-dnd.h"
#include "ephy-marshal.h"
+#include "ephy-debug.h"
static void ephy_tree_model_sort_class_init (EphyTreeModelSortClass *klass);
static void ephy_tree_model_sort_init (EphyTreeModelSort *ma);
@@ -43,6 +44,7 @@ static gboolean ephy_tree_model_sort_multi_drag_data_delete (EggTreeMultiDragSou
struct EphyTreeModelSortPrivate
{
char *str_list;
+ guint drag_property_id;
};
enum
@@ -119,6 +121,8 @@ static void
ephy_tree_model_sort_init (EphyTreeModelSort *ma)
{
ma->priv = g_new0 (EphyTreeModelSortPrivate, 1);
+
+ ma->priv->drag_property_id = -1;
}
static void
@@ -185,6 +189,13 @@ ephy_tree_model_sort_multi_row_draggable (EggTreeMultiDragSource *drag_source, G
return TRUE;
}
+void
+ephy_tree_model_sort_set_drag_property (EphyTreeModelSort *ms,
+ guint id)
+{
+ ms->priv->drag_property_id = id;
+}
+
static gboolean
ephy_tree_model_sort_multi_drag_data_delete (EggTreeMultiDragSource *drag_source,
GList *path_list)
@@ -216,8 +227,10 @@ each_url_get_data_binder (EphyDragEachSelectedItemDataGet iteratee,
if (node == NULL)
return;
- value = ephy_node_get_property_string (node,
- EPHY_DND_NODE_PROPERTY);
+ value = ephy_node_get_property_string
+ (node, EPHY_TREE_MODEL_SORT (model)->priv->drag_property_id);
+
+ LOG ("Data get %s", value)
iteratee (value, -1, -1, -1, -1, data);
}
@@ -228,13 +241,40 @@ ephy_tree_model_sort_multi_drag_data_get (EggTreeMultiDragSource *drag_source,
GList *path_list,
guint info,
GtkSelectionData *selection_data)
-{ gpointer icontext[2];
+{
+ EphyTreeModelSort *ms = EPHY_TREE_MODEL_SORT (drag_source);
- icontext[0] = path_list;
- icontext[1] = drag_source;
+ /* FIXME use the target type here, not property_id */
- ephy_dnd_drag_data_get (NULL, NULL, selection_data,
- info, 0, &icontext, each_url_get_data_binder);
+ if (ms->priv->drag_property_id != -1)
+ {
+ gpointer icontext[2];
+
+ icontext[0] = path_list;
+ icontext[1] = drag_source;
+
+ ephy_dnd_drag_data_get (NULL, NULL, selection_data,
+ info, 0, &icontext, each_url_get_data_binder);
+ }
+ else
+ {
+ GtkTreeIter iter;
+ GtkTreePath *path = gtk_tree_row_reference_get_path (path_list->data);
+ EphyNode *node = NULL;
+ char *data;
+
+ gtk_tree_model_get_iter (GTK_TREE_MODEL (drag_source), &iter, path);
+ g_signal_emit (G_OBJECT (drag_source),
+ ephy_tree_model_sort_signals[NODE_FROM_ITER],
+ 0, &iter, &node);
+
+ /* FIXME free */
+ data = g_strdup_printf ("%ld", ephy_node_get_id (node));
+
+ gtk_selection_data_set (selection_data,
+ selection_data->target,
+ 8, data, strlen (data));
+ }
return TRUE;
}
diff --git a/lib/widgets/ephy-tree-model-sort.h b/lib/widgets/ephy-tree-model-sort.h
index f8cb9fb68..2b8b38be9 100644
--- a/lib/widgets/ephy-tree-model-sort.h
+++ b/lib/widgets/ephy-tree-model-sort.h
@@ -49,10 +49,12 @@ typedef struct
void (*node_from_iter) (EphyTreeModelSort *model, GtkTreeIter *iter, void **node);
} EphyTreeModelSortClass;
-GType ephy_tree_model_sort_get_type (void);
+GType ephy_tree_model_sort_get_type (void);
-GtkTreeModel *ephy_tree_model_sort_new (GtkTreeModel *child_model);
+GtkTreeModel *ephy_tree_model_sort_new (GtkTreeModel *child_model);
+void ephy_tree_model_sort_set_drag_property (EphyTreeModelSort *ms,
+ guint id);
G_END_DECLS