]> www.fi.muni.cz Git - evince.git/commitdiff
Set page action entry width depending on labels width. Fix for 305202
authorNickolay V. Shmyrev <nshmyrev@src.gnome.org>
Tue, 31 May 2005 14:36:02 +0000 (14:36 +0000)
committerNickolay V. Shmyrev <nshmyrev@src.gnome.org>
Tue, 31 May 2005 14:36:02 +0000 (14:36 +0000)
ChangeLog
backend/ev-page-cache.c
backend/ev-page-cache.h
shell/ev-page-action.c

index 0b64c9c9e36661a37814cc0b2057c62ec0a26699..1ec00e8c1908f4692f895e949d4b6d374f761676 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2005-05-31  Nikolay V. Shmyrev  <nshmyrev@yandex.ru>
+
+       * 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  <mpg@redhat.com>
 
        * backend/ev-link.c: (ev_link_class_init):
index 36adf93dfee35272b1711cf6a92e084977520da5..ad0a1fa2d123ac1e28978befa34cba3791cbaa40 100644 (file)
@@ -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,
index fc1111b5662d2d3778bda704c36d3e97e592af4d..22557f145cdb2c0907cb8a36893d6113039f0452 100644 (file)
@@ -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);
index 864e5e39654b5a543e87f453bacb218cb78a2fe3..b1c61e63ed086ffc94c09e793895881bf22312ed 100644 (file)
@@ -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), "");
        }