Cleanup the escape/unescape underscore in Packet List column headers.
We only have to do this when actually set or get the title from the widget. svn path=/trunk/; revision=31689
This commit is contained in:
parent
67ea4d6126
commit
ff9123acbe
|
@ -1051,8 +1051,8 @@ init_prefs(void) {
|
|||
int i;
|
||||
fmt_data *cfmt;
|
||||
const gchar *col_fmt[] = {"No.", "%m", "Time", "%t",
|
||||
"Source", "%s", "Destination", "%d",
|
||||
"Protocol", "%p", "Info", "%i"};
|
||||
"Source", "%s", "Destination", "%d",
|
||||
"Protocol", "%p", "Info", "%i"};
|
||||
|
||||
if (prefs_initialized)
|
||||
return;
|
||||
|
@ -1889,7 +1889,7 @@ set_pref(gchar *pref_name, gchar *value, void *private_data _U_)
|
|||
col_l_elt = g_list_first(col_l);
|
||||
while(col_l_elt) {
|
||||
cfmt = (fmt_data *) g_malloc(sizeof(fmt_data));
|
||||
cfmt->title = ws_strdup_escape_underscore(col_l_elt->data);
|
||||
cfmt->title = g_strdup(col_l_elt->data);
|
||||
col_l_elt = col_l_elt->next;
|
||||
if (strncmp(col_l_elt->data, cust_format, cust_format_len) == 0) {
|
||||
gchar *fmt = g_strdup(col_l_elt->data);
|
||||
|
@ -2886,7 +2886,7 @@ write_prefs(char **pf_path_return)
|
|||
col_l = NULL;
|
||||
while (clp) {
|
||||
cfmt = (fmt_data *) clp->data;
|
||||
col_l = g_list_append(col_l, ws_strdup_unescape_underscore(cfmt->title));
|
||||
col_l = g_list_append(col_l, g_strdup(cfmt->title));
|
||||
if ((strcmp(cfmt->fmt, cust_format) == 0) && (cfmt->custom_field)) {
|
||||
gchar *fmt = g_strdup_printf("%s:%s", cfmt->fmt, cfmt->custom_field);
|
||||
col_l = g_list_append(col_l, fmt);
|
||||
|
|
|
@ -220,11 +220,9 @@ col_title_change_ok (GtkWidget *w, gpointer parent_w)
|
|||
gint col_id = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(packet_list), E_MPACKET_LIST_COL_KEY));
|
||||
GtkWidget *entry = g_object_get_data (G_OBJECT(w), "entry");
|
||||
const gchar *title = gtk_entry_get_text(GTK_ENTRY(entry));
|
||||
gchar *escaped_title = ws_strdup_escape_underscore(title);
|
||||
|
||||
gtk_label_set_text (GTK_LABEL(column_lb), title);
|
||||
column_prefs_rename(col_id, escaped_title);
|
||||
g_free(escaped_title);
|
||||
column_prefs_rename(col_id, title);
|
||||
|
||||
if (!prefs.gui_use_pref_save) {
|
||||
prefs_main_write();
|
||||
|
@ -823,7 +821,6 @@ packet_list_set_column_titles(void)
|
|||
header_field_info *hfi;
|
||||
GtkTooltips *tooltips = gtk_tooltips_new ();
|
||||
int i;
|
||||
gchar *unescaped_title;
|
||||
|
||||
win_style = gtk_widget_get_style(top_level);
|
||||
ascend_pm = gdk_pixmap_create_from_xpm_d(top_level->window, &ascend_bm,
|
||||
|
@ -839,9 +836,7 @@ packet_list_set_column_titles(void)
|
|||
col_arrows[i].table = gtk_table_new(2, 2, FALSE);
|
||||
gtk_table_set_col_spacings(GTK_TABLE(col_arrows[i].table), 5);
|
||||
|
||||
unescaped_title = ws_strdup_unescape_underscore(cfile.cinfo.col_title[i]);
|
||||
col_arrows[i].label = gtk_label_new(unescaped_title);
|
||||
g_free(unescaped_title);
|
||||
col_arrows[i].label = gtk_label_new(cfile.cinfo.col_title[i]);
|
||||
gtk_table_attach(GTK_TABLE(col_arrows[i].table), col_arrows[i].label, 0, 1, 0, 2,
|
||||
GTK_SHRINK, GTK_SHRINK, 0, 0);
|
||||
if (cfile.cinfo.col_fmt[i] == COL_CUSTOM) {
|
||||
|
|
|
@ -178,15 +178,15 @@ col_title_change_ok (GtkWidget *w, gpointer parent_w)
|
|||
GtkTreeViewColumn *col = g_object_get_data (G_OBJECT(w), "column");
|
||||
gint col_id = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(col), E_MPACKET_LIST_COL_KEY));
|
||||
GtkWidget *entry = g_object_get_data (G_OBJECT(w), "entry");
|
||||
const gchar *title = gtk_entry_get_text(GTK_ENTRY(entry));
|
||||
gchar *escaped_title = ws_strdup_escape_underscore(title);
|
||||
const gchar *title = gtk_entry_get_text(GTK_ENTRY(entry));
|
||||
gchar *escaped_title = ws_strdup_escape_underscore(title);
|
||||
gint col_width;
|
||||
|
||||
gtk_tree_view_column_set_title(col, escaped_title);
|
||||
column_prefs_rename(col_id, escaped_title);
|
||||
|
||||
col_width = get_default_col_size (packetlist->view, escaped_title);
|
||||
g_free(escaped_title);
|
||||
column_prefs_rename(col_id, title);
|
||||
|
||||
col_width = get_default_col_size (packetlist->view, title);
|
||||
gtk_tree_view_column_set_min_width(col, col_width);
|
||||
new_packet_list_resize_column (col_id);
|
||||
|
||||
|
@ -206,8 +206,8 @@ col_title_change_cancel (GtkWidget *w _U_, gpointer parent_w)
|
|||
static void
|
||||
col_title_edit_dlg (GtkTreeViewColumn *col)
|
||||
{
|
||||
const gchar *value = gtk_tree_view_column_get_title(col);
|
||||
gchar *unescaped_value = ws_strdup_unescape_underscore(value);
|
||||
const gchar *title = gtk_tree_view_column_get_title(col);
|
||||
gchar *unescaped_title = ws_strdup_unescape_underscore(title);
|
||||
|
||||
GtkWidget *win, *main_tb, *main_vb, *bbox, *cancel_bt, *ok_bt;
|
||||
GtkWidget *entry, *label;
|
||||
|
@ -231,8 +231,8 @@ col_title_edit_dlg (GtkTreeViewColumn *col)
|
|||
|
||||
entry = gtk_entry_new();
|
||||
gtk_table_attach_defaults(GTK_TABLE(main_tb), entry, 1, 2, 1, 2);
|
||||
gtk_entry_set_text(GTK_ENTRY(entry), unescaped_value);
|
||||
g_free(unescaped_value);
|
||||
gtk_entry_set_text(GTK_ENTRY(entry), unescaped_title);
|
||||
g_free(unescaped_title);
|
||||
|
||||
bbox = dlg_button_row_new(GTK_STOCK_CANCEL,GTK_STOCK_OK, NULL);
|
||||
gtk_box_pack_end(GTK_BOX(main_vb), bbox, FALSE, FALSE, 0);
|
||||
|
@ -426,6 +426,7 @@ create_view_and_model(void)
|
|||
gchar *tooltip_text;
|
||||
header_field_info *hfi;
|
||||
gint col_min_width;
|
||||
gchar *escaped_title;
|
||||
GtkTooltips *tooltips = gtk_tooltips_new ();
|
||||
|
||||
packetlist = new_packet_list_new();
|
||||
|
@ -483,7 +484,9 @@ create_view_and_model(void)
|
|||
} else {
|
||||
tooltip_text = g_strdup(col_format_desc(cfile.cinfo.col_fmt[i]));
|
||||
}
|
||||
gtk_tree_view_column_set_title(col, cfile.cinfo.col_title[i]);
|
||||
escaped_title = ws_strdup_escape_underscore(cfile.cinfo.col_title[i]);
|
||||
gtk_tree_view_column_set_title(col, escaped_title);
|
||||
g_free (escaped_title);
|
||||
gtk_tree_view_column_set_clickable(col, TRUE);
|
||||
gtk_tree_view_column_set_resizable(col, TRUE);
|
||||
gtk_tree_view_column_set_sizing(col,GTK_TREE_VIEW_COLUMN_FIXED);
|
||||
|
|
|
@ -75,7 +75,7 @@ column_prefs_show(GtkWidget *prefs_window) {
|
|||
GList *clp;
|
||||
fmt_data *cfmt;
|
||||
gint i;
|
||||
gchar *fmt, *unescaped_title;
|
||||
gchar *fmt;
|
||||
gint cur_fmt;
|
||||
const gchar *column_titles[] = {"Title", "Field type"};
|
||||
GtkListStore *store;
|
||||
|
@ -153,9 +153,7 @@ column_prefs_show(GtkWidget *prefs_window) {
|
|||
fmt = g_strdup_printf("%s", col_format_desc(cur_fmt));
|
||||
}
|
||||
gtk_list_store_append(store, &iter);
|
||||
unescaped_title = ws_strdup_unescape_underscore(cfmt->title);
|
||||
gtk_list_store_set(store, &iter, 0, unescaped_title, 1, fmt, 2, clp, -1);
|
||||
g_free(unescaped_title);
|
||||
gtk_list_store_set(store, &iter, 0, cfmt->title, 1, fmt, 2, clp, -1);
|
||||
if (first_row) {
|
||||
first_iter = iter;
|
||||
first_row = FALSE;
|
||||
|
@ -277,7 +275,7 @@ column_prefs_add_custom(gint fmt, const gchar *title, const gchar *custom_field)
|
|||
* is going to be marked as accelerator for this header (i.e. is going to be
|
||||
* shown underlined), escape it be inserting a second consecutive underscore.
|
||||
*/
|
||||
cfmt->title = ws_strdup_escape_underscore(title);
|
||||
cfmt->title = g_strdup(title);
|
||||
cfmt->fmt = g_strdup(col_format_to_string(fmt));
|
||||
cfmt->custom_field = g_strdup(custom_field);
|
||||
|
||||
|
@ -440,7 +438,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 = ws_strdup_escape_underscore(new_title);
|
||||
cfmt->title = g_strdup(new_title);
|
||||
}
|
||||
|
||||
gtk_tree_path_free (path);
|
||||
|
|
Loading…
Reference in New Issue