static void on_toolbar_reconfigured(GtkToolItem *tool_item, ToolItem *item) { GtkToolShell *shell = GTK_TOOL_SHELL(gtk_widget_get_parent(item->widget)); gboolean large = gtk_tool_shell_get_icon_size(shell) > GTK_ICON_SIZE_MENU; gchar *tooltip = NULL; if (gtk_tool_shell_get_style(shell) == GTK_TOOLBAR_ICONS) { GtkMenuItem *menu_item = GTK_MENU_ITEM(debug_menu_items[item->index].widget); tooltip = g_strdup(gtk_menu_item_get_label(menu_item)); utils_str_remove_chars(tooltip, "_"); } gtk_tool_item_set_tooltip_text(tool_item, tooltip); g_free(tooltip); gtk_tool_button_set_icon_widget(GTK_TOOL_BUTTON(tool_item), get_widget(item->icon[large])); }
/* Create a GtkToolButton with stock icon, label and tooltip. * @param label can be NULL to use stock label text. @a label can contain underscores, * which will be removed. * @param tooltip can be NULL to use label text (useful for GTK_TOOLBAR_ICONS). */ static GtkWidget *ui_tool_button_new(const gchar *stock_id, const gchar *label, const gchar *tooltip) { GtkToolItem *item; gchar *dupl = NULL; if (stock_id && !label) { label = ui_lookup_stock_label(stock_id); } dupl = utils_str_remove_chars(g_strdup(label), "_"); label = dupl; item = gtk_tool_button_new(NULL, label); if (stock_id) gtk_tool_button_set_stock_id(GTK_TOOL_BUTTON(item), stock_id); if (!tooltip) tooltip = label; if (tooltip) gtk_widget_set_tooltip_text(GTK_WIDGET(item), tooltip); g_free(dupl); return GTK_WIDGET(item); }