From: Marco Pesenti Gritti Date: Sat, 16 Apr 2005 10:20:47 +0000 (+0000) Subject: Remove some assertions, documents can have 0 pages. Make initial current X-Git-Tag: EVINCE_0_2_1~46 X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=commitdiff_plain;h=94ba47eee644072736b10ef3fe2188043ade22dd;p=evince.git Remove some assertions, documents can have 0 pages. Make initial current 2005-04-16 Marco Pesenti Gritti * 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. --- diff --git a/ChangeLog b/ChangeLog index c18b42d9..c984d369 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,21 @@ +2005-04-16 Marco Pesenti Gritti + + * 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 * shell/ev-page-view.c: diff --git a/backend/ev-page-cache.c b/backend/ev-page-cache.c index 5a713dab..46ecbc17 100644 --- a/backend/ev-page-cache.c +++ b/backend/ev-page-cache.c @@ -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); diff --git a/shell/ev-page-action.c b/shell/ev-page-action.c index 4b559c5d..d122be45 100644 --- a/shell/ev-page-action.c +++ b/shell/ev-page-action.c @@ -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); diff --git a/shell/ev-window.c b/shell/ev-window.c index f64580ad..fdee542a 100644 --- a/shell/ev-window.c +++ b/shell/ev-window.c @@ -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);