Commit Graph

59812 Commits

Author SHA1 Message Date
Benjamin Otte
b5fd69b69a listitemfactory: Simplify
Instead of 6 vfuncs, we now have 3 and rely on the factory keeping track
of what it needs to do.

We're doing lots of dancing from one object to another here, but this
will hopefully get simpler with further commits.
2019-12-13 06:11:57 +01:00
Benjamin Otte
54159c2a15 listitemfactory: Reorganize vfuncs
Instead of bind/rebind/update/unbind, we now just have update, and the
factories get to interpret that in the way they want.
2019-12-13 06:11:57 +01:00
Benjamin Otte
84f398531d listitem: Make this a GObject
This splits GtkListItem into 2 parts:

1. GtkListItem
   This is purely a GObject with public API for developers who want to
   populate lists. There is no chance to cause conflict with GtkWidget
   properties that the list implementation assumed control over and
   defines a clear boundary.
2. GtkListItemWidget
   The widget part of the listitem. This is not only fully in control of
   the list machinery, the machinery can also use different widget
   implementations for different list widgets like I inted to for
   GtkColumnView.
2019-12-13 06:11:57 +01:00
Benjamin Otte
c860406797 builder: Make gtk_builder_extend_with_template() work with objects
This will be relevant later when we introduce GtkListItem which is not a
GtkWidget.
2019-12-13 06:11:57 +01:00
Benjamin Otte
c307850dcf gtk-demo: Add a Coverflow application launcher
This is roughly the simplest demo I could come up with.

But I documented it, so there's your tutorial.

Related: #2214
2019-12-13 06:11:57 +01:00
Benjamin Otte
2b2aef72d9 Add GtkSignalListItemFactory
So the poor Rust users can actually use this.

I would totally not use this ever!
2019-12-13 06:11:57 +01:00
Benjamin Otte
9f0d107a18 columnview: Allow adding/removing columns
... and make that work in UI files via <child>, too.
2019-12-13 06:11:57 +01:00
Benjamin Otte
5470a3c6b4 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.
2019-12-13 06:11:57 +01:00
Benjamin Otte
2b733dfa08 Add GtkColumnView skeleton
It's just a copy/paste of the listview code with all the internals
gutted. The code doesn't do anything.
2019-12-13 06:11:57 +01:00
Benjamin Otte
e5e376ff7b 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.
2019-12-13 06:11:57 +01:00
Benjamin Otte
71ace6763d listbase: Take over anchor handling
With that, pretty much all code but allocating the widgets is gone from
the gridview and listview.
2019-12-13 06:11:57 +01:00
Benjamin Otte
ad6a6cd2f3 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.
2019-12-13 06:11:57 +01:00
Benjamin Otte
4d565a35aa 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.
2019-12-13 06:11:57 +01:00
Benjamin Otte
7c44a95cea 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.
2019-12-13 06:11:57 +01:00
Benjamin Otte
cb74edc958 listbase: Move orientable implementation here 2019-12-13 06:11:57 +01:00
Benjamin Otte
65b638ac7d listbase: Move selection handling here 2019-12-13 06:11:57 +01:00
Benjamin Otte
f6355cca76 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).
2019-12-13 06:11:57 +01:00
Benjamin Otte
18eb44ee6b listbase: Move GtkScrollable implementation
Shared code between GtkGridView and GtkListView.
2019-12-13 06:11:57 +01:00
Benjamin Otte
9bfe96e397 Add GtkListBase
This is a base item for GTK's list widgets so they can share some (read:
hopefully a lot of) code.
2019-12-13 06:11:57 +01:00
Benjamin Otte
a9d3dace47 gridview: Simplify allocation code
It doesn't fix the bug I'm after, but it looks a lot better.
2019-12-13 06:11:57 +01:00
Benjamin Otte
ec1d462e1f 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.
2019-12-13 06:11:57 +01:00
Benjamin Otte
22fd291d1f demo: Add a file browser demo 2019-12-13 06:11:57 +01:00
Benjamin Otte
fcd7964a3b gridview: Add move keybindings 2019-12-13 06:11:57 +01:00
Benjamin Otte
0121876c4a 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.
2019-12-13 06:11:57 +01:00
Benjamin Otte
65d8941425 gridview: Add a focus tracker
... and use that to properly update selections when moving around with
the arrow keys.
2019-12-13 06:11:57 +01:00
Benjamin Otte
655bdcf95f gridview: Implement list.scroll-to action 2019-12-13 06:11:57 +01:00
Benjamin Otte
7b41bef20e gridview: Add activation 2019-12-13 06:11:57 +01:00
Benjamin Otte
f23b392b2d 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-13 06:11:57 +01:00
Benjamin Otte
875d676ad1 gridview: Implement the list.select-item action 2019-12-13 06:11:57 +01:00
Benjamin Otte
872bb2a43c 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-13 06:11:57 +01:00
Benjamin Otte
99913833ea gridview: Implement anchors and scrolling 2019-12-13 06:11:57 +01:00
Benjamin Otte
5cbfadf65c widget: Add gtk_widget_get_size()
A little bit of convenience.
2019-12-13 06:11:57 +01:00
Benjamin Otte
737b91ae35 listitemmanager: Handle NULL factory
Just don't call it and create empty listitems.
2019-12-13 06:11:57 +01:00
Timm Bäder
6c13c8b0af demo: Use a listview as sidebar 2019-12-13 06:11:57 +01:00
Benjamin Otte
69fc00b4b6 gtk-demo: Introduce awards
We need a way to get a useful listbox, so here we go!
2019-12-13 06:11:57 +01:00
Benjamin Otte
bb71155bfc 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-13 06:11:57 +01:00
Benjamin Otte
60d07488be 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-13 06:11:57 +01:00
Benjamin Otte
3c3de02a3e 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-13 06:11:57 +01:00
Benjamin Otte
36e791fccf listview: Add move keybindings
My god, these are a lot.

And my god, these are complicated to get right.
2019-12-13 06:11:57 +01:00
Benjamin Otte
07d964ece6 listview: Add gtk_list_view_get_position_at_y() 2019-12-13 06:11:57 +01:00
Benjamin Otte
7f4ab1db86 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-13 06:11:57 +01:00
Benjamin Otte
27f5c1b148 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-13 06:11:57 +01:00
Benjamin Otte
764760ee5d 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-13 06:11:57 +01:00
Benjamin Otte
41c93153bf listview: Track focus movements and update selection
When focus moves via tab/arrow, we need to select the new item.
2019-12-13 06:11:56 +01:00
Benjamin Otte
8eee9897a8 listview: Implement activation
- a GtkListview::activate signal
- a GtkListItem::activatable property
- activate list items on double clicks and <Enter> presses
2019-12-13 06:11:56 +01:00
Benjamin Otte
1d2b8af320 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-13 06:11:56 +01:00
Benjamin Otte
e5a4ea71a4 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-13 06:11:56 +01:00
Benjamin Otte
6a496603bd popover: Remove unneeded vfunc
The vfunc is identical to the GtkWidget implementation it replaces. So
just keep using that one.
2019-12-13 06:11:56 +01:00
Benjamin Otte
36621a7f7d 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-13 06:11:56 +01:00
Benjamin Otte
ae86e6fe54 inspector: Use a GtkTreeExpander in the object tree 2019-12-13 06:11:56 +01:00