PROP_0,
PROP_MESSAGE_TYPE,
PROP_SHOW_CLOSE_BUTTON,
+ PROP_REVEALED,
LAST_PROP
};
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;
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;
GTK_RESPONSE_CANCEL);
}
-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)
{
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;
/**
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);
/**
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 property does not automatically show @info_bar and thus won’t
+ * have any effect if it is invisible.
+ *
+ * Since: 3.22
+ */
+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.22
+ */
+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));
+}