aboutsummaryrefslogtreecommitdiffstats
path: root/ui/gtk
diff options
context:
space:
mode:
authorMichael Mann <mmann78@netscape.net>2015-06-26 23:00:33 -0400
committerMichael Mann <mmann78@netscape.net>2015-06-29 02:11:04 +0000
commitda09a1bfd86c2066ab492178bd2c0faa96bfd579 (patch)
treed0855286253963750b272e04ec2e57b56c9bfee1 /ui/gtk
parentb9145bc836daafd6cad960b95e9d2144781e7317 (diff)
Take all epan_column_info members that always get allocated to "number of columns" to share their own data structure.
Change-Id: Ib982662db6cf68730a7d121eac60d9bc5ae67429 Reviewed-on: https://code.wireshark.org/review/9195 Petri-Dish: Michael Mann <mmann78@netscape.net> Reviewed-by: Anders Broman <a.broman58@gmail.com> Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'ui/gtk')
-rw-r--r--ui/gtk/main.c14
-rw-r--r--ui/gtk/packet_list.c16
-rw-r--r--ui/gtk/packet_list_store.c28
-rw-r--r--ui/gtk/packet_win.c2
4 files changed, 32 insertions, 28 deletions
diff --git a/ui/gtk/main.c b/ui/gtk/main.c
index f62e937f23..4244b9a5a7 100644
--- a/ui/gtk/main.c
+++ b/ui/gtk/main.c
@@ -531,10 +531,10 @@ selected_ptree_ref_cb(GtkWidget *widget _U_, gpointer data _U_)
static gboolean
is_address_column (gint column)
{
- if (((cfile.cinfo.col_fmt[column] == COL_DEF_SRC) ||
- (cfile.cinfo.col_fmt[column] == COL_RES_SRC) ||
- (cfile.cinfo.col_fmt[column] == COL_DEF_DST) ||
- (cfile.cinfo.col_fmt[column] == COL_RES_DST)) &&
+ if (((cfile.cinfo.columns[column].col_fmt == COL_DEF_SRC) ||
+ (cfile.cinfo.columns[column].col_fmt == COL_RES_SRC) ||
+ (cfile.cinfo.columns[column].col_fmt == COL_DEF_DST) ||
+ (cfile.cinfo.columns[column].col_fmt == COL_RES_DST)) &&
strlen(cfile.cinfo.col_expr.col_expr_val[column]))
{
return TRUE;
@@ -609,7 +609,7 @@ get_filter_from_packet_list_row_and_column(gpointer data)
fdata, &cfile.cinfo);
epan_dissect_fill_in_columns(&edt, TRUE, TRUE);
- if ((cfile.cinfo.col_custom_occurrence[column]) ||
+ if ((cfile.cinfo.columns[column].col_custom_occurrence) ||
(strchr (cfile.cinfo.col_expr.col_expr_val[column], ',') == NULL))
{
/* Only construct the filter when a single occurrence is displayed
@@ -622,8 +622,8 @@ get_filter_from_packet_list_row_and_column(gpointer data)
if (strlen(cfile.cinfo.col_expr.col_expr[column]) != 0 &&
strlen(cfile.cinfo.col_expr.col_expr_val[column]) != 0) {
/* leak a little; is there a safe wmem_ scope here? */
- if (cfile.cinfo.col_fmt[column] == COL_CUSTOM) {
- header_field_info *hfi = proto_registrar_get_byname(cfile.cinfo.col_custom_field[column]);
+ if (cfile.cinfo.columns[column].col_fmt == COL_CUSTOM) {
+ header_field_info *hfi = proto_registrar_get_byname(cfile.cinfo.columns[column].col_custom_field);
if (hfi && hfi->parent == -1) {
/* Protocol only */
buf = g_strdup(cfile.cinfo.col_expr.col_expr[column]);
diff --git a/ui/gtk/packet_list.c b/ui/gtk/packet_list.c
index 06e8364c75..477a782c81 100644
--- a/ui/gtk/packet_list.c
+++ b/ui/gtk/packet_list.c
@@ -662,6 +662,7 @@ create_view_and_model(void)
header_field_info *hfi;
gint col_min_width;
gchar *escaped_title;
+ col_item_t* col_item;
packetlist = packet_list_new();
@@ -691,6 +692,7 @@ create_view_and_model(void)
/* We need one extra column to store the entire PacketListRecord */
for(i = 0; i < cfile.cinfo.num_cols; i++) {
+ col_item = &cfile.cinfo.columns[i];
renderer = gtk_cell_renderer_text_new();
col = gtk_tree_view_column_new();
gtk_tree_view_column_pack_start(col, renderer, TRUE);
@@ -706,14 +708,14 @@ create_view_and_model(void)
show_cell_data_func,
GINT_TO_POINTER(i),
NULL);
- if (cfile.cinfo.col_fmt[i] == COL_CUSTOM) {
- hfi = proto_registrar_get_byname(cfile.cinfo.col_custom_field[i]);
+ if (col_item->col_fmt == COL_CUSTOM) {
+ hfi = proto_registrar_get_byname(col_item->col_custom_field);
/* Check if this is a valid custom_field */
if (hfi != NULL) {
if (hfi->parent != -1) {
/* Prefix with protocol name */
- if (cfile.cinfo.col_custom_occurrence[i] != 0) {
- tooltip_text = g_strdup_printf("%s\n%s (%s#%d)", proto_get_protocol_name(hfi->parent), hfi->name, hfi->abbrev, cfile.cinfo.col_custom_occurrence[i]);
+ if (col_item->col_custom_occurrence != 0) {
+ tooltip_text = g_strdup_printf("%s\n%s (%s#%d)", proto_get_protocol_name(hfi->parent), hfi->name, hfi->abbrev, col_item->col_custom_occurrence);
} else {
tooltip_text = g_strdup_printf("%s\n%s (%s)", proto_get_protocol_name(hfi->parent), hfi->name, hfi->abbrev);
}
@@ -724,9 +726,9 @@ create_view_and_model(void)
tooltip_text = g_strdup_printf("Unknown Field: %s", get_column_custom_field(i));
}
} else {
- tooltip_text = g_strdup(col_format_desc(cfile.cinfo.col_fmt[i]));
+ tooltip_text = g_strdup(col_format_desc(col_item->col_fmt));
}
- escaped_title = ws_strdup_escape_char(cfile.cinfo.col_title[i], '_');
+ escaped_title = ws_strdup_escape_char(col_item->col_title, '_');
gtk_tree_view_column_set_title(col, escaped_title);
g_free (escaped_title);
gtk_tree_view_column_set_clickable(col, TRUE);
@@ -743,7 +745,7 @@ create_view_and_model(void)
* XXX The minimum size will be the size of the title
* should that be limited for long titles?
*/
- col_min_width = get_default_col_size (packetlist->view, cfile.cinfo.col_title[i]);
+ col_min_width = get_default_col_size (packetlist->view, cfile.cinfo.columns[i].col_title);
if(col_min_width<COLUMN_WIDTH_MIN){
gtk_tree_view_column_set_min_width(col, COLUMN_WIDTH_MIN);
}else{
diff --git a/ui/gtk/packet_list_store.c b/ui/gtk/packet_list_store.c
index dbb511ae43..842497b14d 100644
--- a/ui/gtk/packet_list_store.c
+++ b/ui/gtk/packet_list_store.c
@@ -398,7 +398,7 @@ packet_list_get_value(GtkTreeModel *tree_model, GtkTreeIter *iter, gint column,
text_column = packet_list->col_to_text[column];
if (text_column == -1) { /* column based on frame_data */
col_fill_in_frame_data(record->fdata, &cfile.cinfo, column, FALSE);
- g_value_set_string(value, cfile.cinfo.col_data[column]);
+ g_value_set_string(value, cfile.cinfo.columns[column].col_data);
} else {
g_return_if_fail(record->col_text);
g_value_set_string(value, record->col_text[text_column]);
@@ -652,6 +652,7 @@ packet_list_change_record(PacketList *packet_list, PacketListRecord *record, gin
gchar *str;
size_t col_text_len;
int text_col;
+ col_item_t* col_item;
text_col = packet_list->col_to_text[col];
@@ -659,7 +660,8 @@ packet_list_change_record(PacketList *packet_list, PacketListRecord *record, gin
if (text_col == -1 || record->col_text[text_col] != NULL)
return;
- switch (cfile.cinfo.col_fmt[col]) {
+ col_item = &cfile.cinfo.columns[col];
+ switch (col_item->col_fmt) {
case COL_DEF_SRC:
case COL_RES_SRC: /* COL_DEF_SRC is currently just like COL_RES_SRC */
case COL_UNRES_SRC:
@@ -685,13 +687,13 @@ packet_list_change_record(PacketList *packet_list, PacketListRecord *record, gin
case COL_8021Q_VLAN_ID:
case COL_EXPERT:
case COL_FREQ_CHAN:
- if (cinfo->col_data[col] && cinfo->col_data[col] != cinfo->col_buf[col]) {
- col_text_len = strlen(cinfo->col_data[col]);
+ if (col_item->col_data && col_item->col_data != col_item->col_buf) {
+ col_text_len = strlen(col_item->col_data);
if (col_text_len > G_MAXUSHORT)
col_text_len = G_MAXUSHORT;
/* This is a constant string, so we don't have to copy it */
- record->col_text[text_col] = (gchar *) cinfo->col_data[col];
+ record->col_text[text_col] = (gchar *) col_item->col_data;
record->col_text_len[text_col] = (gushort) col_text_len;
#ifdef PACKET_LIST_STATISTICS
++packet_list->const_strings;
@@ -701,8 +703,8 @@ packet_list_change_record(PacketList *packet_list, PacketListRecord *record, gin
/* !! FALL-THROUGH!! */
default:
- if(cinfo->col_data[col]){
- col_text_len = strlen(cinfo->col_data[col]);
+ if(col_item->col_data){
+ col_text_len = strlen(col_item->col_data);
if (col_text_len > G_MAXUSHORT)
col_text_len = G_MAXUSHORT;
@@ -722,7 +724,7 @@ packet_list_change_record(PacketList *packet_list, PacketListRecord *record, gin
/* Use the unresolved value in col_expr_val */
str = g_string_chunk_insert_const (packet_list->string_pool, (const gchar *)cinfo->col_expr.col_expr_val[col]);
} else {
- str = g_string_chunk_insert_const (packet_list->string_pool, (const gchar *)cinfo->col_data[col]);
+ str = g_string_chunk_insert_const (packet_list->string_pool, (const gchar *)col_item->col_data);
}
record->col_text[text_col] = str;
break;
@@ -930,7 +932,7 @@ packet_list_compare_custom(gint sort_id, gint text_sort_id, PacketListRecord *a,
{
header_field_info *hfi;
- hfi = proto_registrar_get_byname(cfile.cinfo.col_custom_field[sort_id]);
+ hfi = proto_registrar_get_byname(cfile.cinfo.columns[sort_id].col_custom_field);
if (hfi == NULL) {
return frame_data_compare(cfile.epan, a->fdata, b->fdata, COL_NUMBER);
@@ -968,7 +970,7 @@ _packet_list_compare_records(gint sort_id, gint text_sort_id, PacketListRecord *
if(a->col_text[text_sort_id] == b->col_text[text_sort_id])
return 0; /* no need to call strcmp() */
- if (cfile.cinfo.col_fmt[sort_id] == COL_CUSTOM)
+ if (cfile.cinfo.columns[sort_id].col_fmt == COL_CUSTOM)
return packet_list_compare_custom(sort_id, text_sort_id, a, b);
return strcmp(a->col_text[text_sort_id], b->col_text[text_sort_id]);
@@ -980,7 +982,7 @@ packet_list_compare_records(gint sort_id, gint text_sort_id, PacketListRecord *a
gint ret;
if (text_sort_id == -1) /* based on frame_data ? */
- return frame_data_compare(cfile.epan, a->fdata, b->fdata, cfile.cinfo.col_fmt[sort_id]);
+ return frame_data_compare(cfile.epan, a->fdata, b->fdata, cfile.cinfo.columns[sort_id].col_fmt);
ret = _packet_list_compare_records(sort_id, text_sort_id, a, b);
if (ret == 0)
@@ -1216,7 +1218,7 @@ packet_list_get_widest_column_string(PacketList *packet_list, gint col)
record = PACKET_LIST_RECORD_GET(packet_list->visible_rows, vis_idx);
col_fill_in_frame_data(record->fdata, &cfile.cinfo, col, FALSE);
- column_len = (gint) strlen(cfile.cinfo.col_buf[col]);
+ column_len = (gint) strlen(cfile.cinfo.columns[col].col_buf);
if (column_len > widest_column_len) {
widest_column_len = column_len;
widest_packet = vis_idx;
@@ -1227,7 +1229,7 @@ packet_list_get_widest_column_string(PacketList *packet_list, gint col)
record = PACKET_LIST_RECORD_GET(packet_list->visible_rows, widest_packet);
col_fill_in_frame_data(record->fdata, &cfile.cinfo, col, FALSE);
- return cfile.cinfo.col_buf[col];
+ return cfile.cinfo.columns[col].col_buf;
} else
return "";
}
diff --git a/ui/gtk/packet_win.c b/ui/gtk/packet_win.c
index fb28702dfc..ca5a5be6ed 100644
--- a/ui/gtk/packet_win.c
+++ b/ui/gtk/packet_win.c
@@ -172,7 +172,7 @@ create_packet_window_title(void)
* frame was dissected.
*/
for (i = 0; i < cfile.cinfo.num_cols; ++i) {
- g_string_append(title, cfile.cinfo.col_data[i]);
+ g_string_append(title, cfile.cinfo.columns[i].col_data);
g_string_append_c(title, ' ');
}