[PATCH] Fix text DND



Turns out that the "UTF8_STRING" dnd target isn't enough, for instance
mozilla doesn't seem to support it. Proposed patch attached. Note that
all these additional targets only works because we use the GTK+
gtk_selection_data_get_text DND helper.

-- 
Christian Neumair <chris gnome-de org>
Index: libnautilus-private/nautilus-dnd.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-dnd.c,v
retrieving revision 1.20
diff -u -p -r1.20 nautilus-dnd.c
--- libnautilus-private/nautilus-dnd.c	13 Jan 2005 13:27:51 -0000	1.20
+++ libnautilus-private/nautilus-dnd.c	5 Jul 2005 13:18:37 -0000
@@ -70,10 +70,16 @@
 void
 nautilus_drag_init (NautilusDragInfo     *drag_info,
 		    const GtkTargetEntry *drag_types,
-		    int                   drag_type_count)
+		    int                   drag_type_count,
+		    gboolean              add_text_targets)
 {
 	drag_info->target_list = gtk_target_list_new (drag_types,
 						   drag_type_count);
+
+	if (add_text_targets) {
+		gtk_target_list_add_text_targets (drag_info->target_list,
+						  NAUTILUS_ICON_DND_TEXT);
+	}
 
 	drag_info->drop_occured = FALSE;
 	drag_info->need_to_destroy = FALSE;
Index: libnautilus-private/nautilus-dnd.h
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-dnd.h,v
retrieving revision 1.12
diff -u -p -r1.12 nautilus-dnd.h
--- libnautilus-private/nautilus-dnd.h	5 Jul 2005 12:23:34 -0000	1.12
+++ libnautilus-private/nautilus-dnd.h	5 Jul 2005 13:18:37 -0000
@@ -32,7 +32,6 @@
 /* Drag & Drop target names. */
 #define NAUTILUS_ICON_DND_GNOME_ICON_LIST_TYPE  "x-special/gnome-icon-list"
 #define NAUTILUS_ICON_DND_URI_LIST_TYPE         "text/uri-list"
-#define NAUTILUS_ICON_DND_TEXT_TYPE             "UTF8_STRING"
 #define NAUTILUS_ICON_DND_URL_TYPE	        "_NETSCAPE_URL"
 #define NAUTILUS_ICON_DND_COLOR_TYPE            "application/x-color"
 #define NAUTILUS_ICON_DND_BGIMAGE_TYPE          "property/bgimage"
@@ -107,7 +106,8 @@ typedef void 		(* NautilusDragEachSelect
 
 void                        nautilus_drag_init                          (NautilusDragInfo                     *drag_info,
 									 const GtkTargetEntry                 *drag_types,
-									 int                                   drag_type_count);
+									 int                                   drag_type_count,
+									 gboolean                              add_text_targets);
 void                        nautilus_drag_finalize                      (NautilusDragInfo                     *drag_info);
 NautilusDragSelectionItem  *nautilus_drag_selection_item_new            (void);
 void                        nautilus_drag_destroy_selection_list        (GList                                *selection_list);
Index: libnautilus-private/nautilus-icon-dnd.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-icon-dnd.c,v
retrieving revision 1.145
diff -u -p -r1.145 nautilus-icon-dnd.c
--- libnautilus-private/nautilus-icon-dnd.c	5 Jul 2005 12:23:34 -0000	1.145
+++ libnautilus-private/nautilus-icon-dnd.c	5 Jul 2005 13:18:37 -0000
@@ -65,14 +65,12 @@ static const GtkTargetEntry drag_types [
 	{ NAUTILUS_ICON_DND_GNOME_ICON_LIST_TYPE, 0, NAUTILUS_ICON_DND_GNOME_ICON_LIST },
 	{ NAUTILUS_ICON_DND_URI_LIST_TYPE, 0, NAUTILUS_ICON_DND_URI_LIST },
 	{ NAUTILUS_ICON_DND_URL_TYPE, 0, NAUTILUS_ICON_DND_URL },
-	{ NAUTILUS_ICON_DND_TEXT_TYPE, 0, NAUTILUS_ICON_DND_TEXT }
 };
 
 static const GtkTargetEntry drop_types [] = {
 	{ NAUTILUS_ICON_DND_GNOME_ICON_LIST_TYPE, 0, NAUTILUS_ICON_DND_GNOME_ICON_LIST },
 	{ NAUTILUS_ICON_DND_URI_LIST_TYPE, 0, NAUTILUS_ICON_DND_URI_LIST },
 	{ NAUTILUS_ICON_DND_URL_TYPE, 0, NAUTILUS_ICON_DND_URL },
-	{ NAUTILUS_ICON_DND_TEXT_TYPE, 0, NAUTILUS_ICON_DND_TEXT },
 	{ NAUTILUS_ICON_DND_COLOR_TYPE, 0, NAUTILUS_ICON_DND_COLOR },
 	{ NAUTILUS_ICON_DND_BGIMAGE_TYPE, 0, NAUTILUS_ICON_DND_BGIMAGE },
 	{ NAUTILUS_ICON_DND_KEYWORD_TYPE, 0, NAUTILUS_ICON_DND_KEYWORD },
@@ -376,12 +374,16 @@ get_data_on_first_target_we_support (Gtk
 	GList *target;
 	GtkTargetList *list;
 	
-	if (drop_types_list == NULL)
+	if (drop_types_list == NULL) {
 		drop_types_list = gtk_target_list_new (drop_types,
 						       G_N_ELEMENTS (drop_types) - 1);
-	if (drop_types_list_root == NULL)
+		gtk_target_list_add_text_targets (drop_types_list, NAUTILUS_ICON_DND_TEXT);
+	}
+	if (drop_types_list_root == NULL) {
 		drop_types_list_root = gtk_target_list_new (drop_types,
 							    G_N_ELEMENTS (drop_types));
+		gtk_target_list_add_text_targets (drop_types_list_root, NAUTILUS_ICON_DND_TEXT);
+	}
 
 	if (nautilus_icon_container_get_is_desktop (NAUTILUS_ICON_CONTAINER (widget))) {
 		list = drop_types_list_root;
@@ -1696,6 +1698,7 @@ void
 nautilus_icon_dnd_init (NautilusIconContainer *container,
 			GdkBitmap *stipple)
 {
+	GtkTargetList *targets;
 	int n_elements;
 	
 	g_return_if_fail (container != NULL);
@@ -1704,7 +1707,7 @@ nautilus_icon_dnd_init (NautilusIconCont
 
 	container->details->dnd_info = g_new0 (NautilusIconDndInfo, 1);
 	nautilus_drag_init (&container->details->dnd_info->drag_info,
-		drag_types, G_N_ELEMENTS (drag_types));
+		drag_types, G_N_ELEMENTS (drag_types), TRUE);
 
 	/* Set up the widget as a drag destination.
 	 * (But not a source, as drags starting from this widget will be
@@ -1719,6 +1722,9 @@ nautilus_icon_dnd_init (NautilusIconCont
 			   0,
 			   drop_types, n_elements,
 			   GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK | GDK_ACTION_ASK);
+
+	targets = gtk_drag_dest_get_target_list (GTK_WIDGET (container));
+	gtk_target_list_add_text_targets (targets, NAUTILUS_ICON_DND_TEXT);
 
 	/* Messages for outgoing drag. */
 	g_signal_connect (container, "drag_data_get",
Index: libnautilus-private/nautilus-tree-view-drag-dest.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-tree-view-drag-dest.c,v
retrieving revision 1.10
diff -u -p -r1.10 nautilus-tree-view-drag-dest.c
--- libnautilus-private/nautilus-tree-view-drag-dest.c	5 Jul 2005 12:23:34 -0000	1.10
+++ libnautilus-private/nautilus-tree-view-drag-dest.c	5 Jul 2005 13:18:38 -0000
@@ -82,7 +82,6 @@ static const GtkTargetEntry drag_types [
 	{ NAUTILUS_ICON_DND_GNOME_ICON_LIST_TYPE, 0, NAUTILUS_ICON_DND_GNOME_ICON_LIST },
 	{ NAUTILUS_ICON_DND_URI_LIST_TYPE, 0, NAUTILUS_ICON_DND_URI_LIST },
 	{ NAUTILUS_ICON_DND_URL_TYPE, 0, NAUTILUS_ICON_DND_URL },
-	{ NAUTILUS_ICON_DND_TEXT_TYPE, 0, NAUTILUS_ICON_DND_TEXT }
 	/* FIXME: Should handle emblems once the list view supports them */
 };
 
@@ -853,6 +852,7 @@ NautilusTreeViewDragDest *
 nautilus_tree_view_drag_dest_new (GtkTreeView *tree_view)
 {
 	NautilusTreeViewDragDest *dest;
+	GtkTargetList *targets;
 	
 	dest = g_object_new (NAUTILUS_TYPE_TREE_VIEW_DRAG_DEST, NULL);
 
@@ -862,8 +862,11 @@ nautilus_tree_view_drag_dest_new (GtkTre
 	
 	gtk_drag_dest_set (GTK_WIDGET (tree_view),
 			   0, drag_types, G_N_ELEMENTS (drag_types),
-			   GDK_ACTION_MOVE | GDK_ACTION_COPY | GDK_ACTION_LINK | GDK_ACTION_ASK);	
-	
+			   GDK_ACTION_MOVE | GDK_ACTION_COPY | GDK_ACTION_LINK | GDK_ACTION_ASK);
+
+	targets = gtk_drag_dest_get_target_list (GTK_WIDGET (tree_view));
+	gtk_target_list_add_text_targets (targets, NAUTILUS_ICON_DND_TEXT);
+
 	g_signal_connect_object (tree_view,
 				 "drag_motion",
 				 G_CALLBACK (drag_motion_callback),
Index: src/nautilus-spatial-window.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-spatial-window.c,v
retrieving revision 1.445
diff -u -p -r1.445 nautilus-spatial-window.c
--- src/nautilus-spatial-window.c	23 Jun 2005 14:16:58 -0000	1.445
+++ src/nautilus-spatial-window.c	5 Jul 2005 13:18:38 -0000
@@ -105,7 +105,6 @@ static const GtkTargetEntry location_but
 	{ NAUTILUS_ICON_DND_GNOME_ICON_LIST_TYPE, 0, NAUTILUS_ICON_DND_GNOME_ICON_LIST },
 	{ NAUTILUS_ICON_DND_URI_LIST_TYPE, 0, NAUTILUS_ICON_DND_URI_LIST },
 	{ NAUTILUS_ICON_DND_URL_TYPE, 0, NAUTILUS_ICON_DND_URL },
-	{ NAUTILUS_ICON_DND_TEXT_TYPE, 0, NAUTILUS_ICON_DND_TEXT }
 };
 
 GNOME_CLASS_BOILERPLATE (NautilusSpatialWindow, nautilus_spatial_window,
@@ -787,6 +786,7 @@ nautilus_spatial_window_instance_init (N
 	GtkWidget *hbox;
 	GtkActionGroup *action_group;
 	GtkUIManager *ui_manager;
+	GtkTargetList *targets;
 	const char *ui;
 	
 	window->details = g_new0 (NautilusSpatialWindowDetails, 1);
@@ -846,7 +846,10 @@ nautilus_spatial_window_instance_init (N
 			  "drag_data_get",
 			  G_CALLBACK (location_button_drag_data_get_callback),
 			  window);
-	
+
+	targets = gtk_drag_source_get_target_list (window->details->location_button);
+	gtk_target_list_add_text_targets (targets, NAUTILUS_ICON_DND_TEXT);
+
 	gtk_widget_set_sensitive (window->details->location_button, FALSE);
 	g_signal_connect (window->details->location_button, 
 			  "clicked", 
Index: src/file-manager/fm-list-model.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/file-manager/fm-list-model.c,v
retrieving revision 1.43
diff -u -p -r1.43 fm-list-model.c
--- src/file-manager/fm-list-model.c	17 Jun 2005 15:56:34 -0000	1.43
+++ src/file-manager/fm-list-model.c	5 Jul 2005 13:18:39 -0000
@@ -97,7 +97,6 @@ static const GtkTargetEntry drag_types [
 	{ NAUTILUS_ICON_DND_GNOME_ICON_LIST_TYPE, 0, NAUTILUS_ICON_DND_GNOME_ICON_LIST },
 	{ NAUTILUS_ICON_DND_URI_LIST_TYPE, 0, NAUTILUS_ICON_DND_URI_LIST },
 	{ NAUTILUS_ICON_DND_URL_TYPE, 0, NAUTILUS_ICON_DND_URL },
-	{ NAUTILUS_ICON_DND_TEXT_TYPE, 0, NAUTILUS_ICON_DND_TEXT }
 };
 
 static GtkTargetList *drag_target_list = NULL;
@@ -766,7 +765,8 @@ fm_list_model_multi_drag_data_get (EggTr
 	if (!drag_target_list) {
 		drag_target_list = gtk_target_list_new 
 			(drag_types, G_N_ELEMENTS (drag_types));
-
+		gtk_target_list_add_text_targets (
+			drag_target_list, NAUTILUS_ICON_DND_TEXT);
 	}
 
 	if (gtk_target_list_find (drag_target_list,

Attachment: signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]