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.
This commit is contained in:
Carlos Garnacho 2014-02-06 15:30:55 +01:00
parent 13b37bd4e0
commit 99f16d25a7
2 changed files with 18 additions and 0 deletions

View File

@ -66,6 +66,11 @@ enum {
PROP_MODAL
};
enum {
CLOSED,
N_SIGNALS
};
struct _GtkPopoverPrivate
{
GtkWidget *widget;
@ -89,6 +94,7 @@ struct _GtkPopoverPrivate
};
static GQuark quark_widget_popovers = 0;
static guint signals[N_SIGNALS] = { 0 };
static void gtk_popover_update_position (GtkPopover *popover);
static void gtk_popover_update_relative_to (GtkPopover *popover,
@ -289,6 +295,8 @@ gtk_popover_unmap (GtkWidget *widget)
priv = GTK_POPOVER (widget)->priv;
priv->button_pressed = FALSE;
g_signal_emit (widget, signals[CLOSED], 0);
if (priv->modal)
gtk_popover_apply_modality (GTK_POPOVER (widget), FALSE);
@ -1226,6 +1234,14 @@ gtk_popover_class_init (GtkPopoverClass *klass)
TRUE,
GTK_PARAM_READWRITE));
signals[CLOSED] =
g_signal_new (I_("closed"),
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkPopoverClass, closed),
NULL, NULL, NULL,
G_TYPE_NONE, 0);
quark_widget_popovers = g_quark_from_static_string ("gtk-quark-widget-popovers");
}

View File

@ -48,6 +48,8 @@ struct _GtkPopoverClass
{
GtkBinClass parent_class;
void (* closed) (GtkPopover *popover);
/* Padding for future expansion */
gpointer reserved[10];
};