]> www.fi.muni.cz Git - evince.git/commitdiff
Fix for 173185. Number of pages is simply "of ..." when there is no
authorNickolay V. Shmyrev <nshmyrev@src.gnome.org>
Thu, 28 Apr 2005 00:23:39 +0000 (00:23 +0000)
committerNickolay V. Shmyrev <nshmyrev@src.gnome.org>
Thu, 28 Apr 2005 00:23:39 +0000 (00:23 +0000)
page labels

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

index b689d1864afc7b93ade5e4a64271c19de1aa02ab..b6ac3953323cff35c6a02932a591878234834f89 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2005-04-28  Nickolay V. Shmyrev  <nshmyrev@yandex.ru>
+
+       * 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  <nshmyrev@yandex.ru>
 
        * shell/ev-page-action.c: (ev_page_action_dispose):
index 6e559cb30929ca8a4bd22d6444c8b96daac20b16..8fb8bcd17f6b4e6b189eece16653dfe578d57afa 100644 (file)
@@ -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)
index 96a1a5f9579d39b156aab0112d87928a679a06ae..6b9db536a658f69b0405aa262a11f475137a6424 100644 (file)
@@ -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);
index e378d306003f8d0deb26f01b024b48f5c7b7d2c2..78e25700a38292cd5ab9debb3df6e341586b9e87 100644 (file)
@@ -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);
 }