summaryrefslogtreecommitdiff
path: root/gtk/gtkspinbutton.c
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2013-03-22 11:32:07 +0100
committerAlexander Larsson <alexl@redhat.com>2013-04-23 05:58:07 +0200
commit433c0c21341c470388bb73a66ff41c43cd3f01e3 (patch)
tree2b64d8d7160fa6c00f8bca0cea821c7f3dfc4f7a /gtk/gtkspinbutton.c
parent627685e2a2efd9be72e66dd1a1e8f49aab1d1600 (diff)
downloadgtk+-433c0c21341c470388bb73a66ff41c43cd3f01e3.tar.gz
GtkSpinButton: Support baseline alignment
Diffstat (limited to 'gtk/gtkspinbutton.c')
-rw-r--r--gtk/gtkspinbutton.c34
1 files changed, 30 insertions, 4 deletions
diff --git a/gtk/gtkspinbutton.c b/gtk/gtkspinbutton.c
index f05657cf42..0928d9ea60 100644
--- a/gtk/gtkspinbutton.c
+++ b/gtk/gtkspinbutton.c
@@ -222,6 +222,12 @@ static void gtk_spin_button_get_preferred_width (GtkWidget *widget,
static void gtk_spin_button_get_preferred_height (GtkWidget *widget,
gint *minimum,
gint *natural);
+static void gtk_spin_button_get_preferred_height_and_baseline_for_width (GtkWidget *widget,
+ gint width,
+ gint *minimum,
+ gint *natural,
+ gint *minimum_baseline,
+ gint *natural_baseline);
static void gtk_spin_button_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
static gint gtk_spin_button_draw (GtkWidget *widget,
@@ -309,6 +315,7 @@ gtk_spin_button_class_init (GtkSpinButtonClass *class)
widget_class->unrealize = gtk_spin_button_unrealize;
widget_class->get_preferred_width = gtk_spin_button_get_preferred_width;
widget_class->get_preferred_height = gtk_spin_button_get_preferred_height;
+ widget_class->get_preferred_height_and_baseline_for_width = gtk_spin_button_get_preferred_height_and_baseline_for_width;
widget_class->size_allocate = gtk_spin_button_size_allocate;
widget_class->draw = gtk_spin_button_draw;
widget_class->scroll_event = gtk_spin_button_scroll;
@@ -1197,14 +1204,20 @@ gtk_spin_button_get_preferred_width (GtkWidget *widget,
}
static void
-gtk_spin_button_get_preferred_height (GtkWidget *widget,
- gint *minimum,
- gint *natural)
+gtk_spin_button_get_preferred_height_and_baseline_for_width (GtkWidget *widget,
+ gint width,
+ gint *minimum,
+ gint *natural,
+ gint *minimum_baseline,
+ gint *natural_baseline)
{
GtkSpinButton *spin_button = GTK_SPIN_BUTTON (widget);
GtkSpinButtonPrivate *priv = spin_button->priv;
- GTK_WIDGET_CLASS (gtk_spin_button_parent_class)->get_preferred_height (widget, minimum, natural);
+ GTK_WIDGET_CLASS (gtk_spin_button_parent_class)->get_preferred_height_and_baseline_for_width (widget, width,
+ minimum, natural,
+ minimum_baseline,
+ natural_baseline);
if (priv->orientation == GTK_ORIENTATION_VERTICAL)
{
@@ -1216,10 +1229,23 @@ gtk_spin_button_get_preferred_height (GtkWidget *widget,
*minimum += up_panel_height + down_panel_height;
*natural += up_panel_height + down_panel_height;
+
+ if (minimum_baseline && *minimum_baseline != -1)
+ *minimum_baseline += up_panel_height;
+ if (natural_baseline && *natural_baseline != -1)
+ *natural_baseline += up_panel_height;
}
}
static void
+gtk_spin_button_get_preferred_height (GtkWidget *widget,
+ gint *minimum,
+ gint *natural)
+{
+ gtk_spin_button_get_preferred_height_and_baseline_for_width (widget, -1, minimum, natural, NULL, NULL);
+}
+
+static void
gtk_spin_button_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{