diff options
author | Guy Harris <guy@alum.mit.edu> | 2011-11-13 22:51:49 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2011-11-13 22:51:49 +0000 |
commit | a6ccc83e221ff4c5560ed031938a3f41df60d5ac (patch) | |
tree | 7985752d5becb17885c4ebb2b889645e9ab96b8d | |
parent | c32a5e7d8beaa40559ee004ad3cc6da445305549 (diff) |
If we set "column.hidden" on the command line but don't set
"column.format" in a later argument, make sure we mark the appropriate
existing columns as hidden.
As part of cleaning up the infrastructure for doing this, store the COL_
code for a column in a fmt_data structure rather than a pointer to the
raw column format string; this simplifies some code.
Have a routine to return whether a column is visible, not hidden, as
it's used to set a "visible" flag.
svn path=/trunk/; revision=39822
-rw-r--r-- | epan/column.c | 5 | ||||
-rw-r--r-- | epan/column.h | 12 | ||||
-rw-r--r-- | epan/prefs.c | 231 | ||||
-rw-r--r-- | gtk/main_menubar.c | 11 | ||||
-rw-r--r-- | gtk/prefs_column.c | 44 |
5 files changed, 190 insertions, 113 deletions
diff --git a/epan/column.c b/epan/column.c index a3d3513a42..6af5c78636 100644 --- a/epan/column.c +++ b/epan/column.c @@ -638,7 +638,7 @@ get_column_format(const gint col) cfmt = (fmt_data *) clp->data; - return(get_column_format_from_str(cfmt->fmt)); + return(cfmt->fmt); } void @@ -652,8 +652,7 @@ set_column_format(const gint col, const gint fmt) cfmt = (fmt_data *) clp->data; - g_free (cfmt->fmt); - cfmt->fmt = g_strdup(col_format_to_string(fmt)); + cfmt->fmt = fmt; } gint diff --git a/epan/column.h b/epan/column.h index 8dd1607407..5315e7dd42 100644 --- a/epan/column.h +++ b/epan/column.h @@ -30,12 +30,12 @@ extern "C" { #endif /* __cplusplus */ typedef struct _fmt_data { - gchar *title; - gchar *fmt; - gchar *custom_field; - gint custom_occurrence; - gboolean visible; - gboolean resolved; + gchar *title; /* title of the column */ + int fmt; /* format of column */ + gchar *custom_field; /* field name for COL_CUSTOM */ + gint custom_occurrence; /* optional ordinal of occurrence of that field */ + gboolean visible; /* if FALSE, hide this column */ + gboolean resolved; /* if TRUE, show a more human-readable name */ } fmt_data; const gchar *col_format_to_string(const gint); diff --git a/epan/prefs.c b/epan/prefs.c index b70cc29787..065083dfbb 100644 --- a/epan/prefs.c +++ b/epan/prefs.c @@ -1147,6 +1147,63 @@ print.file: /a/very/long/path/ #define DEF_NUM_COLS 7 +/* + * Parse a column format, filling in the relevant fields of a fmt_data. + */ +static gboolean +parse_column_format(fmt_data *cfmt, const char *fmt) +{ + const gchar *cust_format = col_format_to_string(COL_CUSTOM); + size_t cust_format_len = strlen(cust_format); + gchar **cust_format_info; + char *p; + int col_fmt; + gchar *col_custom_field; + long col_custom_occurrence; + gboolean col_resolved; + + /* + * Is this a custom column? + */ + if ((strlen(fmt) > cust_format_len) && (fmt[cust_format_len] == ':') && + strncmp(fmt, cust_format, cust_format_len) == 0) { + /* Yes. */ + col_fmt = COL_CUSTOM; + cust_format_info = g_strsplit(&fmt[cust_format_len+1],":",3); /* add 1 for ':' */ + col_custom_field = g_strdup(cust_format_info[0]); + if (col_custom_field && cust_format_info[1]) { + col_custom_occurrence = strtol(cust_format_info[1], &p, 10); + if (p == cust_format_info[1] || *p != '\0') { + /* Not a valid number. */ + g_free(col_custom_field); + g_strfreev(cust_format_info); + return FALSE; + } + } else { + col_custom_occurrence = 0; + } + if (col_custom_field && cust_format_info[1] && cust_format_info[2]) { + col_resolved = (cust_format_info[2][0] == 'U') ? FALSE : TRUE; + } else { + col_resolved = TRUE; + } + g_strfreev(cust_format_info); + } else { + col_fmt = get_column_format_from_str(fmt); + if (col_fmt == -1) + return FALSE; + col_custom_field = NULL; + col_custom_occurrence = 0; + col_resolved = TRUE; + } + + cfmt->fmt = col_fmt; + cfmt->custom_field = col_custom_field; + cfmt->custom_occurrence = (int)col_custom_occurrence; + cfmt->resolved = col_resolved; + return TRUE; +} + /* Initialize non-dissector preferences to wired-in default values. * (The dissector preferences are assumed to be set to those values * by the dissectors.) @@ -1157,7 +1214,8 @@ static void init_prefs(void) { int i; fmt_data *cfmt; - const gchar *col_fmt[] = {"No.", "%m", "Time", "%t", + static const gchar *col_fmt[DEF_NUM_COLS*2] = { + "No.", "%m", "Time", "%t", "Source", "%s", "Destination", "%d", "Protocol", "%p", "Length", "%L", "Info", "%i"}; @@ -1175,7 +1233,7 @@ init_prefs(void) { for (i = 0; i < DEF_NUM_COLS; i++) { cfmt = (fmt_data *) g_malloc(sizeof(fmt_data)); cfmt->title = g_strdup(col_fmt[i * 2]); - cfmt->fmt = g_strdup(col_fmt[(i * 2) + 1]); + parse_column_format(cfmt, col_fmt[(i * 2) + 1]); cfmt->visible = TRUE; cfmt->resolved = TRUE; cfmt->custom_field = NULL; @@ -1844,28 +1902,79 @@ prefs_is_capture_device_hidden(const char *name) } /* - * Returns TRUE if the given column is hidden + * Returns TRUE if the given column is visible (not hidden) */ static gboolean -prefs_is_column_hidden(const gchar *cols_hidden, const char *fmt) +prefs_is_column_visible(const gchar *cols_hidden, fmt_data *cfmt) { gchar *tok, *cols; - size_t len; + fmt_data cfmt_hidden; - if (cols_hidden && fmt) { - cols = g_strdup (cols_hidden); - len = strlen (fmt); - for (tok = strtok (cols, ","); tok; tok = strtok(NULL, ",")) { - tok = g_strstrip (tok); - if (strlen (tok) == len && strcmp (fmt, tok) == 0) { - g_free (cols); - return TRUE; + /* + * Do we have a list of hidden columns? + */ + if (cols_hidden) { + /* + * Yes - check the column against each of the ones in the + * list. + */ + cols = g_strdup(cols_hidden); + for (tok = strtok(cols, ","); tok; tok = strtok(NULL, ",")) { + tok = g_strstrip(tok); + + /* + * Parse this column format. + */ + if (!parse_column_format(&cfmt_hidden, tok)) { + /* + * It's not valid; ignore it. + */ + continue; + } + + /* + * Does it match the column? + */ + if (cfmt->fmt != cfmt_hidden.fmt) { + /* No. */ + g_free(cfmt_hidden.custom_field); + continue; + } + if (cfmt->fmt == COL_CUSTOM) { + /* + * A custom column has to have the + * same custom field and occurrence. + */ + if (strcmp(cfmt->custom_field, + cfmt_hidden.custom_field) != 0) { + /* Different fields. */ + g_free(cfmt_hidden.custom_field); + continue; + } + if (cfmt->custom_occurrence != + cfmt_hidden.custom_occurrence) { + /* Different occurrences. */ + g_free(cfmt_hidden.custom_field); + continue; + } } + + /* + * OK, they match, so it's one of the hidden fields, + * hence not visible. + */ + g_free(cfmt_hidden.custom_field); + g_free(cols); + return FALSE; } - g_free (cols); + g_free(cols); } - return FALSE; + /* + * No - either there are no hidden columns or this isn't one + * of them - so it is visible. + */ + return TRUE; } /* @@ -2104,7 +2213,7 @@ static prefs_set_pref_e set_pref(gchar *pref_name, gchar *value, void *private_data _U_, gboolean return_range_errors) { - GList *col_l, *col_l_elt; + GList *clp, *col_l, *col_l_elt; gint llen; fmt_data *cfmt; unsigned long int cval; @@ -2119,9 +2228,6 @@ set_pref(gchar *pref_name, gchar *value, void *private_data _U_, module_t *module; pref_t *pref; gboolean had_a_dot; - gchar **cust_format_info; - const gchar *cust_format = col_format_to_string(COL_CUSTOM); - size_t cust_format_len = strlen(cust_format); if (strcmp(pref_name, PRS_PRINT_FMT) == 0) { if (strcmp(value, pr_formats[PR_FMT_TEXT]) == 0) { @@ -2146,7 +2252,18 @@ set_pref(gchar *pref_name, gchar *value, void *private_data _U_, g_free(prefs.pr_cmd); prefs.pr_cmd = g_strdup(value); } else if (strcmp(pref_name, PRS_COL_HIDDEN) == 0) { - cols_hidden_list = g_strdup (value); + g_free(cols_hidden_list); + cols_hidden_list = g_strdup(value); + /* + * Set the "visible" flag for the existing columns; we need to + * do this if we set PRS_COL_HIDDEN but don't set PRS_COL_FMT + * after setting it (which might be the case if, for example, we + * set PRS_COL_HIDDEN on the command line). + */ + for (clp = prefs.col_list; clp != NULL; clp = clp->next) { + cfmt = (fmt_data *)clp->data; + cfmt->visible = prefs_is_column_visible(cols_hidden_list, cfmt); + } } else if (strcmp(pref_name, PRS_GUI_FILTER_LABEL) == 0) { filter_label = g_strdup(value); } else if (strcmp(pref_name, PRS_GUI_FILTER_ENABLED) == 0) { @@ -2168,66 +2285,42 @@ set_pref(gchar *pref_name, gchar *value, void *private_data _U_, /* Check to make sure all column formats are valid. */ col_l_elt = g_list_first(col_l); while(col_l_elt) { + fmt_data cfmt_check; + /* Go past the title. */ col_l_elt = col_l_elt->next; - /* Check the format. */ - if ((strlen(col_l_elt->data) <= cust_format_len) || - (((char*)col_l_elt->data)[cust_format_len] != ':') || - strncmp(col_l_elt->data, cust_format, cust_format_len) != 0) - { - if (get_column_format_from_str(col_l_elt->data) == -1) { - /* It's not a valid column format. */ - prefs_clear_string_list(col_l); - return PREFS_SET_SYNTAX_ERR; - } - + /* Parse the format to see if it's valid. */ + if (!parse_column_format(&cfmt_check, col_l_elt->data)) { + /* It's not a valid column format. */ + prefs_clear_string_list(col_l); + return PREFS_SET_SYNTAX_ERR; + } + if (cfmt_check.fmt != COL_CUSTOM) { /* Some predefined columns have been migrated to use custom colums. * We'll convert these silently here */ try_convert_to_custom_column(&col_l_elt->data); + } else { + /* We don't need the custom column field on this pass. */ + g_free(cfmt_check.custom_field); } /* Go past the format. */ col_l_elt = col_l_elt->next; } + + /* They're all valid; process them. */ free_col_info(&prefs); prefs.col_list = NULL; llen = g_list_length(col_l); prefs.num_cols = llen / 2; col_l_elt = g_list_first(col_l); while(col_l_elt) { - gchar *prefs_fmt; cfmt = (fmt_data *) g_malloc(sizeof(fmt_data)); cfmt->title = g_strdup(col_l_elt->data); col_l_elt = col_l_elt->next; - if ((strlen(col_l_elt->data) > cust_format_len) && - (((char*)col_l_elt->data)[cust_format_len] == ':') && - strncmp(col_l_elt->data, cust_format, cust_format_len) == 0) - { - cfmt->fmt = g_strdup(cust_format); - prefs_fmt = g_strdup(col_l_elt->data); - cust_format_info = g_strsplit(&prefs_fmt[cust_format_len+1],":",3); /* add 1 for ':' */ - cfmt->custom_field = g_strdup(cust_format_info[0]); - if (cfmt->custom_field && cust_format_info[1]) { - cfmt->custom_occurrence = (int)strtol(cust_format_info[1],NULL,10); - } else { - cfmt->custom_occurrence = 0; - } - if (cfmt->custom_field && cust_format_info[1] && cust_format_info[2]) { - cfmt->resolved = (cust_format_info[2][0] == 'U') ? FALSE : TRUE; - } else { - cfmt->resolved = TRUE; - } - g_strfreev(cust_format_info); - } else { - cfmt->fmt = g_strdup(col_l_elt->data); - prefs_fmt = g_strdup(cfmt->fmt); - cfmt->custom_field = NULL; - cfmt->custom_occurrence = 0; - cfmt->resolved = TRUE; - } - cfmt->visible = prefs_is_column_hidden (cols_hidden_list, prefs_fmt) ? FALSE : TRUE; - g_free (prefs_fmt); + parse_column_format(cfmt, col_l_elt->data); + cfmt->visible = prefs_is_column_visible(cols_hidden_list, cfmt); col_l_elt = col_l_elt->next; prefs.col_list = g_list_append(prefs.col_list, cfmt); } @@ -3094,7 +3187,6 @@ write_prefs(char **pf_path_return) FILE *pf; GList *clp, *col_l; fmt_data *cfmt; - const gchar *cust_format = col_format_to_string(COL_CUSTOM); GString *cols_hidden = g_string_new (""); /* Needed for "-G defaultprefs" */ @@ -3296,14 +3388,16 @@ write_prefs(char **pf_path_return) gchar *prefs_fmt; cfmt = (fmt_data *) clp->data; col_l = g_list_append(col_l, g_strdup(cfmt->title)); - if ((strcmp(cfmt->fmt, cust_format) == 0) && (cfmt->custom_field)) { - prefs_fmt = g_strdup_printf("%s:%s:%d:%c", cfmt->fmt, cfmt->custom_field, - cfmt->custom_occurrence, cfmt->resolved ? 'R' : 'U'); - col_l = g_list_append(col_l, prefs_fmt); + if ((cfmt->fmt == COL_CUSTOM) && (cfmt->custom_field)) { + prefs_fmt = g_strdup_printf("%s:%s:%d:%c", + col_format_to_string(cfmt->fmt), + cfmt->custom_field, + cfmt->custom_occurrence, + cfmt->resolved ? 'R' : 'U'); } else { - prefs_fmt = cfmt->fmt; - col_l = g_list_append(col_l, g_strdup(cfmt->fmt)); + prefs_fmt = g_strdup(col_format_to_string(cfmt->fmt)); } + col_l = g_list_append(col_l, prefs_fmt); if (!cfmt->visible) { if (cols_hidden->len) { g_string_append (cols_hidden, ","); @@ -3555,7 +3649,7 @@ copy_prefs(e_prefs *dest, e_prefs *src) src_cfmt = entry->data; dest_cfmt = (fmt_data *) g_malloc(sizeof(fmt_data)); dest_cfmt->title = g_strdup(src_cfmt->title); - dest_cfmt->fmt = g_strdup(src_cfmt->fmt); + dest_cfmt->fmt = src_cfmt->fmt; if (src_cfmt->custom_field) { dest_cfmt->custom_field = g_strdup(src_cfmt->custom_field); dest_cfmt->custom_occurrence = src_cfmt->custom_occurrence; @@ -3686,7 +3780,6 @@ free_col_info(e_prefs *pr) cfmt = pr->col_list->data; g_free(cfmt->title); - g_free(cfmt->fmt); g_free(cfmt->custom_field); g_free(cfmt); pr->col_list = g_list_remove_link(pr->col_list, pr->col_list); diff --git a/gtk/main_menubar.c b/gtk/main_menubar.c index 89e0584684..55224ea36b 100644 --- a/gtk/main_menubar.c +++ b/gtk/main_menubar.c @@ -5234,7 +5234,7 @@ rebuild_visible_columns_menu (void) GList *clp; fmt_data *cfmt; gchar *title; - gint i, col_id, cur_fmt; + gint i, col_id; menu_columns[0] = gtk_ui_manager_get_widget(ui_manager_main_menubar, "/Menubar/ViewMenu/DisplayedColumns"); if(! menu_columns[0]){ fprintf (stderr, "Warning: couldn't find menu_columns[0] path=/Menubar/ViewMenu/DisplayedColumns"); @@ -5253,18 +5253,17 @@ rebuild_visible_columns_menu (void) col_id = 0; while (clp) { cfmt = (fmt_data *) clp->data; - cur_fmt = get_column_format_from_str(cfmt->fmt); if (cfmt->title[0]) { - if (cur_fmt == COL_CUSTOM) { + if (cfmt->fmt == COL_CUSTOM) { title = g_strdup_printf ("%s (%s)", cfmt->title, cfmt->custom_field); } else { - title = g_strdup_printf ("%s (%s)", cfmt->title, col_format_desc (cur_fmt)); + title = g_strdup_printf ("%s (%s)", cfmt->title, col_format_desc (cfmt->fmt)); } } else { - if (cur_fmt == COL_CUSTOM) { + if (cfmt->fmt == COL_CUSTOM) { title = g_strdup_printf ("(%s)", cfmt->custom_field); } else { - title = g_strdup_printf ("(%s)", col_format_desc (cur_fmt)); + title = g_strdup_printf ("(%s)", col_format_desc (cfmt->fmt)); } } menu_item = gtk_check_menu_item_new_with_label(title); diff --git a/gtk/prefs_column.c b/gtk/prefs_column.c index cce743b630..3814229bee 100644 --- a/gtk/prefs_column.c +++ b/gtk/prefs_column.c @@ -109,7 +109,6 @@ column_prefs_show(GtkWidget *prefs_window) { fmt_data *cfmt; gint i; gchar *fmt; - gint cur_fmt; const gchar *column_titles[] = {"Displayed", "Title", "Field type"}; GtkListStore *store; GtkCellRenderer *renderer; @@ -179,12 +178,11 @@ column_prefs_show(GtkWidget *prefs_window) { clp = g_list_first(prefs.col_list); while (clp) { cfmt = (fmt_data *) clp->data; - cur_fmt = get_column_format_from_str(cfmt->fmt); - if (cur_fmt == COL_CUSTOM) { + if (cfmt->fmt == COL_CUSTOM) { if (cfmt->custom_occurrence) { - fmt = g_strdup_printf("%s (%s#%d)", col_format_desc(cur_fmt), cfmt->custom_field, cfmt->custom_occurrence); + fmt = g_strdup_printf("%s (%s#%d)", col_format_desc(cfmt->fmt), cfmt->custom_field, cfmt->custom_occurrence); } else { - fmt = g_strdup_printf("%s (%s)", col_format_desc(cur_fmt), cfmt->custom_field); + fmt = g_strdup_printf("%s (%s)", col_format_desc(cfmt->fmt), cfmt->custom_field); } } else { if (cfmt->custom_field) { @@ -193,7 +191,7 @@ column_prefs_show(GtkWidget *prefs_window) { cfmt->custom_field = NULL; cfmt->custom_occurrence = 0; } - fmt = g_strdup_printf("%s", col_format_desc(cur_fmt)); + fmt = g_strdup_printf("%s", col_format_desc(cfmt->fmt)); } gtk_list_store_insert_with_values(store, &iter, G_MAXINT, VISIBLE_COLUMN, cfmt->visible, @@ -342,7 +340,7 @@ column_prefs_add_custom(gint fmt, const gchar *title, const gchar *custom_field, * shown underlined), escape it be inserting a second consecutive underscore. */ cfmt->title = g_strdup(title); - cfmt->fmt = g_strdup(col_format_to_string(fmt)); + cfmt->fmt = fmt; cfmt->custom_field = g_strdup(custom_field); cfmt->custom_occurrence = custom_occurrence; cfmt->resolved = TRUE; @@ -351,7 +349,7 @@ column_prefs_add_custom(gint fmt, const gchar *title, const gchar *custom_field, cfmt->visible = TRUE; clp = g_list_last(prefs.col_list); last_cfmt = (fmt_data *) clp->data; - if (strcmp(last_cfmt->fmt, "%i") == 0) { + if (last_cfmt->fmt == COL_INFO) { /* Last column is COL_INFO, add custom column before this */ prefs.col_list = g_list_insert(prefs.col_list, cfmt, g_list_length(prefs.col_list)-1); } else { @@ -370,7 +368,6 @@ column_prefs_remove(gint col) fmt_data *cfmt = (fmt_data *) clp->data; g_free(cfmt->title); - g_free(cfmt->fmt); g_free(cfmt->custom_field); g_free(cfmt); prefs.col_list = g_list_remove_link(prefs.col_list, clp); @@ -434,7 +431,6 @@ column_list_delete_cb(GtkWidget *w _U_, gpointer data) { cfmt = (fmt_data *) clp->data; g_free(cfmt->title); - g_free(cfmt->fmt); g_free(cfmt->custom_field); g_free(cfmt); prefs.col_list = g_list_remove_link(prefs.col_list, clp); @@ -515,7 +511,6 @@ static void column_list_select_cb(GtkTreeSelection *sel, gpointer data _U_) { fmt_data *cfmt; - gint cur_fmt; GList *clp; GtkTreeModel *model; GtkTreeIter iter; @@ -526,16 +521,14 @@ column_list_select_cb(GtkTreeSelection *sel, gpointer data _U_) gtk_tree_model_get(model, &iter, DATA_COLUMN, &clp, -1); g_assert(clp != NULL); cfmt = (fmt_data *) clp->data; - cur_fmt = get_column_format_from_str(cfmt->fmt); - g_assert(cur_fmt != -1); /* It should always be valid */ g_signal_handler_block (fmt_cmb, column_menu_changed_handler_id); - gtk_combo_box_set_active(GTK_COMBO_BOX(fmt_cmb), cur_fmt); + gtk_combo_box_set_active(GTK_COMBO_BOX(fmt_cmb), cfmt->fmt); g_signal_handler_unblock(fmt_cmb, column_menu_changed_handler_id); g_signal_handler_block (field_te, column_field_changed_handler_id); g_signal_handler_block (occurrence_te, column_occurrence_changed_handler_id); - if (cur_fmt == COL_CUSTOM) { + if (cfmt->fmt == COL_CUSTOM) { gtk_entry_set_text(GTK_ENTRY(field_te), cfmt->custom_field); gtk_widget_set_sensitive(field_lb, TRUE); gtk_widget_set_sensitive(field_te, TRUE); @@ -590,7 +583,6 @@ static void column_menu_changed_cb(GtkWidget *w, gpointer data) { GtkTreeView *column_l = GTK_TREE_VIEW(data); fmt_data *cfmt; - gint cur_fmt; gint cur_cb_fmt; GList *clp; gchar *fmt; @@ -605,9 +597,8 @@ column_menu_changed_cb(GtkWidget *w, gpointer data) { cur_cb_fmt = gtk_combo_box_get_active(GTK_COMBO_BOX(w)); gtk_tree_model_get(model, &iter, DATA_COLUMN, &clp, -1); cfmt = (fmt_data *) clp->data; - cur_fmt = get_column_format_from_str(cfmt->fmt); - g_assert(cur_cb_fmt != cur_fmt); + g_assert(cur_cb_fmt != cfmt->fmt); /* The User has selected a new format in the combo-box */ /* (IE: combo-box format != current selected row format) */ @@ -615,7 +606,7 @@ column_menu_changed_cb(GtkWidget *w, gpointer data) { /* entry as appropriate. */ g_signal_handler_block (field_te, column_field_changed_handler_id); g_signal_handler_block (occurrence_te, column_occurrence_changed_handler_id); - if (cur_fmt == COL_CUSTOM) { + if (cfmt->fmt == COL_CUSTOM) { /* Changing from custom to non-custom */ gtk_editable_delete_text(GTK_EDITABLE(field_te), 0, -1); gtk_editable_delete_text(GTK_EDITABLE(occurrence_te), 0, -1); @@ -653,8 +644,7 @@ column_menu_changed_cb(GtkWidget *w, gpointer data) { gtk_list_store_set(GTK_LIST_STORE(model), &iter, FORMAT_COLUMN, fmt, -1); g_free(fmt); - g_free(cfmt->fmt); - cfmt->fmt = g_strdup(col_format_to_string(cur_cb_fmt)); + cfmt->fmt = cur_cb_fmt; cfile.cinfo.columns_changed = TRUE; } @@ -671,7 +661,6 @@ column_menu_changed_cb(GtkWidget *w, gpointer data) { static void column_field_changed_cb(GtkEditable *te, gpointer data) { fmt_data *cfmt; - gint cur_fmt; GList *clp; gchar *field, *fmt; GtkTreeView *tree = (GtkTreeView *)data; @@ -692,11 +681,10 @@ column_field_changed_cb(GtkEditable *te, gpointer data) { } /* The user has entered a new value in the field entry box: make the req'd changes */ - cur_fmt = get_column_format_from_str(cfmt->fmt); if (cfmt->custom_occurrence) { - fmt = g_strdup_printf("%s (%s#%d)", col_format_desc(cur_fmt), field, cfmt->custom_occurrence); + fmt = g_strdup_printf("%s (%s#%d)", col_format_desc(cfmt->fmt), field, cfmt->custom_occurrence); } else { - fmt = g_strdup_printf("%s (%s)", col_format_desc(cur_fmt), field); + fmt = g_strdup_printf("%s (%s)", col_format_desc(cfmt->fmt), field); } gtk_list_store_set(GTK_LIST_STORE(model), &iter, FORMAT_COLUMN, fmt, -1); @@ -719,7 +707,6 @@ column_field_changed_cb(GtkEditable *te, gpointer data) { static void column_occurrence_changed_cb(GtkEditable *te, gpointer data) { fmt_data *cfmt; - gint cur_fmt; gint occurrence; GList *clp; gchar *fmt; @@ -741,11 +728,10 @@ column_occurrence_changed_cb(GtkEditable *te, gpointer data) { } /* The user has entered a new value in the field occurrence entry box: make the req'd changes */ - cur_fmt = get_column_format_from_str(cfmt->fmt); if (occurrence) { - fmt = g_strdup_printf("%s (%s#%d)", col_format_desc(cur_fmt), cfmt->custom_field, occurrence); + fmt = g_strdup_printf("%s (%s#%d)", col_format_desc(cfmt->fmt), cfmt->custom_field, occurrence); } else { - fmt = g_strdup_printf("%s (%s)", col_format_desc(cur_fmt), cfmt->custom_field); + fmt = g_strdup_printf("%s (%s)", col_format_desc(cfmt->fmt), cfmt->custom_field); } gtk_list_store_set(GTK_LIST_STORE(model), &iter, FORMAT_COLUMN, fmt, -1); |