]> www.fi.muni.cz Git - evince.git/commitdiff
Implement the 'Open Containing Folder' command
authorFederico Mena Quintero <federico@novell.com>
Thu, 19 Aug 2010 21:04:43 +0000 (16:04 -0500)
committerFederico Mena Quintero <federico@novell.com>
Mon, 13 Sep 2010 17:23:14 +0000 (12:23 -0500)
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 <federico@novell.com>
shell/ev-window.c

index 40fb7000c155e79009d2dc1a173c676c98b03cd3..46c41a903f24b01fbced628fa73690d688e40e48 100644 (file)
@@ -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 *