Commit Graph

89 Commits

Author SHA1 Message Date
Timm Bäder
c28275f4ec GtkPopover: Don't ref NULL widgets
gtk_window_get_default_widget returns NULL if the window does not have a
default widget, so don't ref it in that case.
2015-05-03 20:03:56 +02:00
Matthias Clasen
e1c1fc59e5 Add default widget handling to popovers
Add a new API, gtk_popover_set_default_widget, that can be
used to make a widget act as default while the popover is
shown. This is useful in dialog-like popovers.

http://bugzilla.gnome.org/show_bug.cgi?id=747664
2015-05-02 20:34:28 -04:00
Kjell Ahlstedt
2495edc9fd GtkPopover:pointing-to: GdkRectangle instead of cairo_rectangle_int_t
cairo_rectangle_int_t was replaced by GdkRectangle in commit
552c29b488, but the type of the pointing-to
property was not changed.

To avoid breaking old code that sets or gets the property with a GValue
of type CAIRO_GOBJECT_TYPE_RECTANGLE_INT, transformation functions between
CAIRO_GOBJECT_TYPE_RECTANGLE_INT and GDK_TYPE_RECTANGLE are registered on
the first call to gdk_rectangle_get_type().

https://bugzilla.gnome.org/show_bug.cgi?id=723394
2015-04-21 09:05:26 +02:00
Matthias Clasen
ac931e9506 popover: Remove signal handlers in dispose
If we don't, they may get triggered at an inopportune
time later, causing us to crash.

See
https://bugzilla.redhat.com/show_bug.cgi?id=1203499

https://bugzilla.gnome.org/show_bug.cgi?id=747539
2015-04-09 06:39:11 -04:00
Carlos Garnacho
cff1694c99 popover: Add show/hide transitions
These have the same visual effect and timing than the gnome-shell ones.
During the hide animation, the popover has been made to take focus
elsewhere, and refuse to take any pointer/keyboard input until the popover
is shown again.

This has been based on work from Timm Bäder.

https://bugzilla.gnome.org/show_bug.cgi?id=741405
2015-02-20 14:44:17 +01:00
Carlos Garnacho
4ba2c9ad87 popover: Unset the grab when the popover loses its parent
This ensures the grab and signal handlers are removed if the parent goes
NULL.
2015-02-05 15:09:51 +01:00
Carlos Garnacho
5837c1c710 popover: Keep a ref on the parent scrollable
This ensures the scrollable is still alive on dispose(), and properly unset
after disconnecting all signal handlers.
2015-02-05 15:08:12 +01:00
Ting-Wei Lan
2c6ac1fa3e popover: Add a missing #ifdef 2014-12-24 21:59:49 +08:00
Carlos Garnacho
96f7c11f48 window: Use subsurfaces for popovers on wayland
On the wayland backend, set up GDK_WINDOW_SUBSURFACE windows
for popovers. In the popover code, the popover-relative-to-parent
calculation had to be tweaked, and it's been made to always prefer
the given popover position, since there's no sizing limitations.

https://bugzilla.gnome.org/show_bug.cgi?id=738891
2014-12-23 13:55:24 +01:00
Carlos Garnacho
ba22ae8cce popover: Clamp tail gap limits by the tail height on that side
All popover sides have extra margins to possibly hold the tail, this is
accounted for in gtk_popover_get_rect_coords(), and should be accounted
for too in the tail position calculation.

This fixes the gtk_render_frame_gap() warnings seen when a popover is
pushed far too close to window sides.
2014-12-13 18:02:29 +01:00
Carlos Garnacho
99791007a7 popover: Ensure there is a child before focusing it
Fixes a warning in empty popovers being shown.
2014-12-13 17:11:25 +01:00
Carlos Garnacho
ccdcff9456 popover: make smarter wrt previous focus widget lifetime
If the previous focus widget is unmapped (eg. hidden, scheduled for
destruction, etc), make the popover forget about it and grant focus
back to the window itself.
2014-12-02 15:49:23 +01:00
Matthias Clasen
e26fddc544 Avoid a critical
gtk_window_get_focus can return NULL, deal with it.

https://bugzilla.gnome.org/show_bug.cgi?id=740812
2014-11-27 18:24:12 -05:00
Carlos Garnacho
50076ed95b popover: Send key events only to the focus widget
gtk_window_propagate_key_event() will run unstopped from the focus widget up to the
popover if GDK_EVENT_PROPAGATE was returned along the chain, resulting in infinite
recursion. This could be just triggered by pressing some modifier key on an entry...
2014-11-26 15:30:52 +01:00
Carlos Garnacho
dde77704ed popover: Forward key events to focus widget while visible/modal
This is the expected behavior while the popover keeps the grab, leaving
this up to the toplevel implementation gives place to key handlers
connected there to handle the event otherwise, and maybe redirect key
events somewhere else.
2014-11-25 14:08:34 +01:00
Timm Bäder
9b83858d9a Revert "popover: Add show/hide transition"
This reverts commit 17f48e3a9e.
2014-11-17 18:39:00 +01:00
Timm Bäder
17f48e3a9e popover: Add show/hide transition 2014-11-17 18:37:47 +01:00
Matthias Clasen
49cf85509a GtkPopover: Survive attach_widget == NULL
We can't render a tail, but otherwise things should just work.
This will be useful in glade.
2014-11-14 06:16:41 -05:00
Carlos Garnacho
733f70ea84 gtkpopover: Fix allocation of child widget wrt margins
During size request, all sides' margins are ensured to be as big
as TAIL_HEIGHT, just to avoid possible relocation loops if the
popover doesn't fit in its original position. This must be
accounted for in size_allocate() as well.
2014-11-13 20:32:36 +01:00
Matthias Clasen
e41a8cf6fc Use GtkStack:vhomogeneous for popover menus
This allows us to get rid of a size group.
2014-10-26 15:03:58 -04:00
Timm Bäder
4d075cf202 popover: Use the right area for drawing the background
The border shouldn't be subtracted.
2014-10-26 15:21:06 +01:00
Benjamin Otte
91467a45fc stylecontext: Deprecate functions
- gtk_style_context_get_background_color()
- gtk_style_context_get_border_color()

Those functions shouldn't be used anymore, because they don't represent
anything from the CSS styling we support. The background color often
isn't used due to background images and there are actually 4 different
border colors (1 for each side) - if there isn't also a border image in
use.
2014-10-03 06:18:06 +02:00
Carlos Garnacho
0285a255bc popover: Don't run full dispose() when unmanaging the widget
A popover can go unmanaged for 2 reasons, when the widget it points to
gets destroyed, or transitionally in gtk_popover_set_relative_to(). In
both of these cases it makes sense to only unset popover information
about the previous widget managing it, if the popover is meant to
survive the unmanaging through extra refs.

Also, the focus widget prior to a modal popover being shown is considered
information about the relative_to widget, unset it on
gtk_popover_update_relative_to() with the rest.

https://bugzilla.gnome.org/show_bug.cgi?id=736193
2014-09-22 20:59:09 -04:00
Matthias Clasen
7645d201d4 GtkPopover: Fix rtl positioning
There was some confusion between unflipped and flipped positions.
Both final_position and current_position are meant to be unflipped,
and get_effective_position() needs to be applied to them to get
a flipped position. _gtk_window_set_popover_position() also expects
an unflipped position.

https://bugzilla.gnome.org/show_bug.cgi?id=735014
2014-08-21 11:59:44 -04:00
Carlos Garnacho
5b8267028d window: Update popover positions on ::size-allocate
Popovers may get relocations optimized away if only x/y changed
in the GtkAllocation. So make sure the toplevel updates popover
positions on all situations.

https://bugzilla.gnome.org/show_bug.cgi?id=729140
2014-08-03 18:37:53 +02:00
Lars Uebernickel
d0a3c8bd6f gtkpopover: set background and popover css classes
https://bugzilla.gnome.org/show_bug.cgi?id=731834
2014-06-18 14:24:14 +02:00
Matthias Clasen
8915e9cf42 GtkPopover: Use G_PARAM_EXPLICIT_NOTIFY 2014-06-09 13:31:06 -04:00
Carlos Garnacho
cf7bb9a3bf popover: Hide widget first when disposing
In order to ensure invariants are kept.
2014-05-23 19:54:31 +02:00
Carlos Garnacho
cacccf7a3a popover: Check for uncaught button events from children
And deal correctly with those as a click within the popover.

https://bugzilla.gnome.org/show_bug.cgi?id=727994
2014-05-19 14:00:07 +02:00
Carlos Garnacho
e2cd59b731 popover: Do not hide the popover if the focus widget is just unset
The focus widget might be unset, just to be set again on a widget inside
the popover. Have the popover wait till the focus is actually moved outside
before dismissing.
2014-05-19 13:49:03 +02:00
Owen W. Taylor
8f9e50de80 GtkPopover: inherit actions from the relative_to widget
Make the relative_to widget the parent for a GtkPopover's
GtkActionGroup. This, for example, makes the menu model of a
GtkMenuButton find action groups attached to the button.

https://bugzilla.gnome.org/show_bug.cgi?id=729915
2014-05-12 16:39:44 -04:00
Benjamin Otte
17e0f9fb0a popover: Remove unneeded checks
Size vfuncs always get non-null out variables passed, so no need to
check for NULL.
2014-05-01 14:51:28 +02:00
Carlos Garnacho
5b72e0f8cf popover: Always make room for the tail on all sides on size request
Now that popovers may snap to any side with enough space, make enough
room on every side when requesting size, so that there's no w/h differences
at the time of setting the child allocation.

https://bugzilla.gnome.org/show_bug.cgi?id=729097
2014-04-28 22:35:32 +02:00
Matthias Clasen
6c3936fb9a Document iconic section support
https://bugzilla.gnome.org/show_bug.cgi?id=727477
2014-04-28 14:21:07 -04:00
Ryan Lortie
5137e491dc GtkPopover: new approach to menu model binding
Instead of using GtkMenuTracker to flatten the sections into a single
linear menu, handle the sections ourselves by nesting boxes.

Each section gets an inner and outer box.  The inner box numbers its
children in the way that the tracker instructs.  The outer box
containes the inner box and the separator, if appropriate.

Having the two separate boxes will allow us to change the orientation of
the inner box if we want to pack widgets horizontally within a section.
2014-04-28 14:14:42 -04:00
Ryan Lortie
d930716daf GtkMenuTracker: add 'merge_sections' flag
Add the possibility of a GtkMenuTracker that performs no section
merging.  Instead, it will report an item in the form of a separator for
subsections.  It is then possible to get a separate tracker for the
subsection contents by using gtk_menu_tracker_new_for_item_link().
2014-04-28 14:14:42 -04:00
Ryan Lortie
f6ee00769a GtkMenuTracker: don't specialise "submenu" link
We have some API in GtkMenuTracker and GtkMenuTrackerItem that is
specifically designed to deal with submenus.

Generalise these APIs to take a 'link_name' parameter that we always
give as G_MENU_SUBMENU for now.  In the future, this will allow creating
trackers for other types of links, such as sections.
2014-04-28 14:14:41 -04:00
Matthias Clasen
70b4b622b4 GtkPopover: Fix two doc comments 2014-03-17 19:13:53 -04:00
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