Commit Graph

63633 Commits

Author SHA1 Message Date
Benjamin Otte
ca9e0c0e68 gtk-demo: Add a minesweeper demo
The demo shows creating ones own listmodel and using it to fill a grid.

I am totally getting the hang of React btw:
500 lines of logic with no UI code and 100 lines of GtkBuilder XML and
I get a sweet UI.
2020-05-30 19:26:46 -04:00
Benjamin Otte
0e1632d002 Add GtkColumnView skeleton
It's just a copy/paste of the listview code with all the internals
gutted. The code doesn't do anything.
2020-05-30 19:26:46 -04:00
Benjamin Otte
f4eb026c86 wip: Add GtkCoverFlow
The widget mostly works out of the box, but some tweaking may be
necessary (in particular in the theme) and the gtk-demo changes might
require removing before this is production-ready.
2020-05-30 19:26:46 -04:00
Benjamin Otte
e46fa81927 listbase: Take over anchor handling
With that, pretty much all code but allocating the widgets is gone from
the gridview and listview.
2020-05-30 19:26:46 -04:00
Benjamin Otte
33c6b428f7 listbase: Add vfuncs to convert positions to/from coordinates
... and use that to implement PageUp/PageDown.

With that, all keyboard handling has been moved to GtkListBase.
2020-05-30 19:26:46 -04:00
Benjamin Otte
12331e3376 listbase: Move focus moving keybindings here
The focus tracker is not yet moved because that depends on scroll_to()
support and we don't have that yet.
Whoops.
So we use a hack.
2020-05-30 19:26:46 -04:00
Benjamin Otte
dd5e6d47db Remove gtk_selection_model_user_select_item() again
This reverts commit 6a164ab306dad9096bde736c907494c71086d3c4.

The function was awkward and we now have only one caller again, so we
can fold it back into it.
2020-05-30 19:26:46 -04:00
Benjamin Otte
2541037ec2 listbase: Move orientable implementation here 2020-05-30 19:26:46 -04:00
Benjamin Otte
9d6aa7d88e listbase: Move selection handling here 2020-05-30 19:26:46 -04:00
Benjamin Otte
0bd16308d6 listbase: Move item manager here
Nothing really changes, because both ListView and GridView still keep
self->item_manager around, but it's set up to point at the base's item
manager.

This way we can slowly move things to GtkListBase that need the item
manager (like trackers).
2020-05-30 19:26:46 -04:00
Benjamin Otte
0011ce949c listbase: Move GtkScrollable implementation
Shared code between GtkGridView and GtkListView.
2020-05-30 19:26:46 -04:00
Benjamin Otte
cc987b31ae Add GtkListBase
This is a base item for GTK's list widgets so they can share some (read:
hopefully a lot of) code.
2020-05-30 19:26:46 -04:00
Benjamin Otte
c092d0a616 gridview: Simplify allocation code
It doesn't fix the bug I'm after, but it looks a lot better.
2020-05-30 19:26:46 -04:00
Benjamin Otte
ea390a4a73 listview: Port various gridview improvements
- Handle anchor as align + top/bottom
  This fixes behavior for cells that are higher than the view
- Add gtk_list_view_adjustment_is_flipped()
  This should fix RTL handling of horizontal lists
- Fix scrolling
  This should make scrolling more reliable, particularly on short lists
  that are only a few pages long.
2020-05-30 19:26:46 -04:00
Benjamin Otte
6b98948f9a demo: Add a file browser demo 2020-05-30 19:26:46 -04:00
Benjamin Otte
f57afe51af gridview: Add move keybindings 2020-05-30 19:26:46 -04:00
Benjamin Otte
bc22d04737 gridview: Implement (un)select all
Adds listitem.select-all and listitem.unselect-all actions and installs
the same keybindings as the treeview for those actions.
2020-05-30 19:26:46 -04:00
Benjamin Otte
093677b0f8 gridview: Add a focus tracker
... and use that to properly update selections when moving around with
the arrow keys.
2020-05-30 19:26:46 -04:00
Benjamin Otte
c38e050cc7 gridview: Implement list.scroll-to action 2020-05-30 19:26:46 -04:00
Benjamin Otte
ba0122fd02 gridview: Add activation 2020-05-30 19:26:46 -04:00
Benjamin Otte
affd2737d5 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.
2020-05-30 19:26:46 -04:00
Benjamin Otte
cc68073af0 gridview: Implement the list.select-item action 2020-05-30 19:26:46 -04:00
Benjamin Otte
cb2948eda6 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.
2020-05-30 19:26:46 -04:00
Benjamin Otte
1b105cdbef gridview: Implement anchors and scrolling 2020-05-30 19:26:45 -04:00
Benjamin Otte
dd436e8fe6 listitemmanager: Handle NULL factory
Just don't call it and create empty listitems.
2020-05-30 19:26:45 -04:00
Timm Bäder
a8d2bb6b22 demo: Use a listview as sidebar 2020-05-30 19:26:45 -04:00
Benjamin Otte
fcdc5030bd gtk-demo: Introduce awards
We need a way to get a useful listbox, so here we go!
2020-05-30 19:26:45 -04:00
Benjamin Otte
aad9adf8c3 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.
2020-05-30 19:26:45 -04:00
Benjamin Otte
48a223abdf 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.
2020-05-30 19:26:45 -04:00
Benjamin Otte
12e720fb23 listitemfactory: Make the builder factory properly buildable
Turn the construct arguments into construct properties so that they can
be set from ui files.
2020-05-30 19:26:45 -04:00
Benjamin Otte
042e13a932 listview: Add move keybindings
My god, these are a lot.

And my god, these are complicated to get right.
2020-05-30 19:26:45 -04:00
Benjamin Otte
2b9481ecdc listview: Add gtk_list_view_get_position_at_y() 2020-05-30 19:26:45 -04:00
Benjamin Otte
933c0c678a listitem: Add "listitem.select" action and keybindings for it
In fact, grab space with all modifiers to toggle selection of the
current item.
2020-05-30 19:26:45 -04:00
Benjamin Otte
2539828eac listview: Add a focus tracker
This ensures that the row with the input focus always stays available,
even when scrolled out of view.
2020-05-30 19:26:45 -04:00
Benjamin Otte
4b6f3e0f2c 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.
2020-05-30 19:26:45 -04:00
Benjamin Otte
b9eb818b57 listview: Track focus movements and update selection
When focus moves via tab/arrow, we need to select the new item.
2020-05-30 19:26:45 -04:00
Benjamin Otte
eda547fc4e listview: Implement activation
- a GtkListview::activate signal
- a GtkListItem::activatable property
- activate list items on double clicks and <Enter> presses
2020-05-30 19:26:45 -04:00
Benjamin Otte
1dbd017766 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.
2020-05-30 19:26:45 -04:00
Benjamin Otte
08d9a57c6e 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.
2020-05-30 19:26:45 -04:00
Benjamin Otte
d7b5966fa7 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.
2020-05-30 19:26:45 -04:00
Benjamin Otte
bb44120ae3 inspector: Use a GtkTreeExpander in the object tree 2020-05-30 19:26:45 -04:00
Benjamin Otte
8b1f034242 inspector: Use a treeexpander in the recorder 2020-05-30 19:26:45 -04:00
Benjamin Otte
bb7968ba77 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.
2020-05-30 19:26:45 -04:00
Benjamin Otte
7451e51619 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.
2020-05-30 19:26:45 -04:00
Benjamin Otte
ea93e18081 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).
2020-05-30 19:26:45 -04:00
Benjamin Otte
443e44853a listview: Pass the CSS name of listitems to the manager
... instead of hardcoding "row".
2020-05-30 19:26:45 -04:00
Benjamin Otte
b73e95655d gridview: Implement GtkOrientable
Again, this is just the skeleton, because the Gridview does nothing yet.
2020-05-30 19:26:45 -04:00
Benjamin Otte
e8bb84e0e2 gridview: Add factory handling
Just copy the listview APIs.

Code still doesn't do anything with it.
2020-05-30 19:26:45 -04:00
Benjamin Otte
626c525706 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.
2020-05-30 19:26:45 -04:00
Benjamin Otte
2ef2148fb5 gtk-demo: Add a rough start at a Weather demo
This demos a horizontal listview.
2020-05-30 19:26:45 -04:00