Commit Graph

22 Commits

Author SHA1 Message Date
Benjamin Otte
3162e25671 bitset: Fix typo: gtk_bitset_slice() => gtk_bitset_splice() 2020-07-06 03:42:43 +02:00
Benjamin Otte
795d3122cc selectionmodels: Add set_model() support
Now that we don't care about item types anymore, we can make the child
models settable.

We try to retain the selection, even when the model changes.
2020-07-05 02:59:21 +02:00
Benjamin Otte
5080730728 listmodels: Stop respecting item-type
Simplify all view model APIs and always return G_TYPE_OBJECT as the
item-type for every model.

It turns out nobody uses item-type anyway.

So instead of adding lots of APIs, forcing people to think about it and
trying to figure out how to handle filter or map models that modify item
types, just having an easy life is a better approach.

All the models need to be able to deal with any type of object going
through anyway.
2020-07-05 02:59:21 +02:00
Matthias Clasen
d0068a036f Add gtk_multi_selection_get_model
This getter was missing.
2020-06-30 20:47:03 -04:00
Matthias Clasen
8a269de89a multiselection: Update docs
Remove information that is no longer true. GtkMultiSelection
is persistent across sorting changes since 3d8b6f6b79.
2020-06-27 21:40:26 -04:00
Benjamin Otte
147388e69a multiselection: Implement get_selection_in_range() 2020-06-26 07:13:32 +02:00
Benjamin Otte
3d8b6f6b79 multiselection: Track items across resorts
In particular, track which items remain in ::items-changed
signal emissions.

But the main use case is sorting, which causes items-changed(0, n, n)
to be emitted.
2020-06-26 07:13:32 +02: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
277a91dbf8 multiselection: Port to GtkBitset 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
Matthias Clasen
3e6e247e56 multiselection: Rewrite the select_callback implementation
Use a for loop to make this more obvious, and add some
assertions that the callback is behaving properly.
2020-06-06 11:22:48 -04:00
Matthias Clasen
de6327a885 multiselection: Clarify docs
Make it clear that GtkMultiSelection is not persistent
across resorting.
2020-06-06 10:24:14 -04:00
Matthias Clasen
c3a6e35070 Drop an unnecessary include 2020-06-06 09:39:36 -04:00
Matthias Clasen
a0c489048a Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!2052
2020-06-06 05:30:30 +00:00
Matthias Clasen
b047b7838d multiselection: Don't emit nonsensical signals
I forgot to add a check here. We only want to emit
a ::selection-changed if we actually changed it.
2020-06-05 23:15:20 -04:00
Benjamin Otte
b1c00ecee6 multiselection: Remove unused code
This is leftover code from an earlier SelectionModel API.
2020-06-06 05:02:37 +02:00
Matthias Clasen
80fbc1b72d multiselection: Fix the select_range implementation
When exclusive is TRUE, we would not always emit a
::selection-changed signal that covers all the items
that were unselected.

This commit includes a test.
2020-06-05 14:57:59 -04:00
Matthias Clasen
843bf23f84 Drop gtk_multi_selection-copy
It is not used anymore.
2020-06-05 00:51:35 -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
Matthias Clasen
28f6e27276 Add GtkMultiSelection
This is implemented using a private GtkSet helper.

Includes tests.
2020-06-03 13:32:57 -04:00