Make the color filter list global, and have the code that applies
authorguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Sun, 19 Dec 1999 07:28:36 +0000 (07:28 +0000)
committerguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Sun, 19 Dec 1999 07:28:36 +0000 (07:28 +0000)
color filters check whether it's null to decide if there are any color
filters to apply.

Make "color_filter()" act on that list - there really aren't multiple
lists of color filters, there's only one list ("read_filters()" and
"write_filters()" acts only on one global list - and always has, as they
handled only one file).

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@1359 f5534014-38df-0310-8fa8-9805f1628bb7

colors.c
colors.h
file.c

index f152af7609ba7aec33f6c5aea5b74359ef7d207a..f03a4ee8019f3650e1bd22fad3d7dfd0ad0701f7 100644 (file)
--- a/colors.c
+++ b/colors.c
@@ -1,7 +1,7 @@
 /* colors.c
  * Definitions for color structures and routines
  *
- * $Id: colors.c,v 1.20 1999/12/19 07:11:26 guy Exp $
+ * $Id: colors.c,v 1.21 1999/12/19 07:28:35 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@zing.org>
@@ -55,7 +55,7 @@ static GtkWidget* create_colorize_win(colfilter *filter,
 static GtkWidget* create_color_sel_win(colfilter *filter, GdkColor *);
 static gboolean get_color(GdkColor *new_color);
 
-static GSList *filter_list;
+GSList *filter_list;
 
 static GdkColormap*    sys_cmap;
 static GdkColormap*    our_cmap = NULL;
@@ -125,10 +125,10 @@ colfilter_new(void)
        }
 
        new_color_filter(filter, default_colors[i].proto, default_colors[i].proto);
-       color_filter(filter,i)->bg_color = color;
+       color_filter(i)->bg_color = color;
 
        if (dfilter_compile(default_colors[i].proto,
-           &color_filter(filter,i)->c_colorfilter) != 0) {
+           &color_filter(i)->c_colorfilter) != 0) {
                simple_dialog(ESD_TYPE_WARN, NULL,
                  "Cannot compile default color filter %s.\n%s",
                  default_colors[i].proto, dfilter_error_msg);
@@ -175,9 +175,9 @@ get_color_filter_string(colfilter *filter, gint n)
 }
 
 color_filter_t *
-color_filter(colfilter *filter, gint n)
+color_filter(gint n)
 {
-       return gtk_clist_get_row_data(GTK_CLIST(filter->color_filters),n);
+       return g_slist_nth_data(filter_list, n);
 }
 
 static void
@@ -276,7 +276,7 @@ read_filters(colfilter *filter)
                continue;
            }
             new_color_filter(filter, name, filter_exp);
-           color_filter(filter,i)->c_colorfilter = temp_dfilter;
+           color_filter(i)->c_colorfilter = temp_dfilter;
            filter->num_of_filters++;
            fg_color.red = fg_r;
            fg_color.green = fg_g;
@@ -300,8 +300,8 @@ read_filters(colfilter *filter)
                continue;
            }
 
-            color_filter(filter,i)->bg_color = bg_color;
-            color_filter(filter,i)->fg_color = fg_color;
+            color_filter(i)->bg_color = bg_color;
+            color_filter(i)->fg_color = fg_color;
             gtk_clist_set_foreground(GTK_CLIST(filter->color_filters),
                        i,&fg_color);
             gtk_clist_set_background(GTK_CLIST(filter->color_filters),
@@ -573,7 +573,7 @@ colorize_fg_cb                         (GtkButton       *button,
   color_filter_t * cof;
 
   filter = (colfilter *)user_data;
-  cof = color_filter(filter, filter->row_selected);
+  cof = color_filter(filter->row_selected);
   create_color_sel_win(filter, &cof->fg_color);
   bg_set_flag = 0;
 }
@@ -587,7 +587,7 @@ colorize_bg_cb                         (GtkButton       *button,
   color_filter_t * cof;
 
   filter = (colfilter *)user_data;
-  cof = color_filter(filter, filter->row_selected);
+  cof = color_filter(filter->row_selected);
   create_color_sel_win(filter, &cof->bg_color);
   bg_set_flag = 1;
 }
@@ -623,7 +623,7 @@ colorize_ok_cb                         (GtkButton       *button,
        return;
   }
 
-  cfilter = color_filter(cf.colors, cf.colors->row_selected);
+  cfilter = color_filter(cf.colors->row_selected);
   if (cfilter->filter_name != NULL)
     g_free(cfilter->filter_name);
   cfilter->filter_name = filter_name;
@@ -642,9 +642,9 @@ colorize_ok_cb                         (GtkButton       *button,
                " Please try again. Filter unchanged.\n%s\n", filter_name,dfilter_error_msg);
   } else {
 
-       if( color_filter(cf.colors, cf.colors->row_selected)->c_colorfilter != NULL)
-           dfilter_destroy(color_filter(cf.colors,cf.colors->row_selected)->c_colorfilter);
-       color_filter(cf.colors,cf.colors->row_selected)->c_colorfilter = compiled_filter;
+       if( color_filter(cf.colors->row_selected)->c_colorfilter != NULL)
+           dfilter_destroy(color_filter(cf.colors->row_selected)->c_colorfilter);
+       color_filter(cf.colors->row_selected)->c_colorfilter = compiled_filter;
        set_color_filter_string(cf.colors,cf.colors->row_selected,filter_text);
        set_color_filter_name(cf.colors,cf.colors->row_selected,filter_name);
         gtk_widget_destroy(dialog);
@@ -987,8 +987,8 @@ create_colorize_win (colfilter *filter,
        get_color_filter_name(filter, filter->row_selected));
 
   style = gtk_style_copy(gtk_widget_get_style(*colorize_filter_name));
-  style->base[GTK_STATE_NORMAL] = color_filter(filter,filter->row_selected)->bg_color;
-  style->fg[GTK_STATE_NORMAL]   = color_filter(filter,filter->row_selected)->fg_color;
+  style->base[GTK_STATE_NORMAL] = color_filter(filter->row_selected)->bg_color;
+  style->fg[GTK_STATE_NORMAL]   = color_filter(filter->row_selected)->fg_color;
   gtk_widget_set_style(*colorize_filter_name, style);
 
   gtk_widget_show (*colorize_filter_name);
@@ -1017,8 +1017,8 @@ create_colorize_win (colfilter *filter,
        get_color_filter_string(filter, filter->row_selected));
 #if 0
   style = gtk_style_copy(gtk_widget_get_style(*colorize_filter_text));
-  style->base[GTK_STATE_NORMAL] = color_filter(filter,filter->row_selected)->bg_color;
-  style->fg[GTK_STATE_NORMAL]   = color_filter(filter,filter->row_selected)->fg_color;
+  style->base[GTK_STATE_NORMAL] = color_filter(filter->row_selected)->bg_color;
+  style->fg[GTK_STATE_NORMAL]   = color_filter(filter->row_selected)->fg_color;
 #endif
   gtk_widget_set_style(*colorize_filter_text, style);
   gtk_widget_show (*colorize_filter_text);
index da0af391169a66ef55c3a28003c1449721499348..68c4e97167dde43957f673a4bdac53f1a5c99626 100644 (file)
--- a/colors.h
+++ b/colors.h
@@ -1,7 +1,7 @@
 /* colors.h
  * Definitions for color structures and routines
  *
- * $Id: colors.h,v 1.8 1999/12/19 07:01:30 guy Exp $
+ * $Id: colors.h,v 1.9 1999/12/19 07:28:35 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@zing.org>
@@ -56,6 +56,9 @@ typedef struct _color_filter {
        dfilter *c_colorfilter;
 } color_filter_t;
 
+/* List of all color filters. */
+extern GSList *filter_list;
+
 typedef struct _colfilter  {
        GtkWidget  *color_filters;
        gint      num_of_filters;  /* first num_of_filters rows filled */
@@ -64,7 +67,7 @@ typedef struct _colfilter  {
 
 colfilter *colfilter_new(void);
 
-color_filter_t *color_filter(colfilter *filter, gint n);
+color_filter_t *color_filter(gint n);
 
 /* ===================== USER INTERFACE ====================== */
 
diff --git a/file.c b/file.c
index 06d3df9134ee0a1b95d60982dc42920fe987b40b..f6756c0f34e72cfa88ac071db58c9cc14baefb53 100644 (file)
--- a/file.c
+++ b/file.c
@@ -1,7 +1,7 @@
 /* file.c
  * File I/O routines
  *
- * $Id: file.c,v 1.139 1999/12/15 07:01:33 gram Exp $
+ * $Id: file.c,v 1.140 1999/12/19 07:28:36 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@zing.org>
@@ -820,10 +820,10 @@ add_packet_to_packet_list(frame_data *fdata, capture_file *cf, const u_char *buf
         for(crow = 0; cf->colors->num_of_filters && 
              crow < cf->colors->num_of_filters; crow++) {
 
-            if(color_filter(cf->colors,crow)->c_colorfilter == NULL) {
+            if(color_filter(crow)->c_colorfilter == NULL) {
                continue;
            }
-            if(dfilter_apply(color_filter(cf->colors,crow)->c_colorfilter, protocol_tree,
+            if(dfilter_apply(color_filter(crow)->c_colorfilter, protocol_tree,
                 cf->pd)){
                 color = crow;
                break;
@@ -876,11 +876,11 @@ add_packet_to_packet_list(frame_data *fdata, capture_file *cf, const u_char *buf
     row = gtk_clist_append(GTK_CLIST(packet_list), fdata->cinfo->col_data);
     fdata->row = row;
 
-    if (cf->colors->color_filters && (color != -1)){
+    if (filter_list != NULL && (color != -1)){
         gtk_clist_set_background(GTK_CLIST(packet_list), row,
-                   &(color_filter(cf->colors,color)->bg_color));
+                   &(color_filter(color)->bg_color));
         gtk_clist_set_foreground(GTK_CLIST(packet_list), row,
-                   &(color_filter(cf->colors,color)->fg_color));
+                   &(color_filter(color)->fg_color));
     } else {
         gtk_clist_set_background(GTK_CLIST(packet_list), row, &WHITE);
         gtk_clist_set_foreground(GTK_CLIST(packet_list), row, &BLACK);