[tepl] InfoBar: add the :icon-from-message-type property
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tepl] InfoBar: add the :icon-from-message-type property
- Date: Tue, 10 Nov 2020 19:17:32 +0000 (UTC)
commit 56bfdcd4eeca30f37e571a9919a2ee8a5b08412d
Author: Sébastien Wilmet <swilmet gnome org>
Date: Tue Nov 10 19:52:54 2020 +0100
InfoBar: add the :icon-from-message-type property
Just the boilerplate for this commit.
docs/reference/tepl-sections.txt | 2 ++
tepl/tepl-info-bar.c | 67 ++++++++++++++++++++++++++++++++++++++++
tepl/tepl-info-bar.h | 7 +++++
3 files changed, 76 insertions(+)
---
diff --git a/docs/reference/tepl-sections.txt b/docs/reference/tepl-sections.txt
index 75a3a4b..7f87446 100644
--- a/docs/reference/tepl-sections.txt
+++ b/docs/reference/tepl-sections.txt
@@ -238,6 +238,8 @@ TeplInfoBar
tepl_info_bar_new
tepl_info_bar_new_simple
tepl_info_bar_add_icon
+tepl_info_bar_get_icon_from_message_type
+tepl_info_bar_set_icon_from_message_type
tepl_info_bar_add_primary_message
tepl_info_bar_add_secondary_message
tepl_info_bar_add_content_widget
diff --git a/tepl/tepl-info-bar.c b/tepl/tepl-info-bar.c
index 0149058..2dfccf9 100644
--- a/tepl/tepl-info-bar.c
+++ b/tepl/tepl-info-bar.c
@@ -33,12 +33,14 @@ struct _TeplInfoBarPrivate
/* Can contain primary/secondary messages plus additional widgets. */
GtkGrid *content_vgrid;
+ guint icon_from_message_type : 1;
guint handle_close_response : 1;
};
enum
{
PROP_0,
+ PROP_ICON_FROM_MESSAGE_TYPE,
PROP_HANDLE_CLOSE_RESPONSE,
N_PROPERTIES
};
@@ -57,6 +59,10 @@ tepl_info_bar_get_property (GObject *object,
switch (prop_id)
{
+ case PROP_ICON_FROM_MESSAGE_TYPE:
+ g_value_set_boolean (value, tepl_info_bar_get_icon_from_message_type (info_bar));
+ break;
+
case PROP_HANDLE_CLOSE_RESPONSE:
g_value_set_boolean (value, tepl_info_bar_get_handle_close_response (info_bar));
break;
@@ -77,6 +83,10 @@ tepl_info_bar_set_property (GObject *object,
switch (prop_id)
{
+ case PROP_ICON_FROM_MESSAGE_TYPE:
+ tepl_info_bar_set_icon_from_message_type (info_bar, g_value_get_boolean (value));
+ break;
+
case PROP_HANDLE_CLOSE_RESPONSE:
tepl_info_bar_set_handle_close_response (info_bar, g_value_get_boolean (value));
break;
@@ -120,6 +130,24 @@ tepl_info_bar_class_init (TeplInfoBarClass *klass)
info_bar_class->response = tepl_info_bar_response;
+ /**
+ * TeplInfoBar:icon-from-message-type:
+ *
+ * If this property is %TRUE, then an icon is shown on the left, based
+ * on the value of the #GtkInfoBar:message-type property. For
+ * %GTK_MESSAGE_OTHER no icon is shown.
+ *
+ * Since: 6.0
+ */
+ properties[PROP_ICON_FROM_MESSAGE_TYPE] =
+ g_param_spec_boolean ("icon-from-message-type",
+ "icon-from-message-type",
+ "",
+ FALSE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_STRINGS);
+
/**
* TeplInfoBar:handle-close-response:
*
@@ -286,6 +314,45 @@ tepl_info_bar_add_icon (TeplInfoBar *info_bar)
gtk_widget_show (GTK_WIDGET (info_bar->priv->icon));
}
+/**
+ * tepl_info_bar_get_icon_from_message_type:
+ * @info_bar: a #TeplInfoBar.
+ *
+ * Returns: the value of the #TeplInfoBar:icon-from-message-type property.
+ * Since: 6.0
+ */
+gboolean
+tepl_info_bar_get_icon_from_message_type (TeplInfoBar *info_bar)
+{
+ g_return_val_if_fail (TEPL_IS_INFO_BAR (info_bar), FALSE);
+
+ return info_bar->priv->icon_from_message_type;
+}
+
+/**
+ * tepl_info_bar_set_icon_from_message_type:
+ * @info_bar: a #TeplInfoBar.
+ * @icon_from_message_type: the new value.
+ *
+ * Sets a new value to the #TeplInfoBar:icon-from-message-type property.
+ *
+ * Since: 6.0
+ */
+void
+tepl_info_bar_set_icon_from_message_type (TeplInfoBar *info_bar,
+ gboolean icon_from_message_type)
+{
+ g_return_if_fail (TEPL_IS_INFO_BAR (info_bar));
+
+ icon_from_message_type = icon_from_message_type != FALSE;
+
+ if (info_bar->priv->icon_from_message_type != icon_from_message_type)
+ {
+ info_bar->priv->icon_from_message_type = icon_from_message_type;
+ g_object_notify_by_pspec (G_OBJECT (info_bar), properties[PROP_ICON_FROM_MESSAGE_TYPE]);
+ }
+}
+
/**
* tepl_info_bar_add_primary_message:
* @info_bar: a #TeplInfoBar.
diff --git a/tepl/tepl-info-bar.h b/tepl/tepl-info-bar.h
index 1be0117..388a792 100644
--- a/tepl/tepl-info-bar.h
+++ b/tepl/tepl-info-bar.h
@@ -53,6 +53,13 @@ TeplInfoBar * tepl_info_bar_new_simple
(GtkMessageType msg_type,
_TEPL_EXTERN
void tepl_info_bar_add_icon (TeplInfoBar *info_bar);
+_TEPL_EXTERN
+gboolean tepl_info_bar_get_icon_from_message_type (TeplInfoBar *info_bar);
+
+_TEPL_EXTERN
+void tepl_info_bar_set_icon_from_message_type (TeplInfoBar *info_bar,
+ gboolean icon_from_message_type);
+
_TEPL_EXTERN
void tepl_info_bar_add_primary_message (TeplInfoBar *info_bar,
const gchar *primary_msg);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]