diff options
-rw-r--r-- | gtk/gtkfilechooserdefault.c | 23 | ||||
-rw-r--r-- | gtk/gtkplacessidebar.c | 39 | ||||
-rw-r--r-- | gtk/gtkplacessidebar.h | 2 |
3 files changed, 48 insertions, 16 deletions
diff --git a/gtk/gtkfilechooserdefault.c b/gtk/gtkfilechooserdefault.c index cd86086e2d..f0986d1f43 100644 --- a/gtk/gtkfilechooserdefault.c +++ b/gtk/gtkfilechooserdefault.c @@ -7560,24 +7560,15 @@ static void quick_bookmark_handler (GtkFileChooserDefault *impl, gint bookmark_index) { -#if REMOVE_FOR_PLACES_SIDEBAR - int bookmark_pos; - GtkTreePath *path; - - if (bookmark_index < 0 || bookmark_index >= impl->num_bookmarks) - return; - - bookmark_pos = shortcuts_get_index (impl, SHORTCUTS_BOOKMARKS) + bookmark_index; + GFile *file; - path = gtk_tree_path_new_from_indices (bookmark_pos, -1); + file = gtk_places_sidebar_get_nth_bookmark (GTK_PLACES_SIDEBAR (impl->places_sidebar), bookmark_index); - gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (impl->browse_shortcuts_tree_view), - path, NULL, - FALSE, 0.0, 0.0); - gtk_tree_path_free (path); - - switch_to_shortcut (impl, bookmark_pos); -#endif + if (file) + { + change_folder_and_display_error (impl, file, FALSE); + g_object_unref (file); + } } static void diff --git a/gtk/gtkplacessidebar.c b/gtk/gtkplacessidebar.c index 8f98d9797e..320f3b340f 100644 --- a/gtk/gtkplacessidebar.c +++ b/gtk/gtkplacessidebar.c @@ -4165,3 +4165,42 @@ gtk_places_sidebar_list_shortcuts (GtkPlacesSidebar *sidebar) return g_slist_copy_deep (sidebar->shortcuts, (GCopyFunc) g_object_ref, NULL); } + +GFile * +gtk_places_sidebar_get_nth_bookmark (GtkPlacesSidebar *sidebar, int n) +{ + GtkTreeIter iter; + int k; + GFile *file; + + g_return_val_if_fail (GTK_IS_PLACES_SIDEBAR (sidebar), NULL); + + file = NULL; + + if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (sidebar->store), &iter)) { + k = 0; + + do { + PlaceType place_type; + char *uri; + + gtk_tree_model_get (GTK_TREE_MODEL (sidebar->store), &iter, + PLACES_SIDEBAR_COLUMN_ROW_TYPE, &place_type, + PLACES_SIDEBAR_COLUMN_URI, &uri, + -1); + + if (place_type == PLACES_BOOKMARK) { + if (k == n) { + file = g_file_new_for_uri (uri); + g_free (uri); + break; + } + + g_free (uri); + k++; + } + } while (gtk_tree_model_iter_next (GTK_TREE_MODEL (sidebar->store), &iter)); + } + + return file; +} diff --git a/gtk/gtkplacessidebar.h b/gtk/gtkplacessidebar.h index c9eb5da27a..72b185c0c4 100644 --- a/gtk/gtkplacessidebar.h +++ b/gtk/gtkplacessidebar.h @@ -76,6 +76,8 @@ gboolean gtk_places_sidebar_add_shortcut (GtkPlacesSidebar *sidebar, GFile *loca gboolean gtk_places_sidebar_remove_shortcut (GtkPlacesSidebar *sidebar, GFile *location, GError **error); GSList *gtk_places_sidebar_list_shortcuts (GtkPlacesSidebar *sidebar); +GFile *gtk_places_sidebar_get_nth_bookmark (GtkPlacesSidebar *sidebar, int n); + G_END_DECLS #endif /* __GTK_PLACES_SIDEBAR_H__ */ |