add a new checkitem "Colorize Packet List" into the View menu
authorulfl <ulfl@f5534014-38df-0310-8fa8-9805f1628bb7>
Sun, 27 Mar 2005 02:19:51 +0000 (02:19 +0000)
committerulfl <ulfl@f5534014-38df-0310-8fa8-9805f1628bb7>
Sun, 27 Mar 2005 02:19:51 +0000 (02:19 +0000)
keep it's setting in the recent file

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

color_filters.c
color_filters.h
gtk/main.c
gtk/menu.c
gtk/recent.c
gtk/recent.h

index cfa0e602df5c2474fd852b54f8ecfb902c3c1f15..ef72946dcd409a32dd77e799d27110fd80f2d1c9 100644 (file)
@@ -51,6 +51,9 @@ static gboolean read_global_filters(void);
 GSList *color_filter_list = NULL;
 GSList *removed_filter_list = NULL;
 
+/* Color Filters can en-/disabled. */
+gboolean filters_enabled = TRUE;
+
 /* Remove the specified filter from the list of existing color filters,
  * and add it to the list of removed color filters.
  * This way, unmarking and marking a packet which matches a now removed
@@ -140,7 +143,13 @@ prime_edt(gpointer data, gpointer user_data)
 gboolean 
 color_filters_used(void)
 {
-    return color_filter_list != NULL;
+    return color_filter_list != NULL && filters_enabled;
+}
+
+void
+color_filters_enable(gboolean enable)
+{
+    filters_enabled = enable;
 }
 
 
index 097c0757c55ab9965b16e32f396ce7fa8ebb3dda..46646d05b6f885adf4df36a3580416699f2fe154 100644 (file)
@@ -84,6 +84,13 @@ void color_filters_prime_edt(epan_dissect_t *edt);
  */
 gboolean color_filters_used(void);
 
+/** En-/disable color filters
+ *
+ * @param enable TRUE to enable (default)
+ */
+void
+color_filters_enable(gboolean enable);
+
 /** Colorize a specific packet.
  *
  * @param row the row in the packet list
index 293bc0b4779a3b71976885139a4c054187a70493..327f257a2140b85da67e012a6d7f1c08d8a18153 100644 (file)
@@ -2250,6 +2250,7 @@ main(int argc, char *argv[])
 
   /* Read the recent file, as we have the gui now ready for it. */
   read_recent(&rf_path, &rf_open_errno);
+  color_filters_enable(recent.packet_list_colorize);
 
   /* rearrange all the widgets as we now have the recent settings for this */
   main_widgets_rearrange();
index 61bc3a68c86070b5c213759d9883e178dc7f5616..ced5f3b8ef98f75161986bb6435fd71d69b7d703 100644 (file)
@@ -75,6 +75,7 @@
 #include "hostlist_table.h"
 #include "simple_dialog.h"
 #include "packet_history.h"
+#include "color_filters.h"
 
 GtkWidget *popup_menu_object;
 
@@ -117,6 +118,7 @@ static void name_resolution_transport_cb(GtkWidget *w _U_, gpointer d _U_);
 #ifdef HAVE_LIBPCAP
 static void auto_scroll_live_cb(GtkWidget *w _U_, gpointer d _U_);
 #endif
+static void colorize_cb(GtkWidget *w _U_, gpointer d _U_);
 
 /* This is the GtkItemFactoryEntry structure used to generate new menus.
        Item 1: The menu path. The letter after the underscore indicates an
@@ -235,6 +237,7 @@ static GtkItemFactoryEntry menu_items[] =
     ITEM_FACTORY_ENTRY("/View/Packet _List", NULL, packet_list_show_cb, 0, "<CheckItem>", NULL),
     ITEM_FACTORY_ENTRY("/View/Packet _Details", NULL, tree_view_show_cb, 0, "<CheckItem>", NULL),
     ITEM_FACTORY_ENTRY("/View/Packet _Bytes", NULL, byte_view_show_cb, 0, "<CheckItem>", NULL),
+    ITEM_FACTORY_ENTRY("/View/Colorize Packet List", NULL, colorize_cb, 0, "<CheckItem>", NULL),
     ITEM_FACTORY_ENTRY("/View/<separator>", NULL, NULL, 0, "<Separator>", NULL),
     ITEM_FACTORY_ENTRY("/View/_Time Display Format", NULL, NULL, 0, "<Branch>", NULL),
     ITEM_FACTORY_ENTRY("/View/Time Display Format/Time of Day", NULL, timestamp_absolute_cb, 
@@ -1336,6 +1339,14 @@ auto_scroll_live_cb(GtkWidget *w _U_, gpointer d _U_)
 }
 #endif
 
+static void 
+colorize_cb(GtkWidget *w _U_, gpointer d _U_)
+{
+    recent.packet_list_colorize = GTK_CHECK_MENU_ITEM(w)->active;
+    color_filters_enable(recent.packet_list_colorize);
+    cf_colorize_packets(&cfile);
+}
+
 /* the recent file read has finished, update the menu corresponding */
 void
 menu_recent_read_finished(void) {
@@ -1359,6 +1370,9 @@ menu_recent_read_finished(void) {
     menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Packet Bytes");
     gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), recent.byte_view_show);
 
+    menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Colorize Packet List");
+    gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), recent.packet_list_colorize);
+
     menu_name_resolution_changed();
 
 #ifdef HAVE_LIBPCAP
index 5e200f8e961c12c35e2161799aecdf53b586496d..1c772e6d1cb4cfae574d7807570dd23b362f9167 100644 (file)
@@ -49,6 +49,7 @@
 #define RECENT_KEY_TREE_VIEW_SHOW           "gui.tree_view_show"
 #define RECENT_KEY_BYTE_VIEW_SHOW           "gui.byte_view_show"
 #define RECENT_KEY_STATUSBAR_SHOW           "gui.statusbar_show"
+#define RECENT_KEY_PACKET_LIST_COLORIZE     "gui.packet_list_colorize"
 #define RECENT_GUI_TIME_FORMAT              "gui.time_format"
 #define RECENT_GUI_ZOOM_LEVEL               "gui.zoom_level"
 #define RECENT_GUI_GEOMETRY_MAIN_X          "gui.geometry_main_x"
@@ -179,6 +180,11 @@ write_recent(void)
   fprintf(rf, RECENT_KEY_STATUSBAR_SHOW ": %s\n",
                  recent.statusbar_show == TRUE ? "TRUE" : "FALSE");
 
+  fprintf(rf, "\n# Packet list colorize (hide).\n");
+  fprintf(rf, "# TRUE or FALSE (case-insensitive).\n");
+  fprintf(rf, RECENT_KEY_PACKET_LIST_COLORIZE ": %s\n",
+                 recent.packet_list_colorize == TRUE ? "TRUE" : "FALSE");
+
   fprintf(rf, "\n# Timestamp display format.\n");
   fprintf(rf, "# One of: RELATIVE, ABSOLUTE, ABSOLUTE_WITH_DATE, DELTA\n");
   fprintf(rf, RECENT_GUI_TIME_FORMAT ": %s\n",
@@ -312,6 +318,13 @@ read_set_recent_pair(gchar *key, gchar *value)
     else {
         recent.statusbar_show = FALSE;
     }
+  } else if (strcmp(key, RECENT_KEY_PACKET_LIST_COLORIZE) == 0) {
+    if (strcasecmp(value, "true") == 0) {
+        recent.packet_list_colorize = TRUE;
+    }
+    else {
+        recent.packet_list_colorize = FALSE;
+    }
   } else if (strcmp(key, RECENT_GUI_TIME_FORMAT) == 0) {
     recent.gui_time_format =
        find_index_from_string_array(value, ts_type_text, TS_RELATIVE);
@@ -405,6 +418,7 @@ read_recent(char **rf_path_return, int *rf_errno_return)
   recent.tree_view_show         = TRUE;
   recent.byte_view_show         = TRUE;
   recent.statusbar_show         = TRUE;
+  recent.packet_list_colorize   = TRUE;
   recent.gui_time_format        = TS_RELATIVE;
   recent.gui_zoom_level         = 0;
 
index f034962c35cc4d4cf6b3988ef726535fd0a1ec7f..109dda478f959e23c7655ba2d693554a1ef6013b 100644 (file)
@@ -47,6 +47,7 @@ typedef struct recent_settings_tag {
     gboolean    tree_view_show;
     gboolean    byte_view_show;
     gboolean    statusbar_show;
+    gboolean    packet_list_colorize;
     gint        gui_time_format;
     gint        gui_zoom_level;