[gtk+] popover: Listen on grab_notify from the relative-to widget
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] popover: Listen on grab_notify from the relative-to widget
- Date: Fri, 7 Feb 2014 15:47:00 +0000 (UTC)
commit 63bed5d04019b5487427701e1e070b2279d753fe
Author: Carlos Garnacho <carlosg gnome org>
Date: Fri Feb 7 16:14:23 2014 +0100
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.
gtk/gtkpopover.c | 22 ++++++++++++++++++++++
1 files changed, 22 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkpopover.c b/gtk/gtkpopover.c
index ced74dc..f3505b2 100644
--- a/gtk/gtkpopover.c
+++ b/gtk/gtkpopover.c
@@ -84,6 +84,7 @@ struct _GtkPopoverPrivate
guint size_allocate_id;
guint unmap_id;
guint scrollable_notify_id;
+ guint grab_notify_id;
guint has_pointing_to : 1;
guint preferred_position : 2;
guint final_position : 2;
@@ -1295,6 +1296,21 @@ _gtk_popover_parent_hierarchy_changed (GtkWidget *widget,
}
static void
+_gtk_popover_parent_grab_notify (GtkWidget *widget,
+ gboolean was_shadowed,
+ GtkPopover *popover)
+{
+ GtkPopoverPrivate *priv;
+
+ priv = gtk_popover_get_instance_private (popover);
+
+ if (priv->modal &&
+ gtk_widget_is_visible (GTK_WIDGET (popover)) &&
+ !gtk_widget_has_grab (GTK_WIDGET (popover)))
+ gtk_widget_hide (GTK_WIDGET (popover));
+}
+
+static void
_gtk_popover_parent_unmap (GtkWidget *widget,
GtkPopover *popover)
{
@@ -1439,6 +1455,8 @@ gtk_popover_update_relative_to (GtkPopover *popover,
g_signal_handler_disconnect (priv->widget, priv->size_allocate_id);
if (g_signal_handler_is_connected (priv->widget, priv->unmap_id))
g_signal_handler_disconnect (priv->widget, priv->unmap_id);
+ if (g_signal_handler_is_connected (priv->widget, priv->grab_notify_id))
+ g_signal_handler_disconnect (priv->widget, priv->grab_notify_id);
widget_unmanage_popover (priv->widget, popover);
}
@@ -1470,6 +1488,10 @@ gtk_popover_update_relative_to (GtkPopover *popover,
g_signal_connect (priv->widget, "unmap",
G_CALLBACK (_gtk_popover_parent_unmap),
popover);
+ priv->grab_notify_id =
+ g_signal_connect (priv->widget, "grab-notify",
+ G_CALLBACK (_gtk_popover_parent_grab_notify),
+ popover);
/* Give ownership of the popover to widget */
widget_manage_popover (priv->widget, popover);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]