]> www.fi.muni.cz Git - evince.git/blobdiff - shell/ev-window.c
Make pdf compilation optional. See bug #38007.
[evince.git] / shell / ev-window.c
index 493e28f84bbb53194089c716c4e591e334b4f1f3..98d888f41d940726b3724ee64f45fb50d98bc64c 100644 (file)
@@ -30,6 +30,7 @@
 
 #include "ev-window.h"
 #include "ev-window-title.h"
+#include "ev-navigation-action.h"
 #include "ev-page-action.h"
 #include "ev-sidebar.h"
 #include "ev-sidebar-links.h"
@@ -68,6 +69,7 @@
 #include "ev-file-helpers.h"
 #include "ev-utils.h"
 #include "ev-debug.h"
+#include "ev-history.h"
 
 #ifdef WITH_GNOME_PRINT
 #include "ev-print-job.h"
@@ -78,7 +80,9 @@
 #include <gtk/gtkprintunixdialog.h>
 #endif
 
+#ifdef ENABLE_PDF
 #include <poppler.h>
+#endif
 
 #include <glib/gstdio.h>
 #include <glib/gi18n.h>
@@ -87,6 +91,8 @@
 #include <libgnomevfs/gnome-vfs-utils.h>
 #include <gconf/gconf-client.h>
 
+#include "totem-scrsaver.h"
+
 #include <string.h>
 
 typedef enum {
@@ -146,7 +152,10 @@ struct _EvWindowPrivate {
        GtkWidget *fullscreen_toolbar;
        GtkWidget *fullscreen_popup;
        guint      fullscreen_timeout_id;
-       
+
+       /* Screensaver */
+       TotemScrsaver *screensaver;
+
        /* Popup link */
        GtkWidget *view_popup;
        EvLink    *link;
@@ -162,7 +171,7 @@ struct _EvWindowPrivate {
        gboolean unlink_temp_file;
        
        EvDocument *document;
-
+       EvHistory *history;
        EvPageCache *page_cache;
        EvWindowPageMode page_mode;
        EvWindowTitle *title;
@@ -194,6 +203,7 @@ static const GtkTargetEntry ev_drop_types[] = {
 
 #define PAGE_SELECTOR_ACTION   "PageSelector"
 #define ZOOM_CONTROL_ACTION    "ViewZoom"
+#define NAVIGATION_ACTION      "Navigation"
 
 #define GCONF_OVERRIDE_RESTRICTIONS "/apps/evince/override_restrictions"
 #define GCONF_LOCKDOWN_SAVE         "/desktop/gnome/lockdown/disable_save_to_disk"
@@ -367,6 +377,7 @@ ev_window_setup_action_sensitivity (EvWindow *ev_window)
        /* Toolbar-specific actions: */
        ev_window_set_action_sensitive (ev_window, PAGE_SELECTOR_ACTION, has_pages);
        ev_window_set_action_sensitive (ev_window, ZOOM_CONTROL_ACTION,  has_pages);
+       ev_window_set_action_sensitive (ev_window, NAVIGATION_ACTION,  has_pages);
 
         ev_window_update_actions (ev_window);
 }
@@ -613,7 +624,15 @@ page_changed_cb (EvPageCache *page_cache,
                 gint         page,
                 EvWindow    *ev_window)
 {
+       gchar *label;
+       
        ev_window_update_actions (ev_window);
+       
+       if (ev_window->priv->history) {
+               label = ev_page_cache_get_page_label (ev_window->priv->page_cache, page);
+               ev_history_add_page (ev_window->priv->history, page, label);
+               g_free (label);
+       }
 
        if (!ev_window_is_empty (ev_window))
                ev_metadata_manager_set_int (ev_window->priv->uri, "page", page);
@@ -883,6 +902,13 @@ ev_window_setup_document (EvWindow *ev_window)
        ev_page_action_set_document (EV_PAGE_ACTION (action), document);
        ev_window_setup_action_sensitivity (ev_window);
 
+       if (ev_window->priv->history)
+               g_object_unref (ev_window->priv->history);
+       ev_window->priv->history = ev_history_new ();
+       action = gtk_action_group_get_action (ev_window->priv->action_group, NAVIGATION_ACTION);
+        ev_navigation_action_set_history (EV_NAVIGATION_ACTION (action), ev_window->priv->history);
+        ev_navigation_action_set_window (EV_NAVIGATION_ACTION (action), ev_window);
+       
        if (ev_window->priv->properties) {
                ev_properties_dialog_set_document (EV_PROPERTIES_DIALOG (ev_window->priv->properties),
                                                   ev_window->priv->document);
@@ -2516,6 +2542,8 @@ ev_window_run_presentation (EvWindow *window)
                          window);
        fullscreen_set_timeout (window);
 
+       totem_scrsaver_disable (window->priv->screensaver);
+
        if (!ev_window_is_empty (window))
                ev_metadata_manager_set_boolean (window->priv->uri, "presentation", TRUE);
 }
@@ -2542,6 +2570,8 @@ ev_window_stop_presentation (EvWindow *window)
                                              window);
        fullscreen_clear_timeout (window);
 
+       totem_scrsaver_enable (window->priv->screensaver);
+
        if (!ev_window_is_empty (window))
                ev_metadata_manager_set_boolean (window->priv->uri, "presentation", FALSE);
 }
@@ -3060,6 +3090,7 @@ ev_window_dual_mode_changed_cb (EvView *view, GParamSpec *pspec, EvWindow *ev_wi
 static char *
 build_comments_string (void)
 {
+#ifdef ENABLE_PDF
        PopplerBackend backend;
        const char *backend_name;
        const char *version;
@@ -3081,6 +3112,9 @@ build_comments_string (void)
        return g_strdup_printf (_("PostScript and PDF File Viewer.\n"
                                  "Using poppler %s (%s)"),
                                version, backend_name);
+#else
+       return g_strdup_printf (_("Document Viewer."));
+#endif
 }
 
 static void
@@ -3138,7 +3172,7 @@ ev_window_cmd_help_about (GtkAction *action, EvWindow *ev_window)
                "name", _("Evince"),
                "version", VERSION,
                "copyright",
-               _("\xc2\xa9 1996-2005 The Evince authors"),
+               _("\xc2\xa9 1996-2007 The Evince authors"),
                "license", license_trans,
                "website", "http://www.gnome.org/projects/evince",
                "comments", comments,
@@ -3570,6 +3604,11 @@ ev_window_dispose (GObject *object)
                priv->dest = NULL;
        }
 
+       if (priv->history) {
+               g_object_unref (priv->history);
+               priv->history = NULL;
+       }
+
        if (priv->fullscreen_timeout_id) {
                g_source_remove (priv->fullscreen_timeout_id);
                priv->fullscreen_timeout_id = 0;
@@ -3638,9 +3677,9 @@ static const GtkActionEntry entries[] = {
          G_CALLBACK (ev_window_cmd_edit_find_previous) },
         { "EditToolbar", NULL, N_("T_oolbar"), NULL, NULL,
           G_CALLBACK (ev_window_cmd_edit_toolbar) },
-       { "EditRotateLeft", "object-rotate-left", N_("Rotate _Left"), NULL, NULL,
+       { "EditRotateLeft", EV_STOCK_ROTATE_LEFT, N_("Rotate _Left"), NULL, NULL,
          G_CALLBACK (ev_window_cmd_edit_rotate_left) },
-       { "EditRotateRight", "object-rotate-right", N_("Rotate _Right"), NULL, NULL,
+       { "EditRotateRight", EV_STOCK_ROTATE_RIGHT, N_("Rotate _Right"), NULL, NULL,
          G_CALLBACK (ev_window_cmd_edit_rotate_right) },
 
         /* View menu */
@@ -3850,6 +3889,17 @@ register_custom_actions (EvWindow *window, GtkActionGroup *group)
                          G_CALLBACK (zoom_control_changed_cb), window);
        gtk_action_group_add_action (group, action);
        g_object_unref (action);
+
+       action = g_object_new (EV_TYPE_NAVIGATION_ACTION,
+                              "name", NAVIGATION_ACTION,
+                              "label", _("Navigation"),
+                              "is_important", TRUE,
+                              "short_label", _("Back"),
+                              "stock_id", GTK_STOCK_GO_DOWN,
+                              "tooltip", _("Move across visited pages"),
+                              NULL);
+       gtk_action_group_add_action (group, action);
+       g_object_unref (action);
 }
 
 static void
@@ -4586,7 +4636,11 @@ ev_window_init (EvWindow *ev_window)
        g_signal_connect_swapped (G_OBJECT (ev_window->priv->view), "drag-data-received",
                                  G_CALLBACK (drag_data_received_cb),
                                  ev_window);
-       
+
+       /* Screensaver */
+
+       ev_window->priv->screensaver = totem_scrsaver_new ();
+
        /* Set it user interface params */
 
        ev_window_setup_recent (ev_window);