[gtk+/places-sidebar] Remove the drop feedback row a little time after drag_leave



commit 3b34e70f132ddc6794063fb84a73812b6632f05a
Author: Federico Mena Quintero <federico gnome org>
Date:   Sat Apr 20 14:20:07 2013 -0400

    Remove the drop feedback row a little time after drag_leave
    
    Since ::drag-leave gets emitted before ::drag-drop, we can't just remove the drop feedback row
    in drag-leave, as we *need* it during drag-drop.  So, we use the same trick as in testdnd.c - we
    install a timeout handler in our drag-leave callback, and remove the feedback in the timeout callback.
    
    Signed-off-by: Federico Mena Quintero <federico gnome org>

 gtk/gtkplacessidebar.c | 29 +++++++++++++++++++++++++----
 1 file changed, 25 insertions(+), 4 deletions(-)
---
diff --git a/gtk/gtkplacessidebar.c b/gtk/gtkplacessidebar.c
index 35e2183..acbd59e 100644
--- a/gtk/gtkplacessidebar.c
+++ b/gtk/gtkplacessidebar.c
@@ -165,6 +165,7 @@ struct _GtkPlacesSidebar {
 
        DropState drop_state;
        int new_bookmark_index;
+       guint drag_leave_timeout_id;
 
        guint show_desktop : 1;
 };
@@ -1312,7 +1313,7 @@ compute_drop_position (GtkTreeView             *tree_view,
                goto out;
        }
 
-o      /* Never drop on headings, but special case the bookmarks heading,
+       /* Never drop on headings, but special case the bookmarks heading,
         * so we can drop bookmarks in between it and the first bookmark.
         */
        if (place_type == PLACES_HEADING
@@ -1606,15 +1607,30 @@ drag_motion_callback (GtkTreeView *tree_view,
        return TRUE;
 }
 
+static gboolean
+drag_leave_timeout_cb (gpointer data)
+{
+       GtkPlacesSidebar *sidebar = GTK_PLACES_SIDEBAR (data);
+
+       free_drag_data (sidebar);
+       stop_drop_feedback (sidebar);
+       remove_drop_bookmark_feedback_row (sidebar);
+
+       sidebar->drag_leave_timeout_id = 0;
+       return FALSE;
+}
+
 static void
 drag_leave_callback (GtkTreeView *tree_view,
                     GdkDragContext *context,
                     unsigned int time,
                     GtkPlacesSidebar *sidebar)
 {
-       free_drag_data (sidebar);
-       stop_drop_feedback (sidebar);
-       remove_drop_bookmark_feedback_row (sidebar);
+       if (sidebar->drag_leave_timeout_id)
+               g_source_remove (sidebar->drag_leave_timeout_id);
+
+       sidebar->drag_leave_timeout_id = gdk_threads_add_timeout (500, drag_leave_timeout_cb, sidebar);
+
        g_signal_stop_emission_by_name (tree_view, "drag-leave");
 }
 
@@ -3779,6 +3795,11 @@ gtk_places_sidebar_dispose (GObject *object)
 
        sidebar->tree_view = NULL;
 
+       if (sidebar->drag_leave_timeout_id) {
+               g_source_remove (sidebar->drag_leave_timeout_id);
+               sidebar->drag_leave_timeout_id = 0;
+       }
+
        free_drag_data (sidebar);
 
        if (sidebar->bookmarks_manager != NULL) {


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