]> www.fi.muni.cz Git - evince.git/blobdiff - shell/ev-window.c
Updated list of documenters in about dialog
[evince.git] / shell / ev-window.c
index 4fe718333f0890a131cef978b55c8269f922865b..9ef85aab2d7051d56b362c5ebb27c0b5808597ad 100644 (file)
@@ -75,6 +75,7 @@
 #include "ev-properties-dialog.h"
 #include "ev-sidebar-annotations.h"
 #include "ev-sidebar-attachments.h"
+#include "ev-sidebar-bookmarks.h"
 #include "ev-sidebar.h"
 #include "ev-sidebar-links.h"
 #include "ev-sidebar-page.h"
@@ -140,6 +141,7 @@ struct _EvWindowPrivate {
        GtkWidget *sidebar_attachments;
        GtkWidget *sidebar_layers;
        GtkWidget *sidebar_annots;
+       GtkWidget *sidebar_bookmarks;
 
        /* Settings */
        GSettings *settings;
@@ -251,6 +253,7 @@ struct _EvWindowPrivate {
 #define ATTACHMENTS_SIDEBAR_ID "attachments"
 #define LAYERS_SIDEBAR_ID "layers"
 #define ANNOTS_SIDEBAR_ID "annotations"
+#define BOOKMARKS_SIDEBAR_ID "bookmarks"
 
 #define EV_PRINT_SETTINGS_FILE  "print-settings"
 #define EV_PRINT_SETTINGS_GROUP "Print Settings"
@@ -340,6 +343,8 @@ static void     ev_window_cmd_edit_find                 (GtkAction        *actio
 static void     find_bar_search_changed_cb              (EggFindBar       *find_bar,
                                                         GParamSpec       *param,
                                                         EvWindow         *ev_window);
+static void     view_external_link_cb                   (EvWindow         *window,
+                                                        EvLinkAction     *action);
 static void     ev_window_load_file_remote              (EvWindow         *ev_window,
                                                         GFile            *source_file);
 static void     ev_window_media_player_key_pressed      (EvWindow         *window,
@@ -437,6 +442,7 @@ ev_window_setup_action_sensitivity (EvWindow *ev_window)
        ev_window_set_action_sensitive (ev_window, "FileSaveAs", has_document && ok_to_copy);
        ev_window_set_action_sensitive (ev_window, "FilePrint", has_pages && ok_to_print);
        ev_window_set_action_sensitive (ev_window, "FileProperties", has_document && has_properties);
+       ev_window_set_action_sensitive (ev_window, "FileOpenContainingFolder", has_document);
 
         /* Edit menu */
        ev_window_set_action_sensitive (ev_window, "EditSelectAll", has_pages && can_get_text);
@@ -964,6 +970,8 @@ ev_window_sidebar_get_current_page_id (EvWindow *ev_window)
                id = LAYERS_SIDEBAR_ID;
        } else if (current_page == ev_window->priv->sidebar_annots) {
                id = ANNOTS_SIDEBAR_ID;
+       } else if (current_page == ev_window->priv->sidebar_bookmarks) {
+               id = BOOKMARKS_SIDEBAR_ID;
        } else {
                g_assert_not_reached();
        }
@@ -984,6 +992,7 @@ ev_window_sidebar_set_current_page (EvWindow    *window,
        GtkWidget  *attachments = window->priv->sidebar_attachments;
        GtkWidget  *annots = window->priv->sidebar_annots;
        GtkWidget  *layers = window->priv->sidebar_layers;
+       GtkWidget  *bookmarks = window->priv->sidebar_bookmarks;
 
        if (strcmp (page_id, LINKS_SIDEBAR_ID) == 0 &&
            ev_sidebar_page_support_document (EV_SIDEBAR_PAGE (links), document)) {
@@ -1000,6 +1009,9 @@ ev_window_sidebar_set_current_page (EvWindow    *window,
        } else if (strcmp (page_id, ANNOTS_SIDEBAR_ID) == 0 &&
                   ev_sidebar_page_support_document (EV_SIDEBAR_PAGE (annots), document)) {
                ev_sidebar_set_page (sidebar, annots);
+       } else if (strcmp (page_id, BOOKMARKS_SIDEBAR_ID) == 0 &&
+                  ev_sidebar_page_support_document (EV_SIDEBAR_PAGE (bookmarks), document)) {
+               ev_sidebar_set_page (sidebar, bookmarks);
        }
 }
 
@@ -1455,8 +1467,15 @@ ev_window_set_document (EvWindow *ev_window, EvDocument *document)
        }
 
        if (EV_WINDOW_IS_PRESENTATION (ev_window)) {
+               gint current_page;
+
+               current_page = ev_view_presentation_get_current_page (
+                       EV_VIEW_PRESENTATION (ev_window->priv->presentation_view));
                gtk_widget_destroy (ev_window->priv->presentation_view);
                ev_window->priv->presentation_view = NULL;
+
+               /* Update the model with the current presentation page */
+               ev_document_model_set_page (ev_window->priv->model, current_page);
                ev_window_run_presentation (ev_window);
        }
 
@@ -2044,6 +2063,8 @@ ev_window_open_uri (EvWindow       *ev_window,
 
        if (ev_window->priv->metadata) {
                ev_window->priv->bookmarks = ev_bookmarks_new (ev_window->priv->metadata);
+               ev_sidebar_bookmarks_set_bookmarks (EV_SIDEBAR_BOOKMARKS (ev_window->priv->sidebar_bookmarks),
+                                                   ev_window->priv->bookmarks);
                g_signal_connect_swapped (ev_window->priv->bookmarks, "changed",
                                          G_CALLBACK (ev_window_setup_bookmarks),
                                          ev_window);
@@ -3833,22 +3854,19 @@ fullscreen_toolbar_setup_item_properties (GtkUIManager *ui_manager)
 static void
 fullscreen_toolbar_remove_shadow (GtkWidget *toolbar)
 {
-       static gboolean done = FALSE;
+       GtkCssProvider *provider;
 
-       if (!done) {
-               gtk_rc_parse_string (
-                       "\n"
-                       "   style \"fullscreen-toolbar-style\"\n"
-                       "   {\n"
-                       "      GtkToolbar::shadow-type=GTK_SHADOW_NONE\n"
-                       "   }\n"
-                       "\n"
-                       "    widget \"*.fullscreen-toolbar\" style \"fullscreen-toolbar-style\"\n"
-                       "\n");
-               done = TRUE;
-       }
-       
-       gtk_widget_set_name (toolbar, "fullscreen-toolbar");
+       gtk_widget_set_name (toolbar, "ev-fullscreen-toolbar");
+
+       provider = gtk_css_provider_new ();
+       gtk_css_provider_load_from_data (provider,
+                                        "#ev-fullscreen-toolbar {\n"
+                                        " -GtkToolbar-shadow-type: none; }",
+                                        -1, NULL);
+       gtk_style_context_add_provider (gtk_widget_get_style_context (toolbar),
+                                       GTK_STYLE_PROVIDER (provider),
+                                       GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+       g_object_unref (provider);
 }
 
 static void
@@ -3958,6 +3976,22 @@ ev_window_view_presentation_finished (EvWindow *window)
        ev_window_stop_presentation (window, TRUE);
 }
 
+static gboolean
+ev_window_view_presentation_focus_in (EvWindow *window)
+{
+       ev_application_screensaver_disable (EV_APP);
+
+       return FALSE;
+}
+
+static gboolean
+ev_window_view_presentation_focus_out (EvWindow *window)
+{
+       ev_application_screensaver_enable (EV_APP);
+
+       return FALSE;
+}
+
 static void
 ev_window_run_presentation (EvWindow *window)
 {
@@ -3984,6 +4018,15 @@ ev_window_run_presentation (EvWindow *window)
        g_signal_connect_swapped (window->priv->presentation_view, "finished",
                                  G_CALLBACK (ev_window_view_presentation_finished),
                                  window);
+       g_signal_connect_swapped (window->priv->presentation_view, "external-link",
+                                 G_CALLBACK (view_external_link_cb),
+                                 window);
+       g_signal_connect_swapped (window->priv->presentation_view, "focus-in-event",
+                                 G_CALLBACK (ev_window_view_presentation_focus_in),
+                                 window);
+       g_signal_connect_swapped (window->priv->presentation_view, "focus-out-event",
+                                 G_CALLBACK (ev_window_view_presentation_focus_out),
+                                 window);
 
        gtk_box_pack_start (GTK_BOX (window->priv->main_box),
                            window->priv->presentation_view,
@@ -4010,12 +4053,15 @@ ev_window_stop_presentation (EvWindow *window,
                             gboolean  unfullscreen_window)
 {
        guint current_page;
+       guint rotation;
 
        if (!EV_WINDOW_IS_PRESENTATION (window))
                return;
 
        current_page = ev_view_presentation_get_current_page (EV_VIEW_PRESENTATION (window->priv->presentation_view));
        ev_document_model_set_page (window->priv->model, current_page);
+       rotation = ev_view_presentation_get_rotation (EV_VIEW_PRESENTATION (window->priv->presentation_view));
+       ev_document_model_set_rotation (window->priv->model, rotation);
 
        gtk_container_remove (GTK_CONTAINER (window->priv->main_box),
                              window->priv->presentation_view);
@@ -4187,17 +4233,33 @@ ev_window_set_page_mode (EvWindow         *window,
 static void
 ev_window_cmd_edit_rotate_left (GtkAction *action, EvWindow *ev_window)
 {
-       gint rotation = ev_document_model_get_rotation (ev_window->priv->model);
+       gint rotation;
 
-       ev_document_model_set_rotation (ev_window->priv->model, rotation - 90);
+       if (EV_WINDOW_IS_PRESENTATION (ev_window)) {
+               rotation = ev_view_presentation_get_rotation (EV_VIEW_PRESENTATION (ev_window->priv->presentation_view));
+               ev_view_presentation_set_rotation (EV_VIEW_PRESENTATION (ev_window->priv->presentation_view),
+                                                  rotation - 90);
+       } else {
+               rotation = ev_document_model_get_rotation (ev_window->priv->model);
+
+               ev_document_model_set_rotation (ev_window->priv->model, rotation - 90);
+       }
 }
 
 static void
 ev_window_cmd_edit_rotate_right (GtkAction *action, EvWindow *ev_window)
 {
-       gint rotation = ev_document_model_get_rotation (ev_window->priv->model);
+       gint rotation;
+
+       if (EV_WINDOW_IS_PRESENTATION (ev_window)) {
+               rotation = ev_view_presentation_get_rotation (EV_VIEW_PRESENTATION (ev_window->priv->presentation_view));
+               ev_view_presentation_set_rotation (EV_VIEW_PRESENTATION (ev_window->priv->presentation_view),
+                                                  rotation + 90);
+       } else {
+               rotation = ev_document_model_get_rotation (ev_window->priv->model);
 
-       ev_document_model_set_rotation (ev_window->priv->model, rotation + 90);
+               ev_document_model_set_rotation (ev_window->priv->model, rotation + 90);
+       }
 }
 
 static void
@@ -4255,7 +4317,7 @@ ev_window_cmd_edit_toolbar (GtkAction *action, EvWindow *ev_window)
        gtk_container_set_border_width (GTK_CONTAINER (editor), 5);
        gtk_box_set_spacing (GTK_BOX (EGG_TOOLBAR_EDITOR (editor)), 5);
 
-       gtk_container_add (GTK_CONTAINER (content_area), editor);
+        gtk_box_pack_start (GTK_BOX (content_area), editor, TRUE, TRUE, 0);
 
        egg_editable_toolbar_set_edit_mode (toolbar, TRUE);
 
@@ -4727,6 +4789,8 @@ ev_window_cmd_help_about (GtkAction *action, EvWindow *ev_window)
 
        const char *documenters[] = {
                "Nickolay V. Shmyrev <nshmyrev@yandex.ru>",
+               "Phil Bull <philbull@gmail.com>",
+               "Tiffany Antpolski <tiffany.antopolski@gmail.com>",
                NULL
        };
 
@@ -4834,6 +4898,8 @@ ev_window_sidebar_visibility_changed_cb (EvSidebar  *ev_sidebar,
                if (ev_window->priv->metadata)
                        ev_metadata_set_boolean (ev_window->priv->metadata, "sidebar_visibility",
                                                 visible);
+               if (!visible)
+                       gtk_widget_grab_focus (ev_window->priv->view);
        }
 }
 
@@ -5843,6 +5909,13 @@ sidebar_annots_annot_add_cancelled (EvSidebarAnnotations *sidebar_annots,
        ev_view_cancel_add_annotation (EV_VIEW (window->priv->view));
 }
 
+static void
+sidebar_bookmarks_add_bookmark (EvSidebarBookmarks *sidebar_bookmarks,
+                               EvWindow           *window)
+{
+       ev_window_cmd_bookmarks_add (NULL, window);
+}
+
 static void
 register_custom_actions (EvWindow *window, GtkActionGroup *group)
 {
@@ -6214,7 +6287,7 @@ do_action_named (EvWindow *window, EvLinkAction *action)
 }
 
 static void
-view_external_link_cb (EvView *view, EvLinkAction *action, EvWindow *window)
+view_external_link_cb (EvWindow *window, EvLinkAction *action)
 {
        switch (ev_link_action_get_action_type (action)) {
                case EV_LINK_ACTION_TYPE_GOTO_DEST: {
@@ -6280,6 +6353,30 @@ ev_view_popup_cmd_copy_link_address (GtkAction *action, EvWindow *window)
                                   ev_action);
 }
 
+static GFile *
+create_file_from_uri_for_format (const gchar     *uri,
+                                GdkPixbufFormat *format)
+{
+       GFile  *target_file;
+       gchar **extensions;
+       gchar  *uri_extension;
+       gint    i;
+
+       extensions = gdk_pixbuf_format_get_extensions (format);
+       for (i = 0; extensions[i]; i++) {
+               if (g_str_has_suffix (uri, extensions[i])) {
+                       g_strfreev (extensions);
+                       return g_file_new_for_uri (uri);
+               }
+       }
+
+       uri_extension = g_strconcat (uri, ".", extensions[0], NULL);
+       target_file = g_file_new_for_uri (uri_extension);
+       g_free (uri_extension);
+       g_strfreev (extensions);
+
+       return target_file;
+}
 
 static void
 image_save_dialog_response_cb (GtkWidget *fc,
@@ -6291,7 +6388,6 @@ image_save_dialog_response_cb (GtkWidget *fc,
        GError          *error = NULL;
        GdkPixbuf       *pixbuf;
        gchar           *uri;
-       gchar          **extensions;
        gchar           *filename;
        gchar           *file_format;
        GdkPixbufFormat *format;
@@ -6329,19 +6425,9 @@ image_save_dialog_response_cb (GtkWidget *fc,
                return;
        }
 
-       extensions = gdk_pixbuf_format_get_extensions (format);
-       if (!g_str_has_suffix (uri, extensions[0])) {
-               gchar *uri_extension;
-               
-               uri_extension = g_strconcat (uri, ".", extensions[0], NULL);
-               target_file = g_file_new_for_uri (uri_extension);
-               g_free (uri_extension);
-       } else {
-               target_file = g_file_new_for_uri (uri);
-       }
-       g_strfreev (extensions);
+       target_file = create_file_from_uri_for_format (uri, format);
        g_free (uri);
-       
+
        is_native = g_file_is_native (target_file);
        if (is_native) {
                filename = g_file_get_path (target_file);
@@ -6669,9 +6755,15 @@ ev_window_media_player_key_pressed (EvWindow    *window,
        if (strcmp (key, "Play") == 0) {
                ev_window_run_presentation (window);
        } else if (strcmp (key, "Previous") == 0) {
-               ev_window_cmd_go_previous_page (NULL, window);
+               if (EV_WINDOW_IS_PRESENTATION (window))
+                       ev_view_presentation_previous_page (EV_VIEW_PRESENTATION (window->priv->presentation_view));
+               else
+                       ev_window_cmd_go_previous_page (NULL, window);
        } else if (strcmp (key, "Next") == 0) {
-               ev_window_cmd_go_next_page (NULL, window);
+               if (EV_WINDOW_IS_PRESENTATION (window))
+                       ev_view_presentation_next_page (EV_VIEW_PRESENTATION (window->priv->presentation_view));
+               else
+                       ev_window_cmd_go_next_page (NULL, window);
        } else if (strcmp (key, "FastForward") == 0) {
                ev_window_cmd_go_last_page (NULL, window);
        } else if (strcmp (key, "Rewind") == 0) {
@@ -7045,6 +7137,10 @@ ev_window_init (EvWindow *ev_window)
                               NULL));
        g_object_unref (toolbars_model);
 
+       gtk_style_context_add_class
+               (gtk_widget_get_style_context (GTK_WIDGET (ev_window->priv->toolbar)),
+                GTK_STYLE_CLASS_PRIMARY_TOOLBAR);
+
        egg_editable_toolbar_show (EGG_EDITABLE_TOOLBAR (ev_window->priv->toolbar),
                                   "DefaultToolBar");
        gtk_box_pack_start (GTK_BOX (ev_window->priv->main_box),
@@ -7137,6 +7233,16 @@ ev_window_init (EvWindow *ev_window)
        ev_sidebar_add_page (EV_SIDEBAR (ev_window->priv->sidebar),
                             sidebar_widget);
 
+       sidebar_widget = ev_sidebar_bookmarks_new ();
+       ev_window->priv->sidebar_bookmarks = sidebar_widget;
+       g_signal_connect (sidebar_widget,
+                         "add-bookmark",
+                         G_CALLBACK (sidebar_bookmarks_add_bookmark),
+                         ev_window);
+       gtk_widget_show (sidebar_widget);
+       ev_sidebar_add_page (EV_SIDEBAR (ev_window->priv->sidebar),
+                            sidebar_widget);
+
        ev_window->priv->view_box = gtk_vbox_new (FALSE, 0);
        ev_window->priv->scrolled_window =
                GTK_WIDGET (g_object_new (GTK_TYPE_SCROLLED_WINDOW,
@@ -7166,9 +7272,9 @@ ev_window_init (EvWindow *ev_window)
        g_signal_connect_object (ev_window->priv->view, "focus_out_event",
                                 G_CALLBACK (view_actions_focus_out_cb),
                                 ev_window, 0);
-       g_signal_connect_object (ev_window->priv->view, "external-link",
-                                G_CALLBACK (view_external_link_cb),
-                                ev_window, 0);
+       g_signal_connect_swapped (ev_window->priv->view, "external-link",
+                                 G_CALLBACK (view_external_link_cb),
+                                 ev_window);
        g_signal_connect_object (ev_window->priv->view, "handle-link",
                                 G_CALLBACK (view_handle_link_cb),
                                 ev_window, 0);