spinbutton: Update baseline child
authorMatthias Clasen <mclasen@redhat.com>
Thu, 11 May 2023 19:34:44 +0000 (15:34 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Thu, 11 May 2023 19:34:44 +0000 (15:34 -0400)
When the orientation changes, the entry changes
position, so we need to update baseline-child to match.

gtk/gtkspinbutton.c

index 447af1d64095108aa7a34ee88f72fc8054070303..f7ef127cc57d84f92db4658bd1153145e81afd2a 100644 (file)
@@ -996,7 +996,6 @@ gtk_spin_button_init (GtkSpinButton *spin_button)
 {
   GtkEventController *controller;
   GtkGesture *gesture;
-  GtkLayoutManager *layout;
 
   spin_button->adjustment = NULL;
   spin_button->timer = 0;
@@ -1012,9 +1011,6 @@ gtk_spin_button_init (GtkSpinButton *spin_button)
   spin_button->snap_to_ticks = FALSE;
   spin_button->width_chars = -1;
 
-  layout = gtk_widget_get_layout_manager (GTK_WIDGET (spin_button));
-  gtk_box_layout_set_baseline_child (GTK_BOX_LAYOUT (layout), 1);
-
   gtk_widget_update_orientation (GTK_WIDGET (spin_button), GTK_ORIENTATION_HORIZONTAL);
 
   spin_button->entry = gtk_text_new ();
@@ -1217,11 +1213,13 @@ gtk_spin_button_set_orientation (GtkSpinButton  *spin,
     {
       /* Current orientation of the box is vertical! */
       gtk_widget_insert_after (spin->up_button, GTK_WIDGET (spin), spin->down_button);
+      gtk_box_layout_set_baseline_child (layout_manager, 0);
     }
   else
     {
       /* Current orientation of the box is horizontal! */
       gtk_widget_insert_before (spin->up_button, GTK_WIDGET (spin), spin->entry);
+      gtk_box_layout_set_baseline_child (layout_manager, 1);
     }
 
   g_object_notify (G_OBJECT (spin), "orientation");