Commit Graph

36653 Commits

Author SHA1 Message Date
Carlos Garnacho
dc8adcda0e gtkgesture: ::cancel if a claimed sequence goes denied
The regular paths just emit ::end, which isn't the whole thing.
This gives an opportunity to gestures that are stolen the sequence
to clean themselves up.
2020-08-06 00:01:18 +02:00
Christian Hergert
5ff2b8535f textview: properly remove anchored widgets
Fixes #3021
2020-08-05 14:08:07 -07:00
Matthias Clasen
6dfd92b191 aspectframe: Fix use in ui files
GtkAspectFrame code assumes that its child will be in
self->child, but that is only the case if we arrange
for <child> in ui files to end up calling
gtk_aspect_frame_set_child(). Therefore, implement
GtkBuildable.

Fixes: #3020
2020-08-05 14:05:47 -04:00
Matthias Clasen
d7c4f93c76 Merge branch 'wip/compute-size' into 'master'
Compute size via signal

See merge request GNOME/gtk!2325
2020-08-05 16:19:19 +00:00
Matthias Clasen
df19049dde inspector: Stop showing settings bindings
We were playing fast-and-loose with private GIO data
when showing settings bindings in the property editor,
and this was causing crashes.

We can show this information again if GIO ever gets
api to introspect it.

Fixes: #3015
2020-08-05 11:11:58 -04:00
Jonas Ådahl
2ff74eb667 gdk/toplevel: Negotiate surface size via a compute-size signal
GTK will not up front know how to correctly calculate a size, since it
will not be able to reliably predict the constraints that may exist
where it will be mapped.

Thus, to handle this, calculate the size of the toplevel by having GDK
emitting a signal called 'compute-size' that will contain information
needed for computing a toplevel window size.

This signal may be emitted at any time, e.g. during
gdk_toplevel_present(), or spontaneously if constraints change.

This also drops the max size from the toplevel layout, while moving the
min size from the toplevel layout struct to the struct passed via the
signal,

This needs changes to a test case where we make sure we process
GDK_CONFIGURE etc, which means we also needs to show the window and
process all pending events in the test-focus-chain test case.
2020-08-05 15:49:00 +02:00
Matthias Clasen
d44d9ad40d Adwaita: Reduce the solid csd borders
Reduce the borders we draw ourselves for solid csd
to 1 pixel. It still doesn't look great, but at least
it doesn't look outright broken.

Fixes: #2997
2020-08-05 08:47:00 -04:00
Matthias Clasen
e60d6f70bf Merge branch 'drop-accel-label' into 'master'
Drop accel label

See merge request GNOME/gtk!2368
2020-08-05 03:44:43 +00:00
Matthias Clasen
8562c623d3 Drop GtkAccelLabel
We no longer use this widget anywhere.
2020-08-04 23:05:18 -04:00
Matthias Clasen
2b8aeed4d8 Drop GtkCallback
It is no longer used in any of our public APIs.
2020-08-04 22:24:33 -04:00
Matthias Clasen
ce89f1eda1 selectionfiltermodel: Drop a leftover symbol
We decided not to do new_for_type() for list model
wrappers, so this function does not exist.
2020-08-04 22:11:34 -04:00
Matthias Clasen
f561000124 docs: Clean up many dangling links
In many cases, these were references to no longer
existing api, so some rewording was necessary.
2020-08-04 22:11:34 -04:00
Matthias Clasen
0e1afbbdad Merge branch 'popoverflow' into 'master'
popover: Set overflow: hidden

Closes #3012

See merge request GNOME/gtk!2365
2020-08-04 15:47:50 +00:00
Matthias Clasen
d6e352e862 popover: Set overflow: hidden
This keeps overlay scrollbars from wrecking our
nice rounded corners.

Fixes: #3012
2020-08-04 11:10:49 -04:00
Matthias Clasen
f7eb5f8897 a11y: Don't do unnecessary work
Only serialize all the attributes if we are actually
going to print them.
2020-08-04 11:02:00 -04:00
Matthias Clasen
7398323b82 scrolledwindow: Fix a11y support code
This error was introduced by me in 971ee2d28a
and causes a crash in the scrolling benchmark in gtk-demo.

Fixes: #3014
2020-08-04 11:00:32 -04:00
Jonas Ådahl
cebe469898 gtk/window: Don't remember size from GdkSurface
If we're maximized, and try to remember the non-maximized size, we'd
still get the maximized size.
2020-08-04 15:04:24 +02:00
Matthias Clasen
e818e98187 Merge branch 'pagesetup-leftover' into 'master'
Pagesetup leftover

See merge request GNOME/gtk!2362
2020-08-04 03:47:13 +00:00
Matthias Clasen
942a90cd64 pagesetupdialog: Fix leftover tree model code
This was overlooked when the rest of the dialog
was ported to use list models.
2020-08-03 20:25:00 -04:00
Matthias Clasen
20c1fb0a0a docs: Tweak documentation for list widgets
Fix numerous cases of : vs :: for signal references,
add some more details here and there.
2020-08-03 18:43:25 -04:00
Matthias Clasen
7972dc8776 docs: Unify docs around incremental operations
Sync up the wording around incremental filtering
and sorting to be more similar.
2020-08-03 18:43:25 -04:00
Matthias Clasen
7cb0dd9039 docs: Fix signal references
It is :: for signals, : for properties, | for actions.
2020-08-03 18:43:25 -04:00
Alex
c8d51a7b98 show: remove obsolete comment
g_app_info_launch_default_for_uri supports x-scheme-handler directly since at least 2.27.1, released almost 10 years ago.

Link: https://bugzilla.gnome.org/show_bug.cgi?id=631410
Link: 9b262f1c5f
2020-08-03 15:36:36 +00:00
Matthias Clasen
83682d919f treeview: Don't react to clicks on cell editables
We need to let these pass through, otherwise we
interfere with the entries that are used for editing.

Fixes: #3008
2020-08-03 07:51:09 -04:00
Matthias Clasen
348a38a876 textview: Make insert-emoji replace the selection
This is the expected behavior, and matches what
GtkText does.

Fixes: #2996
2020-08-02 20:48:14 -04:00
Matthias Clasen
0d98bab82b Merge branch 'filechooser-completions' into 'master'
filechooser: Prevent over-eager completions

Closes #2995

See merge request GNOME/gtk!2347
2020-08-03 00:23:28 +00:00
Matthias Clasen
992c5fade7 Merge branch 'wip/chergert/gtk4-textview-fix-selections' into 'master'
textlinedisplaycache: short-circuit y_range invalidation

Closes #2975

See merge request GNOME/gtk!2348
2020-08-03 00:23:13 +00:00
Christian Hergert
94d17a6809 textlinedisplaycache: short-circuit y_range invalidation
If we have a y==-1 then we are generally invalidating the whole textview.
For this case, we can just discard the entire GtkTextLineDisplay cache.

Fixes #2975
2020-08-02 16:35:50 -07:00
Matthias Clasen
9605e49fbf filechooser: Prevent over-eager completions
We don't want the completions to pop up after we call
gtk_file_chooser_set_current_name(). This used to be
handled by gtk_entry_set_text() blocking the completion
signal handler. We don't have that anymore, so block
popup completion around the call to gtk_editable_set_text()
instead.

Fixes: #2995
2020-08-02 19:18:11 -04:00
Matthias Clasen
71be1751c6 builder-tool: Rewrite top/left-attach
Rewrite the GtkGrid:top/left-attach child properties
to the GtkGridLayoutChild:row/column layout properties.

Update expected test output to match.
2020-08-02 17:58:03 -04:00
Matthias Clasen
ed13e6a41e grid layout: Rename some properties
Rename GtkGridLayoutChild:left-attach/top-attach to
GtkGridLayoutChild:column/row. Update all users.

Fixes: #2967
2020-08-02 17:58:03 -04:00
Matthias Clasen
4340f75304 textbuffer: Fix a test failure
The previous change to gtktextbuffer.c was breaking
the textiter testcase.
2020-08-02 17:23:26 -04:00
Matthias Clasen
0add626822 textbuffer: Be careful with tags when copying
We can only insert tags in the buffer if they come
from the same GtkTextTagTable as the buffer uses.
If that is not the case, paste the text without tags.

Fixes: #2991
2020-08-02 13:54:06 -04:00
Matthias Clasen
793ea05f4a Merge branch 'text-drag-select' into 'master'
textview: Only claim the event when appropriate

Closes #2999

See merge request GNOME/gtk!2344
2020-08-02 17:45:30 +00:00
Matthias Clasen
c959f9c701 textview: Only claim the event when appropriate
Don't claim the event unconditionally for the click gesture,
since we may want to start a drag selection.

Fixes: #2999
2020-08-02 13:32:37 -04:00
Matthias Clasen
f8a303b0e5 popovermenu: Avoid a critical
While we guarantee that the widget that a controller
is attached to stays around while it is handling an event,
the same is not true for the root that the widget belongs
to. In corner cases (such as clicking "Close" in the
fallback window menu), it may already be gone.
Avoid a critical in that case.

Fixes: #2998
2020-08-02 13:09:00 -04:00
Matthias Clasen
ddda963f81 Merge branch 'selectable-label-draw' into 'master'
label: Redraw when focus changes

See merge request GNOME/gtk!2342
2020-08-02 16:40:12 +00:00
Matthias Clasen
9bf50e5650 Merge branch 'linked-button-fixes' into 'master'
Adwaita: Add linked styling for particular button widgets

Closes #2939 and #1903

See merge request GNOME/gtk!2339
2020-08-02 16:39:59 +00:00
Matthias Clasen
1c8471c38f label: Redraw when focus changes
When focus changes in a selectable label, we need to
redraw to make the text caret (dis)appear.
2020-08-02 12:11:38 -04:00
Matthias Clasen
17208ca7fa Go back to keeping a list of event controllers
This reverts 4b9e5304cc. It caused a number of regressions,
such as event controller ordering changes.
2020-08-02 12:01:06 -04:00
Matthias Clasen
1c16cb751f Revert "Add gtk_widget_prepend_controller"
This reverts commit 692cc42e10.
2020-08-02 12:01:06 -04:00
Matthias Clasen
127612d213 Revert "entry completion: Make keynav work again"
This reverts commit 53a30eaa12.
2020-08-02 12:01:06 -04:00
Matthias Clasen
888a65c1fb shortcutswindow: Clear search entry on unmap
Otherwise, the search term will linger around until
somebody clicks the search button again.

Fixes: #2981
2020-08-02 09:33:52 -04:00
nana-4
891027f0c3 Adwaita: Add linked styling for particular button widgets
Those button widgets need some special linked styling like what
combobox has.

Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/1903
Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/2939
2020-08-02 19:14:26 +09:00
nana-4
5f00675de4 appchooserbutton: Set a CSS name
Otherwise it has a CSS name "widget".
2020-08-02 18:26:40 +09:00
Matthias Clasen
d17e51df06 Merge branch 'inspector-device-details' into 'master'
inspector: Introspect enum values

See merge request GNOME/gtk!2338
2020-08-02 03:25:33 +00:00
Matthias Clasen
0d608c492d inspector: Introspect enum values
Stop hardcoding arrays with names for enum values.
This has bitten us repeatedly as these enums were
changed around; time to stop doing it.
2020-08-01 23:05:24 -04:00
Matthias Clasen
e0c7d7daeb menusectionbox: Avoid a critical warning
The popover may already be gone when the item
is activated. Don't trigger a critical in that
case.

Related: #2986
2020-08-01 22:03:41 -04:00
Matthias Clasen
64ed69c56f label: Be more selective when selecting on focus-in
We don't want to select on focus-in when the focus
comes from a child. The case where this does harm
is when you activate copy or paste actions from the
context menu. We close the menu before triggering the
action, and if that causes the text in the label to
be selected, unexpected things happen, since the action
applies to the current selection.

This is the equivalent of cd9f5733b3 for GtkLabel.
2020-08-01 22:01:52 -04:00
Matthias Clasen
74662776d4 togglebutton: Don't crash on click
The code used to do
if (parent_class->clicked)
  parent_class->clicked (...)
That is pointless because the parent_class never changes,
so there' no need for that if and commit 415946eb0f
took it out. Unfortunately, p arent_class->clicked is NULL
though, so the whole call needs to go.
2020-08-01 20:09:05 -04:00
Timm Bäder
41b458fba7 Fix and improve various code samples 2020-08-01 20:01:04 +02:00
Timm Bäder
f716daa483 aboutdialog: Fix a code sample
gdk_texture_new_from_file takes a GFile these days.
2020-08-01 19:30:31 +02:00
Timm Bäder
415946eb0f togglebutton: Modernice source file
Make this a little less ancient looking.
2020-08-01 19:24:54 +02:00
Timm Bäder
65b79d2585 Avoid refering to old GtkContainer API in the docs 2020-08-01 15:34:59 +02:00
Timm Bäder
e976825342 button: Use g_object_notify_by_pspec() 2020-08-01 15:34:07 +02:00
Timm Bäder
b489a1f6b5 stack: Allow NULL names
Does this work?
2020-08-01 15:27:13 +02:00
Timm Bäder
2f65459fcc stack: Only compare page names if the new page has one 2020-08-01 15:26:53 +02:00
Timm Bäder
f5af18738b listbox: Add _append
To have easy replacement API for gtk_container_add.
2020-08-01 15:26:28 +02:00
Timm Bäder
b37b85333d adwaita: Reset popover background in backdrop
Otherwise it inherits the generic background color from .background

Fixes #2766
2020-08-01 10:34:04 +02:00
Timm Bäder
76f2396764 popover: Use gtk_widget_add_css_class 2020-08-01 10:31:38 +02:00
Timm Bäder
547842e7f0 window: Keep titlebar after main child
Fixes #2949
2020-08-01 09:30:48 +02:00
Timm Bäder
ebaea07286 inspector: Avoid some failing casts
We might be inspecting a non-widget here, so can't just cast that.
2020-08-01 08:59:46 +02:00
Timm Bäder
0822de1971 textview: Only show "insert emoji" menu item if editable
Fixes #2974
2020-08-01 08:59:46 +02:00
Timm Bäder
bf24da0d80 inspector: Add a type check
We only connect to this signal if sl->obejct is a GtkAccessible, so only
disconnect from it on the same condition.

Fixes #2980
2020-08-01 08:59:41 +02:00
Rico Tzschichholz
d1cab4fbdd gtk: Add annotations to improve GIR API 2020-07-31 20:56:36 +02:00
Matthias Clasen
fc31f3d629 placesview: Keep up with GLib deprecations
We were using deprecated GBookmarkFile api here too.
2020-07-31 12:54:57 -04:00
Matthias Clasen
72e14bd6dd recentmanager: Keep up with GLib deprecations
All the time_t based apis in GBookmarkFile have
been deprecated; use GDateTime instead. This
changes a few GtkRecentManager APIs.
2020-07-31 12:18:47 -04:00
Matthias Clasen
99bb8bb3f7 numericsorter: Ignore deprecations
We use g_value_get_char here; replacing it with
g_value_get_schar is not entirely trivial, so just
ignore deprecations for now.
2020-07-31 11:36:03 -04:00
Matthias Clasen
ff42c94174 gtkicontheme: Stop using GTimeVal
It has been deprecated and the deprecation warnings
break our -Werror build in ci.
2020-07-31 11:22:16 -04:00
Matthias Clasen
8c66e2ff66 widget: Drop unnecessary includes
We don't need to include gobjectnotifyqueue.c anymore,
since style properties are gone. This should fix the
build with -Werror.
2020-07-31 10:34:37 -04:00
Matthias Clasen
62803c19f5 Merge branch 'focus-active' into 'master'
Focus active

Closes #2390

See merge request GNOME/gtk!2324
2020-07-30 17:50:54 +00:00
Matthias Clasen
643d873f47 eventcontrollerkey: Update im focus when active window changes
Use the new GTK_CROSSING_ACTIVE crossing events to update
the im context focus when the window becomes active or
inactive. IBus requires this, since it has only a single,
global focus location.

Fixes: #2390
2020-07-30 13:23:45 -04:00
Matthias Clasen
b0d40403e1 window: Emit GTK_CROSSING_ACTIVE crossing events
Emit crossing events when the active window changes.
We don't want to emit GTK_CROSSING_FOCUS events, since
every window has its own focus location (focus does not
jump from window to window), so we use the new
GTK_CROSSING_ACTIVE type of crossing event for this.
2020-07-30 13:22:26 -04:00
Matthias Clasen
12170acf46 Define GTK_CROSSING_ACTIVE
Document the different crossing event kinds that we use,
and add GTK_CROSSING_ACTIVE. We are going to use it in
the future when the active window changes.
2020-07-30 13:21:28 -04:00
Carlos Garnacho
96452a2e46 gdk: Rename gdk_seat_get_physical_devices() to gdk_seat_get_devices()
We don't want to tell what they are, and the distinction is now less
clear. Remove the adjective from the function name.
2020-07-30 18:44:40 +02:00
Carlos Garnacho
2f792396d7 gtkimcontext: Avoid gdk_device_get_associated_device()
Query the seat for that.
2020-07-30 18:30:13 +02:00
Carlos Garnacho
6730b26b43 gtktextview: Avoid gdk_device_get_associated_device()
Query the seat for that.
2020-07-30 18:30:13 +02:00
Carlos Garnacho
6e83d1f54e gtkwindowhandle: Avoid gdk_device_get_associated_device()
Query the seat for that.
2020-07-30 18:19:44 +02:00
Carlos Garnacho
fb9db7fede gtkdragsource: Avoid gdk_device_get_associated_device()
Query the seat for that.
2020-07-30 18:19:44 +02:00
Benjamin Otte
4dc2ab61c9 Merge branch 'wip/otte/geometry' into 'master'
Some GdkGeometry cleanups

See merge request GNOME/gtk!2322
2020-07-30 15:31:27 +00:00
Benjamin Otte
13d3afa56e Remove unused GDK_HINT_POS 2020-07-30 17:06:15 +02:00
Benjamin Otte
3dd0e6d0b1 Remove gravity from GdkGeometry
It's always northwest
2020-07-30 17:06:15 +02:00
Benjamin Otte
11db6ad574 Remove aspect ratio from GdkGeometry
It's unused.
2020-07-30 17:06:15 +02:00
Benjamin Otte
b12b06e917 gdk: Remove base_size and increment from GdkGeometry
It's unused.
2020-07-30 16:55:45 +02:00
neyfag
a27c3039d0 Scroll to cursor after canceling a selection 2020-07-30 15:52:57 +02:00
Rico Tzschichholz
f02a17805e a11y: Fix typo in GtkATContext::state-changed docs 2020-07-30 09:06:49 +02:00
Matthias Clasen
e8026e29b6 Merge branch 'surface-cleanup' into 'master'
Surface cleanup

See merge request GNOME/gtk!2317
2020-07-30 03:43:30 +00:00
Matthias Clasen
abf8cbeaea a11y: Set an accessible role for GtkLevelBar
Use the 'meter' role for GtkLevelBar, and set the
appropriate properties.

Update the docs and add a test.
2020-07-29 22:46:00 -04:00
Matthias Clasen
c0de580d46 a11y: Set an accessible role for GtkExpander
Use the button accessible role for GtkExpander
and set attributes as appropriate.

Update the documentation and add a test.
2020-07-29 22:46:00 -04:00
Matthias Clasen
144114bf40 a11y: Set accessible role for GtkLinkButton
Set the accessible role for GtkLinkButton to button.
We don't use the 'link' role since ARIA says "if it
behaves like a button, use 'button'".

Update docs and add a test.

This changes should not be neccessary, since
GtkLinkButton derives from GtkButton, see #2965.
2020-07-29 22:46:00 -04:00
Matthias Clasen
c68fe1053a a11y: Set an accessible role for GtkTextView
Use the text-box accessible role for GtkTextView
and set properties as appropriate.

Update the documentation and add a test.
2020-07-29 22:46:00 -04:00
Matthias Clasen
4d012a6d95 Rename gdk_surface_queue_expose
We don't have expose events anymore; instead, there
is a ::render signal. So rename queue_expose to
queue_render to match.

Update all callers.
2020-07-29 22:40:01 -04:00
Jonas Ådahl
c7c71137b2 gdk/monitor: Remove gdk_monitor_work_area and GdkMonitor::work-area
It's not a portable API, so remove it. The corresponding backend
specific functions are still available, if they were implemented, e.g.
gdk_macos_monitor_get_workarea() and gdk_x11_monitor_get_workarea().
2020-07-29 17:57:30 +02:00
Matthias Clasen
d40b1d31b5 Merge branch 'doc-fixes' into 'master'
Doc fixes

See merge request GNOME/gtk!2314
2020-07-29 11:24:48 +00:00
Matthias Clasen
5fd03f3297 Merge branch 'a11y-work' into 'master'
A11y work

See merge request GNOME/gtk!2312
2020-07-29 11:19:22 +00:00
Matthias Clasen
d0abe5a919 filter: Typo fix 2020-07-28 22:40:10 -04:00
Matthias Clasen
26200c0f7e filechooser: Document the response.activate action 2020-07-28 22:40:10 -04:00
Matthias Clasen
07bf9045fb a11y: Document GtkATContext::state-changed 2020-07-28 22:40:10 -04:00
Matthias Clasen
e07b9605bc a11y: Fix a few glitches in the role enum
When the enumeration was synced with the latest draft
of the ARIA spec, the math and note roles missed the boat.
2020-07-28 22:20:40 -04:00
Matthias Clasen
b5f256937f Merge branch 'wip/carlosg/device-api-cleanup' into 'master'
Cleanups to device/event API

See merge request GNOME/gtk!2313
2020-07-28 23:49:35 +00:00
Carlos Garnacho
cab1dcb696 gdk: Conflate GDK devices
Make GdkEvents hold a single GdkDevice. This device is closer to
the logical device conceptually, although it must be sufficient for
device checks (i.e. GdkInputSource), which makes it similar to the
physical devices.

Make the logical devices have a more accurate GdkInputSource where
needed, and conflate the event devices altogether.
2020-07-29 01:27:51 +02:00
Carlos Garnacho
2736633a60 inspector: Show tool axes, instead of device axes
We are moving away from the latter as they are inconsistent with
Wayland. Make the inspector introspect known tools and their info,
instead.
2020-07-29 01:27:51 +02:00
Matthias Clasen
1755e07af7 a11y: Set an accessible role for GtkPasswordEntry
Use the text-box accessible role for GtkPasswordEntry.
And set properties as appropriate.

Update the documentation and add a test.
2020-07-28 18:23:57 -04:00
Matthias Clasen
a610bb89a0 a11y: Set an accessible role for GtkSearchEntry
Use the searchbox accessible role for GtkSearchEntry.
And set properties as appropriate.

Update the documentation and add a test.
2020-07-28 18:16:37 -04:00
Matthias Clasen
2040b7ecdf a11y: Set an accessible role for GtkLabel
Use the label accessible role for GtkLabel. ARIA has some
ominous wording about it going way, but while we have it,
GtkLabel is the obvious candidate for carrying it.

Update the documentation and add a test.
2020-07-28 18:16:37 -04:00
Matthias Clasen
9a82aadca7 a11y: Set an accessible role for GtkEntry
Use the text-box accessible role for GtkEntry and
set the placeholder and read-only accessible properties.

Update the documentation and add tests.
2020-07-28 18:16:37 -04:00
Matthias Clasen
971ee2d28a a11y: Set up controls relations for scrollbars
GtkScrolledWindow knows what its scrollbars control,
so set up the accessible relations for this.
2020-07-28 18:16:37 -04:00
Matthias Clasen
efd4169fa2 a11y: Set accessible roles for GtkImage and GtkPicture
Use the img accessible role for these.
Also update the documentation and add tests.
2020-07-28 18:16:37 -04:00
Emmanuele Bassi
3294557717 a11y: Update the valuetext attribute of GtkProgressBar
Since progress bars can have a label, we should propagate that information
to ATs whenever it's set.
2020-07-28 16:59:08 +01:00
Emmanuele Bassi
470349c902 a11y: Add an explicit "reset to default" method
In some cases we explicitly want to unset an accessible attribute; for
instance, an accessible property is gated on a widget property, and if
the widget property gets unset, the accessible property should be reset.
2020-07-28 16:49:13 +01:00
Emmanuele Bassi
bf06cad5d9 a11y: Add proper error reporting to value collection
We're currently overloading NULL to mean both "this value is undefined,
and should be reset to its default" and "the value collection failed".
Let's do error reporting right, by using GError to mean "the collection
failed, for this specific reason"; then, we can use a NULL return value
to signal that the accessible attribute should be reset to its default
value.

This is only relevant for pointer-sized attribute values: strings,
references, and reference lists; numeric, boolean, tristate, and token
values either cannot be undefined, or have a specific "undefined" value.
2020-07-28 16:49:13 +01:00
Emmanuele Bassi
2e8de6bd88 a11y: Fix the error message for the attribute test macros
We're missing a closing parenthesis.
2020-07-28 16:49:13 +01:00
Emmanuele Bassi
7f04faf30d a11y: Use undefined as default for string attributes
Instead of an empty string.
2020-07-28 16:49:13 +01:00
Carlos Garnacho
5f8258109e gtkwindow: Move away from gdk_device_get_state()
Use gdk_device_get_modifier_state() poking the keyboard and keymap,
instead of this function.
2020-07-28 17:36:18 +02:00
Carlos Garnacho
6a4277a9a9 gtkpopover: Move away from gdk_device_get_state()
Use gdk_device_get_modifier_state() poking the keyboard and keymap,
instead of this function.
2020-07-28 17:36:18 +02:00
Matthias Clasen
42a4940671 inspector: Show a11y information
Show a tab for  accessibility information.

This shows the role and the accessible attributes
(states, properties, relations).

For now, changing the values is not possible, and
we only show the explicitly set values. In the future,
we want to show the attributes that are relevant for
the role, regardless of whether they are set or not,
and allow changing some of the attributes (the ones
that are not fully managed by GTK itself).
2020-07-28 08:41:24 -04:00
Matthias Clasen
ecc329fa2a a11y: Add change notification to GtkATContext
Emit a ::state-change signal when state changes;
this was already a vfunc, but we want to listen
to state changes from the inspector too.
2020-07-28 08:41:24 -04:00
Emmanuele Bassi
5fc5e52f52 Merge branch 'a11y-tests' into 'master'
Add more a11y tests

See merge request GNOME/gtk!2303
2020-07-28 11:47:14 +00:00
Matthias Clasen
1d8e62fb01 Merge branch 'wip/baedert/for-master' into 'master'
Wip/baedert/for master

See merge request GNOME/gtk!2306
2020-07-28 11:44:05 +00:00
Emmanuele Bassi
a85ba95b20 Split GtkProgressBar finalization
We're stopping activity mode when finalizing, which will change
accessible state; this will create a GtkATContext, and since GtkWidget
drops its GtkATContext on dispose(), we're going to end up leaking it on
the floor:

```
2,007 (64 direct, 1,943 indirect) bytes in 1 blocks are definitely lost in loss record 36,242 of 36,944
   at 0x483977F: malloc (vg_replace_malloc.c:307)
   by 0x5222105: g_malloc (gmem.c:106)
   by 0x523E222: g_slice_alloc (gslice.c:1025)
   by 0x523E261: g_slice_alloc0 (gslice.c:1051)
   by 0x534B398: g_type_create_instance (gtype.c:1849)
   by 0x53302EE: g_object_new_internal (gobject.c:1937)
   by 0x53312AF: g_object_new_valist (gobject.c:2262)
   by 0x532FEE8: g_object_new (gobject.c:1780)
   by 0x4B3F942: gtk_test_at_context_new (gtktestatcontext.c:107)
   by 0x491CC50: gtk_at_context_create (gtkatcontext.c:380)
   by 0x4BFEDA0: gtk_widget_accessible_get_at_context (gtkwidget.c:8127)
   by 0x4906079: gtk_accessible_get_at_context (gtkaccessible.c:83)
   by 0x490618F: gtk_accessible_update_state (gtkaccessible.c:137)
   by 0x4ACBA6D: gtk_progress_bar_act_mode_leave (gtkprogressbar.c:690)
   by 0x4ACB4F8: gtk_progress_bar_finalize (gtkprogressbar.c:564)
```

We're also unparenting widgets and changing styles, which is another
potential source of leaks and side effects.
2020-07-28 11:47:40 +01:00
Timm Bäder
2050120098 bitset: Fix typo 2020-07-28 08:10:43 +02:00
Timm Bäder
bbabec3f18 inspector: Avoid an uninitialized value 2020-07-28 05:34:12 +02:00
Timm Bäder
f4d9e4032f widget: Compare proper adjusted size to new size when allocating
We were comparing first but then still modifying the adjusted size later
on, leading to unnecessary resizes.
2020-07-28 05:34:11 +02:00
Matthias Clasen
9458c1cc47 spinbutton: Update accessible state
Make sure to set value-max/min/now when the adjustment
changes.
2020-07-27 21:18:10 -04:00
Matthias Clasen
e10aedccc6 widget: Update accessible state
The sensitive property corresponds to the accessible
property disabled, so update it when sensitivity
changes.
2020-07-27 21:18:10 -04:00
Matthias Clasen
a63d03810f scrollbar: Update accessible state
We have the scrollbar role, and are therefore expected
to set value-min/max/now properties.
2020-07-27 21:18:10 -04:00
Matthias Clasen
2ef4be21c8 switch: Initialize accessible state
The checked state defaults to undefined, so we need
to set it to the desired false state.
2020-07-27 21:18:10 -04:00
Matthias Clasen
d8ac144923 separator: Initialize accessible state
The orientation property of separators should be
set ab initio.
2020-07-27 21:18:10 -04:00
Matthias Clasen
ec5829c401 progressbar: Fix up acessible state handling
We must initialize the properties in init, since they
are expected to be there ab initio, and we can't call
gtk_accessible_update_property from finalize - it causes
us to recreate an at context and badness follows.
2020-07-27 21:18:10 -04:00
Matthias Clasen
29cf11fb6e a11y: Set an accessible role for GtkWindow
Use the window accessible role for GtkWindow, and
set the modal accessible property.
2020-07-27 21:18:10 -04:00
Matthias Clasen
4a9b4ad720 checkbutton: Initialize accessible state
The checked state of checkbuttons should be FALSE
initially, not UNDEFINED.
2020-07-27 21:18:09 -04:00
Matthias Clasen
d90f79de0e a11y: Document roles of widgets
Add a section to the long description for each
widget that is using a non-default accessible role.
2020-07-27 10:48:08 -04:00
Emmanuele Bassi
05d9e0c1c8 a11y: Allow unsetting the relations using NULL
Accessible values storing references and reference lists can be unset by
using NULL to mean "undefined"; since we cannot return the NULL value,
we need to intercept it when collecting a value, and replace it with an
undefined GtkAccessibleValue, which is also the value used as the
default for GtkAccessibleRelation values that store a reference or a
reference list.

Fixes: #2955
2020-07-27 14:26:19 +01:00
Matthias Clasen
bc0182fa3e Merge branch 'ebassi/new-a11y' into 'master'
Accessibility rework

See merge request GNOME/gtk!2239
2020-07-27 11:55:19 +00:00
Emmanuele Bassi
4060febd7f a11y: Make GtkATContext.create() public
Implementations of the GtkAccessible interface should have a way to
instantiate the appropriate GtkATContext.
2020-07-27 11:48:11 +01:00
Emmanuele Bassi
9a4458ba33 docs: Add missing GTK_ACCESSIBLE_VALUE_UNDEFINED 2020-07-27 11:46:07 +01:00
Matthias Clasen
4c5df54e39 a11y: Be a bit safer against crashes
We are collecting values from varargs and use them
as indices into static arrays. We should at least
do some bounds checking to prevent silly crashes.
2020-07-27 00:21:01 -04:00
Matthias Clasen
2ce6ac00cf docs: Expand GtkAccessible documentation
Add some hints and examples.
2020-07-26 22:39:47 -04:00
Matthias Clasen
98f3112158 docs: Add documentation for accessible enumerations
This is largely taking text from the aria spec.
2020-07-26 22:39:47 -04:00
Matthias Clasen
9a27614b41 docs: Update GtkAccessibleRole docs
Sync up the docs with changed enum values, and document
all the roles that are used in GTK at the moment. All
others are left as "Unused".
2020-07-26 21:23:48 -04:00
Matthias Clasen
81c8a2bb4b docs: Update a11y docs
Add some missing functions.
2020-07-26 21:23:48 -04:00
Matthias Clasen
d187ff858c Merge branch 'drop-down-constructor' into 'master'
GtkDropDown api revisions

See merge request GNOME/gtk!2286
2020-07-26 23:57:48 +00:00
Matthias Clasen
e57d6ec359 Merge branch 'list-constructors' into 'master'
List constructors

See merge request GNOME/gtk!2296
2020-07-26 23:56:21 +00:00
Matthias Clasen
eb5c76210e gridview: Revise constructors
Make both gtk_grid_view_new and gtk_grid_view_new_with_factory
take a model as first argument, and make all arguments
allow-none and transfer full.

Update all callers.
2020-07-26 18:50:50 -04:00
Matthias Clasen
fc22b75a06 columnview: Revise the constructor
Make gtk_column_view_new take a model as first argument,
and make it allow-none and transfer full.

Update all callers.
2020-07-26 18:32:50 -04:00
Matthias Clasen
43000abeff listview: Revise constructors
Make both gtk_list_view_new and gtk_list_view_new_with_factory
take a model as first argument, and make all arguments
allow-none and transfer full.

Update all callers.
2020-07-26 18:27:23 -04:00
Matthias Clasen
f7ab6f665d dropdown: Revise constructors
A dropdown without a model is useless, so accept a model
and expression in the constructor. Allow them to be NULL,
but consume them if given. This makes chained constructors
convenient without breaking language bindings.

Drop gtk_drop_down_set_from_strings() and instead add
gtk_drop_down_new_from_strings().

Update all users.
2020-07-26 18:09:54 -04:00
Matthias Clasen
72bb7fc701 selectionfiltermodel: Make constructor allow-none
We don't pay attention to item-type anymore, so
drop the item-type property and the _for_item_type()
constructor, and allow passing NULL to the regular
constructor.

We don't make this constructor transfer-full, since
the selection filter model is not a wrapping model
like the others. It is more like fork than a wrap.
2020-07-26 18:04:40 -04:00
Matthias Clasen
cdc263f796 multiselection: Make constructor transfer full
This is for consistency with other wrapping list constructors.
We want them all to be transfer full, allow-none.

Also make the constructor return GtkMultiSelection *.

Update all callers.
2020-07-26 18:04:40 -04:00
Matthias Clasen
ccb9dcc86b singleselection: Make constructor transfer full
This is for consistency with other wrapping list constructors.
We want them all to be transfer full, allow-none.

Update all callers.
2020-07-26 18:04:40 -04:00
Matthias Clasen
68d6671413 noselection: Make constructor transfer full
This is for consistency with other wrapping list constructors.
We want them all to be transfer full, allow-none.

Update all callers.
2020-07-26 18:04:40 -04:00
Matthias Clasen
dd1c0c0b22 treelistmodel: Make constructor transfer full
Make gtk_tree_list_model_new() take the root model
as first argument, and make it transfer full, for
consistency with other wrapping list constructors.

Update all callers.

Still missing here: Make the model property writable,
and allow passing NULL in the constructor.
2020-07-26 18:04:40 -04:00
Matthias Clasen
a46cfd3ff4 sortlistmodel: Make constructor transfer full
This is for consistency with other wrapping list constructors.
We want them all to be transfer full, allow-none.

Update all callers.
2020-07-26 18:04:40 -04:00
Matthias Clasen
706d464ae6 filterlistmodel: Make constructor transfer full
This is for consistency with other wrapping list constructors.
We want them all to be transfer full, allow-none.

Update all callers.
2020-07-26 18:04:40 -04:00
Matthias Clasen
b6d9f3facb slicelistmodel: Make constructor transfer full
This is for consistency with other wrapping list constructors.
We want them all to be transfer full, allow-none.

Update all callers.
2020-07-26 18:04:40 -04:00
Matthias Clasen
06c6d62629 listlistmodel: Drop item_type
We are using G_TYPE_OBJECT throughout, so there
is no need for GtkListListModel to do anything else.

Update all callers.
2020-07-26 18:02:51 -04:00
Matthias Clasen
32b8fe40bb maplistmodel: Make constructor transfer full
This is for consistency with other wrapping list constructors.
We want them all to be transfer full, allow-none.

Update all callers.
2020-07-26 18:02:51 -04:00
Matthias Clasen
1e8be87026 flattenlistmodel: Make the constructor transfer full
This is for consistency with other wrapping list constructors.
We want them all to be transfer full, allow-none.

Update all callers.
2020-07-26 18:02:44 -04:00
Emmanuele Bassi
3d642460e7 a11y: Simplify the test API
We don't need as many functions to print out the property, relation, and
state of an accessible. Additionally, we should allow comparing the
accessible attributes with an expected value, and print out the real
accessible value if they do not match.
2020-07-26 21:27:03 +01:00
Emmanuele Bassi
82664003c0 a11y: Allow setting the role post-construction
Some widgets have different roles after they are constructed, so we need
to allow changing the role defined by the class. We should still avoid
setting a role after the GtkATContext has been created.
2020-07-26 21:27:03 +01:00
Emmanuele Bassi
b9a1cb74a1 a11y: Add API to retrieve accessible values
We are going to use this for implementing ATContext subclasses, but also
in the testing API.
2020-07-26 20:49:08 +01:00
Emmanuele Bassi
dc1c1e8af9 a11y: Add more test API 2020-07-26 20:49:08 +01:00
Emmanuele Bassi
296f0844df Fix build with debugging notes disabled 2020-07-26 20:31:15 +01:00
Matthias Clasen
e17b5f337d a11y: Update GtkCheckButton
This is a bit unfortunate, since the aria modelling
doesn't quite agree with ours, so we have to listen
for the togglebutton property change, and we inherit
the pressed state from the togglebutton accessible.
2020-07-26 20:31:15 +01:00
Matthias Clasen
c36ad5f474 a11y: Update GtkSpinButton
Set the appropriate accessible role, and update
the value properties.
2020-07-26 20:31:15 +01:00
Matthias Clasen
b7777add36 a11y: Update GtkProgressBar
Update state and properties as appropriate.
2020-07-26 20:31:15 +01:00
Matthias Clasen
609383f93c testatcontext: Print role nicks
This makes for easier reading.
2020-07-26 20:31:15 +01:00
Emmanuele Bassi
a9e0cf77a0 a11y: Update labelled-by when setting mnemonic labels
The ARIA labelled-by attribute behaves the same way as the mnemonic
labels in GTK.
2020-07-26 20:31:15 +01:00
Emmanuele Bassi
86b58529fd a11y: Change the collection type for reflist attributes 2020-07-26 20:31:15 +01:00
Emmanuele Bassi
2fee3793b4 a11y: Allow storing list of references in GtkAccessibleValue
It's one of the fundamental accessible value types in ARIA.
2020-07-26 20:31:15 +01:00
Emmanuele Bassi
03b773f45a a11y: Change default accessible role
Only GtkWidget should use GTK_ACCESSIBLE_ROLE_WIDGET as its default
accessible role; the default for GtkAccessible and GtkATContext should
be GTK_ACCESSIBLE_ROLE_NONE, meaning "an element whose implicit native
role semantics will not be mapped to the accessibility API", according
to the WAI-ARIA specification.
2020-07-26 20:31:15 +01:00
Matthias Clasen
8adcf95300 inspector: Support the a11y debug flag
Add support for the GTK_DEBUG_A11Y debug flag in
the logs tab.
2020-07-26 20:31:15 +01:00
Matthias Clasen
0b6df9efe7 testatcontext: Use the new debug flag
Only dump a11y state if GTK_DEBUG=accessibility is set.
2020-07-26 20:31:15 +01:00
Matthias Clasen
01f31665b8 Add GTK_DEBUG=accessibility
Add a debug flag for accessibility-related debug spew.
2020-07-26 20:31:15 +01:00
Emmanuele Bassi
0d87f8cd62 a11y: Add testing API
We want to test the accessibility API, as well as the implementation
inside each widget. For that, we should expose an API that lets us
verify that a GtkAccessible has a given role, as well as a given
property.

The API follows the pattern of other GTest API:

 - a macro to assert that a condition is respected
 - a function that prints out the error message in case of failure
2020-07-26 20:31:15 +01:00
Emmanuele Bassi
52c1fb8dfe a11y: Implement role and state change in GtkSwitch
Set the "switch" role, and update the "checked" state when the :active
property is toggled.
2020-07-26 20:31:15 +01:00
Emmanuele Bassi
732578eb53 a11y: Consolidate the attributes container
While we have split the various attributes for convenience, there's no
reason why we should have specialised data types for the attributes
container object.
2020-07-26 20:31:15 +01:00
Emmanuele Bassi
1124f2507d a11y: Add relations API
Since we split relation attributes from the generic properties, we need
to add API for setting and retrieving their values.
2020-07-26 20:31:15 +01:00
Emmanuele Bassi
d37511f76b a11y: Simplify GtkAccessibleValue
Reduce the amount of subclassing, by handling collection of fundamental
types directly from the generic code paths. We now handle boolean,
tristate, integer, number, string, and relation values in the generic
code path; if an attribute supports the "undefined" value, we return the
undefined value singleton.
2020-07-26 20:31:15 +01:00
Emmanuele Bassi
55d29d08a1 a11y: Resync with the ARIA spec
Drop roles and properties that were deprecated in WAI-ARIA 1.1, and add
new roles and properties defined in WAI-ARIA 1.2 and later.

We also split the relationship properties into their own enumeration, so
we can keep the GtkAccessibleProperty type more compact.
2020-07-26 20:31:15 +01:00
Emmanuele Bassi
ae446e8f4a Remove GTK_ACCESSIBLE_STATE_NONE
It's pointless, we can use an explicit value of `-1` everywhere.
Additionally, it complicates all code that uses the state enumeration as
an array index, since now we need to guard against a negative offset.
2020-07-26 20:31:15 +01:00
Emmanuele Bassi
c56e9b2031 a11y: Add binding-friendly accessible property setter
Matching the one for the accessible state.
2020-07-26 20:31:15 +01:00
Emmanuele Bassi
93978544c0 a11y: Collect reference value
Some properties that take a reference to an accessible haven't been
updated to collect the correct type.
2020-07-26 20:31:15 +01:00
Emmanuele Bassi
1b612cd5db a11y: Update the accessible label for GtkButton 2020-07-26 20:31:15 +01:00
Emmanuele Bassi
3a1d69ca29 a11y: Update GtkSeparator
Add an accessible role, and update the orientation state.
2020-07-26 20:31:15 +01:00
Emmanuele Bassi
9af74629f6 a11y: Set the role for GtkScale 2020-07-26 20:31:15 +01:00
Emmanuele Bassi
59d85d42cf a11y: Update the accessible state for GtkRange 2020-07-26 20:31:15 +01:00
Emmanuele Bassi
2c75ba5509 a11y: Update the "pressed" state on toggle buttons 2020-07-26 20:31:15 +01:00
Emmanuele Bassi
58628f9a9e a11y: Add roles to various widgets 2020-07-26 20:31:15 +01:00
Emmanuele Bassi
da1ce01a6f Add accessible properties to GtkAccessible
We propagate the accessible state and properties to each ATContext in
the same virtual function, since they are functionally similar.
2020-07-26 20:31:15 +01:00
Emmanuele Bassi
654956223d Add GtkAccessiblePropertySet
Like GtkAccessibleStateSet, the PropertySet is a set for accessible
properties.
2020-07-26 20:31:15 +01:00
Emmanuele Bassi
382fa01301 Plumb all the GtkAccessibleProperty values into GtkAccessibleValue
Similarly to how we deal with GtkAccessibleState.
2020-07-26 20:31:15 +01:00
Emmanuele Bassi
572861be27 Allow setting the accessible role at construction
Some widgets have different accessible roles depending on some
parameter, so we cannot set the role at class init time. For those
widgets, we add an "accessible-role" property to GtkAccessible, and we
allow setting it (only) at construction time.
2020-07-26 20:31:15 +01:00
Emmanuele Bassi
3ea069a8d3 Update the accessible state on widget visibility changes
The GTK_ACCESSIBLE_STATE_HIDDEN has the opposite meaning of the
GtkWidget:visible property.
2020-07-26 20:31:14 +01:00
Emmanuele Bassi
25f6da5e89 Have GtkWidget implement GtkAccessible
Each widget type has an accessible role associated to its class, as
roles cannot change during the life time of a widget instance.

Each widget is also responsible for creating an ATContext, to proxy
state changes to the underlying accessibility infrastructure.
2020-07-26 20:31:14 +01:00
Emmanuele Bassi
566f75af82 Plug GtkATContext into GtkAccessible
An Accessible implementation must create an ATContext object. UI
elements are supposed to interact with the GtkAccessible API, but we
expose GtkATContext to allow patterns like delegation.
2020-07-26 20:31:14 +01:00
Emmanuele Bassi
a382dfd3bd Add GtkATContext
The ATContext type is meant to be used as the base class for
implementations of the assistive technology API—the actual mechanism
needed to communicate to components like the screen reader, or any other
AT.

Every time the widget state changes, the ATContext is meant to broadcast
the state change; and every time the AT queries the state of a UI
element, the ATContext is meant to provide that information.

We also have a "test" ATContext implementation, which is meant to be
used to write tests to verify that changes are propagated without
requiring a whole desktop session.
2020-07-26 20:31:14 +01:00
Emmanuele Bassi
823ee58332 Add GtkAccessibleStateSet
Since states can be set or unset, we need a container type that has all
the possible states, and a bitmask that tells us which ones are set.
2020-07-26 20:31:14 +01:00
Emmanuele Bassi
55120a25db Add GtkAccessibleValue
All accessible properties and states may have one of the following
types:

 - true/false
 - true/false/undefined
 - true/false/mixed/undefined
 - reference (to another UI element)
 - reference list
 - integer
 - number (real numerical value)
 - string
 - token (one of a limited set of allowed values)
 - token list

See: https://www.w3.org/WAI/PF/aria/states_and_properties#propcharacteristic_value

The GtkAccessibleValue is a simple reference counted type that can be
"subclassed" to implement each value type.

This initial commit adds GtkAccessibleValue and the basic subclasses for
plain boolean, tristate (true/false/undefined), and token types,
including statically allocated values that can be shared instead of
allocated.
2020-07-26 20:31:14 +01:00
Emmanuele Bassi
14faec3ce2 Introduce GtkAccessible
GtkAccessible is an interface for accessible UI elements.

Currently, it doesn't do much except exist as a type; in the future, it
will be the entry point for all accessible state in GTK.
2020-07-26 20:31:14 +01:00
Emmanuele Bassi
82fe6fbc62 a11y: Add the supported accessibility roles
The list of roles is taken from the WAI-ARIA 1.2 specification:

  https://w3c.github.io/aria/

Some of these roles do not make entirely sense from a GTK application
perspective, but we can remove them before finalizing the API.
2020-07-26 20:31:14 +01:00
Emmanuele Bassi
c63087a563 Remove ATK
To build a better world sometimes means having to tear the old one down.
        -- Alexander Pierce, "Captain America: The Winter Soldier"

ATK served us well for nearly 20 years, but the world has changed, and
GTK has changed with it. Now ATK is mostly a hindrance towards improving
the accessibility stack:

 - it maps to a very specific implementation, AT-SPI, which is Linux and
   Unix specific
 - it requires implementing the same functionality in three different
   layers of the stack: AT-SPI, ATK, and GTK
 - only GTK uses it; every other Linux and Unix toolkit and application
   talks to AT-SPI directly, including assistive technologies

Sadly, we cannot incrementally port GTK to a new accessibility stack;
since ATK insulates us entirely from the underlying implementation, we
cannot replace it piecemeal. Instead, we're going to remove everything
and then incrementally build on a clean slate:

 - add an "accessible" interface, implemented by GTK objects directly,
   which describe the accessible role and state changes for every UI
   element
 - add an "assistive technology context" to proxy a native accessibility
   API, and assign it to every widget
 - implement the AT context depending on the platform

For more information, see: https://gitlab.gnome.org/GNOME/gtk/-/issues/2833
2020-07-26 20:31:14 +01:00
Benjamin Otte
2f27d29247 Add GtkBoolFilter
Takes a boolean GtkExpression (like a boolean object property) to run a
filter with.
2020-07-26 20:43:08 +02:00
Matthias Clasen
7f9570b95b overlaylayout: Document minimally
This layout manager is not reusable, but we
still need to make its layout properties show
up in the docs.
2020-07-25 19:02:33 -04:00
Matthias Clasen
2ff3e3d1e4 gtk: Improve struct packing in places
Plug some holes in our structs by rearranging
a few fields. This is was done looking at
pahole output.
2020-07-25 11:57:37 -04:00
Matthias Clasen
6e9dbba130 colorswatch: Remove unused radius fields
The radius fields are never used.
2020-07-25 11:57:37 -04:00
Matthias Clasen
706aa93ab5 hsla: Just store floats
We are using floats for rgb, and we don't need more precision
for hsl colors either. We use hsl for computing color expressions
like shade(), lighter() and darker(), which are not precisely
specified anyway.

This commit updates the one test where the output changes a
tiny bit due to this.
2020-07-25 11:56:05 -04:00
Matthias Clasen
54deed9a5a headerbar: Drop the Private struct 2020-07-25 07:41:05 -04:00
Matthias Clasen
0e70ddcab3 colorplane: Drop the Private struct and padding 2020-07-24 22:56:24 -04:00
Matthias Clasen
f2bdb1fb87 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!2283
2020-07-25 00:05:28 +00:00
Matthias Clasen
e9bff53015 timsort: Avoid a crash
We need to clear the pointer after freeing the data,
since the sortlistmodel keeps its timsort structure
around and reuses it.
2020-07-24 19:23:18 -04:00
Benjamin Otte
3078b180fe Replace "gdouble" with "double" 2020-07-25 00:47:36 +02:00
Benjamin Otte
556997f9df Replace "gfloat" with "float" 2020-07-25 00:47:36 +02:00
Benjamin Otte
d375dce9f5 Replace "gchar" with "char" 2020-07-25 00:47:36 +02:00
Benjamin Otte
d7266b25ba Replace "gint" with "int" 2020-07-25 00:47:36 +02:00
Matthias Clasen
f7b73b2e01 sortlistmodel: Fix a crash 2020-07-24 14:15:14 -04:00
Matthias Clasen
c85e424279 dropdown: Fix popup sizing
Setting a width request is not quite enough, since
gtk_widget_set_size_request() only queues a resize
when the widget is visible. Explicitly force one
here. Without this, the popup sometimes shows up
too small.
2020-07-24 14:15:04 -04:00
Florian Müllner
b146c48e23 menubutton: Remove align-widget property
The property has been unused since commit 8701e34f74. That was four
years ago, so it's safe to say that nobody has been missing it terribly.
2020-07-24 13:55:06 +02:00
Matthias Clasen
1e00c887ec docs: Work around escaping bugs
This is truly a russian doll of documentation formats:
a string containing <> inside an xml fragment in an |[ ]|
gtk-doc example in markdown in a doc comment.

Sadly, something gets escaping wrong, so the <> end up
literally in the docbook and mess up the last step of
our document formatting, even after turning them into
entities.

Work around this with an extra level of entities that
really shouldn't be necessary.
2020-07-23 18:24:18 -04:00
Matthias Clasen
03601cb794 docs: Improve shortcut trigger docs
Point out the need to escape <> in xml.
2020-07-23 18:24:18 -04:00
Matthias Clasen
3108b8b4d3 docs: Explain the shortcutcontroller example a bit
Add a reference to the the syntax for shortcut actions
in builder files.
2020-07-23 18:24:18 -04:00
Matthias Clasen
d1afe32762 filechooser: Remove a leftover signal emission
Commit 0145809a94 replace the response-requested
signal with an action, but didn't actually remove the emission
of that no-longer-existing signal.

Fixes: #2942
2020-07-23 12:54:07 -04:00
Benjamin Otte
e81ba8924a searchenginemodel: Remove unused code 2020-07-23 15:31:08 +02:00
Benjamin Otte
8832ab45d9 searchengine: Remove unused set_recursive() call 2020-07-23 15:31:08 +02:00
Benjamin Otte
e22abd73f2 timsort: Actually 0-terminate the array in get_runs()
This could cause SEGVs when changing the sort during an ongoing sort
operation.
2020-07-22 18:59:22 +02:00
Matthias Clasen
63a4345d2c Merge branch 'wip/otte/sortlistmodel2' into 'master'
Massively refactor and improve sortlistmodel

See merge request GNOME/gtk!2273
2020-07-22 13:15:45 +00:00
Benjamin Otte
2b19e2fc1f sortlistmodel: Add progress estimation 2020-07-22 14:30:49 +02:00
Benjamin Otte
703f8b8136 timsort: Add progress estimation 2020-07-22 14:30:49 +02:00
Benjamin Otte
5b18968867 sortlistmodel: Make key generation part of the step function
SSave the missing keys as a bitset and iterate over that bitset in the
step function.

Solves the problem with a large UI block at the beginning of a sort
operation when all the keys were generated, in particular when key
generation was slow.

Benchmarks for maximum time taken by a single main loop callback:

     initial sort with complex GFileInfo keys
                       old      new
      32,000 items   137ms      3ms
     128,000 items   520ms     31ms

     initial sort with string keys
                       old      new
      32,000 items   187ms      1ms
     128,000 items   804ms      3ms
2020-07-22 14:30:49 +02:00
Benjamin Otte
bf5c540357 sortlistmodel: Properly compute runs
When updating a (partially) sorted model, take the known runs for the
existing sort and apply them to the new sort. That way, we don't have to
check the whole model again.

Benchmarks:

      appending half the items to a model of strings
                        old      new
      512,000 items   437ms    389ms
    1,024,000 items  1006ms    914ms

      appending 10% of the items to a model of strings
                        old      new
      512,000 items   206ms    132ms
    1,024,000 items   438ms    301ms

      appending 1 item to a model of strings
                        old      new
       64,000 items   1.8ms   0.00ms
      512,000 items     ---   0.01ms
2020-07-22 14:30:49 +02:00
Benjamin Otte
c03383d3e5 sortlistmodel: Make sort stable again
Previously, the sort was not stable when items were added/removed while
sorting or the sort algorithm was changed.

Now the sort looks at the item position (via the key's location in the
keys array) to make sure each comparison stays stable with respect to
this position.
2020-07-22 14:30:49 +02:00
Benjamin Otte
eaaa287078 multisorter: Implement GtkSortKeys 2020-07-22 14:30:49 +02:00
Benjamin Otte
554defaf1a treelistrowsorter: Implement GtkSortKeys 2020-07-22 14:30:49 +02:00
Benjamin Otte
659fe52b7b numericsorter: Implement GtkSortKeys 2020-07-22 14:30:49 +02:00
Benjamin Otte
0970077af9 stringsorter: Implement GtkSortKeys 2020-07-22 14:30:49 +02:00
Benjamin Otte
814c88fbc1 sortkeys: Add an equal sort keys
Compares every element as equal.
This is useful when sorters are in an invalid configuration.
2020-07-22 14:30:49 +02:00
Benjamin Otte
3b24c8a0a4 sortlistmodel: Use GtkSortKeys
This massively speeds up sorting with expensive sort functions that it's
the most worthwhile optimization of this whole branch.
It's slower for simple sort functions though.

It's also quite a lot slower when the model doesn't support sort keys
(like GtkCustomSorter), but all the other sorters do support keys.

Of course, this depends on the number of items in the model - the number
of comparisons scales O(N * log N) while the overhead for key handling
scales O(N).
So as the log N part grows, generating keys gets more and more
beneficial.

Benchmarks:

       initial sort of a GFileInfo model with display-name keys
                       items     keys
         8,000 items   715ms     50ms
        64,000 items     ---    554ms

       initial sort of a GFileInfo model with complex keys
                       items     keys
        64,000 items   340ms    295ms
       128,000 items   641ms    605ms

       removing half a GFileInfo model with display-name keys
       (no comparisons, just key freeing overhead of a complex sorter)
                       items     keys
       512,000 items    14ms     21ms
     2,048,000 items    40ms     62ms

       removing half a GFileInfo model with complex keys
       (no comparisons, just key freeing overhead of a complex sorter)
                       items     keys
       512,000 items    90ms    237ms
     2,048,000 items   247ms    601ms
2020-07-22 14:30:49 +02:00
Benjamin Otte
e34c7e6796 sorter: Introduce GtkSortKeys
GtkSortKeys is an immutable struct that can be used to manage "sort
keys" for items.

Sort keys are memory that is created specifically for sorting. Because
sorting involves lots of comparisons, it's a good idea to prepare the
data relevant for sorting in advance and sort on that data.

In measurements with a PropertyExpression on a string sorter, it's about
??? faster
2020-07-22 14:30:49 +02:00
Benjamin Otte
8c608e9c1c sortlistmodel: Split the SortItem into 2 arrays
Instead of one item keeping the item + its position and sorting that
list, keep the items in 1 array and put the positions into a 2nd array.

This is generally slower while sorting, but allows multiple improvements:

1. We can replace items with keys
   This allows avoiding multiple slow lookups when using complex
   comparisons

2. We can keep multiple position arrays
   This allows doing a sorting in the background without actually
   emitting items-changed() until the array is completely sorted.

3. The main list tracks the items in the original model
   So only a single memmove() is necessary there, while the old version
   had to upgrade the position in every item.
Benchmarks:

        sorting a model of simple strings
                          old      new
        256,000 items   256ms    268ms
        512,000 items   569ms    638ms

        sorting a model of file trees, directories first, by size
                          old      new
         64,000 items   350ms    364ms
        128,000 items   667ms    691ms

        removing half the model
                          old      new
        512,000 items    24ms     15ms
      1,024,000 items    49ms     25ms
2020-07-22 14:30:49 +02:00
Benjamin Otte
283c3b70dd sortlistmodel: Add an incremental property
Also refactor a large part of the sortmodel to make this convenient.

A large amount of time has been spent on getting items-changed regions
minimized.
2020-07-22 14:30:49 +02:00
Benjamin Otte
080e625090 sortlistmodel: Make the sort callback useful
1. Run step() for a while to avoid very short steps
   This way, we batch items-changed() emissions.

2. Track the change region accurately
   This way, we can avoid invalidating the whole list if our step just
   touched a small part of a huge list.
   As this is a merge sort, this is a common occurence when we're buys
   merging chunks: The rest of the model outside those chunks isn't
   changed.

Note that the tracking is accurate: It determines the minimum change
region in the model.

This will be important, because the testsuite is going to test this.
2020-07-22 14:04:40 +02:00
Benjamin Otte
26696a741e timsort: Add change tracking to gtk_tim_sort_step() 2020-07-22 14:04:40 +02:00
Benjamin Otte
a209e54b8f timsort: Add gtk_tim_sort_set_max_merge_size()
Makes the SOrtListModel responsive when incrementally sorting.

By making it configurable we can avoid losting performance in the
non-incremental case.
2020-07-22 14:04:40 +02:00
Benjamin Otte
8921dadaa1 timsort: Make sure merges don't take too long
Limit the size of the merged areas and thereby chunk larger merges into
smaller ones.
2020-07-22 14:04:40 +02:00
Benjamin Otte
47232acbd8 sortlistmodel: Make sorting incremental
This is just an experiment so far to see how long it takes to sort.
2020-07-22 14:04:40 +02:00
Benjamin Otte
cbad8ec2e4 timsort: Add gtk_tim_sort_set_runs()
... and use it in the SortListModel

Setting runs allows declaring already sorted regions so the sort does
not attempt to sort them again.

This massively speeds up partial inserts where we can reuse the sorted
model as a run and only resort the newly inserted parts.

Benchmarks:

    appending half the model
                    qsort  timsort
    128,000 items    94ms     69ms
    256,000 items   202ms    143ms
    512,000 items   488ms    328ms

    appending 1 item
                    qsort  timsort
      8,000 items   1.5ms    0.0ms
     16,000 items   3.1ms    0.0ms
              ...
    512,000 items     ---    1.8ms
2020-07-22 14:04:40 +02:00
Benjamin Otte
800170b47d sortlistmodel: Use timsort
Simply replace the old qsort() call with a timsort() call.

This is ultimately relevant because timsort is a LOT faster in merging
to already sorted lists (think items-chaged adding some items) or
reversing an existing list (think columnview sort order changes).

Benchmarks:

    initially sorting the model
                    qsort  timsort
    128,000 items   124ms    111ms
    256,000 items   264ms    250ms
2020-07-22 14:04:40 +02:00
Benjamin Otte
97c5cb3514 Add a timsort() implementation 2020-07-22 14:04:40 +02:00
Benjamin Otte
081afc0477 sortlistmodel: Track item positions
The model now tracks the original positions on top of just the items so that
it can remove items in an items-changed emission.

It now takes twice as much memory but removes items much faster.

Benchmarks:

Removing 50% of a model:
                   before    after
   250,000 items    135ms     10ms
   500,000 items    300ms     25ms

Removing 1 item:
     4,000 items    2.2ms      0ms
     8,000 items    4.6ms      0ms
   500,000 items      ---   0.01ms
2020-07-22 14:04:40 +02:00
Benjamin Otte
e807fc3be0 sortlistmodel: Replace with an array-based model
This is the dumbest possible sortmodel using an array:
Just grab all the items, put them in the array, qsort() the array.

Some benchmarks (setting a new model):

  125,000 items - old: 549ms
                  new: 115ms
  250,000 items - new: 250ms

This performance can not be kept for simple additions and removals
though.
2020-07-22 14:04:40 +02:00