Commit Graph

138 Commits

Author SHA1 Message Date
Carlos Garnacho
769ee1156d popover: Update scrollable on relative-to hierarchy changes
The relative-to widget may be reparented itself into/out of a
scrollable. In this cases make the hierachy-changed handler to
unset the parent scrollable when unparented, and look up again
the parent scrollable after it's reparented.

https://bugzilla.gnome.org/show_bug.cgi?id=771812
2016-09-29 12:46:34 +02:00
Carlos Garnacho
588a1dce2b popover: Add helper functions around setting up an scrollable
gtk_popover_set_scrollable_full() takes care of the signal connected
on the scrollable itself, in addition to the adjustment signals the
popover listens to.

gtk_popover_update_scrollable() looks up the current relative-to
widget hierarchy and updates the current scrollable.

The places where the scrollable is being maintained have been updated
to use these functions.

https://bugzilla.gnome.org/show_bug.cgi?id=771812
2016-09-29 12:46:34 +02:00
Timm Bäder
857997be8c popover: Skip first frame when transitioning
Similar to what we do in GtkStack.
2016-09-03 12:24:58 +02:00
Timm Bäder
ce1ae60da2 popover: Propagate drawing 2016-09-01 15:20:12 +02:00
Timm Bäder
2c04941c5c popover: Fix hfw/wfh size request
Since we're using _get_rect_coords in size-allocate when allocating the
size of the child widget, use the newly introduced _get_rect_for_size to
calculate the difference between the passed size_for and the one we're
supposed to pass on to the child widget.
2016-09-01 15:16:58 +02:00
Timm Bäder
7f1ab32e60 popover: Introduce _get_rect helper for a size
When calculating the requested size of a popover, we need to do the
exact same same thing _get_rect_coords did, but not for the
current popopver allocation. Add _get_rect_for_size that can be used for
this purpose
2016-09-01 15:15:18 +02:00
Timm Bäder
5c696a7ee3 popover: Clarify transitions-enabled deprecation
https://bugzilla.gnome.org/show_bug.cgi?id=769706
2016-08-20 20:54:20 +02:00
Timm Bäder
a6b9b3648d GtkPopover: Deprecate transitions-enabled
The effect of transitions-enabled=true can now be
achieved using gtk_popover_popup/popdown and the effect
of transitions-enabled=false can be achieved using
gtk_widget_show/hide.

https://bugzilla.gnome.org/show_bug.cgi?id=769706
2016-08-16 11:49:26 -04:00
Timm Bäder
1f7b6c1d6f GtkPopover: Add gtk_popover_popdown/popup
Since not chaining up in gtk_widget_show/gtk_widget_hide is not allowed,
we can't just implicitly delay the hiding in GtkPopover's hide
implementation. Fix this by introducing gtk_popover_popup() and
gtk_popover_popdown() to show or hide a popover with transition and
revert GtkPopover's show/hide implementation to apply their effect
without the transition.

https://bugzilla.gnome.org/show_bug.cgi?id=769706
2016-08-16 11:49:26 -04:00
Timm Bäder
0d17421ffd popover: Make some public API NULL-safe
Instad of potentially dereferencing a NULL-pointer, use the NULL-safe
gtk_popover_get_instance_private before the g_return_if_fail
precondition check.
2016-08-10 16:37:17 +02:00
Carlos Garnacho
ed227f9e7b GtkPopover: Honor widget margins when calculating tail position
If there are widget margins set, the whole popover will be displaced.
However the calculation of the tail position doesn't have this into
account, ending up with the tail being detached from the popover if
the margin grew too big.

We should not render the arrows invariably next to the GdkWindow edge,
but optionally displaced inside it depending on the widget margins.
Fixes the gtk3-demo "Popovers" demo case, whose GtkEntry popovers set
widget margins for some reason.

https://bugzilla.gnome.org/show_bug.cgi?id=767851
2016-06-21 17:54:42 +02:00
Phillip Wood
72ea348ad6 Fix hiding popover when focus moves outside
Commit a01fe14 changed the behaviour of popovers when the focus leaves
them to stop child popovers being hidden when the focus leaves their
parent. However they are now a bit too reluctant to hide - if the
focus passes to an unrelated popover the first popover is not
hidden. Also if the focus passes to another widget that does not
perform a gtk grab then the popover isn't hidden until the user
presses a non-movement key or clicks outside the popover.

The solution is to go back to checking if the focused widget is a
descendant of the popover, but to include popovers and their related
widgets in the ancestry chain.

https://bugzilla.gnome.org/show_bug.cgi?id=765595
2016-06-05 22:54:00 -04:00
Carlos Garnacho
76a5e3fc3c popover: set priv->window before setting doing add_popover() on it
If the popover's relative-to widget is unparented/reparented, we end
up unparenting/reparenting the popover as well. In that case, at the
moment of reparenting, the widget might have been visible (and is
thus mapped again), but priv->window hasn't been set yet.

We must first set priv->window, and then call gtk_window_add_popover(),
that way gtk_popover_map() has its prerequisites straight.

https://bugzilla.gnome.org/show_bug.cgi?id=766323
2016-05-21 20:40:43 +02:00
Matthias Clasen
9d038df7de popover: Use getter for gtk-enable-animations 2016-05-01 00:39:03 -04:00
Matt Watson
dc8b80cd32 popover: port to progress tracker 2016-04-08 16:09:30 -07:00
Michael Catanzaro
ea423318f1 Fix a typo 2016-02-13 22:15:07 -06:00
Alberto Ruiz
496f0892fc introspection: This patch fixes nullable return values fixes for the following symbols in gtk
gtk_accel_group_query
  gtk_accel_group_from_accel_closure
  gtk_accel_label_get_accel_widget
  gtk_accessible_get_widget
  gtk_actionable_get_action_name
  gtk_app_chooser_get_app_info
  gtk_app_chooser_button_get_heading
  gtk_app_chooser_dialog_get_heading
  gtk_application_get_window_by_id
  gtk_assistant_get_nth_page
  gtk_binding_set_find
  gtk_builder_get_object
  gtk_builder_lookup_callback_symbol
  gtk_builder_get_application
  gtk_button_get_image
  gtk_cell_area_get_focus_from_sibling
  gtk_cell_renderer_start_editing
  gtk_cell_view_get_model
  gtk_cell_view_get_displayed_row
  gtk_clipboard_get_owner
  gtk_container_get_focus_child
  gtk_container_get_focus_vadjustment
  gtk_container_get_focus_hadjustment
  gtk_dialog_get_widget_for_response
  gtk_drag_get_source_widget
  gtk_drag_dest_get_target_list
  gtk_drag_source_get_target_list
  gtk_entry_completion_get_model
  gtk_entry_completion_compute_prefix
  gtk_expander_get_label_widget
  gtk_file_chooser_get_filename
  gtk_file_chooser_get_current_folder
  gtk_file_chooser_get_uri
  gtk_file_chooser_get_current_folder_uri
  gtk_file_chooser_get_preview_widget
  gtk_file_chooser_get_preview_file
  gtk_file_chooser_get_preview_filename
  gtk_file_chooser_get_preview_uri
  gtk_file_chooser_get_extra_widget
  gtk_file_chooser_get_filter
  gtk_file_chooser_native_get_accept_label
  gtk_file_chooser_native_get_cancel_label
  gtk_file_filter_get_name
  gtk_font_chooser_get_font_family
  gtk_font_chooser_get_font_face
  gtk_font_chooser_get_font
  gtk_font_chooser_get_font_desc
  gtk_font_chooser_get_font_map
  gtk_frame_get_label
  gtk_gesture_get_device
  gtk_gesture_get_window
  gtk_gl_area_get_error
  gtk_header_bar_get_title
  gtk_header_bar_get_subtitle
  gtk_header_bar_get_custom_title
  gtk_icon_info_get_filename
  gtk_icon_view_get_path_at_pos
  gtk_icon_view_get_model
  gtk_image_get_pixbuf
  gtk_image_get_animation
  gtk_label_get_mnemonic_widget
  gtk_label_get_attributes
  gtk_check_version
  gtk_menu_button_get_popup
  gtk_menu_button_get_menu_model
  gtk_menu_button_get_align_widget
  gtk_menu_button_get_popover
  gtk_menu_item_get_submenu
  gtk_menu_item_get_accel_path
  gtk_native_dialog_get_title
  gtk_native_dialog_get_transient_for
  gtk_notebook_get_nth_page
  gtk_notebook_get_tab_label_text
  gtk_notebook_get_menu_label
  gtk_notebook_get_menu_label_text
  gtk_notebook_get_group_name
  gtk_notebook_get_action_widget
  gtk_offscreen_window_get_surface
  gtk_offscreen_window_get_pixbuf
  gtk_paned_get_child1
  gtk_paned_get_child2
  gtk_places_sidebar_get_location
  gtk_places_sidebar_get_nth_bookmark
  gtk_plug_get_socket_window
  gtk_popover_get_default_widget
  gtk_progress_bar_get_text
  gtk_recent_filter_get_name
  gtk_recent_manager_lookup_item
  gtk_settings_get_default
  gtk_socket_get_plug_window
  gtk_stack_sidebar_get_stack
  gtk_stack_switcher_get_stack
  gtk_style_context_get_section
  gtk_style_context_get_parent
  gtk_style_context_get_frame_clock
  gtk_test_find_widget
  gtk_text_buffer_get_mark
  gtk_text_tag_table_lookup
  gtk_text_view_get_tabs
  gtk_text_view_toggle_cursor_visible
  gtk_text_view_get_window
  gtk_toolbar_get_nth_item
  gtk_tool_button_get_label
  gtk_tool_button_get_icon_name
  gtk_tool_button_get_label_widget
  gtk_tool_button_get_icon_widget
  gtk_tool_palette_get_drop_item
  gtk_tool_palette_get_drop_group
  gtk_tree_model_filter_convert_child_path_to_path
  gtk_tree_model_filter_convert_path_to_child_path
  gtk_tree_model_sort_convert_child_path_to_path
  gtk_tree_model_sort_convert_path_to_child_path
  gtk_tree_view_get_column
  gtk_tree_view_get_bin_window
  gtk_tree_view_column_get_widget
  gtk_tree_view_column_get_tree_view
  gtk_widget_get_frame_clock
  gtk_window_group_get_current_device_grab
  GtkTextBufferSerializeFunc
2016-01-08 12:18:23 +00:00
Timm Bäder
711ffd648e GtkPopover: Protect against transparent backgrounds
If the background is transparent, we can't use it for the input shape,
since that will be empty. Draw a box with rounded corners irectly
instead, in fully opaque black.

https://bugzilla.gnome.org/show_bug.cgi?id=759905
2016-01-08 09:14:03 +01:00
Carlos Garnacho
3be4971e05 GtkPopover: Ensure we unset modality before unparenting the popover
Otherwise the gtk_grab_remove() calls on widget destruction will happen
on the default window group, which may leave the real window group
of the popover with a dangling pointer if it is not the default one.

This could be seen on the inspector, open a popover in the properties
list and close the window with alt-F4.
2015-12-16 20:47:25 +01:00
Matthias Clasen
0384f9eaf3 popover: Make position property not CONSTRUCT
There is no good reason for it, and it causes problems
with widget templates.
2015-12-02 01:07:02 -05:00
Matthias Clasen
564e11cc4e popover: Port to g_object_install_properties
And use the pspecs for notification.
2015-12-02 01:03:35 -05:00
Matthias Clasen
e626038467 popover: Make it possible to constrain to toplevel
Under X11, popovers are always constrained to the toplevel
window. Under Wayland, they aren't. This commit adds a
property that allows to explicitly constrain popovers to
the toplevel, giving them the same behavior under Wayland
as under X11.

https://bugzilla.gnome.org/show_bug.cgi?id=757474
2015-12-01 17:26:25 -05:00
Timm Bäder
bd0f217ff4 GtkPopover: Restore tails
The call to gtk_style_context_get_border was accidentally removed in
2182fe7d9d.
2015-11-24 11:37:00 +01:00
Timm Bäder
2182fe7d9d Don't pass widget state flags to GtkStyleContext API 2015-11-22 17:11:35 +01:00
Matthias Clasen
87b10e6f60 popover: Avoid a crash when no relative-to widget is set
This was showing up in glade, which creates freestanding
popovers.
2015-11-17 22:48:35 -05:00
Matthias Clasen
0bfc7db1fa popover: Don't create transient CSS nodes
There is no need to save the style context here.
2015-11-06 11:50:23 -05:00
Matthias Clasen
eade244cac popover: Add the .background style class
This style class indicates that something _requires_ a background,
which is clearly the case for popovers.
2015-11-04 12:05:03 -05:00
Carlos Garnacho
9d1b8dfc61 popover: Request raise on ::show
This way latest shown popovers are ensured to be on top.

https://bugzilla.gnome.org/show_bug.cgi?id=756670
2015-11-03 07:25:33 -05:00
Matthias Clasen
e56bb49407 popover: Document differentiating style classes
There's a lot of popover variations out there.
2015-11-02 12:53:57 -05: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
Carlos Garnacho
d8e41e1308 popover: Invalidate borders on tail position changes
There's nothing doing this explicitly, so tail position changes may
leave trails of older positions.

https://bugzilla.gnome.org/show_bug.cgi?id=756449
2015-10-13 02:07:24 +02:00
Timm Bäder
d8856f1b61 GtkPopover: Don't apply shape on wayland
Popovers are subsurfaces on wayland so we don't need that, and the shape
messed up hidpi popovers there.
2015-10-07 09:49:51 +02:00
Timm Bäder
3e39ec5743 GtkPopover: Make transitions faster
https://bugzilla.gnome.org/show_bug.cgi?id=755528
2015-09-29 20:59:12 -04:00
Timm Bäder
5bf47338e8 GtkPopover: Remove apply_shape field
This was introduced in 2d9c09d6 alongside a private setter, but that
setter has been removed and the field is always TRUE.
2015-09-29 15:28:55 +02:00
Timm Bäder
8a6b720632 GtkPopover: Don't resize during the transition
Call gtk_popover_update_position instead which will pick up the new
transition_diff value and pass it on to
_gtk_window_set_popover_position, which in turn will move the window
correctly.

https://bugzilla.gnome.org/show_bug.cgi?id=755435
2015-09-29 15:28:55 +02:00
Timm Bäder
eb8a64982e GtkPopover: Remove _get_pointed_to_coords
It's only used once and removing it only adds a single line there.

https://bugzilla.gnome.org/show_bug.cgi?id=755435
2015-09-29 15:28:55 +02:00
Alexander Larsson
d5f1754981 gtk: Stop setting GDK_EXPOSURE_MASK on random widgets
These days exposure happens only on the native windows (generally the
toplevel window) and is propagated down recursively. The expose event
is only useful for backwards compat, and in fact, for double buffered
widgets we totally ignore the event (and non-double buffering breaks
on wayland).

So, by not setting the mask we avoid emitting these events and then
later ignoring them.

We still keep it on eventbox, fixed and layout as these are used
in weird ways that want backwards compat.
2015-09-14 11:01:13 +02:00
Benjamin Otte
63cefa199a popover: Don't inherit style from parent
Instead, inherit style from toplevel (because that's the default way,
not because it makes lots of sense).

This way, popovers don't inherit the styling from the widget that popped
them up, which is a problem in selected listbox rows, selection-mode
headerbars.
It also doesn't inherit styling where we might want it, like the osd.

But we can only have one of the two things.
2015-09-04 18:59:51 +02:00
Matthias Clasen
58f363c852 Revert "popover: Optimize the transition"
This reverts commit 84bd32a09a.

It turned out that this did break the transition in some places.
2015-08-21 18:08:30 -04:00
Matthias Clasen
775800f76e popover: Don't restore stale default widget
Only restore the saved default widget if the default hasn't been
changed while the popover was visible.
2015-08-15 23:38:20 -04:00
Matthias Clasen
84bd32a09a popover: Optimize the transition
There's no need to queue a resize here.

https://bugzilla.gnome.org/show_bug.cgi?id=753568
2015-08-15 22:02:40 -04: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
Carlos Garnacho
7f57f63eba gtkwindow: Only allow unrestricted positioning to text handle popovers
This behavior has been made optional on add_popover() time, text handles
will keep being able to overflow the window, in order to allow text
selection on views too close to the window edge.

Regular GtkPopovers are reinstaurated to the previous size positioning
logic though, that is, limited by the visible area of the window.
2015-07-06 16:39:06 +02:00
Carlos Garnacho
76dc8aced5 window: Add concept of popover "parent"
This will be the widget that the popover relates to (::pointing-to in
GtkPopover, ::parent in GtkTextHandle).

Additional API to check the popover/parent relationship between widgets
has been added, which will be useful wherever this is necessary in a
generic manner.

https://bugzilla.gnome.org/show_bug.cgi?id=750993
2015-06-17 15:56:42 +02:00
Carlos Garnacho
a01fe14056 popover: Avoid hiding modal popovers if another popover is taking focus
Due to popover modality itself, there's quite high chances the popover
stealing focus has been triggered from within, so stay friendly to it.
Hiding the popover here will only hide the grabbing popover too if this
happens.

https://bugzilla.gnome.org/show_bug.cgi?id=750741
2015-06-12 21:00:45 +02:00
Carlos Garnacho
2be6d09c9e popover: Be lenient wrt visibility of popovers too close to widget borders
The check used to hide the popover if the pointed area fell partly out of
the widget allocation, textviews now can trigger that with text selections
too close to the visible edge, as a small extra area around is now reserved.

The check has been changed to only hide the popover if the pointed area
falls completely outside the widget allocation.
2015-06-12 12:07:30 +02:00
Timm Bäder
d3a18de97e gtkpopover: Update the menu's alignment
... when the popover position changes.
2015-05-29 17:37:04 +02:00
Matthias Clasen
2bb1ed69f0 GtkPopover: Clean up default widget on dispose
We forgot to drop the ref we take. Thankfully our
tests caught this.
2015-05-12 07:57:04 -04:00
Matthias Clasen
1f51c506c3 Fix precondition in gtk_popover_get_default_widget
We need to return a value here.
2015-05-04 09:28:46 -04:00
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