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>
This commit is contained in:
Federico Mena Quintero 2013-04-20 14:20:07 -04:00
parent 9c38ff7dfb
commit 3b34e70f13

View File

@ -165,6 +165,7 @@ struct _GtkPlacesSidebar {
DropState drop_state; DropState drop_state;
int new_bookmark_index; int new_bookmark_index;
guint drag_leave_timeout_id;
guint show_desktop : 1; guint show_desktop : 1;
}; };
@ -1312,7 +1313,7 @@ compute_drop_position (GtkTreeView *tree_view,
goto out; 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. * so we can drop bookmarks in between it and the first bookmark.
*/ */
if (place_type == PLACES_HEADING if (place_type == PLACES_HEADING
@ -1606,15 +1607,30 @@ drag_motion_callback (GtkTreeView *tree_view,
return TRUE; 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 static void
drag_leave_callback (GtkTreeView *tree_view, drag_leave_callback (GtkTreeView *tree_view,
GdkDragContext *context, GdkDragContext *context,
unsigned int time, unsigned int time,
GtkPlacesSidebar *sidebar) GtkPlacesSidebar *sidebar)
{ {
free_drag_data (sidebar); if (sidebar->drag_leave_timeout_id)
stop_drop_feedback (sidebar); g_source_remove (sidebar->drag_leave_timeout_id);
remove_drop_bookmark_feedback_row (sidebar);
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"); g_signal_stop_emission_by_name (tree_view, "drag-leave");
} }
@ -3779,6 +3795,11 @@ gtk_places_sidebar_dispose (GObject *object)
sidebar->tree_view = NULL; 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); free_drag_data (sidebar);
if (sidebar->bookmarks_manager != NULL) { if (sidebar->bookmarks_manager != NULL) {