Commit Graph

59713 Commits

Author SHA1 Message Date
Benjamin Otte
2fb4df8973 listview: Make widget actually do something
The thing we're actually doing is create and maintain a widget for every
row. That's it.

Also add a testcase using this. The testcase quickly allocates too many
rows though and then becomes unresponsive though. You have been warned.
2019-12-13 06:10:08 +01:00
Benjamin Otte
bc637da95c listview: Introduce GtkListItemFactory
Thisis the abstraction I intend to use for creating widgets and binding
them to the item out of the listview.

For now this is a very dumb wrapper around the functions that exist in
the API.

But it leaves the freedom to turn this into public API, make an
interface out of it and most of all write different implementations, in
particular one that uses GtkBuilder.
2019-12-13 06:10:08 +01:00
Benjamin Otte
9575d54d4d gtk: Add a GtkListView skeleton 2019-12-13 06:09:56 +01:00
Benjamin Otte
c6a76c86c3 builder: Add <binding> tag
The tag contains an expression that it then gtk_expression_bind()s to
the object it is contained in.
2019-12-13 05:12:57 +01:00
Benjamin Otte
c04d63ff64 builder: Allow text content in <lookup>
<lookup>foo</lookup>
is now short for
  <lookup>
    <constant>foo</constant>
  </lookup>
ie it looks up the object with the given name so it can then do a
property lookup with it.

This is the most common operation, so it's a nice shortcut.
2019-12-13 05:12:57 +01:00
Benjamin Otte
cde3f3bc9e builder: Allow <constant> without a type
A constant without a type is assumed to be an object. This is the most
common case and allows
  <constant>foo</constant>
without requiring updates to the type whenever the foo object changes.
2019-12-13 05:12:57 +01:00
Benjamin Otte
c7344eef76 builder: Make <lookup> type optional
If no type is set, use the type of the expression.
2019-12-13 05:12:57 +01:00
Benjamin Otte
d2088059d7 gtk-demo: Make fishbowl info text use bindings
It's a good demo for how bindings can format multiple properties into an
informative string with 1 line of code (and 5 lines of XML).
2019-12-13 05:12:57 +01:00
Matthias Clasen
052a3c531f sorter: Add tests
Some basic tests for GtkSorter.
2019-12-13 05:12:57 +01:00
Benjamin Otte
8a07c5533e sortlistmodel: Make sort stable
The sort of the sortlistmodel is now stable with respect to the original
list model.

That means that if the sorter compares items as equal, the model
will make sure those items keep the order they were in in the original
model.

Or in other words: The model guarantees a total order based on the
item's position in the original model.
2019-12-13 05:12:57 +01:00
Benjamin Otte
54a9c07138 sortlistmodel: Redo the way we store the items
We need to keep this data around for changes in future commits where we
make the sorting stable.

An important part of the new data handling is that the unsorted list
needs to always be dealt with before the sorted list - upon creation we
rely on the unsorted iter and upon destruction, the sorted sequence
frees the entry leaving the unsorted sequence pointer invalid.

This change does not do any behavioral changes.
2019-12-13 05:12:57 +01:00
Matthias Clasen
bbc30a5810 Redo sort list model with GtkSorter
Reshuffle the api to take full advantage
of GtkSorter. Update all callers.
2019-12-13 05:12:57 +01:00
Matthias Clasen
3760289bbf Add GtkNumericSorter
This sorter compares numbers obtained from items
by evaluating an expression.
2019-12-13 05:12:57 +01:00
Matthias Clasen
f618c1b3ec Add GtkMultiSorter
This is a sorter that tries multiple sorters in turn.
2019-12-13 05:12:57 +01:00
Matthias Clasen
c0f31f4236 Add GtkStringSorter
This is a GtkSorter implementation collating strings
2019-12-13 05:12:57 +01:00
Matthias Clasen
5aeb9d3d8f Add GtkCustomSorter
This is a GtkSorter implementation which uses a GCompareDataFunc.
2019-12-13 05:12:57 +01:00
Matthias Clasen
38ee3ab8b6 Add GtkSorter
This is a helper object for sorting, similar to GtkFilter.
2019-12-13 05:12:57 +01:00
Benjamin Otte
f50cc76655 Add GtkOrdering
This is an enum that we're gonna use soon and it's worth introducing as a
separate commit.

The intention is to have meaningful names for return values in
comparison functions.
2019-12-13 05:12:57 +01:00
Matthias Clasen
7a52d8d8eb More expression tests
Test type mismatches, and the this pointer
during evaluation.
2019-12-13 05:12:57 +01:00
Benjamin Otte
c40fb49e38 expression: Invalidate bindings before destroying them
Use a weak ref to invalidate bindings. Make sure that this happens
before creating any watches, so that notifies from the
watched expression about changes will not trigger set_property() calls
during dispose()/finalize().

Invalidating also ensures that the watches aren't removed, which can
trigger warnings if the watches are watching the object itself, and the
weak refs cannot be removed anymore.
2019-12-13 05:12:57 +01:00
Benjamin Otte
196a64c380 expression: Add gtk_expression_bind()
Add a simple way to bind expressions to object properties. This is
essentially the thing to replace g_object_bind_property().
2019-12-13 05:12:57 +01:00
Benjamin Otte
211e8e6aec testsuite: Add expression tests 2019-12-13 05:12:57 +01:00
Benjamin Otte
0094aca2c3 expression: Add the ability to watch an expression 2019-12-13 05:12:57 +01:00
Benjamin Otte
6d204848ca builder: Add support for parsing expressions 2019-12-13 05:12:57 +01:00
Benjamin Otte
0a1cde18bb filter: Add tests
Some basic tests for GtkFilter
2019-12-13 05:12:57 +01:00
Benjamin Otte
c13e615f70 Add GtkMultiFilter, GtkAnyFilter, GtkEveryFilter
GtkMultiFilter is the abstract base class for managing multiple child
filter.
GtkAnyFilter and GtkEveryFilter are the actual implementations.
2019-12-13 05:12:57 +01:00
Benjamin Otte
3dc4257506 filter: Add GtkStringFilter
Users provide a search filter and an expression that evaluates the items
to a string and then the filter goes and matches those strings to the
search term.
2019-12-13 05:10:14 +01:00
Benjamin Otte
9b704bcda1 expression: Make property expression allow subexpressions 2019-12-13 05:09:30 +01:00
Benjamin Otte
2f8537fe0d expression: Add GtkObjectExpression
Weak refs break cycles...
2019-12-13 05:09:30 +01:00
Benjamin Otte
9bb71846ae Add GtkExpression
GtkExpressions allow looking up values from objects.

There are a few simple expressions, but the main one is the closure
expression that just calls a user-provided closure.
2019-12-13 05:09:30 +01:00
Benjamin Otte
bb42b71252 filterlistmodel: Rewrite to use GtkFilter 2019-12-13 05:09:30 +01:00
Benjamin Otte
46451a5aa6 tests: Remove testtreemodel test
testlistview does everything this test does.
2019-12-13 05:09:30 +01:00
Benjamin Otte
f06914e84a Add GtkCustomFilter 2019-12-13 05:09:30 +01:00
Benjamin Otte
789a80f905 Add GtkFilter 2019-12-13 05:09:29 +01:00
Benjamin Otte
fbcc8a0afd Add GtkDirectoryList
Adds a new listmodel called GtkDirectoryList that lists the children of
a GFile as GFileInfos.

This is supposed to be used by the filechooser.
2019-12-13 05:09:29 +01:00
Benjamin Otte
41e19757db gdk: Add GDK_DECLARE_EXPORTED_TYPE()
This is like G_DECLARE_FINAL_TYPE(), except it doesn't make the class
struct public, so internally all the subclassing in the world can
happen.

Some subtle differences:
- It marks the get_type() function as G_GNUC_CONST
- It doesn't require the parent type
- It uses G_DEFINE_AUTOPTR_CLEANUP_FUNC() instead of the private glib
  chainup method.

Port a bunch of GDK and the whole event controller + gesture machinery
to provew that it works.

As a side effect, we gained a bunch of missing autocleanups.
2019-12-13 02:09:01 +01:00
Benjamin Otte
b7f99db780 builder: Turn last dlsym() function into a scope API
Looking up a get_type function by its name is now also part of
GtkBuilderScope.
2019-12-12 19:52:15 +01:00
Benjamin Otte
51a535027f builder: Add GtkBuilderScope
GtkBuilderScope is an interface that provides the scope that a builder
instance operates in.
It creates closures and resolves types. Language bindings are meant to
use this interface to customize the behavior of builder files, in
particular when instantiating templates.

A default implementation for C is provided via GtkBuilderCScope (to keep
with the awkward naming that glib uses for closures). It is derivable on
purpose so that languages or extensions that extend C can use it.

The reftest code in fact does derive GtkBuilderCScope for its own scope
implementation that implements looking up symbols in modules.

gtk-widget-factory was updated to use the new GtkBuilderCScope to add
its custom callback symbols.
So it does it different from gtk-demo, which uses the normal way of
exporting symbols for dlsym() and thereby makes the 2 demos test the 2
ways GtkBuilder uses for looking up symbols.
2019-12-12 19:52:15 +01:00
Benjamin Otte
ed076838b5 builder: Add gtk_builder_set_current_object()
Use it as the default object for expression binds and when connecting
signals. It is intended to work kind of as the "this" object while
parsing. In fact, the term "current object" was stolen from the Java
docs and various C++ tutorials for the this pointer.

Set the current object in gtk_widget_init_template() and
GtkListItemBuilder.

This more-or-less replaces the object passed to
gtk_builder_connect_signals() in GTK3.
2019-12-12 19:52:15 +01:00
Benjamin Otte
5d2de89207 builder: Add gtk_builder_lookup_object()
... and use it. This function looks up an object like
gtk_builder_get_object() but generates an error on failure.

Unlike the evil function _gtk_builder_lookup_object() which also
generates an error but hides it for later lookup.

Use this to avoid continuing applying properties when an error was
encountered.
2019-12-12 19:52:15 +01:00
Benjamin Otte
101298c54d gtk-demo: Don't include "gtk.h" 2019-12-12 19:50:55 +01:00
Benjamin Otte
f6bdfc32d3 tests: Set an existing font in testfontchooser 2019-12-12 19:50:55 +01:00
Benjamin Otte
552db7cb08 types: Move GTK_INVALID_LIST_POSITION here
I have no idea where it should go really - maybe glib?

It certainly shouldn't require everybody including selectionmodel code
just to get at this value.
2019-12-12 19:10:45 +01:00
Matthias Clasen
d564cb2a7e Merge branch 'terminal' into 'master'
imwayland: Suppport terminal purpose

See merge request GNOME/gtk!1243
2019-12-12 17:57:05 +00:00
Dorota Czaplejewicz
e331b39ca5 imwayland: Suppport terminal purpose 2019-12-12 14:37:51 +00:00
Christoph Reiter
88da95d921 Merge branch 'honor-hotspot-gtk4' into 'master'
gdk/x11: Honor hotspot during drag cancel animation

See merge request GNOME/gtk!1236
2019-12-11 12:59:23 +00:00
Chun-wei Fan
44f9c67466 Merge branch 'vulkan-no-layered-windows' into 'master'
Win32: Do not enable layered windows when using Vulkan

See merge request GNOME/gtk!1217
2019-12-11 06:24:49 +00:00
Matthias Clasen
02bbe399df Merge branch 'matthiasc/for-master' into 'master'
widget factory: Fix more grid layout fallout

See merge request GNOME/gtk!1237
2019-12-10 03:05:09 +00:00
Matthias Clasen
41bb40feee widget factory: Fix more grid layout fallout 2019-12-09 21:29:03 -05:00
Benjamin Otte
336d652be5 a11y: We can peek here
Avoids instantiating a11y objects when we don't need to.
2019-12-09 16:35:41 +01:00