Commit 825ada0c63edf09cd9c773518a35cec0db9da81d
1 parent
22723d84
Exists in
master
and in
2 other branches
Implementing use of symbolic icons in toolbar.
Showing
9 changed files
with
73 additions
and
21 deletions
Show diff stats
schemas/linux/window.gschema.xml.in
... | ... | @@ -86,14 +86,14 @@ |
86 | 86 | <description></description> |
87 | 87 | </key> |
88 | 88 | |
89 | - <key name="toolbar-icon-symbolic" type="b"> | |
90 | - <default>false</default> | |
89 | + <key name="toolbar-icon-type" type="i"> | |
90 | + <default>0</default> | |
91 | 91 | <summary>Use symbolic icons on toolbar</summary> |
92 | 92 | <description></description> |
93 | 93 | </key> |
94 | 94 | |
95 | - <key name="header-icon-symbolic" type="b"> | |
96 | - <default>false</default> | |
95 | + <key name="header-icon-type" type="i"> | |
96 | + <default>0</default> | |
97 | 97 | <summary>Use symbolic icons on title bar</summary> |
98 | 98 | <description></description> |
99 | 99 | </key> | ... | ... |
schemas/windows/window.gschema.xml.in
... | ... | @@ -86,14 +86,14 @@ |
86 | 86 | <description></description> |
87 | 87 | </key> |
88 | 88 | |
89 | - <key name="toolbar-icon-symbolic" type="b"> | |
90 | - <default>false</default> | |
89 | + <key name="toolbar-icon-type" type="i"> | |
90 | + <default>0</default> | |
91 | 91 | <summary>Use symbolic icons on toolbar</summary> |
92 | 92 | <description></description> |
93 | 93 | </key> |
94 | 94 | |
95 | - <key name="header-icon-symbolic" type="b"> | |
96 | - <default>false</default> | |
95 | + <key name="header-icon-type" type="i"> | |
96 | + <default>0</default> | |
97 | 97 | <summary>Use symbolic icons on title bar</summary> |
98 | 98 | <description></description> |
99 | 99 | </key> | ... | ... |
src/include/pw3270/actions.h
... | ... | @@ -121,7 +121,7 @@ |
121 | 121 | GdkPixbuf * g_action_get_pixbuf(GAction *action, GtkIconSize icon_size, GtkIconLookupFlags flags); |
122 | 122 | |
123 | 123 | GtkWidget * gtk_button_new_from_action(GAction *action, GtkIconSize icon_size); |
124 | - GtkToolItem * gtk_tool_button_new_from_action(GAction *action, GtkIconSize icon_size); | |
124 | + GtkToolItem * gtk_tool_button_new_from_action(GAction *action, GtkIconSize icon_size, gboolean symbolic); | |
125 | 125 | |
126 | 126 | G_END_DECLS |
127 | 127 | ... | ... |
src/include/pw3270/toolbar.h
... | ... | @@ -66,9 +66,11 @@ |
66 | 66 | |
67 | 67 | void pw3270_toolbar_set_style(GtkToolbar *toolbar, GtkToolbarStyle style); |
68 | 68 | void pw3270_toolbar_set_icon_size(GtkToolbar *toolbar, GtkIconSize icon_size); |
69 | + void pw3270_toolbar_set_icon_type(GtkToolbar *toolbar, gint icon_type); | |
69 | 70 | |
70 | 71 | GtkToolbarStyle pw3270_toolbar_get_style(GtkToolbar *toolbar); |
71 | 72 | GtkIconSize pw3270_toolbar_get_icon_size(GtkToolbar *toolbar); |
73 | + gint pw3270_toolbar_get_icon_type(GtkToolbar *toolbar); | |
72 | 74 | |
73 | 75 | G_END_DECLS |
74 | 76 | ... | ... |
src/objects/actions/button.c
... | ... | @@ -62,7 +62,7 @@ |
62 | 62 | return NULL; |
63 | 63 | } |
64 | 64 | |
65 | - GtkToolItem * gtk_tool_button_new_from_action(GAction *action, GtkIconSize icon_size) { | |
65 | + GtkToolItem * gtk_tool_button_new_from_action(GAction *action, GtkIconSize icon_size, gboolean symbolic) { | |
66 | 66 | |
67 | 67 | if(!action) |
68 | 68 | return NULL; |
... | ... | @@ -75,14 +75,18 @@ |
75 | 75 | } |
76 | 76 | |
77 | 77 | g_autofree gchar * icon_name = g_action_get_icon_name(action); |
78 | -// debug("%s(%s).icon_name=%s",__FUNCTION__,g_action_get_name(action),icon_name); | |
79 | 78 | |
80 | 79 | if(icon_name) { |
81 | 80 | |
82 | 81 | // Has icon name |
83 | 82 | GtkToolItem * item = gtk_tool_button_new(NULL,label); |
84 | 83 | |
85 | - gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON(item),icon_name); | |
84 | + if(symbolic && !strstr(icon_name,"-symbolic")) { | |
85 | + g_autofree gchar * symbolic_name = g_strconcat(icon_name,"-symbolic",NULL); | |
86 | + gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON(item),symbolic_name); | |
87 | + } else { | |
88 | + gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON(item),icon_name); | |
89 | + } | |
86 | 90 | |
87 | 91 | if(tooltip) |
88 | 92 | gtk_widget_set_tooltip_markup(GTK_WIDGET(item),tooltip); | ... | ... |
src/objects/toolbar/actions.c
... | ... | @@ -68,7 +68,6 @@ |
68 | 68 | |
69 | 69 | if(ptr) { |
70 | 70 | action = g_action_map_lookup_action(G_ACTION_MAP(window), ptr+1); |
71 | - debug("action(%s)=%p",ptr+1,action); | |
72 | 71 | } |
73 | 72 | |
74 | 73 | } |
... | ... | @@ -77,7 +76,11 @@ |
77 | 76 | |
78 | 77 | if(action) { |
79 | 78 | debug("Creating button \"%s\" from action \"%s\"",name,g_action_get_name(G_ACTION(action))); |
80 | - item = gtk_tool_button_new_from_action(action,GTK_ICON_SIZE_LARGE_TOOLBAR); | |
79 | + item = gtk_tool_button_new_from_action( | |
80 | + action, | |
81 | + GTK_ICON_SIZE_LARGE_TOOLBAR, | |
82 | + pw3270_toolbar_get_icon_type(GTK_TOOLBAR(toolbar)) == 1 | |
83 | + ); | |
81 | 84 | } |
82 | 85 | |
83 | 86 | if(item) { | ... | ... |
src/objects/toolbar/private.h
... | ... | @@ -37,6 +37,9 @@ |
37 | 37 | #define GETTEXT_PACKAGE PACKAGE_NAME |
38 | 38 | #endif |
39 | 39 | |
40 | + /* not really I18N-related, but also a string marker macro */ | |
41 | + #define I_(string) g_intern_static_string (string) | |
42 | + | |
40 | 43 | #include <libintl.h> |
41 | 44 | #include <glib/gi18n.h> |
42 | 45 | #include <gtk/gtk.h> | ... | ... |
src/objects/toolbar/toolbar.c
... | ... | @@ -90,12 +90,14 @@ |
90 | 90 | PROP_NONE, |
91 | 91 | PROP_ACTION_NAMES, |
92 | 92 | PROP_ICON_SIZE, |
93 | + PROP_ICON_TYPE, | |
93 | 94 | PROP_STYLE |
94 | 95 | }; |
95 | 96 | |
96 | 97 | struct _pw3270ToolBar { |
97 | 98 | GtkToolbar parent; |
98 | 99 | GtkToolbarStyle style; |
100 | + int icon_type; | |
99 | 101 | |
100 | 102 | /// @brief Popup Menu |
101 | 103 | struct { |
... | ... | @@ -131,9 +133,9 @@ |
131 | 133 | object_class, |
132 | 134 | PROP_ACTION_NAMES, |
133 | 135 | g_param_spec_string ( |
134 | - "action-names", | |
135 | - N_("Action Names"), | |
136 | - N_("The name of the actions in the toolbar"), | |
136 | + I_("action-names"), | |
137 | + "Action Names", | |
138 | + _("The name of the actions in the toolbar"), | |
137 | 139 | NULL, |
138 | 140 | G_PARAM_READABLE|G_PARAM_WRITABLE) |
139 | 141 | ); |
... | ... | @@ -142,8 +144,8 @@ |
142 | 144 | object_class, |
143 | 145 | PROP_ICON_SIZE, |
144 | 146 | g_param_spec_int( |
145 | - "icon-size", | |
146 | - "icon-size", | |
147 | + I_("icon-size"), | |
148 | + "icon size", | |
147 | 149 | _("The toolbar icon size"), |
148 | 150 | INT_MIN, |
149 | 151 | INT_MAX, |
... | ... | @@ -155,7 +157,7 @@ |
155 | 157 | object_class, |
156 | 158 | PROP_STYLE, |
157 | 159 | g_param_spec_int( |
158 | - "style", | |
160 | + I_("style"), | |
159 | 161 | "style", |
160 | 162 | _("The toolbar style"), |
161 | 163 | INT_MIN, |
... | ... | @@ -164,6 +166,19 @@ |
164 | 166 | G_PARAM_READABLE|G_PARAM_WRITABLE) |
165 | 167 | ); |
166 | 168 | |
169 | + g_object_class_install_property( | |
170 | + object_class, | |
171 | + PROP_ICON_TYPE, | |
172 | + g_param_spec_int( | |
173 | + I_("icon-type"), | |
174 | + I_("icon-type"), | |
175 | + _("The toolbar icon type"), | |
176 | + 0, | |
177 | + 1, | |
178 | + 0, | |
179 | + G_PARAM_READABLE|G_PARAM_WRITABLE) | |
180 | + ); | |
181 | + | |
167 | 182 | } |
168 | 183 | |
169 | 184 | void get_property(GObject *object, guint prop_id, GValue *value, GParamSpec G_GNUC_UNUSED(*pspec)) { |
... | ... | @@ -181,6 +196,10 @@ |
181 | 196 | g_value_set_int(value,pw3270_toolbar_get_style(GTK_TOOLBAR(object))); |
182 | 197 | break; |
183 | 198 | |
199 | + case PROP_ICON_TYPE: | |
200 | + g_value_set_int(value,pw3270_toolbar_get_icon_type(GTK_TOOLBAR(object))); | |
201 | + break; | |
202 | + | |
184 | 203 | default: |
185 | 204 | g_assert_not_reached (); |
186 | 205 | } |
... | ... | @@ -203,13 +222,16 @@ |
203 | 222 | pw3270_toolbar_set_style(GTK_TOOLBAR(object),(GtkToolbarStyle) g_value_get_int(value)); |
204 | 223 | break; |
205 | 224 | |
225 | + case PROP_ICON_TYPE: | |
226 | + pw3270_toolbar_set_icon_type(GTK_TOOLBAR(object),(GtkToolbarStyle) g_value_get_int(value)); | |
227 | + break; | |
228 | + | |
206 | 229 | default: |
207 | 230 | g_assert_not_reached (); |
208 | 231 | } |
209 | 232 | |
210 | 233 | } |
211 | 234 | |
212 | - | |
213 | 235 | static void detacher(GtkWidget *attach_widget, GtkMenu G_GNUC_UNUSED(*menu)) { |
214 | 236 | |
215 | 237 | pw3270ToolBar * toolbar = PW3270_TOOLBAR(attach_widget); |
... | ... | @@ -379,6 +401,15 @@ |
379 | 401 | return PW3270_TOOLBAR(toolbar)->style; |
380 | 402 | } |
381 | 403 | |
404 | + gint pw3270_toolbar_get_icon_type(GtkToolbar *toolbar) { | |
405 | + return PW3270_TOOLBAR(toolbar)->icon_type; | |
406 | + } | |
407 | + | |
408 | + void pw3270_toolbar_set_icon_type(GtkToolbar *toolbar, gint icon_type) { | |
409 | + PW3270_TOOLBAR(toolbar)->icon_type = icon_type; | |
410 | + g_object_notify(G_OBJECT(toolbar), "icon-type"); | |
411 | + } | |
412 | + | |
382 | 413 | void pw3270_toolbar_set_icon_size(GtkToolbar *toolbar, GtkIconSize icon_size) { |
383 | 414 | |
384 | 415 | debug("%s(%d)",__FUNCTION__,(int) icon_size); | ... | ... |
src/objects/window/window.c
... | ... | @@ -284,6 +284,7 @@ |
284 | 284 | } |
285 | 285 | |
286 | 286 | widget->toolbar = GTK_TOOLBAR(pw3270_toolbar_new()); |
287 | + | |
287 | 288 | gtk_box_pack_start(container,GTK_WIDGET(widget->toolbar),FALSE,TRUE,0); |
288 | 289 | |
289 | 290 | // |
... | ... | @@ -578,6 +579,14 @@ |
578 | 579 | |
579 | 580 | g_settings_bind( |
580 | 581 | settings, |
582 | + "toolbar-icon-type", | |
583 | + window->toolbar, | |
584 | + "icon-type", | |
585 | + G_SETTINGS_BIND_DEFAULT | |
586 | + ); | |
587 | + | |
588 | + g_settings_bind( | |
589 | + settings, | |
581 | 590 | "toolbar-action-names", |
582 | 591 | window->toolbar, |
583 | 592 | "action-names", | ... | ... |