void PacketList::writeRecent(FILE *rf) { gint col, width, col_fmt; gchar xalign; fprintf (rf, "%s:", RECENT_KEY_COL_WIDTH); for (col = 0; col < packet_list_model_->columnCount(); col++) { if (col > 0) { fprintf (rf, ","); } col_fmt = get_column_format(col); if (col_fmt == COL_CUSTOM) { fprintf (rf, " %%Cus:%s,", get_column_custom_field(col)); } else { fprintf (rf, " %s,", col_format_to_string(col_fmt)); } width = columnWidth(col); xalign = recent_get_column_xalign (col); if (width == 0) { /* We have not initialized the packet list yet, use old values */ width = recent_get_column_width (col); } fprintf (rf, " %d", width); if (xalign != COLUMN_XALIGN_DEFAULT) { fprintf (rf, ":%c", xalign); } } fprintf (rf, "\n"); }
gint get_column_format_from_str(const gchar *str) { gint i; for (i = 0; i < NUM_COL_FMTS; i++) { if (strcmp(str, col_format_to_string(i)) == 0) return i; } return -1; /* illegal */ }
void set_column_format(const gint col, const gint fmt) { GList *clp = g_list_nth(prefs.col_list, col); fmt_data *cfmt; if (!clp) /* Invalid column requested */ return; cfmt = (fmt_data *) clp->data; g_free (cfmt->fmt); cfmt->fmt = g_strdup(col_format_to_string(fmt)); }
static void column_list_new_cb(GtkWidget *w _U_, gpointer data) { fmt_data *cfmt; gint cur_fmt; const gchar *title = "New Column"; GtkTreeView *column_l = GTK_TREE_VIEW(data); GtkTreeModel *model; GtkTreeIter iter; GtkTreePath *path; GtkTreeViewColumn *title_column; cur_fmt = COL_NUMBER; cfmt = (fmt_data *) g_malloc(sizeof(fmt_data)); cfmt->title = g_strdup(title); cfmt->fmt = g_strdup(col_format_to_string(cur_fmt)); cfmt->custom_field = NULL; prefs.col_list = g_list_append(prefs.col_list, cfmt); model = gtk_tree_view_get_model(column_l); gtk_list_store_append(GTK_LIST_STORE(model), &iter); gtk_list_store_set(GTK_LIST_STORE(model), &iter, 0, title, 1, col_format_desc(cur_fmt), 2, g_list_last(prefs.col_list), -1); /* Triggers call to column_list_select_cb() */ gtk_tree_selection_select_iter(gtk_tree_view_get_selection(column_l), &iter); /* Set the cursor to the 'Title' column of the newly added row and enable editing */