core: Add meta_close_dialog_is_visible() property

Since the last show/hide call should be effective, implement
it without requiring an extra interface property.

https://bugzilla.gnome.org/show_bug.cgi?id=762083
This commit is contained in:
Carlos Garnacho 2017-07-14 16:42:58 +02:00
parent 5aee5048ba
commit aa47374d0e
2 changed files with 21 additions and 0 deletions

View File

@ -31,6 +31,8 @@ enum {
guint dialog_signals[N_SIGNALS] = { 0 };
static GQuark quark_visible = 0;
G_DEFINE_INTERFACE (MetaCloseDialog, meta_close_dialog, G_TYPE_OBJECT)
static void
@ -50,6 +52,8 @@ meta_close_dialog_default_init (MetaCloseDialogInterface *iface)
0,
NULL, NULL, NULL,
G_TYPE_NONE, 1, META_TYPE_CLOSE_DIALOG_RESPONSE);
quark_visible = g_quark_from_static_string ("meta-close-dialog-visible");
}
/**
@ -67,6 +71,7 @@ meta_close_dialog_show (MetaCloseDialog *dialog)
iface = META_CLOSE_DIALOG_GET_IFACE (dialog);
iface->show (dialog);
g_object_set_qdata (G_OBJECT (dialog), quark_visible, GINT_TO_POINTER (TRUE));
}
/**
@ -84,6 +89,7 @@ meta_close_dialog_hide (MetaCloseDialog *dialog)
iface = META_CLOSE_DIALOG_GET_IFACE (dialog);
iface->hide (dialog);
g_object_steal_qdata (G_OBJECT (dialog), quark_visible);
}
/**
@ -101,3 +107,17 @@ meta_close_dialog_response (MetaCloseDialog *dialog,
g_signal_emit (dialog, dialog_signals[RESPONSE], 0, response);
meta_close_dialog_hide (dialog);
}
/**
* meta_close_dialog_is_visible:
* @dialog: a #MetaCloseDialog
*
* Returns whether @dialog is currently visible.
*
* Returns: #TRUE if @dialog is visible.
**/
gboolean
meta_close_dialog_is_visible (MetaCloseDialog *dialog)
{
return GPOINTER_TO_INT (g_object_get_qdata (G_OBJECT (dialog), quark_visible));
}

View File

@ -46,6 +46,7 @@ struct _MetaCloseDialogInterface
void meta_close_dialog_show (MetaCloseDialog *dialog);
void meta_close_dialog_hide (MetaCloseDialog *dialog);
gboolean meta_close_dialog_is_visible (MetaCloseDialog *dialog);
void meta_close_dialog_response (MetaCloseDialog *dialog,
MetaCloseDialogResponse response);