mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-17 23:50:16 +00:00
GtkListBoxRow: Update the listbox's cursor row when focusing
https://bugzilla.gnome.org/show_bug.cgi?id=708320
This commit is contained in:
parent
b876e036b2
commit
9141eeb60e
@ -168,7 +168,8 @@ static void gtk_list_box_add_move_binding (GtkBindin
|
|||||||
GtkMovementStep step,
|
GtkMovementStep step,
|
||||||
gint count);
|
gint count);
|
||||||
static void gtk_list_box_update_cursor (GtkListBox *box,
|
static void gtk_list_box_update_cursor (GtkListBox *box,
|
||||||
GtkListBoxRow *row);
|
GtkListBoxRow *row,
|
||||||
|
gboolean grab_focus);
|
||||||
static void gtk_list_box_select_and_activate (GtkListBox *box,
|
static void gtk_list_box_select_and_activate (GtkListBox *box,
|
||||||
GtkListBoxRow *row);
|
GtkListBoxRow *row);
|
||||||
static void gtk_list_box_update_prelight (GtkListBox *box,
|
static void gtk_list_box_update_prelight (GtkListBox *box,
|
||||||
@ -1380,10 +1381,12 @@ ensure_row_visible (GtkListBox *box,
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_list_box_update_cursor (GtkListBox *box,
|
gtk_list_box_update_cursor (GtkListBox *box,
|
||||||
GtkListBoxRow *row)
|
GtkListBoxRow *row,
|
||||||
|
gboolean grab_focus)
|
||||||
{
|
{
|
||||||
BOX_PRIV (box)->cursor_row = row;
|
BOX_PRIV (box)->cursor_row = row;
|
||||||
ensure_row_visible (box, row);
|
ensure_row_visible (box, row);
|
||||||
|
if (grab_focus)
|
||||||
gtk_widget_grab_focus (GTK_WIDGET (row));
|
gtk_widget_grab_focus (GTK_WIDGET (row));
|
||||||
gtk_widget_queue_draw (GTK_WIDGET (row));
|
gtk_widget_queue_draw (GTK_WIDGET (row));
|
||||||
_gtk_list_box_accessible_update_cursor (box, row);
|
_gtk_list_box_accessible_update_cursor (box, row);
|
||||||
@ -1549,7 +1552,7 @@ gtk_list_box_update_selection (GtkListBox *box,
|
|||||||
{
|
{
|
||||||
GtkListBoxPrivate *priv = BOX_PRIV (box);
|
GtkListBoxPrivate *priv = BOX_PRIV (box);
|
||||||
|
|
||||||
gtk_list_box_update_cursor (box, row);
|
gtk_list_box_update_cursor (box, row, TRUE);
|
||||||
|
|
||||||
if (priv->selection_mode == GTK_SELECTION_NONE)
|
if (priv->selection_mode == GTK_SELECTION_NONE)
|
||||||
return;
|
return;
|
||||||
@ -1624,7 +1627,7 @@ gtk_list_box_select_and_activate (GtkListBox *box,
|
|||||||
if (row != NULL)
|
if (row != NULL)
|
||||||
{
|
{
|
||||||
gtk_list_box_select_row_internal (box, row);
|
gtk_list_box_select_row_internal (box, row);
|
||||||
gtk_list_box_update_cursor (box, row);
|
gtk_list_box_update_cursor (box, row, TRUE);
|
||||||
gtk_list_box_activate (box, row);
|
gtk_list_box_activate (box, row);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2850,7 +2853,7 @@ gtk_list_box_move_cursor (GtkListBox *box,
|
|||||||
|
|
||||||
get_current_selection_modifiers (GTK_WIDGET (box), &modify, &extend);
|
get_current_selection_modifiers (GTK_WIDGET (box), &modify, &extend);
|
||||||
|
|
||||||
gtk_list_box_update_cursor (box, row);
|
gtk_list_box_update_cursor (box, row, TRUE);
|
||||||
if (!modify)
|
if (!modify)
|
||||||
gtk_list_box_update_selection (box, row, FALSE, extend);
|
gtk_list_box_update_selection (box, row, FALSE, extend);
|
||||||
}
|
}
|
||||||
@ -2900,7 +2903,7 @@ gtk_list_box_row_set_focus (GtkListBoxRow *row)
|
|||||||
get_current_selection_modifiers (GTK_WIDGET (row), &modify, &extend);
|
get_current_selection_modifiers (GTK_WIDGET (row), &modify, &extend);
|
||||||
|
|
||||||
if (modify)
|
if (modify)
|
||||||
gtk_list_box_update_cursor (box, row);
|
gtk_list_box_update_cursor (box, row, TRUE);
|
||||||
else
|
else
|
||||||
gtk_list_box_update_selection (box, row, FALSE, FALSE);
|
gtk_list_box_update_selection (box, row, FALSE, FALSE);
|
||||||
}
|
}
|
||||||
@ -3458,6 +3461,18 @@ gtk_list_box_row_finalize (GObject *obj)
|
|||||||
G_OBJECT_CLASS (gtk_list_box_row_parent_class)->finalize (obj);
|
G_OBJECT_CLASS (gtk_list_box_row_parent_class)->finalize (obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gtk_list_box_row_grab_focus (GtkWidget *widget)
|
||||||
|
{
|
||||||
|
GtkListBoxRow *row = GTK_LIST_BOX_ROW (widget);
|
||||||
|
GtkListBox *box = gtk_list_box_row_get_box (row);
|
||||||
|
|
||||||
|
if (BOX_PRIV (box)->cursor_row != row)
|
||||||
|
gtk_list_box_update_cursor (box, row, FALSE);
|
||||||
|
|
||||||
|
GTK_WIDGET_CLASS (gtk_list_box_row_parent_class)->grab_focus (widget);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_list_box_row_class_init (GtkListBoxRowClass *klass)
|
gtk_list_box_row_class_init (GtkListBoxRowClass *klass)
|
||||||
{
|
{
|
||||||
@ -3479,6 +3494,7 @@ gtk_list_box_row_class_init (GtkListBoxRowClass *klass)
|
|||||||
widget_class->get_preferred_width_for_height = gtk_list_box_row_get_preferred_width_for_height;
|
widget_class->get_preferred_width_for_height = gtk_list_box_row_get_preferred_width_for_height;
|
||||||
widget_class->size_allocate = gtk_list_box_row_size_allocate;
|
widget_class->size_allocate = gtk_list_box_row_size_allocate;
|
||||||
widget_class->focus = gtk_list_box_row_focus;
|
widget_class->focus = gtk_list_box_row_focus;
|
||||||
|
widget_class->grab_focus = gtk_list_box_row_grab_focus;
|
||||||
|
|
||||||
klass->activate = gtk_list_box_row_activate;
|
klass->activate = gtk_list_box_row_activate;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user