X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;ds=inline;f=shell%2Fev-window.c;h=e70e7eee84805ce23a020563fa84a7c9b4f265de;hb=223cc03e0275c77c4482ed0495b3bd15993a3ab8;hp=f1d3bd905cb534b88a12eb8a5efb257b456885be;hpb=5fa25dfa71018662facc53affd30fdcb76dbc4cf;p=evince.git diff --git a/shell/ev-window.c b/shell/ev-window.c index f1d3bd90..e70e7eee 100644 --- a/shell/ev-window.c +++ b/shell/ev-window.c @@ -56,7 +56,6 @@ #include "ev-document-fonts.h" #include "ev-document-images.h" #include "ev-document-links.h" -#include "ev-document-thumbnails.h" #include "ev-document-annotations.h" #include "ev-document-type-builtins.h" #include "ev-document-misc.h" @@ -344,6 +343,7 @@ static void ev_window_media_player_key_pressed (EvWindow *windo 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; @@ -895,6 +895,13 @@ view_selection_changed_cb (EvView *view, ev_view_get_has_selection (view)); } +static void +view_layers_changed_cb (EvView *view, + EvWindow *window) +{ + ev_sidebar_layers_update_layers_state (EV_SIDEBAR_LAYERS (window->priv->sidebar_layers)); +} + static void ev_window_page_changed_cb (EvWindow *ev_window, gint old_page, @@ -1310,8 +1317,7 @@ ev_window_refresh_window_thumbnail (EvWindow *ev_window) gint rotation; EvDocument *document = ev_window->priv->document; - if (!EV_IS_DOCUMENT_THUMBNAILS (document) || - ev_document_get_n_pages (document) <= 0 || + if (ev_document_get_n_pages (document) <= 0 || !ev_document_check_dimensions (document)) { return; } @@ -1531,6 +1537,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); @@ -2864,6 +2873,48 @@ ev_window_cmd_save_as (GtkAction *action, EvWindow *ev_window) 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) { @@ -4160,7 +4211,6 @@ ev_window_cmd_edit_toolbar (GtkAction *action, EvWindow *ev_window) gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CLOSE); gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)), 5); gtk_box_set_spacing (GTK_BOX (content_area), 2); - gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE); gtk_window_set_default_size (GTK_WINDOW (dialog), 500, 400); toolbar = EGG_EDITABLE_TOOLBAR (ev_window->priv->toolbar); @@ -5408,6 +5458,9 @@ static const GtkActionEntry entries[] = { { "FileSaveAs", GTK_STOCK_SAVE_AS, N_("_Save a Copy…"), "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…"), "P", N_("Print this document"), G_CALLBACK (ev_window_cmd_file_print) }, @@ -5718,6 +5771,10 @@ set_action_properties (GtkActionGroup *action_group) { 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*/ @@ -6598,6 +6655,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, @@ -6615,10 +6701,11 @@ method_call_cb (GDBusConnection *connection, if (window->priv->document && ev_document_has_synctex (window->priv->document)) { EvSourceLink link; + guint32 timestamp; - g_variant_get (parameters, "(&s(ii))", &link.filename, &link.line, &link.col); + g_variant_get (parameters, "(&s(ii)u)", &link.filename, &link.line, &link.col, ×tamp); ev_view_highlight_forward_search (EV_VIEW (window->priv->view), &link); - gtk_window_present (GTK_WINDOW (window)); + gtk_window_present_with_time (GTK_WINDOW (window), timestamp); } g_dbus_method_invocation_return_value (invocation, g_variant_new ("()")); @@ -6630,12 +6717,16 @@ static const char introspection_xml[] = "" "" "" + "" "" "" "" "" "" "" + "" + "" + "" "" ""; @@ -6924,6 +7015,9 @@ ev_window_init (EvWindow *ev_window) g_signal_connect_object (ev_window->priv->view, "annot-added", G_CALLBACK (view_annot_added), ev_window, 0); + g_signal_connect_object (ev_window->priv->view, "layers-changed", + G_CALLBACK (view_layers_changed_cb), + ev_window, 0); #ifdef ENABLE_DBUS g_signal_connect_swapped (ev_window->priv->view, "sync-source", G_CALLBACK (ev_window_sync_source),