From: Carlos Garcia Campos Date: Thu, 20 Aug 2009 10:35:08 +0000 (+0200) Subject: Move ev_page_cache_check_dimensions() to EvDocument X-Git-Tag: EVINCE_2_29_1~101 X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=commitdiff_plain;h=8c149ccd2a3cced2cd0a676ad6f7b8d33fd98404;p=evince.git Move ev_page_cache_check_dimensions() to EvDocument --- diff --git a/libdocument/ev-document.c b/libdocument/ev-document.c index c2c73aa4..5c63b25f 100644 --- a/libdocument/ev-document.c +++ b/libdocument/ev-document.c @@ -464,6 +464,14 @@ ev_document_get_max_page_size (EvDocument *document, *height = document->priv->max_height; } +gboolean +ev_document_check_dimensions (EvDocument *document) +{ + g_return_val_if_fail (EV_IS_DOCUMENT (document), FALSE); + + return (document->priv->max_width > 0 && document->priv->max_height > 0); +} + gint ev_document_get_max_label_len (EvDocument *document) { diff --git a/libdocument/ev-document.h b/libdocument/ev-document.h index 2ce1cf18..608e90fe 100644 --- a/libdocument/ev-document.h +++ b/libdocument/ev-document.h @@ -139,6 +139,7 @@ gboolean ev_document_is_page_size_uniform (EvDocument *document); void ev_document_get_max_page_size (EvDocument *document, gdouble *width, gdouble *height); +gboolean ev_document_check_dimensions (EvDocument *document); gint ev_document_get_max_label_len (EvDocument *document); gboolean ev_document_has_text_page_labels (EvDocument *document); gboolean ev_document_find_page_by_label (EvDocument *document, diff --git a/libview/ev-page-cache.c b/libview/ev-page-cache.c index 231af3b1..ab468b93 100644 --- a/libview/ev-page-cache.c +++ b/libview/ev-page-cache.c @@ -207,17 +207,6 @@ ev_page_cache_new (EvDocument *document) return page_cache; } -gboolean -ev_page_cache_check_dimensions (EvPageCache *page_cache) -{ - gdouble document_width, document_height; - - ev_document_get_max_page_size (page_cache->document, - &document_width, &document_height); - - return (document_width > 0 && document_height > 0); -} - gint ev_page_cache_get_current_page (EvPageCache *page_cache) { diff --git a/libview/ev-page-cache.h b/libview/ev-page-cache.h index d51707a1..1c3629db 100644 --- a/libview/ev-page-cache.h +++ b/libview/ev-page-cache.h @@ -68,8 +68,6 @@ gboolean ev_page_cache_set_page_label (EvPageCache *page_cache, EvPageCache *ev_page_cache_get (EvDocument *document); -gboolean ev_page_cache_check_dimensions (EvPageCache *page_cache); - G_END_DECLS #endif /* __EV_PAGE_CACHE_H__ */ diff --git a/shell/ev-sidebar-thumbnails.c b/shell/ev-sidebar-thumbnails.c index 4e8c5b2f..7137fa1c 100644 --- a/shell/ev-sidebar-thumbnails.c +++ b/shell/ev-sidebar-thumbnails.c @@ -808,7 +808,7 @@ ev_sidebar_thumbnails_set_document (EvSidebarPage *sidebar_page, if (!EV_IS_DOCUMENT_THUMBNAILS (document) || ev_document_get_n_pages (document) <= 0 || - !ev_page_cache_check_dimensions (priv->page_cache)) { + !ev_document_check_dimensions (document)) { return; } diff --git a/shell/ev-window.c b/shell/ev-window.c index 13321229..078cb9c2 100644 --- a/shell/ev-window.c +++ b/shell/ev-window.c @@ -1158,7 +1158,7 @@ ev_window_refresh_window_thumbnail (EvWindow *ev_window, int rotation) if (!EV_IS_DOCUMENT_THUMBNAILS (document) || ev_document_get_n_pages (document) <= 0 || - !ev_page_cache_check_dimensions (ev_window->priv->page_cache)) { + !ev_document_check_dimensions (document)) { return; } @@ -1239,16 +1239,16 @@ ev_window_set_document (EvWindow *ev_window, EvDocument *document) /* Restart the current page */ page = CLAMP (ev_link_dest_get_page (ev_window->priv->dest), 0, - ev_document_get_n_pages (ev_window->priv->document) - 1); + ev_document_get_n_pages (document) - 1); ev_page_cache_set_current_page (ev_window->priv->page_cache, page); g_object_unref (ev_window->priv->dest); ev_window->priv->dest = NULL; } - if (ev_document_get_n_pages (ev_window->priv->document) <= 0) { + if (ev_document_get_n_pages (document) <= 0) { ev_window_warning_message (ev_window, "%s", _("The document contains no pages")); - } else if (!ev_page_cache_check_dimensions (ev_window->priv->page_cache)) { + } else if (!ev_document_check_dimensions (document)) { ev_window_warning_message (ev_window, "%s", _("The document contains only empty pages")); } else {