diff options
author | Federico Mena Quintero <federico@gnome.org> | 2013-01-25 18:01:42 -0600 |
---|---|---|
committer | Federico Mena Quintero <federico@gnome.org> | 2013-01-25 18:01:42 -0600 |
commit | 4bff4b025ba84f3d7f0ee563dc85ccc57c2ae3a1 (patch) | |
tree | 55e116378f1af74e5a90e52013c605d6504c70c8 /gtk | |
parent | f3fb51e96b22fab38f4248c9ec306560370b53ed (diff) | |
download | gtk+-4bff4b025ba84f3d7f0ee563dc85ccc57c2ae3a1.tar.gz |
Reset the treeview drag dest row if the drop is not possible
This keeps the drop indicator line from 'sticking' if you drag a bookmark above
the Bookmarks heading.
Signed-off-by: Federico Mena Quintero <federico@gnome.org>
Diffstat (limited to 'gtk')
-rw-r--r-- | gtk/gtkplacessidebar.c | 52 |
1 files changed, 29 insertions, 23 deletions
diff --git a/gtk/gtkplacessidebar.c b/gtk/gtkplacessidebar.c index cfe20c6ffb..6062cebd84 100644 --- a/gtk/gtkplacessidebar.c +++ b/gtk/gtkplacessidebar.c @@ -1253,29 +1253,33 @@ compute_drop_position (GtkTreeView *tree_view, PLACES_SIDEBAR_COLUMN_SECTION_TYPE, §ion_type, -1); - if (section_type != SECTION_BOOKMARKS && - place_type == PLACES_HEADING) { - /* never drop on headings, but special case the bookmarks heading, - * so we can drop bookmarks in between it and the first item when - * reordering. - */ - + /* 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 + && section_type != SECTION_BOOKMARKS) { gtk_tree_path_free (*path); *path = NULL; return FALSE; } - if (section_type != SECTION_BOOKMARKS && - sidebar->drag_data_received && - sidebar->drag_data_info == GTK_TREE_MODEL_ROW) { - /* don't allow dropping bookmarks into non-bookmark areas */ - gtk_tree_path_free (*path); - *path = NULL; + /* Dragging a bookmark? */ + if (sidebar->drag_data_received + && sidebar->drag_data_info == GTK_TREE_MODEL_ROW) { + /* Don't allow reordering bookmarks into non-bookmark areas */ + if (section_type != SECTION_BOOKMARKS) { + gtk_tree_path_free (*path); + *path = NULL; - return FALSE; - } + return FALSE; + } + printf ("dragging a bookmark, pos = %d\n", *pos); + } else { + printf ("dragging a file, pos = %d\n", *pos); + } +#if 0 if (sidebar->drag_data_received && sidebar->drag_data_info == GTK_TREE_MODEL_ROW) { /* bookmark rows can only be reordered */ @@ -1283,7 +1287,7 @@ compute_drop_position (GtkTreeView *tree_view, } else { *pos = GTK_TREE_VIEW_DROP_INTO_OR_BEFORE; } - +#endif return TRUE; } @@ -1334,15 +1338,19 @@ drag_motion_callback (GtkTreeView *tree_view, char *uri; gboolean res; + action = 0; + if (!sidebar->drag_data_received) { if (!get_drag_data (tree_view, context, time)) { - return FALSE; + goto out; } } path = NULL; res = compute_drop_position (tree_view, x, y, &path, &pos, sidebar); + printf ("compute_drop_position(): pos %d, result %d\n", pos, res); + if (!res) { goto out; } @@ -1351,11 +1359,8 @@ drag_motion_callback (GtkTreeView *tree_view, if (sidebar->drag_data_received && sidebar->drag_data_info == GTK_TREE_MODEL_ROW) { action = GDK_ACTION_MOVE; - } else { - action = 0; } } else { - action = 0; if (sidebar->accept_uri_drops) { if (sidebar->drag_list != NULL) { GFile *dest_file; @@ -1376,15 +1381,16 @@ drag_motion_callback (GtkTreeView *tree_view, } } - if (action != 0) { + out: + if (action != 0) gtk_tree_view_set_drag_dest_row (tree_view, path, pos); - } + else + gtk_tree_view_set_drag_dest_row (tree_view, NULL, pos); if (path != NULL) { gtk_tree_path_free (path); } - out: g_signal_stop_emission_by_name (tree_view, "drag-motion"); gdk_drag_status (context, action, time); |