Commit c10ef04b9a7524946eb3d9f9f0b75124fc88e61f

Authored by Perry Werneck
1 parent 8338dec5

Auto updating toolbar when icon style changes.

Showing 1 changed file with 31 additions and 0 deletions   Show diff stats
src/objects/toolbar/toolbar.c
... ... @@ -296,8 +296,39 @@
296 296 }
297 297  
298 298 void pw3270_toolbar_set_icon_type(GtkToolbar *toolbar, gint icon_type) {
  299 +
  300 + if(PW3270_TOOLBAR(toolbar)->icon_type == icon_type)
  301 + return;
  302 +
299 303 PW3270_TOOLBAR(toolbar)->icon_type = icon_type;
  304 +
  305 + // Redefine icon types
  306 + GList * children = gtk_container_get_children(GTK_CONTAINER(toolbar));
  307 + GList * item;
  308 +
  309 + for(item = children;item;item = g_list_next(item)) {
  310 +
  311 + if(GTK_IS_TOOL_BUTTON(item->data)) {
  312 +
  313 + g_autofree gchar * icon_name = g_strdup(gtk_tool_button_get_icon_name(GTK_TOOL_BUTTON(item->data)));
  314 + if(g_str_has_suffix(icon_name,"-symbolic")) {
  315 + icon_name[strlen(icon_name)-9] = 0;
  316 + }
  317 +
  318 + if(icon_type) {
  319 + g_autofree gchar * new_name = g_strconcat(icon_name,"-symbolic",NULL);
  320 + gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON(item->data),new_name);
  321 + } else {
  322 + gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON(item->data),icon_name);
  323 + }
  324 +
  325 + }
  326 +
  327 + }
  328 +
  329 + g_list_free(children);
300 330 g_object_notify(G_OBJECT(toolbar), "icon-type");
  331 +
301 332 }
302 333  
303 334 void pw3270_toolbar_set_icon_size(GtkToolbar *toolbar, GtkIconSize icon_size) {
... ...