]> www.fi.muni.cz Git - evince.git/blobdiff - shell/ev-window.c
Rework border calculation, so that I can more easily disable it. Code
[evince.git] / shell / ev-window.c
index 734846ffc8aace25c5d620be9ac8530b08e04844..fdee542a739c593563c1555423e28a66d5ea6958 100644 (file)
@@ -182,45 +182,44 @@ update_action_sensitivity (EvWindow *ev_window)
 {
        EvDocument *document;
        EvWindowPageMode page_mode;
 {
        EvDocument *document;
        EvWindowPageMode page_mode;
-       EvView *view;
+       gboolean sensitive, has_pages = FALSE, has_document;
+       int n_pages = 0, page = -1;
 
        document = ev_window->priv->document;
        page_mode = ev_window->priv->page_mode;
 
        document = ev_window->priv->document;
        page_mode = ev_window->priv->page_mode;
-       view = EV_VIEW (ev_window->priv->view);
+       has_document = document != NULL;
+       if (has_document && ev_window->priv->page_cache) {
+               page = ev_page_cache_get_current_page (ev_window->priv->page_cache);
+               n_pages = ev_page_cache_get_n_pages (ev_window->priv->page_cache);
+               has_pages = has_document && n_pages > 0;
+       }
 
        /* File menu */
        /* "FileOpen": always sensitive */
 
        /* File menu */
        /* "FileOpen": always sensitive */
-       set_action_sensitive (ev_window, "FileSaveAs", document!=NULL);
-       set_action_sensitive (ev_window, "FilePrint", document!=NULL);
+       set_action_sensitive (ev_window, "FileSaveAs", has_document);
+       set_action_sensitive (ev_window, "FilePrint", has_pages);
        /* "FileCloseWindow": always sensitive */
 
         /* Edit menu */
        /* "FileCloseWindow": always sensitive */
 
         /* Edit menu */
-       set_action_sensitive (ev_window, "EditCopy", document!=NULL);
-       set_action_sensitive (ev_window, "EditSelectAll", document!=NULL);
-
-       if (document)
-               set_action_sensitive (ev_window, "EditFind", EV_IS_DOCUMENT_FIND (document));
-       else
-               set_action_sensitive (ev_window, "EditFind", FALSE);
 
 
+       sensitive = has_pages && ev_document_can_get_text (document);
+       set_action_sensitive (ev_window, "EditCopy", sensitive);
+       set_action_sensitive (ev_window, "EditSelectAll", sensitive);
+       set_action_sensitive (ev_window, "EditFind",
+                             has_pages && EV_IS_DOCUMENT_FIND (document));
        set_action_sensitive (ev_window, "EditFindNext",
                              ev_view_can_find_next (EV_VIEW (ev_window->priv->view)));
 
         /* View menu */
        set_action_sensitive (ev_window, "EditFindNext",
                              ev_view_can_find_next (EV_VIEW (ev_window->priv->view)));
 
         /* View menu */
-       set_action_sensitive (ev_window, "ViewZoomIn", document!=NULL);
-       set_action_sensitive (ev_window, "ViewZoomOut", document!=NULL);
-       set_action_sensitive (ev_window, "ViewNormalSize", document!=NULL);
-       set_action_sensitive (ev_window, "ViewBestFit", document!=NULL);
-       set_action_sensitive (ev_window, "ViewPageWidth", document!=NULL);
-       set_action_sensitive (ev_window, "ViewReload", document!=NULL);
+       set_action_sensitive (ev_window, "ViewZoomIn", has_pages);
+       set_action_sensitive (ev_window, "ViewZoomOut", has_pages);
+       set_action_sensitive (ev_window, "ViewNormalSize", has_pages);
+       set_action_sensitive (ev_window, "ViewBestFit", has_pages);
+       set_action_sensitive (ev_window, "ViewPageWidth", has_pages);
+       set_action_sensitive (ev_window, "ViewReload", has_pages);
 
         /* Go menu */
        if (document) {
 
         /* Go menu */
        if (document) {
-               int n_pages;
-               int page;
-               page = ev_page_cache_get_current_page (ev_window->priv->page_cache);
-               n_pages = ev_page_cache_get_n_pages (ev_window->priv->page_cache);
-
                set_action_sensitive (ev_window, "GoPreviousPage", page > 0);
                set_action_sensitive (ev_window, "GoNextPage", page < n_pages - 1);
                set_action_sensitive (ev_window, "GoFirstPage", page > 0);
                set_action_sensitive (ev_window, "GoPreviousPage", page > 0);
                set_action_sensitive (ev_window, "GoNextPage", page < n_pages - 1);
                set_action_sensitive (ev_window, "GoFirstPage", page > 0);
@@ -245,7 +244,7 @@ update_action_sensitivity (EvWindow *ev_window)
        /* "HelpAbout": always sensitive */
 
        /* Toolbar-specific actions: */
        /* "HelpAbout": always sensitive */
 
        /* Toolbar-specific actions: */
-       set_action_sensitive (ev_window, PAGE_SELECTOR_ACTION, document!=NULL);
+       set_action_sensitive (ev_window, PAGE_SELECTOR_ACTION, has_pages);
 }
 
 static void
 }
 
 static void
@@ -500,14 +499,6 @@ update_window_title (EvDocument *document, GParamSpec *pspec, EvWindow *ev_windo
        g_free (title);
 }
 
        g_free (title);
 }
 
-/* This function assumes that ev_window just had ev_window->document set.
- */
-static gboolean
-document_supports_sidebar (EvDocument *document)
-{
-       return (EV_IS_DOCUMENT_THUMBNAILS (document) || (EV_IS_DOCUMENT_LINKS (document)));
-}
-
 static void
 hide_sidebar_and_actions (EvWindow *ev_window)
 {
 static void
 hide_sidebar_and_actions (EvWindow *ev_window)
 {
@@ -562,12 +553,14 @@ ev_window_setup_document (EvWindow *ev_window)
 
        ev_window_set_page_mode (ev_window, PAGE_MODE_SINGLE_PAGE);
 
 
        ev_window_set_page_mode (ev_window, PAGE_MODE_SINGLE_PAGE);
 
-       if (document_supports_sidebar (document)) 
+       if (ev_sidebar_supports_document (sidebar, document)) 
                ev_sidebar_set_document (sidebar, document);
        else
                hide_sidebar_and_actions (ev_window);
 
                ev_sidebar_set_document (sidebar, document);
        else
                hide_sidebar_and_actions (ev_window);
 
-       ev_view_set_document (view, document);
+       if (ev_page_cache_get_n_pages (ev_window->priv->page_cache) > 0) {
+               ev_view_set_document (view, document);
+       }
 
        update_window_title (document, NULL, ev_window);
        action = gtk_action_group_get_action (ev_window->priv->action_group, PAGE_SELECTOR_ACTION);
 
        update_window_title (document, NULL, ev_window);
        action = gtk_action_group_get_action (ev_window->priv->action_group, PAGE_SELECTOR_ACTION);
@@ -2246,10 +2239,27 @@ set_action_properties (GtkActionGroup *action_group)
        /*translators: this is the label for toolbar button*/
        g_object_set (action, "short_label", _("Previous"), NULL);
        g_object_set (action, "is-important", TRUE, NULL);
        /*translators: this is the label for toolbar button*/
        g_object_set (action, "short_label", _("Previous"), NULL);
        g_object_set (action, "is-important", TRUE, NULL);
+
        action = gtk_action_group_get_action (action_group, "GoNextPage");
        action = gtk_action_group_get_action (action_group, "GoNextPage");
-       /*translators: this is the label for toolbar button*/
        g_object_set (action, "is-important", TRUE, NULL);
        g_object_set (action, "is-important", TRUE, NULL);
+       /*translators: this is the label for toolbar button*/
        g_object_set (action, "short_label", _("Next"), NULL);
        g_object_set (action, "short_label", _("Next"), NULL);
+
+       action = gtk_action_group_get_action (action_group, "ViewZoomIn");
+       /*translators: this is the label for toolbar button*/
+       g_object_set (action, "short_label", _("Zoom In"), NULL);
+       action = gtk_action_group_get_action (action_group, "ViewZoomIn");
+
+       action = gtk_action_group_get_action (action_group, "ViewZoomOut");
+       /*translators: this is the label for toolbar button*/
+       g_object_set (action, "short_label", _("Zoom Out"), NULL);
+       action = gtk_action_group_get_action (action_group, "ViewZoomIn");
+
+       action = gtk_action_group_get_action (action_group, "ViewBestFit");
+       /*translators: this is the label for toolbar button*/
+       g_object_set (action, "short_label", _("Best Fit"), NULL);
+       action = gtk_action_group_get_action (action_group, "ViewZoomIn");
+
        action = gtk_action_group_get_action (action_group, "ViewPageWidth");
        /*translators: this is the label for toolbar button*/
        g_object_set (action, "short_label", _("Fit Width"), NULL);
        action = gtk_action_group_get_action (action_group, "ViewPageWidth");
        /*translators: this is the label for toolbar button*/
        g_object_set (action, "short_label", _("Fit Width"), NULL);