Commit 1bb4f1e9 authored by Timm Bäder's avatar Timm Bäder 🤔
Browse files

infobar: Add :revealed property

parent e3871c44
......@@ -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;
......@@ -301,36 +308,6 @@ gtk_info_bar_close (GtkInfoBar *info_bar)
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)
{
......@@ -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));
}
......@@ -130,6 +130,12 @@ void gtk_info_bar_set_show_close_button (GtkInfoBar *info_bar,
GDK_AVAILABLE_IN_3_10
gboolean gtk_info_bar_get_show_close_button (GtkInfoBar *info_bar);
GDK_AVAILABLE_IN_3_90
void gtk_info_bar_set_revealed (GtkInfoBar *info_bar,
gboolean revealed);
GDK_AVAILABLE_IN_3_90
gboolean gtk_info_bar_get_revealed (GtkInfoBar *info_bar);
G_END_DECLS
#endif /* __GTK_INFO_BAR_H__ */
......@@ -5,6 +5,7 @@
<child>
<object class="GtkRevealer" id="revealer">
<property name="visible">1</property>
<property name="reveal-child">1</property>
<child>
<object class="GtkBox" id="content">
<property name="visible">1</property>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment