From: Nickolay V. Shmyrev Date: Thu, 28 Apr 2005 00:23:39 +0000 (+0000) Subject: Fix for 173185. Number of pages is simply "of ..." when there is no X-Git-Tag: EVINCE_0_3_0~20 X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=commitdiff_plain;h=0616c7d07421dc271f0a1b9a10de9e7c7d44582d;p=evince.git Fix for 173185. Number of pages is simply "of ..." when there is no page labels --- diff --git a/ChangeLog b/ChangeLog index b689d186..b6ac3953 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2005-04-28 Nickolay V. Shmyrev + + * backend/ev-page-cache.c: (_ev_page_cache_new), + (ev_page_cache_set_page_label), + (ev_page_cache_has_nonnumeric_page_labels): + * backend/ev-page-cache.h: + * shell/ev-page-action.c: (update_pages_label): + + If all page labels are numeric, fallback to default + way to display number of pages. See bug 173185. + 2005-04-28 Nickolay V. Shmyrev * shell/ev-page-action.c: (ev_page_action_dispose): diff --git a/backend/ev-page-cache.c b/backend/ev-page-cache.c index 6e559cb3..8fb8bcd1 100644 --- a/backend/ev-page-cache.c +++ b/backend/ev-page-cache.c @@ -19,8 +19,10 @@ struct _EvPageCache int n_pages; char *title; char **page_labels; - + + gboolean has_labels; gboolean uniform; + double uniform_width; double uniform_height; @@ -107,6 +109,7 @@ _ev_page_cache_new (EvDocument *document) /* Assume all pages are the same size until proven otherwise */ page_cache->uniform = TRUE; + page_cache->has_labels = FALSE; page_cache->n_pages = ev_document_get_n_pages (document); page_cache->page_labels = g_new0 (char *, page_cache->n_pages); page_cache->max_width_page_width = 0; @@ -125,9 +128,19 @@ _ev_page_cache_new (EvDocument *document) for (i = 0; i < page_cache->n_pages; i++) { double page_width = 0; double page_height = 0; - + ev_document_get_page_size (document, i, &page_width, &page_height); - page_cache->page_labels[i] = ev_document_get_page_label (document, i); + + page_cache->page_labels[i] = ev_document_get_page_label (document, i); + + if (!page_cache->has_labels && page_cache->page_labels[i] != NULL) { + gchar *expected_label; + + expected_label = g_strdup_printf ("%d", i + 1); + if (strcmp (expected_label, page_cache->page_labels[i])) + page_cache->has_labels = TRUE; + g_free (expected_label); + } if (page_width > page_cache->max_width_page_width) { page_cache->max_width_page_width = page_width; @@ -223,7 +236,7 @@ ev_page_cache_set_page_label (EvPageCache *page_cache, g_return_val_if_fail (page_label != NULL, FALSE); /* First, look for a literal label match */ - for (i = 0; i < page_cache->n_pages; i ++) { + for (i = 0; i < page_cache->n_pages && page_cache->has_labels; i ++) { if (page_cache->page_labels[i] != NULL && ! strcmp (page_label, page_cache->page_labels[i])) { ev_page_cache_set_current_page (page_cache, i); @@ -346,6 +359,12 @@ ev_page_cache_get_page_label (EvPageCache *page_cache, return g_strdup (page_cache->page_labels[page]); } +gboolean +ev_page_cache_has_nonnumeric_page_labels (EvPageCache *page_cache) +{ + g_return_val_if_fail (EV_IS_PAGE_CACHE (page_cache), FALSE); + return page_cache->has_labels; +} gboolean ev_page_cache_next_page (EvPageCache *page_cache) diff --git a/backend/ev-page-cache.h b/backend/ev-page-cache.h index 96a1a5f9..6b9db536 100644 --- a/backend/ev-page-cache.h +++ b/backend/ev-page-cache.h @@ -49,6 +49,7 @@ void ev_page_cache_get_max_height_size (EvPageCache *page_cache, gint *height); char *ev_page_cache_get_page_label (EvPageCache *page_cache, gint page); +gboolean ev_page_cache_has_nonnumeric_page_labels (EvPageCache *page_cache); /* Navigation */ gint ev_page_cache_get_current_page (EvPageCache *page_cache); diff --git a/shell/ev-page-action.c b/shell/ev-page-action.c index e378d306..78e25700 100644 --- a/shell/ev-page-action.c +++ b/shell/ev-page-action.c @@ -103,7 +103,11 @@ update_pages_label (EvPageActionWidget *proxy, gint n_pages; n_pages = page_cache ? ev_page_cache_get_n_pages (page_cache) : 0; - label_text = g_strdup_printf (_("(%d of %d)"), page + 1, n_pages); + if (ev_page_cache_has_nonnumeric_page_labels (page_cache)) { + label_text = g_strdup_printf (_("(%d of %d)"), page + 1, n_pages); + } else { + label_text = g_strdup_printf (_("of %d"), n_pages); + } gtk_label_set_text (GTK_LABEL (proxy->label), label_text); g_free (label_text); }