]> www.fi.muni.cz Git - evince.git/commitdiff
Merge branch 'unmessify-my-pdfs' - bgo#627443 - Add an 'Open containing folder' command
authorFederico Mena Quintero <federico@novell.com>
Mon, 13 Sep 2010 19:41:34 +0000 (14:41 -0500)
committerFederico Mena Quintero <federico@novell.com>
Mon, 13 Sep 2010 19:41:43 +0000 (14:41 -0500)
1  2 
shell/ev-window.c

diff --combined shell/ev-window.c
index 32db0ef2b83b23a4041e147b5ff5c008ffcc8f96,aad7dee7413a0f1f78681f3ebd61b23cf2810b55..ce43ab072b16a512735556248af9b89f3da9cefb
@@@ -343,7 -343,6 +343,7 @@@ static void     ev_window_media_player_
  static void     ev_window_update_max_min_scale          (EvWindow         *window);
  #ifdef ENABLE_DBUS
  static void   ev_window_emit_closed                   (EvWindow         *window);
 +static void   ev_window_emit_doc_loaded               (EvWindow         *window);
  #endif
  
  static guint ev_window_n_copies = 0;
@@@ -1530,9 -1529,6 +1530,9 @@@ ev_window_load_job_cb (EvJob *job
        if (!ev_job_is_failed (job)) {
                ev_document_model_set_document (ev_window->priv->model, document);
  
 +#ifdef ENABLE_DBUS
 +              ev_window_emit_doc_loaded (ev_window);
 +#endif
                setup_chrome_from_metadata (ev_window);
                update_chrome_actions (ev_window);
                setup_document_from_metadata (ev_window);
@@@ -2866,6 -2862,48 +2866,48 @@@ ev_window_cmd_save_as (GtkAction *actio
        gtk_widget_show (fc);
  }
  
+ static void
+ ev_window_cmd_open_containing_folder (GtkAction *action, EvWindow *ev_window)
+ {
+       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 *
  get_print_settings_file (void)
  {
@@@ -5410,6 -5448,9 +5452,9 @@@ static const GtkActionEntry entries[] 
                { "FileSaveAs", GTK_STOCK_SAVE_AS, N_("_Save a Copy…"), "<control>S",
          N_("Save a copy of the current document"),
          G_CALLBACK (ev_window_cmd_save_as) },
+       { "FileOpenContainingFolder", GTK_STOCK_DIRECTORY, N_("Open Containing _Folder"), NULL,
+         N_("Show the folder which contains this file in the file manager"),
+         G_CALLBACK (ev_window_cmd_open_containing_folder) },
        { "FilePrint", GTK_STOCK_PRINT, N_("_Print…"), "<control>P",
          N_("Print this document"),
          G_CALLBACK (ev_window_cmd_file_print) },
@@@ -5720,6 -5761,10 +5765,10 @@@ set_action_properties (GtkActionGroup *
  {
        GtkAction *action;
  
+       action = gtk_action_group_get_action (action_group, "FileOpenContainingFolder");
+       /*translators: this is the label for toolbar button*/
+       g_object_set (action, "short_label", _("Open Folder"), NULL);
        action = gtk_action_group_get_action (action_group, "GoPreviousPage");
        g_object_set (action, "is-important", TRUE, NULL);
        /*translators: this is the label for toolbar button*/
@@@ -6600,35 -6645,6 +6649,35 @@@ ev_window_emit_closed (EvWindow *window
                g_dbus_connection_flush_sync (connection, NULL, NULL);
  }
  
 +static void
 +ev_window_emit_doc_loaded (EvWindow *window)
 +{
 +      GDBusConnection *connection;
 +      GError          *error = NULL;
 +
 +      if (window->priv->dbus_object_id <= 0)
 +              return;
 +
 +      connection = ev_application_get_dbus_connection (EV_APP);
 +      if (!connection)
 +              return;
 +
 +      g_dbus_connection_emit_signal (connection,
 +                                     NULL,
 +                                     window->priv->dbus_object_path,
 +                                     EV_WINDOW_DBUS_INTERFACE,
 +                                     "DocumentLoaded",
 +                                     g_variant_new("(s)", window->priv->uri),
 +                                     &error);
 +      if (error) {
 +              g_printerr ("Failed to emit DBus signal DocumentLoaded: %s\n",
 +                          error->message);
 +              g_error_free (error);
 +
 +              return;
 +      }
 +}
 +
  static void
  method_call_cb (GDBusConnection       *connection,
                  const gchar           *sender,
@@@ -6667,9 -6683,6 +6716,9 @@@ static const char introspection_xml[] 
              "<arg type='(ii)' name='source_point' direction='out'/>"
            "</signal>"
              "<signal name='Closed'/>"
 +          "<signal name='DocumentLoaded'>"
 +            "<arg type='s' name='uri' direction='out'/>"
 +          "</signal>"
            "</interface>"
          "</node>";