[evince/gnome3-style] Correct test for the max zoom text width



commit a48244873735d14c4203836edf55ce617cf4fc40
Author: William Jon McCann <jmccann redhat com>
Date:   Wed Dec 12 13:22:44 2012 +0100

    Correct test for the max zoom text width
    
    https://bugzilla.gnome.org/show_bug.cgi?id=690102

 shell/ev-zoom-action-widget.c |   18 +++++++++++++++---
 1 files changed, 15 insertions(+), 3 deletions(-)
---
diff --git a/shell/ev-zoom-action-widget.c b/shell/ev-zoom-action-widget.c
index ef82888..403418a 100644
--- a/shell/ev-zoom-action-widget.c
+++ b/shell/ev-zoom-action-widget.c
@@ -243,6 +243,8 @@ ev_zoom_action_widget_init (EvZoomActionWidget *control)
         GtkWidget                 *vbox;
         GtkCellRenderer           *renderer;
         GtkListStore              *store;
+        int                        i;
+        int                        width;
 
         control->priv = G_TYPE_INSTANCE_GET_PRIVATE (control, EV_TYPE_ZOOM_ACTION_WIDGET, EvZoomActionWidgetPrivate);
         priv = control->priv;
@@ -255,9 +257,19 @@ ev_zoom_action_widget_init (EvZoomActionWidget *control)
         g_object_unref (store);
 
         entry = gtk_bin_get_child (GTK_BIN (priv->combo));
-        /* Longest name + two digits + % + icon(3) */
-        gtk_entry_set_width_chars (GTK_ENTRY (entry),
-                                   strlen (zoom_levels[G_N_ELEMENTS (zoom_levels) - 1].name) + 3 + 3);
+
+        /* Find the longest name */
+        width = 0;
+        for (i = 0; i < 3; i++) {
+                if (zoom_levels[i].name != NULL) {
+                        int length;
+
+                        length = strlen (zoom_levels[i].name);
+                        if (length > width)
+                                width = length;
+                }
+        }
+        gtk_entry_set_width_chars (GTK_ENTRY (entry), width);
 
         renderer = gtk_cell_renderer_text_new ();
         gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (priv->combo), renderer, FALSE);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]