[nautilus] Always use activation URI for DnD sources



commit 1d1488cbc96ee9f7dd69b708e093d274a5374878
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Wed Mar 6 16:00:29 2013 -0500

    Always use activation URI for DnD sources
    
    This ensures DnD from special locations (e.g. Recent or Trash) always
    works even for targets that do not use gvfs.

 libnautilus-private/nautilus-canvas-container.c |   25 +++++++++++++++++++++++
 libnautilus-private/nautilus-canvas-container.h |    2 +
 libnautilus-private/nautilus-canvas-dnd.c       |    2 +-
 libnautilus-private/nautilus-canvas-private.h   |    2 +
 src/nautilus-canvas-view.c                      |   14 ++++++++++++
 src/nautilus-list-view.c                        |    2 +-
 6 files changed, 45 insertions(+), 2 deletions(-)
---
diff --git a/libnautilus-private/nautilus-canvas-container.c b/libnautilus-private/nautilus-canvas-container.c
index ce3ae97..1450565 100644
--- a/libnautilus-private/nautilus-canvas-container.c
+++ b/libnautilus-private/nautilus-canvas-container.c
@@ -226,6 +226,7 @@ enum {
        MIDDLE_CLICK,
        GET_CONTAINER_URI,
        GET_ICON_URI,
+       GET_ICON_ACTIVATION_URI,
        GET_ICON_DROP_TARGET_URI,
        GET_STORED_ICON_POSITION,
        ICON_POSITION_CHANGED,
@@ -4847,6 +4848,16 @@ nautilus_canvas_container_class_init (NautilusCanvasContainerClass *class)
                                g_cclosure_marshal_generic,
                                G_TYPE_STRING, 1,
                                G_TYPE_POINTER);
+       signals[GET_ICON_ACTIVATION_URI]
+               = g_signal_new ("get-icon-activation-uri",
+                               G_TYPE_FROM_CLASS (class),
+                               G_SIGNAL_RUN_LAST,
+                               G_STRUCT_OFFSET (NautilusCanvasContainerClass,
+                                                get_icon_activation_uri),
+                               NULL, NULL,
+                               g_cclosure_marshal_generic,
+                               G_TYPE_STRING, 1,
+                               G_TYPE_POINTER);
        signals[GET_ICON_DROP_TARGET_URI]
                = g_signal_new ("get-icon-drop-target-uri",
                                G_TYPE_FROM_CLASS (class),
@@ -6964,6 +6975,20 @@ nautilus_canvas_container_get_icon_uri (NautilusCanvasContainer *container,
 }
 
 char *
+nautilus_canvas_container_get_icon_activation_uri (NautilusCanvasContainer *container,
+                                                  NautilusCanvasIcon *icon)
+{
+       char *uri;
+
+       uri = NULL;
+       g_signal_emit (container,
+                      signals[GET_ICON_ACTIVATION_URI], 0,
+                      icon->data,
+                      &uri);
+       return uri;
+}
+
+char *
 nautilus_canvas_container_get_icon_drop_target_uri (NautilusCanvasContainer *container,
                                                      NautilusCanvasIcon *icon)
 {
diff --git a/libnautilus-private/nautilus-canvas-container.h b/libnautilus-private/nautilus-canvas-container.h
index d5ec7a0..ff534a7 100644
--- a/libnautilus-private/nautilus-canvas-container.h
+++ b/libnautilus-private/nautilus-canvas-container.h
@@ -180,6 +180,8 @@ typedef struct {
                                                     NautilusCanvasPosition *position);
        char *       (* get_icon_uri)             (NautilusCanvasContainer *container,
                                                     NautilusCanvasIconData *data);
+       char *       (* get_icon_activation_uri)  (NautilusCanvasContainer *container,
+                                                    NautilusCanvasIconData *data);
        char *       (* get_icon_drop_target_uri) (NautilusCanvasContainer *container,
                                                     NautilusCanvasIconData *data);
 
diff --git a/libnautilus-private/nautilus-canvas-dnd.c b/libnautilus-private/nautilus-canvas-dnd.c
index b4eb586..b85d635 100644
--- a/libnautilus-private/nautilus-canvas-dnd.c
+++ b/libnautilus-private/nautilus-canvas-dnd.c
@@ -238,7 +238,7 @@ icon_get_data_binder (NautilusCanvasIcon *icon, gpointer data)
 
        canvas_rect_world_to_widget (EEL_CANVAS (container), &world_rect, &widget_rect);
 
-       uri = nautilus_canvas_container_get_icon_uri (container, icon);
+       uri = nautilus_canvas_container_get_icon_activation_uri (container, icon);
        if (uri == NULL) {
                g_warning ("no URI for one of the iterated icons");
                return TRUE;
diff --git a/libnautilus-private/nautilus-canvas-private.h b/libnautilus-private/nautilus-canvas-private.h
index 79154db..3753ad1 100644
--- a/libnautilus-private/nautilus-canvas-private.h
+++ b/libnautilus-private/nautilus-canvas-private.h
@@ -272,6 +272,8 @@ void          nautilus_canvas_container_select_list_unselect_others (NautilusCan
                                                                     GList                 *icons);
 char *        nautilus_canvas_container_get_icon_uri                (NautilusCanvasContainer *container,
                                                                       NautilusCanvasIcon          *canvas);
+char *        nautilus_canvas_container_get_icon_activation_uri     (NautilusCanvasContainer *container,
+                                                                    NautilusCanvasIcon          *canvas);
 char *        nautilus_canvas_container_get_icon_drop_target_uri    (NautilusCanvasContainer *container,
                                                                       NautilusCanvasIcon          *canvas);
 void          nautilus_canvas_container_update_icon                 (NautilusCanvasContainer *container,
diff --git a/src/nautilus-canvas-view.c b/src/nautilus-canvas-view.c
index 2cfe145..5ffc9ec 100644
--- a/src/nautilus-canvas-view.c
+++ b/src/nautilus-canvas-view.c
@@ -1699,6 +1699,18 @@ get_icon_uri_callback (NautilusCanvasContainer *container,
 }
 
 static char *
+get_icon_activation_uri_callback (NautilusCanvasContainer *container,
+                                 NautilusFile *file,
+                                 NautilusCanvasView *canvas_view)
+{
+       g_assert (NAUTILUS_IS_CANVAS_CONTAINER (container));
+       g_assert (NAUTILUS_IS_FILE (file));
+       g_assert (NAUTILUS_IS_CANVAS_VIEW (canvas_view));
+
+       return nautilus_file_get_activation_uri (file);
+}
+
+static char *
 get_icon_drop_target_uri_callback (NautilusCanvasContainer *container,
                                   NautilusFile *file,
                                   NautilusCanvasView *canvas_view)
@@ -1930,6 +1942,8 @@ create_canvas_container (NautilusCanvasView *canvas_view)
        /* FIXME: many of these should move into fm-canvas-container as virtual methods */
        g_signal_connect_object (canvas_container, "get-icon-uri",
                                 G_CALLBACK (get_icon_uri_callback), canvas_view, 0);
+       g_signal_connect_object (canvas_container, "get-icon-activation-uri",
+                                G_CALLBACK (get_icon_activation_uri_callback), canvas_view, 0);
        g_signal_connect_object (canvas_container, "get-icon-drop-target-uri",
                                 G_CALLBACK (get_icon_drop_target_uri_callback), canvas_view, 0);
        g_signal_connect_object (canvas_container, "move-copy-items",
diff --git a/src/nautilus-list-view.c b/src/nautilus-list-view.c
index 72e78e8..989c40a 100644
--- a/src/nautilus-list-view.c
+++ b/src/nautilus-list-view.c
@@ -450,7 +450,7 @@ item_get_data_binder (GtkTreeModel *model,
                                     column,
                                     &cell_area);
 
-       uri = nautilus_file_get_uri (file);
+       uri = nautilus_file_get_activation_uri (file);
        nautilus_file_unref (file);
 
        /* pass the uri, mouse-relative x/y and icon width/height */


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