Commit Graph

323 Commits

Author SHA1 Message Date
Matthias Clasen
4e066a750a GtkPopover: avoid a critical
focus_widget can be NULL, as pointed out in
https://bugzilla.gnome.org/show_bug.cgi?id=723181#c7
2014-01-30 08:13:05 -05:00
Carlos Garnacho
709fb26587 popover: Improve minimal size allocation
The minimal size if no child widget was present/shown was far too small
to have enough room for the arrow width plus border radii, so
gtk_render_frame_gap would spew warnings about the gap being out of
boundaries.

Fixes issues seen in
https://bugzilla.gnome.org/show_bug.cgi?id=723031#c2
2014-01-28 16:20:05 +01:00
Carlos Garnacho
7b4ef99320 popover: Hide/ungrab on button release
If the grab is released during button press, the button release is
just then sent to the widget below the pointer. Depending on the
widget implementation, this could already trigger actions if the
widget does not perform any kind of button state tracking. It is
safer to ungrab on button release so no extra actions are possibly
triggered, and the behavior is uniform across widgets.

But the opposite situation may also happen, that a popover is
shown/grabbed on a button press event, so it'd get the sole button
release event after being shown, so prepare for that case by making
popover ignore single button release events with no preceding button
press.

Fixes issues seen in
https://bugzilla.gnome.org/show_bug.cgi?id=723031#c2
2014-01-28 16:18:53 +01:00
Matthias Clasen
fec0116493 Slight rewording of some docs 2014-01-23 21:09:24 -05:00
Carlos Garnacho
074e17e100 popover: Don't overdraw background
It was only done so the background would connect visually to the popover
tail, but then it brings aliasing issues when the border is drawn over the
background. Instead, overdraw the tail, so it also fills the gap left by
the border.
2014-01-22 18:32:16 +01:00
Carlos Garnacho
eb2c1242fe popover: Update child visibility when scrolling happens
If pointing_to starts falling outside of the parent scrollable allocation,
the popover will be automatically hidden, and shown back again when
pointing_to scrolls back to visibility.
2014-01-22 17:10:07 +01:00
Carlos Garnacho
8d3439db61 popover: Track parent scrollable adjustments
This makes sure popovers follow the relative_to widget if it is
contained within a GtkScrollable.
2014-01-22 17:10:07 +01:00
Carlos Garnacho
81f13232d8 popover: fix g-i warning 2014-01-22 17:10:07 +01:00
Carlos Garnacho
d0c74dc288 popover: Fix documentation blurb
The grabbing behavior is no longer exclusively controlled by the caller,
mention gtk_popover_set_modal().
2014-01-22 17:10:07 +01:00
Carlos Garnacho
5f667b5820 popover: use GtkWindow private popover API 2014-01-22 17:10:07 +01:00
Carlos Garnacho
649004ce43 popover: Do not set GTK_STYLE_CLASS_OSD directly
That's up to the caller, popovers are by design not only meant to
have that role.
2014-01-22 17:10:06 +01:00
Carlos Garnacho
462e7f0de1 popover: Fix allocation of CSS margins
that was forgotten about, leaving no room for theme shadows that'd
make popovers look less flat.
2014-01-22 17:10:06 +01:00
Carlos Garnacho
69182c03fb popover: Flip popovers positioning on left/right on RTL.
If widgets have GTK_TEXT_DIRECTION_RTL, popovers being positioned
on GTK_POS_LEFT/RIGHT will default to appearing on the other side
too.
2014-01-22 17:10:06 +01:00
Matthias Clasen
ea0a1e31a7 Implement wfh functions
With only get_preferred_width and get_preferred_height implemented,
we end up calling the GtkBin height_for_width implmementation, which
knows nothing about the margins and paddings that GtkPopover needs.
As a result, a listbox added to a popover was getting cut off
at the bottom.
2014-01-22 17:10:06 +01:00
Carlos Garnacho
e8fa9e1851 popover: Remember last focused widget on the toplevel when a popover is shown
This is so the previously focused widget can regain focus when a modal popover
is dismissed.
2014-01-22 17:10:06 +01:00
Carlos Garnacho
1d495cbafd popover: Add a "modal" boolean property to GtkPopover
This property is TRUE by default, when a popover is modal, it
will automatically set a GTK+ grab on the popover, and grab
the keyboard focus into the popover.
2014-01-22 17:10:06 +01:00
Carlos Garnacho
31042fe95f popover: Fix memory management of popovers
Popovers are strange in the sense that they aren't attached to a
parent directly, they rely on the relative_to widget so the toplevel
is shared, and when they have a parent, it is the toplevel itself,
not relative_to. This also means that there are conditions where the
popover loses it's parent, so they must survive unparenting.

The previous code would be floating the last reference as soon as the
parent is gone, but it was non-obvious who'd own that reference. So
fix this situation by granting the ownership of popovers to their
relative_to widget, an extra reference may be held by the toplevel
when the popover has a parent, but the popover object will be
guaranteed to be alive as long as the parent lives.

This way, memory management of popovers is as hidden from the user
as regular widgets within containers are, users are free to call
gtk_widget_destroy() on a popover, but it'd eventually become
destructed when relative_to is.
2014-01-22 17:10:06 +01:00
Carlos Garnacho
342c23da23 popover: Implement keyboard focus behavior
When a popover is focused, the focus is forwarded so the first
child what would get the focus actually gets it. Also, implement
correct focus chain, so the keyboard focus stays within the popover
when navigating with keyboard.
2014-01-22 17:10:06 +01:00
Carlos Garnacho
bb7ef098c4 popover: Add documentation 2014-01-22 17:10:05 +01:00
Carlos Garnacho
4d12d85919 popover: Honor GtkContainer::border-width
The border width is now set around the contained widget.
2014-01-22 17:10:05 +01:00
Carlos Garnacho
7c10fc5580 popover: remove GTK+ grab (if any) on unmap
If there is a GTK+ grab on the popover, ensure that it's removed when it's
unmapped. If no GTK+ grab was performed on the popover, this function will
do nothing.
2014-01-22 17:10:05 +01:00
Carlos Garnacho
b4805f7076 popover: listen harder on the widget being pointed to
Hierarchy, size allocation and widget visibility are now listened
to in order to update the popover state accordingly.
2014-01-22 17:10:05 +01:00
Carlos Garnacho
caeb896096 Introduce GtkPopover
Now that the GtkBubbleWindow object has been cleaned up and made
more generic, rename it as GtkPopover and make it public.
2014-01-22 17:10:04 +01:00