Allow to use move/copy/link operations on open folder, attempt #2
- From: Christian Neumair <chris gnome-de org>
- To: nautilus-list gnome org
- Subject: Allow to use move/copy/link operations on open folder, attempt #2
- Date: Sat, 26 Mar 2005 23:22:40 +0100
This is the newest version of a patch I once sent this to mailing-list
[1] and that caused a long follow-up discussion. The thread revealed
that it was rejected because of possible bugs or sideffects, which was
totally unacceptable during pre-major freezes. Now that Nautilus has
branched, it would be nice to have this functionality in HEAD.
Thanks in advance!
[1]
http://mail.gnome.org/archives/nautilus-list/2005-February/msg00030.html
--
Christian Neumair <chris gnome-de org>
Index: src/nautilus-spatial-window.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-spatial-window.c,v
retrieving revision 1.436
diff -u -p -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 23 Feb 2005 18:39:30 -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 @@ struct _NautilusSpatialWindowDetails {
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,60 @@ location_button_clicked_callback (GtkWid
gtk_object_sink (GTK_OBJECT (popup));
}
+static void
+location_button_drag_begin_callback (GtkWidget *widget,
+ GdkDragContext *context,
+ NautilusSpatialWindow *window)
+{
+ GdkPixbuf *pixbuf;
+
+ pixbuf = nautilus_icon_factory_get_pixbuf_for_file (NAUTILUS_WINDOW (window)->details->viewed_file,
+ "open", NAUTILUS_ICON_SIZE_DND);
+
+ gtk_drag_set_icon_pixbuf (context, pixbuf, 0, 0);
+
+ g_object_unref (pixbuf);
+}
+
+/* build GNOME icon list, which only contains the window's URI.
+ * If we just used URIs, moving the folder to trash
+ * wouldn't work */
+static void
+get_data_binder (NautilusDragEachSelectedItemDataGet iteratee,
+ gpointer iterator_context,
+ gpointer data)
+{
+ NautilusSpatialWindow *window;
+ gchar *uri;
+
+ g_assert (NAUTILUS_IS_SPATIAL_WINDOW (iterator_context));
+ window = NAUTILUS_SPATIAL_WINDOW (iterator_context);
+
+ uri = gnome_vfs_uri_to_string (window->details->location,
+ GNOME_VFS_URI_HIDE_NONE);
+
+ iteratee (uri,
+ 0,
+ 0,
+ NAUTILUS_ICON_SIZE_DND,
+ NAUTILUS_ICON_SIZE_DND,
+ data);
+
+ g_free (uri);
+}
+
+static void
+location_button_drag_data_get_callback (GtkWidget *widget,
+ GdkDragContext *context,
+ GtkSelectionData *selection_data,
+ guint info,
+ guint time,
+ NautilusSpatialWindow *window)
+{
+ nautilus_drag_drag_data_get (widget, context, selection_data,
+ info, time, window, get_data_binder);
+}
+
void
nautilus_spatial_window_set_location_button (NautilusSpatialWindow *window,
const char *location)
@@ -642,6 +702,18 @@ nautilus_spatial_window_instance_init (N
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 | GDK_BUTTON2_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]