[eog] Add an "Open containing folder" command



commit 9df5fd43cc9cea9ded47953d22d82cfea1ace015
Author: Akshay Gupta <kitallis gmail com>
Date:   Fri May 20 12:07:19 2011 +0200

    Add an "Open containing folder" command
    
    https://bugzilla.gnome.org/show_bug.cgi?id=650402

 data/eog-toolbar.xml |    1 +
 data/eog-ui.xml      |    3 ++
 src/eog-window.c     |   54 ++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 58 insertions(+), 0 deletions(-)
---
diff --git a/data/eog-toolbar.xml b/data/eog-toolbar.xml
index fad785f..0ff0c24 100644
--- a/data/eog-toolbar.xml
+++ b/data/eog-toolbar.xml
@@ -3,6 +3,7 @@
 <available>
     <toolitem name="ImageOpen"/>
     <toolitem name="ImageSave"/>
+    <toolitem name="ImageOpenContainingFolder"/>
     <toolitem name="ImagePrint"/>
     <toolitem name="ImageProperties"/>
     <toolitem name="ViewImageGallery"/>
diff --git a/data/eog-ui.xml b/data/eog-ui.xml
index 07441b4..9cb695d 100644
--- a/data/eog-ui.xml
+++ b/data/eog-ui.xml
@@ -12,6 +12,7 @@
       <menuitem action="ImagePrint"/>
       <separator/>
       <menuitem action="ImageSetAsWallpaper"/>
+      <menuitem action="ImageOpenContainingFolder"/>
       <separator/>
       <menuitem action="ImageProperties"/>
       <separator/>
@@ -121,6 +122,7 @@
     <separator/>
     <menuitem action="ImageProperties"/>
     <menuitem action="ImageSetAsWallpaper"/>
+    <menuitem action="ImageOpenContainingFolder"/>
   </popup>
 
   <popup name="ViewPopup">
@@ -139,6 +141,7 @@
     <separator/>
     <menuitem action="ImageProperties"/>
     <menuitem action="ImageSetAsWallpaper"/>
+    <menuitem action="ImageOpenContainingFolder"/>
   </popup>
 
   <accelerator name="ControlEqualAccel" action="ControlEqual"/>
diff --git a/src/eog-window.c b/src/eog-window.c
index f0d83b3..8566224 100644
--- a/src/eog-window.c
+++ b/src/eog-window.c
@@ -3000,6 +3000,54 @@ eog_window_cmd_save_as (GtkAction *action, gpointer user_data)
 }
 
 static void
+eog_window_cmd_open_containing_folder (GtkAction *action, gpointer user_data)
+{
+	EogWindow *window = EOG_WINDOW (user_data);
+	EogWindowPrivate *priv;
+	
+	GtkWidget *eog_window_widget;
+  
+	GFile *file;
+	GFile *parent = NULL;
+	
+	eog_window_widget = GTK_WIDGET (window);	
+	priv = window->priv;
+	
+	g_return_if_fail (priv->image != NULL);	
+	
+	file = eog_image_get_file (priv->image);
+
+	if (file) {
+		parent = g_file_get_parent (file);
+		g_object_unref(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 (eog_window_widget);
+			timestamp = gtk_get_current_event_time ();
+
+			error = NULL;
+			if (!gtk_show_uri (screen, parent_uri, timestamp, &error)) {
+				eog_debug_message (DEBUG_WINDOW, "Could not open the containing folder");
+				g_error_free (error);
+			}
+
+			g_free (parent_uri);
+		}
+
+		g_object_unref(parent);
+	}
+}
+
+static void
 eog_window_cmd_print (GtkAction *action, gpointer user_data)
 {
 	EogWindow *window = EOG_WINDOW (user_data);
@@ -3700,6 +3748,9 @@ static const GtkActionEntry action_entries_image[] = {
 	{ "ImageSaveAs", GTK_STOCK_SAVE_AS, N_("Save _Asâ?¦"), "<control><shift>s",
 	  N_("Save the selected images with a different name"),
 	  G_CALLBACK (eog_window_cmd_save_as) },
+	{ "ImageOpenContainingFolder", GTK_STOCK_DIRECTORY, N_("Open Containing _Folder"), NULL,
+	  N_("Show the folder which contains this file in the file manager"),
+	  G_CALLBACK (eog_window_cmd_open_containing_folder) },
 	{ "ImagePrint", GTK_STOCK_PRINT, N_("_Printâ?¦"), "<control>p",
 	  N_("Print the selected image"),
 	  G_CALLBACK (eog_window_cmd_print) },
@@ -3873,6 +3924,9 @@ set_action_properties (GtkActionGroup *window_group,
         action = gtk_action_group_get_action (image_group, "EditRotate270");
         g_object_set (action, "short_label", _("Left"), NULL);
 
+        action = gtk_action_group_get_action (image_group, "ImageOpenContainingFolder");
+        g_object_set (action, "short_label", _("Open Folder"), NULL);
+
         action = gtk_action_group_get_action (image_group, "ViewZoomIn");
         g_object_set (action, "short_label", _("In"), NULL);
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]