Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNickolay V. Shmyrev <nshmyrev@src.gnome.org>2005-04-28 00:23:39 (GMT)
committer Nickolay V. Shmyrev <nshmyrev@src.gnome.org>2005-04-28 00:23:39 (GMT)
commit0616c7d07421dc271f0a1b9a10de9e7c7d44582d (patch)
tree1e73feedb6c30572e7e357fb4645acc748287f3a
parenta154e22c19e8c654971c4fc06ddf106c30f47f87 (diff)
Fix for 173185. Number of pages is simply "of ..." when there is no
page labels
-rw-r--r--ChangeLog11
-rw-r--r--backend/ev-page-cache.c27
-rw-r--r--backend/ev-page-cache.h1
-rw-r--r--shell/ev-page-action.c6
4 files changed, 40 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index b689d18..b6ac395 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
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):
* shell/ev-view.c: (view_update_range_and_current_page):
* shell/ev-window.c: (ev_window_dispose):
diff --git a/backend/ev-page-cache.c b/backend/ev-page-cache.c
index 6e559cb..8fb8bcd 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 96a1a5f..6b9db53 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 e378d30..78e2570 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);
}