Commit Graph

2548 Commits

Author SHA1 Message Date
Matthias Clasen
d89ff71819 Flip margin-start and -end in RTL
We lost this at some point, but the widget margins
are still meant to be relative to the text direction.

Fixes: #3583
2021-01-15 14:58:21 -05:00
Benjamin Otte
4761641098 Add critical if widget has a parent during dispose
This is a refcounting bug. Be very verbose about it instead of trying to
call a function that releases a reference to the widget without
references.
2021-01-07 11:39:32 -06:00
Timm Bäder
699adb0b10 widget: Refactor gtk_widget_class_set_template()
Don't call gbytes_get_data/get_size so often and exit early if the given
bytes is already precompiled.
2021-01-03 11:01:29 +01:00
Timm Bäder
c91b5eaa41 widget: Inline setup_template_child() into only caller
This is a pretty short and self-contained function.
2021-01-03 11:01:29 +01:00
Timm Bäder
06cce81a97 widget: Use gtk_widget_get_native() in get_surface_allocation() 2021-01-03 11:01:29 +01:00
Timm Bäder
92ec754737 widget: Move quark_builder_set_id declaration to other GQuarks 2021-01-03 11:01:29 +01:00
Timm Bäder
d11fbbc478 widget: Re-arrange some more functions 2021-01-03 11:01:29 +01:00
Timm Bäder
f11f0da11c wiget: Fix whitespace issues
Switch from tabs to spaces everywhere consistently and remove all
trailing whitespace.
2021-01-03 11:01:29 +01:00
Timm Bäder
ebdf2989f8 widget: Move a few vfunc implementations above class_init
And save us the prototypes at the top of the file this way.
2021-01-03 11:01:29 +01:00
Emmanuele Bassi
af0973c847 a11y: Fix removing mnemonic widgets
We must not use the variadic arguments version with GList, as it expects
a pointer to a GtkAccessible.
2020-12-17 15:49:00 +00:00
Emmanuele Bassi
fb93baeae4 docs: Add missing description for GtkWidget::move-focus 2020-12-16 16:29:01 +00:00
Emmanuele Bassi
2c97d44281 docs: Fix the Widget as Buildable example
The layout properties use an old name.
2020-12-11 23:41:51 +00:00
Matthias Clasen
1f141c1953 Merge branch 'wip/surface-state-rework' into 'master'
Rework surface state and geometry computation

See merge request GNOME/gtk!2885
2020-12-08 15:38:36 +00:00
Jonas Ådahl
8a599b2582 gtk: Allocate everything from GtkNativeClass::layout
This changes allocation of the widget trees to happen as a side effect
to the GdkSurface::layout signal, which first passes the GtkNative
instance where it is then forwarded to the implementations of the
GtkNative interface.

The implementations of GtkNative are the ones doing the actual
gtk_widget_allocate(), and they do so in their GtkNativeClass::layout
function.
2020-12-07 09:46:39 +01:00
Jonas Ådahl
ecc861bf06 Pass the layout signal via GdkSurface to GtkRoot
Don't have GtkRoot listen directly to the layout signal on the frame
clock, but let it pass through GdkSurface. This will allow GdkSurface to
be more involved in the layout phase.
2020-12-07 09:46:39 +01:00
Emmanuele Bassi
d8c9a67d20 docs: Clarify gtk_widget_activate()
We need to tell people what signal will be emitted when calling
gtk_widget_activate(), and that the shortcuts API might be more
appropriate to what they are looking for.
2020-12-06 15:13:57 +00:00
Emmanuele Bassi
c352fe9ab0 Move activate_signal to the widget private class data
Instead of having it as a field in the class structure.
2020-12-06 15:06:18 +00:00
Emmanuele Bassi
fe9c0db603 Add getter for WidgetClass.activate_signal
Just like we have a setter.
2020-12-05 01:04:18 +00:00
Emmanuele Bassi
e5e18ddffb Add private method to check activatability
We should have an actual method, instead of checking the
WidgetClass.activate_signal directly.
2020-12-05 01:04:18 +00:00
Emmanuele Bassi
b3e03fa6f0 Add wrappers for setting the WidgetClass.activate_signal field
Setting a field on a class structure is not always an easy task from
languages other than C. While bindings can provide access to the class
pointer, twiddling the fields in the class structure can be awkward.
Additionally, signal ids are not always readily available.

We can paper over the direct access to the class structure, as well as
the "signal name to id" mapping with a simple couple of setter
functions.
2020-12-05 01:04:18 +00:00
Matthias Clasen
ab9e99218f docs: Remove mentions of <accelerator>
That is no longer supported, keyboard shortcuts
are done with GtkShortcut now.

Fixes: #3429
2020-12-02 19:59:44 -05:00
Matthias Clasen
af944aa74c widget: Add a missing nullability annotation 2020-12-02 10:08:58 -05:00
Matthias Clasen
b5077d02ed Clarify the docs for gtk_widget_class_set_css_name
Reword, and mention the default css name.
2020-12-02 10:06:01 -05:00
Timm Bäder
2d43ecf8ca widget: root child before emitting child observer signals
Try to avoid the childen_observer signal handlers screwing up internal
state.

Fixes #3364
2020-11-30 09:21:52 -05:00
Christoph Reiter
b97b95b0c7 gtkwidget: fix crashes with GTK_A11Y=none
at_context can be NULL in that case, so guard against it.

Fixes #3333
2020-11-15 15:59:31 +01:00
Carlos Garnacho
80de00a248 gtk/main: Stack ::active calls
We may have the situation of multiple touchpoints in the same
widget, or combinations with other devices. Stack those ::active
states are preserved on widgets on all but the last pointer/touch
going away.
2020-11-13 00:39:23 +01:00
Matthias Clasen
5d9799d4e3 Merge branch 'ebassi/for-master' into 'master'
ATContext lifetime fixes

Closes #3341

See merge request GNOME/gtk!2811
2020-11-12 12:35:23 +00:00
Emmanuele Bassi
8157717e03 a11y: Add missing fallback for accessible-role getter
If the per-instance accessible role is unset, use the class role.
2020-11-11 19:45:43 +00:00
Emmanuele Bassi
9052f6dafe a11y: Rework ownership and lifetime of GtkATContext
Now that GtkATContext is explicitly realized and unrealized, we should
always create an instance at widget initialization time, and drop it
during the widget finalization. This should make it easier to set up the
initial accessible state of a widget during the instance initialization,
as well as reduce the chances of accidental creation of GtkATContext
instances during the destruction sequence.
2020-11-11 19:45:43 +00:00
Emmanuele Bassi
428ec29598 a11y: Unrealize ATContext on dispose()
By unrealizing the context we avoid additional work during the dispose
phase, in case widget code updates the accessible state. We use
GtkAccessible's API, to ensure we unrealize the right ATContext, instead
of the one we store inside GtkWidgetPrivate.

We drop the ATContext instance inside GtkWidget during finalization, to
mop up eventual vivifications there.
2020-11-11 18:33:15 +00:00
Matthias Clasen
27c4c19333 Don't hide widgets in dispose()
This is leftover code from when widgets were hidden
by default, and was setting them back to their initial
state.

This is getting in the way now, as hiding the widget
updates the HIDDEN accessible state, which ends up
re-creating the at context that we've already disposed
of, leading to memory leaks.
2020-11-11 10:35:54 -05:00
Emmanuele Bassi
c264254d4b a11y: Parse reference lists using varargs
Using GList is a bit lame, and makes the API more complicated to use
than necessary in the common case.

The only real use case for a GList is gtk_widget_add_mnemonic_label(),
and for that we can use the GValue-based API instead.

Fixes: #3343
2020-11-10 14:31:56 +00:00
Emmanuele Bassi
1bdc8b9061 a11y: Proxy GtkWidget:accessible-role
The accessible-role property in GtkWidget has three possible targets:

 - the :accessible-role of a GtkATContext, if realized
 - the accessible_role field of GtkWidgetPrivate
 - the accessible_role field of GtkWidgetClassPrivate

When we set the accessible role of a widget using the GObject property
mechanism, we want to either set the GtkWidgetPrivate.accessible_role
field, if there's no ATContext *or* if the ATContext is not realized.
Conversely, when we get the accessible-role property we want to have a
series of fallbacks in place:

 - if GtkAccessible.get_at_context() returns an ATContext, and that
   ATContext is realized, return the :accessible-role of the context
 - if GtkWidgetPrivate.accessible_role is not WIDGET, return the
   stored accessible role
 - return GtkWidgetClassPrivate.accessible_role

This should help catch the case of getting the accessible role of
widgets that override GtkAccessible.get_at_context(), like
GtkModelButton.

See: #3342
2020-11-10 14:31:56 +00:00
Emmanuele Bassi
d88f7c9459 a11y: Use the tooltip text as the accessible description
It's more common to have a tooltip as the accessible description than an
explicit description. This is also the behaviour of GTK3.
2020-11-04 17:15:13 +00:00
Matthias Clasen
828a067b2b Propagate accessible-role to backend
We want to allow setting the accessible role as long
as the context is unrealized, so we need to propagate
the new role.
2020-11-04 11:53:07 -05:00
Emmanuele Bassi
dafb2b0361 a11y: Allow updating role on unrealized contexts
We can still change the accessible role if an ATContext instance is
unrealized.
2020-11-04 15:22:31 +00:00
Emmanuele Bassi
30210c7087 a11y: Move ATContext to an explicit realization model
We are doing too much work during the construction phase of the
AT-SPI backend for GtkATContext. Instead of having the AtSpiContext
register itself at construction time, let's add explicit realize
and unrealize operations, and connect the ATContext realization to the
rooting operation of a GtkWidget.
2020-11-04 15:02:44 +00:00
Matthias Clasen
3cf26b471b Fix the definition of GtkWidget:can-target
We are setting the value to TRUE initially, but
the property had a declared default of FALSE.
This is messing up the simplification of .ui files
with gtk4-builder-tool, since it thinks it can
omit can-target properties when it really can't.
2020-11-01 21:23:35 -05:00
Matthias Clasen
8df883ed71 Merge branch 'matthiasc/atspi-child' into 'master'
Emit ChildrenChanged signal on hierarchy updates

See merge request GNOME/gtk!2752
2020-10-27 18:24:43 +00:00
Matthias Clasen
0c49f7349d Merge branch 'matthiasc/a11y-buildable' into 'master'
Implement accessible attributes for ui files

See merge request GNOME/gtk!2751
2020-10-27 18:13:44 +00:00
Matthias Clasen
0a3b370805 Cosmetics
Remove some comments that refer to no longer
existing menu code.
2020-10-25 00:31:18 -04:00
Matthias Clasen
1e13acb206 widget: Don't add reordered children
gtk_widget_reposition_after is called both to add new children,
and to reposition existing children. We only want to emit
accessible changes in the former case (since AT-SPI doesn't
have events for reordering).
2020-10-24 11:17:56 -04:00
Emmanuele Bassi
80756322cd a11y: Handle relations in UI files
A bit hacky: we skip parsing values that have a reference or
reference-list type, but we do not error out. Instead, we return a NULL
value, which we catch in the GtkBuildable interface implementation to
get the actual object, and construct a reference list value.

There's still some ickyness around the value type that can only be
solved by having an attribute and role taxonomy.
2020-10-21 14:48:49 +01:00
Emmanuele Bassi
8d46bd1d7c a11y: Notify of changes in the children list 2020-10-21 14:04:49 +01:00
Emmanuele Bassi
7702670d86 docs: Document the "accessibility" custom tag 2020-10-21 13:33:37 +01:00
Emmanuele Bassi
9e4316bf96 a11y: Add an "accessibility" section to the builder XML tree
Accessible attributes are not GObject properties. This means that we
need a custom parser for setting attributes in our UI description files.

The new section is defined as a sub-tree with the `<accessibility>`
element at its root, and elements for each type of accessible
attributes, i.e. properties, relations, and states:

```xml
  <object class="..." id="...">
    <accessibility>
      <property name="label">The accessible label</property>
      <state name="pressed">false</state>
      <relation name="labelled-by">label1</relation>
    </accessibility>
  </object>
```

The name of the attribute is the enumeration value; the value is defined
by the WAI-ARIA specification.
2020-10-21 13:33:37 +01:00
Matthias Clasen
8880e3bd2e Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!2729
2020-10-21 11:43:58 +00:00
Timm Bäder
0b5b908a74 Merge branch 'wip/exalm/nullable' into 'master'
widget: Add missing (nullable) on binding functions

See merge request GNOME/gtk!2730
2020-10-21 08:17:45 +00:00
Alexander Mikhaylenko
31a072497d widget: Add missing (nullable) on binding functions
Even though they are marked as (skip), they are used in Vala and have wrong
types there atm.
2020-10-21 12:27:51 +05:00
Matthias Clasen
a8baee342c a11y: Fix handling of LABELLED_BY relation
There were several places where we were confusing
GList and GSList and list->data and list->next, causing
a crash in the accessible name computation for buttons
with mnemonic labels.
2020-10-20 21:27:39 -04:00