Commit Graph

63821 Commits

Author SHA1 Message Date
Matthias Clasen
e3ce99988f Add GtkTreeListRowSorter
This is a special-purpose sorter that can
apply the sorting of another sorter to the
levels of a GtkTreeListModel.
2020-05-30 19:30:14 -04:00
Benjamin Otte
fb78f1ef8e testcolumnview: Add sorters 2020-05-30 19:28:30 -04:00
Matthias Clasen
1ba1eda8ab column view title: Show sort indicators 2020-05-30 19:28:30 -04:00
Matthias Clasen
2945430ad7 columnview: Add a sort-by api 2020-05-30 19:28:28 -04:00
Matthias Clasen
66500a6882 columnview: Add sorting
This is a somewhat large commit that:

- Adds GtkColumnViewSorter
This is a special-purpose, private sorter implementation which sorts
according to multiple sorters, allowing each individual sorter to be
inverted. This will be used with clickable column view headers.

- Adds a read-only GtkColumnView::sorter property
The GtkColumnView creates a GtkColumnViewSorter at startup that it uses
for this property.

- Adds a writable GtkColumnViewColumn::sorter property
This allows defining per-column sorters. Whenever an application sets a
sorter for a column, the header becomes clickable and whenever
a header is clicked, that column's sorter is prepended to the list of
sorters, unless it is already the first sorter, in which case we invert
its order. No column can be in the list more than once.
2020-05-30 19:26:46 -04:00
Matthias Clasen
2c4c07c96d listview: Add single-click-activate
Add a single-click-activate property to GtkListView.
2020-05-30 19:26:46 -04:00
Matthias Clasen
69c86ae385 listitemwidget: Add single-click-activate
Add a mode to GtkListItemWidget that activates on
single click and selects on hover. Make
GtkListItemManager set this on its items
when its own 'property' of the same name is set.
2020-05-30 19:26:46 -04:00
Matthias Clasen
21eac434c3 builder-tool: Pass through CDATA where it makes sense
This avoids a ton of escaping for
GtkBuilderListItemFactory::bytes.
2020-05-30 19:26:46 -04:00
Matthias Clasen
2f21003064 docs: Reorganize list widgets in their own chapter 2020-05-30 19:26:46 -04:00
Benjamin Otte
58b65d1bf6 fontchooserwidget: Port to listmodels
The port is kind of evil, in that it stores either a PangoFontFamily or a
PangoFontFace in the list, depending on if the fontchooser is configured
to select fonts or faces.
It also does not cache the font description anymore, so more calls to
pango_font_describe() may happen.

If both of these issues turn out problematic, the fontchooser would need
to resurrect GtkDelayedFontDescription again and put objects of that
type through the model.

These changes depend on Pango 1.46's introduction of listmodels and
various new getters, so the dependency has been upgraded.
2020-05-30 19:26:46 -04:00
Matthias Clasen
542829ee81 Add some tests for expression binding
In particular, test that expressios can deal with object == this.
2020-05-30 19:26:46 -04:00
Benjamin Otte
b43c8ae646 expression: Allow passing a this object to bind()
This gives a bit more control over the arguments passed to expressions.
2020-05-30 19:26:46 -04:00
Benjamin Otte
22e6fa3a64 gtk-demo: Add a Clocks demo
This demo is meant to showcase expressions.

It also needs the fixes in glib 2.64 to work properly.
2020-05-30 19:26:46 -04:00
Benjamin Otte
c337887e29 xxx: Add a hack to make paintables transform to/from objects
See also: https://gitlab.gnome.org/GNOME/glib/merge_requests/1251
2020-05-30 19:26:46 -04:00
Benjamin Otte
650688c635 inspector: Remove private struct for prop editor 2020-05-30 19:26:46 -04:00
Benjamin Otte
2787e916b2 inspector: Make Controller page a GtkWidget 2020-05-30 19:26:46 -04:00
Benjamin Otte
e72119e9bb inspector: Remove private struct from controllers 2020-05-30 19:26:46 -04:00
Benjamin Otte
efcb3a9d67 columnview: Add header
This uses a custom GtkColumnViewTitle widget. So far that widget is
pretty boring, but that will change once we added
resizing, reordering, dnd, sorting, hiding/showing of columns or
whatever UIs we want.
2020-05-30 19:26:46 -04:00
Benjamin Otte
9f19699806 tests: Add testcolumnview 2020-05-30 19:26:46 -04:00
Benjamin Otte
326cb1148b columnview: Add a custom LayoutManager
The ColumnView now allocates column widths first and then the individual
rows use the new layout manager which looks at the column allocations to
allocate their children.
2020-05-30 19:26:46 -04:00
Benjamin Otte
767e7cb06f constraint-editor: Don't poke around in widget internals 2020-05-30 19:26:46 -04:00
Benjamin Otte
084725e280 columnview: Fix styling with Adwaita
- Use "treeview" as the node name
- Add .view style class
2020-05-30 19:26:46 -04:00
Benjamin Otte
6e3b6980de inspector: Port object tree to GtkColumnView 2020-05-30 19:26:46 -04:00
Benjamin Otte
9927d9bda2 columnview: Add GtkColumnViewCell
It's a GtkListItemWidget subclass that tracks the column it belongs to
and allows the column to track it.

We also use this subclass to implement sizing support so columns share
the same size and get resized in sync.
2020-05-30 19:26:46 -04:00
Benjamin Otte
34c6ef5332 widget: Add a hook for resizes
It's private, no APIs, we don't talk about it. But we will start using
it very soon, so we can do size request caching in columns and avoid
sizegroups...
2020-05-30 19:26:46 -04:00
Benjamin Otte
8af3e407c2 columnview: Implement GtkScrollable
Just forward it to the listview for now.
2020-05-30 19:26:46 -04:00
Benjamin Otte
8736343544 columnview: Add listitems for the columns
They are not aligned in columns yet, but they do exist.
2020-05-30 19:26:46 -04:00
Benjamin Otte
9caca0b127 listitemwidget: Lazily create listitems
We only create them in root/unroot (they should be created in
appear/disappear, but that vfunc doesn't exist yet), that way we can
avoid expensive work while the widget isn't used for anything.
2020-05-30 19:26:46 -04:00
Benjamin Otte
9d86020d4c listitem: Move position/item/selected tracking to widget
This way, we can ensure it's always there when we need it (before the
item gets created) and gone when we don't (if some GC language holds on
to the item after we've destroyed the widget).
2020-05-30 19:26:46 -04:00
Benjamin Otte
32eedec565 listitemwidget: Add a private struct
I had to rename the item property to list_item anyway, so I could just
do the next step with it.
2020-05-30 19:26:46 -04:00
Benjamin Otte
1af004361c 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.
2020-05-30 19:26:46 -04:00
Benjamin Otte
b33c56819b 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.
2020-05-30 19:26:46 -04:00
Benjamin Otte
30f09ea10b 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.
2020-05-30 19:26:46 -04:00
Benjamin Otte
db3e225f09 builder: Make gtk_builder_extend_with_template() work with objects
This will be relevant later when we introduce GtkListItem which is not a
GtkWidget.
2020-05-30 19:26:46 -04:00
Benjamin Otte
a44c06b264 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
2020-05-30 19:26:46 -04:00
Benjamin Otte
f5f9f70dd0 Add GtkSignalListItemFactory
So the poor Rust users can actually use this.

I would totally not use this ever!
2020-05-30 19:26:46 -04:00
Benjamin Otte
03e5c6e32d columnview: Allow adding/removing columns
... and make that work in UI files via <child>, too.
2020-05-30 19:26:46 -04:00
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