+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):
int n_pages;
char *title;
char **page_labels;
-
+
+ gboolean has_labels;
gboolean uniform;
+
double uniform_width;
double uniform_height;
/* 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;
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;
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);
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)
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);
}