listbase: Return early on non-existent scroll position

This commit is contained in:
Khalid Abu Shawarib
2024-05-09 21:37:38 +00:00
parent 0d007345b8
commit bf47031699
3 changed files with 9 additions and 3 deletions

View File

@@ -2184,7 +2184,8 @@ gtk_column_view_set_header_factory (GtkColumnView *self,
/**
* gtk_column_view_scroll_to:
* @self: The columnview to scroll in
* @pos: position of the item
* @pos: position of the item. Must be less than the number of
* items in the view.
* @column: (nullable) (transfer none): The column to scroll to
* or %NULL to not scroll columns.
* @flags: actions to perform
@@ -2207,6 +2208,7 @@ gtk_column_view_scroll_to (GtkColumnView *self,
GtkScrollInfo *scroll)
{
g_return_if_fail (GTK_IS_COLUMN_VIEW (self));
g_return_if_fail (pos < gtk_list_base_get_n_items (GTK_LIST_BASE (self)));
g_return_if_fail (column == NULL || GTK_IS_COLUMN_VIEW_COLUMN (column));
if (column)
{

View File

@@ -1574,7 +1574,8 @@ gtk_grid_view_get_tab_behavior (GtkGridView *self)
/**
* gtk_grid_view_scroll_to:
* @self: The gridview to scroll in
* @pos: position of the item
* @pos: position of the item. Must be less than the number of
* items in the view.
* @flags: actions to perform
* @scroll: (nullable) (transfer full): details of how to perform
* the scroll operation or %NULL to scroll into view
@@ -1594,6 +1595,7 @@ gtk_grid_view_scroll_to (GtkGridView *self,
GtkScrollInfo *scroll)
{
g_return_if_fail (GTK_IS_GRID_VIEW (self));
g_return_if_fail (pos < gtk_list_base_get_n_items (GTK_LIST_BASE (self)));
gtk_list_base_scroll_to (GTK_LIST_BASE (self), pos, flags, scroll);
}

View File

@@ -1352,7 +1352,8 @@ gtk_list_view_get_tab_behavior (GtkListView *self)
/**
* gtk_list_view_scroll_to:
* @self: The listview to scroll in
* @pos: position of the item
* @pos: position of the item. Must be less than the number of
* items in the view.
* @flags: actions to perform
* @scroll: (nullable) (transfer full): details of how to perform
* the scroll operation or %NULL to scroll into view
@@ -1372,6 +1373,7 @@ gtk_list_view_scroll_to (GtkListView *self,
GtkScrollInfo *scroll)
{
g_return_if_fail (GTK_IS_LIST_VIEW (self));
g_return_if_fail (pos < gtk_list_base_get_n_items (GTK_LIST_BASE (self)));
gtk_list_base_scroll_to (GTK_LIST_BASE (self), pos, flags, scroll);
}