aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKovarththanan Rajaratnam <kovarththanan.rajaratnam@gmail.com>2009-09-06 05:49:00 +0000
committerKovarththanan Rajaratnam <kovarththanan.rajaratnam@gmail.com>2009-09-06 05:49:00 +0000
commit2ab0685d8a7de5b310ddc5a3146abd48948ff721 (patch)
tree593742b1910b5611376f6415836493411717c8d8
parentf352fa6d90abf152a5c4a18893f2080109c7655e (diff)
Make sure that we can enable/disable color filtering.
Fixes http://wiki.wireshark.org/Development/OptimizePacketList?action=diff&rev1=11&rev2=12 svn path=/trunk/; revision=29728
-rw-r--r--gtk/new_packet_list.c64
-rw-r--r--gtk/packet_list_store.c80
-rw-r--r--gtk/packet_list_store.h20
3 files changed, 91 insertions, 73 deletions
diff --git a/gtk/new_packet_list.c b/gtk/new_packet_list.c
index dfa54b9830..2cf7ee65e5 100644
--- a/gtk/new_packet_list.c
+++ b/gtk/new_packet_list.c
@@ -175,14 +175,14 @@ create_view_and_model(void)
for(i = 0; i < cfile.cinfo.num_cols; i++) {
renderer = gtk_cell_renderer_text_new();
if (right_justify_column (i)) {
- g_object_set(G_OBJECT(renderer),
- "xalign",
- 1.0,
+ g_object_set(G_OBJECT(renderer),
+ "xalign",
+ 1.0,
NULL);
}
g_object_set(renderer,
"ypad", 0,
- NULL);
+ NULL);
col = gtk_tree_view_column_new();
gtk_tree_view_column_pack_start(col, renderer, TRUE);
gtk_tree_view_column_set_cell_data_func(col, renderer,
@@ -195,7 +195,7 @@ create_view_and_model(void)
gtk_tree_view_column_set_sizing(col,GTK_TREE_VIEW_COLUMN_FIXED);
gtk_tree_view_column_set_reorderable(col, TRUE); /* XXX - Should this be saved in the prefs? */
- /* The column can't be adjusted to a size smaller than this
+ /* The column can't be adjusted to a size smaller than this
* XXX Should we use a different value for different column formats?
*/
gtk_tree_view_column_set_min_width(col, 40);
@@ -440,7 +440,7 @@ new_packet_list_find_row_from_data(gpointer data, gboolean select)
GtkTreeIter iter;
frame_data *fdata_needle = data;
- /* Initializes iter with the first iterator in the tree (the one at the path "0")
+ /* Initializes iter with the first iterator in the tree (the one at the path "0")
* and returns TRUE. Returns FALSE if the tree is empty
*/
if(!gtk_tree_model_get_iter_first(model, &iter))
@@ -506,7 +506,7 @@ row_number_from_iter(GtkTreeIter *iter)
/* Indices start from 0, but rows start from 1. Hence +1 */
row = indices[0] + 1;
- gtk_tree_path_free(path);
+ gtk_tree_path_free(path);
return row;
}
@@ -598,23 +598,18 @@ show_cell_data_func(GtkTreeViewColumn *col _U_, GtkCellRenderer *renderer,
{
guint col_num = GPOINTER_TO_INT(data);
frame_data *fdata;
- color_filter_t *color_filter;
- color_t fg_color_t;
- color_t bg_color_t;
- GdkColor fg_gdk;
- GdkColor bg_gdk;
const gchar *cell_text;
PacketListRecord *record;
record = new_packet_list_get_record(model, iter);
- fdata = record->fdata;
-
- if (record->dissected)
- color_filter = fdata->color_filter;
- else {
- g_assert(fdata->col_text == NULL);
- packet_list_dissect_and_cache(packetlist, iter);
- color_filter = fdata->color_filter;
+ fdata = record->fdata;
+
+ if (!record->columnized || !record->colorized) {
+ g_assert((fdata->col_text == NULL && !record->columnized) ||
+ (fdata->col_text != NULL && record->columnized));
+ packet_list_dissect_and_cache(packetlist, iter,
+ !record->columnized,
+ !record->colorized);
}
g_assert(fdata->col_text);
@@ -627,12 +622,17 @@ show_cell_data_func(GtkTreeViewColumn *col _U_, GtkCellRenderer *renderer,
if((fdata->color_filter)||(fdata->flags.marked)){
gboolean color_on = enable_color;
+ GdkColor fg_gdk;
+ GdkColor bg_gdk;
if(fdata->flags.marked){
color_t_to_gdkcolor(&fg_gdk, &prefs.gui_marked_fg);
color_t_to_gdkcolor(&bg_gdk, &prefs.gui_marked_bg);
color_on = TRUE;
}else{
- color_filter = fdata->color_filter;
+ color_t fg_color_t;
+ color_t bg_color_t;
+ color_filter_t *color_filter = fdata->color_filter;
+
fg_color_t = color_filter->fg_color;
bg_color_t = color_filter->bg_color;
color_t_to_gdkcolor(&fg_gdk, &fg_color_t);
@@ -668,7 +668,7 @@ new_packet_list_queue_draw(void)
}
/* call this after last set_frame_mark is done */
-static void mark_frames_ready(void)
+static void mark_frames_ready(void)
{
file_save_update_dynamics();
packets_bar_update();
@@ -711,7 +711,7 @@ new_packet_list_set_font(PangoFontDescription *font)
gtk_widget_modify_font(packetlist->view, font);
}
-void new_packet_list_mark_frame_cb(GtkWidget *w _U_, gpointer data _U_)
+void new_packet_list_mark_frame_cb(GtkWidget *w _U_, gpointer data _U_)
{
GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(packetlist->view));
GtkTreeSelection *selection;
@@ -744,7 +744,7 @@ typedef enum {
CS_CSV /* Packet summary data (comma separated) */
} copy_summary_type;
-void
+void
new_packet_list_copy_summary_cb(GtkWidget * w _U_, gpointer data _U_, gint copy_type)
{
gint col;
@@ -816,17 +816,17 @@ new_packet_list_recent_write_all(FILE *rf)
fprintf (rf, "\n");
}
-GtkWidget *
-new_packet_list_get_widget(void)
-{
- g_assert(packetlist);
- g_assert(packetlist->view);
- return packetlist->view;
-}
+GtkWidget *
+new_packet_list_get_widget(void)
+{
+ g_assert(packetlist);
+ g_assert(packetlist->view);
+ return packetlist->view;
+}
void new_packet_list_colorize_packets(void)
{
- packet_list_reset_dissected(packetlist);
+ packet_list_reset_colorized(packetlist);
gtk_widget_queue_draw (packetlist->view);
}
#endif /* NEW_PACKET_LIST */
diff --git a/gtk/packet_list_store.c b/gtk/packet_list_store.c
index 0ff460d3f2..e5d52a88f5 100644
--- a/gtk/packet_list_store.c
+++ b/gtk/packet_list_store.c
@@ -104,7 +104,7 @@ static void packet_list_sortable_init(GtkTreeSortableIface *iface);
static gint packet_list_compare_records(gint sort_id _U_, PacketListRecord *a,
PacketListRecord *b);
static void packet_list_resort(PacketList *packet_list);
-static void packet_list_dissect_and_cache_by_record(PacketList *packet_list, PacketListRecord *record);
+static void packet_list_dissect_and_cache_by_record(PacketList *packet_list, PacketListRecord *record, gboolean dissect_columns, gboolean dissect_color );
static GObjectClass *parent_class = NULL;
@@ -149,7 +149,7 @@ packet_list_get_type(void)
g_type_add_interface_static(packet_list_type,
GTK_TYPE_TREE_MODEL,
&tree_model_info);
-
+
/* Register our GtkTreeModel interface with the type system */
g_type_add_interface_static(packet_list_type,
@@ -233,7 +233,7 @@ packet_list_init(PacketList *packet_list)
packet_list->physical_rows = g_ptr_array_new();
packet_list->visible_rows = g_ptr_array_new();
- packet_list->dissected = FALSE;
+ packet_list->columnized = FALSE;
packet_list->sort_id = 0; /* defaults to first column for now */
packet_list->sort_order = GTK_SORT_ASCENDING;
}
@@ -365,10 +365,10 @@ packet_list_get_value(GtkTreeModel *tree_model, GtkTreeIter *iter, gint column,
type = packet_list->column_types[column];
g_value_init(value, type);
- /* XXX Probably the switch should be on column or
+ /* XXX Probably the switch should be on column or
* should we allways return the pointer and read the data as required??
* If we use FOREGROUND_COLOR_COL etc we'll need a couple of "internal" columns
- */
+ */
switch(type){
case G_TYPE_POINTER:
g_value_set_pointer(value, record);
@@ -569,7 +569,7 @@ new_packet_list_store_clear(PacketList *packet_list)
g_ptr_array_free(packet_list->visible_rows, TRUE);
packet_list->physical_rows = g_ptr_array_new();
packet_list->visible_rows = g_ptr_array_new();
- packet_list->dissected = FALSE;
+ packet_list->columnized = FALSE;
}
#if 0
@@ -619,7 +619,8 @@ packet_list_append_record(PacketList *packet_list, frame_data *fdata)
g_return_val_if_fail(PACKETLIST_IS_LIST(packet_list), -1);
newrecord = se_alloc(sizeof(PacketListRecord));
- newrecord->dissected = FALSE;
+ newrecord->columnized = FALSE;
+ newrecord->colorized = FALSE;
newrecord->fdata = fdata;
newrecord->physical_pos = PACKET_LIST_RECORD_COUNT(packet_list->physical_rows);
@@ -712,7 +713,7 @@ packet_list_sortable_get_sort_column_id(GtkTreeSortable *sortable,
static gboolean
packet_list_column_contains_values(PacketList *packet_list, gint sort_col_id)
{
- if (packet_list->dissected || col_based_on_frame_data(&cfile.cinfo, sort_col_id))
+ if (packet_list->columnized || col_based_on_frame_data(&cfile.cinfo, sort_col_id))
return TRUE;
else
return FALSE;
@@ -724,16 +725,16 @@ packet_list_dissect_and_cache_all(PacketList *packet_list)
PacketListRecord *record;
guint i;
- g_assert(packet_list->dissected == FALSE);
+ g_assert(packet_list->columnized == FALSE);
g_warning(G_STRLOC " - TODO: Insert progress bar");
for(i = 0; i < PACKET_LIST_RECORD_COUNT(packet_list->physical_rows); ++i) {
record = PACKET_LIST_RECORD_GET(packet_list->physical_rows, i);
- packet_list_dissect_and_cache_by_record(packet_list, record);
+ packet_list_dissect_and_cache_by_record(packet_list, record, TRUE, FALSE);
}
- packet_list->dissected = TRUE;
+ packet_list->columnized = TRUE;
}
static void
@@ -820,7 +821,7 @@ packet_list_compare_records(gint sort_id, PacketListRecord *a,
return (a->fdata->col_text[sort_id] == NULL) ? -1 : 1;
g_return_val_if_reached(0);
-}
+}
static gint
packet_list_qsort_physical_compare_func(PacketListRecord **a, PacketListRecord **b,
@@ -847,7 +848,7 @@ packet_list_qsort_visible_compare_func(PacketListRecord **a, PacketListRecord **
g_assert((a) && (b) && (packet_list));
- ret = ((*a)->visible_pos) < ((*b)->visible_pos) ? -1 :
+ ret = ((*a)->visible_pos) < ((*b)->visible_pos) ? -1 :
((*a)->visible_pos) > ((*b)->visible_pos) ? 1 : 0;
return ret;
@@ -869,7 +870,7 @@ packet_list_resort(PacketList *packet_list)
return;
/* resort physical rows according to sorting column */
- g_qsort_with_data(packet_list->physical_rows->pdata,
+ g_qsort_with_data(packet_list->physical_rows->pdata,
PACKET_LIST_RECORD_COUNT(packet_list->physical_rows),
sizeof(PacketListRecord*),
(GCompareDataFunc) packet_list_qsort_physical_compare_func,
@@ -893,7 +894,7 @@ packet_list_resort(PacketList *packet_list)
g_assert(vis_idx == PACKET_LIST_RECORD_COUNT(packet_list->visible_rows));
/* resort visible rows according to new physical order */
- g_qsort_with_data(packet_list->visible_rows->pdata,
+ g_qsort_with_data(packet_list->visible_rows->pdata,
PACKET_LIST_RECORD_COUNT(packet_list->visible_rows),
sizeof(PacketListRecord*),
(GCompareDataFunc) packet_list_qsort_visible_compare_func,
@@ -925,7 +926,7 @@ packet_list_recreate_visible_rows(PacketList *packet_list)
g_ptr_array_free(packet_list->visible_rows, TRUE);
packet_list->visible_rows = g_ptr_array_new();
-
+
for(phy_idx = 0, vis_idx = 0; phy_idx < PACKET_LIST_RECORD_COUNT(packet_list->physical_rows); ++phy_idx) {
record = PACKET_LIST_RECORD_GET(packet_list->physical_rows, phy_idx);
if (record->fdata->flags.passed_dfilter) {
@@ -940,7 +941,7 @@ packet_list_recreate_visible_rows(PacketList *packet_list)
}
void
-packet_list_dissect_and_cache(PacketList *packet_list, GtkTreeIter *iter)
+packet_list_dissect_and_cache(PacketList *packet_list, GtkTreeIter *iter, gboolean dissect_columns, gboolean dissect_color)
{
PacketListRecord *record;
@@ -951,11 +952,11 @@ packet_list_dissect_and_cache(PacketList *packet_list, GtkTreeIter *iter)
record = iter->user_data;
- packet_list_dissect_and_cache_by_record(packet_list, record);
+ packet_list_dissect_and_cache_by_record(packet_list, record, dissect_columns, dissect_color);
}
static void
-packet_list_dissect_and_cache_by_record(PacketList *packet_list, PacketListRecord *record)
+packet_list_dissect_and_cache_by_record(PacketList *packet_list, PacketListRecord *record, gboolean dissect_columns, gboolean dissect_color)
{
epan_dissect_t edt;
int err;
@@ -965,7 +966,11 @@ packet_list_dissect_and_cache_by_record(PacketList *packet_list, PacketListRecor
gint col;
fdata = record->fdata;
- cinfo = &cfile.cinfo;
+
+ if (dissect_columns)
+ cinfo = &cfile.cinfo;
+ else
+ cinfo = NULL;
if (!wtap_seek_read(cfile.wth, fdata->file_off, &cfile.pseudo_header,
cfile.pd, fdata->cap_len, &err, &err_info)) {
@@ -975,34 +980,45 @@ packet_list_dissect_and_cache_by_record(PacketList *packet_list, PacketListRecor
}
epan_dissect_init(&edt, TRUE /* create_proto_tree */, FALSE /* proto_tree_visible */);
- color_filters_prime_edt(&edt);
- col_custom_prime_edt(&edt, cinfo);
+
+ if (dissect_color)
+ color_filters_prime_edt(&edt);
+ if (dissect_columns)
+ col_custom_prime_edt(&edt, cinfo);
+
epan_dissect_run(&edt, &cfile.pseudo_header, cfile.pd, fdata, cinfo);
- fdata->color_filter = color_filters_colorize_packet(0 /* row - unused */, &edt);
- /* "Stringify" non frame_data vals */
- epan_dissect_fill_in_columns(&edt, FALSE /* fill_fd_colums */);
+ if (dissect_color)
+ fdata->color_filter = color_filters_colorize_packet(0 /* row - unused */, &edt);
- for(col = 0; col < cinfo->num_cols; ++col) {
- /* Skip columns based om frame_data because we already store those. */
- if (!col_based_on_frame_data(cinfo, col))
- packet_list_change_record(packet_list, record->physical_pos, col, cinfo);
+ if (dissect_columns) {
+ /* "Stringify" non frame_data vals */
+ epan_dissect_fill_in_columns(&edt, FALSE /* fill_fd_colums */);
+
+ for(col = 0; col < cinfo->num_cols; ++col) {
+ /* Skip columns based om frame_data because we already store those. */
+ if (!col_based_on_frame_data(cinfo, col))
+ packet_list_change_record(packet_list, record->physical_pos, col, cinfo);
+ }
}
- record->dissected = TRUE;
+ if (dissect_columns)
+ record->columnized = TRUE;
+ if (dissect_color)
+ record->colorized = TRUE;
epan_dissect_cleanup(&edt);
}
void
-packet_list_reset_dissected(PacketList *packet_list)
+packet_list_reset_colorized(PacketList *packet_list)
{
PacketListRecord *record;
guint i;
for(i = 0; i < PACKET_LIST_RECORD_COUNT(packet_list->physical_rows); ++i) {
record = PACKET_LIST_RECORD_GET(packet_list->physical_rows, i);
- record->dissected = FALSE;
+ record->colorized = FALSE;
}
}
diff --git a/gtk/packet_list_store.h b/gtk/packet_list_store.h
index ac70c49715..70c1095f3a 100644
--- a/gtk/packet_list_store.h
+++ b/gtk/packet_list_store.h
@@ -50,15 +50,17 @@ typedef struct _PacketListClass PacketListClass;
/* PacketListRecord: represents a row */
struct _PacketListRecord
{
- /* Has this record been dissected? */
- gboolean dissected;
+ /* Has this record been columnized? */
+ gboolean columnized;
+ /* Has this record been colorized? */
+ gboolean colorized;
frame_data *fdata;
/* admin stuff used by the custom list model */
/* position within the physical array */
- guint physical_pos;
+ guint physical_pos;
/* position within the visible array */
- gint visible_pos;
+ gint visible_pos;
};
/* PacketListRecord: Everything for our model implementation. */
@@ -68,10 +70,10 @@ struct _PacketList
GPtrArray *visible_rows;
/* Array of pointers to the PacketListRecord structure for each row. */
- GPtrArray *physical_rows;
+ GPtrArray *physical_rows;
- /* Has the entire file been dissected? */
- gboolean dissected;
+ /* Has the entire file been columnized? */
+ gboolean columnized;
gint n_columns;
/* Note: We need one extra column to store the entire PacketListRecord */
@@ -98,8 +100,8 @@ guint packet_list_recreate_visible_rows(PacketList *packet_list);
gboolean packet_list_visible_record(PacketList *packet_list, GtkTreeIter *iter);
gint packet_list_append_record(PacketList *packet_list, frame_data *fdata);
void packet_list_change_record(PacketList *packet_list, guint row, gint col, column_info *cinfo);
-void packet_list_dissect_and_cache(PacketList *packet_list, GtkTreeIter *iter);
-void packet_list_reset_dissected(PacketList *packet_list);
+void packet_list_dissect_and_cache(PacketList *packet_list, GtkTreeIter *iter, gboolean dissect_columns, gboolean dissect_color);
+void packet_list_reset_colorized(PacketList *packet_list);
#endif /* NEW_PACKET_LIST */
#endif /* __NEW_PACKET_LIST_H__ */