[nautilus/wip/csoriano/dnd: 9/9] f



commit 1ef0bccb671876507a13cc288e43cef533262bc9
Author: Carlos Soriano <csoriano gnome org>
Date:   Wed Sep 30 09:07:06 2015 +0200

    f

 libnautilus-private/nautilus-canvas-dnd.c |   17 ++++++++++++++++-
 libnautilus-private/nautilus-canvas-dnd.h |    1 +
 libnautilus-private/nautilus-dnd.c        |    5 ++++-
 src/nautilus-list-view.c                  |   17 +++++++++++++++++
 src/nautilus-window-slot-dnd.c            |    2 ++
 src/nautilus-window.c                     |    7 +++++--
 6 files changed, 45 insertions(+), 4 deletions(-)
---
diff --git a/libnautilus-private/nautilus-canvas-dnd.c b/libnautilus-private/nautilus-canvas-dnd.c
index a035ef9..4905cbb 100644
--- a/libnautilus-private/nautilus-canvas-dnd.c
+++ b/libnautilus-private/nautilus-canvas-dnd.c
@@ -1080,6 +1080,19 @@ nautilus_canvas_container_receive_dropped_icons (NautilusCanvasContainer *contai
        container->details->dnd_info->drag_info.selection_list = NULL;
 }
 
+GList *
+nautilus_canvas_container_get_drag_source_data (NautilusCanvasContainer *container)
+{
+       if (!container->details->dnd_info->drag_info.got_drop_data_type ||
+            container->details->dnd_info->drag_info.data_type != NAUTILUS_ICON_DND_GNOME_ICON_LIST) {
+               /* drag_data_received_callback didn't get called yet or the drag
+                 * wasn't started in the canvas container */
+               return NULL;
+       }
+
+        return container->details->dnd_info->drag_info.selection_list;
+}
+
 static void
 nautilus_canvas_container_get_drop_action (NautilusCanvasContainer *container,
                                         GdkDragContext *context,
@@ -1110,6 +1123,9 @@ nautilus_canvas_container_get_drop_action (NautilusCanvasContainer *container,
        switch (container->details->dnd_info->drag_info.data_type) {
        case NAUTILUS_ICON_DND_GNOME_ICON_LIST:
                if (container->details->dnd_info->drag_info.selection_list != NULL) {
+                        NautilusWindow *window;
+                        window = NAUTILUS_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (container)));
+                        nautilus_window_start_dnd (window, context);
                        nautilus_drag_default_drop_action_for_icons (context, drop_target, 
                                                                     
container->details->dnd_info->drag_info.selection_list, 
                                                                     action);
@@ -1297,7 +1313,6 @@ drag_begin_callback (GtkWidget      *widget,
        drag_info = &(container->details->dnd_info->drag_info);
        drag_info->selection_cache = nautilus_drag_create_selection_cache (widget,
                                                                           each_icon_get_data_binder);
-        nautilus_window_start_dnd (window, context);
 }
 
 void
diff --git a/libnautilus-private/nautilus-canvas-dnd.h b/libnautilus-private/nautilus-canvas-dnd.h
index f780848..ad57d43 100644
--- a/libnautilus-private/nautilus-canvas-dnd.h
+++ b/libnautilus-private/nautilus-canvas-dnd.h
@@ -53,5 +53,6 @@ void   nautilus_canvas_dnd_begin_drag            (NautilusCanvasContainer *conta
                                                  int                    start_x,
                                                  int                    start_y);
 void   nautilus_canvas_dnd_end_drag              (NautilusCanvasContainer *container);
+GList *nautilus_canvas_container_get_drag_source_data (NautilusCanvasContainer *container);
 
 #endif /* NAUTILUS_CANVAS_DND_H */
diff --git a/libnautilus-private/nautilus-dnd.c b/libnautilus-private/nautilus-dnd.c
index 788b04a..917d080 100644
--- a/libnautilus-private/nautilus-dnd.c
+++ b/libnautilus-private/nautilus-dnd.c
@@ -394,6 +394,8 @@ nautilus_drag_sidebar_default_drop_action_for_icons (GdkDragContext *context,
        GdkDragAction actions;
        NautilusFile *dropped_file, *target_file;
 
+  g_assert_not_reached ();
+
         g_print ("default %d\n", gdk_drag_context_get_suggested_action (context));
        if (target_uri_string == NULL) {
         g_print ("uri null\n");
@@ -514,7 +516,8 @@ nautilus_drag_sidebar_default_drop_action_for_icons (GdkDragContext *context,
 
 void
 nautilus_drag_default_drop_action_for_icons (GdkDragContext *context,
-                                            const char *target_uri_string, const GList *items,
+                                            const char *target_uri_string,
+                                             const GList *items,
                                             int *action)
 {
        gboolean same_fs;
diff --git a/src/nautilus-list-view.c b/src/nautilus-list-view.c
index 50e76a4..0e13415 100644
--- a/src/nautilus-list-view.c
+++ b/src/nautilus-list-view.c
@@ -479,6 +479,17 @@ each_item_get_data_binder (NautilusDragEachSelectedItemDataGet iteratee,
        gtk_tree_selection_selected_foreach (selection, item_get_data_binder, &context);
 }
 
+static void
+drag_end_callback (GtkWidget        *widget,
+                   GdkDragContext   *context,
+                   NautilusListView *view)
+{
+        NautilusWindow *window;
+
+        window = nautilus_files_view_get_window (NAUTILUS_FILES_VIEW (view));
+
+        nautilus_window_end_dnd (window, context);
+}
 
 static void
 drag_begin_callback (GtkWidget *widget,
@@ -487,7 +498,9 @@ drag_begin_callback (GtkWidget *widget,
 {
        GList *selection_cache;
        cairo_surface_t *surface;
+        NautilusWindow *window;
 
+        window = nautilus_files_view_get_window (NAUTILUS_FILES_VIEW (view));
        surface = get_drag_surface (view);
        if (surface) {
                gtk_drag_set_icon_surface (context, surface);
@@ -506,6 +519,8 @@ drag_begin_callback (GtkWidget *widget,
                                "drag-info",
                                selection_cache,
                                (GDestroyNotify)nautilus_drag_destroy_selection_list);
+
+        nautilus_window_start_dnd (window, context);
 }
 
 static gboolean
@@ -1851,6 +1866,8 @@ create_and_set_up_tree_view (NautilusListView *view)
 
        g_signal_connect_object (view->details->tree_view, "drag-begin",
                                 G_CALLBACK (drag_begin_callback), view, 0);
+       g_signal_connect_object (view->details->tree_view, "drag-end",
+                                G_CALLBACK (drag_end_callback), view, 0);
        g_signal_connect_object (view->details->tree_view, "drag-data-get",
                                 G_CALLBACK (drag_data_get_callback), view, 0);
        g_signal_connect_object (view->details->tree_view, "motion-notify-event",
diff --git a/src/nautilus-window-slot-dnd.c b/src/nautilus-window-slot-dnd.c
index 6c9fea5..579ac77 100644
--- a/src/nautilus-window-slot-dnd.c
+++ b/src/nautilus-window-slot-dnd.c
@@ -212,6 +212,8 @@ slot_proxy_drag_motion (GtkWidget          *widget,
   if (drag_info->have_data &&
       drag_info->have_valid_data) {
     if (drag_info->info == NAUTILUS_ICON_DND_GNOME_ICON_LIST) {
+      nautilus_window_start_dnd (NAUTILUS_WINDOW (window), context);
+
       nautilus_drag_default_drop_action_for_icons (context, target_uri,
                                                    drag_info->data.selection_list,
                                                    &action);
diff --git a/src/nautilus-window.c b/src/nautilus-window.c
index b171f7e..0c74b74 100644
--- a/src/nautilus-window.c
+++ b/src/nautilus-window.c
@@ -981,6 +981,9 @@ void
 nautilus_window_start_dnd (NautilusWindow *window,
                            GdkDragContext *context)
 {
+        /* currently we don't use the context, so the sidebar enables all the
+         * known files and the 'New Bookmark' row.
+         */
         gtk_places_sidebar_set_drop_targets_visible (GTK_PLACES_SIDEBAR (window->priv->places_sidebar),
                                                      TRUE,
                                                      context);
@@ -1010,8 +1013,8 @@ places_sidebar_drag_action_requested_cb (GtkPlacesSidebar *sidebar,
        items = build_selection_list_from_gfile_list (source_file_list);
        uri = g_file_get_uri (dest_file);
 
-       nautilus_drag_sidebar_default_drop_action_for_icons (context, uri, items, &action);
-        g_print ("action %d %s\n", action, uri);
+       nautilus_drag_default_drop_action_for_icons (context, uri, items, &action);
+        g_print ("action %d %s\n", action, uri, g_list_length (source_file_list));
 
        nautilus_drag_destroy_selection_list (items);
        g_free (uri);


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