Commit Graph

68 Commits

Author SHA1 Message Date
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
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