Commit Graph

12 Commits

Author SHA1 Message Date
Matthias Clasen
91f7b9663f gtk: Clean up docs syntax
Replace leftover gtk-doc syntax (#Type) with backquotes.
2021-05-22 17:25:26 -04:00
Matthias Clasen
8ba16eb4f1 Documentation fixes
Mostly fixing up indentation of continuation lines,
and other small cleanups.
2021-05-20 19:17:49 -04:00
Benjamin Otte
006dfdc55a selectionmodel: Remove select_callback() functions
gtk_selection_model_set_selection() takes care of those now.
2020-06-26 07:13:32 +02:00
Benjamin Otte
fa0295629b selectionmodel: Add gtk_selection_model_set_selection()
Also port the testsuite.
2020-06-26 07:13:32 +02:00
Benjamin Otte
8395698090 selectionmodel: Replace query_range() with get_selection() 2020-06-26 07:13:32 +02:00
Benjamin Otte
541aaa2392 selectionmodel: Add unselect_rest argument to select_callback
This is not just about consistency with other functions.

It is about avoiding reentrancy problems.

GtkListBase first doing an unselect_all() will then force the
SelectionModel to consider a state where all items are unselected
(and potentially deciding to autoselect one) and then cause a
"selection-changed" emission that unselects all items and potentially
updates all the list item widgets in the GtkListBase to the unselected
state.

After this, GtkListBase selects new items, but to the SelectionModel and
the list item widgets this looks like an enitrely new operation and
there is no way to associate it with the previous state, so the
SelectionModel cannot undo any previous actions it took when
unselecting.
And all listitem widgets will now think they were just selected and
start running animations about selecting.
2020-06-08 19:06:56 +02:00
Benjamin Otte
d294b01cee selectionmodel: Rename "exclusive" to "unselect_rest"
The name is better at explaining what this boolean is meant to do.
2020-06-08 18:26:48 +02:00
Matthias Clasen
b0cf7a95b0 Add a forgotten export
gtk_selection_model_unselect_callback needs to be exported.
2020-06-06 11:22:48 -04:00
Matthias Clasen
fd7f19c934 selectionmodel: Document the callback apis 2020-06-06 10:36:57 -04:00
Matthias Clasen
20611cf68c Add gtk_selection_model_[un]select_callback
Add a methods to add or remove a whole set
(specified via a query-range style callback).
2020-06-04 22:28:54 -04:00
Benjamin Otte
1f56f5c2e9 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.
2019-02-15 06:28:35 +01:00
Benjamin Otte
16024fba7c gtk: Add GtkSelectionModel
The selection model is a list model interface that takes care of
selections and is to be used by the list model widgets to manage their
selections.
2019-02-10 18:43:59 -05:00