summaryrefslogtreecommitdiff
path: root/gtk/gtkspinbutton.c
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2016-01-25 15:42:18 +0100
committerBenjamin Otte <otte@redhat.com>2016-01-25 15:49:17 +0100
commit3982f05be4c228c3ec754a9783913b55d1ecef4d (patch)
tree4e3b174bebbda903160db2b6253098cbbbfee4ba /gtk/gtkspinbutton.c
parent02fab14b3bd8aa2bb34e0945c783276e85a6f098 (diff)
downloadgtk+-3982f05be4c228c3ec754a9783913b55d1ecef4d.tar.gz
entry: Move spinbutton size hack
If we want to do special sizing for the text, we need to do it for the text. Otherwise paddings, borders and entyr icons will screw up everything.
Diffstat (limited to 'gtk/gtkspinbutton.c')
-rw-r--r--gtk/gtkspinbutton.c58
1 files changed, 29 insertions, 29 deletions
diff --git a/gtk/gtkspinbutton.c b/gtk/gtkspinbutton.c
index 3b619a74b1..dc39e3820a 100644
--- a/gtk/gtkspinbutton.c
+++ b/gtk/gtkspinbutton.c
@@ -1185,45 +1185,45 @@ gtk_spin_button_format_for_value (GtkSpinButton *spin_button,
return buf;
}
-static void
-gtk_spin_button_get_preferred_width (GtkWidget *widget,
- gint *minimum,
- gint *natural)
+gint
+gtk_spin_button_get_text_width (GtkSpinButton *spin_button)
{
- GtkSpinButton *spin_button = GTK_SPIN_BUTTON (widget);
GtkSpinButtonPrivate *priv = spin_button->priv;
- GtkEntry *entry = GTK_ENTRY (widget);
+ gint width, w;
+ PangoLayout *layout;
+ gchar *str;
- GTK_WIDGET_CLASS (gtk_spin_button_parent_class)->get_preferred_width (widget, minimum, natural);
+ layout = pango_layout_copy (gtk_entry_get_layout (GTK_ENTRY (spin_button)));
- if (gtk_entry_get_width_chars (entry) < 0)
- {
- gint width, w;
- PangoLayout *layout;
- gchar *str;
+ /* Get max of MIN_SPIN_BUTTON_WIDTH, size of upper, size of lower */
+ width = MIN_SPIN_BUTTON_WIDTH;
- layout = pango_layout_copy (gtk_entry_get_layout (entry));
+ str = gtk_spin_button_format_for_value (spin_button,
+ gtk_adjustment_get_upper (priv->adjustment));
+ w = measure_string_width (layout, str);
+ width = MAX (width, w);
+ g_free (str);
- /* Get max of MIN_SPIN_BUTTON_WIDTH, size of upper, size of lower */
- width = MIN_SPIN_BUTTON_WIDTH;
+ str = gtk_spin_button_format_for_value (spin_button,
+ gtk_adjustment_get_lower (priv->adjustment));
+ w = measure_string_width (layout, str);
+ width = MAX (width, w);
+ g_free (str);
- str = gtk_spin_button_format_for_value (spin_button,
- gtk_adjustment_get_upper (priv->adjustment));
- w = measure_string_width (layout, str);
- width = MAX (width, w);
- g_free (str);
+ g_object_unref (layout);
- str = gtk_spin_button_format_for_value (spin_button,
- gtk_adjustment_get_lower (priv->adjustment));
- w = measure_string_width (layout, str);
- width = MAX (width, w);
- g_free (str);
+ return width;
+}
- *minimum = width;
- *natural = width;
+static void
+gtk_spin_button_get_preferred_width (GtkWidget *widget,
+ gint *minimum,
+ gint *natural)
+{
+ GtkSpinButton *spin_button = GTK_SPIN_BUTTON (widget);
+ GtkSpinButtonPrivate *priv = spin_button->priv;
- g_object_unref (layout);
- }
+ GTK_WIDGET_CLASS (gtk_spin_button_parent_class)->get_preferred_width (widget, minimum, natural);
if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
{