This patch makes it possible to disable individual coloring rules
authorsake <sake@f5534014-38df-0310-8fa8-9805f1628bb7>
Sat, 10 Nov 2007 15:18:49 +0000 (15:18 +0000)
committersake <sake@f5534014-38df-0310-8fa8-9805f1628bb7>
Sat, 10 Nov 2007 15:18:49 +0000 (15:18 +0000)
without having to delete them. The patch has been tested on
Fedora-7 with GTK+ 1.2.10 and GTK+ 2.10.11.

Since I don't know how to use "strikethrough" in clists in GTK1
there is a little difference in how the disabled coloring rules
are displayed. In GTK2 they are striked through and in GTK1
they are shown in lightgrey on a white background.

Any info on how to use strikthrough in clists within GTK1 is more
than welcome :-)

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

color_filters.c
color_filters.h
gtk/color_dlg.c
gtk/color_edit_dlg.c
gtk/colors.c
gtk/colors.h
gtk/compat_macros.h
gtk/toolbar.c

index a1c661a..2abadc9 100644 (file)
@@ -63,7 +63,8 @@ color_filter_t *
 color_filter_new(const gchar *name,    /* The name of the filter to create */
                  const gchar *filter_string, /* The string representing the filter */
                  color_t *bg_color,    /* The background color */
-                 color_t *fg_color)    /* The foreground color */
+                 color_t *fg_color,    /* The foreground color */
+                 gboolean disabled)     /* Is the filter disabled? */
 {
        color_filter_t *colorf;
 
@@ -72,6 +73,7 @@ color_filter_new(const gchar *name,    /* The name of the filter to create */
        colorf->filter_text = g_strdup(filter_string);
        colorf->bg_color = *bg_color;
        colorf->fg_color = *fg_color;
+       colorf->disabled = disabled;
        colorf->c_colorfilter = NULL;
        colorf->edit_dialog = NULL;
        colorf->selected = FALSE;
@@ -120,6 +122,7 @@ color_filter_clone(color_filter_t *colorf)
        new_colorf->filter_text = g_strdup(colorf->filter_text);
        new_colorf->bg_color = colorf->bg_color;
        new_colorf->fg_color = colorf->fg_color;
+       new_colorf->disabled = colorf->disabled;
        new_colorf->c_colorfilter = NULL;
        new_colorf->edit_dialog = NULL;
        new_colorf->selected = FALSE;
@@ -284,6 +287,7 @@ color_filters_colorize_packet(gint row, epan_dissect_t *edt)
         while(curr != NULL) {
             colorf = curr->data;
             if ((colorf->c_colorfilter != NULL) &&
+               (!colorf->disabled) &&
                  dfilter_apply_edt(colorf->c_colorfilter, edt)) {
                     /* this is the filter to use, apply it to the packet list */
                     packet_list_set_colors(row, &(colorf->fg_color), &(colorf->bg_color));
@@ -310,6 +314,7 @@ read_filters_file(FILE *f, gpointer user_data)
        guint32 i = 0;
        gint32  c;
        guint16 fg_r, fg_g, fg_b, bg_r, bg_g, bg_b;
+       gboolean disabled = FALSE;
        gboolean skip_end_of_line = FALSE;
 
        name = g_malloc(name_len + 1);
@@ -323,6 +328,7 @@ read_filters_file(FILE *f, gpointer user_data)
                        } while (c != EOF && c != '\n');
                        if (c == EOF)
                                break;
+                       disabled = FALSE;
                        skip_end_of_line = FALSE;
                }
 
@@ -335,6 +341,11 @@ read_filters_file(FILE *f, gpointer user_data)
                if (c == EOF)
                        break;
 
+               if (c == '!') {
+                       disabled = TRUE;
+                       continue;
+               }
+
                /* skip # comments and invalid lines */
                if (c != '@') { 
                        skip_end_of_line = TRUE;
@@ -428,7 +439,7 @@ read_filters_file(FILE *f, gpointer user_data)
                        }
 
                        colorf = color_filter_new(name, filter_exp, &bg_color,
-                           &fg_color);
+                           &fg_color, disabled);
                         if(user_data == &color_filter_list) {
                                 GSList **cfl = (GSList **)user_data;
 
@@ -539,7 +550,8 @@ write_filter(gpointer filter_arg, gpointer data_arg)
        FILE *f = data->f;
 
        if (colorf->selected || !data->only_selected) {
-               fprintf(f,"@%s@%s@[%d,%d,%d][%d,%d,%d]\n",
+               fprintf(f,"%s@%s@%s@[%d,%d,%d][%d,%d,%d]\n",
+                   colorf->disabled ? "!" : "",
                    colorf->filter_name,
                    colorf->filter_text,
                    colorf->bg_color.red,
index beceea5..056115d 100644 (file)
@@ -34,6 +34,7 @@ typedef struct _color_filter {
         gchar     *filter_text;   /* text of the filter expression */
         color_t    bg_color;      /* background color for packets that match */
         color_t    fg_color;      /* foreground color for packets that match */
+       gboolean   disabled;      /* set if the filter is disabled */
        gboolean   selected;      /* set if the filter is selected in the color dialog box */
 
         /* only used inside of color_filters.c */
@@ -149,7 +150,7 @@ gboolean color_filters_export(gchar *path, GSList *cfl, gboolean only_selected);
  */
 color_filter_t *color_filter_new(
     const gchar *name, const gchar *filter_string,
-    color_t *bg_color, color_t *fg_color);
+    color_t *bg_color, color_t *fg_color, gboolean disabled);
 
 /** Delete a single color filter (g_free'ed).
  *
index 604cb35..a594e69 100644 (file)
@@ -77,6 +77,7 @@ static void destroy_edit_dialog_cb(gpointer filter_arg, gpointer dummy);
 static void create_new_color_filter(GtkButton *button, const char *filter);
 static void color_new_cb(GtkButton *button, gpointer user_data);
 static void color_edit_cb(GtkButton *button, gpointer user_data);
+static void color_disable_cb(GtkWidget *widget, gboolean user_data);
 static void color_delete_cb(GtkWidget *widget, gpointer user_data);
 static void color_save_cb(GtkButton *button, gpointer user_data);
 static void color_ok_cb(GtkButton *button, gpointer user_data);
@@ -109,6 +110,8 @@ static GSList *color_filter_edit_list = NULL;
 #define COLOR_UP_LB            "color_up_lb"
 #define COLOR_DOWN_LB          "color_down_lb"
 #define COLOR_EDIT_LB          "color_edit_lb"
+#define COLOR_ENABLE_LB                "color_enable_lb"
+#define COLOR_DISABLE_LB       "color_disable_lb"
 #define COLOR_DELETE_LB                "color_delete_lb"
 #define COLOR_FILTERS_CL       "color_filters_cl"
 #define COLOR_FILTER_LIST       "color_filter_list"
@@ -187,6 +190,8 @@ colorize_dialog_new (char *filter)
   GtkWidget *edit_vbox;
   GtkWidget *color_new;
   GtkWidget *color_edit;
+  GtkWidget *color_enable;
+  GtkWidget *color_disable;
   GtkWidget *color_delete;
 
   GtkWidget *manage_fr;
@@ -258,6 +263,22 @@ colorize_dialog_new (char *filter)
       " If more than one filter is selected, edit the first selected one"), NULL);
   gtk_widget_set_sensitive (color_edit, FALSE);
 
+  color_enable = BUTTON_NEW_FROM_STOCK(WIRESHARK_STOCK_ENABLE);
+  gtk_box_pack_start (GTK_BOX (edit_vbox), color_enable, FALSE, FALSE, 5);
+#if GTK_MAJOR_VERSION < 2
+  WIDGET_SET_SIZE(color_enable, BUTTON_SIZE_X, BUTTON_SIZE_Y);
+#endif
+  gtk_tooltips_set_tip (tooltips, color_enable, ("Enable the selected filter(s)"), NULL);
+  gtk_widget_set_sensitive (color_enable, FALSE);
+
+  color_disable = BUTTON_NEW_FROM_STOCK(WIRESHARK_STOCK_DISABLE);
+  gtk_box_pack_start (GTK_BOX (edit_vbox), color_disable, FALSE, FALSE, 5);
+#if GTK_MAJOR_VERSION < 2
+  WIDGET_SET_SIZE(color_disable, BUTTON_SIZE_X, BUTTON_SIZE_Y);
+#endif
+  gtk_tooltips_set_tip (tooltips, color_disable, ("Disable the selected filter(s)"), NULL);
+  gtk_widget_set_sensitive (color_disable, FALSE);
+
   color_delete = BUTTON_NEW_FROM_STOCK(GTK_STOCK_DELETE);
   gtk_box_pack_start (GTK_BOX (edit_vbox), color_delete, FALSE, FALSE, 5);
 #if GTK_MAJOR_VERSION < 2
@@ -322,20 +343,27 @@ colorize_dialog_new (char *filter)
 #else
   /* the list store contains : filter name, filter string, foreground
    * color, background color, pointer to color filter */
-  store = gtk_list_store_new(5, G_TYPE_STRING, G_TYPE_STRING,
-                             G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER);
+  store = gtk_list_store_new(6, G_TYPE_STRING, G_TYPE_STRING,
+                             G_TYPE_STRING, G_TYPE_STRING, 
+                            G_TYPE_BOOLEAN, G_TYPE_POINTER);
   color_filters = tree_view_new(GTK_TREE_MODEL(store));
   g_object_unref(store);
   renderer = gtk_cell_renderer_text_new();
-  column = gtk_tree_view_column_new_with_attributes(titles[0], renderer, "text",
-                                                    0, "foreground", 2,
-                                                    "background", 3, NULL);
+  column = gtk_tree_view_column_new_with_attributes(titles[0], renderer,
+                                                    "text", 0,
+                                                   "foreground", 2,
+                                                    "background", 3,
+                                                   "strikethrough", 4,
+                                                   NULL);
   gtk_tree_view_column_set_fixed_width(column, 80);
   gtk_tree_view_append_column(GTK_TREE_VIEW(color_filters), column);
   renderer = gtk_cell_renderer_text_new();
-  column = gtk_tree_view_column_new_with_attributes(titles[1], renderer, "text",
-                                                    1, "foreground", 2,
-                                                    "background", 3, NULL);
+  column = gtk_tree_view_column_new_with_attributes(titles[1], renderer,
+                                                    "text", 1,
+                                                   "foreground", 2,
+                                                    "background", 3,
+                                                   "strikethrough", 4,
+                                                   NULL);
   gtk_tree_view_column_set_fixed_width(column, 300);
   gtk_tree_view_append_column(GTK_TREE_VIEW(color_filters), column);
   gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(color_filters), TRUE);
@@ -429,11 +457,17 @@ colorize_dialog_new (char *filter)
   OBJECT_SET_DATA(color_filters, COLOR_UP_LB, color_filter_up);
   OBJECT_SET_DATA(color_filters, COLOR_DOWN_LB, color_filter_down);
   OBJECT_SET_DATA(color_filters, COLOR_EDIT_LB, color_edit);
+  OBJECT_SET_DATA(color_filters, COLOR_ENABLE_LB, color_enable);
+  OBJECT_SET_DATA(color_filters, COLOR_DISABLE_LB, color_disable);
   OBJECT_SET_DATA(color_filters, COLOR_DELETE_LB, color_delete);
   OBJECT_SET_DATA(color_new, COLOR_FILTERS_CL, color_filters);
   SIGNAL_CONNECT(color_new, "clicked", color_new_cb, NULL);
   OBJECT_SET_DATA(color_edit, COLOR_FILTERS_CL, color_filters);
   SIGNAL_CONNECT(color_edit, "clicked", color_edit_cb, NULL);
+  OBJECT_SET_DATA(color_enable, COLOR_FILTERS_CL, color_filters);
+  SIGNAL_CONNECT(color_enable, "clicked", color_disable_cb, FALSE);
+  OBJECT_SET_DATA(color_disable, COLOR_FILTERS_CL, color_filters);
+  SIGNAL_CONNECT(color_disable, "clicked", color_disable_cb, TRUE);
   OBJECT_SET_DATA(color_delete, COLOR_EDIT_LB, color_edit);
   OBJECT_SET_DATA(color_delete, COLOR_FILTERS_CL, color_filters);
   SIGNAL_CONNECT(color_delete, "clicked", color_delete_cb, NULL);
@@ -484,6 +518,7 @@ static void move_this_row (GtkWidget   *color_filters,
   GtkTreeModel   *model;
   GtkTreeIter     iter1, iter2;
   gchar          *name, *string, *fg_str, *bg_str;
+  gboolean        disabled;
 #endif
 
   g_assert(amount == +1 || amount == -1);
@@ -517,14 +552,14 @@ static void move_this_row (GtkWidget   *color_filters,
   gtk_tree_model_iter_nth_child(model, &iter2, NULL, filter_number + amount);
 
   gtk_tree_model_get(model, &iter1, 0, &name, 1, &string,
-                     2, &fg_str, 3, &bg_str, 4, &colorf, -1);
+                     2, &fg_str, 3, &bg_str, 4, &disabled, 5, &colorf, -1);
   gtk_list_store_remove(GTK_LIST_STORE(model), &iter1);
   if (amount < 0)
     gtk_list_store_insert_before(GTK_LIST_STORE(model), &iter1, &iter2);
   else
     gtk_list_store_insert_after(GTK_LIST_STORE(model), &iter1, &iter2);
   gtk_list_store_set(GTK_LIST_STORE(model), &iter1, 0, name, 1, string,
-                     2, fg_str, 3, bg_str, 4, colorf, -1);
+                     2, fg_str, 3, bg_str, 4, disabled, 5, colorf, -1);
   g_free(name);
   g_free(string);
   g_free(fg_str);
@@ -576,7 +611,7 @@ color_filter_up_cb(GtkButton *button, gpointer user_data _U_)
 #else
     model = gtk_tree_view_get_model(GTK_TREE_VIEW(color_filters));
     gtk_tree_model_iter_nth_child(model, &iter, NULL, filter_number);
-    gtk_tree_model_get(model, &iter, 4, &colorf, -1);
+    gtk_tree_model_get(model, &iter, 5, &colorf, -1);
     sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(color_filters));
     if (gtk_tree_selection_iter_is_selected(sel, &iter))
       move_this_row (color_filters, filter_number, amount);
@@ -614,7 +649,7 @@ color_filter_down_cb(GtkButton *button, gpointer user_data _U_)
 #else
     model = gtk_tree_view_get_model(GTK_TREE_VIEW(color_filters));
     gtk_tree_model_iter_nth_child(model, &iter, NULL, filter_number);
-    gtk_tree_model_get(model, &iter, 4, &colorf, -1);
+    gtk_tree_model_get(model, &iter, 5, &colorf, -1);
 #endif
     if (colorf->selected)
       move_this_row (color_filters, filter_number, amount);
@@ -649,6 +684,10 @@ remember_selected_row(GtkCList *clist, gint row, gint column _U_,
      */
     button = (GtkWidget *)OBJECT_GET_DATA(clist, COLOR_EDIT_LB);
     gtk_widget_set_sensitive (button, TRUE);
+    button = (GtkWidget *)OBJECT_GET_DATA(clist, COLOR_ENABLE_LB);
+    gtk_widget_set_sensitive(button, TRUE);
+    button = (GtkWidget *)OBJECT_GET_DATA(clist, COLOR_DISABLE_LB);
+    gtk_widget_set_sensitive(button, TRUE);
     button = (GtkWidget *)OBJECT_GET_DATA(clist, COLOR_DELETE_LB);
     gtk_widget_set_sensitive(button, TRUE);
 
@@ -670,7 +709,7 @@ static void remember_this_row (GtkTreeModel *model, GtkTreePath *path, GtkTreeIt
     color_filter_t *colorf;
     struct remember_data *data = arg;
 
-    gtk_tree_model_get(model, iter, 4, &colorf, -1);
+    gtk_tree_model_get(model, iter, 5, &colorf, -1);
     colorf->selected = TRUE;
 
     path_index = gtk_tree_path_get_indices(path);   /* not to be freed */
@@ -723,9 +762,18 @@ remember_selected_row(GtkTreeSelection *sel, gpointer color_filters)
       button = (GtkWidget *)OBJECT_GET_DATA(color_filters, COLOR_EDIT_LB);
       gtk_widget_set_sensitive (button, data.count == 1);
 
+      /* We can enable any number of filters */
+      button = (GtkWidget *)OBJECT_GET_DATA(color_filters, COLOR_ENABLE_LB);
+      gtk_widget_set_sensitive (button, TRUE);
+
+      /* We can disable any number of filters */
+      button = (GtkWidget *)OBJECT_GET_DATA(color_filters, COLOR_DISABLE_LB);
+      gtk_widget_set_sensitive (button, TRUE);
+
       /* We can delete any number of filters */
       button = (GtkWidget *)OBJECT_GET_DATA(color_filters, COLOR_DELETE_LB);
       gtk_widget_set_sensitive (button, TRUE);
+
       /*
        * We can move them up *if* one of them isn't the top row,
        * and move them down *if* one of them isn't the bottom row.
@@ -751,6 +799,10 @@ remember_selected_row(GtkTreeSelection *sel, gpointer color_filters)
       }
       button = (GtkWidget *)OBJECT_GET_DATA(color_filters, COLOR_EDIT_LB);
       gtk_widget_set_sensitive (button, FALSE);
+      button = (GtkWidget *)OBJECT_GET_DATA(color_filters, COLOR_ENABLE_LB);
+      gtk_widget_set_sensitive (button, FALSE);
+      button = (GtkWidget *)OBJECT_GET_DATA(color_filters, COLOR_DISABLE_LB);
+      gtk_widget_set_sensitive (button, FALSE);
       button = (GtkWidget *)OBJECT_GET_DATA(color_filters, COLOR_DELETE_LB);
       gtk_widget_set_sensitive (button, FALSE);
     }
@@ -786,6 +838,10 @@ unremember_selected_row                 (GtkCList        *clist,
     gtk_widget_set_sensitive (button, FALSE);
     button = (GtkWidget *)OBJECT_GET_DATA(clist, COLOR_EDIT_LB);
     gtk_widget_set_sensitive (button, FALSE);
+    button = (GtkWidget *)OBJECT_GET_DATA(clist, COLOR_ENABLE_LB);
+    gtk_widget_set_sensitive(button, FALSE);
+    button = (GtkWidget *)OBJECT_GET_DATA(clist, COLOR_DISABLE_LB);
+    gtk_widget_set_sensitive(button, FALSE);
     button = (GtkWidget *)OBJECT_GET_DATA(clist, COLOR_DELETE_LB);
     gtk_widget_set_sensitive(button, FALSE);
   }
@@ -861,11 +917,21 @@ add_filter_to_list(gpointer filter_arg, gpointer list_arg)
   data[0] = colorf->filter_name;
   data[1] = colorf->filter_text;
   row = gtk_clist_append(GTK_CLIST(color_filters), data);
+
   color_t_to_gdkcolor(&fg, &colorf->fg_color);
   color_t_to_gdkcolor(&bg, &colorf->bg_color);
+
   gtk_clist_set_row_data(GTK_CLIST(color_filters), row, colorf);
-  gtk_clist_set_foreground(GTK_CLIST(color_filters), row, &fg);
-  gtk_clist_set_background(GTK_CLIST(color_filters), row, &bg);
+
+  /* XXX Using light-gray on white for disabled coloring-rules is a
+   * workaround to using strikethrough as I don't know how to set
+   * text to strikethrough in GTK1. This needs to be changed to
+   * keep the GTK1 and GTK2 version simular
+   */
+  gtk_clist_set_foreground(GTK_CLIST(color_filters), row,
+           colorf->disabled ? &LTGREY : &fg);
+  gtk_clist_set_background(GTK_CLIST(color_filters), row,
+           colorf->disabled ? &WHITE : &bg);
 #else
   gchar           fg_str[14], bg_str[14];
   GtkListStore   *store;
@@ -879,7 +945,7 @@ add_filter_to_list(gpointer filter_arg, gpointer list_arg)
           colorf->bg_color.red, colorf->bg_color.green, colorf->bg_color.blue);
   gtk_list_store_set(store, &iter, 0, colorf->filter_name,
                      1, colorf->filter_text, 2, fg_str, 3, bg_str,
-                     4, colorf, -1);
+                     4, colorf->disabled, 5, colorf, -1);
 #endif
   color_filter_edit_list = g_slist_append(color_filter_edit_list, colorf);
 
@@ -928,10 +994,8 @@ create_new_color_filter(GtkButton *button, const char *filter)
   gdkcolor_to_color_t(&bg_color, &style->base[GTK_STATE_NORMAL]);
   gdkcolor_to_color_t(&fg_color, &style->text[GTK_STATE_NORMAL]);
 
-  colorf = color_filter_new("name", filter, &bg_color, &fg_color);
-
+  colorf = color_filter_new("name", filter, &bg_color, &fg_color, FALSE);
   add_filter_to_list(colorf, color_filters);
-
   select_row(color_filters, num_of_filters-1);
 
   /* open the edit dialog */
@@ -962,6 +1026,61 @@ color_edit_cb(GtkButton *button, gpointer user_data _U_)
   edit_color_filter_dialog(color_filters, FALSE /* is not a new filter */);
 }
 
+/* action_disable==TRUE  ==> User pressed the "Disable" button:
+ *                           Disable the selected filters in the list.
+ * action_disable==FALSE ==> User pressed the "Enable" button:
+ *                           Enable the selected filters in the list.
+ */
+static void
+color_disable_cb(GtkWidget *widget, gboolean action_disable)
+{
+  gint filter_number;
+  GtkWidget * color_filters;
+  color_filter_t *colorf;
+#if GTK_MAJOR_VERSION < 2
+  GdkColor          fg, bg;
+#else
+  GtkTreeIter       iter;
+  GtkTreeModel     *model;
+  GtkTreeSelection *sel;
+#endif
+
+  color_filters = (GtkWidget *)OBJECT_GET_DATA(widget, COLOR_FILTERS_CL);
+
+  for (filter_number = 0; filter_number < num_of_filters; filter_number++)
+  {
+#if GTK_MAJOR_VERSION < 2
+    colorf = gtk_clist_get_row_data(GTK_CLIST(color_filters), filter_number);
+    if (colorf->selected) {
+      colorf->disabled = action_disable;
+
+      color_t_to_gdkcolor(&fg, &colorf->fg_color);
+      color_t_to_gdkcolor(&bg, &colorf->bg_color);
+
+      /* XXX Using light-gray on white for disabled coloring-rules is a
+       * workaround to using strikethrough as I don't know how to set
+       * text to strikethrough in GTK1. This needs to be changed to
+       * keep the GTK1 and GTK2 version simular
+       */
+      gtk_clist_set_foreground(GTK_CLIST(color_filters), filter_number, 
+             colorf->disabled ? &LTGREY : &fg);
+      gtk_clist_set_background(GTK_CLIST(color_filters), filter_number,
+             colorf->disabled ? &WHITE : &bg);
+    }
+
+#else
+    model = gtk_tree_view_get_model(GTK_TREE_VIEW(color_filters));
+    gtk_tree_model_iter_nth_child(model, &iter, NULL, filter_number);
+    gtk_tree_model_get(model, &iter, 5, &colorf, -1);
+    sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(color_filters));
+    if (gtk_tree_selection_iter_is_selected(sel, &iter)) {
+      colorf->disabled = action_disable;
+      gtk_list_store_set(GTK_LIST_STORE(model), &iter, 4, action_disable, -1);
+    }
+#endif
+  }
+}
+
 /* Delete a single color filter from the list and elsewhere. */
 void
 color_delete(gint row, GtkWidget *color_filters)
@@ -975,7 +1094,7 @@ color_delete(gint row, GtkWidget *color_filters)
 
     model = gtk_tree_view_get_model(GTK_TREE_VIEW(color_filters));
     gtk_tree_model_iter_nth_child(model, &iter, NULL, row);
-    gtk_tree_model_get(model, &iter, 4, &colorf, -1);
+    gtk_tree_model_get(model, &iter, 5, &colorf, -1);
 
     /* Remove this color filter from the CList displaying the
     color filters. */
index 5913810..b702a30 100644 (file)
@@ -60,6 +60,9 @@ static void edit_color_filter_destroy_cb(GObject *object, gpointer user_data);
 #endif
 static void edit_color_filter_fg_cb(GtkButton *button, gpointer user_data);
 static void edit_color_filter_bg_cb(GtkButton *button, gpointer user_data);
+/*
+static void edit_disabled_cb_cb(GtkButton *button, gpointer user_data);
+*/
 static void edit_color_filter_ok_cb(GtkButton *button, gpointer user_data);
 static void edit_new_color_filter_cancel_cb(GtkButton *button, gpointer user_data);
 
@@ -80,6 +83,7 @@ static void color_sel_cancel_cb(GtkObject *object, gpointer user_data);
    open, so these shouldn't be global. */
 static GtkWidget *filt_name_entry;
 static GtkWidget *filt_text_entry;
+static GtkWidget *disabled_cb;
 
 
 static void
@@ -110,11 +114,16 @@ edit_color_filter_dialog(GtkWidget *color_filters,
     GtkWidget *add_expression_bt;
     GtkWidget *color_filter_text;
 
+    GtkWidget *settings_hbox;
+
     GtkWidget *colorize_fr;
     GtkWidget *colorize_hbox;
     GtkWidget *colorize_filter_fg;
     GtkWidget *colorize_filter_bg;
 
+    GtkWidget *status_fr;
+    GtkWidget *status_vbox;
+
     GtkWidget *bbox;
     GtkWidget *edit_color_filter_ok;
     GtkWidget *edit_color_filter_cancel;
@@ -128,7 +137,7 @@ edit_color_filter_dialog(GtkWidget *color_filters,
     model = gtk_tree_view_get_model(GTK_TREE_VIEW(color_filters));
 
     gtk_tree_model_iter_nth_child(model, &iter, NULL, row_selected);
-    gtk_tree_model_get(model, &iter, 4, &colorf, -1);
+    gtk_tree_model_get(model, &iter, 5, &colorf, -1);
 
 #else
     colorf = gtk_clist_get_row_data(GTK_CLIST(color_filters), row_selected);
@@ -203,9 +212,13 @@ edit_color_filter_dialog(GtkWidget *color_filters,
     /* Show the (in)validity of the default filter string */
     filter_te_syntax_check_cb(filt_text_entry);
 
+    /* settings-hbox for "choose color frame" and "status frame" */
+    settings_hbox = gtk_hbox_new (FALSE, 0);
+    gtk_box_pack_start (GTK_BOX (dialog_vbox), settings_hbox, FALSE, FALSE, 0);
+
     /* choose color frame */
     colorize_fr = gtk_frame_new("Display Colors");
-    gtk_box_pack_start (GTK_BOX (dialog_vbox), colorize_fr, FALSE, FALSE, 0);
+    gtk_box_pack_start (GTK_BOX (settings_hbox), colorize_fr, TRUE, TRUE, 0);
 
     colorize_hbox = gtk_hbox_new (FALSE, 0);
     gtk_container_set_border_width  (GTK_CONTAINER (colorize_hbox), 5);
@@ -219,7 +232,19 @@ edit_color_filter_dialog(GtkWidget *color_filters,
     gtk_box_pack_start (GTK_BOX (colorize_hbox), colorize_filter_bg, TRUE, FALSE, 0);
     gtk_tooltips_set_tip (tooltips, colorize_filter_bg, ("Select background color for data display"), NULL);
 
+    /* status frame */
+    status_fr = gtk_frame_new("Status");
+    gtk_box_pack_start (GTK_BOX (settings_hbox), status_fr, TRUE, TRUE, 0);
+
+    status_vbox = gtk_vbox_new (FALSE, 0);
+    gtk_container_set_border_width  (GTK_CONTAINER (status_vbox), 5);
+    gtk_container_add(GTK_CONTAINER(status_fr), status_vbox);
 
+    disabled_cb = gtk_check_button_new_with_label("Disabled");
+    gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(disabled_cb), colorf->disabled);
+    gtk_box_pack_start (GTK_BOX (status_vbox), disabled_cb, TRUE, FALSE, 0);
+    gtk_tooltips_set_tip (tooltips, disabled_cb, ("Color rule won't be checked if this box is selected"), NULL);
+    
     /* button box */
     bbox = dlg_button_row_new(GTK_STOCK_OK, GTK_STOCK_CANCEL, NULL);
        gtk_box_pack_start(GTK_BOX(dialog_vbox), bbox, FALSE, FALSE, 0);
@@ -240,6 +265,8 @@ edit_color_filter_dialog(GtkWidget *color_filters,
     SIGNAL_CONNECT(colorize_filter_fg, "clicked", edit_color_filter_fg_cb, NULL);
     OBJECT_SET_DATA(colorize_filter_bg, COLOR_FILTER, colorf);
     SIGNAL_CONNECT(colorize_filter_bg, "clicked", edit_color_filter_bg_cb, NULL);
+    OBJECT_SET_DATA(disabled_cb, COLOR_FILTER, colorf);
+/*    SIGNAL_CONNECT(disabled_cb, "clicked", edit_disabled_cb_cb, NULL);*/
     OBJECT_SET_DATA(edit_color_filter_ok, COLOR_FILTERS_CL, color_filters);
     OBJECT_SET_DATA(edit_color_filter_ok, COLOR_FILTER, colorf);
     SIGNAL_CONNECT(edit_color_filter_ok, "clicked", edit_color_filter_ok_cb, edit_dialog);
@@ -331,6 +358,21 @@ edit_color_filter_bg_cb                (GtkButton       *button,
   }
 }
 
+/* Toggle the disabled flag */
+/*
+static void
+edit_disabled_cb_cb                   (GtkButton       *button,
+                                        gpointer         user_data _U_)
+{
+  color_filter_t *colorf;
+
+  colorf = (color_filter_t *)OBJECT_GET_DATA(button, COLOR_FILTER);
+  colorf->disabled = GTK_TOGGLE_BUTTON (button)->active;
+
+  printf("Colorfilter %s is now %s\n",colorf->filter_name,colorf->disabled?"disabled":"enabled");
+}
+*/
+
 /* accept color (and potential content) change */
 static void
 edit_color_filter_ok_cb                (GtkButton       *button,
@@ -342,6 +384,7 @@ edit_color_filter_ok_cb                (GtkButton       *button,
     GdkColor        new_bg_color;
     gchar          *filter_name;
     gchar          *filter_text;
+    gboolean        filter_disabled;
     color_filter_t *colorf;
     dfilter_t      *compiled_filter;
     GtkWidget      *color_filters;
@@ -359,6 +402,7 @@ edit_color_filter_ok_cb                (GtkButton       *button,
 
     filter_name = g_strdup(gtk_entry_get_text(GTK_ENTRY(filt_name_entry)));
     filter_text = g_strdup(gtk_entry_get_text(GTK_ENTRY(filt_text_entry)));
+    filter_disabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(disabled_cb));
 
     if(strchr(filter_name,'@') || strchr(filter_text,'@')){
         simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
@@ -384,13 +428,20 @@ edit_color_filter_ok_cb                (GtkButton       *button,
         if (colorf->filter_text != NULL)
             g_free(colorf->filter_text);
         colorf->filter_text = filter_text;
+       colorf->disabled = filter_disabled;
         gdkcolor_to_color_t(&colorf->fg_color, &new_fg_color);
         gdkcolor_to_color_t(&colorf->bg_color, &new_bg_color);
 #if GTK_MAJOR_VERSION < 2
-        gtk_clist_set_foreground(GTK_CLIST(color_filters), row_selected,
-                                 &new_fg_color);
-        gtk_clist_set_background(GTK_CLIST(color_filters), row_selected,
-                                 &new_bg_color);
+
+       /* XXX Using light-gray on white for disabled coloring-rules is a
+        * workaround to using strikethrough as I don't know how to set
+        * text to strikethrough in GTK1. This needs to be changed to
+        * keep the GTK1 and GTK2 version simular
+        */
+       gtk_clist_set_foreground(GTK_CLIST(color_filters), row_selected,
+                               filter_disabled ? &LTGREY : &new_fg_color);
+       gtk_clist_set_background(GTK_CLIST(color_filters), row_selected,
+                               filter_disabled ? &WHITE : &new_bg_color);
 #else
         g_snprintf(fg_str, 14, "#%04X%04X%04X",
                 new_fg_color.red, new_fg_color.green, new_fg_color.blue);
@@ -399,7 +450,8 @@ edit_color_filter_ok_cb                (GtkButton       *button,
         model = gtk_tree_view_get_model(GTK_TREE_VIEW(color_filters));
         gtk_tree_model_iter_nth_child(model, &iter, NULL, row_selected);
         gtk_list_store_set(GTK_LIST_STORE(model), &iter, 0, filter_name,
-                           1, filter_text, 2, fg_str, 3, bg_str, -1);
+                           1, filter_text, 2, fg_str, 3, bg_str,
+                          4, filter_disabled, -1);
 #endif
         if(colorf->c_colorfilter != NULL)
             dfilter_free(colorf->c_colorfilter);
index 48cfdbb..872a16a 100644 (file)
@@ -39,6 +39,7 @@ static GdkColormap*   sys_cmap;
 static GdkColormap*    our_cmap = NULL;
 
 GdkColor       WHITE = { 0, 65535, 65535, 65535 };
+GdkColor       LTGREY = { 0, 57343, 57343, 57343 };
 GdkColor       BLACK = { 0, 0, 0, 0 };
 
 /* Initialize the colors */
index 6738945..8445611 100644 (file)
@@ -31,6 +31,9 @@
 /** The color white. */
 extern GdkColor WHITE;
 
+/** The color light-grey. */
+extern GdkColor LTGREY;
+
 /** The color black. */
 extern GdkColor BLACK;
 
index 45a089e..32dc95b 100644 (file)
@@ -220,6 +220,8 @@ gtk_signal_emit_stop_by_name(GTK_OBJECT(widget), name)
 #define WIRESHARK_STOCK_FILE_SET_NEXT            "Next File"
 #define WIRESHARK_STOCK_FILE_SET_PREVIOUS        "Previous File"
 #define WIRESHARK_STOCK_FILTER_OUT_STREAM        "Filter Out This Stream"
+#define WIRESHARK_STOCK_ENABLE                   "Enable"
+#define WIRESHARK_STOCK_DISABLE                  "Disable"
 
 /** Create a stock button. Will create a "normal" button for GTK1.
  *
@@ -355,6 +357,8 @@ g_signal_stop_emission_by_name(G_OBJECT(widget), name)
 #define WIRESHARK_STOCK_LABEL_FILE_SET_NEXT            "Next File"
 #define WIRESHARK_STOCK_LABEL_FILE_SET_PREVIOUS        "Previous File"
 #define WIRESHARK_STOCK_LABEL_FILTER_OUT_STREAM        "Filter Out This Stream"
+#define WIRESHARK_STOCK_LABEL_ENABLE                   "Enable"
+#define WIRESHARK_STOCK_LABEL_DISABLE                  "Disable"
 
 #ifdef HAVE_LIBPCAP
 #define WIRESHARK_STOCK_CAPTURE_INTERFACES       "Wireshark_Stock_CaptureInterfaces"
@@ -395,6 +399,8 @@ g_signal_stop_emission_by_name(G_OBJECT(widget), name)
 #define WIRESHARK_STOCK_FILE_SET_NEXT            "Wireshark_Stock_File_Set_Next"
 #define WIRESHARK_STOCK_FILE_SET_PREVIOUS        "Wireshark_Stock_File_Set_Previous"
 #define WIRESHARK_STOCK_FILTER_OUT_STREAM        "Wireshark_Stock_Filter_Out_This_Stream"
+#define WIRESHARK_STOCK_ENABLE                   "Wireshark_Stock_Enable"
+#define WIRESHARK_STOCK_DISABLE                  "Wireshark_Stock_Disable"
 
 #define BUTTON_NEW_FROM_STOCK(stock_id) \
 gtk_button_new_from_stock(stock_id);
index 7d18e94..4f025d9 100644 (file)
 #include "../image/toolbar/file_set_list_16.xpm"
 #include "../image/toolbar/file_set_next_16.xpm"
 #include "../image/toolbar/file_set_previous_16.xpm"
+#include "../image/toolbar/stock_close_24.xpm"
 #endif
 
 
@@ -219,7 +220,9 @@ static void wireshark_stock_icons(void) {
         { WIRESHARK_STOCK_FILE_SET_LIST,         WIRESHARK_STOCK_LABEL_FILE_SET_LIST,         0, 0, NULL },
         { WIRESHARK_STOCK_FILE_SET_NEXT,         WIRESHARK_STOCK_LABEL_FILE_SET_NEXT,         0, 0, NULL },
         { WIRESHARK_STOCK_FILE_SET_PREVIOUS,     WIRESHARK_STOCK_LABEL_FILE_SET_PREVIOUS,     0, 0, NULL },
-        { WIRESHARK_STOCK_FILTER_OUT_STREAM,     WIRESHARK_STOCK_LABEL_FILTER_OUT_STREAM,     0, 0, NULL }
+        { WIRESHARK_STOCK_FILTER_OUT_STREAM,     WIRESHARK_STOCK_LABEL_FILTER_OUT_STREAM,     0, 0, NULL },
+        { WIRESHARK_STOCK_ENABLE,                WIRESHARK_STOCK_LABEL_ENABLE,                0, 0, NULL },
+        { WIRESHARK_STOCK_DISABLE,               WIRESHARK_STOCK_LABEL_DISABLE,               0, 0, NULL }
     };
 
     static const stock_pixmap_t pixmaps[] = {
@@ -260,6 +263,8 @@ static void wireshark_stock_icons(void) {
         { WIRESHARK_STOCK_FILE_SET_NEXT,         file_set_next_16_xpm},
         { WIRESHARK_STOCK_FILE_SET_PREVIOUS,     file_set_previous_16_xpm},
         { WIRESHARK_STOCK_FILTER_OUT_STREAM,     display_filter_24_xpm},
+        { WIRESHARK_STOCK_ENABLE,                checkbox_16_xpm},
+        { WIRESHARK_STOCK_DISABLE,               stock_close_24_xpm},
         { NULL, NULL }
     };