summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorey Berla <corey@berla.me>2022-11-29 19:58:25 -0800
committerCorey Berla <corey@berla.me>2022-11-30 09:43:20 -0800
commit7eac27e5eef069a7d90b96bb18cb18994d4a1c85 (patch)
tree7925b0b1e6a94e03f78741d023297e60363a76ae
parent847b3261fcb400488bb54bea9557a797c653b048 (diff)
downloadgtk+-7eac27e5eef069a7d90b96bb18cb18994d4a1c85.tar.gz
listitemwidget: Add listitem.scroll-to action
This is the matching action for list.scroll-to-item
-rw-r--r--gtk/gtklistitemwidget.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/gtk/gtklistitemwidget.c b/gtk/gtklistitemwidget.c
index 2fb5e1633c..7ce0f30af1 100644
--- a/gtk/gtklistitemwidget.c
+++ b/gtk/gtklistitemwidget.c
@@ -303,6 +303,20 @@ gtk_list_item_widget_select_action (GtkWidget *widget,
}
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)
{
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (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,