]> www.fi.muni.cz Git - evince.git/blobdiff - shell/ev-window.c
Removed
[evince.git] / shell / ev-window.c
index ca4ab5853f1774bf4815bf1d713ecba06794fd8d..94477dcef67931447c7ded4b50ac9c96b35518e9 100644 (file)
 #include "ev-jobs.h"
 #include "ev-sidebar-page.h"
 #include "eggfindbar.h"
-
-#ifndef HAVE_GTK_RECENT
-#include "egg-recent-view-uimanager.h"
-#include "egg-recent-view.h"
-#include "egg-recent-model.h"
-#endif
-
 #include "egg-toolbar-editor.h"
 #include "egg-editable-toolbar.h"
 #include "egg-toolbars-model.h"
@@ -145,11 +138,9 @@ struct _EvWindowPrivate {
        GtkActionGroup   *action_group;
        GtkActionGroup   *view_popup_action_group;
        GtkActionGroup   *attachment_popup_action_group;
-#ifdef HAVE_GTK_RECENT
        GtkRecentManager *recent_manager;
        GtkActionGroup   *recent_action_group;
        guint             recent_ui_id;
-#endif
        GtkUIManager     *ui_manager;
 
        /* Fullscreen mode */
@@ -183,9 +174,6 @@ struct _EvWindowPrivate {
        EvPageCache *page_cache;
        EvWindowPageMode page_mode;
        EvWindowTitle *title;
-#ifndef HAVE_GTK_RECENT
-       EggRecentViewUIManager *recent_view;
-#endif
 
        EvJob *load_job;
        EvJob *thumbnail_job;
@@ -1063,6 +1051,36 @@ ev_window_set_icon_from_thumbnail (EvJobThumbnail *job,
        ev_window_clear_thumbnail_job (ev_window);
 }
 
+static void
+ev_window_refresh_window_thumbnail (EvWindow *ev_window, int rotation)
+{
+       
+       EvRenderContext *rc;
+       gint page_width, page_height;
+       gdouble scale;
+       EvDocument *document = ev_window->priv->document;
+       
+       if (!EV_IS_DOCUMENT_THUMBNAILS (document)) {
+               return;
+       }
+       
+       ev_window_clear_thumbnail_job (ev_window);
+       
+       ev_page_cache_get_size (ev_window->priv->page_cache,
+                               0, 0, 1.0,
+                               &page_width, &page_height);
+       scale = (gdouble)128 / (gdouble)page_width;
+       
+       rc = ev_render_context_new (rotation, 0, scale);
+       
+       ev_window->priv->thumbnail_job = ev_job_thumbnail_new (document, rc);
+       g_signal_connect (ev_window->priv->thumbnail_job, "finished",
+                         G_CALLBACK (ev_window_set_icon_from_thumbnail),
+                         ev_window);
+       ev_job_queue_add_job (EV_JOB (ev_window->priv->thumbnail_job), EV_JOB_PRIORITY_LOW);
+       g_object_unref (rc);
+}
+
 static gboolean
 ev_window_setup_document (EvWindow *ev_window)
 {
@@ -1077,27 +1095,8 @@ ev_window_setup_document (EvWindow *ev_window)
                                         G_CALLBACK (find_changed_cb),  
                                         ev_window, 0);
        }
-
-       if (EV_IS_DOCUMENT_THUMBNAILS (document)) {
-               EvRenderContext *rc;
-               gint page_width, page_height;
-               gdouble scale;
-
-               ev_window_clear_thumbnail_job (ev_window);
-               
-               ev_page_cache_get_size (ev_window->priv->page_cache,
-                                       0, 0, 1.0,
-                                       &page_width, &page_height);
-               scale = (gdouble)128 / (gdouble)page_width;
-
-               rc = ev_render_context_new (0, 0, scale);
-               ev_window->priv->thumbnail_job = ev_job_thumbnail_new (document, rc);
-               g_signal_connect (ev_window->priv->thumbnail_job, "finished",
-                                 G_CALLBACK (ev_window_set_icon_from_thumbnail),
-                                 ev_window);
-               ev_job_queue_add_job (EV_JOB (ev_window->priv->thumbnail_job), EV_JOB_PRIORITY_LOW);
-               g_object_unref (rc);
-       }
+       
+       ev_window_refresh_window_thumbnail (ev_window, 0);
 
        ev_window_set_page_mode (ev_window, PAGE_MODE_DOCUMENT);
        ev_window_title_set_document (ev_window->priv->title, document);
@@ -1696,7 +1695,6 @@ ev_window_cmd_file_open_copy (GtkAction *action, EvWindow *window)
        g_object_unref (dest);
 }
 
-#ifdef HAVE_GTK_RECENT
 static void
 ev_window_cmd_recent_file_activate (GtkAction     *action,
                                    EvWindow      *window)
@@ -1714,43 +1712,13 @@ ev_window_cmd_recent_file_activate (GtkAction     *action,
                                         NULL, 0, FALSE, NULL, 
                                         GDK_CURRENT_TIME);
 }
-#else
-static void
-ev_window_cmd_recent_file_activate (GtkAction *action,
-                                   EvWindow *ev_window)
-{
-       char *uri;
-       EggRecentItem *item;
-
-       item = egg_recent_view_uimanager_get_item (ev_window->priv->recent_view,
-                                                  action);
-
-       uri = egg_recent_item_get_uri (item);
-
-       ev_application_open_uri_at_dest (EV_APP, uri,
-                                        gtk_window_get_screen (GTK_WINDOW (ev_window)),
-                                        NULL, 0, FALSE, NULL,
-                                        GDK_CURRENT_TIME);
-       
-       g_free (uri);
-}
-#endif /* HAVE_GTK_RECENT */
 
 static void
 ev_window_add_recent (EvWindow *window, const char *filename)
 {
-#ifdef HAVE_GTK_RECENT
        gtk_recent_manager_add_item (window->priv->recent_manager, filename);
-#else
-       EggRecentItem *item;
-
-       item = egg_recent_item_new_from_uri (filename);
-       egg_recent_item_add_group (item, "Evince");
-       egg_recent_model_add_full (ev_application_get_recent_model (EV_APP), item);
-#endif /* HAVE_GTK_RECENT */
 }
 
-#ifdef HAVE_GTK_RECENT
 static gint
 compare_recent_items (GtkRecentInfo *a, GtkRecentInfo *b)
 {
@@ -1775,7 +1743,6 @@ compare_recent_items (GtkRecentInfo *a, GtkRecentInfo *b)
 
        return 0;
 }
-#endif /* HAVE_GTK_RECENT */
 
 /*
  * Doubles underscore to avoid spurious menu accels.
@@ -1819,7 +1786,6 @@ ev_window_get_recent_file_label (gint index, const gchar *filename)
 static void
 ev_window_setup_recent (EvWindow *ev_window)
 {
-#ifdef HAVE_GTK_RECENT
        GList        *items, *l;
        guint         n_items = 0;
        const gchar  *evince = g_get_application_name ();
@@ -1894,22 +1860,6 @@ ev_window_setup_recent (EvWindow *ev_window)
        
        g_list_foreach (items, (GFunc) gtk_recent_info_unref, NULL);
        g_list_free (items);
-#else /* HAVE_GTK_RECENT */
-       ev_window->priv->recent_view = egg_recent_view_uimanager_new (ev_window->priv->ui_manager,
-                                                                     "/MainMenu/FileMenu/RecentFilesMenu",
-                                                                     G_CALLBACK (ev_window_cmd_recent_file_activate), 
-                                                                     ev_window);       
-
-        egg_recent_view_uimanager_show_icons (EGG_RECENT_VIEW_UIMANAGER (ev_window->priv->recent_view), FALSE);
-
-       egg_recent_view_set_model (EGG_RECENT_VIEW (ev_window->priv->recent_view),
-                                  ev_application_get_recent_model (EV_APP));
-
-       egg_recent_view_uimanager_set_trailing_sep (ev_window->priv->recent_view, TRUE);
-       
-       g_signal_connect (ev_window->priv->recent_view, "activate",
-                       G_CALLBACK (ev_window_cmd_recent_file_activate), ev_window);
-#endif /* HAVE_GTK_RECENT */
 }
 
 static gint
@@ -2349,7 +2299,17 @@ ev_window_print_dialog_response_cb (GtkDialog *dialog,
                        ranges = g_memdup (page_range, n_ranges * sizeof (GtkPageRange));
        }
                break;
-       default:
+       case GTK_PRINT_PAGES_ALL: {
+               gint n_pages;
+
+               n_pages = ev_page_cache_get_n_pages (ev_page_cache_get (window->priv->document));
+               
+               ranges = g_new0 (EvPrintRange, 1);
+
+               ranges->start = 0;
+               ranges->end = n_pages - 1;
+               n_ranges = 1;
+       }
                break;
        }
 
@@ -3626,6 +3586,7 @@ ev_window_rotation_changed_cb (EvView *view, GParamSpec *pspec, EvWindow *window
 
        ev_sidebar_thumbnails_refresh (EV_SIDEBAR_THUMBNAILS (window->priv->sidebar_thumbs),
                                       rotation);
+       ev_window_refresh_window_thumbnail (window, rotation);
 }
 
 static void
@@ -4103,7 +4064,6 @@ ev_window_dispose (GObject *object)
                priv->attachment_popup_action_group = NULL;
        }
 
-#ifdef HAVE_GTK_RECENT
        if (priv->recent_action_group) {
                g_object_unref (priv->recent_action_group);
                priv->recent_action_group = NULL;
@@ -4117,12 +4077,6 @@ ev_window_dispose (GObject *object)
        }
 
        priv->recent_ui_id = 0;
-#else
-       if (priv->recent_view) {
-               g_object_unref (priv->recent_view);
-               priv->recent_view = NULL;
-       }
-#endif /* HAVE_GTK_RECENT */
 
        if (priv->page_cache) {
                g_signal_handlers_disconnect_by_func (priv->page_cache, page_changed_cb, window);
@@ -4289,11 +4243,7 @@ static const GtkActionEntry entries[] = {
         /* Edit menu */
         { "EditCopy", GTK_STOCK_COPY, NULL, "<control>C", NULL,
           G_CALLBACK (ev_window_cmd_edit_copy) },
-#ifdef HAVE_GTK_RECENT
        { "EditSelectAll", GTK_STOCK_SELECT_ALL, N_("Select _All"), "<control>A", NULL,
-#else
-       { "EditSelectAll", NULL, N_("Select _All"), "<control>A", NULL,
-#endif /* HAVE_GTK_RECENT */
          G_CALLBACK (ev_window_cmd_edit_select_all) },
         { "EditFind", GTK_STOCK_FIND, N_("_Find..."), "<control>F",
           N_("Find a word or phrase in the document"),
@@ -4415,7 +4365,7 @@ static const GtkToggleActionEntry toggle_entries[] = {
         { "ViewFullscreen", GTK_STOCK_FULLSCREEN, N_("_Fullscreen"), "F11",
           N_("Expand the window to fill the screen"),
           G_CALLBACK (ev_window_cmd_view_fullscreen) },
-        { "ViewPresentation", EV_STOCK_RUN_PRESENTATION, N_("_Presentation"), "F5",
+        { "ViewPresentation", EV_STOCK_RUN_PRESENTATION, N_("Pre_sentation"), "F5",
           N_("Run document as a presentation"),
           G_CALLBACK (ev_window_cmd_view_presentation) },
         { "ViewBestFit", EV_STOCK_ZOOM_PAGE, N_("_Best Fit"), NULL,
@@ -4706,45 +4656,41 @@ launch_action (EvWindow *window, EvLinkAction *action)
           allowing to launch executables is a good idea though. -- marco */
 }
 
-static gboolean
-uri_is_valid (const gchar *uri)
-{
-       gchar *p = (gchar *) uri;
-       
-       if (!p || !g_ascii_isalpha (*p))
-               return FALSE;
-       
-       p++;
-       while (g_ascii_isalnum (*p))
-               p++;
-
-       return (g_ascii_strncasecmp (p, "://", strlen ("://")) == 0);
-}
-
 static void
 launch_external_uri (EvWindow *window, EvLinkAction *action)
 {
        const gchar *uri = ev_link_action_get_uri (action);
-       
-       if (!uri_is_valid (uri)) {
-               GtkWidget *dialog;
+       GnomeVFSResult result = gnome_vfs_url_show (uri);
+       GtkWidget *dialog;
+       gchar* message = NULL;
 
+       switch(result) {
+               case GNOME_VFS_OK:
+                       break;
+               case GNOME_VFS_ERROR_BAD_PARAMETERS:
+                       message = _("Invalid URI: “%s”");
+                       break;
+               case GNOME_VFS_ERROR_NOT_SUPPORTED:
+                       message = _("Unsupported URI: “%s”");
+                       break;
+               default:
+                       message = _("Unknown error");
+       }
+       if(message) {
                dialog = gtk_message_dialog_new (GTK_WINDOW (window),
                                                 GTK_DIALOG_DESTROY_WITH_PARENT,
                                                 GTK_MESSAGE_ERROR,
                                                 GTK_BUTTONS_CLOSE,
                                                 _("Unable to open external link"));
                gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
-                                                         _("Invalid URI: “%s”"), uri);
+                                                         message, uri);
                g_signal_connect (dialog, "response",
                                  G_CALLBACK (gtk_widget_destroy),
                                  NULL);
                gtk_widget_show (dialog);
 
-               return;
        }
-       
-       gnome_vfs_url_show (uri);
+       return;
 }
 
 static void
@@ -5190,7 +5136,6 @@ ev_window_init (EvWindow *ev_window)
                g_error_free (error);
        }
        
-#ifdef HAVE_GTK_RECENT
 #if GTK_CHECK_VERSION(2,11,4)
        ev_window->priv->recent_manager = gtk_recent_manager_get_default ();
 #else
@@ -5204,7 +5149,6 @@ ev_window_init (EvWindow *ev_window)
                                  "changed",
                                  G_CALLBACK (ev_window_setup_recent),
                                  ev_window);
-#endif /* HAVE_GTK_RECENT */
        
        ev_window->priv->menubar =
                 gtk_ui_manager_get_widget (ev_window->priv->ui_manager,