diff options
author | Timm Bäder <mail@baedert.org> | 2017-01-12 09:09:22 +0100 |
---|---|---|
committer | Timm Bäder <mail@baedert.org> | 2017-01-12 09:16:02 +0100 |
commit | 1bb4f1e9d9c4fb54e1a4b4e05bf6c5d1302f00d3 (patch) | |
tree | 284ab539e72719751ab619932af0202ac6dd1bef /gtk/gtkinfobar.c | |
parent | e3871c4424081cc521e7ec6502ef5cfb6a535b2a (diff) | |
download | gtk+-1bb4f1e9d9c4fb54e1a4b4e05bf6c5d1302f00d3.tar.gz |
infobar: Add :revealed property
Diffstat (limited to 'gtk/gtkinfobar.c')
-rw-r--r-- | gtk/gtkinfobar.c | 94 |
1 files changed, 61 insertions, 33 deletions
diff --git a/gtk/gtkinfobar.c b/gtk/gtkinfobar.c index 91e25150b5..2a2293893f 100644 --- a/gtk/gtkinfobar.c +++ b/gtk/gtkinfobar.c @@ -132,6 +132,7 @@ enum PROP_0, PROP_MESSAGE_TYPE, PROP_SHOW_CLOSE_BUTTON, + PROP_REVEALED, LAST_PROP }; @@ -211,6 +212,9 @@ gtk_info_bar_set_property (GObject *object, case PROP_SHOW_CLOSE_BUTTON: gtk_info_bar_set_show_close_button (info_bar, g_value_get_boolean (value)); break; + case PROP_REVEALED: + gtk_info_bar_set_revealed (info_bar, g_value_get_boolean (value)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -233,6 +237,9 @@ gtk_info_bar_get_property (GObject *object, case PROP_SHOW_CLOSE_BUTTON: g_value_set_boolean (value, gtk_info_bar_get_show_close_button (info_bar)); break; + case PROP_REVEALED: + g_value_set_boolean (value, gtk_info_bar_get_revealed (info_bar)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -302,36 +309,6 @@ gtk_info_bar_close (GtkInfoBar *info_bar) } static void -gtk_info_bar_show (GtkWidget *widget) -{ - GtkInfoBarPrivate *priv = GTK_INFO_BAR (widget)->priv; - - GTK_WIDGET_CLASS (gtk_info_bar_parent_class)->show (widget); - - gtk_revealer_set_reveal_child (GTK_REVEALER (priv->revealer), TRUE); -} - -static void -child_revealed (GObject *object, GParamSpec *pspec, gpointer data) -{ - GtkWidget *widget = data; - - GTK_WIDGET_CLASS (gtk_info_bar_parent_class)->hide (widget); - g_signal_handlers_disconnect_by_func (object, child_revealed, widget); - g_object_notify (G_OBJECT (widget), "visible"); -} - -static void -gtk_info_bar_hide (GtkWidget *widget) -{ - GtkInfoBarPrivate *priv = GTK_INFO_BAR (widget)->priv; - - g_signal_connect_object (priv->revealer, "notify::child-revealed", - G_CALLBACK (child_revealed), widget, 0); - gtk_revealer_set_reveal_child (GTK_REVEALER (priv->revealer), FALSE); -} - -static void gtk_info_bar_class_init (GtkInfoBarClass *klass) { GtkWidgetClass *widget_class; @@ -344,9 +321,6 @@ gtk_info_bar_class_init (GtkInfoBarClass *klass) object_class->get_property = gtk_info_bar_get_property; object_class->set_property = gtk_info_bar_set_property; - widget_class->show = gtk_info_bar_show; - widget_class->hide = gtk_info_bar_hide; - klass->close = gtk_info_bar_close; /** @@ -380,6 +354,13 @@ gtk_info_bar_class_init (GtkInfoBarClass *klass) FALSE, GTK_PARAM_READWRITE|G_PARAM_CONSTRUCT|G_PARAM_EXPLICIT_NOTIFY); + props[PROP_REVEALED] = + g_param_spec_boolean ("revealed", + P_("Reveal"), + P_("Controls whether the action bar shows its contents or not"), + TRUE, + GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY); + g_object_class_install_properties (object_class, LAST_PROP, props); /** @@ -1178,3 +1159,50 @@ gtk_info_bar_get_show_close_button (GtkInfoBar *info_bar) return info_bar->priv->show_close_button; } + +/** + * gtk_info_bar_set_revealed: + * @info_bar: a #GtkActionBar + * @revealed: The new value of the property + * + * Sets the GtkInfoBar:revealed property to @revealed. This will cause + * @info_bar to show up with a slide-in transition. + * + * Note that this settings does not automatically show @info_bar and thus won't + * have any effect if it is invisible. + * + * Since: 3.90 + */ +void +gtk_info_bar_set_revealed (GtkInfoBar *info_bar, + gboolean revealed) +{ + GtkInfoBarPrivate *priv = gtk_info_bar_get_instance_private (info_bar); + + g_return_if_fail (GTK_IS_INFO_BAR (info_bar)); + + revealed = !!revealed; + if (revealed != gtk_revealer_get_reveal_child (GTK_REVEALER (priv->revealer))) + { + gtk_revealer_set_reveal_child (GTK_REVEALER (priv->revealer), revealed); + g_object_notify_by_pspec (G_OBJECT (info_bar), props[PROP_REVEALED]); + } +} + +/** + * gtk_info_bar_get_revealed: + * @info_bar: a #GtkInfoBar + * + * Returns: the current value of the GtkInfoBar:revealed property. + * + * Since: 3.90 + */ +gboolean +gtk_info_bar_get_revealed (GtkInfoBar *info_bar) +{ + GtkInfoBarPrivate *priv = gtk_info_bar_get_instance_private (info_bar); + + g_return_val_if_fail (GTK_IS_INFO_BAR (info_bar), FALSE); + + return gtk_revealer_get_reveal_child (GTK_REVEALER (priv->revealer)); +} |