From 7eac27e5eef069a7d90b96bb18cb18994d4a1c85 Mon Sep 17 00:00:00 2001 From: Corey Berla Date: Tue, 29 Nov 2022 19:58:25 -0800 Subject: [PATCH] listitemwidget: Add listitem.scroll-to action This is the matching action for list.scroll-to-item --- gtk/gtklistitemwidget.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/gtk/gtklistitemwidget.c b/gtk/gtklistitemwidget.c index 2fb5e1633c..7ce0f30af1 100644 --- a/gtk/gtklistitemwidget.c +++ b/gtk/gtklistitemwidget.c @@ -302,6 +302,20 @@ gtk_list_item_widget_select_action (GtkWidget *widget, priv->position, modify, extend); } +static void +gtk_list_item_widget_scroll_to_action (GtkWidget *widget, + const char *action_name, + GVariant *parameter) +{ + GtkListItemWidget *self = GTK_LIST_ITEM_WIDGET (widget); + GtkListItemWidgetPrivate *priv = gtk_list_item_widget_get_instance_private (self); + + gtk_widget_activate_action (GTK_WIDGET (self), + "list.scroll-to-item", + "u", + priv->position); +} + static void gtk_list_item_widget_class_init (GtkListItemWidgetClass *klass) { @@ -359,6 +373,17 @@ gtk_list_item_widget_class_init (GtkListItemWidgetClass *klass) "(bb)", gtk_list_item_widget_select_action); + /** + * GtkListItem|listitem.scroll-to: + * + * Moves the visible area of the list to this item with the minimum amount + * of scrolling required. If the item is already visible, nothing happens. + */ + gtk_widget_class_install_action (widget_class, + "listitem.scroll-to", + NULL, + gtk_list_item_widget_scroll_to_action); + gtk_widget_class_add_binding_signal (widget_class, GDK_KEY_Return, 0, "activate-keybinding", 0); gtk_widget_class_add_binding_signal (widget_class, GDK_KEY_ISO_Enter, 0, -- 2.30.2