]> www.fi.muni.cz Git - evince.git/commitdiff
Remove some assertions, documents can have 0 pages. Make initial current
authorMarco Pesenti Gritti <mpg@redhat.com>
Sat, 16 Apr 2005 10:20:47 +0000 (10:20 +0000)
committerMarco Pesenti Gritti <marco@src.gnome.org>
Sat, 16 Apr 2005 10:20:47 +0000 (10:20 +0000)
2005-04-16  Marco Pesenti Gritti <mpg@redhat.com>

        * backend/ev-page-cache.c: (ev_page_cache_init),
        (_ev_page_cache_new):

        Remove some assertions, documents can have 0 pages.
        Make initial current page -1.

        * shell/ev-page-action.c: (page_changed_cb):

        Show "" if current page is -1

        * shell/ev-window.c: (update_action_sensitivity),
        (ev_window_setup_document):

        When document has 0 pages do not set the view
        and make nearly everything insensitive.

ChangeLog
backend/ev-page-cache.c
shell/ev-page-action.c
shell/ev-window.c

index c18b42d969786c8f12d170639ed414198542408d..c984d3698c55eaae75d39e0bf81652c2adae69a2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2005-04-16  Marco Pesenti Gritti <mpg@redhat.com>
+
+       * backend/ev-page-cache.c: (ev_page_cache_init),
+       (_ev_page_cache_new):
+
+       Remove some assertions, documents can have 0 pages.
+       Make initial current page -1.
+
+       * shell/ev-page-action.c: (page_changed_cb):
+
+       Show "" if current page is -1
+
+       * shell/ev-window.c: (update_action_sensitivity),
+       (ev_window_setup_document):
+
+       When document has 0 pages do not set the view
+       and make nearly everything insensitive.
+
 2005-04-16  Nickolay V. Shmyrev  <nshmyrev@yandex.ru>
 
        * shell/ev-page-view.c:
index 5a713dab8bdb092a150f8b2d5005680cb007fc54..46ecbc170045e82b1fdb40eb239117d13ab5b60c 100644 (file)
@@ -51,7 +51,7 @@ G_DEFINE_TYPE (EvPageCache, ev_page_cache, G_TYPE_OBJECT)
 static void
 ev_page_cache_init (EvPageCache *page_cache)
 {
-       page_cache->current_page = 0;
+       page_cache->current_page = -1;
 }
 
 static void
@@ -141,11 +141,8 @@ _ev_page_cache_new (EvDocument *document)
        }
 
        /* make some sanity check assertions */
-       g_assert (page_cache->n_pages > 0);
        if (! page_cache->uniform)
                g_assert (page_cache->size_cache != NULL);
-       if (page_cache->uniform)
-               g_assert (page_cache->uniform_width > 0 && page_cache->uniform_height > 0);
 
        g_mutex_unlock (EV_DOC_MUTEX);
 
index 4b559c5d4bba96fa327437b6ce7bdbe8b629cd9f..d122be45906a4482f2edd9c917a4d74d4568ebe3 100644 (file)
@@ -100,7 +100,7 @@ page_changed_cb (EvPageCache        *page_cache,
 {
        g_assert (proxy);
        
-       if (page_cache != NULL) {
+       if (page_cache != NULL && page >= 0) {
                gchar *page_label = ev_page_cache_get_page_label (page_cache, page);
                gtk_entry_set_text (GTK_ENTRY (proxy->entry), page_label);
                gtk_editable_set_position (GTK_EDITABLE (proxy->entry), -1);
index f64580ad4aaf766b032f08bdc18890ae447fe215..fdee542a739c593563c1555423e28a66d5ea6958 100644 (file)
@@ -182,48 +182,44 @@ update_action_sensitivity (EvWindow *ev_window)
 {
        EvDocument *document;
        EvWindowPageMode page_mode;
-       EvView *view;
-       gboolean sensitive;
+       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;
-       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 */
-       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 */
 
-       sensitive = document && ev_document_can_get_text (document);
+       sensitive = has_pages && ev_document_can_get_text (document);
        set_action_sensitive (ev_window, "EditCopy", sensitive);
        set_action_sensitive (ev_window, "EditSelectAll", sensitive);
-
-       if (document)
-               set_action_sensitive (ev_window, "EditFind", EV_IS_DOCUMENT_FIND (document));
-       else
-               set_action_sensitive (ev_window, "EditFind", FALSE);
-
+       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, "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) {
-               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);
@@ -248,7 +244,7 @@ update_action_sensitivity (EvWindow *ev_window)
        /* "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
@@ -562,7 +558,9 @@ ev_window_setup_document (EvWindow *ev_window)
        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);