From 6077ea4f48952039eaee61c94ef25b99484c424f Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Wed, 24 May 2023 22:38:36 -0400 Subject: [PATCH] Add gtk_grid_view_scroll_to This does the same as gtk_list_view_scroll_to, just for a grid view. --- gtk/gtkgridview.c | 26 ++++++++++++++++++++++++++ gtk/gtkgridview.h | 7 +++++++ 2 files changed, 33 insertions(+) diff --git a/gtk/gtkgridview.c b/gtk/gtkgridview.c index dd36309844..1a9e2a5f3d 100644 --- a/gtk/gtkgridview.c +++ b/gtk/gtkgridview.c @@ -1564,3 +1564,29 @@ gtk_grid_view_get_tab_behavior (GtkGridView *self) return gtk_list_base_get_tab_behavior (GTK_LIST_BASE (self)); } +/** + * gtk_grid_view_scroll_to: + * @self: The gridview to scroll in + * @pos: position of the item + * @flags: actions to perform + * @scroll: (nullable) (transfer full): details of how to perform + * the scroll operation or %NULL to scroll into view + * + * Scrolls to the item at the given position and performs the actions + * specified in @flags. + * + * This function works no matter if the gridview is shown or focused. + * If it isn't, then the changes will take effect once that happens. + * + * Since: 4.12 + */ +void +gtk_grid_view_scroll_to (GtkGridView *self, + guint pos, + GtkListScrollFlags flags, + GtkScrollInfo *scroll) +{ + g_return_if_fail (GTK_IS_GRID_VIEW (self)); + + gtk_list_base_scroll_to (GTK_LIST_BASE (self), pos, flags, scroll); +} diff --git a/gtk/gtkgridview.h b/gtk/gtkgridview.h index 9525c07c7b..6e4b70f940 100644 --- a/gtk/gtkgridview.h +++ b/gtk/gtkgridview.h @@ -85,6 +85,13 @@ void gtk_grid_view_set_single_click_activate (GtkGridView GDK_AVAILABLE_IN_ALL gboolean gtk_grid_view_get_single_click_activate (GtkGridView *self); +GDK_AVAILABLE_IN_4_12 +void gtk_grid_view_scroll_to (GtkGridView *self, + guint pos, + GtkListScrollFlags flags, + GtkScrollInfo *scroll); + + G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkGridView, g_object_unref) G_END_DECLS -- 2.30.2