Commit Graph

59817 Commits

Author SHA1 Message Date
Benjamin Otte
ddc665bb01 gridview: Add a focus tracker
... and use that to properly update selections when moving around with
the arrow keys.
2019-12-15 23:33:04 +01:00
Benjamin Otte
d0495e36e6 gridview: Implement list.scroll-to action 2019-12-15 23:33:04 +01:00
Benjamin Otte
4444bb3d98 gridview: Add activation 2019-12-15 23:33:04 +01:00
Benjamin Otte
b9616124cb gridview: Implement minimum row height
We only allocate a certain amount of widgets - and we don't want to run
out of them. So we make all widgets high enough for this to never
happen.
2019-12-15 23:33:04 +01:00
Benjamin Otte
6218a27daf gridview: Implement the list.select-item action 2019-12-15 23:33:04 +01:00
Benjamin Otte
51ecc2d566 selectionmodel: Add gtk_selection_model_user_select_item()
I'm not sure this should be public API because it's incredibly awkward.
But it should definitely be shared between list widget implementations.
2019-12-15 23:33:04 +01:00
Benjamin Otte
050bd6d5e3 gridview: Implement anchors and scrolling 2019-12-15 23:33:04 +01:00
Benjamin Otte
0229f11784 widget: Add gtk_widget_get_size()
A little bit of convenience.
2019-12-15 23:33:04 +01:00
Benjamin Otte
cee950b455 listitemmanager: Handle NULL factory
Just don't call it and create empty listitems.
2019-12-15 23:33:04 +01:00
Timm Bäder
3a5f47c3b8 demo: Use a listview as sidebar 2019-12-15 23:33:04 +01:00
Benjamin Otte
484f804ba6 gtk-demo: Introduce awards
We need a way to get a useful listbox, so here we go!
2019-12-15 23:33:04 +01:00
Benjamin Otte
5b96335956 builder: Autofill scope property of listitemfactory
I couldn't come up with a better way to automatically inherit the scope
in the builder list item factory that didn't involve a magic
incantation in the XML file. And I do not want developers to know magic
incantations to do a thing that should pretty much always be done.
2019-12-15 23:33:04 +01:00
Benjamin Otte
61362af27b builderlistitemfactory: Add scope argument
This way, the scope used when creating builder instances can be
influenced. This way, callbacks can be passed into the factory.
2019-12-15 23:33:04 +01:00
Benjamin Otte
fc82f5fe29 listitemfactory: Make the builder factory properly buildable
Turn the construct arguments into construct properties so that they can
be set from ui files.
2019-12-15 23:33:04 +01:00
Benjamin Otte
5ae2c1fdca listview: Add move keybindings
My god, these are a lot.

And my god, these are complicated to get right.
2019-12-15 23:33:04 +01:00
Benjamin Otte
eba9ec613d listview: Add gtk_list_view_get_position_at_y() 2019-12-15 23:33:04 +01:00
Benjamin Otte
61fc0a6a59 listitem: Add "listitem.select" action and keybindings for it
In fact, grab space with all modifiers to toggle selection of the
current item.
2019-12-15 23:33:03 +01:00
Benjamin Otte
250760468b listview: Add a focus tracker
This ensures that the row with the input focus always stays available,
even when scrolled out of view.
2019-12-15 23:33:03 +01:00
Benjamin Otte
9d5063cf68 listview: Implement (un)select all
Adds listitem.select-all and listitem.unselect-all actions and installs
the same keybindings as the treeview for those actions.
2019-12-15 23:33:03 +01:00
Benjamin Otte
c4af364bfb listview: Track focus movements and update selection
When focus moves via tab/arrow, we need to select the new item.
2019-12-15 23:33:03 +01:00
Benjamin Otte
3e1cad5755 listview: Implement activation
- a GtkListview::activate signal
- a GtkListItem::activatable property
- activate list items on double clicks and <Enter> presses
2019-12-15 23:33:03 +01:00
Benjamin Otte
42c077443e treeexpander: Implement input support
This implements all the keybindings from GtkTreeView that can be
supported.

It does not implement expand-all, because supporting that means
causing the TreeListModel to emit lots of create_model vfuncs which in
turn would cause many items-changed signal which in turn would cause
many signal handlers to run which in turn would make "expand-all" very
reentrant, and I'm uneasy about supporting that.

For the mouse, just add a click gesture to the expander icon that toggles
expanded state.
2019-12-15 23:33:03 +01:00
Benjamin Otte
7a49d2e848 listitem: Change focus handling
Focus in the listitem now works like this:
1. If any child can take focus, do not ever attempt
   to take focus.
2. Otherwise, if this item is selectable or activatable,
   allow focusing this widget.

This makes sure every item in a list is focusable for
activation and selection handling, but no useless widgets
get focused and moving focus is as fast as possible.
2019-12-15 23:33:03 +01:00
Benjamin Otte
462953cac0 inspector: Make the recorder node list use a ListView
It's quite a bit faster now, but the code is also a bit more awkward.

Pain points:

- GtkTreeListModel cannot be created in UI files because it needs
  a CreateModelFunc.
  Using a signal for this doesn't work because autoexpand wants to
  expand the model before the signal handler is connected.

- The list item factory usage is still awkward. It's bearable here
  because the list items are very simple, but still.
2019-12-15 23:33:03 +01:00
Benjamin Otte
5b5ab5c592 inspector: Use a GtkTreeExpander in the object tree 2019-12-15 23:33:03 +01:00
Benjamin Otte
d89f9b6684 inspector: Use a treeexpander in the recorder 2019-12-15 23:33:03 +01:00
Benjamin Otte
71f104782a demo: Add a GSettings tree demo
It is meant to look somewhat like dconf-editor when it is done.

So far, it's just a list.
2019-12-15 23:33:03 +01:00
Benjamin Otte
297a2795c3 Add GtkTreeExpander
This is a container widget that takes over all the duties of tree
expanding and collapsing.
It has to be a container so it can capture keybindings while focus is
inside the listitem.

So far, this widget does not allow interacting with it, but it shows the
expander arrow in its correct state.

Also, testlistview uses this widget now instead of implementing
expanding itself.
2019-12-15 23:33:03 +01:00
Benjamin Otte
081645186d gridview: Actually do something
Implement measuring and allocating items - which makes the items appear
when drawing and allows interacting with the items.

However, the gridview still does not allow any user interaction
(including scrolling).
2019-12-15 23:33:03 +01:00
Benjamin Otte
20201662f1 listview: Pass the CSS name of listitems to the manager
... instead of hardcoding "row".
2019-12-15 21:11:03 +01:00
Benjamin Otte
3c97226e66 gridview: Implement GtkOrientable
Again, this is just the skeleton, because the Gridview does nothing yet.
2019-12-15 21:11:03 +01:00
Benjamin Otte
6b4b1e1921 gridview: Add factory handling
Just copy the listview APIs.

Code still doesn't do anything with it.
2019-12-15 21:11:03 +01:00
Benjamin Otte
246421f92c listview: Expose GtkListItemFactory APIs
Due to the many different ways to set factories, it makes sense to
expose them as custom objects.

This makes the actual APIs for the list widgets simpler, because they
can just have a regular "factory" property.

As a convenience function, gtk_list_view_new_with_factory() was added
to make this whole approach easy to use from C.
2019-12-15 21:11:03 +01:00
Benjamin Otte
603055b70d textview: Make cursor work when blinking is disabled 2019-12-15 21:10:29 +01:00
Benjamin Otte
6a26bb0e2f gtk-demo: Add a rough start at a Weather demo
This demos a horizontal listview.
2019-12-15 21:10:29 +01:00
Benjamin Otte
81bc2117b2 listview: Implement GtkOrientable 2019-12-15 21:10:28 +01:00
Benjamin Otte
f307f99275 tests: Add a rough form of multiselection
Just store a "filechooser::selected" attribute in the GFileInfo if
the file is meant to be selected.
2019-12-15 21:10:28 +01:00
Benjamin Otte
8157408df8 listview: Implement extending selections
Shift-clicking to extend selections now also works, imitating the
behavior of normal clicking and Windows Explorer (but not treeview):

1. We track the last selected item (normally, not via extend-clicking).

2. When shift-selecting, we modify the range from the last selected item
   to this item the same way we modify the regular item when not using
   shift:

2a. If Ctrl is not pressed, we select the range and unselect everything
    else.

2b. If Ctrl is pressed, we make the range have the same selection state
    as the last selected item:
    - If the last selected item is selected, select the range.
    - If the last selected item is not selected, unselect the range.
2019-12-15 21:10:28 +01:00
Benjamin Otte
9630b9f244 listview: Add list.scroll_to_item action
The action scrolls the given item into view.

Listitems activate this action when they gain focus.
2019-12-15 21:10:28 +01:00
Benjamin Otte
4b277dd47a testlistview: Load icons async
Speeds up loading by 4x, because out of view icons aren't loaded
anymore.
2019-12-15 21:10:28 +01:00
Benjamin Otte
5fcdf00a1a testlistview: Port to directory list 2019-12-15 21:10:28 +01:00
Benjamin Otte
48e1a3cc06 listitemfactory: Add a factory for ui files
Reuse <template> magic to initialize GtkListItems. This feels
amazingly hacky, but it also amazingly worked on the first try.
2019-12-15 21:10:28 +01:00
Benjamin Otte
8c5b077555 listitemfactory: Split implementation out
.. into gtkfunctionslistitemfactory.c

Now we can add a different implmenetation.
2019-12-15 21:10:28 +01:00
Benjamin Otte
023ff509b2 listitemfactory: vfuncify
No functional changes other than a new indirection.
2019-12-15 21:10:28 +01:00
Benjamin Otte
a0a7da2e3b listitemfactory: Sanitize APIs
Make sure the APIs follow a predictable path:

setup
  bind
    rebind/update (0-N times)
  unbind
teardown

This is the first step towards providing multiple different factories.
2019-12-15 21:10:28 +01:00
Benjamin Otte
b7ae37ab3d listview: Add gtk_list_view_set_show_separators()
Do the same thing that GtkListBox does in commit
0249bd4f8a
2019-12-15 21:10:28 +01:00
Benjamin Otte
6d8c6bb2f7 listitemmanager: Add trackers
... and replace the anchor tracking with a tracker.

Trackers track an item through the list across changes and ensure that
this item (and potentially siblings before/after it) are always backed
by a GtkListItem and that if the item gets removed a replacement gets
chosen.

This is now used for tracking the anchor but can also be used to add
trackers for the cursor later.
2019-12-15 21:10:28 +01:00
Benjamin Otte
b00c04a986 listitemmanager: Simplify
Remove a bunch of API from the headers that isn't used anymore and then
refactor code to not call it anymore.

In particular, get rid of GtkListItemManagerChange and replace it with a
GHashTable.
2019-12-15 21:10:28 +01:00
Benjamin Otte
62da088018 gridview: Implement GtkScrollable
We can now scroll all the nothing we display.

We also clip it properly.
2019-12-15 21:10:28 +01:00
Benjamin Otte
6d93197f08 listitemmanager: Move list of listitems here
All the listview infrastructure moved with it, so the next step is
moving that back...
2019-12-15 21:10:28 +01:00