various (huge) code cleanup incl. splitting of the coloring dialog and the actual...
[metze/wireshark/wip.git] / color_filters.h
1 /* color_filters.h
2  * Definitions for color filters
3  *
4  * $Id$
5  *
6  * Wireshark - Network traffic analyzer
7  * By Gerald Combs <gerald@wireshark.org>
8  * Copyright 1998 Gerald Combs
9  *
10  * This program is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU General Public License
12  * as published by the Free Software Foundation; either version 2
13  * of the License, or (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
23  */
24 #ifndef  __COLOR_FILTERS_H__
25 #define  __COLOR_FILTERS_H__
26
27 /** @file
28  *  Color filters.
29  */
30
31 /* Data for a color filter. */
32 typedef struct _color_filter {
33         gchar     *filter_name;   /* name of the filter */
34         gchar     *filter_text;   /* text of the filter expression */
35         color_t    bg_color;      /* background color for packets that match */
36         color_t    fg_color;      /* foreground color for packets that match */
37         dfilter_t *c_colorfilter; /* compiled filter expression */
38         void      *edit_dialog;   /* if filter is being edited, dialog
39                                    * box for it */
40         gboolean    marked;         /* set if the filter is marked in the color dialog box */
41 } color_filter_t;
42
43 /* List of all color filters. */
44 extern GSList *color_filter_list;
45
46 /** Init the color filters. */
47 void color_filters_init(void);
48
49 /** Save filters in users filter file.
50  *
51  * @return TRUE if write succeeded
52  */
53 gboolean color_filters_write(void);
54
55 /** Delete users filter file and reload global filters.
56  *
57  * @return TRUE if write succeeded
58  */
59 gboolean color_filters_revert(void);
60
61 /** Load filters (import) from some other filter file.
62  *
63  * @param path the path to the filter file
64  * @param arg the color filter widget
65  * @return TRUE, if read succeeded
66  */
67 gboolean color_filters_import(gchar *path, gpointer arg);
68
69 /** Save filters (export) to some other filter file.
70  *
71  * @param path the path to the filter file
72  * @param only_marked TRUE if only the marked filters should be saved
73  * @return TRUE, if write succeeded
74  */
75 gboolean color_filters_export(gchar *path, gboolean only_marked);
76
77 /* Prime the epan_dissect_t with all the compiler
78  * color filters in 'color_filter_list'. 
79  *
80  * @param the epan dissector details
81  */
82 void color_filters_prime_edt(epan_dissect_t *edt);
83
84 /** Color filters currently used?
85  *
86  * @return TRUE, if filters are used
87  */
88 gboolean color_filters_used(void);
89
90 /** En-/disable color filters
91  *
92  * @param enable TRUE to enable (default)
93  */
94 void
95 color_filters_enable(gboolean enable);
96
97 /** Colorize a specific packet.
98  *
99  * @param row the row in the packet list
100  * @param edt the dissected packet
101  * @return the matching color filter or NULL
102  */
103 color_filter_t *
104 color_filters_colorize_packet(gint row, epan_dissect_t *edt);
105
106 /** Create a new color filter.
107  *
108  * @param name the name of the filter
109  * @param filter_string the filter string
110  * @param bg_color background color
111  * @param fg_color foreground color
112  * @return the new color filter
113  */
114 color_filter_t *color_filter_new(const gchar *name, const gchar *filter_string,
115     color_t *bg_color, color_t *fg_color);
116
117 /** Remove the color filter.
118  *
119  * @param colorf the color filter to be removed
120  */
121 void color_filter_remove(color_filter_t *colorf);
122
123 /** A color filter was added (from import).
124  *
125  * @param colorf the new color filter
126  * @param arg the color filter widget
127  */
128 void color_filter_add_cb (color_filter_t *colorf, gpointer arg);
129
130 #endif