diff options
author | Gerasimos Dimitriadis <dimeg@intracom.gr> | 2010-01-24 22:25:40 +0000 |
---|---|---|
committer | Gerasimos Dimitriadis <dimeg@intracom.gr> | 2010-01-24 22:25:40 +0000 |
commit | 11e340038fdf325794fc38efd323605af7a02ffa (patch) | |
tree | 8450ba6c2369cf5db736f361e7d95e7c137708c3 /gtk/prefs_column.c | |
parent | 9106b7351a934173fc26edca2b981aeb614b4499 (diff) | |
download | wireshark-11e340038fdf325794fc38efd323605af7a02ffa.tar.gz |
Handle underscore escaping/unescaping of the column titles
under the new packet list
svn path=/trunk/; revision=31649
Diffstat (limited to 'gtk/prefs_column.c')
-rw-r--r-- | gtk/prefs_column.c | 36 |
1 files changed, 5 insertions, 31 deletions
diff --git a/gtk/prefs_column.c b/gtk/prefs_column.c index 7dceb19396..aee8def7c1 100644 --- a/gtk/prefs_column.c +++ b/gtk/prefs_column.c @@ -74,7 +74,7 @@ column_prefs_show(GtkWidget *prefs_window) { GList *clp; fmt_data *cfmt; gint i; - gchar *fmt; + gchar *fmt, *unescaped_title; gint cur_fmt; const gchar *column_titles[] = {"Title", "Field type"}; GtkListStore *store; @@ -152,7 +152,9 @@ column_prefs_show(GtkWidget *prefs_window) { fmt = g_strdup_printf("%s", col_format_desc(cur_fmt)); } gtk_list_store_append(store, &iter); - gtk_list_store_set(store, &iter, 0, cfmt->title, 1, fmt, 2, clp, -1); + unescaped_title = g_strdup_unescape_underscore(cfmt->title); + gtk_list_store_set(store, &iter, 0, unescaped_title, 1, fmt, 2, clp, -1); + g_free(unescaped_title); if (first_row) { first_iter = iter; first_row = FALSE; @@ -262,34 +264,6 @@ column_prefs_show(GtkWidget *prefs_window) { return(main_vb); } -/* - * This function takes a string and copies it, inserting an underscore before - * every underscore in it. - */ -gchar* -g_strdup_escape_underscore (const gchar *str) -{ - gchar *p, *q, *new_str; - - if(!str) - return NULL; - - p = (gchar *)str; - /* Worst case: A string that is full of underscores */ - q = new_str = g_malloc (strlen(str) * 2 + 1); - - while(*p != 0) - { - if(*p == '_') - *q++ = '_'; - - *q++ = *p++; - } - *q++ = '\0'; - - return new_str; -} - void column_prefs_add_custom(gint fmt, const gchar *title, const gchar *custom_field) { @@ -465,7 +439,7 @@ column_title_changed_cb(GtkCellRendererText *cell _U_, const gchar *str_path, co if (clp) { cfmt = (fmt_data *) clp->data; g_free(cfmt->title); - cfmt->title = g_strdup(new_title); + cfmt->title = g_strdup_escape_underscore(new_title); } gtk_tree_path_free (path); |