Commit Graph

51 Commits

Author SHA1 Message Date
Carlos Garnacho
31cd153050 a11y: Add GtkPopopverAccessible
And let GtkPopover use it as its GtkAccessible implementation, this
accessible sets the POPUP_FOR relationship to the relative-to widget,
and keeps track of changes there.

https://bugzilla.gnome.org/show_bug.cgi?id=725864
2014-03-10 23:02:14 +01:00
Carlos Garnacho
43e8852829 popover: Track toplevel's focus widget when visible
If the toplevel focus widget is forced out of the popover (eg. through
gtk_widget_grab_focus() anywhere else), then dismiss the popover.
2014-03-06 23:23:47 +01:00
Carlos Garnacho
dcba77fcc4 popover: Track toplevel focus changes
Make the popover temporarily undo the GTK+ grab, so it remains modal
to its window, but does not attempt to steal focus on other non-modal
windows that get the focus.

This was most confusing with keyboard navigation, as the focus would
remain stuck on the popover, and not move to the newly focused window
after the popover was dismissed. It didn't have as much effect on
pointer operations as only the first click would be consumed in order
to hide the popover.
2014-03-06 23:23:47 +01:00
Carlos Garnacho
08e9c93b17 popover: Only give back focus to drawable widgets
If the previous focus widget is not drawable anymore, don't even
bother in transmitting the focus grab to it.
2014-03-06 20:38:11 +01:00
Carlos Garnacho
aa7e00fcb8 popover: dispose popovers when unmanaging them
This makes popovers get rid of dangling pointers at the time of destroying
the relative-to widget, just in case these are kept alive by a reference.
2014-03-06 19:34:06 +01:00
Carlos Garnacho
5b1eeac96d popover: Set pointer motion mask on the popover window
This is not necessary for the popover itself, but helps tooltips
code confine the widget lookup within the popover if the pointer
is inside it, otherwise the widget lookup may turn out wrong for
motion events, starting the tooltip widget lookup from the toplevel
window, mistakenly triggering tooltips on the natural window
descendants (ie. the widget below the popover)

https://bugzilla.gnome.org/show_bug.cgi?id=724785
2014-03-05 13:58:04 +01:00
Carlos Garnacho
eb0f86d485 popover: Always apply the window shape
In practice this shape is only used to outline the popover when it is
above native windows, in the most normal full-csw case the shape won't apply
visibly, so popovers will still be able to cast a shadow there.

If there are native windows below the popover, the shape will exclude the
shadow, so there are no alpha contents above the window. One worst case that
might happen is that the popover lays above patches of native/client-side
windows, so the shadow could come and go around the border. But first let's
see whether that happens often or visibly enough before adding something more
convoluted.
2014-02-20 16:36:34 +01:00
Matthias Clasen
8ea40e4956 Trivial annotation syntax fix 2014-02-20 10:18:45 -05:00
William Jon McCann
469d333aa2 docs: use Returns: consistently
Instead of Return value:
2014-02-19 18:56:05 -05:00
Carlos Garnacho
63bb834b2e popover: Accept NULL relative_to widgets
And document the fact that the popover will get destroyed if
a NULL relative-to is given on a parented popover, if no extra
references are kept.

For gtk_popover_new*(), a NULL relative-to will leave the widget
as a floating object, to be sunk by a later call to
gtk_widget_set_relative_to().

https://bugzilla.gnome.org/show_bug.cgi?id=724407
2014-02-19 00:25:34 -05:00
Matthias Clasen
885026851f Another trivial doc rewording 2014-02-17 22:38:24 -05:00
Matthias Clasen
99bc982bd8 Trivial typo fix 2014-02-17 22:38:24 -05:00
Matthias Clasen
72e2094472 Drop with_separators from gtk_popover_bind_model
The with_separators argument does not really make sense
for popovers, it was just copied from the menu implementation.
Drop it now, before it becomes part of the public API.
2014-02-17 06:52:38 -05:00
Juan R. García Blanco
f3c9f86d14 popover: Make gtk_popover_bind_model() public
This is needed for the C++ bindings.

https://bugzilla.gnome.org/show_bug.cgi?id=724503
2014-02-17 06:52:23 -05:00
Matthias Clasen
444d04a360 More coding style cleanups 2014-02-09 01:22:07 -05:00
Matthias Clasen
eb0eaffd24 Trivial coding style cleanups 2014-02-09 00:48:38 -05:00
Matthias Clasen
add7a83452 Trivial formatting fix 2014-02-08 22:18:15 -05:00
Matthias Clasen
d1ba50aa96 Quell a compiler warning 2014-02-08 22:17:28 -05:00
Matthias Clasen
14ba1280ce Improve popover positioning
Improve the algorithm to determing popover placement:
If it fits in the preferred direction or its opposite,
do that, otherwise use the direction that causes the least
of the popover to be cut off.
2014-02-08 22:14:51 -05:00
Juan R. García Blanco
552c29b488 GtkPopover: use GdkRectangle instead of cairo_rectangle_int_t
cairo_rectangle_int_t replaced by GdkRectangle whenever it is used.
Also, rect parameter in public method gtk_popover_set_pointing_to
made const.

Bug #723394
2014-02-08 21:53:07 +01:00
Matthias Clasen
2fea2d4dbd Populate popovers from menu models
This adds a new function, gtk_popover_new_from_model, which creates
a popover and populates it with suitable content according to the
menu model. The current implementation uses GtkModelButton for the
individual items, and a GtkStack for submenus.

https://bugzilla.gnome.org/show_bug.cgi?id=723014
2014-02-07 15:11:51 -05:00
Carlos Garnacho
98a67d9697 popover: propagate (insensitive|backdrop) flags from relative-to widget
Popovers aren't direct children of the widget they point to, but yet
they act as children of it, so do the same with state propagation,
so the flags that propagate across the hierarchy reach popovers too.
2014-02-07 16:47:57 +01:00
Carlos Garnacho
63bed5d040 popover: Listen on grab_notify from the relative-to widget
Anytime ::grab-notify comes across, the popover visibility and GTK+
grab ownership are checked, so the popover is hidden when it loses
the GTK+ by any reason.
2014-02-07 16:47:57 +01:00
Bastien Nocera
d74ca9f02c popover: Emit ::closed once modality is cleared
Otherwise, calling gtk_widget_grab_focus() on a widget when the
popover send ::closed won't work.
2014-02-06 16:13:43 +01:00
Carlos Garnacho
99f16d25a7 popover: Add ::closed signal
This signal is emitted when the popover is dismissed either through
API or user interaction, somewhat more friendly than connecting to
::unmap.
2014-02-06 15:32:48 +01:00
Carlos Garnacho
2d9c09d6c0 popover: Add private _gtk_popover_set_apply_shape() call
Popovers no longer sets a shape, unless this function is called. This
function exists so widgets that are potentially placed on top of other
native windows can get a popover that's nicely shaped, even if it has
no border shadow around.

https://bugzilla.gnome.org/show_bug.cgi?id=723556
2014-02-04 21:29:25 +01:00
Alexander Larsson
0493d74650 popover: Apply child shapes on the GtkWidget popover subwindow
https://bugzilla.gnome.org/show_bug.cgi?id=723556
2014-02-04 21:29:10 +01:00
Matthias Clasen
245c385ae7 Docs: Don't use note elements
In most cases, the text itself makes the message clear enough.
2014-02-02 01:22:14 -05:00
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