From 1f56f5c2e97afdd6ab75a0826f13ea8608e8246c Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Mon, 11 Feb 2019 04:57:46 +0100 Subject: selectionmodel: Change prototype of query_range() 1. Do not make position an inout variable The function is meant to return a range for a given position, not modify a position. So it makes no conceptual sense to use an inout variable. 2. Pass the selected state as an out variable Using a boolean return value - in particular in an interface full of boolean return values - makes the return value intuitively feel like a success/failure return. Using an out variable clarifies the usage. 3. Allow passing every position value Define what happens when position >= list.n_items 4. Clarify the docs about how this function should behave In particular, mention the case from point (3) 5. Add more tests Again, (3) needs testing. --- gtk/gtkselectionmodel.h | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'gtk/gtkselectionmodel.h') diff --git a/gtk/gtkselectionmodel.h b/gtk/gtkselectionmodel.h index 65c424716d..9e8de6a66b 100644 --- a/gtk/gtkselectionmodel.h +++ b/gtk/gtkselectionmodel.h @@ -79,9 +79,11 @@ struct _GtkSelectionModelInterface guint n_items); gboolean (* select_all) (GtkSelectionModel *model); gboolean (* unselect_all) (GtkSelectionModel *model); - gboolean (* query_range) (GtkSelectionModel *model, - guint *position, - guint *n_items); + void (* query_range) (GtkSelectionModel *model, + guint position, + guint *start_range, + guint *n_items, + gboolean *selected); }; GDK_AVAILABLE_IN_ALL @@ -110,9 +112,11 @@ GDK_AVAILABLE_IN_ALL gboolean gtk_selection_model_unselect_all (GtkSelectionModel *model); GDK_AVAILABLE_IN_ALL -gboolean gtk_selection_model_query_range (GtkSelectionModel *model, - guint *position, - guint *n_items); +void gtk_selection_model_query_range (GtkSelectionModel *model, + guint position, + guint *start_range, + guint *n_items, + gboolean *selected); /* for implementations only */ GDK_AVAILABLE_IN_ALL -- cgit v1.2.1