Merge branch 'fix-focus-tests' into 'main'

spinbutton: Update baseline child

See merge request GNOME/gtk!5950
This commit is contained in:
Matthias Clasen 2023-05-11 22:28:46 +00:00
commit 3353eac289
2 changed files with 27 additions and 5 deletions

View 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");

View File

@ -17,6 +17,8 @@
#include "gtkwidgetprivate.h"
#include "gtknative.h"
#include "gtkboxlayout.h"
#include "gtkorientable.h"
typedef struct _CompareInfo CompareInfo;
@ -434,7 +436,29 @@ gtk_widget_focus_sort (GtkWidget *widget,
{
case GTK_DIR_TAB_FORWARD:
case GTK_DIR_TAB_BACKWARD:
{
GtkLayoutManager *layout = gtk_widget_get_layout_manager (widget);
if (GTK_IS_BOX_LAYOUT (layout))
{
GtkOrientation orientation = gtk_orientable_get_orientation (GTK_ORIENTABLE (layout));
if (orientation == GTK_ORIENTATION_HORIZONTAL)
{
if (direction == GTK_DIR_TAB_FORWARD)
focus_sort_left_right (widget, GTK_DIR_RIGHT, focus_order);
else
focus_sort_left_right (widget, GTK_DIR_LEFT, focus_order);
}
else
{
if (direction == GTK_DIR_TAB_FORWARD)
focus_sort_up_down (widget, GTK_DIR_DOWN, focus_order);
else
focus_sort_up_down (widget, GTK_DIR_UP, focus_order);
}
}
else
focus_sort_tab (widget, direction, focus_order);
}
break;
case GTK_DIR_UP:
case GTK_DIR_DOWN: