Commit Graph

850 Commits

Author SHA1 Message Date
Christian Hergert
d63d9b2319 joinedmenu: add helper to join menus instead of nesting
In many cases, we have an "extra-menu" property that is used to allow
applications to join menus into the native menu for the widget. Previously,
this was done by nesting that menu in a section.

Doing so increases the complexity of the rules for GtkMenuTracker as you
may want different handling from inside of the section vs toplevel
sections.

If instead we synthetically glue the menus together, we have a much more
natural joining of menus as the application developer would expect for
their menu.

This also ports GtkLabel, GtkText, GtkPasswordEntry, and GtkTextView to
use the joined menu helper.

The joined menu helper comes originally from GNOME Builder and has had
extensive use there.

Fixes #4094
2021-07-08 14:16:06 -07:00
Matthias Clasen
c4a2234a28 label: Fix mnemonic handling
We were not handling the case right in which we
want to use underlines, but not use markup. Since
we are now using pango_parse_markup for this case,
we need to escape the xml markup.

Fixes: #4041
2021-06-15 13:06:10 -04:00
Bilal Elmoussaoui
8ebdd256a5 docs: fix broken links 2021-05-27 00:18:23 +00:00
Emmanuele Bassi
7da2e86d4b docs: Fix the PANGO_SCALE link
The fragment for constants is `const`.
2021-05-25 13:31:49 +01:00
Matthias Clasen
052917a67d label: Fix mnemonic activation
The intention of the code is to find a focusable ancestor,
so it needs to look at the focusable property, not at
can-focus. This is a change from GTK 3, where can-focus
was the correct property to look at.

Fixes: #3965
2021-05-23 11:19:40 -04:00
Matthias Clasen
91f7b9663f gtk: Clean up docs syntax
Replace leftover gtk-doc syntax (#Type) with backquotes.
2021-05-22 17:25:26 -04:00
Matthias Clasen
4a0d3d7acc docs: Reduce redundancy
Remove a boatload of "or %NULL" from nullable parameters
and return values. gi-docgen generates suitable text from
the annotation that we don't need to duplicate.

This adds a few missing nullable annotations too.
2021-05-20 20:45:06 -04:00
Matthias Clasen
7fe0610b68 introspection: Stop using allow-none
allow-none has been deprecated for a long time
already. Instead use optional and nullable everywhere.
2021-05-20 19:17:49 -04:00
Matthias Clasen
8ba16eb4f1 Documentation fixes
Mostly fixing up indentation of continuation lines,
and other small cleanups.
2021-05-20 19:17:49 -04:00
Matthias Clasen
d94c386320 label: Make hidden mnemonics work again
The change in 875a92b95f made labels strip
out underlines earlier, but overlooked that this made
mnemonics not work before the timeout to show them
has passed. That was unintentional. Make mnemonics
work regardless of their visibility, again.
2021-05-05 22:55:52 -04:00
Alexander Mikhaylenko
316c783fce label: Update selection node and redraw on state changes
Mirror GtkText and GtkTextView.
2021-05-04 02:29:10 +05:00
Matthias Clasen
eaf09a4625 Cosmetics
Pango lets us pass NULL for the font desc and language
in pango_context_get_font_metrics() to use the context
values.
2021-03-18 07:52:03 -04:00
Matthias Clasen
e6b1443fbb label: Fix tooltips on links
Fix pointed out by Timm Baeder.

Fixes: #3765
2021-03-17 19:46:02 -04:00
Matthias Clasen
e930433800 label: Fix some external links
I had put in a bunch of [class@Pango.Attribute],
but it needs to be [struct@Pango.Attribute].

Know your dependencies` type hierarchy!
2021-03-11 16:37:38 +00:00
Matthias Clasen
9f6e4e60d0 label: Use markdown for css tree 2021-03-11 16:37:35 +00:00
Matthias Clasen
a8a15d48ad label: Add property annotations
Connect properties, getters, and setters with annotations.
2021-03-11 16:37:32 +00:00
Matthias Clasen
f00f900224 label: Convert docs
Change link syntax, add singl-line summaries,
add missing property docs.
2021-03-11 16:37:30 +00:00
Matthias Clasen
875a92b95f label: Fix markup parsing interactions
We were not handling mnemonics vs markup right
in all cases. Rewrite the _-stripping code to
do it during the link parsing, instead of as
a separate function. This avoids the issue of
stripping _ from attribute names in markup.

Add tests.

Fixes: 3706
2021-03-02 23:25:01 -05:00
Alexander Mikhaylenko
f63e6394ac dragsource: Use double coordinates for checking drag threshold
If multiple nested widgets have drag sources on them, both using bubble
phase, we need to reliably pick the inner one. Both of them will try to
start dragging, and we need to make sure there are no situations where the
outer widget starts drag earlier and cancels the inner one.

Currently, this can easily happen via integer rounding: start and current
coordinates passed into gtk_drag_check_threshold() are initially doubles
(other than in GtkNotebook and GtkIconView), and are casted to ints. Then
those rounded values are used to calculate deltas to compare to the drag
threshold, losing quite a lot of precision along the way, and often
resulting in the outer widget getting larger deltas.

To avoid it, just don't round it. Introduce a variant of the function that
operates on doubles: gtk_drag_check_threshold_double() and use it instead
of the original everywhere.
2021-01-29 12:01:34 +05:00
Matthias Clasen
98c247ec29 label: Drop some unused includes 2021-01-28 12:27:07 -05:00
Matthias Clasen
10d5705b70 Reduce use of GtkStyleContext
Remove some unnecessary uses of GtkStyleContext where
we can directly go to the GtkCssStyle, and and drop
unnnecessary includes.
2021-01-28 12:27:07 -05:00
Timm Bäder
934b91f65f label: Remove unneeded NULL guards
The pointers passed to GtkWidgetClass::measure cannot be NULL
2021-01-17 04:39:26 +01:00
Timm Bäder
c3050231d1 label: Refactor get_layout_location
Make this function shorter, the parameters non-nullable and the simple
cases more explicit.
2021-01-17 04:39:26 +01:00
Timm Bäder
ec8614e8e4 label: Fix a potential memory leak
This only happens in error cases so not very interesting. Anyway, try to
make scan-build happy.
2021-01-17 04:39:26 +01:00
Timm Bäder
03f5a368ec label: Remove unused private functions 2021-01-03 11:01:29 +01:00
Timm Bäder
0b15aba82a label: Remove mnemonics_visible_apply_recursively from private header
This is only used in gtklabel.c
2021-01-03 11:01:28 +01:00
Timm Bäder
d8fa9de93a label: Modernize source file
Try to sort toplevel functions to minimize unnecessary function
prototypes at the beginning of the file, get rid of all tabs and
trailing whitespace.
2021-01-03 11:01:28 +01:00
Timm Bäder
e7a326e230 label: Refactor get_layout_location()
Rename a few local variables to be clearer about whether they belong to
the widget or to the layout.

Remove a workaround for an old bug that is no longer valid. We don't
underallocate the layout anymore. Aways center vertically, with respect
to the yalign.
2020-12-21 12:44:01 +01:00
Timm Bäder
9eaeaa8452 label: Refactor snapshot()
Use two early-out style if statements to reduce indentation in this
entire function.
2020-12-21 12:32:32 +01: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
2cddec7798 gtk/popover: Use gtk_popover_present() instead of going via GtkNative
This makes it more explicit that managers of popovers make it "present".
2020-12-07 20:37:29 +01:00
Emmanuele Bassi
fde32c5219 Use private can_activate() method
Instead of checking the activate_signal field directly.
2020-12-05 01:04:18 +00:00
Sophie Herold
1e01b9079d Fix some nullable return annotations 2020-11-21 16:33:40 +01:00
Matthias Clasen
2ef72442ec docs: Fix the links for keybinding signals
GtkBindingSignal does not exist anymore, so link to
GtkSignalAction for an explanation of keybinding signals.
2020-11-17 07:34:52 -05:00
Matthias Clasen
d347df431d label: Avoid short-circuiting
Commit 0db504edde made a mistake described here:
https://en.wikipedia.org/wiki/Short-circuit_evaluation#Possible_problems

Fixes: #3359
2020-11-13 15:35:51 -05:00
Matthias Clasen
82b855cc4b label: Avoid a needless strdup
Don't duplicate the string before we know if it
has actually changed.
2020-11-11 12:24:35 -05:00
Matthias Clasen
0db504edde label: Optimize GtkLabel setters
The overarching goal here is to not queue a resize
unless something has actually changed. In columnview
scenarios, we often deal with hundreds of labels.

Labels are cattle, not pets.
2020-11-11 11:48:27 -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
Timm Bäder
c7dbb8ef91 label: Plug a potential memory leak
This only happens in error cases so pretty insignificant.

Found by scan-build
2020-10-22 17:46:33 +02:00
Benjamin Otte
8dad615f04 gtk: Remove unused header include
gtkcssnodeprivate.h was mainly used for repositioning CSS nodes in
gadgets, and gadgets are gone now.
2020-10-20 04:50:12 +02:00
Matthias Clasen
08ae513064 label: Set the accessible label property
This will make label text show up in ATs again.
2020-10-19 14:29:19 -04:00
Matthias Clasen
929a56e53c Clean up lots of GTK+ -> GTK
Replace most remaining uses of GTK+ in the docs and
user-visible strings by GTK. Also remove some leftover
"Was added in 3.x" sentences from the docs.
2020-09-12 12:01:04 -04:00
Björn Daase
6315cd977c *: Fix spelling mistakes found by codespell 2020-08-21 15:29:34 +02:00
Timm Bäder
ec81ccd5f9 label: Try to avoid a pango_layout_get_extents call
Measuring text is quite expensive, so only do this if really necessary.
2020-08-19 16:14:59 -04:00
Matthias Clasen
3faa7feb7c label: Disable unavailable actions
Fixes: #3034
2020-08-08 11:48:32 -04: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
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
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
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
3078b180fe Replace "gdouble" with "double" 2020-07-25 00:47:36 +02:00