aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ephy-dnd.c
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/ephy-dnd.c
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/ephy-dnd.c')
-rw-r--r--lib/ephy-dnd.c95
1 files changed, 56 insertions, 39 deletions
diff --git a/lib/ephy-dnd.c b/lib/ephy-dnd.c
index 7dfd1f272..ef39f37f0 100644
--- a/lib/ephy-dnd.c
+++ b/lib/ephy-dnd.c
@@ -17,25 +17,13 @@
*/
#include "ephy-dnd.h"
+#include "ephy-string.h"
+#include "ephy-node.h"
#include <gtk/gtkselection.h>
#include <gtk/gtktreeview.h>
#include <string.h>
-typedef enum {
- EPHY_DND_URI_LIST,
- EPHY_DND_TEXT,
- EPHY_DND_URL
-} EphyIconDndTargetType;
-
-static GtkTargetEntry url_drag_types [] =
-{
- { EPHY_DND_URI_LIST_TYPE, 0, EPHY_DND_URI_LIST },
- { EPHY_DND_TEXT_TYPE, 0, EPHY_DND_TEXT },
- { EPHY_DND_URL_TYPE, 0, EPHY_DND_URL }
-};
-static int n_url_drag_types = G_N_ELEMENTS (url_drag_types);
-
/* Encode a "_NETSCAPE_URL_" selection.
* As far as I can tell, Netscape is expecting a single
* URL to be returned. I cannot discover a way to construct
@@ -64,6 +52,17 @@ add_one_uri (const char *uri, int x, int y, int w, int h, gpointer data)
g_string_append (result, "\r\n");
}
+static void
+add_one_node (const char *uri, int x, int y, int w, int h, gpointer data)
+{
+ GString *result;
+
+ result = (GString *) data;
+
+ g_string_append (result, uri);
+ g_string_append (result, ";");
+}
+
gboolean
ephy_dnd_drag_data_get (GtkWidget *widget,
GdkDragContext *context,
@@ -73,21 +72,32 @@ ephy_dnd_drag_data_get (GtkWidget *widget,
gpointer container_context,
EphyDragEachSelectedItemIterator each_selected_item_iterator)
{
- GString *result;
+ GString *result = NULL;
+ GdkAtom target;
+
+ target = selection_data->target;
- switch (info) {
- case EPHY_DND_URI_LIST:
- case EPHY_DND_TEXT:
+ if (target == gdk_atom_intern (EPHY_DND_URI_LIST_TYPE, FALSE) ||
+ target == gdk_atom_intern (EPHY_DND_TEXT_TYPE, FALSE))
+ {
result = g_string_new (NULL);
(* each_selected_item_iterator) (add_one_uri, container_context, result);
- break;
- case EPHY_DND_URL:
+ }
+ else if (target == gdk_atom_intern (EPHY_DND_URL_TYPE, FALSE))
+ {
result = g_string_new (NULL);
(* each_selected_item_iterator) (add_one_netscape_url, container_context, result);
- break;
- default:
- return FALSE;
- }
+ }
+ else if (target == gdk_atom_intern (EPHY_DND_TOPIC_TYPE, FALSE) ||
+ target == gdk_atom_intern (EPHY_DND_BOOKMARK_TYPE, FALSE))
+ {
+ result = g_string_new (NULL);
+ (* each_selected_item_iterator) (add_one_node, container_context, result);
+ }
+ else
+ {
+ g_assert_not_reached ();
+ }
gtk_selection_data_set (selection_data,
selection_data->target,
@@ -96,23 +106,30 @@ ephy_dnd_drag_data_get (GtkWidget *widget,
return TRUE;
}
-void
-ephy_dnd_url_drag_source_set (GtkWidget *widget)
+GList *
+ephy_dnd_node_list_extract_nodes (const char *node_list)
{
- gtk_drag_source_set (widget,
- GDK_BUTTON1_MASK,
- url_drag_types,
- n_url_drag_types,
- GDK_ACTION_COPY);
-}
+ GList *result = NULL;
+ char **nodes;
+ int i;
-void
-ephy_dnd_enable_model_drag_source (GtkWidget *treeview)
-{
- gtk_tree_view_enable_model_drag_source (GTK_TREE_VIEW (treeview),
- GDK_BUTTON1_MASK,
- url_drag_types, n_url_drag_types,
- GDK_ACTION_COPY);
+ nodes = g_strsplit (node_list, ";", -1);
+
+ for (i = 0; nodes[i] != NULL; i++)
+ {
+ gulong id;
+
+ if (ephy_str_to_int (nodes[i], &id))
+ {
+ EphyNode *node;
+
+ node = ephy_node_get_from_id (id);
+ g_return_val_if_fail (node != NULL, NULL);
+ result = g_list_append (result, node);
+ }
+ }
+
+ return result;
}
GList *