const gchar * balsa_toolbar_sanitize_id(const gchar *id) { gint button = get_toolbar_button_index(id); if (button >= 0) return toolbar_buttons[button].pixmap_id; else return NULL; }
/* Refresh the page's current GtkTreeView. */ static void tp_page_refresh_current(ToolbarPage * page) { GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(page->current)); GtkTreeModel *model; GtkTreeIter iter; GtkTreePath *path; int item; GArray *current; guint j; /* save currently selected path, or point path to the first row */ if (gtk_tree_selection_get_selected(selection, &model, &iter)) path = gtk_tree_model_get_path(model, &iter); else { path = gtk_tree_path_new(); gtk_tree_path_down(path); } gtk_list_store_clear(GTK_LIST_STORE(model)); current = balsa_toolbar_model_get_current(page->model); for (j = 0; j < current->len; j++) { BalsaToolbarEntry *entry; entry = &g_array_index(current, BalsaToolbarEntry, j); item = get_toolbar_button_index(entry->icon); if (item < 0) continue; gtk_list_store_append(GTK_LIST_STORE(model), &iter); tp_store_set(GTK_LIST_STORE(model), &iter, item); } if (gtk_tree_model_get_iter(model, &iter, path) || gtk_tree_path_prev(path)) { gtk_tree_selection_select_path(selection, path); gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(page->current), path, NULL, FALSE, 0, 0); } gtk_tree_path_free(path); }
static gboolean tm_has_second_line(BalsaToolbarModel * model) { GArray *current; guint j; /* Find out whether any button has 2 lines of text. */ current = balsa_toolbar_model_get_current(model); for (j = 0; j < current->len; j++) { const gchar *icon; gint button; icon = g_array_index(current, BalsaToolbarEntry, j).icon; button = get_toolbar_button_index(icon); if (button >= 0 && strchr(balsa_toolbar_button_text(button), '\n')) return TRUE; } return FALSE; }
static gint tm_set_tool_item_label(GtkToolItem * tool_item, const gchar * stock_id, gboolean make_two_line) { gint button = get_toolbar_button_index(stock_id); const gchar *text; gchar *label; if (button < 0) return button; text = balsa_toolbar_button_text(button); if (balsa_app.toolbar_wrap_button_text) { /* Make sure all buttons have the same number of lines of * text (1 or 2), to keep icons aligned */ label = make_two_line && !strchr(text, '\n') ? g_strconcat(text, "\n", NULL) : g_strdup(text); } else { gchar *p = label = g_strdup(text); while ((p = strchr(p, '\n'))) *p++ = ' '; } gtk_tool_button_set_label(GTK_TOOL_BUTTON(tool_item), label); g_free(label); gtk_tool_item_set_is_important(tool_item, toolbar_buttons[button].is_important); if (strcmp(toolbar_buttons[button].pixmap_id, BALSA_PIXMAP_SEND) == 0 && balsa_app.always_queue_sent_mail) gtk_tool_item_set_tooltip_text(tool_item, _("Queue this message for sending")); return button; }