4 * $Id: menu.c,v 1.189 2004/05/04 20:04:26 guy Exp $
6 * Ethereal - Network traffic analyzer
7 * By Gerald Combs <gerald@ethereal.com>
8 * Copyright 1998 Gerald Combs
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.
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.
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.
36 #include <epan/packet.h>
37 #include <epan/resolv.h>
39 #include "capture_dlg.h"
40 #include "color_dlg.h"
41 #include "filter_prefs.h"
45 #include "summary_dlg.h"
46 #include "prefs_dlg.h"
47 #include "packet_win.h"
49 #include "follow_dlg.h"
50 #include "decode_as_dlg.h"
52 #include "supported_protos_dlg.h"
53 #include "proto_dlg.h"
54 #include "proto_hier_stats_dlg.h"
56 #include <epan/plugins.h>
57 #include <epan/epan_dissect.h>
58 #include "compat_macros.h"
60 #include "gtkglobals.h"
64 #include "../ipproto.h"
65 #include "packet_list.h"
68 #include "../ui_util.h"
69 #include "proto_draw.h"
70 #include "simple_dialog.h"
71 #include <epan/timestamp.h>
73 GtkWidget *popup_menu_object;
75 extern void savehex_cb(GtkWidget * w, gpointer data _U_);
76 extern void init_ett_notebook_cb(GtkWidget *w _U_, gpointer d _U_);
77 extern void init_hostlist_notebook_cb(GtkWidget *w _U_, gpointer d _U_);
80 clear_menu_recent_capture_file_cmd_cb(GtkWidget *w, gpointer unused _U_);
82 typedef struct _menu_item {
86 GtkItemFactoryCallback callback;
87 gpointer callback_data;
88 gboolean (*selected_packet_enabled)(frame_data *, epan_dissect_t *);
89 gboolean (*selected_tree_row_enabled)(field_info *);
93 static GList *tap_menu_tree_root = NULL;
96 merge_all_tap_menus(GList *node);
98 #define GTK_MENU_FUNC(a) ((GtkItemFactoryCallback)(a))
100 static void menus_init(void);
101 static void set_menu_sensitivity (GtkItemFactory *, const gchar *, gint);
102 static void main_toolbar_show_cb(GtkWidget *w _U_, gpointer d _U_);
103 static void filter_toolbar_show_cb(GtkWidget *w _U_, gpointer d _U_);
104 static void packet_list_show_cb(GtkWidget *w _U_, gpointer d _U_);
105 static void tree_view_show_cb(GtkWidget *w _U_, gpointer d _U_);
106 static void byte_view_show_cb(GtkWidget *w _U_, gpointer d _U_);
107 static void statusbar_show_cb(GtkWidget *w _U_, gpointer d _U_);
108 static void timestamp_absolute_cb(GtkWidget *w _U_, gpointer d _U_);
109 static void timestamp_absolute_date_cb(GtkWidget *w _U_, gpointer d _U_);
110 static void timestamp_relative_cb(GtkWidget *w _U_, gpointer d _U_);
111 static void timestamp_delta_cb(GtkWidget *w _U_, gpointer d _U_);
112 static void name_resolution_mac_cb(GtkWidget *w _U_, gpointer d _U_);
113 static void name_resolution_network_cb(GtkWidget *w _U_, gpointer d _U_);
114 static void name_resolution_transport_cb(GtkWidget *w _U_, gpointer d _U_);
116 static void auto_scroll_live_cb(GtkWidget *w _U_, gpointer d _U_);
119 /* This is the GtkItemFactoryEntry structure used to generate new menus.
120 Item 1: The menu path. The letter after the underscore indicates an
121 accelerator key once the menu is open.
122 Item 2: The accelerator key for the entry
123 Item 3: The callback function.
124 Item 4: The callback action. This changes the parameters with
125 which the function is called. The default is 0.
126 Item 5: The item type, used to define what kind of an item it is.
127 Here are the possible values:
131 "<Title>" -> create a title item
132 "<Item>" -> create a simple item
133 "<ImageItem>" -> create an item holding an image (gtk2)
134 "<StockItem>" -> create an item holding a stock image (gtk2)
135 "<CheckItem>" -> create a check item
136 "<ToggleItem>" -> create a toggle item
137 "<RadioItem>" -> create a radio item
138 <path> -> path of a radio item to link against
139 "<Separator>" -> create a separator
140 "<Tearoff>" -> create a tearoff separator (gtk2)
141 "<Branch>" -> create an item to hold sub items (optional)
142 "<LastBranch>" -> create a right justified branch
143 Item 6: extra data needed for ImageItem and StockItem (gtk2)
147 static GtkItemFactoryEntry menu_items[] =
149 ITEM_FACTORY_ENTRY("/_File", NULL, NULL, 0, "<Branch>", NULL),
150 ITEM_FACTORY_STOCK_ENTRY("/File/_Open...", "<control>O", file_open_cmd_cb,
152 ITEM_FACTORY_ENTRY("/File/Open _Recent", NULL, NULL, 0, "<Branch>", NULL),
153 ITEM_FACTORY_STOCK_ENTRY("/File/_Close", "<control>W", file_close_cmd_cb,
155 ITEM_FACTORY_ENTRY("/File/<separator>", NULL, NULL, 0, "<Separator>", NULL),
156 ITEM_FACTORY_STOCK_ENTRY("/File/_Save", "<control>S", file_save_cmd_cb,
158 ITEM_FACTORY_STOCK_ENTRY("/File/Save _As...", "<shift><control>S", file_save_as_cmd_cb,
159 0, GTK_STOCK_SAVE_AS),
160 ITEM_FACTORY_ENTRY("/File/<separator>", NULL, NULL, 0, "<Separator>", NULL),
161 ITEM_FACTORY_ENTRY("/File/_Export", NULL, NULL, 0, "<Branch>", NULL),
162 ITEM_FACTORY_ENTRY("/File/Export/as \"Plain _Text\" file...", NULL, export_text_cmd_cb,
164 ITEM_FACTORY_ENTRY("/File/Export/as \"_PostScript\" file...", NULL, export_ps_cmd_cb,
166 ITEM_FACTORY_ENTRY("/File/Export/as XML - \"P_SML\" (packet summary) file...", NULL, export_psml_cmd_cb,
168 ITEM_FACTORY_ENTRY("/File/Export/as XML - \"P_DML\" (packet details) file...", NULL, export_pdml_cmd_cb,
170 ITEM_FACTORY_ENTRY("/File/Export/<separator>", NULL, NULL, 0, "<Separator>", NULL),
171 ITEM_FACTORY_ENTRY("/File/Export/Selected Packet _Bytes...", "<control>H", savehex_cb,
173 ITEM_FACTORY_ENTRY("/File/<separator>", NULL, NULL, 0, "<Separator>", NULL),
174 ITEM_FACTORY_STOCK_ENTRY("/File/_Print...", "<control>P", file_print_cmd_cb,
176 ITEM_FACTORY_ENTRY("/File/<separator>", NULL, NULL, 0, "<Separator>", NULL),
177 ITEM_FACTORY_STOCK_ENTRY("/File/_Quit", "<control>Q", file_quit_cmd_cb,
179 ITEM_FACTORY_ENTRY("/_Edit", NULL, NULL, 0, "<Branch>", NULL),
181 /* Un-#if this when we actually implement Cut/Copy/Paste. */
182 ITEM_FACTORY_STOCK_ENTRY("/Edit/Cut", "<control>X", NULL,
184 ITEM_FACTORY_STOCK_ENTRY("/Edit/Copy", "<control>C", NULL,
186 ITEM_FACTORY_STOCK_ENTRY("/Edit/Paste", "<control>V", NULL,
188 ITEM_FACTORY_ENTRY("/Edit/<separator>", NULL, NULL, 0, "<Separator>"),
190 ITEM_FACTORY_STOCK_ENTRY("/Edit/_Find Packet...", "<control>F",
191 find_frame_cb, 0, GTK_STOCK_FIND),
192 ITEM_FACTORY_STOCK_ENTRY("/Edit/Find Ne_xt", "<control>N", find_next_cb,
193 0, GTK_STOCK_GO_FORWARD),
194 ITEM_FACTORY_STOCK_ENTRY("/Edit/Find Pre_vious", "<control>B",
195 find_previous_cb, 0, GTK_STOCK_GO_BACK),
196 ITEM_FACTORY_ENTRY("/Edit/<separator>", NULL, NULL, 0, "<Separator>", NULL),
197 ITEM_FACTORY_ENTRY("/Edit/_Time Reference", NULL, NULL, 0, "<Branch>", NULL),
198 ITEM_FACTORY_ENTRY("/Edit/Time Reference/Set Time Reference (toggle)", "<control>T", reftime_frame_cb, 0, NULL, NULL),
199 ITEM_FACTORY_ENTRY("/Edit/Time Reference/Find Next", NULL, reftime_frame_cb, 1, NULL, NULL),
200 ITEM_FACTORY_ENTRY("/Edit/Time Reference/Find Previous", NULL, reftime_frame_cb, 2, NULL, NULL),
201 ITEM_FACTORY_ENTRY("/Edit/_Mark Packet", "<control>M", mark_frame_cb,
203 ITEM_FACTORY_ENTRY("/Edit/Mark _All Packets", NULL, mark_all_frames_cb,
205 ITEM_FACTORY_ENTRY("/Edit/_Unmark All Packets", NULL, unmark_all_frames_cb,
207 ITEM_FACTORY_ENTRY("/Edit/<separator>", NULL, NULL, 0, "<Separator>", NULL),
208 ITEM_FACTORY_STOCK_ENTRY("/Edit/_Preferences...", "<shift><control>P", prefs_cb,
209 0, GTK_STOCK_PREFERENCES),
210 ITEM_FACTORY_ENTRY("/_View", NULL, NULL, 0, "<Branch>", NULL),
211 ITEM_FACTORY_ENTRY("/View/_Main Toolbar", NULL, main_toolbar_show_cb, 0, "<CheckItem>", NULL),
212 ITEM_FACTORY_ENTRY("/View/_Filter Toolbar", NULL, filter_toolbar_show_cb, 0, "<CheckItem>", NULL),
213 ITEM_FACTORY_ENTRY("/View/_Statusbar", NULL, statusbar_show_cb, 0, "<CheckItem>", NULL),
214 ITEM_FACTORY_ENTRY("/View/<separator>", NULL, NULL, 0, "<Separator>", NULL),
215 ITEM_FACTORY_ENTRY("/View/Packet _List", NULL, packet_list_show_cb, 0, "<CheckItem>", NULL),
216 ITEM_FACTORY_ENTRY("/View/Packet _Details", NULL, tree_view_show_cb, 0, "<CheckItem>", NULL),
217 ITEM_FACTORY_ENTRY("/View/Packet _Bytes", NULL, byte_view_show_cb, 0, "<CheckItem>", NULL),
218 ITEM_FACTORY_ENTRY("/View/<separator>", NULL, NULL, 0, "<Separator>", NULL),
219 ITEM_FACTORY_ENTRY("/View/_Time Display Format", NULL, NULL, 0, "<Branch>", NULL),
220 ITEM_FACTORY_ENTRY("/View/Time Display Format/Time of Day", NULL, timestamp_absolute_cb,
221 0, "<RadioItem>", NULL),
222 ITEM_FACTORY_ENTRY("/View/Time Display Format/Date and Time of Day", NULL, timestamp_absolute_date_cb,
223 0, "/View/Time Display Format/Time of Day", NULL),
224 ITEM_FACTORY_ENTRY("/View/Time Display Format/Seconds Since Beginning of Capture", NULL, timestamp_relative_cb,
225 0, "/View/Time Display Format/Time of Day", NULL),
226 ITEM_FACTORY_ENTRY("/View/Time Display Format/Seconds Since Previous Packet", NULL, timestamp_delta_cb,
227 0, "/View/Time Display Format/Time of Day", NULL),
228 ITEM_FACTORY_ENTRY("/View/Name Resol_ution", NULL, NULL, 0, "<Branch>", NULL),
229 ITEM_FACTORY_ENTRY("/View/Name Resolution/Enable for _MAC Layer", NULL, name_resolution_mac_cb, 0, "<CheckItem>", NULL),
230 ITEM_FACTORY_ENTRY("/View/Name Resolution/Enable for _Network Layer", NULL, name_resolution_network_cb, 0, "<CheckItem>", NULL),
231 ITEM_FACTORY_ENTRY("/View/Name Resolution/Enable for _Transport Layer", NULL, name_resolution_transport_cb, 0, "<CheckItem>", NULL),
233 ITEM_FACTORY_ENTRY("/View/Auto Scroll in Li_ve Capture", NULL, auto_scroll_live_cb, 0, "<CheckItem>", NULL),
235 ITEM_FACTORY_ENTRY("/View/<separator>", NULL, NULL, 0, "<Separator>", NULL),
236 ITEM_FACTORY_STOCK_ENTRY("/View/_Zoom In", "<control>plus", view_zoom_in_cb,
237 0, GTK_STOCK_ZOOM_IN),
238 ITEM_FACTORY_STOCK_ENTRY("/View/Zoom _Out", "<control>minus", view_zoom_out_cb,
239 0, GTK_STOCK_ZOOM_OUT),
240 ITEM_FACTORY_STOCK_ENTRY("/View/_Normal Size", "<control>equal", view_zoom_100_cb,
241 0, GTK_STOCK_ZOOM_100),
242 ITEM_FACTORY_ENTRY("/View/<separator>", NULL, NULL, 0, "<Separator>", NULL),
243 ITEM_FACTORY_ENTRY("/View/Collapse _All", NULL, collapse_all_cb,
245 ITEM_FACTORY_ENTRY("/View/_Expand All", NULL, expand_all_cb,
247 ITEM_FACTORY_ENTRY("/View/Expand Tree", NULL, expand_tree_cb, 0, NULL, NULL),
248 ITEM_FACTORY_ENTRY("/View/<separator>", NULL, NULL, 0, "<Separator>", NULL),
249 ITEM_FACTORY_STOCK_ENTRY("/View/_Coloring Rules...", NULL, color_display_cb,
250 0, GTK_STOCK_SELECT_COLOR),
251 ITEM_FACTORY_ENTRY("/View/<separator>", NULL, NULL, 0, "<Separator>", NULL),
252 ITEM_FACTORY_ENTRY("/View/Show Packet in New _Window", NULL,
253 new_window_cb, 0, NULL, NULL),
254 ITEM_FACTORY_STOCK_ENTRY("/View/_Reload", "<control>R", file_reload_cmd_cb,
255 0, GTK_STOCK_REFRESH),
256 ITEM_FACTORY_ENTRY("/_Go", NULL, NULL, 0, "<Branch>", NULL),
257 ITEM_FACTORY_STOCK_ENTRY("/Go/_Go to Packet...", "<control>G",
258 goto_frame_cb, 0, GTK_STOCK_JUMP_TO),
259 ITEM_FACTORY_ENTRY("/Go/Go to _Corresponding Packet", NULL, goto_framenum_cb,
261 ITEM_FACTORY_ENTRY("/Go/<separator>", NULL, NULL, 0, "<Separator>", NULL),
262 ITEM_FACTORY_STOCK_ENTRY("/Go/_First Packet", NULL,
263 goto_top_frame_cb, 0, GTK_STOCK_GOTO_TOP),
264 ITEM_FACTORY_STOCK_ENTRY("/Go/_Last Packet", NULL,
265 goto_bottom_frame_cb, 0, GTK_STOCK_GOTO_BOTTOM),
267 ITEM_FACTORY_ENTRY("/_Capture", NULL, NULL, 0, "<Branch>", NULL),
268 ITEM_FACTORY_STOCK_ENTRY("/Capture/_Start...", "<control>K",
269 capture_prep_cb, 0, ETHEREAL_STOCK_CAPTURE_START),
270 ITEM_FACTORY_STOCK_ENTRY("/Capture/S_top", "<control>E", capture_stop_cb,
272 ITEM_FACTORY_STOCK_ENTRY("/Capture/_Capture Filters...", NULL, cfilter_dialog_cb,
273 0, ETHEREAL_STOCK_CAPTURE_FILTER),
274 #endif /* HAVE_LIBPCAP */
275 ITEM_FACTORY_ENTRY("/_Analyze", NULL, NULL, 0, "<Branch>", NULL),
276 ITEM_FACTORY_STOCK_ENTRY("/Analyze/_Display Filters...", NULL, dfilter_dialog_cb,
277 0, ETHEREAL_STOCK_DISPLAY_FILTER),
278 ITEM_FACTORY_ENTRY("/Analyze/_Match", NULL, NULL, 0, "<Branch>", NULL),
279 ITEM_FACTORY_ENTRY("/Analyze/Match/_Selected", NULL,
280 match_selected_cb_replace_ptree, 0, NULL, NULL),
281 ITEM_FACTORY_ENTRY("/Analyze/Match/_Not Selected", NULL,
282 match_selected_cb_not_ptree, 0, NULL, NULL),
283 ITEM_FACTORY_ENTRY("/Analyze/Match/_And Selected", NULL,
284 match_selected_cb_and_ptree, 0, NULL, NULL),
285 ITEM_FACTORY_ENTRY("/Analyze/Match/_Or Selected", NULL,
286 match_selected_cb_or_ptree, 0, NULL, NULL),
287 ITEM_FACTORY_ENTRY("/Analyze/Match/A_nd Not Selected", NULL,
288 match_selected_cb_and_ptree_not, 0, NULL, NULL),
289 ITEM_FACTORY_ENTRY("/Analyze/Match/O_r Not Selected", NULL,
290 match_selected_cb_or_ptree_not, 0, NULL, NULL),
291 ITEM_FACTORY_ENTRY("/Analyze/_Prepare", NULL, NULL, 0, "<Branch>", NULL),
292 ITEM_FACTORY_ENTRY("/Analyze/Prepare/_Selected", NULL,
293 prepare_selected_cb_replace_ptree, 0, NULL, NULL),
294 ITEM_FACTORY_ENTRY("/Analyze/Prepare/_Not Selected", NULL,
295 prepare_selected_cb_not_ptree, 0, NULL, NULL),
296 ITEM_FACTORY_ENTRY("/Analyze/Prepare/_And Selected", NULL,
297 prepare_selected_cb_and_ptree, 0, NULL, NULL),
298 ITEM_FACTORY_ENTRY("/Analyze/Prepare/_Or Selected", NULL,
299 prepare_selected_cb_or_ptree, 0, NULL, NULL),
300 ITEM_FACTORY_ENTRY("/Analyze/Prepare/A_nd Not Selected", NULL,
301 prepare_selected_cb_and_ptree_not, 0, NULL, NULL),
302 ITEM_FACTORY_ENTRY("/Analyze/Prepare/O_r Not Selected", NULL,
303 prepare_selected_cb_or_ptree_not, 0, NULL, NULL),
304 ITEM_FACTORY_ENTRY("/Analyze/<separator>", NULL, NULL, 0, "<Separator>", NULL),
305 ITEM_FACTORY_ENTRY("/Analyze/_Enabled Protocols...", "<shift><control>R", proto_cb, 0, NULL, NULL),
306 ITEM_FACTORY_ENTRY("/Analyze/Decode _As...", NULL, decode_as_cb,
308 ITEM_FACTORY_ENTRY("/Analyze/_User Specified Decodes...", NULL,
309 decode_show_cb, 0, NULL, NULL),
310 ITEM_FACTORY_ENTRY("/Analyze/<separator>", NULL, NULL, 0, "<Separator>", NULL),
311 ITEM_FACTORY_ENTRY("/Analyze/_Follow TCP Stream", NULL,
312 follow_stream_cb, 0, NULL, NULL),
313 ITEM_FACTORY_ENTRY("/_Statistics", NULL, NULL, 0, "<Branch>", NULL),
314 ITEM_FACTORY_ENTRY("/Statistics/_Summary", NULL, summary_open_cb, 0, NULL, NULL),
315 ITEM_FACTORY_ENTRY("/Statistics/_Protocol Hierarchy", NULL,
316 proto_hier_stats_cb, 0, NULL, NULL),
317 ITEM_FACTORY_ENTRY("/Statistics/Conversations", NULL,
318 init_ett_notebook_cb, 0, NULL, NULL),
319 ITEM_FACTORY_ENTRY("/Statistics/Endpoints", NULL,
320 init_hostlist_notebook_cb, 0, NULL, NULL),
321 ITEM_FACTORY_ENTRY("/_Help", NULL, NULL, 0, "<Branch>", NULL),
322 ITEM_FACTORY_STOCK_ENTRY("/Help/_Contents", "F1", help_cb, 0, GTK_STOCK_HELP),
323 ITEM_FACTORY_ENTRY("/Help/_Supported Protocols", NULL, supported_cb, 0, NULL, NULL),
324 ITEM_FACTORY_ENTRY("/Help/<separator>", NULL, NULL, 0, "<Separator>", NULL),
326 ITEM_FACTORY_ENTRY("/Help/About _Plugins", NULL, tools_plugins_cmd_cb,
328 #endif /* HAVE_PLUGINS */
329 ITEM_FACTORY_ENTRY("/Help/_About Ethereal", NULL, about_ethereal,
334 /* calculate the number of menu_items */
335 static int nmenu_items = sizeof(menu_items) / sizeof(menu_items[0]);
337 /* packet list popup */
338 static GtkItemFactoryEntry packet_list_menu_items[] =
340 ITEM_FACTORY_ENTRY("/Follow TCP Stream", NULL, follow_stream_cb,
342 ITEM_FACTORY_ENTRY("/Decode As...", NULL, decode_as_cb, 0, NULL, NULL),
343 ITEM_FACTORY_ENTRY("/Display Filters...", NULL, dfilter_dialog_cb,
345 ITEM_FACTORY_ENTRY("/<separator>", NULL, NULL, 0, "<Separator>", NULL),
346 ITEM_FACTORY_ENTRY("/Mark Packet", NULL, mark_frame_cb, 0, NULL, NULL),
347 ITEM_FACTORY_ENTRY("/Time Reference", NULL, NULL, 0, "<Branch>", NULL),
348 ITEM_FACTORY_ENTRY("/Time Reference/Set Time Reference (toggle)", NULL, reftime_frame_cb, 0, NULL, NULL),
349 ITEM_FACTORY_ENTRY("/Time Reference/Find Next", NULL, reftime_frame_cb, 1, NULL, NULL),
350 ITEM_FACTORY_ENTRY("/Time Reference/Find Previous", NULL, reftime_frame_cb, 2, NULL, NULL),
351 ITEM_FACTORY_ENTRY("/Match", NULL, NULL, 0, "<Branch>", NULL),
352 ITEM_FACTORY_ENTRY("/Match/_Selected", NULL,
353 match_selected_cb_replace_plist, 0, NULL, NULL),
354 ITEM_FACTORY_ENTRY("/Match/_Not Selected", NULL,
355 match_selected_cb_not_plist, 0, NULL, NULL),
356 ITEM_FACTORY_ENTRY("/Match/_And Selected", NULL,
357 match_selected_cb_and_plist, 0, NULL, NULL),
358 ITEM_FACTORY_ENTRY("/Match/_Or Selected", NULL, match_selected_cb_or_plist,
360 ITEM_FACTORY_ENTRY("/Match/A_nd Not Selected", NULL,
361 match_selected_cb_and_plist_not, 0, NULL, NULL),
362 ITEM_FACTORY_ENTRY("/Match/O_r Not Selected", NULL,
363 match_selected_cb_or_plist_not, 0, NULL, NULL),
364 ITEM_FACTORY_ENTRY("/Prepare", NULL, NULL, 0, "<Branch>", NULL),
365 ITEM_FACTORY_ENTRY("/Prepare/_Selected", NULL,
366 prepare_selected_cb_replace_plist, 0, NULL, NULL),
367 ITEM_FACTORY_ENTRY("/Prepare/_Not Selected", NULL,
368 prepare_selected_cb_not_plist, 0, NULL, NULL),
369 ITEM_FACTORY_ENTRY("/Prepare/_And Selected", NULL,
370 prepare_selected_cb_and_plist, 0, NULL, NULL),
371 ITEM_FACTORY_ENTRY("/Prepare/_Or Selected", NULL,
372 prepare_selected_cb_or_plist, 0, NULL, NULL),
373 ITEM_FACTORY_ENTRY("/Prepare/A_nd Not Selected", NULL,
374 prepare_selected_cb_and_plist_not, 0, NULL, NULL),
375 ITEM_FACTORY_ENTRY("/Prepare/O_r Not Selected", NULL,
376 prepare_selected_cb_or_plist_not, 0, NULL, NULL),
377 ITEM_FACTORY_ENTRY("/<separator>", NULL, NULL, 0, "<Separator>", NULL),
378 ITEM_FACTORY_ENTRY("/Coloring Rules...", NULL, color_display_cb,
380 ITEM_FACTORY_ENTRY("/Print...", NULL, file_print_cmd_cb, 0, NULL, NULL),
381 ITEM_FACTORY_ENTRY("/Show Packet in New Window", NULL, new_window_cb,
385 static GtkItemFactoryEntry tree_view_menu_items[] =
387 ITEM_FACTORY_ENTRY("/Follow TCP Stream", NULL, follow_stream_cb,
389 ITEM_FACTORY_ENTRY("/Decode As...", NULL, decode_as_cb, 0, NULL, NULL),
390 ITEM_FACTORY_ENTRY("/Display Filters...", NULL, dfilter_dialog_cb,
392 ITEM_FACTORY_ENTRY("/<separator>", NULL, NULL, 0, "<Separator>", NULL),
393 ITEM_FACTORY_ENTRY("/_Resolve Name", NULL, resolve_name_cb, 0, NULL, NULL),
394 ITEM_FACTORY_ENTRY("/_Go to Corresponding Packet", NULL, goto_framenum_cb, 0, NULL, NULL),
395 ITEM_FACTORY_ENTRY("/_Export Selected Packet Bytes...", NULL, savehex_cb,
397 ITEM_FACTORY_ENTRY("/Protocol Properties...", NULL, properties_cb,
399 ITEM_FACTORY_ENTRY("/Match", NULL, NULL, 0, "<Branch>", NULL),
400 ITEM_FACTORY_ENTRY("/Match/_Selected", NULL,
401 match_selected_cb_replace_ptree, 0, NULL, NULL),
402 ITEM_FACTORY_ENTRY("/Match/_Not Selected", NULL,
403 match_selected_cb_not_ptree, 0, NULL, NULL),
404 ITEM_FACTORY_ENTRY("/Match/_And Selected", NULL,
405 match_selected_cb_and_ptree, 0, NULL, NULL),
406 ITEM_FACTORY_ENTRY("/Match/_Or Selected", NULL, match_selected_cb_or_ptree,
408 ITEM_FACTORY_ENTRY("/Match/A_nd Not Selected", NULL,
409 match_selected_cb_and_ptree_not, 0, NULL, NULL),
410 ITEM_FACTORY_ENTRY("/Match/O_r Not Selected", NULL,
411 match_selected_cb_or_ptree_not, 0, NULL, NULL),
412 ITEM_FACTORY_ENTRY("/Prepare", NULL, NULL, 0, "<Branch>", NULL),
413 ITEM_FACTORY_ENTRY("/Prepare/_Selected", NULL,
414 prepare_selected_cb_replace_ptree, 0, NULL, NULL),
415 ITEM_FACTORY_ENTRY("/Prepare/_Not Selected", NULL,
416 prepare_selected_cb_not_ptree, 0, NULL, NULL),
417 ITEM_FACTORY_ENTRY("/Prepare/_And Selected", NULL,
418 prepare_selected_cb_and_ptree, 0, NULL, NULL),
419 ITEM_FACTORY_ENTRY("/Prepare/_Or Selected", NULL,
420 prepare_selected_cb_or_ptree, 0, NULL, NULL),
421 ITEM_FACTORY_ENTRY("/Prepare/A_nd Not Selected", NULL,
422 prepare_selected_cb_and_ptree_not, 0, NULL, NULL),
423 ITEM_FACTORY_ENTRY("/Prepare/O_r Not Selected", NULL,
424 prepare_selected_cb_or_ptree_not, 0, NULL, NULL),
425 ITEM_FACTORY_ENTRY("/<separator>", NULL, NULL, 0, "<Separator>", NULL),
426 ITEM_FACTORY_ENTRY("/Collapse All", NULL, collapse_all_cb, 0, NULL, NULL),
427 ITEM_FACTORY_ENTRY("/Expand All", NULL, expand_all_cb, 0, NULL, NULL),
428 ITEM_FACTORY_ENTRY("/Expand Tree", NULL, expand_tree_cb, 0, NULL, NULL)
431 static GtkItemFactoryEntry hexdump_menu_items[] =
433 ITEM_FACTORY_ENTRY("/Follow TCP Stream", NULL, follow_stream_cb,
435 ITEM_FACTORY_ENTRY("/Decode As...", NULL, decode_as_cb, 0, NULL, NULL),
436 ITEM_FACTORY_ENTRY("/Display Filters...", NULL, dfilter_dialog_cb,
438 ITEM_FACTORY_ENTRY("/Export Selected Packet Bytes...", NULL, savehex_cb,
442 static int initialize = TRUE;
443 static GtkItemFactory *main_menu_factory = NULL;
444 static GtkItemFactory *packet_list_menu_factory = NULL;
445 static GtkItemFactory *tree_view_menu_factory = NULL;
446 static GtkItemFactory *hexdump_menu_factory = NULL;
448 static GSList *popup_menu_list = NULL;
450 static GtkAccelGroup *grp;
453 main_menu_new(GtkAccelGroup ** table) {
456 grp = gtk_accel_group_new();
461 menubar = main_menu_factory->widget;
475 packet_list_menu_factory = gtk_item_factory_new(GTK_TYPE_MENU, "<main>", NULL);
476 popup_menu_object = gtk_menu_new();
477 gtk_item_factory_create_items_ac(packet_list_menu_factory, sizeof(packet_list_menu_items)/sizeof(packet_list_menu_items[0]), packet_list_menu_items, popup_menu_object, 2);
478 OBJECT_SET_DATA(popup_menu_object, PM_PACKET_LIST_KEY,
479 packet_list_menu_factory->widget);
480 popup_menu_list = g_slist_append((GSList *)popup_menu_list, packet_list_menu_factory);
482 tree_view_menu_factory = gtk_item_factory_new(GTK_TYPE_MENU, "<main>", NULL);
483 gtk_item_factory_create_items_ac(tree_view_menu_factory, sizeof(tree_view_menu_items)/sizeof(tree_view_menu_items[0]), tree_view_menu_items, popup_menu_object, 2);
484 OBJECT_SET_DATA(popup_menu_object, PM_TREE_VIEW_KEY,
485 tree_view_menu_factory->widget);
486 popup_menu_list = g_slist_append((GSList *)popup_menu_list, tree_view_menu_factory);
488 hexdump_menu_factory = gtk_item_factory_new(GTK_TYPE_MENU, "<main>", NULL);
489 gtk_item_factory_create_items_ac(hexdump_menu_factory, sizeof(hexdump_menu_items)/sizeof(hexdump_menu_items[0]), hexdump_menu_items, popup_menu_object, 2);
490 OBJECT_SET_DATA(popup_menu_object, PM_HEXDUMP_KEY,
491 hexdump_menu_factory->widget);
492 popup_menu_list = g_slist_append((GSList *)popup_menu_list, hexdump_menu_factory);
495 main_menu_factory = gtk_item_factory_new(GTK_TYPE_MENU_BAR, "<main>", grp);
496 gtk_item_factory_create_items_ac(main_menu_factory, nmenu_items, menu_items, NULL, 2);
498 merge_all_tap_menus(tap_menu_tree_root);
500 /* Initialize enabled/disabled state of menu items */
501 set_menus_for_unsaved_capture_file(FALSE);
502 set_menus_for_capture_file(FALSE);
504 /* Un-#if this when we actually implement Cut/Copy/Paste.
505 Then make sure you enable them when they can be done. */
506 set_menu_sensitivity(main_menu_factory, "/Edit/Cut", FALSE);
507 set_menu_sensitivity(main_menu_factory, "/Edit/Copy", FALSE);
508 set_menu_sensitivity(main_menu_factory, "/Edit/Paste", FALSE);
511 set_menus_for_captured_packets(FALSE);
512 set_menus_for_selected_packet(&cfile);
513 set_menus_for_selected_tree_row(&cfile);
515 /* init with an empty recent files list */
516 clear_menu_recent_capture_file_cmd_cb(NULL, NULL);
521 gint tap_menu_item_add_compare(gconstpointer a, gconstpointer b)
524 ((const menu_item_t *) a)->name,
525 ((const menu_item_t *) b)->name);
529 /* add a menuitem below the current node */
530 GList * tap_menu_item_add(
533 GtkItemFactoryCallback callback,
534 gboolean (*selected_packet_enabled)(frame_data *, epan_dissect_t *),
535 gboolean (*selected_tree_row_enabled)(field_info *),
536 gpointer callback_data,
543 child = g_malloc(sizeof (menu_item_t));
544 child->group = group;
546 child->callback = callback;
547 child->selected_packet_enabled = selected_packet_enabled;
548 child->selected_tree_row_enabled = selected_tree_row_enabled;
549 child->callback_data = callback_data;
550 child->enabled = FALSE;
551 child->children = NULL;
553 /* insert the new child node into the parent */
554 curr = curnode->data;
555 curr->children = g_list_insert_sorted(curr->children, child, tap_menu_item_add_compare);
557 /* return the new node */
558 /* XXX: improve this */
559 return g_list_find(curr->children, child);
563 * Add a new menu item for a tap.
564 * This must be called after we've created the main menu, so it can't
565 * be called from the routine that registers taps - we have to introduce
566 * another per-tap registration routine.
568 * "callback" gets called when the menu item is selected; it should do
569 * the work of creating the tap window.
571 * "selected_packet_enabled" gets called by "set_menus_for_selected_packet()";
572 * it's passed a Boolean that's TRUE if a packet is selected and FALSE
573 * otherwise, and should return TRUE if the tap will work now (which
574 * might depend on whether a packet is selected and, if one is, on the
575 * packet) and FALSE if not.
577 * "selected_tree_row_enabled" gets called by
578 * "set_menus_for_selected_tree_row()"; it's passed a Boolean that's TRUE if
579 * a protocol tree row is selected and FALSE otherwise, and should return
580 * TRUE if the tap will work now (which might depend on whether a tree row
581 * is selected and, if one is, on the tree row) and FALSE if not.
584 register_tap_menu_item(
587 GtkItemFactoryCallback callback,
588 gboolean (*selected_packet_enabled)(frame_data *, epan_dissect_t *),
589 gboolean (*selected_tree_row_enabled)(field_info *),
590 gpointer callback_data)
592 /*static const char toolspath[] = "/Statistics/";*/
602 * The menu path must be relative.
604 g_assert(*name != '/');
607 case(REGISTER_TAP_GROUP_GENERIC): toolspath = "/Statistics/"; break;
608 case(REGISTER_TAP_GROUP_CONVERSATION_LIST): toolspath = "/Statistics/_Conversation List/"; break;
609 case(REGISTER_TAP_GROUP_ENDPOINT_LIST): toolspath = "/Statistics/_Endpoint List/"; break;
610 case(REGISTER_TAP_GROUP_RESPONSE_TIME): toolspath = "/Statistics/Service _Response Time/"; break;
611 case(REGISTER_TAP_GROUP_NONE): toolspath = "/Statistics/"; break;
617 /* add the (empty) root node, if not already done */
618 if(tap_menu_tree_root == NULL) {
619 child = g_malloc0(sizeof (menu_item_t));
620 tap_menu_tree_root = g_list_append(NULL, child);
624 * Create any submenus required.
626 curnode = tap_menu_tree_root;
628 while ((p = strchr(p, '/')) != NULL) {
630 * OK, everything between "name" and "p" is
631 * a menu relative subtree into which the menu item
634 * Construct the absolute path name of that subtree.
636 menupathlen = strlen(toolspath) + 1 + (p - name);
637 menupath = g_malloc(menupathlen);
638 strcpy(menupath, toolspath);
639 strncat(menupath, name, p - name);
642 * Does there exist an entry with that path at this
643 * level of the Analyze menu tree?
645 child = curnode->data;
646 for (childnode = child->children; childnode != NULL; childnode = childnode->next) {
647 child = childnode->data;
648 if (strcmp(child->name, menupath) == 0)
651 if (childnode == NULL) {
653 * No. Create such an item as a subtree, and
654 * add it to the Tools menu tree.
656 childnode = tap_menu_item_add(
657 menupath, group, NULL, NULL ,NULL, NULL, curnode);
660 * Yes. We don't need this "menupath" any longer.
667 * Skip over the '/' we found.
673 * Construct the main menu path for the menu item.
675 menupathlen = strlen(toolspath) + 1 + strlen(name);
676 menupath = g_malloc(menupathlen);
677 strcpy(menupath, toolspath);
678 strcat(menupath, name);
681 * Construct an item factory entry for the item, and add it to
685 menupath, group, callback,
686 selected_packet_enabled, selected_tree_row_enabled,
687 callback_data, curnode);
691 guint merge_tap_menus_layered(GList *node, gint group) {
692 GtkItemFactoryEntry *entry;
695 menu_item_t *node_data = node->data;
698 * Is this a leaf node or an interior node?
700 if (node_data->children == NULL) {
706 * The root node doesn't correspond to a menu tree item; it
707 * has a null name pointer.
709 if (node_data->name != NULL && group == node_data->group) {
710 entry = g_malloc0(sizeof (GtkItemFactoryEntry));
711 entry->path = node_data->name;
712 entry->callback = node_data->callback;
713 gtk_item_factory_create_item(main_menu_factory, entry, node_data->callback_data, 2);
714 set_menu_sensitivity(main_menu_factory, node_data->name, FALSE); /* no capture file yet */
719 * It's an interior node; call
720 * "merge_tap_menus_layered()" on all its children
724 * The root node doesn't correspond to a menu tree item; it
725 * has a null name pointer.
727 if (node_data->name != NULL && group == node_data->group) {
728 entry = g_malloc0(sizeof (GtkItemFactoryEntry));
729 entry->path = node_data->name;
730 entry->item_type = "<Branch>";
731 gtk_item_factory_create_item(main_menu_factory, entry,
733 set_menu_sensitivity(main_menu_factory, node_data->name,
734 FALSE); /* no children yet */
738 for (child = node_data->children; child != NULL; child =
740 added += merge_tap_menus_layered(child, group);
748 void merge_all_tap_menus(GList *node) {
749 GtkItemFactoryEntry *entry;
751 entry = g_malloc0(sizeof (GtkItemFactoryEntry));
752 entry->item_type = "<Separator>";
753 entry->path = "/Statistics/";
756 * merge only the menu items of the specific group,
757 * and then append a seperator
759 if (merge_tap_menus_layered(node, REGISTER_TAP_GROUP_GENERIC)) {
760 gtk_item_factory_create_item(main_menu_factory, entry, NULL, 2);
762 if (merge_tap_menus_layered(node, REGISTER_TAP_GROUP_CONVERSATION_LIST)) {
763 /*gtk_item_factory_create_item(main_menu_factory, entry, NULL, 2);*/
765 if (merge_tap_menus_layered(node, REGISTER_TAP_GROUP_ENDPOINT_LIST)) {
766 /*gtk_item_factory_create_item(main_menu_factory, entry, NULL, 2);*/
768 if (merge_tap_menus_layered(node, REGISTER_TAP_GROUP_RESPONSE_TIME)) {
769 gtk_item_factory_create_item(main_menu_factory, entry, NULL, 2);
771 if (merge_tap_menus_layered(node, REGISTER_TAP_GROUP_NONE)) {
772 /*gtk_item_factory_create_item(main_menu_factory, entry, NULL, 2);*/
779 * Enable/disable menu sensitivity.
782 set_menu_sensitivity(GtkItemFactory *ifactory, const gchar *path, gint val)
785 GtkWidget *menu_item;
790 /* the underscore character regularly confuses things, as it will prevent finding
791 * the menu_item, so it has to be removed first */
792 dup = g_strdup(path);
803 if (ifactory == NULL) {
805 * Do it for all pop-up menus.
807 for (menu_list = popup_menu_list; menu_list != NULL;
808 menu_list = g_slist_next(menu_list))
809 set_menu_sensitivity(menu_list->data, dup, val);
812 * Do it for that particular menu.
814 if ((menu_item = gtk_item_factory_get_widget(ifactory, dup)) != NULL) {
815 if (GTK_IS_MENU(menu_item)) {
817 * "dup" refers to a submenu; "gtk_item_factory_get_widget()"
818 * gets the menu, not the item that, when selected, pops up
821 * We have to change the latter item's sensitivity, so that
822 * it shows up normally if sensitive and grayed-out if
825 menu_item = gtk_menu_get_attach_widget(GTK_MENU(menu_item));
827 gtk_widget_set_sensitive(menu_item, val);
829 /* be sure this menu item *is* existing */
830 g_assert_not_reached();
838 set_menu_object_data_meat(GtkItemFactory *ifactory, gchar *path, gchar *key, gpointer data)
840 GtkWidget *menu = NULL;
842 if ((menu = gtk_item_factory_get_widget(ifactory, path)) != NULL)
843 OBJECT_SET_DATA(menu, key, data);
847 set_menu_object_data (gchar *path, gchar *key, gpointer data) {
848 GSList *menu_list = popup_menu_list;
849 gchar *shortpath = strrchr(path, '/');
851 set_menu_object_data_meat(main_menu_factory, path, key, data);
852 while (menu_list != NULL) {
853 set_menu_object_data_meat(menu_list->data, shortpath, key, data);
854 menu_list = g_slist_next(menu_list);
859 /* Recently used capture files submenu:
860 * Submenu containing the recently used capture files.
861 * The capture filenames are always kept with the absolute path, to be independant
862 * of the current path.
863 * They are only stored inside the labels of the submenu (no separate list). */
865 #define MENU_RECENT_FILES_PATH "/File/Open Recent"
866 #define MENU_RECENT_FILES_KEY "Recent File Name"
869 update_menu_recent_capture_file1(GtkWidget *widget, gpointer cnt) {
870 gchar *widget_cf_name;
872 widget_cf_name = OBJECT_GET_DATA(widget, MENU_RECENT_FILES_KEY);
874 /* if this menu item is a file, count it */
875 if (widget_cf_name) {
881 /* update the menu */
883 update_menu_recent_capture_file(GtkWidget *submenu_recent_files) {
886 gtk_container_foreach(GTK_CONTAINER(submenu_recent_files),
887 update_menu_recent_capture_file1, &cnt);
889 /* make parent menu item sensitive only, if we have any valid files in the list */
890 set_menu_sensitivity(main_menu_factory, MENU_RECENT_FILES_PATH, cnt);
894 /* remove the capture filename from the "Recent Files" menu */
896 remove_menu_recent_capture_file(GtkWidget *widget, gpointer unused _U_) {
897 GtkWidget *submenu_recent_files;
898 gchar *widget_cf_name;
901 widget_cf_name = OBJECT_GET_DATA(widget, MENU_RECENT_FILES_KEY);
902 g_free(widget_cf_name);
904 /* get the submenu container item */
905 submenu_recent_files = gtk_item_factory_get_widget(main_menu_factory, MENU_RECENT_FILES_PATH);
907 /* XXX: is this all we need to do, to free the menu item and its label?
908 The reference count of widget will go to 0, so it'll be freed;
909 will that free the label? */
910 gtk_container_remove(GTK_CONTAINER(submenu_recent_files), widget);
914 /* callback, if the user pushed the <Clear File List> item */
916 clear_menu_recent_capture_file_cmd_cb(GtkWidget *w _U_, gpointer unused _U_) {
917 GtkWidget *submenu_recent_files;
920 submenu_recent_files = gtk_item_factory_get_widget(main_menu_factory, MENU_RECENT_FILES_PATH);
922 gtk_container_foreach(GTK_CONTAINER(submenu_recent_files),
923 remove_menu_recent_capture_file, NULL);
925 update_menu_recent_capture_file(submenu_recent_files);
929 /* callback, if the user pushed a recent file submenu item */
931 menu_open_recent_file_cmd(GtkWidget *w)
933 GtkWidget *submenu_recent_files;
934 GtkWidget *menu_item_child;
938 submenu_recent_files = gtk_item_factory_get_widget(main_menu_factory, MENU_RECENT_FILES_PATH);
940 /* get capture filename from the menu item label */
941 menu_item_child = (GTK_BIN(w))->child;
942 gtk_label_get(GTK_LABEL(menu_item_child), &cf_name);
944 /* open and read the capture file (this will close an existing file) */
945 if ((err = cf_open(cf_name, FALSE, &cfile)) == 0) {
948 /* the capture file isn't existing any longer, remove menu item */
949 /* XXX: ask user to remove item, it's maybe only a temporary problem */
950 remove_menu_recent_capture_file(w, NULL);
953 update_menu_recent_capture_file(submenu_recent_files);
956 static void menu_open_recent_file_answered_cb(gpointer dialog _U_, gint btn, gpointer data _U_)
960 /* save file first */
961 file_save_as_cmd(after_save_open_recent_file, data);
965 menu_open_recent_file_cmd(data);
967 case(ESD_BTN_CANCEL):
970 g_assert_not_reached();
975 menu_open_recent_file_cmd_cb(GtkWidget *widget, gpointer data _U_) {
979 if((cfile.state != FILE_CLOSED) && !cfile.user_saved) {
980 /* user didn't saved his current file, ask him */
981 dialog = simple_dialog(ESD_TYPE_CONFIRMATION, ESD_BTNS_YES_NO_CANCEL,
982 PRIMARY_TEXT_START "Save capture file before opening a new one?" PRIMARY_TEXT_END "\n\n"
983 "If you open a new capture file without saving, your current capture data will be discarded.");
984 simple_dialog_set_cb(dialog, menu_open_recent_file_answered_cb, widget);
987 menu_open_recent_file_cmd(widget);
991 /* add the capture filename (with an absolute path) to the "Recent Files" menu */
993 add_menu_recent_capture_file_absolute(gchar *cf_name) {
994 GtkWidget *submenu_recent_files;
995 GList *menu_item_list;
997 gchar *widget_cf_name;
998 gchar *normalized_cf_name;
999 GtkWidget *menu_item;
1004 normalized_cf_name = g_strdup(cf_name);
1006 /* replace all slashes by backslashes */
1007 g_strdelimit(normalized_cf_name, "/", '\\');
1010 /* get the submenu container item */
1011 submenu_recent_files = gtk_item_factory_get_widget(main_menu_factory, MENU_RECENT_FILES_PATH);
1013 /* convert container to a GList */
1014 menu_item_list = gtk_container_children(GTK_CONTAINER(submenu_recent_files));
1016 /* iterate through list items of menu_item_list,
1017 * removing special items, a maybe duplicate entry and every item above count_max */
1019 for (li = g_list_first(menu_item_list); li; li = li->next, cnt++) {
1020 /* get capture filename */
1021 menu_item = GTK_WIDGET(li->data);
1022 widget_cf_name = OBJECT_GET_DATA(menu_item, MENU_RECENT_FILES_KEY);
1024 /* if this element string is one of our special items (seperator, ...) or
1025 * already in the list or
1026 * this element is above maximum count (too old), remove it */
1027 if (!widget_cf_name ||
1029 /* do a case insensitive compare on win32 */
1030 #if GLIB_MAJOR_VERSION < 2
1031 g_strncasecmp(widget_cf_name, normalized_cf_name, 1000) == 0 ||
1033 g_ascii_strncasecmp(widget_cf_name, normalized_cf_name, 1000) == 0 ||
1036 /* do a case sensitive compare on unix */
1037 strncmp(widget_cf_name, normalized_cf_name, 1000) == 0 ||
1039 cnt >= prefs.gui_recent_files_count_max) {
1040 remove_menu_recent_capture_file(li->data, NULL);
1045 g_list_free(menu_item_list);
1047 /* add new item at latest position */
1048 menu_item = gtk_menu_item_new_with_label(normalized_cf_name);
1049 OBJECT_SET_DATA(menu_item, MENU_RECENT_FILES_KEY, normalized_cf_name);
1050 gtk_menu_prepend (GTK_MENU(submenu_recent_files), menu_item);
1051 SIGNAL_CONNECT_OBJECT(GTK_OBJECT(menu_item), "activate",
1052 menu_open_recent_file_cmd_cb, (GtkObject *) menu_item);
1053 gtk_widget_show (menu_item);
1055 /* add seperator at last position */
1056 menu_item = gtk_menu_item_new();
1057 gtk_menu_append (GTK_MENU(submenu_recent_files), menu_item);
1058 gtk_widget_show (menu_item);
1060 /* add new "clear list" item at last position */
1061 #if GTK_MAJOR_VERSION < 2
1062 menu_item = gtk_menu_item_new_with_label("<Clear File List>");
1064 menu_item = gtk_image_menu_item_new_from_stock
1065 (GTK_STOCK_CLEAR, NULL);
1067 gtk_menu_append (GTK_MENU(submenu_recent_files), menu_item);
1068 SIGNAL_CONNECT_OBJECT(GTK_OBJECT(menu_item), "activate",
1069 clear_menu_recent_capture_file_cmd_cb, (GtkObject *) menu_item);
1070 gtk_widget_show (menu_item);
1072 update_menu_recent_capture_file(submenu_recent_files);
1076 /* add the capture filename to the "Recent Files" menu */
1077 /* (will change nothing, if this filename is already in the menu) */
1079 add_menu_recent_capture_file(gchar *cf_name) {
1084 /* if this filename is an absolute path, we can use it directly */
1085 if (g_path_is_absolute(cf_name)) {
1086 add_menu_recent_capture_file_absolute(cf_name);
1090 /* this filename is not an absolute path, prepend the current dir */
1091 curr = g_get_current_dir();
1092 absolute = g_strdup_printf("%s%s%s", curr, G_DIR_SEPARATOR_S, cf_name);
1093 add_menu_recent_capture_file_absolute(absolute);
1099 /* write all capture filenames of the menu to the user's recent file */
1101 menu_recent_file_write_all(FILE *rf) {
1102 GtkWidget *submenu_recent_files;
1108 submenu_recent_files = gtk_item_factory_get_widget(main_menu_factory, MENU_RECENT_FILES_PATH);
1110 /* we have to iterate backwards through the children's list,
1111 * so we get the latest item last in the file.
1112 * (don't use gtk_container_foreach() here, it will return the wrong iteration order) */
1113 children = gtk_container_children(GTK_CONTAINER(submenu_recent_files));
1114 child = g_list_last(children);
1115 while(child != NULL) {
1116 /* get capture filename from the menu item label */
1117 cf_name = OBJECT_GET_DATA(child->data, MENU_RECENT_FILES_KEY);
1119 fprintf (rf, RECENT_KEY_CAPTURE_FILE ": %s\n", cf_name);
1122 child = g_list_previous(child);
1125 g_list_free(children);
1130 main_toolbar_show_cb(GtkWidget *w _U_, gpointer d _U_)
1133 /* save current setting in recent */
1134 recent.main_toolbar_show = GTK_CHECK_MENU_ITEM(w)->active;
1136 main_widgets_rearrange();
1141 filter_toolbar_show_cb(GtkWidget *w _U_, gpointer d _U_)
1144 /* save current setting in recent */
1145 recent.filter_toolbar_show = GTK_CHECK_MENU_ITEM(w)->active;
1147 main_widgets_rearrange();
1152 packet_list_show_cb(GtkWidget *w _U_, gpointer d _U_)
1155 /* save current setting in recent */
1156 recent.packet_list_show = GTK_CHECK_MENU_ITEM(w)->active;
1158 main_widgets_rearrange();
1163 tree_view_show_cb(GtkWidget *w _U_, gpointer d _U_)
1166 /* save current setting in recent */
1167 recent.tree_view_show = GTK_CHECK_MENU_ITEM(w)->active;
1169 main_widgets_rearrange();
1174 byte_view_show_cb(GtkWidget *w _U_, gpointer d _U_)
1177 /* save current setting in recent */
1178 recent.byte_view_show = GTK_CHECK_MENU_ITEM(w)->active;
1180 main_widgets_rearrange();
1185 statusbar_show_cb(GtkWidget *w _U_, gpointer d _U_)
1188 /* save current setting in recent */
1189 recent.statusbar_show = GTK_CHECK_MENU_ITEM(w)->active;
1191 main_widgets_rearrange();
1196 timestamp_absolute_cb(GtkWidget *w _U_, gpointer d _U_)
1198 if (recent.gui_time_format != TS_ABSOLUTE) {
1199 set_timestamp_setting(TS_ABSOLUTE);
1200 recent.gui_time_format = TS_ABSOLUTE;
1201 change_time_formats(&cfile);
1206 timestamp_absolute_date_cb(GtkWidget *w _U_, gpointer d _U_)
1208 if (recent.gui_time_format != TS_ABSOLUTE_WITH_DATE) {
1209 set_timestamp_setting(TS_ABSOLUTE_WITH_DATE);
1210 recent.gui_time_format = TS_ABSOLUTE_WITH_DATE;
1211 change_time_formats(&cfile);
1216 timestamp_relative_cb(GtkWidget *w _U_, gpointer d _U_)
1218 if (recent.gui_time_format != TS_RELATIVE) {
1219 set_timestamp_setting(TS_RELATIVE);
1220 recent.gui_time_format = TS_RELATIVE;
1221 change_time_formats(&cfile);
1226 timestamp_delta_cb(GtkWidget *w _U_, gpointer d _U_)
1228 if (recent.gui_time_format != TS_DELTA) {
1229 set_timestamp_setting(TS_DELTA);
1230 recent.gui_time_format = TS_DELTA;
1231 change_time_formats(&cfile);
1236 name_resolution_mac_cb(GtkWidget *w _U_, gpointer d _U_)
1238 if (GTK_CHECK_MENU_ITEM(w)->active) {
1239 g_resolv_flags |= RESOLV_MAC;
1241 g_resolv_flags &= ~RESOLV_MAC;
1246 name_resolution_network_cb(GtkWidget *w _U_, gpointer d _U_)
1248 if (GTK_CHECK_MENU_ITEM(w)->active) {
1249 g_resolv_flags |= RESOLV_NETWORK;
1251 g_resolv_flags &= ~RESOLV_NETWORK;
1256 name_resolution_transport_cb(GtkWidget *w _U_, gpointer d _U_)
1258 if (GTK_CHECK_MENU_ITEM(w)->active) {
1259 g_resolv_flags |= RESOLV_TRANSPORT;
1261 g_resolv_flags &= ~RESOLV_TRANSPORT;
1267 auto_scroll_live_cb(GtkWidget *w _U_, gpointer d _U_)
1269 auto_scroll_live = GTK_CHECK_MENU_ITEM(w)->active;
1273 /* the recent file read has finished, update the menu corresponding */
1275 menu_recent_read_finished(void) {
1276 GtkWidget *menu = NULL;
1278 menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Main Toolbar");
1279 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), recent.main_toolbar_show);
1281 menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Filter Toolbar");
1282 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), recent.filter_toolbar_show);
1284 menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Statusbar");
1285 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), recent.statusbar_show);
1287 menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Packet List");
1288 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), recent.packet_list_show);
1290 menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Packet Details");
1291 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), recent.tree_view_show);
1293 menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Packet Bytes");
1294 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), recent.byte_view_show);
1296 menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Name Resolution/Enable for MAC Layer");
1297 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), g_resolv_flags & RESOLV_MAC);
1299 menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Name Resolution/Enable for Network Layer");
1300 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), g_resolv_flags & RESOLV_NETWORK);
1302 menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Name Resolution/Enable for Transport Layer");
1303 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), g_resolv_flags & RESOLV_TRANSPORT);
1306 menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Auto Scroll in Live Capture");
1307 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), auto_scroll_live);
1310 main_widgets_rearrange();
1312 /* don't change the time format, if we had a command line value */
1313 if (get_timestamp_setting() != TS_NOT_SET) {
1314 recent.gui_time_format = get_timestamp_setting();
1317 switch(recent.gui_time_format) {
1319 menu = gtk_item_factory_get_widget(main_menu_factory,
1320 "/View/Time Display Format/Time of Day");
1321 /* set_active will not trigger the callback when activating an active item! */
1322 recent.gui_time_format = -1;
1323 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), FALSE);
1324 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), TRUE);
1326 case(TS_ABSOLUTE_WITH_DATE):
1327 menu = gtk_item_factory_get_widget(main_menu_factory,
1328 "/View/Time Display Format/Date and Time of Day");
1329 recent.gui_time_format = -1;
1330 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), TRUE);
1333 menu = gtk_item_factory_get_widget(main_menu_factory,
1334 "/View/Time Display Format/Seconds Since Beginning of Capture");
1335 recent.gui_time_format = -1;
1336 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), TRUE);
1339 menu = gtk_item_factory_get_widget(main_menu_factory,
1340 "/View/Time Display Format/Seconds Since Previous Packet");
1341 recent.gui_time_format = -1;
1342 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), TRUE);
1345 g_assert_not_reached();
1351 popup_menu_handler(GtkWidget *widget, GdkEvent *event, gpointer data)
1353 GtkWidget *menu = (GtkWidget *)data;
1354 GdkEventButton *event_button = NULL;
1357 if(widget == NULL || event == NULL || data == NULL) {
1362 * If we ever want to make the menu differ based on what row
1363 * and/or column we're above, we'd use "eth_clist_get_selection_info()"
1364 * to find the row and column number for the coordinates; a CTree is,
1365 * I guess, like a CList with one column(?) and the expander widget
1368 /* Check if we are on packet_list object */
1369 if (widget == OBJECT_GET_DATA(popup_menu_object, E_MPACKET_LIST_KEY)) {
1370 if (packet_list_get_event_row_column(widget, (GdkEventButton *)event,
1372 OBJECT_SET_DATA(popup_menu_object, E_MPACKET_LIST_ROW_KEY,
1373 GINT_TO_POINTER(row));
1374 OBJECT_SET_DATA(popup_menu_object, E_MPACKET_LIST_COL_KEY,
1375 GINT_TO_POINTER(column));
1376 packet_list_set_selected_row(row);
1380 /* Check if we are on tree_view object */
1381 if (widget == tree_view) {
1382 tree_view_select(widget, (GdkEventButton *) event);
1385 /* Check if we are on byte_view object */
1386 if(widget == get_notebook_bv_ptr(byte_nb_ptr)) {
1387 byte_view_select(widget, (GdkEventButton *) event);
1390 if(event->type == GDK_BUTTON_PRESS) {
1391 event_button = (GdkEventButton *) event;
1393 /* To qoute the "Gdk Event Structures" doc:
1394 * "Normally button 1 is the left mouse button, 2 is the middle button, and 3 is the right button" */
1395 if(event_button->button == 3) {
1396 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL,
1397 event_button->button,
1398 event_button->time);
1399 SIGNAL_EMIT_STOP_BY_NAME(widget, "button_press_event");
1403 #if GTK_MAJOR_VERSION >= 2
1404 /* GDK_2BUTTON_PRESS is a doubleclick -> expand/collapse tree row */
1405 /* GTK version 1 seems to be doing this automatically */
1406 if (widget == tree_view && event->type == GDK_2BUTTON_PRESS) {
1409 if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(widget),
1410 (gint) (((GdkEventButton *)event)->x),
1411 (gint) (((GdkEventButton *)event)->y),
1412 &path, NULL, NULL, NULL))
1414 if (gtk_tree_view_row_expanded(GTK_TREE_VIEW(widget), path))
1415 gtk_tree_view_collapse_row(GTK_TREE_VIEW(widget), path);
1417 gtk_tree_view_expand_row(GTK_TREE_VIEW(widget), path,
1419 gtk_tree_path_free(path);
1426 /* Enable or disable menu items based on whether you have a capture file
1427 you've finished reading. */
1429 set_menus_for_capture_file(gboolean have_capture_file)
1431 set_menu_sensitivity(main_menu_factory, "/File/Open...", have_capture_file);
1432 set_menu_sensitivity(main_menu_factory, "/File/Open Recent", have_capture_file);
1433 set_menu_sensitivity(main_menu_factory, "/File/Close", have_capture_file);
1434 set_menu_sensitivity(main_menu_factory, "/File/Save As...",
1436 set_menu_sensitivity(main_menu_factory, "/File/Export", have_capture_file);
1437 set_menu_sensitivity(main_menu_factory, "/View/Reload", have_capture_file);
1438 set_toolbar_for_capture_file(have_capture_file);
1439 packets_bar_update();
1442 /* Enable or disable menu items based on whether you have an unsaved
1443 capture file you've finished reading. */
1445 set_menus_for_unsaved_capture_file(gboolean have_unsaved_capture_file)
1447 set_menu_sensitivity(main_menu_factory, "/File/Save",
1448 have_unsaved_capture_file);
1449 set_toolbar_for_unsaved_capture_file(have_unsaved_capture_file);
1452 /* Enable or disable menu items based on whether there's a capture in
1455 set_menus_for_capture_in_progress(gboolean capture_in_progress)
1457 set_menu_sensitivity(main_menu_factory, "/File/Open...",
1458 !capture_in_progress);
1459 set_menu_sensitivity(main_menu_factory, "/File/Open Recent",
1460 !capture_in_progress);
1462 set_menu_sensitivity(main_menu_factory, "/Capture/Start...",
1463 !capture_in_progress);
1464 set_menu_sensitivity(main_menu_factory, "/Capture/Stop",
1465 capture_in_progress);
1466 #endif /* HAVE_LIBPCAP */
1467 set_toolbar_for_capture_in_progress(capture_in_progress);
1470 /* Enable or disable menu items based on whether you have some captured
1473 walk_menu_tree_for_captured_packets(GList *node,
1474 gboolean have_captured_packets)
1476 gboolean is_enabled;
1478 menu_item_t *node_data = node->data;
1481 * Is this a leaf node or an interior node?
1483 if (node_data->children == NULL) {
1487 * If it has no "selected_packet_enabled()" or
1488 * "selected_tree_row_enabled()" routines, we enable
1489 * it. This allows tap windows to be popped up even
1490 * if you have no capture file; this is done to let
1491 * the user pop up multiple tap windows before reading
1492 * in a capture file, so that they can be processed in
1493 * parallel while the capture file is being read rather
1494 * than one at at time as you pop up the windows, and to
1495 * let the user pop up tap windows before starting an
1496 * "Update list of packets in real time" capture, so that
1497 * the statistics can be displayed while the capture is
1500 * If it has either of those routines, we disable it for
1501 * now - as long as, when a capture is first available,
1502 * we don't get called after a packet or tree row is
1503 * selected, that's OK.
1504 * XXX - that should be done better.
1506 if (node_data->selected_packet_enabled == NULL &&
1507 node_data->selected_tree_row_enabled == NULL)
1508 node_data->enabled = TRUE;
1510 node_data->enabled = FALSE;
1513 * It's an interior node; call
1514 * "walk_menu_tree_for_captured_packets()" on all its
1515 * children and, if any of them are enabled, enable
1516 * this node, otherwise disable it.
1518 * XXX - should we just leave all interior nodes enabled?
1519 * Which is a better UI choice?
1522 for (child = node_data->children; child != NULL; child =
1524 if (walk_menu_tree_for_captured_packets(child,
1525 have_captured_packets))
1528 node_data->enabled = is_enabled;
1532 * The root node doesn't correspond to a menu tree item; it
1533 * has a null name pointer.
1535 if (node_data->name != NULL) {
1536 set_menu_sensitivity(main_menu_factory, node_data->name,
1537 node_data->enabled);
1539 return node_data->enabled;
1543 set_menus_for_captured_packets(gboolean have_captured_packets)
1545 set_menu_sensitivity(main_menu_factory, "/File/Print...",
1546 have_captured_packets);
1547 set_menu_sensitivity(packet_list_menu_factory, "/Print...",
1548 have_captured_packets);
1549 set_menu_sensitivity(main_menu_factory, "/Edit/Find Packet...",
1550 have_captured_packets);
1551 set_menu_sensitivity(main_menu_factory, "/Edit/Find Next",
1552 have_captured_packets);
1553 set_menu_sensitivity(main_menu_factory, "/Edit/Find Previous",
1554 have_captured_packets);
1555 set_menu_sensitivity(main_menu_factory, "/View/Zoom In",
1556 have_captured_packets);
1557 set_menu_sensitivity(main_menu_factory, "/View/Zoom Out",
1558 have_captured_packets);
1559 set_menu_sensitivity(main_menu_factory, "/View/Normal Size",
1560 have_captured_packets);
1561 set_menu_sensitivity(packet_list_menu_factory, "/Coloring Rules...",
1562 have_captured_packets);
1563 set_menu_sensitivity(main_menu_factory, "/Go/Go to Packet...",
1564 have_captured_packets);
1565 set_menu_sensitivity(main_menu_factory, "/Go/First Packet",
1566 have_captured_packets);
1567 set_menu_sensitivity(main_menu_factory, "/Go/Last Packet",
1568 have_captured_packets);
1569 set_menu_sensitivity(main_menu_factory, "/Statistics/Summary",
1570 have_captured_packets);
1571 set_menu_sensitivity(main_menu_factory, "/Statistics/Protocol Hierarchy",
1572 have_captured_packets);
1574 walk_menu_tree_for_captured_packets(tap_menu_tree_root,
1575 have_captured_packets);
1576 set_toolbar_for_captured_packets(have_captured_packets);
1577 packets_bar_update();
1580 /* Enable or disable menu items based on whether a packet is selected and,
1581 if so, on the properties of the packet. */
1583 walk_menu_tree_for_selected_packet(GList *node, frame_data *fd,
1584 epan_dissect_t *edt)
1586 gboolean is_enabled;
1588 menu_item_t *node_data = node->data;
1591 * Is this a leaf node or an interior node?
1593 if (node_data->children == NULL) {
1597 * If it has no "selected_packet_enabled()" routine,
1598 * leave its enabled/disabled status alone - it
1599 * doesn't depend on whether we have a packet selected
1600 * or not or on the selected packet.
1602 * If it has a "selected_packet_enabled()" routine,
1603 * call it and set the item's enabled/disabled status
1604 * based on its return value.
1606 if (node_data->selected_packet_enabled != NULL)
1607 node_data->enabled = node_data->selected_packet_enabled(fd, edt);
1610 * It's an interior node; call
1611 * "walk_menu_tree_for_selected_packet()" on all its
1612 * children and, if any of them are enabled, enable
1613 * this node, otherwise disable it.
1615 * XXX - should we just leave all interior nodes enabled?
1616 * Which is a better UI choice?
1619 for (child = node_data->children; child != NULL; child =
1621 if (walk_menu_tree_for_selected_packet(child, fd, edt))
1624 node_data->enabled = is_enabled;
1628 * The root node doesn't correspond to a menu tree item; it
1629 * has a null name pointer.
1631 if (node_data->name != NULL) {
1632 set_menu_sensitivity(main_menu_factory, node_data->name,
1633 node_data->enabled);
1635 return node_data->enabled;
1639 set_menus_for_selected_packet(capture_file *cf)
1641 set_menu_sensitivity(main_menu_factory, "/Edit/Mark Packet",
1642 cf->current_frame != NULL);
1643 set_menu_sensitivity(packet_list_menu_factory, "/Mark Packet",
1644 cf->current_frame != NULL);
1645 set_menu_sensitivity(main_menu_factory, "/Edit/Time Reference",
1646 cf->current_frame != NULL);
1647 set_menu_sensitivity(packet_list_menu_factory, "/Time Reference",
1648 cf->current_frame != NULL);
1649 set_menu_sensitivity(main_menu_factory, "/Edit/Mark All Packets",
1650 cf->current_frame != NULL);
1651 set_menu_sensitivity(main_menu_factory, "/Edit/Unmark All Packets",
1652 cf->current_frame != NULL);
1653 set_menu_sensitivity(main_menu_factory, "/View/Collapse All",
1654 cf->current_frame != NULL);
1655 set_menu_sensitivity(tree_view_menu_factory, "/Collapse All",
1656 cf->current_frame != NULL);
1657 set_menu_sensitivity(main_menu_factory, "/View/Expand All",
1658 cf->current_frame != NULL);
1659 set_menu_sensitivity(tree_view_menu_factory, "/Expand All",
1660 cf->current_frame != NULL);
1661 set_menu_sensitivity(main_menu_factory, "/View/Show Packet in New Window",
1662 cf->current_frame != NULL);
1663 set_menu_sensitivity(packet_list_menu_factory, "/Show Packet in New Window",
1664 cf->current_frame != NULL);
1665 set_menu_sensitivity(main_menu_factory, "/Analyze/Follow TCP Stream",
1666 cf->current_frame != NULL ? (cf->edt->pi.ipproto == IP_PROTO_TCP) : FALSE);
1667 set_menu_sensitivity(NULL, "/Follow TCP Stream",
1668 cf->current_frame != NULL ? (cf->edt->pi.ipproto == IP_PROTO_TCP) : FALSE);
1669 set_menu_sensitivity(main_menu_factory, "/Analyze/Decode As...",
1670 cf->current_frame != NULL && decode_as_ok());
1671 set_menu_sensitivity(NULL, "/Decode As...",
1672 cf->current_frame != NULL && decode_as_ok());
1673 set_menu_sensitivity(tree_view_menu_factory, "/Resolve Name",
1674 cf->current_frame != NULL && (g_resolv_flags & RESOLV_ALL_ADDRS) != RESOLV_ALL_ADDRS);
1675 set_menu_sensitivity(packet_list_menu_factory, "/Match",
1676 cf->current_frame != NULL);
1677 set_menu_sensitivity(packet_list_menu_factory, "/Prepare",
1678 cf->current_frame != NULL);
1680 walk_menu_tree_for_selected_packet(tap_menu_tree_root, cf->current_frame,
1682 packets_bar_update();
1685 /* Enable or disable menu items based on whether a tree row is selected
1686 and, if so, on the properties of the tree row. */
1688 walk_menu_tree_for_selected_tree_row(GList *node, field_info *fi)
1690 gboolean is_enabled;
1692 menu_item_t *node_data = node->data;
1695 * Is this a leaf node or an interior node?
1697 if (node_data->children == NULL) {
1701 * If it has no "selected_tree_row_enabled()" routine,
1702 * leave its enabled/disabled status alone - it
1703 * doesn't depend on whether we have a tree row selected
1704 * or not or on the selected tree row.
1706 * If it has a "selected_tree_row_enabled()" routine,
1707 * call it and set the item's enabled/disabled status
1708 * based on its return value.
1710 if (node_data->selected_tree_row_enabled != NULL)
1711 node_data->enabled = node_data->selected_tree_row_enabled(fi);
1714 * It's an interior node; call
1715 * "walk_menu_tree_for_selected_tree_row()" on all its
1716 * children and, if any of them are enabled, enable
1717 * this node, otherwise disable it.
1719 * XXX - should we just leave all interior nodes enabled?
1720 * Which is a better UI choice?
1723 for (child = node_data->children; child != NULL; child =
1725 if (walk_menu_tree_for_selected_tree_row(child, fi))
1728 node_data->enabled = is_enabled;
1732 * The root node doesn't correspond to a menu tree item; it
1733 * has a null name pointer.
1735 if (node_data->name != NULL) {
1736 set_menu_sensitivity(main_menu_factory, node_data->name,
1737 node_data->enabled);
1739 return node_data->enabled;
1743 set_menus_for_selected_tree_row(capture_file *cf)
1745 gboolean properties;
1748 set_menu_sensitivity(main_menu_factory, "/File/Export/Selected Packet Bytes...",
1749 cf->finfo_selected != NULL);
1750 set_menu_sensitivity(tree_view_menu_factory, "/Export Selected Packet Bytes...",
1751 cf->finfo_selected != NULL);
1752 set_menu_sensitivity(hexdump_menu_factory, "/Export Selected Packet Bytes...",
1753 cf->finfo_selected != NULL);
1755 if (cf->finfo_selected != NULL) {
1756 header_field_info *hfinfo = cf->finfo_selected->hfinfo;
1757 if (hfinfo->parent == -1) {
1758 properties = prefs_is_registered_protocol(hfinfo->abbrev);
1760 properties = prefs_is_registered_protocol(proto_registrar_get_abbrev(hfinfo->parent));
1762 set_menu_sensitivity(main_menu_factory,
1763 "/Go/Go to Corresponding Packet", hfinfo->type == FT_FRAMENUM);
1764 set_menu_sensitivity(tree_view_menu_factory,
1765 "/Go to Corresponding Packet", hfinfo->type == FT_FRAMENUM);
1766 set_menu_sensitivity(main_menu_factory, "/Analyze/Match",
1767 proto_can_match_selected(cf->finfo_selected, cf->edt));
1768 set_menu_sensitivity(tree_view_menu_factory, "/Match",
1769 proto_can_match_selected(cf->finfo_selected, cf->edt));
1770 set_menu_sensitivity(main_menu_factory, "/Analyze/Prepare",
1771 proto_can_match_selected(cf->finfo_selected, cf->edt));
1772 set_menu_sensitivity(tree_view_menu_factory, "/Prepare",
1773 proto_can_match_selected(cf->finfo_selected, cf->edt));
1774 set_menu_sensitivity(tree_view_menu_factory, "/Protocol Properties...",
1776 set_menu_sensitivity(main_menu_factory, "/View/Expand Tree", cf->finfo_selected->tree_type != -1);
1777 set_menu_sensitivity(tree_view_menu_factory, "/Expand Tree", cf->finfo_selected->tree_type != -1);
1779 set_menu_sensitivity(main_menu_factory,
1780 "/Go/Go to Corresponding Packet", FALSE);
1781 set_menu_sensitivity(tree_view_menu_factory,
1782 "/Go to Corresponding Packet", FALSE);
1783 set_menu_sensitivity(main_menu_factory, "/Analyze/Match", FALSE);
1784 set_menu_sensitivity(tree_view_menu_factory, "/Match", FALSE);
1785 set_menu_sensitivity(main_menu_factory, "/Analyze/Prepare", FALSE);
1786 set_menu_sensitivity(tree_view_menu_factory, "/Prepare", FALSE);
1787 set_menu_sensitivity(tree_view_menu_factory, "/Protocol Properties...",
1789 set_menu_sensitivity(main_menu_factory, "/View/Expand Tree", FALSE);
1790 set_menu_sensitivity(tree_view_menu_factory, "/Expand Tree", FALSE);
1793 walk_menu_tree_for_selected_tree_row(tap_menu_tree_root, cf->finfo_selected);