From: Federico Mena Quintero Date: Thu, 19 Aug 2010 21:04:43 +0000 (-0500) Subject: Implement the 'Open Containing Folder' command X-Git-Tag: EVINCE_2_91_0~43^2~1 X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=commitdiff_plain;h=5d42af6c195aa3d17047afbaeec438009fcf17ce;p=evince.git Implement the 'Open Containing Folder' command Nautilus doesn't seem to like nautilus file:///home/foo/Downloads/foo.pdf these days; it complains that foo.pdf is not a folder. So, we just launch the default handler for the file's parent folder. When that bug in Nautilus is fixed, maybe we can go back to spawning it directly. Signed-off-by: Federico Mena Quintero --- diff --git a/shell/ev-window.c b/shell/ev-window.c index 40fb7000..46c41a90 100644 --- a/shell/ev-window.c +++ b/shell/ev-window.c @@ -2865,7 +2865,43 @@ ev_window_cmd_save_as (GtkAction *action, EvWindow *ev_window) static void ev_window_cmd_open_containing_folder (GtkAction *action, EvWindow *ev_window) { - /* FIXME */ + GtkWidget *ev_window_widget; + GFile *file; + GFile *parent; + + ev_window_widget = GTK_WIDGET (ev_window); + + file = g_file_new_for_uri (ev_window->priv->uri); + parent = g_file_get_parent (file); + + if (parent) { + char *parent_uri; + + parent_uri = g_file_get_uri (parent); + if (parent_uri) { + GdkScreen *screen; + guint32 timestamp; + GError *error; + + screen = gtk_widget_get_screen (ev_window_widget); + timestamp = gtk_get_current_event_time (); + + error = NULL; + if (!gtk_show_uri (screen, parent_uri, timestamp, &error)) { + ev_window_error_message (ev_window, error, _("Could not open the containing folder")); + g_error_free (error); + } + + g_free (parent_uri); + } + } + + if (file) + g_object_unref (file); + + if (parent) + g_object_unref (parent); + } static GKeyFile *