aboutsummaryrefslogtreecommitdiffstats
path: root/lib/widgets
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@it.gnome.org>2003-03-30 01:07:50 +0800
committerMarco Pesenti Gritti <mpeseng@src.gnome.org>2003-03-30 01:07:50 +0800
commitc1a38e77d25cde47f4cc33922f0ef8983e12ae17 (patch)
tree9e8ca41c5c1bec6f7d8cd59831dc68c15e6813f5 /lib/widgets
parentf1d834f969e790e26fe7a0bd2aa203977113bc88 (diff)
downloadgsoc2013-epiphany-c1a38e77d25cde47f4cc33922f0ef8983e12ae17.tar
gsoc2013-epiphany-c1a38e77d25cde47f4cc33922f0ef8983e12ae17.tar.gz
gsoc2013-epiphany-c1a38e77d25cde47f4cc33922f0ef8983e12ae17.tar.bz2
gsoc2013-epiphany-c1a38e77d25cde47f4cc33922f0ef8983e12ae17.tar.lz
gsoc2013-epiphany-c1a38e77d25cde47f4cc33922f0ef8983e12ae17.tar.xz
gsoc2013-epiphany-c1a38e77d25cde47f4cc33922f0ef8983e12ae17.tar.zst
gsoc2013-epiphany-c1a38e77d25cde47f4cc33922f0ef8983e12ae17.zip
Make dnd code smarter, so it can support more than just urls types.
2003-03-29 Marco Pesenti Gritti <marco@it.gnome.org> * lib/ephy-dnd.c: (add_one_node), (ephy_dnd_drag_data_get), (ephy_dnd_node_list_extract_nodes): * lib/ephy-dnd.h: * lib/ephy-marshal.list: * lib/widgets/ephy-tree-model-sort.c: (each_node_get_data_binder), (ephy_tree_model_sort_multi_drag_data_get): * src/bookmarks/ephy-bookmarks-editor.c: (cmd_rename), (cmd_select_all), (ephy_bookmarks_editor_show_popup_cb), (keyword_node_show_popup_cb), (node_dropped_cb), (ephy_bookmarks_editor_construct), (ephy_bookmarks_editor_update_menu): * src/bookmarks/ephy-node-view.c: (ephy_node_view_class_init), (ephy_node_view_button_press_cb), (ephy_node_view_has_focus), (get_node_from_path), (drag_motion_cb), (drag_drop_cb), (drag_data_received_cb), (ephy_node_view_enable_drag_dest), (ephy_node_view_enable_drag_source): * src/bookmarks/ephy-node-view.h: * src/ephy-favicon-action.c: (connect_proxy): * src/history-dialog.c: (history_dialog_setup_view): * src/toolbar.c: (toolbar_get_action_name): Make dnd code smarter, so it can support more than just urls types. Implement drag of bookmarks on topics in bme. What a pain !
Diffstat (limited to 'lib/widgets')
-rw-r--r--lib/widgets/ephy-tree-model-sort.c59
1 files changed, 41 insertions, 18 deletions
diff --git a/lib/widgets/ephy-tree-model-sort.c b/lib/widgets/ephy-tree-model-sort.c
index 41369afd9..bc32131f3 100644
--- a/lib/widgets/ephy-tree-model-sort.c
+++ b/lib/widgets/ephy-tree-model-sort.c
@@ -19,6 +19,7 @@
*/
#include <gtk/gtkmarshal.h>
+#include <gtk/gtktreednd.h>
#include <string.h>
#include "ephy-node.h"
@@ -236,17 +237,47 @@ each_url_get_data_binder (EphyDragEachSelectedItemDataGet iteratee,
}
}
+static void
+each_node_get_data_binder (EphyDragEachSelectedItemDataGet iteratee,
+ gpointer iterator_context, gpointer data)
+{
+ gpointer *context = (gpointer *) iterator_context;
+ GList *path_list = (GList *) (context[0]);
+ GList *i;
+ GtkTreeModel *model = GTK_TREE_MODEL (context[1]);
+
+ for (i = path_list; i != NULL; i = i->next)
+ {
+ GtkTreeIter iter;
+ GtkTreePath *path = gtk_tree_row_reference_get_path (i->data);
+ EphyNode *node = NULL;
+ char *value;
+
+ gtk_tree_model_get_iter (GTK_TREE_MODEL (model), &iter, path);
+ g_signal_emit (G_OBJECT (model),
+ ephy_tree_model_sort_signals[NODE_FROM_ITER],
+ 0, &iter, &node);
+ if (node == NULL)
+ return;
+
+ value = g_strdup_printf ("%ld", ephy_node_get_id (node));
+ iteratee (value, -1, -1, -1, -1, data);
+ g_free (value);
+ }
+}
+
static gboolean
ephy_tree_model_sort_multi_drag_data_get (EggTreeMultiDragSource *drag_source,
GList *path_list,
guint info,
GtkSelectionData *selection_data)
{
- EphyTreeModelSort *ms = EPHY_TREE_MODEL_SORT (drag_source);
+ GdkAtom target;
- /* FIXME use the target type here, not property_id */
+ target = selection_data->target;
- if (ms->priv->drag_property_id != -1)
+ if (target == gdk_atom_intern (EPHY_DND_BOOKMARK_TYPE, FALSE) ||
+ target == gdk_atom_intern (EPHY_DND_TOPIC_TYPE, FALSE))
{
gpointer icontext[2];
@@ -254,26 +285,18 @@ ephy_tree_model_sort_multi_drag_data_get (EggTreeMultiDragSource *drag_source,
icontext[1] = drag_source;
ephy_dnd_drag_data_get (NULL, NULL, selection_data,
- info, 0, &icontext, each_url_get_data_binder);
+ info, 0, &icontext, each_node_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);
+ gpointer icontext[2];
- /* FIXME free */
- data = g_strdup_printf ("%ld", ephy_node_get_id (node));
+ icontext[0] = path_list;
+ icontext[1] = drag_source;
- gtk_selection_data_set (selection_data,
- selection_data->target,
- 8, data, strlen (data));
+ ephy_dnd_drag_data_get (NULL, NULL, selection_data,
+ info, 0, &icontext, each_url_get_data_binder);
}
return TRUE;