[tepl] InfoBar: take the :icon-name property into account
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tepl] InfoBar: take the :icon-name property into account
- Date: Tue, 10 Nov 2020 23:33:16 +0000 (UTC)
commit 5497900263ec4b6d2f9415199cb10715b84e8fe0
Author: Sébastien Wilmet <swilmet gnome org>
Date: Wed Nov 11 00:24:48 2020 +0100
InfoBar: take the :icon-name property into account
tepl/tepl-info-bar.c | 21 ++++++++++++++++++---
tests/test-tab.c | 4 ++++
2 files changed, 22 insertions(+), 3 deletions(-)
---
diff --git a/tepl/tepl-info-bar.c b/tepl/tepl-info-bar.c
index 193011b..00bcdc7 100644
--- a/tepl/tepl-info-bar.c
+++ b/tepl/tepl-info-bar.c
@@ -258,15 +258,30 @@ get_icon_name_for_message_type (TeplInfoBar *info_bar)
return NULL;
}
+static const gchar *
+get_real_icon_name (TeplInfoBar *info_bar)
+{
+ if (info_bar->priv->icon_name != NULL)
+ {
+ return info_bar->priv->icon_name;
+ }
+
+ if (info_bar->priv->icon_from_message_type)
+ {
+ return get_icon_name_for_message_type (info_bar);
+ }
+
+ return NULL;
+}
+
static void
update_icon_state (TeplInfoBar *info_bar)
{
const gchar *icon_name;
- icon_name = get_icon_name_for_message_type (info_bar);
+ icon_name = get_real_icon_name (info_bar);
- if (info_bar->priv->icon_from_message_type &&
- icon_name != NULL)
+ if (icon_name != NULL)
{
gtk_image_set_from_icon_name (info_bar->priv->icon, icon_name, GTK_ICON_SIZE_DIALOG);
gtk_widget_show (GTK_WIDGET (info_bar->priv->icon));
diff --git a/tests/test-tab.c b/tests/test-tab.c
index fb91c17..8086d5b 100644
--- a/tests/test-tab.c
+++ b/tests/test-tab.c
@@ -35,6 +35,10 @@ basic_cb (GtkButton *button,
// updated?
gtk_info_bar_set_message_type (GTK_INFO_BAR (info_bar), GTK_MESSAGE_QUESTION);
+ // Test setting the :icon-name property. It should have a higher
+ // priority.
+ tepl_info_bar_set_icon_name (info_bar, "document-print");
+
tepl_tab_add_info_bar (tab, GTK_INFO_BAR (info_bar));
gtk_widget_show (GTK_WIDGET (info_bar));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]