From 540884a59a599ff7b256e44f38b7b299add09794 Mon Sep 17 00:00:00 2001 From: Perry Werneck Date: Sat, 19 Sep 2020 12:09:06 -0300 Subject: [PATCH] Adding option for symbolic icons in the header bar. --- pw3270.cbp | 8 ++++---- src/include/pw3270/actions.h | 2 +- src/objects/actions/button.c | 9 +++++++-- src/objects/window/header.c | 4 +++- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/pw3270.cbp b/pw3270.cbp index aefb8a8..c57dd55 100644 --- a/pw3270.cbp +++ b/pw3270.cbp @@ -130,7 +130,10 @@ - + + + @@ -189,9 +192,6 @@ - - diff --git a/src/include/pw3270/actions.h b/src/include/pw3270/actions.h index 3b78e71..03a7e55 100644 --- a/src/include/pw3270/actions.h +++ b/src/include/pw3270/actions.h @@ -120,7 +120,7 @@ GdkPixbuf * g_action_get_pixbuf(GAction *action, GtkIconSize icon_size, GtkIconLookupFlags flags); - GtkWidget * gtk_button_new_from_action(GAction *action, GtkIconSize icon_size); + GtkWidget * gtk_button_new_from_action(GAction *action, GtkIconSize icon_size, gboolean symbolic); GtkToolItem * gtk_tool_button_new_from_action(GAction *action, GtkIconSize icon_size, gboolean symbolic); G_END_DECLS diff --git a/src/objects/actions/button.c b/src/objects/actions/button.c index e692826..4425643 100644 --- a/src/objects/actions/button.c +++ b/src/objects/actions/button.c @@ -35,14 +35,19 @@ #include "private.h" #include - GtkWidget * gtk_button_new_from_action(GAction *action, GtkIconSize icon_size) { + GtkWidget * gtk_button_new_from_action(GAction *action, GtkIconSize icon_size, gboolean symbolic) { if(!action) return NULL; g_autofree gchar * icon_name = g_action_get_icon_name(action); - if(icon_name) + if(icon_name) { + if(symbolic && !strstr(icon_name,"-symbolic")) { + g_autofree gchar * name = g_strconcat(icon_name,"-symbolic",NULL); + return gtk_button_new_from_icon_name(name,icon_size); + } return gtk_button_new_from_icon_name(icon_name,icon_size); + } GdkPixbuf * pixbuf = g_action_get_pixbuf(action, GTK_ICON_SIZE_BUTTON, GTK_ICON_LOOKUP_GENERIC_FALLBACK); diff --git a/src/objects/window/header.c b/src/objects/window/header.c index fd05818..d88eaa7 100644 --- a/src/objects/window/header.c +++ b/src/objects/window/header.c @@ -124,6 +124,8 @@ GtkWidget * pw3270_header_button_new_from_builder(GtkWidget *widget, GtkBuilder * builder, const gchar *action_name) { GtkWidget * button = NULL; + g_autoptr(GSettings) settings = pw3270_application_window_settings_new(); + gboolean symbolic = g_settings_get_int(settings,"header-icon-type") == 1; if(g_str_has_prefix(action_name,"menu.")) { @@ -145,7 +147,7 @@ g_warning("Can't find action %s",action_name); } - button = gtk_button_new_from_action(action,GTK_ICON_SIZE_BUTTON); + button = gtk_button_new_from_action(action,GTK_ICON_SIZE_BUTTON,symbolic); gtk_actionable_set_action_name(GTK_ACTIONABLE(button),action_name); gtk_widget_set_visible(button,g_action_get_enabled(action)); -- libgit2 0.21.2