name change
[obnox/wireshark/wip.git] / gtk / main.h
1 /* main.h
2  * Global defines, etc.
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
25 #ifndef __MAIN_H__
26 #define __MAIN_H__
27
28 #ifdef HAVE_CONFIG_H
29 #include "config.h"
30 #endif
31
32 #include "globals.h"
33
34 /** @defgroup main_window_group Main window
35  * The main window has the following submodules:
36    @dot
37   digraph main_dependencies {
38       node [shape=record, fontname=Helvetica, fontsize=10];
39       main [ label="main window" URL="\ref main.h"];
40       menu [ label="menubar" URL="\ref menu.h"];
41       toolbar [ label="toolbar" URL="\ref toolbar.h"];
42       packet_list [ label="packet list pane" URL="\ref packet_list.h"];
43       proto_draw [ label="packet details & bytes panes" URL="\ref proto_draw.h"];
44       recent [ label="recent user settings" URL="\ref recent.h"];
45       main -> menu [ arrowhead="open", style="solid" ];
46       main -> toolbar [ arrowhead="open", style="solid" ];
47       main -> packet_list [ arrowhead="open", style="solid" ];
48       main -> proto_draw [ arrowhead="open", style="solid" ];
49       main -> recent [ arrowhead="open", style="solid" ];
50   }
51   @enddot
52  */
53
54 /** @file
55  *  The main window, filter toolbar, program start/stop and a lot of other things
56  *  @ingroup main_window_group
57  *  @ingroup windows_group
58  */
59
60 /** Global compile time version string */
61 extern GString *comp_info_str;
62 /** Global runtime version string */
63 extern GString *runtime_info_str;
64
65 /** Global capture options type. */
66 typedef struct capture_options_tag * p_capture_options_t;
67 /** Pointer to global capture options. */
68 extern p_capture_options_t capture_opts;
69
70 extern void protect_thread_critical_region(void);
71 extern void unprotect_thread_critical_region(void);
72
73 /** User requested "Zoom In" by menu or toolbar.
74  *
75  * @param widget parent widget (unused)
76  * @param data unused
77  */
78 extern void view_zoom_in_cb(GtkWidget *widget, gpointer data);
79
80 /** User requested "Zoom Out" by menu or toolbar.
81  *
82  * @param widget parent widget (unused)
83  * @param data unused
84  */
85 extern void view_zoom_out_cb(GtkWidget *widget, gpointer data);
86
87 /** User requested "Zoom 100%" by menu or toolbar.
88  *
89  * @param widget parent widget (unused)
90  * @param data unused
91  */
92 extern void view_zoom_100_cb(GtkWidget *widget, gpointer data);
93
94 /** User requested "Protocol Info" by ptree context menu.
95  *
96  * @param widget parent widget (unused)
97  * @param data unused
98  */
99 extern void selected_ptree_info_cb(GtkWidget *widget, gpointer data);
100
101 /** User requested "Filter Reference" by ptree context menu.
102  *
103  * @param widget parent widget (unused)
104  * @param data unused
105  */
106 extern void selected_ptree_ref_cb(GtkWidget *widget, gpointer data);
107
108 /** "Apply as Filter" / "Prepare a Filter" action type. */
109 typedef enum {
110     MATCH_SELECTED_REPLACE, /**< "Selected" */
111     MATCH_SELECTED_AND,     /**< "and Selected" */
112     MATCH_SELECTED_OR,      /**< "or Selected" */
113     MATCH_SELECTED_NOT,     /**< "Not Selected" */
114     MATCH_SELECTED_AND_NOT, /**< "and not Selected" */
115     MATCH_SELECTED_OR_NOT   /**< "or not Selected" */
116 } MATCH_SELECTED_E;
117
118 /** mask MATCH_SELECTED_E values (internally used) */
119 #define MATCH_SELECTED_MASK         0x0ff
120
121 /** "bitwise or" this with MATCH_SELECTED_E value for instant apply instead of prepare only */
122 #define MATCH_SELECTED_APPLY_NOW    0x100
123
124 /** User highlited item in details window and then right clicked and selected the copy option 
125  *
126  * @param widget parent widget
127  * @param data parent widget
128  */
129 extern void copy_selected_plist_cb(GtkWidget *w _U_, gpointer data);
130
131 /** User requested one of "Apply as Filter" or "Prepare a Filter" functions 
132  *  by menu or context menu of protocol tree.
133  *
134  * @param widget parent widget
135  * @param data parent widget
136  * @param action the function to use
137  */
138 extern void match_selected_ptree_cb(GtkWidget *widget, gpointer data, MATCH_SELECTED_E action);
139
140 /** User requested one of "Apply as Filter" or "Prepare a Filter" functions
141  *  by context menu of packet list.
142  *
143  * @param widget parent widget (unused)
144  * @param data parent widget
145  * @param action the function to use
146  */
147 extern void match_selected_plist_cb(GtkWidget *widget, gpointer data, MATCH_SELECTED_E action);
148
149 /** User requested "Quit" by menu or toolbar.
150  *
151  * @param widget parent widget (unused)
152  * @param data unused
153  */
154 extern void file_quit_cmd_cb(GtkWidget *widget, gpointer data);
155
156 /** User requested "Print" by menu or toolbar.
157  *
158  * @param widget parent widget (unused)
159  * @param data unused
160  */
161 extern void file_print_cmd_cb(GtkWidget *widget, gpointer data);
162
163 /** User requested "Print" by packet list context menu.
164  *
165  * @param widget parent widget (unused)
166  * @param data unused
167  */
168 extern void file_print_selected_cmd_cb(GtkWidget *widget _U_, gpointer data _U_);
169
170 /** User requested "Export as Plain Text" by menu.
171  *
172  * @param widget parent widget (unused)
173  * @param data unused
174  */
175 extern void export_text_cmd_cb(GtkWidget *widget, gpointer data);
176
177 /** User requested "Export as Postscript" by menu.
178  *
179  * @param widget parent widget (unused)
180  * @param data unused
181  */
182 extern void export_ps_cmd_cb(GtkWidget *widget, gpointer data);
183
184 /** User requested "Export as PSML" by menu.
185  *
186  * @param widget parent widget (unused)
187  * @param data unused
188  */
189 extern void export_psml_cmd_cb(GtkWidget *widget, gpointer data);
190
191 /** User requested "Export as PDML" by menu.
192  *
193  * @param widget parent widget (unused)
194  * @param data unused
195  */
196 extern void export_pdml_cmd_cb(GtkWidget *widget, gpointer data);
197
198 /** User requested "Export as CSV" by menu.
199  *
200  * @param widget parent widget (unused)
201  * @param data unused
202  */
203 extern void export_csv_cmd_cb(GtkWidget *widget, gpointer data);
204
205 /** User requested "Expand Tree" by menu.
206  *
207  * @param widget parent widget (unused)
208  * @param data unused
209  */
210 extern void expand_tree_cb(GtkWidget *widget, gpointer data);
211
212 /** User requested "Expand All" by menu.
213  *
214  * @param widget parent widget (unused)
215  * @param data unused
216  */
217 extern void expand_all_cb(GtkWidget *widget, gpointer data);
218
219 /** User requested "Collapse All" by menu.
220  *
221  * @param widget parent widget (unused)
222  * @param data unused
223  */
224 extern void collapse_all_cb(GtkWidget *widget, gpointer data);
225
226 /** User requested "Resolve Name" by menu.
227  *
228  * @param widget parent widget (unused)
229  * @param data unused
230  */
231 extern void resolve_name_cb(GtkWidget *widget, gpointer data);
232
233 /** Action to take for reftime_frame_cb() */
234 typedef enum {
235     REFTIME_TOGGLE,     /**< toggle ref frame */
236     REFTIME_FIND_NEXT,  /**< find next ref frame */
237     REFTIME_FIND_PREV   /**< find previous ref frame */
238 } REFTIME_ACTION_E;
239
240 /** User requested one of the "Time Reference" functions by menu.
241  *
242  * @param widget parent widget (unused)
243  * @param data unused
244  * @param action the function to use
245  */
246 extern void reftime_frame_cb(GtkWidget *widget, gpointer data, REFTIME_ACTION_E action);
247
248 /** Add a display filter coming from the user's recent file to the dfilter combo box.
249  *
250  * @param dftext the filter string
251  */
252 extern gboolean dfilter_combo_add_recent(gchar *dftext);
253
254 /** Empty out the combobox entry field */
255 extern void dfilter_combo_add_empty(void);
256
257 /** Write all non empty display filters (until maximum count) 
258  *  of the combo box GList to the user's recent file.
259  *
260  * @param rf the recent file
261  */
262 extern void dfilter_recent_combo_write_all(FILE *rf);
263
264 /** Quit the program.
265  *
266  * @return TRUE, if a file read is in progress
267  */
268 extern gboolean main_do_quit(void);
269
270 /** Rearrange the main window widgets, user changed it's preferences. */
271 extern void main_widgets_rearrange(void);
272
273 /** Show or hide the main window widgets, user changed it's preferences. */
274 extern void main_widgets_show_or_hide(void);
275
276 /** Apply a new filter string. 
277  *  Call cf_filter_packets() and add this filter string to the recent filter list.
278  *
279  * @param cf the capture file
280  * @param dftext the new filter string
281  * @param force force the refiltering, even if filter string doesn't changed
282  * @return TRUE, if the filtering succeeded
283  */
284 extern gboolean main_filter_packets(capture_file *cf, const gchar *dftext,
285     gboolean force);
286
287 /** Init the drag-n-drop functionality.
288  *
289  * @param w the target widget for this dnd operations
290  */
291 extern void dnd_init(GtkWidget *w);
292
293 /** Open a new file coming from drag and drop.
294  * @param cf_names_freeme the selection data reported from GTK
295  */
296 extern void dnd_open_file_cmd(gchar *cf_names_freeme);
297
298 /** Update the packets statusbar to the current values. */
299 extern void packets_bar_update(void);
300
301 #ifdef _WIN32
302 /** Win32 only: Create a console. Beware: cannot be closed again. */
303 extern void create_console(void);
304 #endif
305
306 #endif /* __MAIN_H__ */