Commit Graph

46 Commits

Author SHA1 Message Date
Matthias Clasen
23c67f8c67 New focus change handling
Instead of relying on gdk's antiquated crossing events,
create a new GtkCrossingData struct that contains the
actual widgets, and a new event controller vfunc that
expects this struct. This also saves us from making sense
of X's crossing modes and details, and makes for a
generally simpler api.

The ::focus-in and ::focus-out signals of GtkEventControllerKey
have been replaced by a single ::focus-change signal that
takes GtkCrossingData as an argument. All callers have
been updated.
2020-02-21 00:47:53 -05:00
Timm Bäder
a1bc3ae2c8 popvermenu: Clarify css node docs
We add the .menu css class to the popover main node, not its contents
node.
2020-02-20 10:23:09 +01:00
Matthias Clasen
073e8dd987 popovermenu: Avoid an uninitialized variable
Pointed out by Timm/clang.

Fixes https://gitlab.gnome.org/GNOME/gtk/issues/2434
2020-02-12 17:58:41 -05:00
Timm Bäder
655711fef2 Rename gtk_widget{get,set,has}_style_class to _css_class
We want to use css instead of style everywhere now.
2020-02-07 13:16:45 -05:00
Timm Bäder
b7ee2cbc28 Start using GtkWidget's new style class API 2020-02-07 13:16:32 -05:00
Robert Ancell
9e9eae3ad4 Add missing transfer notation for function return types. 2020-01-13 12:14:08 +13:00
Matthias Clasen
b06331218d docs: Rewrite popover menu docs
These were outdated and did not reflect current api.
2019-12-29 20:31:58 -05:00
Matthias Clasen
0b6e521dc5 popovermenu: Use a weak ref for active item
Otherwise, we can end up with a dangling pointer,
leading to badness.
2019-12-29 17:10:15 -05:00
Matthias Clasen
9543a5daeb popovermenu: Fix keynav with submenus
When we right-arrow all the way into a submenu
and then cycle to the next menu in a menubar,
we need to reset all open submenus, so that
left-arrowing back to the menu puts the focus
on the first item again.
2019-12-27 22:54:11 -05:00
Benjamin Otte
dff86c0e12 eventcontrollermotion: Add getters for the properties
... and use them.

Also, rename them from is/contains-pointer-focus to is/contains-pointer,
that's clear enough and not too long.

Finally, adapt the semantics of contains-pointer to mirror
GtkEventControllerKey::contains-focus. If is-pointer is set, so is
contains-pointer, they are not exclusive.
Which is what all users of this property wanted, too.
2019-12-15 21:07:54 +01:00
Matthias Clasen
bfa0509f08 Privatize popover menu pieces
Don't allow manual creation of popover menus
anymore. This lets us also make GtkModelButton
private
2019-11-11 12:42:06 +01:00
Timm Bäder
172f68e77d popovermenu: Switch to main submenu before mapping 2019-10-09 16:57:22 +02:00
Timm Bäder
fb1145d72d popovermenu: Only close if there's a new focus widget
Makes sense and otherwise we end up closing the popover for no reason
2019-10-09 16:57:22 +02:00
Timm Bäder
bd9687a4f2 popovermenu: Switch back to "main" AFTER unmapping
Otherwise we might set things to child visible etc. while being
unmapped, which is a violation of the widget invariants of these
properties.
2019-10-09 16:57:22 +02:00
Benjamin Otte
578dc9e70b eventcontrollerkey: Add getters for the properties
...and use them.
2019-10-07 04:49:50 +02:00
Matthias Clasen
ea44eade21 Add nesting popover menus
Add a variant of popover menus that are nesting
like traditional menus. This is a better fit for
replacing traditional main menus.
2019-09-08 19:02:06 -04:00
Matthias Clasen
cbc0a8447d popover menu: Unify hover and focus
Menus traditionally don't have separate
hover and focus locations. Make the same
change here that we already did for
popover menubars: Track the active item
and set its selected state. Both keynav
and mouse change the active item.
2019-06-12 21:50:46 -04:00
Matthias Clasen
c16f10abea popover menu: Add our own activate key bindings
This solves issues with parent widgets, like combobox
or entry, installing their own bindings for these
keys, overriding the activation behavior that
is implemented in gtkwindow.
2019-06-12 21:50:08 -04:00
Matthias Clasen
a56f99355a popover menu: Add our own focus key bindings
This solves issues with parent widgets, like textview
or scrolled window or combobox installing their own
bindings for these keys, overriding the focus behavior
that is implemented in gtkwindow.
2019-06-12 21:49:52 -04:00
Matthias Clasen
37090a7ab4 popover menu: Set autohide
This is the expected behavior for menus.
2019-06-11 17:38:22 +00:00
Matthias Clasen
f1b9e7c23b Rename a bunch of private headers
We want to follow the convention that all
private headers have names ending in private.h
2019-06-10 03:10:13 +00:00
Matthias Clasen
6342287288 popover menu: Disappear on focus out
We try to keep focus inside by wrapping arrow keynav.
But focus can still escape. If it does, we want to
disappear, like any good menu should.
2019-06-09 17:38:54 +00:00
Matthias Clasen
abc9fef615 popover menu: Implement focus
We want to cycle around for up/down arrows.
2019-06-09 17:38:54 +00:00
Matthias Clasen
609f1659bd Rationalize popover menu apis
Make gtk_popover_new_from_model() return a GtkPopoverMenu,
rename it to gtk_popover_menu_new_from_model() and add
a relative_to argument to gtk_popover_menu_new().

Update all callers.
2019-06-09 17:38:54 +00:00
Matthias Clasen
698e39bcac popover menu: Fix style classes
We want the same style classes that are produced
when creating a popover from a menu model.
2019-06-09 17:38:53 +00:00
Matthias Clasen
56e93332d8 popover menu: Make not subclassable 2019-05-19 16:46:07 -04:00
Matthias Clasen
5c2697633c popover menu: Drop the submenu child property
We are using the GtkWidget::name property instead.
2019-03-27 18:37:57 -04:00
Matthias Clasen
4a1019bed0 popover menu: Add an api for adding submenus
This is a step towards removing the submenu
child property.
2019-03-27 17:53:48 -04:00
Matthias Clasen
268fcbb838 Drop GtkPopoverMenu::position
This is another unnecessary position child property.
2019-02-04 10:47:18 -05:00
Ernestas Kulik
d88268c142 gtkpopovermenu: Conditionally chain up in gtk_popover_menu_add()
Otherwise the stack gets parented to the wrong widget and the contents
are never drawn.
2018-07-23 13:01:01 +03:00
Ernestas Kulik
49ae68c2c7 gtkpopovermenu: Drop call to gtk_widget_show()
The stack is already visible.
2018-07-23 13:00:11 +03:00
Matthias Clasen
4c150d8eb5 The big versioning cleanup
Remove all the old 2.x and 3.x version annotations.
GTK+ 4 is a new start, and from the perspective of a
GTK+ 4 developer all these APIs have been around since
the beginning.
2018-02-06 01:16:32 -05:00
Timm Bäder
f637006b3e popover: Add a contents node
Remove the special case in gtkwidget.c where we didn't draw any css
background/border for popovers. Instead, rely on themes to not style the
popover node and add a contents gizmo that gets the actual css styling.
We then requeste enough space for the popover to draw both the contents
and the arrow on the side.
2017-07-19 21:27:15 -04:00
Timm Bäder
4bd2a9bca9 popovermenu: Remove forall implementation 2017-01-20 21:50:02 +01:00
Emmanuele Bassi
1f132607f7 gtk: Use appropriate constness for variables 2016-10-17 11:44:11 +01:00
Marek Černocký
f64bb38aa7 Fixed typo childen->children 2016-01-19 12:52:58 +01:00
Timm Bäder
33ac663b13 popover: Use element name
Pick "popover" and add .menu for popover menus
2015-10-30 15:10:35 +01:00
Timm Bäder
ddcb309b5b GtkPopover: Set interpolate-size on the stack...
... in gtk_popover_bind_model
and gtk_popover_menu_init
2015-07-20 10:26:06 +02:00
Matthias Clasen
d51c9e0337 GtkPopoverMenu: be more careful about change notification
Only emit notify for ::visible-submenu when the visible page
in the stack actually changed.
2014-11-19 21:14:30 -05:00
Matthias Clasen
955c798ab1 GtkPopoverMenu: expose more properties
Expose the position as a child property and the visible page
as a property. These are useful in glade.
2014-11-18 13:39:15 +01:00
Matthias Clasen
1e39790c49 GtkPopoverMenu: Implement forall
This is required to make glade work.
2014-11-16 02:30:19 -05:00
Matthias Clasen
f60b2a11c5 Drop an unneeded include 2014-11-06 15:17:09 -05:00
Matthias Clasen
0b4c37624a GtkPopoverMenu: Add API to open a submenu
This allows alternative menu switching to be implemented, besides
the builtin GtkModelButton support.
2014-10-29 06:49:59 -04:00
Matthias Clasen
6e001acbf9 Add documentation
Document GtkModelButton and GtkPopoverMenu.
2014-10-29 06:49:59 -04:00
Matthias Clasen
55b7838b4f GtkPopoverMenu: Simplify
Change things so each submenu is a single child, and users are
required to create the box themselves.
2014-10-29 06:49:59 -04:00
Matthias Clasen
1f81c83fd8 Add GtkPopoverMenu
GtkPopoverMenu is a GtkPopover subclass that has a menu-like stack
built-in.
2014-10-29 06:49:58 -04:00