Commit Graph

2610 Commits

Author SHA1 Message Date
Matthias Clasen
32796cad10 Use gtk_event_controller_set_static_name
This avoids strdups.
2022-08-27 22:35:13 -04:00
David Demelier
06bec5fb45 gtk: Missing end of code block 2022-07-26 14:52:30 +00:00
Philip Withnall
87ba99f66b gtkwidget: Fix a small typo in a docs comment
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-07-25 23:15:58 +02:00
Emmanuele Bassi
f4f683a469 Rename clear_template to dispose_template
Make it more clear that the function is supposed to be called during the
dispose sequence of a widget.
2022-07-11 18:24:37 +01:00
Emmanuele Bassi
c2ec244b84 docs: Include clear_template() in the templates overview
Make sure that it's clear how to use it in idiomatic code, by tying it
to gtk_widget_init_template().
2022-07-11 18:24:37 +01:00
Emmanuele Bassi
620d48ca0c docs: Clarify scope of gtk_widget_clear_template()
The clear_template() method only clears the template children.
2022-07-11 18:24:37 +01:00
Emmanuele Bassi
7857c1a66b Add gtk_widget_clear_template()
The dual of gtk_widget_init_template(), which should be used to clear
the template data associated with a specific GtkWidget type.
2022-07-11 18:24:37 +01:00
Sophie Herold
a546ae32d7 Remove all nicks and blurbs from param specs
Those property features don't seem to be in use anywhere.
They are redundant since the docs cover the same information
and more. They also created unnecessary translation work.

Closes #4904
2022-05-11 18:16:29 +02:00
Benjamin Otte
7149bfd100 widget: Don't queue an allocate on a nonexisting parent
No test, no idea how to trigger this reliably.
2021-12-26 22:17:54 +01:00
Benjamin Otte
15528599f4 Merge branch 'wip/otte/for-master' into 'master'
window: Always clamp to max size

See merge request GNOME/gtk!4185
2021-11-21 18:44:26 +00:00
Emmanuele Bassi
031aab3ef6 Merge branch 'ebassi/issue-4421' into 'master'
Unrealize ATContext on unroot

Closes #4421

See merge request GNOME/gtk!4136
2021-11-21 15:36:25 +00:00
Benjamin Otte
822508f33e widget: Clear size request cache on queue_resize()
... and not later.

Otherwise future calls to sizing fucntions will reuse an outdated cache
and compute wrong values.
2021-11-21 06:08:06 +01:00
Benjamin Otte
1eb86d6394 widget: Remove a check
That consistency check is entirely outdated and just prints confusing
stuff.
2021-11-20 06:04:10 +01:00
Benjamin Otte
50e0893497 widget: force adjustment method is one size is FILL
If halign=fill, force adjustment to height-for-width.
If valign=fill, force adjustment to width-for-height.
Otherwise look at request mode.

This way we don't try to adapt the filled dimension and only adjust
the one that is not set to fill.
2021-11-20 06:04:10 +01:00
Benjamin Otte
7459d430eb widget: Don't forget margins when adjusting
This could lead to the wrong values being passed and computing invalid
sizes which would then lead to very unhappy code.

Test included.
2021-11-19 23:46:59 +01:00
Carlos Garnacho
615b8fc569 gtkwidget: Do not check event sequence state before cancelling gesture
The sequence should be cancelled from the gesture despite its current state.
Also, there was a piece of pointer emulation that was not dropped here,
maybe breaking things further for the pointer emulated touchpoint.

Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/4387
2021-11-16 00:41:17 +01:00
Emmanuele Bassi
018388d321 Unrealize ATContext on unroot
Non-root widgets should unrealize their ATContext, if they have one,
when they are unrooted, as they don't have a connection to a top level
any more.

Fixes: #4421
2021-11-08 10:18:22 +00:00
Emmanuele Bassi
59f45aa30c docs: Fix wrong fragments in type links
Due to a bug in gi-docgen we're not getting a warning if a fragment to a
type does not match the actual type, and we're generating a broken link.

See: https://gitlab.gnome.org/GNOME/gi-docgen/-/merge_requests/120
2021-11-07 18:40:24 +00:00
Benjamin Otte
1606a41116 widget: adjust allocation even better
This fixes fallout from 3742fabae0 where
we would no longer allocate widgets to their natural size when
align flags where used.

GtkPicture wants to be allocated at 100% in that case, so a picture with
a 100x100 image inside a 200x200 window should be allocated 100x100.

The new adjustment code now does the following (for width-for-height
instead of height-for-width, swap width and height in the following):

1. query the minimum width for the allocated height
2. query the natural width
3. compute the maximum of (1) and (2)
4. set the widget width to the minimum of (3) and the allocated
   width.
5. compute the natural height for (4)
6. set the widget height to the minimum of (5) and the allocated height.
2021-10-22 17:51:40 +02:00
Benjamin Otte
3742fabae0 widget: Don't overadjust allocations
When adjusting allocations, don't query height for the current width,
but query it for the adjusted width.

And adjust width not to the width-for-any-height, but to
width-for-allocated-height.
2021-10-19 01:55:59 +02:00
Matthias Clasen
a9b81577c6 widget: Provide a helper for updating pango contexts 2021-09-04 15:42:05 -04:00
Matthias Clasen
eaa2dada54 Rename an internal function
It occupies a name I want to reuse for something else.
2021-09-04 15:42:05 -04:00
Matthias Clasen
26e632e549 widget: Redraw when font options change
Its the right thing to do, even if it is a rare event.
2021-09-03 13:56:29 -04:00
Matthias Clasen
b26a370ce4 Add a gtk-hint-font-metrics setting
This lets people switch back to font rendering that is closer
to what GTK 3 does. It is not perfect - subpixel antialiasing
is not going to work. But it give us an Escape hatch while
we shake out the bugs in our linear layout.

Related: #3787
2021-09-01 15:52:07 -04:00
Alexander Mikhaylenko
342f02711b widget: Fix gtk_widget_class_query_action() annotations
Add transfer none on all out values as they aren't being copied.
2021-08-11 14:33:38 +05:00
Matthias Clasen
04f3c8054b Merge branch 'callback-annotation-again' into 'master'
widget: Change callback scope

See merge request GNOME/gtk!3796
2021-08-10 01:16:56 +00:00
Florian Müllner
bc386c9a60 widget: Change callback scope
Look who changed his mind since commit 8e2ffb3b46 :-)

The "call" scope means that the callback is only used during the
function call itself (here: gtk_widget_class_install_action()).

That's clearly wrong here, as the callback is invoked every time
the action is activated.

Arguably the "notified" scope is a better match here, where the
lack of a GDestroyNotify parameter suggests that the callback may
be used forever (which is the case here).

Related: #3498
2021-07-28 21:48:01 +02:00
Matthias Clasen
ee6491f717 widget: Avoid some unnecessary back-and-forth casting
Avoid some unnecessary casting and a redundant early exit.
2021-07-24 18:49:27 -04:00
Matthias Clasen
7044951dab widget: Avoid GObject data for action muxer
Most widget have an action muxer now, so just
store it in GtkWidgetPrivate.
2021-07-24 18:48:10 -04:00
Marco Melorio
eacfa2a966 doc: Syntax fixes 2021-07-13 22:53:19 +00:00
Matthias Clasen
4c2761302a doc: Syntax fixes
No, we can't have links that say [constructor@...] or
[mehtod@...] or [methoc@...] or [methos@...] or [metohd@...].
And no, not [signals@...] either.
2021-05-25 07:33:55 -04:00
Matthias Clasen
13a93489b7 widget: Cosmetic docs changes 2021-05-22 17:25:26 -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
Carlos Garnacho
f003a4c6cc gtkwindow: Simplify GTK grab notification
The _gtk_widget_grab_notify() function just (maybe) did a) reset
controllers and b) hide toplevels. The second part was a testing
remnant introduced in commit 024d832d94, not part of the original
fix.

Do the former more concisely, called from the place where we figure
out whether a widget's ability to receive events changed due to
GTK grabs. It's across those changes that we are interested in
resetting the controllers.

With the gestures being reset both ways, GtkWindowHandle (and
probably other) gestures are now able to reset after a GTK grab
takes input away (e.g. GtkMenuButton). This could be seen as
a sudden jump the next time they'd be dragged with the mouse,
as the gesture would "resume" the previous interaction.

Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/3942
2021-05-18 00:16:48 +02:00
Matthias Clasen
bf454e948d Fix picking with transforms
When transforms include scales, we weren't picking
children properly. The special-case in gtk_widget_do_pick
only applies to 2D translations.
2021-05-12 20:58:16 -04:00
Matthias Clasen
32280090fe Check for root being a GtkWindow in a few places
These things were showing up as crashes during DND,
when the root is a GtkDragIcon. I'm sure there's more.
2021-04-30 13:45:39 -04:00
Matthias Clasen
a455db01a0 a11y: Actually set accessible roles
With most context realization happening inside
GtkAtspiContext in response to D-Bus calls, the
code in gtk_widget_realize_at_context that sets
the role is not executed for most accessibles,
causing them to be stuck with the 'filler' role
that makes orca ignore them.

To fix this, split gtk_widget_realize_at_context
into the actual context realization (getting on
the bus) and the setting of widget-specific
properties, and do the latter part when the
widget is rooted.

This makes accerciser report proper roles for
entries and buttons. Orca still has an issue
with getting the hierarchy populated.
2021-04-19 19:22:20 +01:00
Matthias Clasen
9e8187bdc4 a11y: Track window states more closely
Orca ignores events unless the object is inside an object
with role window and states ACTIVE and SHOWING. To arrange
for this, introduce a new ACTIVE platform state, and set it
for windows when they are active.

This gets orca to be a lot more talkative.
2021-04-19 19:22:20 +01:00
Emmanuele Bassi
0a7af75639 docs: Update annotations for WidgetClass.query_action()
The parameter_type and property_name out arguments can be set to NULL.

Fixes: #3757
2021-03-15 13:48:35 +00:00
Matthias Clasen
8d7103116a widget: Fix up some links
Fix up some links to vfuncs and to sections, as well as class methods.
2021-03-11 16:37:38 +00:00
Matthias Clasen
30073de932 widget: Add property annotations
Connect properties, getters, and setters with annotations.
2021-03-11 16:37:32 +00:00
Matthias Clasen
e034046724 widget: Convert docs
Some work toward converting the docs to markdown.

More work needed, in particular around vfuncs and
class functions.
2021-03-11 16:37:31 +00:00
Emmanuele Bassi
b2a99642a9 docs: Begin porting GtkWidget to the new format 2021-03-11 16:37:30 +00:00
Matthias Clasen
5556907194 inspector: Fix surface transform regression
Ever since we added surface-to-widget transforms,
the autofading of the fps overlay did not work anymore,
since it was given the transient transform node, most
of the time.

Fix this by passing both the root of the node tree and
the node for the toplevel widget to prepare_render, and
hande the widget node to the overlays. Update the
affected overlays that need to have their positioning
adjusted.
2021-03-09 18:27:04 -05:00
Alexander Mikhaylenko
8e2f90e342 widget: Don't assume GtkWindow root in gtk_widget_propagate_state()
Avoid crashes with GtkDragIcon children.
2021-02-18 13:41:41 +05:00
Emmanuele Bassi
958005317b Merge branch 'master' into 'master'
Improve the docs of GtkWidget and GtkGrid

See merge request GNOME/gtk!2946
2021-02-05 12:14:26 +00:00
Matthias Clasen
bf4102e664 Merge branch 'wip/exalm/consumes-motion' into 'master'
Drag fixes and cleanups

Closes #3513

See merge request GNOME/gtk!3001
2021-02-01 01:34:45 +00:00