From b69134d4ad94bcf59ce305d62088487dbb7e727e Mon Sep 17 00:00:00 2001 From: Nickolay V. Shmyrev Date: Tue, 31 May 2005 14:36:02 +0000 Subject: Set page action entry width depending on labels width. Fix for 305202 --- diff --git a/ChangeLog b/ChangeLog index 0b64c9c..1ec00e8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2005-05-31 Nikolay V. Shmyrev + + * backend/ev-page-cache.c: (ev_page_cache_init), + (_ev_page_cache_new), (ev_page_cache_get_max_label_chars): + * backend/ev-page-cache.h: + * shell/ev-page-action.c: (page_changed_cb): + + Set page action entry width depending on labels width. Fix + for bug 305202. + 2005-05-31 Marco Pesenti Gritti * backend/ev-link.c: (ev_link_class_init): diff --git a/backend/ev-page-cache.c b/backend/ev-page-cache.c index 36adf93..ad0a1fa 100644 --- a/backend/ev-page-cache.c +++ b/backend/ev-page-cache.c @@ -20,6 +20,7 @@ struct _EvPageCache char *title; char **page_labels; + gint max_label_chars; gboolean has_labels; gboolean uniform; @@ -60,6 +61,7 @@ static void ev_page_cache_init (EvPageCache *page_cache) { page_cache->current_page = -1; + page_cache->max_label_chars = 0; } static void @@ -134,14 +136,19 @@ _ev_page_cache_new (EvDocument *document) ev_document_get_page_size (document, i, &page_width, &page_height); 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; + + if (page_cache->page_labels[i] != NULL) { + + page_cache->max_label_chars = MAX(page_cache->max_label_chars, + g_utf8_strlen (page_cache->page_labels[i], 256)); + if (!page_cache->has_labels) { + 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); + 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) { @@ -349,6 +356,13 @@ ev_page_cache_get_max_height_size (EvPageCache *page_cache, *height = page_cache->max_height_page_height * scale; } +gint +ev_page_cache_get_max_label_chars (EvPageCache *page_cache) +{ + g_return_val_if_fail (EV_IS_PAGE_CACHE (page_cache), 0); + + return page_cache->max_label_chars; +} gchar * ev_page_cache_get_page_label (EvPageCache *page_cache, diff --git a/backend/ev-page-cache.h b/backend/ev-page-cache.h index fc1111b..22557f1 100644 --- a/backend/ev-page-cache.h +++ b/backend/ev-page-cache.h @@ -47,6 +47,7 @@ void ev_page_cache_get_max_height_size (EvPageCache *page_cache, gfloat scale, gint *width, gint *height); +gint ev_page_cache_get_max_label_chars (EvPageCache *page_cache); char *ev_page_cache_get_page_label (EvPageCache *page_cache, gint page); gboolean ev_page_cache_has_nonnumeric_page_labels (EvPageCache *page_cache); diff --git a/shell/ev-page-action.c b/shell/ev-page-action.c index 864e5e3..b1c61e6 100644 --- a/shell/ev-page-action.c +++ b/shell/ev-page-action.c @@ -180,10 +180,16 @@ page_changed_cb (EvPageCache *page_cache, g_assert (proxy); if (page_cache != NULL && page >= 0) { + + gtk_entry_set_width_chars (GTK_ENTRY (proxy->entry), + CLAMP (ev_page_cache_get_max_label_chars (page_cache), + 4, 12)); + gchar *page_label = ev_page_cache_get_page_label (page_cache, page); gtk_entry_set_text (GTK_ENTRY (proxy->entry), page_label); gtk_editable_set_position (GTK_EDITABLE (proxy->entry), -1); g_free (page_label); + } else { gtk_entry_set_text (GTK_ENTRY (proxy->entry), ""); } -- cgit v0.9.1