From f3beff7556a256743f2d8a980f6d7d2b1cbca64e Mon Sep 17 00:00:00 2001 From: Federico Mena Quintero Date: Mon, 10 Dec 2012 14:18:00 -0600 Subject: [PATCH] Implement the 'Add to bookmarks' command as before Signed-off-by: Federico Mena Quintero --- gtk/gtkfilechooserdefault.c | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/gtk/gtkfilechooserdefault.c b/gtk/gtkfilechooserdefault.c index af6e53cdf5..7f3e745646 100644 --- a/gtk/gtkfilechooserdefault.c +++ b/gtk/gtkfilechooserdefault.c @@ -1427,14 +1427,41 @@ popup_menu_detach_cb (GtkWidget *attach_widget, impl->browse_files_popup_menu_copy_file_location_item = NULL; } +/* Callback used from gtk_tree_selection_selected_foreach(); adds a bookmark for + * each selected item in the file list. + */ +static void +add_bookmark_foreach_cb (GtkTreeModel *model, + GtkTreePath *path, + GtkTreeIter *iter, + gpointer data) +{ + GtkFileChooserDefault *impl; + GFile *file; + + impl = (GtkFileChooserDefault *) data; + + gtk_tree_model_get (model, iter, + MODEL_COL_FILE, &file, + -1); + + _gtk_bookmarks_manager_insert_bookmark (impl->bookmarks_manager, file, 0, NULL); /* NULL-GError */ + + g_object_unref (file); +} + /* Callback used when the "Add to Bookmarks" menu item is activated */ static void add_to_shortcuts_cb (GtkMenuItem *item, GtkFileChooserDefault *impl) { -#if REMOVE_FOR_PLACES_SIDEBAR - bookmarks_add_selected_folder (impl); -#endif + GtkTreeSelection *selection; + + selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->browse_files_tree_view)); + + gtk_tree_selection_selected_foreach (selection, + add_bookmark_foreach_cb, + impl); } /* callback used to set data to clipboard */