[PATCH] Allow to use move/copy/link operations on open folder (was: Re: [Usability] Interacting with open folders)



Am Donnerstag, den 10.02.2005, 18:40 +0000 schrieb John Spray:
> On Thu, 2005-02-10 at 18:09 +0100, Maurizio Colucci wrote:
> > > b Use menu in statusbar on the left as drag handle
> > 
> > not discoverable.
> I think that this is arguably as discoverable as dragging any file in
> the window: when not expanded the bottom-left menu is just a folder icon
> with the name next to it.  I say this because I attempted to 'discover'
> precisely this feature when it wasn't there: I tried dragging that menu
> and was disappointed when it didn't do anything.

After applying this patch, you should be able to drag any focused
folder's spatial window through it's location button located on the
bottom left of the window. It will allow you to move, copy or link the
dragged folder to any other folder, including the trash.

-- 
Christian Neumair <chris gnome-de org>
? depcomp
? nautilus-folder-handler.desktop
? stamp-h1
? src/.nautilus-spatial-window.c.swp
? src/file-manager/.fm-directory-view.c.swp
Index: src/nautilus-spatial-window.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-spatial-window.c,v
retrieving revision 1.436
diff -u -r1.436 nautilus-spatial-window.c
--- src/nautilus-spatial-window.c	27 Jan 2005 12:35:47 -0000	1.436
+++ src/nautilus-spatial-window.c	10 Feb 2005 19:04:44 -0000
@@ -48,6 +48,7 @@
 #include <eel/eel-string.h>
 #include <gdk-pixbuf/gdk-pixbuf.h>
 #include <gdk/gdkx.h>
+#include <gtk/gtkdnd.h>
 #include <gtk/gtkmain.h>
 #include <gtk/gtkmenubar.h>
 #include <gtk/gtkmenuitem.h>
@@ -63,6 +64,7 @@
 #include <libgnomeui/gnome-window-icon.h>
 #include <libgnomevfs/gnome-vfs-uri.h>
 #include <libgnomevfs/gnome-vfs-utils.h>
+#include <libnautilus-private/nautilus-dnd.h>
 #include <libnautilus-private/nautilus-file-utilities.h>
 #include <libnautilus-private/nautilus-ui-utilities.h>
 #include <libnautilus-private/nautilus-file-attributes.h>
@@ -91,6 +93,10 @@
 	GnomeVFSURI *location;
 };
 
+static GtkTargetEntry location_button_drag_types[] = {
+	{ NAUTILUS_ICON_DND_GNOME_ICON_LIST_TYPE, 0, NAUTILUS_ICON_DND_GNOME_ICON_LIST }
+};
+
 GNOME_CLASS_BOILERPLATE (NautilusSpatialWindow, nautilus_spatial_window,
 			 NautilusWindow, NAUTILUS_TYPE_WINDOW)
 
@@ -536,6 +542,40 @@
  	gtk_object_sink (GTK_OBJECT (popup));
 }
 
+static void
+location_button_drag_begin_callback (GtkWidget             *widget,
+				     GdkDragContext        *context,
+				     NautilusSpatialWindow *window)
+{
+	gtk_drag_set_icon_pixbuf (context, gtk_window_get_icon (GTK_WINDOW (window)), -2, -2);
+}
+
+
+static void
+location_button_drag_data_get_callback (GtkWidget             *widget,
+					GdkDragContext        *context,
+					GtkSelectionData      *selection_data,
+					guint                  info,
+					guint                  time,
+					NautilusSpatialWindow *window)
+{
+	gchar *uri, *sel;
+
+	/* build GNOME icon list, which only contains the window's URI.
+	 * If we just used URIs, moving the folder to trash
+	 * wouldn't work */
+	uri = gnome_vfs_uri_to_string (window->details->location,
+				       GNOME_VFS_URI_HIDE_NONE);
+	sel = g_strconcat (uri, "\r0:0:1:1\r\n", NULL);
+
+	gtk_selection_data_set (selection_data,
+				selection_data->target,
+				8, sel, strlen (sel)+1);
+
+	g_free (sel);
+	g_free (uri);
+}
+
 void
 nautilus_spatial_window_set_location_button  (NautilusSpatialWindow *window,
 					      const char            *location)
@@ -642,6 +682,18 @@
 	gtk_box_pack_start (GTK_BOX (hbox), arrow, FALSE, FALSE, 0);
 	gtk_widget_show (arrow);
 
+	gtk_drag_source_set (window->details->location_button,
+			     GDK_BUTTON1_MASK, location_button_drag_types,
+			     G_N_ELEMENTS (location_button_drag_types),
+			     GDK_ACTION_MOVE | GDK_ACTION_COPY | GDK_ACTION_LINK | GDK_ACTION_ASK);
+	g_signal_connect (window->details->location_button,
+			  "drag-begin",
+			  G_CALLBACK (location_button_drag_begin_callback),
+			  window);
+	g_signal_connect (window->details->location_button,
+			  "drag-data-get",
+			  G_CALLBACK (location_button_drag_data_get_callback),
+			  window);
 	
 	gtk_widget_set_sensitive (window->details->location_button, FALSE);
 	g_signal_connect (window->details->location_button, 


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