diff options
author | Federico Mena Quintero <federico@gnome.org> | 2012-12-17 20:05:23 -0600 |
---|---|---|
committer | Federico Mena Quintero <federico@gnome.org> | 2012-12-17 20:05:23 -0600 |
commit | 8dd233dfaca63616b12b0711ac8b2b534d782654 (patch) | |
tree | 10e09408de88b54d5c37ace9e0c1b082262c7aed /gtk/gtkplacessidebar.c | |
parent | bfa1f4ac0b102676d10c4fc5c12fedc775bc16b9 (diff) | |
download | gtk+-8dd233dfaca63616b12b0711ac8b2b534d782654.tar.gz |
New public function to get the selected location from menu item callbacks
Signed-off-by: Federico Mena Quintero <federico@gnome.org>
Diffstat (limited to 'gtk/gtkplacessidebar.c')
-rw-r--r-- | gtk/gtkplacessidebar.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/gtk/gtkplacessidebar.c b/gtk/gtkplacessidebar.c index 1133958a6a..7ede59be14 100644 --- a/gtk/gtkplacessidebar.c +++ b/gtk/gtkplacessidebar.c @@ -3807,6 +3807,44 @@ gtk_places_sidebar_set_current_location (GtkPlacesSidebar *sidebar, GFile *locat } /** + * gtk_places_sidebar_get_selected_location: + * @sidebar: a places sidebar + * + * When you connect to the populate-popup signal for the @sidebar, the callback functions + * for your menu items will need to know the file to which the contextual menu refers. Use + * this function to obtain that file's location. + * + * Returns: a GFile with the selected location, or #NULL if nothing is visually selected. + * It may be the case that the sidebar doesn't have anything visually selected because + * the location being shown in the sidebar's surrounding widgets is not actually + * in the list of places that the sidebar shows. In that case, use + * gtk_places_sidebar_get_current_location(). + */ +GFile * +gtk_places_sidebar_get_selected_location (GtkPlacesSidebar *sidebar) +{ + GtkTreeIter iter; + GFile *file; + + g_return_val_if_fail (sidebar != NULL, NULL); + + file = NULL; + + if (get_selected_iter (sidebar, &iter)) { + char *uri; + + gtk_tree_model_get (GTK_TREE_MODEL (sidebar->store), &iter, + PLACES_SIDEBAR_COLUMN_URI, &uri, + -1); + + file = g_file_new_for_uri (uri); + g_free (uri); + } + + return file; +} + +/** * gtk_places_sidebar_set_show_desktop: * @sidebar: a places sidebar * @show_desktop: whether to show an item for the Desktop folder |