Internalize struct preference
[metze/wireshark/wip.git] / ui / gtk / main_menubar.c
1 /* main_menubar.c
2  * Menu routines
3  *
4  * Wireshark - Network traffic analyzer
5  * By Gerald Combs <gerald@wireshark.org>
6  * Copyright 1998 Gerald Combs
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21  */
22 #include "config.h"
23
24 #include <gtk/gtk.h>
25
26 #include <stdlib.h>
27 #include <string.h>
28
29 #include <epan/packet.h>
30 #include <epan/prefs.h>
31 #include <epan/prefs-int.h>
32 #include <epan/dissector_filters.h>
33 #include <epan/epan_dissect.h>
34 #include <epan/column.h>
35 #include <epan/stats_tree_priv.h>
36 #include <epan/plugin_if.h>
37 #include <epan/export_object.h>
38
39 #include "globals.h"
40 #include <epan/color_filters.h>
41
42 #include "ui/commandline.h"
43 #include "ui/dissect_opts.h"
44 #include "ui/main_statusbar.h"
45 #include "ui/preference_utils.h"
46 #include "ui/recent.h"
47 #include "ui/recent_utils.h"
48 #include "ui/simple_dialog.h"
49 #include "ui/software_update.h"
50 #include <wsutil/utf8_entities.h>
51
52 #include "ui/gtk/gui_stat_menu.h"
53 #include "ui/gtk/about_dlg.h"
54 #include "ui/gtk/capture_dlg.h"
55 #include "ui/gtk/capture_if_dlg.h"
56 #include "ui/gtk/color_dlg.h"
57 #include "ui/gtk/export_object_dlg.h"
58 #include "ui/gtk/filter_dlg.h"
59 #include "ui/gtk/profile_dlg.h"
60 #include "ui/gtk/dlg_utils.h"
61 #include "ui/gtk/capture_file_dlg.h"
62 #include "ui/gtk/fileset_dlg.h"
63 #include "ui/gtk/file_import_dlg.h"
64 #include "ui/gtk/find_dlg.h"
65 #include "ui/gtk/goto_dlg.h"
66 #include "ui/gtk/summary_dlg.h"
67 #include "ui/gtk/prefs_dlg.h"
68 #include "ui/gtk/packet_win.h"
69 #include "ui/gtk/follow_stream.h"
70 #include "ui/gtk/decode_as_dlg.h"
71 #include "ui/gtk/help_dlg.h"
72 #include "ui/gtk/supported_protos_dlg.h"
73 #include "ui/gtk/proto_dlg.h"
74 #include "ui/gtk/proto_hier_stats_dlg.h"
75 #include "ui/gtk/keys.h"
76 #include "ui/gtk/stock_icons.h"
77 #include "ui/gtk/gtkglobals.h"
78 #include "ui/gtk/packet_panes.h"
79 #include "ui/gtk/conversations_table.h"
80 #include "ui/gtk/hostlist_table.h"
81 #include "ui/gtk/packet_history.h"
82 #include "ui/gtk/sctp_stat_gtk.h"
83 #include "ui/gtk/firewall_dlg.h"
84 #include "ui/gtk/macros_dlg.h"
85 #include "ui/gtk/export_sslkeys.h"
86 #include "ui/gtk/gui_stat_menu.h"
87 #include "ui/gtk/main.h"
88 #include "ui/gtk/menus.h"
89 #include "ui/gtk/main_menubar_private.h"
90 #include "ui/gtk/main_toolbar.h"
91 #include "ui/gtk/main_welcome.h"
92 #include "ui/gtk/uat_gui.h"
93 #include "ui/gtk/gui_utils.h"
94 #include "ui/gtk/manual_addr_resolv.h"
95 #include "ui/gtk/dissector_tables_dlg.h"
96 #include "ui/gtk/expert_comp_dlg.h"
97 #include "ui/gtk/time_shift_dlg.h"
98 #include "ui/gtk/edit_packet_comment_dlg.h"
99 #include "ui/gtk/addr_resolution_dlg.h"
100 #include "ui/gtk/export_pdu_dlg.h"
101 #include "ui/gtk/conversation_hastables_dlg.h"
102 #include "ui/gtk/webbrowser.h"
103
104 #include "ui/gtk/packet_list.h"
105 #include "ui/gtk/lbm_stream_dlg.h"
106 #include "ui/gtk/lbm_uimflow_dlg.h"
107
108 #ifdef HAVE_LIBPCAP
109 #include "capture_opts.h"
110 #include "ui/capture_globals.h"
111 #endif
112 #ifdef HAVE_IGE_MAC_INTEGRATION
113 #include <ige-mac-menu.h>
114 #endif
115
116 #ifdef HAVE_GTKOSXAPPLICATION
117 #include <gtkmacintegration/gtkosxapplication.h>
118 #endif
119
120 static int initialize = TRUE;
121 GtkActionGroup    *main_menu_bar_action_group;
122 static GtkUIManager *ui_manager_main_menubar = NULL;
123 static GtkUIManager *ui_manager_packet_list_heading = NULL;
124 static GtkUIManager *ui_manager_packet_list_menu = NULL;
125 static GtkUIManager *ui_manager_tree_view_menu = NULL;
126 static GtkUIManager *ui_manager_bytes_menu = NULL;
127 static GtkUIManager *ui_manager_statusbar_profiles_menu = NULL;
128 static GSList *popup_menu_list = NULL;
129
130 static GtkAccelGroup *grp;
131
132 static GList *merge_menu_items_list = NULL;
133 static GList *build_menubar_items_callback_list = NULL;
134
135 GtkWidget *popup_menu_object;
136
137 static void menu_open_recent_file_cmd_cb(GtkAction *action, gpointer data _U_ );
138 static void add_recent_items (guint merge_id, GtkUIManager *ui_manager);
139 static void add_tap_plugins (guint merge_id, GtkUIManager *ui_manager);
140
141 static void menus_init(void);
142 static void merge_menu_items(GList *node);
143 static void ws_menubar_external_menus(void);
144 static void ws_menubar_build_external_menus(void);
145 static void set_menu_sensitivity (GtkUIManager *ui_manager, const gchar *, gint);
146 static void menu_name_resolution_update_cb(GtkAction *action, gpointer data);
147 static void name_resolution_cb(GtkWidget *w, gpointer d, gboolean* res_flag);
148 static void colorize_cb(GtkWidget *w, gpointer d);
149 static void rebuild_protocol_prefs_menu (module_t *prefs_module_p, gboolean preferences,
150         GtkUIManager *ui_menu, const char *path);
151
152 static void plugin_if_menubar_preference(gconstpointer user_data);
153
154
155 /*  As a general GUI guideline, we try to follow the Gnome Human Interface Guidelines, which can be found at:
156     http://developer.gnome.org/projects/gup/hig/1.0/index.html
157
158 Please note: there are some differences between the Gnome HIG menu suggestions and our implementation:
159
160 File/Open Recent:   the Gnome HIG suggests putting the list of recently used files as elements into the File menuitem.
161                     As this is ok for only a few items, this will become unhandy for 10 or even more list entries.
162                     For this reason, we use a submenu for this.
163
164 File/Close:         the Gnome HIG suggests putting this item just above the Quit item.
165                     This results in unintuitive behaviour as both Close and Quit items are very near together.
166                     By putting the Close item near the open item(s), it better suggests that it will close the
167                     currently opened/captured file only.
168 */
169
170 static void
171 new_window_cb(GtkWidget *widget)
172 {
173     new_packet_window(widget, FALSE, FALSE);
174 }
175
176 static void
177 new_window_cb_ref(GtkWidget *widget)
178 {
179     new_packet_window(widget, TRUE, FALSE);
180 }
181
182 #ifdef WANT_PACKET_EDITOR
183 static void
184 edit_window_cb(GtkWidget *widget _U_)
185 {
186     new_packet_window(widget, FALSE, TRUE);
187 }
188 #endif
189
190 static void
191 colorize_conversation_cb(conversation_filter_t* color_filter, int action_num)
192 {
193     gchar *filter = NULL;
194     packet_info *pi = &cfile.edt->pi;
195     gchar *err_msg = NULL;
196
197     if (action_num == 255) {
198         if (!color_filters_reset_tmp(&err_msg)) {
199             simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_msg);
200             g_free(err_msg);
201         }
202         packet_list_colorize_packets();
203     } else if (cfile.current_frame) {
204         if (color_filter == NULL) {
205             /* colorize_conversation_cb was called from the window-menu
206                 * or through an accelerator key. Try to build a conversation
207                 * filter in the order TCP, UDP, IP, Ethernet and apply the
208                 * coloring */
209             color_filter = find_conversation_filter("tcp");
210             if ((color_filter != NULL) && (color_filter->is_filter_valid(pi)))
211                 filter = color_filter->build_filter_string(pi);
212             if (filter == NULL) {
213                 color_filter = find_conversation_filter("udp");
214                 if ((color_filter != NULL) && (color_filter->is_filter_valid(pi)))
215                     filter = color_filter->build_filter_string(pi);
216             }
217             if (filter == NULL) {
218                 color_filter = find_conversation_filter("ip");
219                 if ((color_filter != NULL) && (color_filter->is_filter_valid(pi)))
220                     filter = color_filter->build_filter_string(pi);
221             }
222             if (filter == NULL) {
223                 color_filter = find_conversation_filter("ipv6");
224                 if ((color_filter != NULL) && (color_filter->is_filter_valid(pi)))
225                     filter = color_filter->build_filter_string(pi);
226             }
227             if (filter == NULL) {
228                 color_filter = find_conversation_filter("eth");
229                 if ((color_filter != NULL) && (color_filter->is_filter_valid(pi)))
230                     filter = color_filter->build_filter_string(pi);
231             }
232             if( filter == NULL ) {
233                 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "Unable to build conversation filter.");
234                 return;
235             }
236         } else {
237             filter = color_filter->build_filter_string(pi);
238         }
239
240         if (action_num == 0) {
241             /* Open the "new coloring filter" dialog with the filter */
242             color_display_with_filter(filter);
243         } else {
244             /* Set one of the temporary coloring filters */
245             if (!color_filters_set_tmp(action_num, filter, FALSE, &err_msg)) {
246                 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_msg);
247                 g_free(err_msg);
248             }
249             packet_list_colorize_packets();
250         }
251
252         g_free(filter);
253     }
254 }
255
256 static void
257 goto_conversation_frame(gboolean dir)
258 {
259     gchar     *filter       = NULL;
260     dfilter_t *dfcode       = NULL;
261     gboolean   found_packet = FALSE;
262     packet_info *pi = &cfile.edt->pi;
263     conversation_filter_t* conv_filter;
264
265     /* Try to build a conversation
266      * filter in the order TCP, UDP, IP, Ethernet and apply the
267      * coloring */
268     conv_filter = find_conversation_filter("tcp");
269     if ((conv_filter != NULL) && (conv_filter->is_filter_valid(pi)))
270         filter = conv_filter->build_filter_string(pi);
271     conv_filter = find_conversation_filter("udp");
272     if ((conv_filter != NULL) && (conv_filter->is_filter_valid(pi)))
273         filter = conv_filter->build_filter_string(pi);
274     conv_filter = find_conversation_filter("ip");
275     if ((conv_filter != NULL) && (conv_filter->is_filter_valid(pi)))
276         filter = conv_filter->build_filter_string(pi);
277     conv_filter = find_conversation_filter("ipv6");
278     if ((conv_filter != NULL) && (conv_filter->is_filter_valid(pi)))
279         filter = conv_filter->build_filter_string(pi);
280
281     if( filter == NULL ) {
282         statusbar_push_temporary_msg("Unable to build conversation filter.");
283         g_free(filter);
284         return;
285     }
286
287     if (!dfilter_compile(filter, &dfcode, NULL)) {
288         /* The attempt failed; report an error. */
289         statusbar_push_temporary_msg("Error compiling filter for this conversation.");
290         g_free(filter);
291         return;
292     }
293
294     found_packet = cf_find_packet_dfilter(&cfile, dfcode, dir?SD_BACKWARD:SD_FORWARD);
295
296     if (!found_packet) {
297         /* We didn't find a packet */
298         statusbar_push_temporary_msg("No previous/next packet in conversation.");
299     }
300
301     dfilter_free(dfcode);
302     g_free(filter);
303 }
304
305 static void
306 goto_next_frame_conversation_cb(GtkAction *action _U_, gpointer user_data _U_)
307 {
308     goto_conversation_frame(FALSE);
309 }
310
311 static void
312 goto_previous_frame_conversation_cb(GtkAction *action _U_, gpointer user_data _U_)
313 {
314     goto_conversation_frame(TRUE);
315 }
316
317
318
319 static void
320 copy_description_cb(GtkAction *action _U_, gpointer user_data)
321 {
322     copy_selected_plist_cb( NULL /* widget _U_ */ , user_data, COPY_SELECTED_DESCRIPTION);
323 }
324
325 static void
326 copy_fieldname_cb(GtkAction *action _U_, gpointer user_data)
327 {
328     copy_selected_plist_cb( NULL /* widget _U_ */ , user_data, COPY_SELECTED_FIELDNAME);
329 }
330
331 static void
332 copy_value_cb(GtkAction *action _U_, gpointer user_data)
333 {
334     copy_selected_plist_cb( NULL /* widget _U_ */ , user_data, COPY_SELECTED_VALUE);
335 }
336
337 static void
338 copy_as_filter_cb(GtkAction *action _U_, gpointer user_data _U_)
339 {
340     /* match_selected_ptree_cb needs the popup_menu_object to get the right object E_DFILTER_TE_KEY */
341     match_selected_ptree_cb( popup_menu_object, (MATCH_SELECTED_E)(MATCH_SELECTED_REPLACE|MATCH_SELECTED_COPY_ONLY));
342 }
343
344 static void
345 set_reftime_cb(GtkAction *action _U_, gpointer user_data)
346 {
347     reftime_frame_cb( NULL /* widget _U_ */ , user_data, REFTIME_TOGGLE);
348 }
349
350 static void
351 find_next_ref_time_cb(GtkAction *action _U_, gpointer user_data)
352 {
353     reftime_frame_cb( NULL /* widget _U_ */ , user_data, REFTIME_FIND_NEXT);
354 }
355
356 static void
357 find_previous_ref_time_cb(GtkAction *action _U_, gpointer user_data)
358 {
359     reftime_frame_cb( NULL /* widget _U_ */ , user_data, REFTIME_FIND_PREV);
360 }
361
362 static void
363 menus_prefs_cb(GtkAction *action _U_, gpointer user_data)
364 {
365     prefs_page_cb( NULL /* widget _U_ */ , user_data, PREFS_PAGE_USER_INTERFACE);
366 }
367
368 static void
369 main_toolbar_show_hide_cb(GtkAction *action _U_, gpointer user_data _U_)
370 {
371     GtkWidget *widget = gtk_ui_manager_get_widget(ui_manager_main_menubar, "/Menubar/ViewMenu/MainToolbar");
372
373     recent.main_toolbar_show = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget));
374     main_widgets_show_or_hide();
375
376 }
377
378 static void
379 filter_toolbar_show_hide_cb(GtkAction * action _U_, gpointer user_data _U_)
380 {
381     GtkWidget *widget = gtk_ui_manager_get_widget(ui_manager_main_menubar, "/Menubar/ViewMenu/FilterToolbar");
382
383     recent.filter_toolbar_show = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget));
384     main_widgets_show_or_hide();
385 }
386
387 static void
388 wireless_toolbar_show_hide_cb(GtkAction *action _U_, gpointer user_data _U_)
389 {
390     GtkWidget *widget = gtk_ui_manager_get_widget(ui_manager_main_menubar, "/Menubar/ViewMenu/WirelessToolbar");
391
392     if(widget) {
393         recent.wireless_toolbar_show = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget));
394     } else {
395         recent.wireless_toolbar_show = FALSE;
396     }
397     main_widgets_show_or_hide();
398 }
399
400 static void
401 status_bar_show_hide_cb(GtkAction *action _U_, gpointer user_data _U_)
402 {
403     GtkWidget *widget = gtk_ui_manager_get_widget(ui_manager_main_menubar, "/Menubar/ViewMenu/StatusBar");
404
405     recent.statusbar_show = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget));
406     main_widgets_show_or_hide();
407 }
408 static void
409 packet_list_show_hide_cb(GtkAction *action _U_, gpointer user_data _U_)
410 {
411     GtkWidget *widget = gtk_ui_manager_get_widget(ui_manager_main_menubar, "/Menubar/ViewMenu/PacketList");
412
413     recent.packet_list_show = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget));
414     main_widgets_show_or_hide();
415 }
416 static void
417 packet_details_show_hide_cb(GtkAction *action _U_, gpointer user_data _U_)
418 {
419     GtkWidget *widget = gtk_ui_manager_get_widget(ui_manager_main_menubar, "/Menubar/ViewMenu/PacketDetails");
420
421     recent.tree_view_show = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget));
422     main_widgets_show_or_hide();
423 }
424 static void
425 packet_bytes_show_hide_cb(GtkAction *action _U_, gpointer user_data _U_)
426 {
427     GtkWidget *widget = gtk_ui_manager_get_widget(ui_manager_main_menubar, "/Menubar/ViewMenu/PacketBytes");
428
429     recent.byte_view_show = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget));
430     main_widgets_show_or_hide();
431 }
432
433 static void
434 timestamp_seconds_time_cb(GtkAction *action _U_, gpointer user_data _U_)
435 {
436     GtkWidget *widget = gtk_ui_manager_get_widget(ui_manager_main_menubar, "/Menubar/ViewMenu/TimeDisplayFormat/DisplaySecondsWithHoursAndMinutes");
437
438     if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget))) {
439         recent.gui_seconds_format = TS_SECONDS_HOUR_MIN_SEC;
440     } else {
441         recent.gui_seconds_format = TS_SECONDS_DEFAULT;
442     }
443     timestamp_set_seconds_type (recent.gui_seconds_format);
444
445     /* This call adjusts column width */
446     cf_timestamp_auto_precision(&cfile);
447     packet_list_queue_draw();
448 }
449
450 static void
451 timestamp_format_new_cb (GtkRadioAction *action, GtkRadioAction *current _U_, gpointer user_data  _U_)
452 {
453     ts_type value;
454
455     value = (ts_type) gtk_radio_action_get_current_value (action);
456     if (recent.gui_time_format != value) {
457         timestamp_set_type(value);
458         recent.gui_time_format = value;
459         /* This call adjusts column width */
460         cf_timestamp_auto_precision(&cfile);
461         packet_list_queue_draw();
462     }
463
464 }
465
466 static void
467 timestamp_precision_new_cb (GtkRadioAction *action, GtkRadioAction *current _U_, gpointer user_data _U_)
468 {
469     gint value;
470
471     value = gtk_radio_action_get_current_value (action);
472     if (recent.gui_time_precision != value) {
473         /* the actual precision will be set in packet_list_queue_draw() below */
474         timestamp_set_precision(value);
475         recent.gui_time_precision  = value;
476         /* This call adjusts column width */
477         cf_timestamp_auto_precision(&cfile);
478         packet_list_queue_draw();
479     }
480 }
481
482 static void
483 view_menu_en_for_MAC_cb(GtkAction *action _U_, gpointer user_data)
484 {
485     GtkWidget *widget = gtk_ui_manager_get_widget(ui_manager_main_menubar, "/Menubar/ViewMenu/NameResolution/EnableforMACLayer");
486
487     if (!widget){
488         g_warning("view_menu_en_for_MAC_cb: No widget found");
489     }else{
490         name_resolution_cb( widget , user_data, &gbl_resolv_flags.mac_name);
491     }
492 }
493
494 static void
495 view_menu_en_for_network_cb(GtkAction *action _U_, gpointer user_data)
496 {
497     GtkWidget *widget = gtk_ui_manager_get_widget(ui_manager_main_menubar, "/Menubar/ViewMenu/NameResolution/EnableforNetworkLayer");
498
499     if (!widget){
500         g_warning("view_menu_en_for_network_cb: No widget found");
501     }else{
502         name_resolution_cb( widget , user_data, &gbl_resolv_flags.network_name);
503     }
504 }
505
506 static void
507 view_menu_en_for_transport_cb(GtkAction *action _U_, gpointer user_data)
508 {
509     GtkWidget *widget = gtk_ui_manager_get_widget(ui_manager_main_menubar, "/Menubar/ViewMenu/NameResolution/EnableforTransportLayer");
510
511     if (!widget){
512         g_warning("view_menu_en_for_transport_cb: No widget found");
513     }else{
514         name_resolution_cb( widget , user_data, &gbl_resolv_flags.transport_name);
515     }
516 }
517
518 static void
519 view_menu_en_use_external_resolver_cb(GtkAction *action _U_, gpointer user_data)
520 {
521     GtkWidget *widget = gtk_ui_manager_get_widget(ui_manager_main_menubar, "/Menubar/ViewMenu/NameResolution/UseExternalNetworkNameResolver");
522
523     if (!widget){
524         g_warning("view_menu_en_use_external_resolver_cb: No widget found");
525     }else{
526         name_resolution_cb( widget , user_data, &gbl_resolv_flags.use_external_net_name_resolver);
527     }
528 }
529
530 static void
531 view_menu_colorize_pkt_lst_cb(GtkAction *action _U_, gpointer user_data)
532 {
533     GtkWidget *widget = gtk_ui_manager_get_widget(ui_manager_main_menubar, "/Menubar/ViewMenu/ColorizePacketList");
534
535     if (!widget){
536         g_warning("view_menu_colorize_pkt_lst_cb: No widget found");
537     }else{
538         colorize_cb( widget , user_data);
539     }
540
541 }
542
543 #ifdef HAVE_LIBPCAP
544 static void
545 view_menu_auto_scroll_live_cb(GtkAction *action _U_, gpointer user_data _U_)
546 {
547     GtkWidget *widget = gtk_ui_manager_get_widget(ui_manager_main_menubar, "/Menubar/ViewMenu/AutoScrollinLiveCapture");
548
549     if (!widget){
550         g_warning("view_menu_auto_scroll_live_cb: No widget found");
551     }else{
552         main_auto_scroll_live_changed(gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget)));
553     }
554 }
555 #endif
556
557 static void
558 view_menu_color_conv_color1_cb(GtkAction *action _U_, gpointer user_data _U_)
559 {
560     colorize_conversation_cb(NULL, 1);
561 }
562
563 static void
564 view_menu_color_conv_color2_cb(GtkAction *action _U_, gpointer user_data _U_)
565 {
566     colorize_conversation_cb(NULL, 2);
567 }
568
569 static void
570 view_menu_color_conv_color3_cb(GtkAction *action _U_, gpointer user_data _U_)
571 {
572     colorize_conversation_cb(NULL, 3);
573 }
574
575 static void
576 view_menu_color_conv_color4_cb(GtkAction *action _U_, gpointer user_data _U_)
577 {
578     colorize_conversation_cb(NULL, 4);
579 }
580
581 static void
582 view_menu_color_conv_color5_cb(GtkAction *action _U_, gpointer user_data _U_)
583 {
584     colorize_conversation_cb(NULL, 5);
585 }
586
587 static void
588 view_menu_color_conv_color6_cb(GtkAction *action _U_, gpointer user_data _U_)
589 {
590     colorize_conversation_cb(NULL, 6);
591 }
592
593 static void
594 view_menu_color_conv_color7_cb(GtkAction *action _U_, gpointer user_data _U_)
595 {
596     colorize_conversation_cb(NULL, 7);
597 }
598
599 static void
600 view_menu_color_conv_color8_cb(GtkAction *action _U_, gpointer user_data _U_)
601 {
602     colorize_conversation_cb(NULL, 8);
603 }
604
605 static void
606 view_menu_color_conv_color9_cb(GtkAction *action _U_, gpointer user_data _U_)
607 {
608     colorize_conversation_cb(NULL, 9);
609 }
610
611 static void
612 view_menu_color_conv_color10_cb(GtkAction *action _U_, gpointer user_data _U_)
613 {
614     colorize_conversation_cb(NULL, 10);
615 }
616
617 static void
618 view_menu_color_conv_new_rule_cb(GtkAction *action _U_, gpointer user_data _U_)
619 {
620     colorize_conversation_cb(NULL, 0);
621 }
622
623 static void
624 view_menu_reset_coloring_cb(GtkAction *action _U_, gpointer user_data _U_)
625 {
626     colorize_conversation_cb(NULL, 255);
627 }
628
629 /*
630  * TODO Move this menu to capture_if_dlg.c ?
631  */
632 #ifdef HAVE_LIBPCAP
633 static void
634 capture_if_action_cb(GtkAction *action _U_, gpointer user_data)
635 {
636     capture_if_cb(NULL /* GtkWidget *w _U_ */, user_data);
637 }
638
639 static void
640 capture_prep_action_cb(GtkAction *action _U_, gpointer user_data)
641 {
642     capture_prep_cb(NULL /* GtkWidget *w _U_ */, user_data);
643 }
644
645 static void
646 capture_start_action_cb(GtkAction *action _U_, gpointer user_data)
647 {
648     capture_start_cb(NULL /* GtkWidget *w _U_ */, user_data);
649 }
650
651 static void
652 capture_stop_action_cb(GtkAction *action _U_, gpointer user_data)
653 {
654     capture_stop_cb(NULL /* GtkWidget *w _U_ */, user_data);
655 }
656
657 static void
658 capture_restart_action_cb(GtkAction *action _U_, gpointer user_data)
659 {
660     capture_restart_cb(NULL /* GtkWidget *w _U_ */, user_data);
661 }
662
663 static void
664 capture_filters_action_cb(GtkAction *action _U_, gpointer user_data _U_)
665 {
666     cfilter_dialog_cb(NULL /* GtkWidget *w _U_ */);
667 }
668
669 /*
670  * We've been asked to rescan the system looking for interfaces.
671  */
672 static void
673 refresh_interfaces_action_cb(GtkAction *action _U_, gpointer user_data _U_)
674 {
675     refresh_local_interface_lists();
676 }
677 #endif /* HAVE_LIBPCAP */
678
679 static void
680 help_menu_cont_cb(GtkAction *action _U_, gpointer user_data _U_)
681 {
682     topic_menu_cb(NULL/*widget _U_ */, NULL /*GdkEventButton *event _U_*/, GINT_TO_POINTER(HELP_CONTENT));
683 }
684
685 static void
686 help_menu_faq_cb(GtkAction *action _U_, gpointer user_data _U_)
687 {
688     topic_menu_cb(NULL/*widget _U_ */, NULL /*GdkEventButton *event _U_*/, GINT_TO_POINTER(ONLINEPAGE_FAQ));
689 }
690
691 static void
692 help_menu_ask_cb(GtkAction *action _U_, gpointer user_data _U_)
693 {
694     topic_menu_cb(NULL/*widget _U_ */, NULL /*GdkEventButton *event _U_*/, GINT_TO_POINTER(ONLINEPAGE_ASK));
695 }
696
697 static void
698 help_menu_wireshark_cb(GtkAction *action _U_, gpointer user_data _U_)
699 {
700     topic_menu_cb(NULL/*widget _U_ */, NULL /*GdkEventButton *event _U_*/, GINT_TO_POINTER(LOCALPAGE_MAN_WIRESHARK));
701 }
702
703 static void
704 help_menu_wireshark_flt_cb(GtkAction *action _U_, gpointer user_data _U_)
705 {
706     topic_menu_cb(NULL/*widget _U_ */, NULL /*GdkEventButton *event _U_*/, GINT_TO_POINTER(LOCALPAGE_MAN_WIRESHARK_FILTER));
707 }
708
709 static void
710 help_menu_Capinfos_cb(GtkAction *action _U_, gpointer user_data _U_)
711 {
712     topic_menu_cb(NULL/*widget _U_ */, NULL /*GdkEventButton *event _U_*/, GINT_TO_POINTER(LOCALPAGE_MAN_CAPINFOS));
713 }
714
715 static void
716 help_menu_Dumpcap_cb(GtkAction *action _U_, gpointer user_data _U_)
717 {
718     topic_menu_cb(NULL/*widget _U_ */, NULL /*GdkEventButton *event _U_*/, GINT_TO_POINTER(LOCALPAGE_MAN_DUMPCAP));
719 }
720
721 static void
722 help_menu_Editcap_cb(GtkAction *action _U_, gpointer user_data _U_)
723 {
724     topic_menu_cb(NULL/* widget _U_ */, NULL /*GdkEventButton *event _U_*/, GINT_TO_POINTER(LOCALPAGE_MAN_EDITCAP));
725 }
726
727 static void
728 help_menu_Mergecap_cb(GtkAction *action _U_, gpointer user_data _U_)
729 {
730     topic_menu_cb(NULL/*widget _U_ */, NULL /*GdkEventButton *event _U_*/, GINT_TO_POINTER(LOCALPAGE_MAN_MERGECAP));
731 }
732
733 static void
734 help_menu_RawShark_cb(GtkAction *action _U_, gpointer user_data _U_)
735 {
736     topic_menu_cb(NULL/*widget _U_ */, NULL /*GdkEventButton *event _U_*/, GINT_TO_POINTER(LOCALPAGE_MAN_RAWSHARK));
737 }
738
739 static void
740 help_menu_Reorder_cb(GtkAction *action _U_, gpointer user_data _U_)
741 {
742     topic_menu_cb(NULL/*widget _U_ */, NULL /*GdkEventButton *event _U_*/, GINT_TO_POINTER(LOCALPAGE_MAN_REORDERCAP));
743 }
744
745 static void
746 help_menu_Text2pcap_cb(GtkAction *action _U_, gpointer user_data _U_)
747 {
748     topic_menu_cb(NULL/* widget _U_ */, NULL /*GdkEventButton *event _U_*/, GINT_TO_POINTER(LOCALPAGE_MAN_TEXT2PCAP));
749 }
750
751 static void
752 help_menu_TShark_cb(GtkAction *action _U_, gpointer user_data _U_)
753 {
754     topic_menu_cb(NULL/*widget _U_ */, NULL /*GdkEventButton *event _U_*/, GINT_TO_POINTER(LOCALPAGE_MAN_TSHARK));
755 }
756
757 static void
758 help_menu_Website_cb(GtkAction *action _U_, gpointer user_data _U_)
759 {
760     topic_menu_cb(NULL/* widget _U_ */, NULL /*GdkEventButton *event _U_*/, GINT_TO_POINTER(ONLINEPAGE_HOME));
761 }
762
763 static void
764 help_menu_Wiki_cb(GtkAction *action _U_, gpointer user_data _U_)
765 {
766     topic_menu_cb(NULL/* widget _U_ */, NULL /*GdkEventButton *event _U_*/, GINT_TO_POINTER(ONLINEPAGE_WIKI));
767 }
768
769 static void
770 help_menu_Downloads_cb(GtkAction *action _U_, gpointer user_data _U_)
771 {
772     topic_menu_cb(NULL/* widget _U_ */, NULL /*GdkEventButton *event _U_*/, GINT_TO_POINTER(ONLINEPAGE_DOWNLOAD));
773 }
774
775 static void
776 help_menu_SampleCaptures_cb(GtkAction *action _U_, gpointer user_data _U_)
777 {
778     topic_menu_cb( NULL/* widget_U_ */, NULL /*GdkEventButton *event _U_*/, GINT_TO_POINTER(ONLINEPAGE_SAMPLE_FILES));
779 }
780
781 #ifdef HAVE_SOFTWARE_UPDATE
782 static void
783 check_for_updates_cb(GtkAction *action _U_, gpointer user_data _U_)
784 {
785     software_update_check();
786 }
787 #endif /* HAVE_SOFTWARE_UPDATE */
788
789 static const char *ui_desc_menubar =
790 "<ui>\n"
791 "  <menubar name ='Menubar'>\n"
792 "    <menu name= 'FileMenu' action='/File'>\n"
793 "      <menuitem name='Open' action='/File/Open'/>\n"
794 "      <menu name='OpenRecent' action='/File/OpenRecent'>\n"
795 "         <placeholder name='RecentFiles'/>\n"
796 "      </menu>\n"
797 "      <menuitem name='Merge' action='/File/Merge'/>\n"
798 "      <menuitem name='ImportFromHexDump' action='/File/ImportFromHexDump'/>\n"
799 "      <menuitem name='Close' action='/File/Close'/>\n"
800 "      <separator/>\n"
801 "      <menuitem name='Save' action='/File/Save'/>\n"
802 "      <menuitem name='SaveAs' action='/File/SaveAs'/>\n"
803 "      <separator/>\n"
804 "      <menu name= 'Set' action='/File/Set'>\n"
805 "        <menuitem name='ListFiles' action='/File/Set/ListFiles'/>\n"
806 "        <menuitem name='NextFile' action='/File/Set/NextFile'/>\n"
807 "        <menuitem name='PreviousFile' action='/File/Set/PreviousFile'/>\n"
808 "      </menu>\n"
809 "      <separator/>\n"
810 "      <menuitem name='ExportSpecifiedPackets' action='/File/ExportSpecifiedPackets'/>\n"
811 "      <menu name= 'ExportPacketDissections' action='/File/ExportPacketDissections'>\n"
812 "        <menuitem name='AsTxt' action='/File/ExportPacketDissections/Text'/>\n"
813 "        <menuitem name='AsPostScript' action='/File/ExportPacketDissections/PostScript'/>\n"
814 "        <menuitem name='AsCSV' action='/File/ExportPacketDissections/CSV'/>\n"
815 "        <menuitem name='AsCArrays' action='/File/ExportPacketDissections/CArrays'/>\n"
816 "        <separator/>\n"
817 "        <menuitem name='AsPSML' action='/File/ExportPacketDissections/PSML'/>\n"
818 "        <menuitem name='AsPDML' action='/File/ExportPacketDissections/PDML'/>\n"
819 "        <menuitem name='AsJSON' action='/File/ExportPacketDissections/JSON'/>\n"
820 "        <separator/>\n"
821 "      </menu>\n"
822 "      <menuitem name='ExportSelectedPacketBytes' action='/File/ExportSelectedPacketBytes'/>\n"
823 "      <menuitem name='ExportPDUs' action='/File/ExportPDUs'/>\n"
824 "      <menuitem name='ExportSSLSessionKeys' action='/File/ExportSSLSessionKeys'/>\n"
825 "      <menu name= 'ExportObjectsMenu' action='/File/ExportObjects'>\n"
826 "        <placeholder name='ExportObjects'/>\n"
827 "      </menu>\n"
828 "      <separator/>\n"
829 "      <menuitem name='Print' action='/File/Print'/>\n"
830 "      <separator/>\n"
831 "        <menuitem name='Quit' action='/File/Quit'/>\n"
832 "    </menu>\n"
833 "    <menu name= 'EditMenu' action='/Edit'>\n"
834 "        <menu name= 'Copy' action='/Edit/Copy'>\n"
835 "          <menuitem name='Description' action='/Edit/Copy/Description'/>\n"
836 "          <menuitem name='Fieldname' action='/Edit/Copy/Fieldname'/>\n"
837 "          <menuitem name='Value' action='/Edit/Copy/Value'/>\n"
838 "          <separator/>\n"
839 "          <menuitem name='AsFilter' action='/Edit/Copy/AsFilter'/>\n"
840 "        </menu>\n"
841 "        <menuitem name='FindPacket' action='/Edit/FindPacket'/>\n"
842 "        <menuitem name='FindNext' action='/Edit/FindNext'/>\n"
843 "        <menuitem name='FindPrevious' action='/Edit/FindPrevious'/>\n"
844 "        <separator/>\n"
845 "        <menuitem name='MarkPacket' action='/Edit/MarkPacket'/>\n"
846 "        <menuitem name='MarkAllDisplayedPackets' action='/Edit/MarkAllDisplayedPackets'/>\n"
847 "        <menuitem name='UnmarkAllDisplayedPackets' action='/Edit/UnmarkAllDisplayedPackets'/>\n"
848 "        <menuitem name='FindNextMark' action='/Edit/FindNextMark'/>\n"
849 "        <menuitem name='FindPreviousMark' action='/Edit/FindPreviousMark'/>\n"
850 "        <separator/>\n"
851 "        <menuitem name='IgnorePacket' action='/Edit/IgnorePacket'/>\n"
852 "        <menuitem name='IgnoreAllDisplayedPackets' action='/Edit/IgnoreAllDisplayedPackets'/>\n"
853 "        <menuitem name='Un-IgnoreAllPackets' action='/Edit/Un-IgnoreAllPackets'/>\n"
854 "        <separator/>\n"
855 "        <menuitem name='SetTimeReference' action='/Edit/SetTimeReference'/>\n"
856 "        <menuitem name='Un-TimeReferenceAllPackets' action='/Edit/Un-TimeReferenceAllPackets'/>\n"
857 "        <menuitem name='FindNextTimeReference' action='/Edit/FindNextTimeReference'/>\n"
858 "        <menuitem name='FindPreviousTimeReference' action='/Edit/FindPreviousTimeReference'/>\n"
859 "        <separator/>\n"
860 "        <menuitem name='TimeShift' action='/Edit/TimeShift'/>\n"
861 "        <separator/>\n"
862 #ifdef WANT_PACKET_EDITOR
863 "        <menuitem name='EditPacket' action='/Edit/EditPacket'/>\n"
864 #endif
865 "        <menuitem name='AddEditPktComment' action='/Edit/AddEditPktComment'/>\n"
866 "        <menuitem name='AddEditCaptureComment' action='/Edit/AddEditCaptureComment'/>\n"
867 "        <separator/>\n"
868 "        <menuitem name='ConfigurationProfiles' action='/Edit/ConfigurationProfiles'/>\n"
869 "        <menuitem name='Preferences' action='/Edit/Preferences'/>\n"
870 "    </menu>\n"
871 "    <menu name= 'ViewMenu' action='/View'>\n"
872 "      <menuitem name='MainToolbar' action='/View/MainToolbar'/>\n"
873 "      <menuitem name='FilterToolbar' action='/View/FilterToolbar'/>\n"
874 "      <menuitem name='WirelessToolbar' action='/View/WirelessToolbar'/>\n"
875 "      <menuitem name='StatusBar' action='/View/StatusBar'/>\n"
876 "      <separator/>\n"
877 "      <menuitem name='PacketList' action='/View/PacketList'/>\n"
878 "      <menuitem name='PacketDetails' action='/View/PacketDetails'/>\n"
879 "      <menuitem name='PacketBytes' action='/View/PacketBytes'/>\n"
880 "      <separator/>\n"
881 "      <menu name= 'TimeDisplayFormat' action='/View/TimeDisplayFormat'>\n"
882 "        <menuitem name='DateYMDandTimeofDay' action='/View/TimeDisplayFormat/DateYMDandTimeofDay'/>\n"
883 "        <menuitem name='DateYDOYandTimeofDay' action='/View/TimeDisplayFormat/DateYDOYandTimeofDay'/>\n"
884 "        <menuitem name='TimeofDay' action='/View/TimeDisplayFormat/TimeofDay'/>\n"
885 "        <menuitem name='SecondsSinceEpoch' action='/View/TimeDisplayFormat/SecondsSinceEpoch'/>\n"
886 "        <menuitem name='SecondsSinceBeginningofCapture' action='/View/TimeDisplayFormat/SecondsSinceBeginningofCapture'/>\n"
887 "        <menuitem name='SecondsSincePreviousCapturedPacket' action='/View/TimeDisplayFormat/SecondsSincePreviousCapturedPacket'/>\n"
888 "        <menuitem name='SecondsSincePreviousDisplayedPacket' action='/View/TimeDisplayFormat/SecondsSincePreviousDisplayedPacket'/>\n"
889 "        <menuitem name='UTCDateYMDandTimeofDay' action='/View/TimeDisplayFormat/UTCDateYMDandTimeofDay'/>\n"
890 "        <menuitem name='UTCDateYDOYandTimeofDay' action='/View/TimeDisplayFormat/UTCDateYDOYandTimeofDay'/>\n"
891 "        <menuitem name='UTCTimeofDay' action='/View/TimeDisplayFormat/UTCTimeofDay'/>\n"
892 "        <separator/>\n"
893 "        <menuitem name='FileFormatPrecision-Automatic' action='/View/TimeDisplayFormat/FileFormatPrecision-Automatic'/>\n"
894 "        <menuitem name='FileFormatPrecision-Seconds' action='/View/TimeDisplayFormat/FileFormatPrecision-Seconds'/>\n"
895 "        <menuitem name='FileFormatPrecision-Deciseconds' action='/View/TimeDisplayFormat/FileFormatPrecision-Deciseconds'/>\n"
896 "        <menuitem name='FileFormatPrecision-Centiseconds' action='/View/TimeDisplayFormat/FileFormatPrecision-Centiseconds'/>\n"
897 "        <menuitem name='FileFormatPrecision-Milliseconds' action='/View/TimeDisplayFormat/FileFormatPrecision-Milliseconds'/>\n"
898 "        <menuitem name='FileFormatPrecision-Microseconds' action='/View/TimeDisplayFormat/FileFormatPrecision-Microseconds'/>\n"
899 "        <menuitem name='FileFormatPrecision-Nanoseconds' action='/View/TimeDisplayFormat/FileFormatPrecision-Nanoseconds'/>\n"
900 "        <separator/>\n"
901 "        <menuitem name='DisplaySecondsWithHoursAndMinutes' action='/View/TimeDisplayFormat/DisplaySecondsWithHoursAndMinutes'/>\n"
902 "      </menu>\n"
903 "      <menu name= 'NameResolution' action='/View/NameResolution'>\n"
904 "         <menuitem name='ResolveName' action='/View/NameResolution/ResolveName'/>\n"
905 "         <menuitem name='ManuallyResolveName' action='/View/NameResolution/ManuallyResolveName'/>\n"
906 "         <separator/>\n"
907 "         <menuitem name='EnableforMACLayer' action='/View/NameResolution/EnableforMACLayer'/>\n"
908 "         <menuitem name='EnableforTransportLayer' action='/View/NameResolution/EnableforTransportLayer'/>\n"
909 "         <menuitem name='EnableforNetworkLayer' action='/View/NameResolution/EnableforNetworkLayer'/>\n"
910 "         <menuitem name='UseExternalNetworkNameResolver' action='/View/NameResolution/UseExternalNetworkNameResolver'/>\n"
911 "      </menu>\n"
912 "      <menuitem name='ColorizePacketList' action='/View/ColorizePacketList'/>\n"
913 #ifdef HAVE_LIBPCAP
914 "      <menuitem name='AutoScrollinLiveCapture' action='/View/AutoScrollinLiveCapture'/>\n"
915 #endif
916 "      <separator/>\n"
917 "      <menuitem name='ZoomIn' action='/View/ZoomIn'/>\n"
918 "      <menuitem name='ZoomOut' action='/View/ZoomOut'/>\n"
919 "      <menuitem name='NormalSize' action='/View/NormalSize'/>\n"
920 "      <separator/>\n"
921 "      <menuitem name='ResizeAllColumns' action='/View/ResizeAllColumns'/>\n"
922 "      <menuitem name='DisplayedColumns' action='/View/DisplayedColumns'/>\n"
923 "      <separator/>\n"
924 "      <menuitem name='ExpandSubtrees' action='/View/ExpandSubtrees'/>\n"
925 "      <menuitem name='CollapseSubtrees' action='/View/CollapseSubtrees'/>\n"
926 "      <menuitem name='ExpandAll' action='/View/ExpandAll'/>\n"
927 "      <menuitem name='CollapseAll' action='/View/CollapseAll'/>\n"
928 "      <separator/>\n"
929 "      <menu name= 'ColorizeConversation' action='/View/ColorizeConversation'>\n"
930 "         <menuitem name='Color1' action='/View/ColorizeConversation/Color 1'/>\n"
931 "         <menuitem name='Color2' action='/View/ColorizeConversation/Color 2'/>\n"
932 "         <menuitem name='Color3' action='/View/ColorizeConversation/Color 3'/>\n"
933 "         <menuitem name='Color4' action='/View/ColorizeConversation/Color 4'/>\n"
934 "         <menuitem name='Color5' action='/View/ColorizeConversation/Color 5'/>\n"
935 "         <menuitem name='Color6' action='/View/ColorizeConversation/Color 6'/>\n"
936 "         <menuitem name='Color7' action='/View/ColorizeConversation/Color 7'/>\n"
937 "         <menuitem name='Color8' action='/View/ColorizeConversation/Color 8'/>\n"
938 "         <menuitem name='Color9' action='/View/ColorizeConversation/Color 9'/>\n"
939 "         <menuitem name='Color10' action='/View/ColorizeConversation/Color 10'/>\n"
940 "         <menuitem name='NewColoringRule' action='/View/ColorizeConversation/NewColoringRule'/>\n"
941 "      </menu>\n"
942 "      <separator/>\n"
943 "      <menuitem name='ResetColoring1-10' action='/View/ResetColoring1-10'/>\n"
944 "      <menuitem name='ColoringRules' action='/View/ColoringRules'/>\n"
945 "      <separator/>\n"
946 "      <menuitem name='ShowPacketinNewWindow' action='/View/ShowPacketinNewWindow'/>\n"
947 "      <menuitem name='Reload' action='/View/Reload'/>\n"
948 "    </menu>\n"
949 "    <menu name= 'GoMenu' action='/Go'>\n"
950 "      <menuitem name='Back' action='/Go/Back'/>\n"
951 "      <menuitem name='Forward' action='/Go/Forward'/>\n"
952 "      <menuitem name='Goto' action='/Go/Goto'/>\n"
953 "      <menuitem name='GotoCorrespondingPacket' action='/Go/GotoCorrespondingPacket'/>\n"
954 "      <separator/>\n"
955 "      <menuitem name='PreviousPacket' action='/Go/PreviousPacket'/>\n"
956 "      <menuitem name='NextPacket' action='/Go/NextPacket'/>\n"
957 "      <menuitem name='FirstPacket' action='/Go/FirstPacket'/>\n"
958 "      <menuitem name='LastPacket' action='/Go/LastPacket'/>\n"
959 "      <menuitem name='PreviousPacketInConversation' action='/Go/PreviousPacketInConversation'/>\n"
960 "      <menuitem name='NextPacketInConversation' action='/Go/NextPacketInConversation'/>\n"
961 "    </menu>\n"
962 #ifdef HAVE_LIBPCAP
963 "    <menu name= 'CaptureMenu' action='/Capture'>\n"
964 "      <menuitem name='Interfaces' action='/Capture/Interfaces'/>\n"
965 "      <menuitem name='Options' action='/Capture/Options'/>\n"
966 "      <menuitem name='Start' action='/Capture/Start'/>\n"
967 "      <menuitem name='Stop' action='/Capture/Stop'/>\n"
968 "      <menuitem name='Restart' action='/Capture/Restart'/>\n"
969 "      <menuitem name='CaptureFilters' action='/Capture/CaptureFilters'/>\n"
970 "      <menuitem name='RefreshInterfaces' action='/Capture/RefreshInterfaces'/>\n"
971 "    </menu>\n"
972 #endif
973 "    <menu name= 'AnalyzeMenu' action='/Analyze'>\n"
974 "      <menuitem name='DisplayFilters' action='/Analyze/DisplayFilters'/>\n"
975 "      <menuitem name='DisplayFilterMacros' action='/Analyze/DisplayFilterMacros'/>\n"
976 "      <separator/>\n"
977 "      <menuitem name='ApplyasColumn' action='/Analyze/ApplyasColumn'/>\n"
978 "      <menu name= 'ApplyAsFilter' action='/ApplyasFilter'>\n"
979 "        <menuitem name='Selected' action='/ApplyasFilter/Selected'/>\n"
980 "        <menuitem name='NotSelected' action='/ApplyasFilter/Not Selected'/>\n"
981 "        <menuitem name='AndSelected' action='/ApplyasFilter/AndSelected'/>\n"
982 "        <menuitem name='OrSelected' action='/ApplyasFilter/OrSelected'/>\n"
983 "        <menuitem name='AndNotSelected' action='/ApplyasFilter/AndNotSelected'/>\n"
984 "        <menuitem name='OrNotSelected' action='/ApplyasFilter/OrNotSelected'/>\n"
985 "      </menu>\n"
986 "      <menu name= 'PrepareaFilter' action='/PrepareaFilter'>\n"
987 "        <menuitem name='Selected' action='/PrepareaFilter/Selected'/>\n"
988 "        <menuitem name='NotSelected' action='/PrepareaFilter/Not Selected'/>\n"
989 "        <menuitem name='AndSelected' action='/PrepareaFilter/AndSelected'/>\n"
990 "        <menuitem name='OrSelected' action='/PrepareaFilter/OrSelected'/>\n"
991 "        <menuitem name='AndNotSelected' action='/PrepareaFilter/AndNotSelected'/>\n"
992 "        <menuitem name='OrNotSelected' action='/PrepareaFilter/OrNotSelected'/>\n"
993 "      </menu>\n"
994 "      <separator/>\n"
995 "      <menuitem name='EnabledProtocols' action='/Analyze/EnabledProtocols'/>\n"
996 "      <menuitem name='DecodeAs' action='/Analyze/DecodeAs'/>\n"
997 "      <menuitem name='UserSpecifiedDecodes' action='/Analyze/UserSpecifiedDecodes'/>\n"
998 "      <separator/>\n"
999 "      <menuitem name='FollowTCPStream' action='/Analyze/FollowTCPStream'/>\n"
1000 "      <menuitem name='FollowUDPStream' action='/Analyze/FollowUDPStream'/>\n"
1001 "      <menuitem name='FollowSSLStream' action='/Analyze/FollowSSLStream'/>\n"
1002 "      <menuitem name='FollowHTTPStream' action='/Analyze/FollowHTTPStream'/>\n"
1003 "      <menuitem name='ExpertInfo' action='/Analyze/ExpertInfo'/>\n"
1004 "      <menu name= 'ConversationFilterMenu' action='/Analyze/ConversationFilter'>\n"
1005 "        <placeholder name='Filters'/>\n"
1006 "      </menu>\n"
1007 "    </menu>\n"
1008 "    <menu name= 'StatisticsMenu' action='/Statistics'>\n"
1009 "      <menuitem name='Summary' action='/Statistics/Summary'/>\n"
1010 "      <menuitem name='ShowCommentsSummary' action='/Statistics/CommentsSummary'/>\n"
1011 "      <menuitem name='ShowAddreRes' action='/Statistics/ShowAddreRes'/>\n"
1012 "      <menuitem name='ProtocolHierarchy' action='/Statistics/ProtocolHierarchy'/>\n"
1013 "      <menuitem name='Conversations' action='/Statistics/Conversations'/>\n"
1014 "      <menuitem name='Endpoints' action='/Statistics/Endpoints'/>\n"
1015 "      <menuitem name='PacketLengths' action='/Statistics/plen'/>\n"
1016 "      <menuitem name='IOGraphs' action='/Statistics/IOGraphs'/>\n"
1017 "      <separator/>\n"
1018 "      <menu name= 'ConversationListMenu' action='/Statistics/ConversationList'>\n"
1019 "        <placeholder name='Conversations'/>\n"
1020 "      </menu>\n"
1021 "      <menu name= 'EndpointListMenu' action='/Statistics/EndpointList'>\n"
1022 "        <placeholder name='Endpoints'/>\n"
1023 "      </menu>\n"
1024 "      <menu name='ServiceResponseTimeMenu' action='/Statistics/ServiceResponseTime'>\n"
1025 "        <menuitem name='DCE-RPC' action='/Statistics/ServiceResponseTime/DCE-RPC'/>\n"
1026 "        <menuitem name='ONC-RPC' action='/Statistics/ServiceResponseTime/ONC-RPC'/>\n"
1027 "      </menu>\n"
1028 "      <separator/>\n"
1029 "      <menu name= '29West' action='/Statistics/29West'>\n"
1030 "        <menu name= '29WestTopicMenu' action='/Statistics/29West/Topics'>\n"
1031 "          <menuitem name='29WestTopicAdsTopic' action='/Statistics/29West/Topics/lbmr_topic_ads_topic'/>\n"
1032 "          <menuitem name='29WestTopicAdsSource' action='/Statistics/29West/Topics/lbmr_topic_ads_source'/>\n"
1033 "          <menuitem name='29WestTopicAdsTransport' action='/Statistics/29West/Topics/lbmr_topic_ads_transport'/>\n"
1034 "          <menuitem name='29WestTopicQueriesTopic' action='/Statistics/29West/Topics/lbmr_topic_queries_topic'/>\n"
1035 "          <menuitem name='29WestTopicQueriesReceiver' action='/Statistics/29West/Topics/lbmr_topic_queries_receiver'/>\n"
1036 "          <menuitem name='29WestTopicQueriesPattern' action='/Statistics/29West/Topics/lbmr_topic_queries_pattern'/>\n"
1037 "          <menuitem name='29WestTopicQueriesPatternReceiver' action='/Statistics/29West/Topics/lbmr_topic_queries_pattern_receiver'/>\n"
1038 "        </menu>\n"
1039 "        <menu name= '29WestQueueMenu' action='/Statistics/29West/Queues'>\n"
1040 "          <menuitem name='29WestQueueAdsQueue' action='/Statistics/29West/Queues/lbmr_queue_ads_queue'/>\n"
1041 "          <menuitem name='29WestQueueAdsSource' action='/Statistics/29West/Queues/lbmr_queue_ads_source'/>\n"
1042 "          <menuitem name='29WestQueueQueriesQueue' action='/Statistics/29West/Queues/lbmr_queue_queries_queue'/>\n"
1043 "          <menuitem name='29WestQueueQueriesReceiver' action='/Statistics/29West/Queues/lbmr_queue_queries_receiver'/>\n"
1044 "        </menu>\n"
1045 "        <menu name= '29WestUIMMenu' action='/Statistics/29West/UIM'>\n"
1046 "          <menuitem name='29WestUIMStreams' action='/Statistics/29West/UIM/Streams' />\n"
1047 "          <menuitem name='29WestUIMStreamFlowGraph' action='/Statistics/29West/UIM/StreamFlowGraph' />\n"
1048 "        </menu>\n"
1049 "      </menu>\n"
1050 "      <menuitem name='ANCP' action='/Statistics/ancp'/>\n"
1051 "      <menu name= 'BACnetMenu' action='/Statistics/BACnet'>\n"
1052 "        <menuitem name='bacapp_instanceid' action='/Statistics/BACnet/bacapp_instanceid'/>\n"
1053 "        <menuitem name='bacapp_ip' action='/Statistics/BACnet/bacapp_ip'/>\n"
1054 "        <menuitem name='bacapp_objectid' action='/Statistics/BACnet/bacapp_objectid'/>\n"
1055 "        <menuitem name='bacapp_service' action='/Statistics/BACnet/bacapp_service'/>\n"
1056 "      </menu>\n"
1057 "      <menuitem name='Collectd' action='/Statistics/collectd'/>\n"
1058 "      <menuitem name='Compare' action='/Statistics/compare'/>\n"
1059 "      <menuitem name= 'DNS' action='/Statistics/dns'/>\n"
1060 "      <menuitem name='FlowGraph' action='/Statistics/FlowGraph'/>\n"
1061 "      <menuitem name='HART-IP' action='/Statistics/hart_ip'/>\n"
1062 "      <menuitem name= 'Hpfeeds' action='/Statistics/hpfeeds'/>\n"
1063 "      <menu name= 'HTTPMenu' action='/Statistics/HTTP'>\n"
1064 "        <menuitem name='http' action='/Statistics/HTTP/http'/>\n"
1065 "        <menuitem name='http_req' action='/Statistics/HTTP/http_req'/>\n"
1066 "        <menuitem name='http_srv' action='/Statistics/HTTP/http_srv'/>\n"
1067 "      </menu>\n"
1068 "      <menuitem name='HTTP2' action='/Statistics/http2'/>\n"
1069 "      <menu name= 'SametimeMenu' action='/Statistics/Sametime'>\n"
1070 "        <menuitem name='sametime' action='/Statistics/Sametime/sametime'/>\n"
1071 "      </menu>\n"
1072 "      <menu name= 'TCPStreamGraphMenu' action='/Statistics/TCPStreamGraphMenu'>\n"
1073 "        <menuitem name='Sequence-Graph-Stevens' action='/Statistics/TCPStreamGraphMenu/Time-Sequence-Graph-Stevens'/>\n"
1074 "        <menuitem name='Sequence-Graph-tcptrace' action='/Statistics/TCPStreamGraphMenu/Time-Sequence-Graph-tcptrace'/>\n"
1075 "        <menuitem name='Throughput-Graph' action='/Statistics/TCPStreamGraphMenu/Throughput-Graph'/>\n"
1076 "        <menuitem name='RTT-Graph' action='/Statistics/TCPStreamGraphMenu/RTT-Graph'/>\n"
1077 "        <menuitem name='Window-Scaling-Graph' action='/Statistics/TCPStreamGraphMenu/Window-Scaling-Graph'/>\n"
1078 "      </menu>\n"
1079 "      <menuitem name='UDPMulticastStreams' action='/Statistics/UDPMulticastStreams'/>\n"
1080 "      <menuitem name='WLANTraffic' action='/Statistics/WLANTraffic'/>\n"
1081 "      <separator/>\n"
1082 "    </menu>\n"
1083 "    <menu name= 'TelephonyMenu' action='/Telephony'>\n"
1084 "      <menu name= 'ANSImenu' action='/Telephony/ANSI'>\n"
1085 "      </menu>\n"
1086 "      <menu name= 'GSM' action='/Telephony/GSM'>\n"
1087 "        <menuitem name='MAP-Summary' action='/Telephony/GSM/MAPSummary'/>\n"
1088 "      </menu>\n"
1089 "      <menu name= 'IAX2menu' action='/Telephony/IAX2'>\n"
1090 "        <menuitem name='StreamAnalysis' action='/Telephony/IAX2/StreamAnalysis'/>\n"
1091 "      </menu>\n"
1092 "      <menuitem name='ISUP' action='/Telephony/isup_msg'/>\n"
1093 "      <menu name= 'LTEmenu' action='/Telephony/LTE'>\n"
1094 "        <menuitem name='LTE_RLC_Graph' action='/Telephony/LTE/RLCGraph'/>\n"
1095 "      </menu>\n"
1096 "      <menu name= 'MTP3menu' action='/Telephony/MTP3'>\n"
1097 "        <menuitem name='MSUSummary' action='/Telephony/MTP3/MSUSummary'/>\n"
1098 "      </menu>\n"
1099 "      <menu name= 'RTPmenu' action='/Telephony/RTP'>\n"
1100 "        <menuitem name='ShowAllStreams' action='/Telephony/RTP/ShowAllStreams'/>\n"
1101 "        <menuitem name='StreamAnalysis' action='/Telephony/RTP/StreamAnalysis'/>\n"
1102 "      </menu>\n"
1103 "      <menu name= 'RTSPmenu' action='/Telephony/RTSP'>\n"
1104 "        <menuitem name='rtsp' action='/Telephony/RTSP/rtsp'/>\n"
1105 "      </menu>\n"
1106 "      <menu name= 'SCTPmenu' action='/Telephony/SCTP'>\n"
1107 "        <menuitem name='AnalysethisAssociation' action='/Telephony/SCTP/AnalysethisAssociation'/>\n"
1108 "        <menuitem name='ShowAllAssociations' action='/Telephony/SCTP/ShowAllAssociations'/>\n"
1109 "      </menu>\n"
1110 "      <menuitem name='SMPP' action='/Telephony/smpp_commands'/>\n"
1111 "      <menuitem name='UCP' action='/Telephony/ucp_messages'/>\n"
1112 "      <menuitem name='VoIPCalls' action='/Telephony/VoIPCalls'/>\n"
1113 "      <menuitem name='VoIPFlows' action='/Telephony/VoIPFlows'/>\n"
1114 "    </menu>\n"
1115 "    <menu name= 'ToolsMenu' action='/Tools'>\n"
1116 "      <menuitem name='FirewallACLRules' action='/Tools/FirewallACLRules'/>\n"
1117 "    </menu>\n"
1118 "    <menu name= 'InternalsMenu' action='/Internals'>\n"
1119 "      <menuitem name='Dissectortables' action='/Internals/Dissectortables'/>\n"
1120 "      <menuitem name='Conversations' action='/Internals/Conversations'/>\n"
1121 "      <menuitem name='SupportedProtocols' action='/Internals/SupportedProtocols'/>\n"
1122 "    </menu>\n"
1123 "    <menu name= 'HelpMenu' action='/Help'>\n"
1124 "      <menuitem name='Contents' action='/Help/Contents'/>\n"
1125 "      <menu name= 'ManualPages' action='/Help/ManualPages'>\n"
1126 "        <menuitem name='Wireshark' action='/Help/ManualPages/Wireshark'/>\n"
1127 "        <menuitem name='WiresharkFilter' action='/Help/ManualPages/WiresharkFilter'/>\n"
1128 "        <separator/>\n"
1129 "        <menuitem name='Capinfos' action='/Help/ManualPages/Capinfos'/>\n"
1130 "        <menuitem name='Dumpcap' action='/Help/ManualPages/Dumpcap'/>\n"
1131 "        <menuitem name='Editcap' action='/Help/ManualPages/Editcap'/>\n"
1132 "        <menuitem name='Mergecap' action='/Help/ManualPages/Mergecap'/>\n"
1133 "        <menuitem name='RawShark' action='/Help/ManualPages/RawShark'/>\n"
1134 "        <menuitem name='Reordercap' action='/Help/ManualPages/Reordercap'/>\n"
1135 "        <menuitem name='Text2pcap' action='/Help/ManualPages/Text2pcap'/>\n"
1136 "        <menuitem name='TShark' action='/Help/ManualPages/TShark'/>\n"
1137 "      </menu>\n"
1138 "      <separator/>\n"
1139 "      <menuitem name='Website' action='/Help/Website'/>\n"
1140 "      <menuitem name='FAQs' action='/Help/FAQs'/>\n"
1141 "      <menuitem name='Ask' action='/Help/ASK'/>\n"
1142 "      <menuitem name='Downloads' action='/Help/Downloads'/>\n"
1143 "      <separator/>\n"
1144 "      <menuitem name='Wiki' action='/Help/Wiki'/>\n"
1145 "      <menuitem name='SampleCaptures' action='/Help/SampleCaptures'/>\n"
1146 #ifdef HAVE_SOFTWARE_UPDATE
1147 "      <separator/>\n"
1148 "      <menuitem name='CheckForUpdates' action='/Help/CheckForUpdates'/>\n"
1149 #endif /* HAVE_SOFTWARE_UPDATE */
1150 "      <separator/>\n"
1151 "      <menuitem name='AboutWireshark' action='/Help/AboutWireshark'/>\n"
1152 "    </menu>\n"
1153 "  </menubar>\n"
1154 "</ui>\n";
1155
1156
1157
1158 /*
1159  * Main menu.
1160  *
1161  * Please do not use keystrokes that are used as "universal" shortcuts in
1162  * various desktop environments:
1163  *
1164  *   Windows:
1165  *  http://support.microsoft.com/kb/126449
1166  *
1167  *   GNOME:
1168  *  http://library.gnome.org/users/user-guide/nightly/keyboard-skills.html.en
1169  *
1170  *   KDE:
1171  *  http://developer.kde.org/documentation/standards/kde/style/keys/shortcuts.html
1172  *
1173  * In particular, do not use the following <control> sequences for anything
1174  * other than their standard purposes:
1175  *
1176  *  <control>O  File->Open
1177  *  <control>S  File->Save
1178  *  <control>P  File->Print
1179  *  <control>W  File->Close
1180  *  <control>Q  File->Quit
1181  *  <control>Z  Edit->Undo (which we don't currently have)
1182  *  <control>X  Edit->Cut (which we don't currently have)
1183  *  <control>C  Edit->Copy (which we don't currently have)
1184  *  <control>V  Edit->Paste (which we don't currently have)
1185  *  <control>A  Edit->Select All (which we don't currently have)
1186  *
1187  * Note that some if not all of the Edit keys above already perform those
1188  * functions in text boxes, such as the Filter box.  Do no, under any
1189  * circumstances, make a change that keeps them from doing so.
1190  */
1191
1192 /*
1193  * GtkActionEntry
1194  * typedef struct {
1195  *   const gchar     *name;
1196  *   const gchar     *stock_id;
1197  *   const gchar     *label;
1198  *   const gchar     *accelerator;
1199  *   const gchar     *tooltip;
1200  *   GCallback  callback;
1201  * } GtkActionEntry;
1202  * const gchar *name;           The name of the action.
1203  * const gchar *stock_id;       The stock id for the action, or the name of an icon from the icon theme.
1204  * const gchar *label;          The label for the action. This field should typically be marked for translation,
1205  *                              see gtk_action_group_set_translation_domain().
1206  *                              If label is NULL, the label of the stock item with id stock_id is used.
1207  * const gchar *accelerator;    The accelerator for the action, in the format understood by gtk_accelerator_parse().
1208  * const gchar *tooltip;        The tooltip for the action. This field should typically be marked for translation,
1209  *                              see gtk_action_group_set_translation_domain().
1210  * GCallback callback;          The function to call when the action is activated.
1211  *
1212  */
1213
1214 #ifdef HAVE_LIBPCAP
1215 /*
1216  * TODO Move this menu to capture_if_dlg.c
1217  * eg put a "place holder" in the UI description and
1218  * make a call from main_menubar.c i.e build_capture_menu()
1219  * ad do the UI stuff there.
1220  */
1221 static const GtkActionEntry capture_menu_entries[] = {
1222    { "/Capture",                    NULL,                               "_Capture",             NULL,            NULL,    NULL },
1223    { "/Capture/Interfaces",         WIRESHARK_STOCK_CAPTURE_INTERFACES, "_Interfaces...",       "<control>I",    NULL,    G_CALLBACK(capture_if_action_cb) },
1224    { "/Capture/Options",            WIRESHARK_STOCK_CAPTURE_OPTIONS,    "_Options...",          "<control>K",    NULL,    G_CALLBACK(capture_prep_action_cb) },
1225    { "/Capture/Start",              WIRESHARK_STOCK_CAPTURE_START,      "_Start",               "<control>E",    NULL,    G_CALLBACK(capture_start_action_cb) },
1226    { "/Capture/Stop",               WIRESHARK_STOCK_CAPTURE_STOP,       "S_top",                "<control>E",    NULL,    G_CALLBACK(capture_stop_action_cb) },
1227    { "/Capture/Restart",            WIRESHARK_STOCK_CAPTURE_RESTART,    "_Restart",             "<control>R",    NULL,    G_CALLBACK(capture_restart_action_cb) },
1228    { "/Capture/CaptureFilters",     WIRESHARK_STOCK_CAPTURE_FILTER,     "Capture _Filters...",  NULL,            NULL,    G_CALLBACK(capture_filters_action_cb) },
1229    { "/Capture/RefreshInterfaces",  GTK_STOCK_REFRESH,                  "Refresh Interfaces",   NULL,            NULL,    G_CALLBACK(refresh_interfaces_action_cb) },
1230 };
1231 #endif
1232
1233 static const GtkActionEntry main_menu_bar_entries[] = {
1234   /* Top level */
1235   { "/File",                    NULL,                              "_File",              NULL,                   NULL,           NULL },
1236   { "/Edit",                    NULL,                              "_Edit",              NULL,                   NULL,           NULL },
1237   { "/View",                    NULL,                              "_View",              NULL,                   NULL,           NULL },
1238   { "/Go",                      NULL,                              "_Go",                NULL,                   NULL,           NULL },
1239   { "/Analyze",                 NULL,                              "_Analyze",           NULL,                   NULL,           NULL },
1240   { "/Statistics",              NULL,                              "_Statistics",        NULL,                   NULL,           NULL },
1241   { "/Telephony",               NULL,                              "Telephon_y",         NULL,                   NULL,           NULL },
1242   { "/Tools",                   NULL,                              "_Tools",             NULL,                   NULL,           NULL },
1243   { "/Internals",               NULL,                              "_Internals",         NULL,                   NULL,           NULL },
1244   { "/Help",                    NULL,                              "_Help",              NULL,                   NULL,           NULL },
1245
1246   { "/File/Open",               GTK_STOCK_OPEN,                    "_Open...",           "<control>O",           "Open a file",  G_CALLBACK(file_open_cmd_cb) },
1247   { "/File/OpenRecent",         NULL,                              "Open _Recent",       NULL,                   NULL,           NULL },
1248   { "/File/Merge",              NULL,                              "_Merge...",          NULL,                   NULL,           G_CALLBACK(file_merge_cmd_cb) },
1249   { "/File/ImportFromHexDump",  NULL,                              "_Import from Hex Dump...", NULL,                   NULL,           G_CALLBACK(file_import_cmd_cb) },
1250   { "/File/Close",              GTK_STOCK_CLOSE,                   "_Close",             "<control>W",           NULL,           G_CALLBACK(file_close_cmd_cb) },
1251
1252   { "/File/Save",               WIRESHARK_STOCK_SAVE,              "_Save",              "<control>S",           NULL,           G_CALLBACK(file_save_cmd_cb) },
1253   { "/File/SaveAs",             WIRESHARK_STOCK_SAVE,              "Save _As...",        "<shift><control>S",    NULL,           G_CALLBACK(file_save_as_cmd_cb) },
1254
1255   { "/File/Set",                NULL,                              "File Set",           NULL,                   NULL,           NULL },
1256   { "/File/ExportSpecifiedPackets", NULL,         "Export Specified Packets...", NULL,           NULL,           G_CALLBACK(file_export_specified_packets_cmd_cb) },
1257   { "/File/ExportPacketDissections",  NULL,                        "Export Packet Dissections", NULL,                   NULL,           NULL },
1258   { "/File/ExportSelectedPacketBytes", NULL,         "Export Selected Packet _Bytes...", "<control>H",           NULL,           G_CALLBACK(savehex_cb) },
1259   { "/File/ExportPDUs",            NULL,                           "Export PDUs to File...",  NULL,                NULL,           G_CALLBACK(export_pdu_show_cb) },
1260   { "/File/ExportSSLSessionKeys",  NULL,                   "Export SSL Session Keys...", NULL,                   NULL,           G_CALLBACK(savesslkeys_cb) },
1261   { "/File/ExportObjects",      NULL,                              "Export Objects",     NULL,                   NULL,           NULL },
1262   { "/File/Print",              GTK_STOCK_PRINT,                   "_Print...",          "<control>P",           NULL,           G_CALLBACK(file_print_cmd_cb) },
1263   { "/File/Quit",               GTK_STOCK_QUIT,                    "_Quit",              "<control>Q",           NULL,           G_CALLBACK(file_quit_cmd_cb) },
1264
1265   { "/File/Set/ListFiles",      WIRESHARK_STOCK_FILE_SET_LIST,     "List Files",         NULL,                   NULL,           G_CALLBACK(fileset_cb) },
1266   { "/File/Set/NextFile",       WIRESHARK_STOCK_FILE_SET_NEXT,     "Next File",          NULL,                   NULL,           G_CALLBACK(fileset_next_cb) },
1267   { "/File/Set/PreviousFile",   WIRESHARK_STOCK_FILE_SET_PREVIOUS, "Previous File",      NULL,                   NULL,           G_CALLBACK(fileset_previous_cb) },
1268
1269   { "/File/ExportPacketDissections/Text",       NULL,       "as \"Plain _Text\" file...",      NULL,                   NULL,           G_CALLBACK(export_text_cmd_cb) },
1270   { "/File/ExportPacketDissections/PostScript", NULL,       "as \"_PostScript\" file...",      NULL,                   NULL,           G_CALLBACK(export_ps_cmd_cb) },
1271   { "/File/ExportPacketDissections/CSV",        NULL,       "as \"_CSV\" (Comma Separated Values packet summary) file...",
1272                                                                                          NULL,                   NULL,           G_CALLBACK(export_csv_cmd_cb) },
1273   { "/File/ExportPacketDissections/CArrays",    NULL,       "as \"C _Arrays\" (packet bytes) file...",
1274                                                                                          NULL,                   NULL,           G_CALLBACK(export_carrays_cmd_cb) },
1275   { "/File/ExportPacketDissections/PSML",       NULL,       "as XML - \"P_SML\" (packet summary) file...",
1276                                                                                          NULL,                   NULL,           G_CALLBACK(export_psml_cmd_cb) },
1277   { "/File/ExportPacketDissections/PDML",       NULL,       "as XML - \"P_DML\" (packet details) file...",
1278                                                                                          NULL,                   NULL,           G_CALLBACK(export_pdml_cmd_cb) },
1279   { "/File/ExportPacketDissections/JSON",       NULL,       "as \"_JSON\" file...",
1280                                                                                          NULL,                   NULL,           G_CALLBACK(export_json_cmd_cb) },
1281
1282   { "/Edit/Copy",                         NULL,       "Copy",                            NULL,                   NULL,           NULL },
1283
1284   { "/Edit/Copy/Description",             NULL,       "Description",                     "<shift><control>D",    NULL,           G_CALLBACK(copy_description_cb) },
1285   { "/Edit/Copy/Fieldname",               NULL,       "Fieldname",                       "<shift><control>F",    NULL,           G_CALLBACK(copy_fieldname_cb) },
1286   { "/Edit/Copy/Value",                   NULL,       "Value",                           "<shift><control>V",    NULL,           G_CALLBACK(copy_value_cb) },
1287   { "/Edit/Copy/AsFilter",                NULL,       "As Filter",                       "<shift><control>C",    NULL,           G_CALLBACK(copy_as_filter_cb) },
1288
1289 #if 0
1290     /*
1291      * Un-#if this when we actually implement Cut/Copy/Paste for the
1292      * packet list and packet detail windows.
1293      *
1294      * Note: when we implement Cut/Copy/Paste in those windows, we
1295      * will almost certainly want to allow multiple packets to be
1296      * selected in the packet list pane and multiple packet detail
1297      * items to be selected in the packet detail pane, so that
1298      * the user can, for example, copy the summaries of multiple
1299      * packets to the clipboard from the packet list pane and multiple
1300      * packet detail items - perhaps *all* packet detail items - from
1301      * the packet detail pane.  Given that, we'll also want to
1302      * implement Select All.
1303      *
1304      * If multiple packets are selected, we would probably display nothing
1305      * in the packet detail pane, just as we do if no packet is selected,
1306      * and any menu items etc. that would pertain only to a single packet
1307      * would be disabled.
1308      *
1309      * If multiple packet detail items are selected, we would probably
1310      * disable all items that pertain only to a single packet detail
1311      * item, such as some items in the status bar.
1312      *
1313      * XXX - the actions for these will be different depending on what
1314      * widget we're in; ^C should copy from the filter text widget if
1315      * we're in that widget, the packet list if we're in that widget
1316      * (presumably copying the summaries of selected packets to the
1317      * clipboard, e.g. the text copy would be the text of the columns),
1318      * the packet detail if we're in that widget (presumably copying
1319      * the contents of selected protocol tree items to the clipboard,
1320      * e.g. the text copy would be the text displayed for those items),
1321      * etc..
1322      *
1323      * Given that those menu items should also affect text widgets
1324      * such as the filter box, we would again want Select All, and,
1325      * at least for the filter box, we would also want Undo and Redo.
1326      * We would only want Cut, Paste, Undo, and Redo for the packet
1327      * list and packet detail panes if we support modifying them.
1328      */
1329     {"/Edit/_Undo", "<control>Z", NULL,
1330                              0, "<StockItem>", GTK_STOCK_UNDO,},
1331     {"/Edit/_Redo", "<shift><control>Z", NULL,
1332                              0, "<StockItem>", GTK_STOCK_REDO,},
1333     {"/Edit/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
1334     {"/Edit/Cu_t", "<control>X", NULL,
1335                              0, "<StockItem>", GTK_STOCK_CUT,},
1336     {"/Edit/_Copy", "<control>C", NULL,
1337                              0, "<StockItem>", GTK_STOCK_COPY,},
1338     {"/Edit/_Paste", "<control>V", NULL,
1339                              0, "<StockItem>", GTK_STOCK_PASTE,},
1340     {"/Edit/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
1341     {"/Edit/Select _All", "<control>A", NULL, 0,
1342                              "<StockItem>", GTK_STOCK_SELECT_ALL,},
1343 #endif /* 0 */
1344    { "/Edit/FindPacket",                GTK_STOCK_FIND,     "_Find Packet...",                      "<control>F",           NULL,           G_CALLBACK(find_frame_cb) },
1345    { "/Edit/FindNext",                  NULL,               "Find Ne_xt",                           "<control>N",           NULL,           G_CALLBACK(find_next_cb) },
1346    { "/Edit/FindPrevious",              NULL,               "Find Pre_vious",                       "<control>B",           NULL,           G_CALLBACK(find_previous_cb) },
1347
1348    { "/Edit/MarkPacket",                NULL,               "_Mark/Unmark Packet",                  "<control>M",           NULL,           G_CALLBACK(packet_list_mark_frame_cb) },
1349    /* XXX - Unused. Should this and its associated code be removed? */
1350    { "/Edit/ToggleMarkingOfAllDisplayedPackets",    NULL,   "Toggle Marking of All Displayed Packets",  "<shift><alt><control>M",           NULL,           G_CALLBACK(packet_list_toggle_mark_all_displayed_frames_cb) },
1351    { "/Edit/MarkAllDisplayedPackets",   NULL,               "Mark All Displayed Packets",           "<shift><control>M",    NULL,           G_CALLBACK(packet_list_mark_all_displayed_frames_cb) },
1352    { "/Edit/UnmarkAllDisplayedPackets", NULL,               "_Unmark All Displayed Packets",        "<alt><control>M",      NULL,           G_CALLBACK(packet_list_unmark_all_displayed_frames_cb) },
1353    { "/Edit/FindNextMark",              NULL,               "Next Mark",                            "<shift><control>N",    NULL,           G_CALLBACK(find_next_mark_cb) },
1354    { "/Edit/FindPreviousMark",          NULL,               "Previous Mark",                        "<shift><control>B",    NULL,           G_CALLBACK(find_prev_mark_cb) },
1355
1356    { "/Edit/IgnorePacket",              NULL,               "_Ignore/Unignore Packet",              "<control>D",           NULL,           G_CALLBACK(packet_list_ignore_frame_cb) },
1357     /*
1358      * XXX - this next one overrides /Edit/Copy/Description
1359      */
1360    { "/Edit/IgnoreAllDisplayedPackets", NULL,               "Ignore All Displayed Packets",         "<shift><control>D",        NULL,           G_CALLBACK(packet_list_ignore_all_displayed_frames_cb) },
1361    { "/Edit/Un-IgnoreAllPackets",       NULL,               "U_nignore All Packets",                "<alt><control>D",          NULL,           G_CALLBACK(packet_list_unignore_all_frames_cb) },
1362    { "/Edit/SetTimeReference",          WIRESHARK_STOCK_TIME,   "Set/Unset Time Reference",         "<control>T",           NULL,           G_CALLBACK(set_reftime_cb) },
1363    { "/Edit/Un-TimeReferenceAllPackets",NULL,               "Unset All Time References",            "<alt><control>T",          NULL,           G_CALLBACK(packet_list_untime_reference_all_frames_cb) },
1364    { "/Edit/FindNextTimeReference",     NULL,               "Next Time Reference",                  "<alt><control>N",          NULL,           G_CALLBACK(find_next_ref_time_cb) },
1365    { "/Edit/FindPreviousTimeReference", NULL,               "Previous Time Reference",              "<alt><control>B",          NULL,           G_CALLBACK(find_previous_ref_time_cb) },
1366    { "/Edit/TimeShift",             WIRESHARK_STOCK_TIME,   "Time Shift...",                        "<shift><control>T",        NULL,           G_CALLBACK(time_shift_cb) },
1367
1368    { "/Edit/ConfigurationProfiles", NULL,                   "_Configuration Profiles...",           "<shift><control>A",        NULL,           G_CALLBACK(profile_dialog_cb) },
1369    { "/Edit/Preferences",           GTK_STOCK_PREFERENCES,  "_Preferences...",                      "<shift><control>P",        NULL,           G_CALLBACK(menus_prefs_cb) },
1370 #ifdef WANT_PACKET_EDITOR
1371    { "/Edit/EditPacket",                NULL,               "_Edit Packet",                          NULL,                      NULL,           G_CALLBACK(edit_window_cb) },
1372 #endif
1373    { "/Edit/AddEditPktComment",         WIRESHARK_STOCK_EDIT,   "Packet Comment...",                "<alt><control>C",          NULL,           G_CALLBACK(edit_packet_comment_dlg) },
1374    { "/Edit/AddEditCaptureComment",     NULL,                   "Capture Comment...",               "<shift><alt><control>C",   NULL,           G_CALLBACK(edit_capture_comment_dlg_launch) },
1375
1376    { "/View/TimeDisplayFormat",     NULL,                   "_Time Display Format",                  NULL,                      NULL,           NULL },
1377
1378    { "/View/NameResolution",                    NULL,        "Name Resol_ution",                     NULL,                      NULL,           NULL },
1379    { "/View/NameResolution/ResolveName",        NULL,        "_Resolve Name",                        NULL,                      NULL,           G_CALLBACK(resolve_name_cb) },
1380    { "/View/NameResolution/ManuallyResolveName",NULL,        "Manually Resolve Name",                NULL,                      NULL,           G_CALLBACK(manual_addr_resolv_dlg) },
1381
1382    { "/View/ZoomIn",                GTK_STOCK_ZOOM_IN,      "_Zoom In",                             "<control>plus",            NULL,           G_CALLBACK(view_zoom_in_cb) },
1383    { "/View/ZoomOut",               GTK_STOCK_ZOOM_OUT,     "Zoom _Out",                            "<control>minus",           NULL,           G_CALLBACK(view_zoom_out_cb) },
1384    { "/View/NormalSize",            GTK_STOCK_ZOOM_100,     "_Normal Size",                         "<control>equal",           NULL,           G_CALLBACK(view_zoom_100_cb) },
1385    { "/View/ResizeAllColumns",      WIRESHARK_STOCK_RESIZE_COLUMNS, "Resize All Columns",           "<shift><control>R",        NULL,           G_CALLBACK(packet_list_resize_columns_cb) },
1386    { "/View/DisplayedColumns",      NULL,                   "Displayed Columns",                    NULL,                       NULL,           NULL },
1387    { "/View/ExpandSubtrees",        NULL,                   "E_xpand Subtrees",                      "<shift>Right",             NULL,           G_CALLBACK(expand_tree_cb) },
1388    { "/View/CollapseSubtrees",      NULL,                   "Collapse Subtrees",                     "<shift>Left",              NULL,           G_CALLBACK(collapse_tree_cb) },
1389    { "/View/ExpandAll",             NULL,                   "_Expand All",                           "<control>Right",           NULL,           G_CALLBACK(expand_all_cb) },
1390    { "/View/CollapseAll",           NULL,                   "Collapse _All",                         "<control>Left",            NULL,           G_CALLBACK(collapse_all_cb) },
1391    { "/View/ColorizeConversation",  NULL,                   "Colorize Conversation",NULL,                   NULL,           NULL },
1392
1393    { "/View/ColorizeConversation/Color 1",  WIRESHARK_STOCK_COLOR1, "Color 1",                  "<control>1", NULL, G_CALLBACK(view_menu_color_conv_color1_cb) },
1394    { "/View/ColorizeConversation/Color 2",  WIRESHARK_STOCK_COLOR2, "Color 2",                  "<control>2", NULL, G_CALLBACK(view_menu_color_conv_color2_cb) },
1395    { "/View/ColorizeConversation/Color 3",  WIRESHARK_STOCK_COLOR3, "Color 3",                  "<control>3", NULL, G_CALLBACK(view_menu_color_conv_color3_cb) },
1396    { "/View/ColorizeConversation/Color 4",  WIRESHARK_STOCK_COLOR4, "Color 4",                  "<control>4", NULL, G_CALLBACK(view_menu_color_conv_color4_cb) },
1397    { "/View/ColorizeConversation/Color 5",  WIRESHARK_STOCK_COLOR5, "Color 5",                  "<control>5", NULL, G_CALLBACK(view_menu_color_conv_color5_cb) },
1398    { "/View/ColorizeConversation/Color 6",  WIRESHARK_STOCK_COLOR6, "Color 6",                  "<control>6", NULL, G_CALLBACK(view_menu_color_conv_color6_cb) },
1399    { "/View/ColorizeConversation/Color 7",  WIRESHARK_STOCK_COLOR7, "Color 7",                  "<control>7", NULL, G_CALLBACK(view_menu_color_conv_color7_cb) },
1400    { "/View/ColorizeConversation/Color 8",  WIRESHARK_STOCK_COLOR8, "Color 8",                  "<control>8", NULL, G_CALLBACK(view_menu_color_conv_color8_cb) },
1401    { "/View/ColorizeConversation/Color 9",  WIRESHARK_STOCK_COLOR9, "Color 9",                  "<control>9", NULL, G_CALLBACK(view_menu_color_conv_color9_cb) },
1402    { "/View/ColorizeConversation/Color 10", WIRESHARK_STOCK_COLOR0, "Color 10",                 "<control>0", NULL, G_CALLBACK(view_menu_color_conv_color10_cb) },
1403    { "/View/ColorizeConversation/NewColoringRule",  NULL,           "New Coloring Rule...",     NULL,         NULL, G_CALLBACK(view_menu_color_conv_new_rule_cb) },
1404
1405    { "/View/ResetColoring1-10",     NULL,                   "Reset Coloring 1-10",              "<control>space",               NULL,               G_CALLBACK(view_menu_reset_coloring_cb) },
1406    { "/View/ColoringRules",         GTK_STOCK_SELECT_COLOR, "_Coloring Rules...",               NULL,                           NULL,               G_CALLBACK(color_display_cb) },
1407    { "/View/ShowPacketinNewWindow", NULL,                   "Show Packet in New _Window",       NULL,                           NULL,               G_CALLBACK(new_window_cb) },
1408    { "/View/Reload",                GTK_STOCK_REFRESH,      "_Reload",                          "<control>R",                   NULL,               G_CALLBACK(file_reload_cmd_cb) },
1409
1410
1411    { "/Go/Back",                    GTK_STOCK_GO_BACK,      "_Back",                            "<alt>Left",                    NULL,               G_CALLBACK(history_back_cb) },
1412    { "/Go/Forward",                 GTK_STOCK_GO_FORWARD,   "_Forward",                         "<alt>Right",                   NULL,               G_CALLBACK(history_forward_cb) },
1413    { "/Go/Goto",                    GTK_STOCK_JUMP_TO,      "_Go to Packet...",                 "<control>G",                   NULL,               G_CALLBACK(goto_frame_cb) },
1414    { "/Go/GotoCorrespondingPacket", NULL,                   "Go to _Corresponding Packet",      NULL,                           NULL,               G_CALLBACK(goto_framenum_cb) },
1415    { "/Go/PreviousPacket",          GTK_STOCK_GO_UP,        "Previous Packet",                  "<control>Up",                  NULL,               G_CALLBACK(goto_previous_frame_cb) },
1416    { "/Go/NextPacket",              GTK_STOCK_GO_DOWN,      "Next Packet",                      "<control>Down",                NULL,               G_CALLBACK(goto_next_frame_cb) },
1417    { "/Go/FirstPacket",             GTK_STOCK_GOTO_TOP,     "F_irst Packet",                    "<control>Home",                NULL,               G_CALLBACK(goto_top_frame_cb) },
1418    { "/Go/LastPacket",              GTK_STOCK_GOTO_BOTTOM,  "_Last Packet",                     "<control>End",                 NULL,               G_CALLBACK(goto_bottom_frame_cb) },
1419    { "/Go/PreviousPacketInConversation",            GTK_STOCK_GO_UP,        "Previous Packet In Conversation",                  "<control>comma",                   NULL,               G_CALLBACK(goto_previous_frame_conversation_cb) },
1420    { "/Go/NextPacketInConversation",                GTK_STOCK_GO_DOWN,      "Next Packet In Conversation",                      "<control>period",              NULL,               G_CALLBACK(goto_next_frame_conversation_cb) },
1421
1422
1423    { "/Analyze/DisplayFilters",     WIRESHARK_STOCK_DISPLAY_FILTER,     "_Display Filters...",  NULL,                           NULL,               G_CALLBACK(dfilter_dialog_cb) },
1424
1425    { "/Analyze/DisplayFilterMacros",            NULL,                   "Display Filter _Macros...",    NULL,                   NULL,               G_CALLBACK(macros_dialog_cb) },
1426    { "/Analyze/ApplyasColumn",                  NULL,                           "Apply as Column",      NULL,                   NULL,               G_CALLBACK(apply_as_custom_column_cb) },
1427
1428    { "/Analyze/EnabledProtocols",   WIRESHARK_STOCK_CHECKBOX, "_Enabled Protocols...",  "<shift><control>E", NULL, G_CALLBACK(proto_cb) },
1429    { "/Analyze/DecodeAs",   WIRESHARK_STOCK_DECODE_AS, "Decode _As...",         NULL, NULL, G_CALLBACK(decode_as_cb) },
1430    { "/Analyze/UserSpecifiedDecodes",   WIRESHARK_STOCK_DECODE_AS, "_User Specified Decodes...",            NULL, NULL, G_CALLBACK(decode_show_cb) },
1431
1432    { "/Analyze/FollowTCPStream",                            NULL,       "Follow TCP Stream",                    NULL, NULL, G_CALLBACK(follow_tcp_stream_cb) },
1433    { "/Analyze/FollowUDPStream",                            NULL,       "Follow UDP Stream",                    NULL, NULL, G_CALLBACK(follow_udp_stream_cb) },
1434    { "/Analyze/FollowSSLStream",                            NULL,       "Follow SSL Stream",                    NULL, NULL, G_CALLBACK(follow_ssl_stream_cb) },
1435    { "/Analyze/FollowHTTPStream",                           NULL,       "Follow HTTP Stream",                   NULL, NULL, G_CALLBACK(follow_http_stream_cb) },
1436
1437    { "/Analyze/ExpertInfo",          WIRESHARK_STOCK_EXPERT_INFO,       "Expert _Info",               NULL, NULL, G_CALLBACK(expert_comp_dlg_launch) },
1438
1439    { "/Analyze/ConversationFilter",                         NULL,       "Conversation Filter",                  NULL, NULL, NULL },
1440
1441
1442    { "/Statistics/ConversationList",                           NULL,       "_Conversation List",                   NULL, NULL, NULL },
1443
1444    { "/Statistics/EndpointList",                                NULL,               "_Endpoint List",               NULL, NULL, NULL },
1445
1446    { "/Statistics/ServiceResponseTime",             NULL,           "Service _Response Time",       NULL, NULL, NULL },
1447    { "/Statistics/ServiceResponseTime/DCE-RPC",     WIRESHARK_STOCK_TIME,           "DCE-RPC...",                   NULL, NULL, G_CALLBACK(gtk_dcerpcstat_cb) },
1448    { "/Statistics/ServiceResponseTime/ONC-RPC",     WIRESHARK_STOCK_TIME,           "ONC-RPC...",                   NULL, NULL, G_CALLBACK(gtk_rpcstat_cb) },
1449
1450    { "/Statistics/29West",                                            NULL,                       "29West",                       NULL, NULL, NULL },
1451    { "/Statistics/29West/Topics",                                     NULL,                       "Topics",                       NULL, NULL, NULL },
1452    { "/Statistics/29West/Topics/lbmr_topic_ads_topic",                NULL,                       "Advertisements by Topic",      NULL, NULL, G_CALLBACK(gtk_stats_tree_cb) },
1453    { "/Statistics/29West/Topics/lbmr_topic_ads_source",               NULL,                       "Advertisements by Source",     NULL, NULL, G_CALLBACK(gtk_stats_tree_cb) },
1454    { "/Statistics/29West/Topics/lbmr_topic_ads_transport",            NULL,                       "Advertisements by Transport",  NULL, NULL, G_CALLBACK(gtk_stats_tree_cb) },
1455    { "/Statistics/29West/Topics/lbmr_topic_queries_topic",            NULL,                       "Queries by Topic",             NULL, NULL, G_CALLBACK(gtk_stats_tree_cb) },
1456    { "/Statistics/29West/Topics/lbmr_topic_queries_receiver",         NULL,                       "Queries by Receiver",          NULL, NULL, G_CALLBACK(gtk_stats_tree_cb) },
1457    { "/Statistics/29West/Topics/lbmr_topic_queries_pattern",          NULL,                       "Wildcard Queries by Pattern",  NULL, NULL, G_CALLBACK(gtk_stats_tree_cb) },
1458    { "/Statistics/29West/Topics/lbmr_topic_queries_pattern_receiver", NULL,                       "Wildcard Queries by Receiver", NULL, NULL, G_CALLBACK(gtk_stats_tree_cb) },
1459    { "/Statistics/29West/Queues",                                     NULL,                       "Queues",                       NULL, NULL, NULL },
1460    { "/Statistics/29West/Queues/lbmr_queue_ads_queue",                NULL,                       "Advertisements by Queue",      NULL, NULL, G_CALLBACK(gtk_stats_tree_cb) },
1461    { "/Statistics/29West/Queues/lbmr_queue_ads_source",               NULL,                       "Advertisements by Source",     NULL, NULL, G_CALLBACK(gtk_stats_tree_cb) },
1462    { "/Statistics/29West/Queues/lbmr_queue_queries_queue",            NULL,                       "Queries by Queue",             NULL, NULL, G_CALLBACK(gtk_stats_tree_cb) },
1463    { "/Statistics/29West/Queues/lbmr_queue_queries_receiver",         NULL,                       "Queries by Receiver",          NULL, NULL, G_CALLBACK(gtk_stats_tree_cb) },
1464    { "/Statistics/29West/UIM",                                        NULL,                       "UIM",                          NULL, NULL, NULL },
1465    { "/Statistics/29West/UIM/Streams",                                NULL,                       "Streams",                      NULL, NULL, G_CALLBACK(lbmc_stream_dlg_stream_menu_cb) },
1466    { "/Statistics/29West/UIM/StreamFlowGraph",                        WIRESHARK_STOCK_FLOW_GRAPH, "Stream Flow Graph",            NULL, NULL, G_CALLBACK(lbmc_uim_flow_menu_cb) },
1467
1468    { "/Statistics/ancp",                            NULL,       "ANCP",                             NULL, NULL, G_CALLBACK(gtk_stats_tree_cb) },
1469    { "/Statistics/BACnet",                          NULL,       "BACnet",                           NULL, NULL, NULL },
1470    { "/Statistics/BACnet/bacapp_instanceid",        NULL,       "Packets sorted by Instance ID",    NULL, NULL, G_CALLBACK(gtk_stats_tree_cb) },
1471    { "/Statistics/BACnet/bacapp_ip",                NULL,       "Packets sorted by IP",             NULL, NULL, G_CALLBACK(gtk_stats_tree_cb) },
1472    { "/Statistics/BACnet/bacapp_objectid",          NULL,       "Packets sorted by Object Type",    NULL, NULL, G_CALLBACK(gtk_stats_tree_cb) },
1473    { "/Statistics/BACnet/bacapp_service",           NULL,       "Packets sorted by Service",        NULL, NULL, G_CALLBACK(gtk_stats_tree_cb) },
1474    { "/Statistics/collectd",                        NULL,       "Collectd...",                      NULL, NULL, G_CALLBACK(gtk_stats_tree_cb) },
1475    { "/Statistics/compare",                         NULL,       "Compare...",                       NULL, NULL, G_CALLBACK(gtk_comparestat_cb) },
1476    { "/Statistics/dns",                             NULL,       "DNS",                              NULL, NULL, G_CALLBACK(gtk_stats_tree_cb) },
1477    { "/Statistics/FlowGraph",       WIRESHARK_STOCK_FLOW_GRAPH, "Flo_w Graph...",                   NULL, NULL, G_CALLBACK(flow_graph_launch) },
1478    { "/Statistics/hart_ip",                         NULL,       "HART-IP",                          NULL, NULL, G_CALLBACK(gtk_stats_tree_cb) },
1479    { "/Statistics/hpfeeds",                         NULL,       "HPFEEDS",                          NULL, NULL, G_CALLBACK(gtk_stats_tree_cb) },
1480    { "/Statistics/HTTP",                            NULL,       "HTTP",                             NULL, NULL, NULL },
1481    { "/Statistics/HTTP/http",                       NULL,       "Packet Counter",                   NULL, NULL, G_CALLBACK(gtk_stats_tree_cb) },
1482    { "/Statistics/HTTP/http_req",                   NULL,       "Requests",                         NULL, NULL, G_CALLBACK(gtk_stats_tree_cb) },
1483    { "/Statistics/HTTP/http_srv",                   NULL,       "Load Distribution",                NULL, NULL, G_CALLBACK(gtk_stats_tree_cb) },
1484    { "/Statistics/http2",                           NULL,       "HTTP2",                          NULL, NULL, G_CALLBACK(gtk_stats_tree_cb) },
1485    { "/Statistics/Sametime",                        NULL,       "Sametime",                         NULL, NULL, NULL },
1486    { "/Statistics/Sametime/sametime",               NULL,       "Messages",                         NULL, NULL, G_CALLBACK(gtk_stats_tree_cb) },
1487    { "/Statistics/TCPStreamGraphMenu",  NULL,           "TCP StreamGraph",                          NULL, NULL, NULL },
1488    { "/Statistics/TCPStreamGraphMenu/Time-Sequence-Graph-Stevens",  NULL, "Time-Sequence Graph (Stevens)",  NULL, NULL, G_CALLBACK(tcp_graph_cb) },
1489    { "/Statistics/TCPStreamGraphMenu/Time-Sequence-Graph-tcptrace", NULL, "Time-Sequence Graph (tcptrace)", NULL, NULL, G_CALLBACK(tcp_graph_cb) },
1490    { "/Statistics/TCPStreamGraphMenu/Throughput-Graph",             NULL, "Throughput Graph",               NULL, NULL, G_CALLBACK(tcp_graph_cb) },
1491    { "/Statistics/TCPStreamGraphMenu/RTT-Graph",                    NULL, "Round Trip Time Graph",          NULL, NULL, G_CALLBACK(tcp_graph_cb) },
1492    { "/Statistics/TCPStreamGraphMenu/Window-Scaling-Graph",         NULL, "Window Scaling Graph",           NULL, NULL, G_CALLBACK(tcp_graph_cb) },
1493
1494    { "/Statistics/UDPMulticastStreams",                             NULL, "UDP Multicast Streams",          NULL, NULL, G_CALLBACK(mcaststream_launch) },
1495    { "/Statistics/WLANTraffic",                                     NULL, "WLAN Traffic",                   NULL, NULL, G_CALLBACK(wlanstat_launch) },
1496
1497    { "/Statistics/Summary",                     GTK_STOCK_PROPERTIES,           "_Summary",                     NULL, NULL, G_CALLBACK(summary_open_cb) },
1498    { "/Statistics/CommentsSummary",             NULL,                           "Comments Summary",             NULL, NULL, G_CALLBACK(show_packet_comment_summary_dlg) },
1499    { "/Statistics/ShowAddreRes",                NULL,                           "Show address resolution",      NULL, NULL, G_CALLBACK(addr_resolution_dlg) },
1500    { "/Statistics/ProtocolHierarchy",           NULL,                           "_Protocol Hierarchy",          NULL, NULL, G_CALLBACK(proto_hier_stats_cb) },
1501    { "/Statistics/Conversations",   WIRESHARK_STOCK_CONVERSATIONS,  "Conversations",            NULL,                       NULL,               G_CALLBACK(init_conversation_notebook_cb) },
1502    { "/Statistics/Endpoints",       WIRESHARK_STOCK_ENDPOINTS,      "Endpoints",                NULL,                       NULL,               G_CALLBACK(init_hostlist_notebook_cb) },
1503    { "/Statistics/IOGraphs",            WIRESHARK_STOCK_GRAPHS,     "_IO Graph",                NULL,                       NULL,               G_CALLBACK(gui_iostat_cb) },
1504    { "/Statistics/plen",                        NULL,               "Packet Lengths...",        NULL,                       NULL,               G_CALLBACK(gtk_stats_tree_cb) },
1505
1506    { "/Telephony/ANSI",                 NULL,                       "_ANSI",                    NULL, NULL, NULL },
1507    { "/Telephony/GSM",                  NULL,                       "_GSM",                     NULL, NULL, NULL },
1508    { "/Telephony/GSM/MAPSummary",       NULL,                       "MAP Summary",              NULL,                       NULL,               G_CALLBACK(gsm_map_stat_gtk_sum_cb) },
1509
1510    { "/Telephony/IAX2",                 NULL,                       "IA_X2",                    NULL, NULL, NULL },
1511    { "/Telephony/IAX2/StreamAnalysis",  NULL,                       "Stream Analysis...",       NULL,                       NULL,               G_CALLBACK(iax2_analysis_cb) },
1512
1513    { "/Telephony/isup_msg",             NULL,                       "_ISUP Messages",           NULL,                       NULL,               G_CALLBACK(gtk_stats_tree_cb) },
1514
1515    { "/Telephony/LTE",                  NULL,                       "_LTE",                     NULL, NULL, NULL },
1516    { "/Telephony/LTE/RLCGraph",         NULL,                       "RLC _Graph...",            NULL,                       NULL,               G_CALLBACK(rlc_lte_graph_cb) },
1517    { "/Telephony/MTP3",                 NULL,                       "_MTP3",                    NULL, NULL, NULL },
1518    { "/Telephony/MTP3/MSUSummary",      NULL,                       "MSU Summary",              NULL,                       NULL,               G_CALLBACK(mtp3_sum_gtk_sum_cb) },
1519    { "/Telephony/RTP",                  NULL,                       "_RTP",                     NULL, NULL, NULL },
1520    { "/Telephony/RTP/StreamAnalysis",   NULL,                       "Stream Analysis...",       NULL,                       NULL,               G_CALLBACK(rtp_analysis_cb) },
1521    { "/Telephony/RTP/ShowAllStreams",   NULL,                       "Show All Streams",         NULL,                       NULL,               G_CALLBACK(rtpstream_launch) },
1522    { "/Telephony/RTSP",                 NULL,                       "RTSP",                     NULL, NULL, NULL },
1523    { "/Telephony/RTSP/rtsp",            NULL,                       "Packet Counter",           NULL,                       NULL,               G_CALLBACK(gtk_stats_tree_cb) },
1524    { "/Telephony/SCTP",                 NULL,                       "S_CTP",                        NULL, NULL, NULL },
1525    { "/Telephony/SCTP/AnalysethisAssociation",  NULL,               "Analyse this Association", NULL,                       NULL,               G_CALLBACK(sctp_analyse_start) },
1526    { "/Telephony/SCTP/ShowAllAssociations",     NULL,               "Show All Associations...", NULL,                       NULL,               G_CALLBACK(sctp_stat_start) },
1527    { "/Telephony/smpp_commands",        NULL,                       "SM_PPOperations",          NULL,                       NULL,               G_CALLBACK(gtk_stats_tree_cb) },
1528    { "/Telephony/ucp_messages",         NULL,                       "_UCP Messages",            NULL,                       NULL,               G_CALLBACK(gtk_stats_tree_cb) },
1529    { "/Telephony/VoIPCalls",            WIRESHARK_STOCK_TELEPHONE,  "_VoIP Calls",              NULL,                       NULL,               G_CALLBACK(voip_calls_launch) },
1530    { "/Telephony/VoIPFlows",            WIRESHARK_STOCK_TELEPHONE,  "SIP _Flows",               NULL,                       NULL,               G_CALLBACK(voip_flows_launch) },
1531
1532    { "/Tools/FirewallACLRules",     NULL,                           "Firewall ACL Rules",       NULL,                       NULL,               G_CALLBACK(firewall_rule_cb) },
1533
1534    { "/Internals/Dissectortables",  NULL,                           "_Dissector tables",        NULL,                       NULL,               G_CALLBACK(dissector_tables_dlg_cb) },
1535    { "/Internals/Conversations",    NULL,                           "_Conversation hash tables",NULL,                       NULL,               G_CALLBACK(conversation_hastables_dlg) },
1536    { "/Internals/SupportedProtocols", NULL,                 "_Supported Protocols (slow!)",     NULL,                       NULL,               G_CALLBACK(supported_cb) },
1537
1538    { "/Help/Contents",              GTK_STOCK_HELP,                 "_Contents",            "F1",                           NULL,               G_CALLBACK(help_menu_cont_cb) },
1539    { "/Help/ManualPages",           NULL,                           "ManualPages",          NULL,                           NULL,               NULL },
1540    { "/Help/ManualPages/Wireshark", NULL,                           "Wireshark",            NULL,                           NULL,               G_CALLBACK(help_menu_wireshark_cb) },
1541    { "/Help/ManualPages/WiresharkFilter", NULL,                     "Wireshark Filter",     NULL,                           NULL,               G_CALLBACK(help_menu_wireshark_flt_cb) },
1542    { "/Help/ManualPages/Capinfos",  NULL,                           "Capinfos",              NULL,                          NULL,               G_CALLBACK(help_menu_Capinfos_cb) },
1543    { "/Help/ManualPages/Dumpcap",   NULL,                           "Dumpcap",              NULL,                           NULL,               G_CALLBACK(help_menu_Dumpcap_cb) },
1544    { "/Help/ManualPages/Editcap",   NULL,                           "Editcap",              NULL,                           NULL,               G_CALLBACK(help_menu_Editcap_cb) },
1545    { "/Help/ManualPages/Mergecap",  NULL,                           "Mergecap",             NULL,                           NULL,               G_CALLBACK(help_menu_Mergecap_cb) },
1546    { "/Help/ManualPages/RawShark",  NULL,                           "RawShark",             NULL,                           NULL,               G_CALLBACK(help_menu_RawShark_cb) },
1547    { "/Help/ManualPages/Reordercap",  NULL,                         "Reordercap",             NULL,                         NULL,               G_CALLBACK(help_menu_Reorder_cb) },
1548    { "/Help/ManualPages/Text2pcap", NULL,                           "Text2pcap",            NULL,                           NULL,               G_CALLBACK(help_menu_Text2pcap_cb) },
1549    { "/Help/ManualPages/TShark",    NULL,                           "TShark",            NULL,                           NULL,               G_CALLBACK(help_menu_TShark_cb) },
1550
1551    { "/Help/Website",               GTK_STOCK_HOME,                 "Website",              NULL,                           NULL,               G_CALLBACK(help_menu_Website_cb) },
1552    { "/Help/FAQs",                  NULL,                           "FAQ's",                NULL,                           NULL,               G_CALLBACK(help_menu_faq_cb) },
1553    { "/Help/ASK",                   NULL,                           "Ask (Q&A)",            NULL,                           NULL,               G_CALLBACK(help_menu_ask_cb) },
1554    { "/Help/Downloads",             NULL,                           "Downloads",            NULL,                           NULL,               G_CALLBACK(help_menu_Downloads_cb) },
1555    { "/Help/Wiki",                  WIRESHARK_STOCK_WIKI,           "Wiki",                 NULL,                           NULL,               G_CALLBACK(help_menu_Wiki_cb) },
1556    { "/Help/SampleCaptures",        NULL,                           "Sample Captures",      NULL,                           NULL,               G_CALLBACK(help_menu_SampleCaptures_cb) },
1557 #ifdef HAVE_SOFTWARE_UPDATE
1558    { "/Help/CheckForUpdates",       NULL,                           "Check for Updates...", NULL,                           NULL,               G_CALLBACK(check_for_updates_cb) },
1559 #endif /* HAVE_SOFTWARE_UPDATE */
1560    { "/Help/AboutWireshark",        WIRESHARK_STOCK_ABOUT,          "_About Wireshark",     NULL,                           NULL,               G_CALLBACK(about_wireshark_cb) },
1561 };
1562
1563 static const GtkToggleActionEntry main_menu_bar_toggle_action_entries[] =
1564 {
1565     /* name, stock id, label, accel, tooltip, callback, is_active */
1566     {"/View/MainToolbar",                                           NULL, "_Main Toolbar",                          NULL, NULL, G_CALLBACK(main_toolbar_show_hide_cb), TRUE},
1567     {"/View/FilterToolbar",                                         NULL, "_Filter Toolbar",                         NULL, NULL, G_CALLBACK(filter_toolbar_show_hide_cb), TRUE},
1568     {"/View/WirelessToolbar",                                       NULL, "Wire_less Toolbar",                       NULL, NULL, G_CALLBACK(wireless_toolbar_show_hide_cb), FALSE},
1569     {"/View/StatusBar",                                             NULL, "_Status Bar",                             NULL, NULL, G_CALLBACK(status_bar_show_hide_cb), TRUE},
1570     {"/View/PacketList",                                            NULL, "Packet _List",                           NULL, NULL, G_CALLBACK(packet_list_show_hide_cb), TRUE},
1571     {"/View/PacketDetails",                                         NULL, "Packet _Details",                        NULL, NULL, G_CALLBACK(packet_details_show_hide_cb), TRUE},
1572     {"/View/PacketBytes",                                           NULL, "Packet _Bytes",                          NULL, NULL, G_CALLBACK(packet_bytes_show_hide_cb), TRUE},
1573     {"/View/TimeDisplayFormat/DisplaySecondsWithHoursAndMinutes",   NULL, "Display Seconds with hours and minutes", NULL, NULL, G_CALLBACK(timestamp_seconds_time_cb), FALSE},
1574     {"/View/NameResolution/EnableforMACLayer",                      NULL, "Enable for _MAC Layer",                  NULL, NULL, G_CALLBACK(view_menu_en_for_MAC_cb), TRUE},
1575     {"/View/NameResolution/EnableforTransportLayer",                NULL, "Enable for _Transport Layer",            NULL, NULL, G_CALLBACK(view_menu_en_for_transport_cb), TRUE },
1576     {"/View/NameResolution/EnableforNetworkLayer",                  NULL, "Enable for _Network Layer",              NULL, NULL, G_CALLBACK(view_menu_en_for_network_cb), TRUE },
1577     {"/View/NameResolution/UseExternalNetworkNameResolver",         NULL, "Use _External Network Name Resolver",    NULL, NULL, G_CALLBACK(view_menu_en_use_external_resolver_cb), TRUE },
1578     {"/View/ColorizePacketList",                                    NULL, "Colorize Packet List",                   NULL, NULL, G_CALLBACK(view_menu_colorize_pkt_lst_cb), TRUE },
1579 #ifdef HAVE_LIBPCAP
1580     {"/View/AutoScrollinLiveCapture",                               NULL, "Auto Scroll in Li_ve Capture",           NULL, NULL, G_CALLBACK(view_menu_auto_scroll_live_cb), TRUE },
1581 #endif
1582 };
1583
1584 static const GtkRadioActionEntry main_menu_bar_radio_view_time_entries [] =
1585 {
1586     /* name, stock id, label, accel, tooltip,  value */
1587     { "/View/TimeDisplayFormat/DateYMDandTimeofDay",                NULL, "Date and Time of Day:   1970-01-01 01:02:03.123456", "<alt><control>1", NULL, TS_ABSOLUTE_WITH_YMD },
1588     { "/View/TimeDisplayFormat/DateYDOYandTimeofDay",               NULL, "Date (with day of year) and Time of Day:   1970/001 01:02:03.123456", NULL, NULL, TS_ABSOLUTE_WITH_YDOY },
1589     { "/View/TimeDisplayFormat/TimeofDay",                          NULL, "Time of Day:   01:02:03.123456", "<alt><control>2", NULL, TS_ABSOLUTE },
1590     { "/View/TimeDisplayFormat/SecondsSinceEpoch",                  NULL, "Seconds Since Epoch (1970-01-01):   1234567890.123456", "<alt><control>3", NULL, TS_EPOCH },
1591     { "/View/TimeDisplayFormat/SecondsSinceBeginningofCapture",     NULL, "Seconds Since Beginning of Capture:   123.123456", "<alt><control>4", NULL, TS_RELATIVE },
1592     { "/View/TimeDisplayFormat/SecondsSincePreviousCapturedPacket", NULL, "Seconds Since Previous Captured Packet:   1.123456", "<alt><control>5", NULL, TS_DELTA },
1593     { "/View/TimeDisplayFormat/SecondsSincePreviousDisplayedPacket",NULL, "Seconds Since Previous Displayed Packet:   1.123456", "<alt><control>6", NULL, TS_DELTA_DIS },
1594     { "/View/TimeDisplayFormat/UTCDateYMDandTimeofDay",             NULL, "UTC Date and Time of Day:   1970-01-01 01:02:03.123456", "<alt><control>7", NULL, TS_UTC_WITH_YMD },
1595     { "/View/TimeDisplayFormat/UTCDateYDOYandTimeofDay",            NULL, "UTC Date (with day of year) and Time of Day:   1970/001 01:02:03.123456", NULL, NULL, TS_UTC_WITH_YDOY },
1596     { "/View/TimeDisplayFormat/UTCTimeofDay",                       NULL, "UTC Time of Day:   01:02:03.123456", "<alt><control>8", NULL, TS_UTC },
1597 };
1598
1599 static const GtkRadioActionEntry main_menu_bar_radio_view_time_fileformat_prec_entries [] =
1600 {
1601     /* name, stock id, label, accel, tooltip,  value */
1602     { "/View/TimeDisplayFormat/FileFormatPrecision-Automatic",      NULL, "Automatic (use precision indicated in the file)",  NULL, NULL, TS_PREC_AUTO },
1603     { "/View/TimeDisplayFormat/FileFormatPrecision-Seconds",        NULL, "Seconds:   0",                       NULL, NULL, TS_PREC_FIXED_SEC },
1604     { "/View/TimeDisplayFormat/FileFormatPrecision-Deciseconds",    NULL, "Deciseconds:   0.1",                 NULL, NULL, TS_PREC_FIXED_DSEC },
1605     { "/View/TimeDisplayFormat/FileFormatPrecision-Centiseconds",   NULL, "Centiseconds:  0.12",                NULL, NULL, TS_PREC_FIXED_CSEC },
1606     { "/View/TimeDisplayFormat/FileFormatPrecision-Milliseconds",   NULL, "Milliseconds:  0.123",               NULL, NULL, TS_PREC_FIXED_MSEC },
1607     { "/View/TimeDisplayFormat/FileFormatPrecision-Microseconds",   NULL, "Microseconds:  0.123456",            NULL, NULL, TS_PREC_FIXED_USEC },
1608     { "/View/TimeDisplayFormat/FileFormatPrecision-Nanoseconds",    NULL, "Nanoseconds:   0.123456789",         NULL, NULL, TS_PREC_FIXED_NSEC },
1609 };
1610
1611
1612 static void
1613 select_bytes_view_cb (GtkRadioAction *action, GtkRadioAction *current _U_, gpointer user_data _U_)
1614 {
1615     bytes_view_type value;
1616
1617     value = (bytes_view_type)gtk_radio_action_get_current_value (action);
1618     /* Fix me */
1619     select_bytes_view( NULL, NULL, value);
1620 }
1621
1622 static void
1623 sort_ascending_cb(GtkAction *action _U_, gpointer user_data)
1624 {
1625     GtkWidget *widget = gtk_ui_manager_get_widget(ui_manager_packet_list_heading, "/PacketListHeadingPopup/SortAscending");
1626     packet_list_column_menu_cb( widget , user_data, COLUMN_SELECTED_SORT_ASCENDING);
1627 }
1628
1629 static void
1630 sort_descending_cb(GtkAction *action _U_, gpointer user_data)
1631 {
1632     GtkWidget *widget = gtk_ui_manager_get_widget(ui_manager_packet_list_heading, "/PacketListHeadingPopup/SortDescending");
1633     packet_list_column_menu_cb( widget , user_data, COLUMN_SELECTED_SORT_DESCENDING);
1634 }
1635
1636 static void
1637 no_sorting_cb(GtkAction *action _U_, gpointer user_data)
1638 {
1639     GtkWidget *widget = gtk_ui_manager_get_widget(ui_manager_packet_list_heading, "/PacketListHeadingPopup/NoSorting");
1640     packet_list_column_menu_cb( widget , user_data, COLUMN_SELECTED_SORT_NONE);
1641 }
1642
1643 static void
1644 packet_list_heading_show_resolved_cb(GtkAction *action _U_, gpointer user_data _U_)
1645 {
1646     GtkWidget *widget = gtk_ui_manager_get_widget(ui_manager_packet_list_heading, "/PacketListHeadingPopup/ShowResolved");
1647
1648     packet_list_column_menu_cb( widget , user_data, COLUMN_SELECTED_TOGGLE_RESOLVED);
1649 }
1650
1651 static void
1652 packet_list_heading_align_left_cb(GtkAction *action _U_, gpointer user_data)
1653 {
1654     GtkWidget *widget = gtk_ui_manager_get_widget(ui_manager_packet_list_heading, "/PacketListHeadingPopup/AlignLeft");
1655     packet_list_column_menu_cb( widget , user_data, COLUMN_SELECTED_ALIGN_LEFT);
1656 }
1657
1658 static void
1659 packet_list_heading_align_center_cb(GtkAction *action _U_, gpointer user_data)
1660 {
1661     GtkWidget *widget = gtk_ui_manager_get_widget(ui_manager_packet_list_heading, "/PacketListHeadingPopup/AlignCenter");
1662     packet_list_column_menu_cb( widget , user_data, COLUMN_SELECTED_ALIGN_CENTER);
1663 }
1664
1665 static void
1666 packet_list_heading_align_right_cb(GtkAction *action _U_, gpointer user_data)
1667 {
1668     GtkWidget *widget = gtk_ui_manager_get_widget(ui_manager_packet_list_heading, "/PacketListHeadingPopup/AlignRight");
1669     packet_list_column_menu_cb( widget , user_data, COLUMN_SELECTED_ALIGN_RIGHT);
1670 }
1671
1672 static void
1673 packet_list_heading_col_pref_cb(GtkAction *action _U_, gpointer user_data)
1674 {
1675     GtkWidget *widget = gtk_ui_manager_get_widget(ui_manager_packet_list_heading, "/PacketListHeadingPopup/ColumnPreferences");
1676     prefs_page_cb( widget , user_data, PREFS_PAGE_COLUMNS);
1677 }
1678
1679 static void
1680 packet_list_heading_resize_col_cb(GtkAction *action _U_, gpointer user_data)
1681 {
1682     GtkWidget *widget = gtk_ui_manager_get_widget(ui_manager_packet_list_heading, "/PacketListHeadingPopup/ResizeColumn");
1683     packet_list_column_menu_cb( widget , user_data, COLUMN_SELECTED_RESIZE);
1684 }
1685
1686 static void
1687 packet_list_heading_change_col_cb(GtkAction *action _U_, gpointer user_data)
1688 {
1689     GtkWidget *widget = gtk_ui_manager_get_widget(ui_manager_packet_list_heading, "/PacketListHeadingPopup/EditColumnDetails");
1690     packet_list_column_menu_cb( widget , user_data, COLUMN_SELECTED_CHANGE);
1691 }
1692
1693 static void
1694 packet_list_heading_activate_all_columns_cb(GtkAction *action _U_, gpointer user_data _U_)
1695 {
1696     packet_list_set_all_columns_visible ();
1697 }
1698
1699 static void
1700 packet_list_heading_hide_col_cb(GtkAction *action _U_, gpointer user_data)
1701 {
1702     GtkWidget *widget = gtk_ui_manager_get_widget(ui_manager_packet_list_heading, "/PacketListHeadingPopup/HideColumn");
1703     packet_list_column_menu_cb( widget , user_data, COLUMN_SELECTED_HIDE);
1704 }
1705
1706 static void
1707 packet_list_heading_remove_col_cb(GtkAction *action _U_, gpointer user_data)
1708 {
1709     GtkWidget *widget = gtk_ui_manager_get_widget(ui_manager_packet_list_heading, "/PacketListHeadingPopup/RemoveColumn");
1710     packet_list_column_menu_cb( widget , user_data, COLUMN_SELECTED_REMOVE);
1711 }
1712
1713 static void
1714 packet_list_menu_set_ref_time_cb(GtkAction *action _U_, gpointer user_data)
1715 {
1716     reftime_frame_cb( NULL /* widget _U_ */ , user_data, REFTIME_TOGGLE);
1717 }
1718
1719
1720 static void
1721 apply_selected_filter_cb(GtkAction *action, gpointer user_data)
1722 {
1723     const gchar *path = gtk_action_get_accel_path(action);
1724     /*g_warning("Accelerator path %s",path+9);*/
1725
1726     /* path starts with "<Actions>" */
1727     if (strncmp (path+9,"/PacketListPopUpMenuActionGroup",31) == 0){
1728         /* Use different callbacks depending action path */
1729         match_selected_plist_cb(user_data, (MATCH_SELECTED_E)(MATCH_SELECTED_REPLACE|MATCH_SELECTED_APPLY_NOW));
1730     } else {
1731         match_selected_ptree_cb(user_data, (MATCH_SELECTED_E)(MATCH_SELECTED_REPLACE|MATCH_SELECTED_APPLY_NOW));
1732     }
1733 }
1734
1735 static void
1736 apply_not_selected_cb(GtkAction *action, gpointer user_data)
1737 {
1738     const gchar *path = gtk_action_get_accel_path(action);
1739
1740     /* path starts with "<Actions>" */
1741     if (strncmp (path+9,"/PacketListPopUpMenuActionGroup",31) == 0){
1742         /* Use different callbacks depending action path */
1743         match_selected_plist_cb(user_data, (MATCH_SELECTED_E)(MATCH_SELECTED_NOT|MATCH_SELECTED_APPLY_NOW));
1744     } else {
1745         match_selected_ptree_cb(user_data, (MATCH_SELECTED_E)(MATCH_SELECTED_NOT|MATCH_SELECTED_APPLY_NOW));
1746     }
1747 }
1748
1749 static void
1750 apply_and_selected_cb(GtkAction *action, gpointer user_data)
1751 {
1752     const gchar *path = gtk_action_get_accel_path(action);
1753
1754     /* path starts with "<Actions>" */
1755     if (strncmp (path+9,"/PacketListPopUpMenuActionGroup",31) == 0){
1756         /* Use different callbacks depending action path */
1757         match_selected_plist_cb(user_data, (MATCH_SELECTED_E)(MATCH_SELECTED_AND|MATCH_SELECTED_APPLY_NOW));
1758     } else {
1759         match_selected_ptree_cb(user_data, (MATCH_SELECTED_E)(MATCH_SELECTED_AND|MATCH_SELECTED_APPLY_NOW));
1760     }
1761 }
1762
1763 static void
1764 apply_or_selected_cb(GtkAction *action, gpointer user_data)
1765 {
1766     const gchar *path = gtk_action_get_accel_path(action);
1767
1768     /* path starts with "<Actions>" */
1769     if (strncmp (path+9,"/PacketListPopUpMenuActionGroup",31) == 0){
1770         /* Use different callbacks depending action path */
1771         match_selected_plist_cb(user_data, (MATCH_SELECTED_E)(MATCH_SELECTED_OR|MATCH_SELECTED_APPLY_NOW));
1772     } else {
1773         match_selected_ptree_cb(user_data, (MATCH_SELECTED_E)(MATCH_SELECTED_OR|MATCH_SELECTED_APPLY_NOW));
1774     }
1775 }
1776
1777 static void
1778 apply_and_not_selected_cb(GtkAction *action, gpointer user_data)
1779 {
1780     const gchar *path = gtk_action_get_accel_path(action);
1781
1782     /* path starts with "<Actions>" */
1783     if (strncmp (path+9,"/PacketListPopUpMenuActionGroup",31) == 0){
1784         /* Use different callbacks depending action path */
1785         match_selected_plist_cb(user_data, (MATCH_SELECTED_E)(MATCH_SELECTED_AND_NOT|MATCH_SELECTED_APPLY_NOW));
1786     } else {
1787         match_selected_ptree_cb(user_data, (MATCH_SELECTED_E)(MATCH_SELECTED_AND_NOT|MATCH_SELECTED_APPLY_NOW));
1788     }
1789 }
1790
1791 static void
1792 apply_or_not_selected_cb(GtkAction *action, gpointer user_data)
1793 {
1794     const gchar *path = gtk_action_get_accel_path(action);
1795
1796     /* path starts with "<Actions>" */
1797     if (strncmp (path+9,"/PacketListPopUpMenuActionGroup",31) == 0){
1798         /* Use different callbacks depending action path */
1799         match_selected_plist_cb(user_data,(MATCH_SELECTED_E)(MATCH_SELECTED_OR_NOT|MATCH_SELECTED_APPLY_NOW));
1800     } else {
1801         match_selected_ptree_cb(user_data, (MATCH_SELECTED_E)(MATCH_SELECTED_OR_NOT|MATCH_SELECTED_APPLY_NOW));
1802     }
1803 }
1804
1805 /* Prepare a filter */
1806 static void
1807 prepare_selected_cb(GtkAction *action, gpointer user_data)
1808 {
1809     const gchar *path = gtk_action_get_accel_path(action);
1810
1811     /* path starts with "<Actions>" */
1812     if (strncmp (path+9,"/PacketListPopUpMenuActionGroup",31) == 0){
1813         /* Use different callbacks depending action path */
1814         match_selected_plist_cb(user_data, MATCH_SELECTED_REPLACE);
1815     } else {
1816         match_selected_ptree_cb(user_data, MATCH_SELECTED_REPLACE);
1817     }
1818 }
1819
1820 static void
1821 prepare_not_selected_cb(GtkAction *action, gpointer user_data)
1822 {
1823     const gchar *path = gtk_action_get_accel_path(action);
1824
1825     /* path starts with "<Actions>" */
1826     if (strncmp (path+9,"/PacketListPopUpMenuActionGroup",31) == 0){
1827         /* Use different callbacks depending action path */
1828         match_selected_plist_cb(user_data, MATCH_SELECTED_NOT);
1829     } else {
1830         match_selected_ptree_cb(user_data, MATCH_SELECTED_NOT);
1831     }
1832 }
1833
1834 static void
1835 prepare_and_selected_cb(GtkAction *action, gpointer user_data)
1836 {
1837     const gchar *path = gtk_action_get_accel_path(action);
1838
1839     /* path starts with "<Actions>" */
1840     if (strncmp (path+9,"/PacketListPopUpMenuActionGroup",31) == 0){
1841         /* Use different callbacks depending action path */
1842         match_selected_plist_cb(user_data, MATCH_SELECTED_AND);
1843     } else {
1844         match_selected_ptree_cb(user_data, MATCH_SELECTED_AND);
1845     }
1846 }
1847
1848 static void
1849 prepare_or_selected_cb(GtkAction *action, gpointer user_data)
1850 {
1851     const gchar *path = gtk_action_get_accel_path(action);
1852
1853     /* path starts with "<Actions>" */
1854     if (strncmp (path+9,"/PacketListPopUpMenuActionGroup",31) == 0){
1855         /* Use different callbacks depending action path */
1856         match_selected_plist_cb(user_data, MATCH_SELECTED_OR);
1857     } else {
1858         match_selected_ptree_cb(user_data, MATCH_SELECTED_OR);
1859     }
1860 }
1861
1862 static void
1863 prepare_and_not_selected_cb(GtkAction *action, gpointer user_data)
1864 {
1865     const gchar *path = gtk_action_get_accel_path(action);
1866
1867     /* path starts with "<Actions>" */
1868     if (strncmp (path+9,"/PacketListPopUpMenuActionGroup",31) == 0){
1869         /* Use different callbacks depending action path */
1870         match_selected_plist_cb(user_data, MATCH_SELECTED_AND_NOT);
1871     } else {
1872         match_selected_ptree_cb(user_data, MATCH_SELECTED_AND_NOT);
1873     }
1874 }
1875
1876 static void
1877 prepare_or_not_selected_cb(GtkAction *action, gpointer user_data)
1878 {
1879     const gchar *path = gtk_action_get_accel_path(action);
1880
1881     /* path starts with "<Actions>" */
1882     if (strncmp (path+9,"/PacketListPopUpMenuActionGroup",31) == 0){
1883         /* Use different callbacks depending action path */
1884         match_selected_plist_cb(user_data, MATCH_SELECTED_OR_NOT);
1885     } else {
1886         match_selected_ptree_cb(user_data, MATCH_SELECTED_OR_NOT);
1887     }
1888 }
1889
1890 typedef void (*packet_list_menu_color_conv_color_cb_t)(GtkAction *action, gpointer user_data);
1891
1892 static void
1893 packet_list_menu_color_conv_color1_cb(GtkAction *action _U_, gpointer user_data)
1894 {
1895     conversation_filter_t* color_filter = (conversation_filter_t*)user_data;
1896     colorize_conversation_cb(color_filter, 1);
1897 }
1898
1899 static void
1900 packet_list_menu_color_conv_color2_cb(GtkAction *action _U_, gpointer user_data)
1901 {
1902     conversation_filter_t* color_filter = (conversation_filter_t*)user_data;
1903     colorize_conversation_cb(color_filter, 2);
1904 }
1905
1906 static void
1907 packet_list_menu_color_conv_color3_cb(GtkAction *action _U_, gpointer user_data)
1908 {
1909     conversation_filter_t* color_filter = (conversation_filter_t*)user_data;
1910     colorize_conversation_cb(color_filter, 3);
1911 }
1912
1913 static void
1914 packet_list_menu_color_conv_color4_cb(GtkAction *action _U_, gpointer user_data)
1915 {
1916     conversation_filter_t* color_filter = (conversation_filter_t*)user_data;
1917     colorize_conversation_cb(color_filter, 4);
1918 }
1919
1920 static void
1921 packet_list_menu_color_conv_color5_cb(GtkAction *action _U_, gpointer user_data)
1922 {
1923     conversation_filter_t* color_filter = (conversation_filter_t*)user_data;
1924     colorize_conversation_cb(color_filter, 5);
1925 }
1926
1927 static void
1928 packet_list_menu_color_conv_color6_cb(GtkAction *action _U_, gpointer user_data)
1929 {
1930     conversation_filter_t* color_filter = (conversation_filter_t*)user_data;
1931     colorize_conversation_cb(color_filter, 6);
1932 }
1933
1934 static void
1935 packet_list_menu_color_conv_color7_cb(GtkAction *action _U_, gpointer user_data)
1936 {
1937     conversation_filter_t* color_filter = (conversation_filter_t*)user_data;
1938     colorize_conversation_cb(color_filter, 7);
1939 }
1940
1941 static void
1942 packet_list_menu_color_conv_color8_cb(GtkAction *action _U_, gpointer user_data)
1943 {
1944     conversation_filter_t* color_filter = (conversation_filter_t*)user_data;
1945     colorize_conversation_cb(color_filter, 8);
1946 }
1947
1948 static void
1949 packet_list_menu_color_conv_color9_cb(GtkAction *action _U_, gpointer user_data)
1950 {
1951     conversation_filter_t* color_filter = (conversation_filter_t*)user_data;
1952     colorize_conversation_cb(color_filter, 9);
1953 }
1954
1955 static void
1956 packet_list_menu_color_conv_color10_cb(GtkAction *action _U_, gpointer user_data)
1957 {
1958     conversation_filter_t* color_filter = (conversation_filter_t*)user_data;
1959     colorize_conversation_cb(color_filter, 10);
1960 }
1961
1962 static void
1963 packet_list_menu_color_conv_new_rule_cb(GtkAction *action _U_, gpointer user_data)
1964 {
1965     conversation_filter_t* color_filter = (conversation_filter_t*)user_data;
1966     colorize_conversation_cb(color_filter, 0);
1967 }
1968
1969 static void
1970 packet_list_menu_copy_sum_txt(GtkAction *action _U_, gpointer user_data)
1971 {
1972     packet_list_copy_summary_cb(user_data, CS_TEXT);
1973 }
1974
1975 static void
1976 packet_list_menu_copy_sum_csv(GtkAction *action _U_, gpointer user_data)
1977 {
1978     packet_list_copy_summary_cb(user_data, CS_CSV);
1979 }
1980
1981 static void
1982 packet_list_menu_copy_as_flt(GtkAction *action _U_, gpointer user_data)
1983 {
1984     match_selected_plist_cb(user_data, (MATCH_SELECTED_E)(MATCH_SELECTED_REPLACE|MATCH_SELECTED_COPY_ONLY));
1985 }
1986
1987 static void
1988 packet_list_menu_copy_bytes_oht_cb(GtkAction *action _U_, gpointer user_data)
1989 {
1990     copy_hex_cb( NULL /* widget _U_ */ , user_data, (copy_data_type)(CD_ALLINFO | CD_FLAGS_SELECTEDONLY));
1991 }
1992
1993 static void
1994 packet_list_menu_copy_bytes_oh_cb(GtkAction *action _U_, gpointer user_data)
1995 {
1996     copy_hex_cb( NULL /* widget _U_ */ , user_data, (copy_data_type)(CD_HEXCOLUMNS | CD_FLAGS_SELECTEDONLY));
1997 }
1998
1999 static void
2000 packet_list_menu_copy_bytes_text_cb(GtkAction *action _U_, gpointer user_data)
2001 {
2002     copy_hex_cb( NULL /* widget _U_ */ , user_data, (copy_data_type)(CD_TEXTONLY | CD_FLAGS_SELECTEDONLY));
2003 }
2004
2005 static void
2006 packet_list_menu_copy_bytes_hex_strm_cb(GtkAction *action _U_, gpointer user_data)
2007 {
2008     copy_hex_cb( NULL /* widget _U_ */ , user_data,  (copy_data_type)(CD_HEX | CD_FLAGS_SELECTEDONLY));
2009 }
2010
2011 static void
2012 packet_list_menu_copy_bytes_bin_strm_cb(GtkAction *action _U_, gpointer user_data)
2013 {
2014     copy_hex_cb( NULL /* widget _U_ */ , user_data, (copy_data_type)(CD_BINARY | CD_FLAGS_SELECTEDONLY));
2015 }
2016
2017 /* tree */
2018
2019 static void
2020 tree_view_menu_color_with_flt_color1_cb(GtkAction *action _U_, gpointer user_data)
2021 {
2022     colorize_selected_ptree_cb( NULL /* widget _U_ */ , user_data, 1);
2023 }
2024
2025 static void
2026 tree_view_menu_color_with_flt_color2_cb(GtkAction *action _U_, gpointer user_data)
2027 {
2028     colorize_selected_ptree_cb( NULL /* widget _U_ */ , user_data, 2);
2029 }
2030
2031 static void
2032 tree_view_menu_color_with_flt_color3_cb(GtkAction *action _U_, gpointer user_data)
2033 {
2034     colorize_selected_ptree_cb( NULL /* widget _U_ */ , user_data, 3);
2035 }
2036
2037 static void
2038 tree_view_menu_color_with_flt_color4_cb(GtkAction *action _U_, gpointer user_data)
2039 {
2040     colorize_selected_ptree_cb( NULL /* widget _U_ */ , user_data, 4);
2041 }
2042
2043 static void
2044 tree_view_menu_color_with_flt_color5_cb(GtkAction *action _U_, gpointer user_data)
2045 {
2046     colorize_selected_ptree_cb( NULL /* widget _U_ */ , user_data, 5);
2047 }
2048
2049 static void
2050 tree_view_menu_color_with_flt_color6_cb(GtkAction *action _U_, gpointer user_data)
2051 {
2052     colorize_selected_ptree_cb( NULL /* widget _U_ */ , user_data, 6);
2053 }
2054
2055 static void
2056 tree_view_menu_color_with_flt_color7_cb(GtkAction *action _U_, gpointer user_data)
2057 {
2058     colorize_selected_ptree_cb( NULL /* widget _U_ */ , user_data, 7);
2059 }
2060
2061 static void
2062 tree_view_menu_color_with_flt_color8_cb(GtkAction *action _U_, gpointer user_data)
2063 {
2064     colorize_selected_ptree_cb( NULL /* widget _U_ */ , user_data, 8);
2065 }
2066
2067 static void
2068 tree_view_menu_color_with_flt_color9_cb(GtkAction *action _U_, gpointer user_data)
2069 {
2070     colorize_selected_ptree_cb( NULL /* widget _U_ */ , user_data, 9);
2071 }
2072
2073 static void
2074 tree_view_menu_color_with_flt_color10_cb(GtkAction *action _U_, gpointer user_data)
2075 {
2076     colorize_selected_ptree_cb( NULL /* widget _U_ */ , user_data, 10);
2077 }
2078
2079 static void
2080 tree_view_menu_color_with_flt_new_rule_cb(GtkAction *action _U_, gpointer user_data)
2081 {
2082     colorize_selected_ptree_cb( NULL /* widget _U_ */ , user_data, 0);
2083 }
2084
2085
2086 static void
2087 tree_view_menu_copy_desc(GtkAction *action _U_, gpointer user_data)
2088 {
2089     copy_selected_plist_cb( NULL /* widget _U_ */ , user_data, COPY_SELECTED_DESCRIPTION);
2090 }
2091
2092 static void
2093 tree_view_menu_copy_field(GtkAction *action _U_, gpointer user_data)
2094 {
2095     copy_selected_plist_cb( NULL /* widget _U_ */ , user_data, COPY_SELECTED_FIELDNAME);
2096 }
2097
2098 static void
2099 tree_view_menu_copy_value(GtkAction *action _U_, gpointer user_data)
2100 {
2101     copy_selected_plist_cb( NULL /* widget _U_ */ , user_data, COPY_SELECTED_VALUE);
2102 }
2103
2104 static void
2105 tree_view_menu_copy_as_flt(GtkAction *action _U_, gpointer user_data _U_)
2106 {
2107     /* match_selected_ptree_cb needs the popup_menu_object to get the right object E_DFILTER_TE_KEY */
2108     match_selected_ptree_cb( popup_menu_object, (MATCH_SELECTED_E)(MATCH_SELECTED_REPLACE|MATCH_SELECTED_COPY_ONLY));
2109 }
2110
2111 static const char *ui_desc_packet_list_heading_menu_popup =
2112 "<ui>\n"
2113 "  <popup name='PacketListHeadingPopup' action='PopupAction'>\n"
2114 "     <menuitem name='SortAscending' action='/Sort Ascending'/>\n"
2115 "     <menuitem name='SortDescending' action='/Sort Descending'/>\n"
2116 "     <menuitem name='NoSorting' action='/No Sorting'/>\n"
2117 "     <separator/>\n"
2118 "     <menuitem name='ShowResolved' action='/Show Resolved'/>\n"
2119 "     <separator/>\n"
2120 "     <menuitem name='AlignLeft' action='/Align Left'/>\n"
2121 "     <menuitem name='AlignCenter' action='/Align Center'/>\n"
2122 "     <menuitem name='AlignRight' action='/Align Right'/>\n"
2123 "     <separator/>\n"
2124 "     <menuitem name='ColumnPreferences' action='/Column Preferences'/>\n"
2125 "     <menuitem name='EditColumnDetails' action='/Edit Column Details'/>\n"
2126 "     <menuitem name='ResizeColumn' action='/Resize Column'/>\n"
2127 "     <separator/>\n"
2128 "     <menu name='DisplayedColumns' action='/Displayed Columns'>\n"
2129 "       <menuitem name='Display All' action='/Displayed Columns/Display All'/>\n"
2130 "     </menu>\n"
2131 "     <menuitem name='HideColumn' action='/Hide Column'/>\n"
2132 "     <menuitem name='RemoveColumn' action='/Remove Column'/>\n"
2133 "  </popup>\n"
2134 "</ui>\n";
2135
2136 static const GtkActionEntry packet_list_heading_menu_popup_action_entries[] = {
2137   { "/Sort Ascending",                  GTK_STOCK_SORT_ASCENDING,           "Sort Ascending",           NULL,   NULL,   G_CALLBACK(sort_ascending_cb) },
2138   { "/Sort Descending",                 GTK_STOCK_SORT_DESCENDING,          "Sort Descending",          NULL,   NULL,   G_CALLBACK(sort_descending_cb) },
2139   { "/No Sorting",                      NULL,                               "No Sorting",               NULL,   NULL,   G_CALLBACK(no_sorting_cb) },
2140   { "/Align Left",                      GTK_STOCK_JUSTIFY_LEFT,             "Align Left",               NULL,   NULL,   G_CALLBACK(packet_list_heading_align_left_cb) },
2141   { "/Align Center",                    GTK_STOCK_JUSTIFY_CENTER,           "Align Center",             NULL,   NULL,   G_CALLBACK(packet_list_heading_align_center_cb) },
2142   { "/Align Right",                     GTK_STOCK_JUSTIFY_RIGHT,            "Align Right",              NULL,   NULL,   G_CALLBACK(packet_list_heading_align_right_cb) },
2143   { "/Column Preferences",              GTK_STOCK_PREFERENCES,              "Column Preferences...",    NULL,   NULL,   G_CALLBACK(packet_list_heading_col_pref_cb) },
2144   { "/Edit Column Details",             WIRESHARK_STOCK_EDIT,           "Edit Column Details...",       NULL,   NULL,   G_CALLBACK(packet_list_heading_change_col_cb) },
2145   { "/Resize Column",                   WIRESHARK_STOCK_RESIZE_COLUMNS,     "Resize Column",            NULL,   NULL,   G_CALLBACK(packet_list_heading_resize_col_cb) },
2146   { "/Displayed Columns",               NULL,                               "Displayed Columns",        NULL,   NULL,   NULL },
2147   { "/Displayed Columns/Display All",               NULL,                   "Display All",              NULL,   NULL,   G_CALLBACK(packet_list_heading_activate_all_columns_cb) },
2148   { "/Hide Column",                     NULL,                               "Hide Column",              NULL,   NULL,   G_CALLBACK(packet_list_heading_hide_col_cb) },
2149   { "/Remove Column",                   GTK_STOCK_DELETE,                   "Remove Column",            NULL,   NULL,   G_CALLBACK(packet_list_heading_remove_col_cb) },
2150 };
2151
2152 static const GtkToggleActionEntry packet_list_heading_menu_toggle_action_entries[] =
2153 {
2154     /* name, stock id, label, accel, tooltip, callback, is_active */
2155     {"/Show Resolved",  NULL, "Show Resolved",  NULL, NULL, G_CALLBACK(packet_list_heading_show_resolved_cb), FALSE},
2156 };
2157
2158 static const char *ui_desc_packet_list_menu_popup =
2159 "<ui>\n"
2160 "  <popup name='PacketListMenuPopup' action='PopupAction'>\n"
2161 "     <menuitem name='MarkPacket' action='/MarkPacket'/>\n"
2162 "     <menuitem name='IgnorePacket' action='/IgnorePacket'/>\n"
2163 "     <menuitem name='SetTimeReference' action='/Set Time Reference'/>\n"
2164 "     <menuitem name='TimeShift' action='/TimeShift'/>\n"
2165 #ifdef WANT_PACKET_EDITOR
2166 "     <menuitem name='EditPacket' action='/Edit/EditPacket'/>\n"
2167 #endif
2168 "     <menuitem name='AddEditPktComment' action='/Edit/AddEditPktComment'/>\n"
2169 "     <separator/>\n"
2170 "     <menuitem name='ManuallyResolveAddress' action='/ManuallyResolveAddress'/>\n"
2171 "     <separator/>\n"
2172 "     <menu name= 'ApplyAsFilter' action='/ApplyasFilter'>\n"
2173 "       <menuitem name='Selected' action='/ApplyasFilter/Selected'/>\n"
2174 "       <menuitem name='NotSelected' action='/ApplyasFilter/Not Selected'/>\n"
2175 "       <menuitem name='AndSelected' action='/ApplyasFilter/AndSelected'/>\n"
2176 "       <menuitem name='OrSelected' action='/ApplyasFilter/OrSelected'/>\n"
2177 "       <menuitem name='AndNotSelected' action='/ApplyasFilter/AndNotSelected'/>\n"
2178 "       <menuitem name='OrNotSelected' action='/ApplyasFilter/OrNotSelected'/>\n"
2179 "     </menu>\n"
2180 "     <menu name= 'PrepareaFilter' action='/PrepareaFilter'>\n"
2181 "       <menuitem name='Selected' action='/PrepareaFilter/Selected'/>\n"
2182 "       <menuitem name='NotSelected' action='/PrepareaFilter/Not Selected'/>\n"
2183 "       <menuitem name='AndSelected' action='/PrepareaFilter/AndSelected'/>\n"
2184 "       <menuitem name='OrSelected' action='/PrepareaFilter/OrSelected'/>\n"
2185 "       <menuitem name='AndNotSelected' action='/PrepareaFilter/AndNotSelected'/>\n"
2186 "       <menuitem name='OrNotSelected' action='/PrepareaFilter/OrNotSelected'/>\n"
2187 "     </menu>\n"
2188 "     <menu name= 'ConversationFilter' action='/Conversation Filter'>\n"
2189 "       <placeholder name='Conversations'/>\n"
2190 "     </menu>\n"
2191 "     <menu name= 'ColorizeConversation' action='/Colorize Conversation'>\n"
2192 "       <placeholder name='Colorize'/>\n"
2193 "     </menu>\n"
2194 "     <menu name= 'SCTP' action='/SCTP'>\n"
2195 "        <menuitem name='AnalysethisAssociation' action='/SCTP/Analyse this Association'/>\n"
2196 "        <menuitem name='PrepareFilterforthisAssociation' action='/SCTP/Prepare Filter for this Association'/>\n"
2197 "     </menu>\n"
2198 "     <menuitem name='FollowTCPStream' action='/Follow TCP Stream'/>\n"
2199 "     <menuitem name='FollowUDPStream' action='/Follow UDP Stream'/>\n"
2200 "     <menuitem name='FollowSSLStream' action='/Follow SSL Stream'/>\n"
2201 "     <menuitem name='FollowHTTPStream' action='/Follow HTTP Stream'/>\n"
2202 "     <separator/>\n"
2203 "     <menu name= 'Copy' action='/Copy'>\n"
2204 "        <menuitem name='SummaryTxt' action='/Copy/SummaryTxt'/>\n"
2205 "        <menuitem name='SummaryCSV' action='/Copy/SummaryCSV'/>\n"
2206 "        <menuitem name='AsFilter' action='/Copy/AsFilter'/>\n"
2207 "        <separator/>\n"
2208 "        <menu name= 'Bytes' action='/Copy/Bytes'>\n"
2209 "           <menuitem name='OffsetHexText' action='/Copy/Bytes/OffsetHexText'/>\n"
2210 "           <menuitem name='OffsetHex' action='/Copy/Bytes/OffsetHex'/>\n"
2211 "           <menuitem name='PrintableTextOnly' action='/Copy/Bytes/PrintableTextOnly'/>\n"
2212 "           <separator/>\n"
2213 "           <menuitem name='HexStream' action='/Copy/Bytes/HexStream'/>\n"
2214 "           <menuitem name='BinaryStream' action='/Copy/Bytes/BinaryStream'/>\n"
2215 "        </menu>\n"
2216 "     </menu>\n"
2217 "     <separator/>\n"
2218 "     <menuitem name='ProtocolPreferences' action='/ProtocolPreferences'/>\n"
2219 "     <menuitem name='DecodeAs' action='/DecodeAs'/>\n"
2220 "     <menuitem name='Print' action='/Print'/>\n"
2221 "     <menuitem name='ShowPacketinNewWindow' action='/ShowPacketinNewWindow'/>\n"
2222 "  </popup>\n"
2223 "</ui>\n";
2224
2225 static const GtkActionEntry apply_prepare_filter_action_entries[] = {
2226   { "/ApplyasFilter",                 NULL, "Apply as Filter",                             NULL, NULL, NULL },
2227   { "/ApplyasFilter/Selected",        NULL, "_Selected" ,                                  NULL, NULL, G_CALLBACK(apply_selected_filter_cb) },
2228   { "/ApplyasFilter/Not Selected",    NULL, "_Not Selected",                               NULL, NULL, G_CALLBACK(apply_not_selected_cb) },
2229   { "/ApplyasFilter/AndSelected",     NULL, UTF8_HORIZONTAL_ELLIPSIS " _and Selected",     NULL, NULL, G_CALLBACK(apply_and_selected_cb) },
2230   { "/ApplyasFilter/OrSelected",      NULL, UTF8_HORIZONTAL_ELLIPSIS " _or Selected",      NULL, NULL, G_CALLBACK(apply_or_selected_cb) },
2231   { "/ApplyasFilter/AndNotSelected",  NULL, UTF8_HORIZONTAL_ELLIPSIS " a_nd not Selected", NULL, NULL, G_CALLBACK(apply_and_not_selected_cb) },
2232   { "/ApplyasFilter/OrNotSelected",   NULL, UTF8_HORIZONTAL_ELLIPSIS " o_r not Selected",  NULL, NULL, G_CALLBACK(apply_or_not_selected_cb) },
2233
2234   { "/PrepareaFilter",                NULL, "Prepare a Filter",       NULL, NULL, NULL },
2235   { "/PrepareaFilter/Selected",       NULL, "_Selected" ,             NULL, NULL, G_CALLBACK(prepare_selected_cb) },
2236   { "/PrepareaFilter/Not Selected",   NULL, "_Not Selected",          NULL, NULL, G_CALLBACK(prepare_not_selected_cb) },
2237   { "/PrepareaFilter/AndSelected",    NULL, UTF8_HORIZONTAL_ELLIPSIS " _and Selected",        NULL, NULL, G_CALLBACK(prepare_and_selected_cb) },
2238   { "/PrepareaFilter/OrSelected",     NULL, UTF8_HORIZONTAL_ELLIPSIS " _or Selected",     NULL, NULL, G_CALLBACK(prepare_or_selected_cb) },
2239   { "/PrepareaFilter/AndNotSelected", NULL, UTF8_HORIZONTAL_ELLIPSIS " a_nd not Selected",    NULL, NULL, G_CALLBACK(prepare_and_not_selected_cb) },
2240   { "/PrepareaFilter/OrNotSelected",  NULL, UTF8_HORIZONTAL_ELLIPSIS " o_r not Selected", NULL, NULL, G_CALLBACK(prepare_or_not_selected_cb) },
2241 };
2242
2243
2244 static const GtkActionEntry packet_list_menu_popup_action_entries[] = {
2245   { "/MarkPacket",                      NULL,                   "Mark Packet (toggle)",         NULL,                   NULL,           G_CALLBACK(packet_list_mark_frame_cb) },
2246   { "/IgnorePacket",                    NULL,                   "Ignore Packet (toggle)",       NULL,                   NULL,           G_CALLBACK(packet_list_ignore_frame_cb) },
2247   { "/Set Time Reference",              WIRESHARK_STOCK_TIME,   "Set Time Reference (toggle)",  NULL,                   NULL,           G_CALLBACK(packet_list_menu_set_ref_time_cb) },
2248   { "/TimeShift",                       WIRESHARK_STOCK_TIME,   "Time Shift...",                NULL,                   NULL,           G_CALLBACK(time_shift_cb) },
2249   { "/ManuallyResolveAddress",          NULL,                   "Manually Resolve Address",     NULL,                   NULL,           G_CALLBACK(manual_addr_resolv_dlg) },
2250 #ifdef WANT_PACKET_EDITOR
2251    { "/Edit/EditPacket",                NULL,                   "_Edit Packet",                 NULL,                   NULL,           G_CALLBACK(edit_window_cb) },
2252 #endif
2253   { "/Edit/AddEditPktComment",          WIRESHARK_STOCK_EDIT,   "Packet Comment...",            NULL,                   NULL,           G_CALLBACK(edit_packet_comment_dlg) },
2254
2255   { "/Conversation Filter",             NULL, "Conversation Filter",    NULL, NULL, NULL },
2256   { "/Colorize Conversation",           NULL, "Colorize Conversation",  NULL, NULL, NULL },
2257
2258   { "/SCTP",        NULL, "SCTP",               NULL, NULL, NULL },
2259   { "/SCTP/Analyse this Association",               NULL,       "Analyse this Association",             NULL, NULL, G_CALLBACK(sctp_analyse_start) },
2260   { "/SCTP/Prepare Filter for this Association",    NULL,       "Prepare Filter for this Association",  NULL, NULL, G_CALLBACK(sctp_set_assoc_filter) },
2261
2262
2263   { "/Follow TCP Stream",                           NULL,       "Follow TCP Stream",                    NULL, NULL, G_CALLBACK(follow_tcp_stream_cb) },
2264   { "/Follow UDP Stream",                           NULL,       "Follow UDP Stream",                    NULL, NULL, G_CALLBACK(follow_udp_stream_cb) },
2265   { "/Follow SSL Stream",                           NULL,       "Follow SSL Stream",                    NULL, NULL, G_CALLBACK(follow_ssl_stream_cb) },
2266   { "/Follow HTTP Stream",                          NULL,       "Follow HTTP Stream",                   NULL, NULL, G_CALLBACK(follow_http_stream_cb) },
2267
2268   { "/Copy",        NULL, "Copy",                   NULL, NULL, NULL },
2269   { "/Copy/SummaryTxt",                             NULL,       "Summary (Text)",                       NULL, NULL, G_CALLBACK(packet_list_menu_copy_sum_txt) },
2270   { "/Copy/SummaryCSV",                             NULL,       "Summary (CSV)",                        NULL, NULL, G_CALLBACK(packet_list_menu_copy_sum_csv) },
2271   { "/Copy/AsFilter",                               NULL,       "As Filter",                            NULL, NULL, G_CALLBACK(packet_list_menu_copy_as_flt) },
2272
2273
2274   { "/Copy/Bytes",                                  NULL,       "Bytes",                    NULL, NULL, NULL },
2275   { "/Copy/Bytes/OffsetHexText",                    NULL,       "Offset Hex Text",                      NULL, NULL, G_CALLBACK(packet_list_menu_copy_bytes_oht_cb) },
2276   { "/Copy/Bytes/OffsetHex",                        NULL,       "Offset Hex",                           NULL, NULL, G_CALLBACK(packet_list_menu_copy_bytes_oh_cb) },
2277   { "/Copy/Bytes/PrintableTextOnly",                NULL,       "Printable Text Only",                  NULL, NULL, G_CALLBACK(packet_list_menu_copy_bytes_text_cb) },
2278
2279   { "/Copy/Bytes/HexStream",                        NULL,       "Hex Stream",                           NULL, NULL, G_CALLBACK(packet_list_menu_copy_bytes_hex_strm_cb) },
2280   { "/Copy/Bytes/BinaryStream",                     NULL,       "Binary Stream",                        NULL, NULL, G_CALLBACK(packet_list_menu_copy_bytes_bin_strm_cb) },
2281
2282   { "/ProtocolPreferences",                         NULL,       "Protocol Preferences",                 NULL, NULL, NULL },
2283   { "/DecodeAs",                                    WIRESHARK_STOCK_DECODE_AS,  "Decode As...",         NULL, NULL, G_CALLBACK(decode_as_cb) },
2284   { "/Print",                                       GTK_STOCK_PRINT,            "Print...",             NULL, NULL, G_CALLBACK(file_print_selected_cmd_cb) },
2285   { "/ShowPacketinNewWindow",                       NULL,           "Show Packet in New Window",        NULL, NULL, G_CALLBACK(new_window_cb) },
2286
2287 };
2288
2289 static const char *ui_desc_tree_view_menu_popup =
2290 "<ui>\n"
2291 "  <popup name='TreeViewPopup' action='PopupAction'>\n"
2292 "     <menuitem name='ExpandSubtrees' action='/ExpandSubtrees'/>\n"
2293 "     <menuitem name='CollapseSubtrees' action='/CollapseSubtrees'/>\n"
2294 "     <menuitem name='ExpandAll' action='/ExpandAll'/>\n"
2295 "     <menuitem name='CollapseAll' action='/CollapseAll'/>\n"
2296 "     <separator/>\n"
2297 "     <menuitem name='ApplyasColumn' action='/Apply as Column'/>\n"
2298 "     <separator/>\n"
2299 "     <menu name= 'ApplyAsFilter' action='/ApplyasFilter'>\n"
2300 "       <menuitem name='Selected' action='/ApplyasFilter/Selected'/>\n"
2301 "       <menuitem name='NotSelected' action='/ApplyasFilter/Not Selected'/>\n"
2302 "       <menuitem name='AndSelected' action='/ApplyasFilter/AndSelected'/>\n"
2303 "       <menuitem name='OrSelected' action='/ApplyasFilter/OrSelected'/>\n"
2304 "       <menuitem name='AndNotSelected' action='/ApplyasFilter/AndNotSelected'/>\n"
2305 "       <menuitem name='OrNotSelected' action='/ApplyasFilter/OrNotSelected'/>\n"
2306 "     </menu>\n"
2307 "     <menu name= 'PrepareaFilter' action='/PrepareaFilter'>\n"
2308 "       <menuitem name='Selected' action='/PrepareaFilter/Selected'/>\n"
2309 "       <menuitem name='NotSelected' action='/PrepareaFilter/Not Selected'/>\n"
2310 "       <menuitem name='AndSelected' action='/PrepareaFilter/AndSelected'/>\n"
2311 "       <menuitem name='OrSelected' action='/PrepareaFilter/OrSelected'/>\n"
2312 "       <menuitem name='AndNotSelected' action='/PrepareaFilter/AndNotSelected'/>\n"
2313 "       <menuitem name='OrNotSelected' action='/PrepareaFilter/OrNotSelected'/>\n"
2314 "     </menu>\n"
2315 "     <menu name= 'ColorizewithFilter' action='/Colorize with Filter'>\n"
2316 "       <menuitem name='Color1' action='/Colorize with Filter/Color 1'/>\n"
2317 "       <menuitem name='Color2' action='/Colorize with Filter/Color 2'/>\n"
2318 "       <menuitem name='Color3' action='/Colorize with Filter/Color 3'/>\n"
2319 "       <menuitem name='Color4' action='/Colorize with Filter/Color 4'/>\n"
2320 "       <menuitem name='Color5' action='/Colorize with Filter/Color 5'/>\n"
2321 "       <menuitem name='Color6' action='/Colorize with Filter/Color 6'/>\n"
2322 "       <menuitem name='Color7' action='/Colorize with Filter/Color 7'/>\n"
2323 "       <menuitem name='Color8' action='/Colorize with Filter/Color 8'/>\n"
2324 "       <menuitem name='Color9' action='/Colorize with Filter/Color 9'/>\n"
2325 "       <menuitem name='Color10' action='/Colorize with Filter/Color 10'/>\n"
2326 "       <menuitem name='NewColoringRule' action='/Colorize with Filter/New Coloring Rule'/>\n"
2327 "     </menu>\n"
2328 "     <menuitem name='FollowTCPStream' action='/Follow TCP Stream'/>\n"
2329 "     <menuitem name='FollowUDPStream' action='/Follow UDP Stream'/>\n"
2330 "     <menuitem name='FollowSSLStream' action='/Follow SSL Stream'/>\n"
2331 "     <menuitem name='FollowHTTPStream' action='/Follow HTTP Stream'/>\n"
2332 "     <separator/>\n"
2333 "     <menu name= 'Copy' action='/Copy'>\n"
2334 "        <menuitem name='Description' action='/Copy/Description'/>\n"
2335 "        <menuitem name='Fieldname' action='/Copy/Fieldname'/>\n"
2336 "        <menuitem name='Value' action='/Copy/Value'/>\n"
2337 "        <separator/>\n"
2338 "        <menuitem name='AsFilter' action='/Copy/AsFilter'/>\n"
2339 "        <separator/>\n"
2340 "        <menu name= 'Bytes' action='/Copy/Bytes'>\n"
2341 "           <menuitem name='OffsetHexText' action='/Copy/Bytes/OffsetHexText'/>\n"
2342 "           <menuitem name='OffsetHex' action='/Copy/Bytes/OffsetHex'/>\n"
2343 "           <menuitem name='PrintableTextOnly' action='/Copy/Bytes/PrintableTextOnly'/>\n"
2344 "           <separator/>\n"
2345 "           <menuitem name='HexStream' action='/Copy/Bytes/HexStream'/>\n"
2346 "           <menuitem name='BinaryStream' action='/Copy/Bytes/BinaryStream'/>\n"
2347 "        </menu>\n"
2348 "     </menu>\n"
2349 "     <menuitem name='ExportSelectedPacketBytes' action='/ExportSelectedPacketBytes'/>\n"
2350 #ifdef WANT_PACKET_EDITOR
2351 "     <menuitem name='EditPacket' action='/Edit/EditPacket'/>\n"
2352 #endif
2353 "     <separator/>\n"
2354 "     <menuitem name='WikiProtocolPage' action='/WikiProtocolPage'/>\n"
2355 "     <menuitem name='FilterFieldReference' action='/FilterFieldReference'/>\n"
2356 "     <menuitem name='ProtocolHelp' action='/ProtocolHelp'/>\n"
2357 "     <menuitem name='ProtocolPreferences' action='/ProtocolPreferences'/>\n"
2358 "     <separator/>\n"
2359 "     <menuitem name='DecodeAs' action='/DecodeAs'/>\n"
2360 "     <menuitem name='DisableProtocol' action='/DisableProtocol'/>\n"
2361 "     <menuitem name='ResolveName' action='/ResolveName'/>\n"
2362 "     <menuitem name='GotoCorrespondingPacket' action='/GotoCorrespondingPacket'/>\n"
2363 "     <menuitem name='ShowPacketRefinNewWindow' action='/ShowPacketRefinNewWindow'/>\n"
2364 "  </popup>\n"
2365 "</ui>\n";
2366
2367 static const GtkActionEntry tree_view_menu_popup_action_entries[] = {
2368   { "/ExpandSubtrees",                  NULL,                           "Expand Subtrees",         NULL,                   NULL,           G_CALLBACK(expand_tree_cb) },
2369   { "/CollapseSubtrees",                NULL,                           "Collapse Subtrees",       NULL,                   NULL,           G_CALLBACK(collapse_tree_cb) },
2370   { "/ExpandAll",                       NULL,                           "Expand All",              NULL,                   NULL,           G_CALLBACK(expand_all_cb) },
2371   { "/CollapseAll",                     NULL,                           "Collapse All",            NULL,                   NULL,           G_CALLBACK(collapse_all_cb) },
2372   { "/Apply as Column",                 NULL,                           "Apply as Column",         NULL,                   NULL,           G_CALLBACK(apply_as_custom_column_cb) },
2373
2374   { "/Colorize with Filter",            NULL, "Colorize with Filter",   NULL, NULL, NULL },
2375   { "/Colorize with Filter/Color 1",        WIRESHARK_STOCK_COLOR1, "Color 1",                  NULL, NULL, G_CALLBACK(tree_view_menu_color_with_flt_color1_cb) },
2376   { "/Colorize with Filter/Color 2",        WIRESHARK_STOCK_COLOR2, "Color 2",                  NULL, NULL, G_CALLBACK(tree_view_menu_color_with_flt_color2_cb) },
2377   { "/Colorize with Filter/Color 3",        WIRESHARK_STOCK_COLOR3, "Color 3",                  NULL, NULL, G_CALLBACK(tree_view_menu_color_with_flt_color3_cb) },
2378   { "/Colorize with Filter/Color 4",        WIRESHARK_STOCK_COLOR4, "Color 4",                  NULL, NULL, G_CALLBACK(tree_view_menu_color_with_flt_color4_cb) },
2379   { "/Colorize with Filter/Color 5",        WIRESHARK_STOCK_COLOR5, "Color 5",                  NULL, NULL, G_CALLBACK(tree_view_menu_color_with_flt_color5_cb) },
2380   { "/Colorize with Filter/Color 6",        WIRESHARK_STOCK_COLOR6, "Color 6",                  NULL, NULL, G_CALLBACK(tree_view_menu_color_with_flt_color6_cb) },
2381   { "/Colorize with Filter/Color 7",        WIRESHARK_STOCK_COLOR7, "Color 7",                  NULL, NULL, G_CALLBACK(tree_view_menu_color_with_flt_color7_cb) },
2382   { "/Colorize with Filter/Color 8",        WIRESHARK_STOCK_COLOR8, "Color 8",                  NULL, NULL, G_CALLBACK(tree_view_menu_color_with_flt_color8_cb) },
2383   { "/Colorize with Filter/Color 9",        WIRESHARK_STOCK_COLOR9, "Color 9",                  NULL, NULL, G_CALLBACK(tree_view_menu_color_with_flt_color9_cb) },
2384   { "/Colorize with Filter/Color 10",       WIRESHARK_STOCK_COLOR0, "Color 10",                 NULL, NULL, G_CALLBACK(tree_view_menu_color_with_flt_color10_cb) },
2385   { "/Colorize with Filter/New Coloring Rule",  NULL,       "New Coloring Rule...",             NULL, NULL, G_CALLBACK(tree_view_menu_color_with_flt_new_rule_cb) },
2386
2387   { "/Follow TCP Stream",                           NULL,       "Follow TCP Stream",                    NULL, NULL, G_CALLBACK(follow_tcp_stream_cb) },
2388   { "/Follow UDP Stream",                           NULL,       "Follow UDP Stream",                    NULL, NULL, G_CALLBACK(follow_udp_stream_cb) },
2389   { "/Follow SSL Stream",                           NULL,       "Follow SSL Stream",                    NULL, NULL, G_CALLBACK(follow_ssl_stream_cb) },
2390   { "/Follow HTTP Stream",                          NULL,       "Follow HTTP Stream",                   NULL, NULL, G_CALLBACK(follow_http_stream_cb) },
2391
2392   { "/Copy",        NULL, "Copy",                   NULL, NULL, NULL },
2393   { "/Copy/Description",                            NULL,       "Description",                      NULL, NULL, G_CALLBACK(tree_view_menu_copy_desc) },
2394   { "/Copy/Fieldname",                              NULL,       "Fieldname",                        NULL, NULL, G_CALLBACK(tree_view_menu_copy_field) },
2395   { "/Copy/Value",                                  NULL,       "Value",                            NULL, NULL, G_CALLBACK(tree_view_menu_copy_value) },
2396
2397   { "/Copy/AsFilter",                               NULL,       "As Filter",                        NULL, NULL, G_CALLBACK(tree_view_menu_copy_as_flt) },
2398
2399   { "/Copy/Bytes",                                  NULL,       "Bytes",                                NULL, NULL, NULL },
2400   { "/Copy/Bytes/OffsetHexText",                    NULL,       "Offset Hex Text",                      NULL, NULL, G_CALLBACK(packet_list_menu_copy_bytes_oht_cb) },
2401   { "/Copy/Bytes/OffsetHex",                        NULL,       "Offset Hex",                           NULL, NULL, G_CALLBACK(packet_list_menu_copy_bytes_oh_cb) },
2402   { "/Copy/Bytes/PrintableTextOnly",                NULL,       "Printable Text Only",                  NULL, NULL, G_CALLBACK(packet_list_menu_copy_bytes_text_cb) },
2403
2404   { "/Copy/Bytes/HexStream",                        NULL,       "Hex Stream",                           NULL, NULL, G_CALLBACK(packet_list_menu_copy_bytes_hex_strm_cb) },
2405   { "/Copy/Bytes/BinaryStream",                     NULL,       "Binary Stream",                        NULL, NULL, G_CALLBACK(packet_list_menu_copy_bytes_bin_strm_cb) },
2406
2407   { "/ExportSelectedPacketBytes",                   NULL,       "Export Selected Packet Bytes...",      NULL, NULL, G_CALLBACK(savehex_cb) },
2408 #ifdef WANT_PACKET_EDITOR
2409   { "/Edit/EditPacket",                NULL,               "_Edit Packet",                         NULL,                       NULL,           G_CALLBACK(edit_window_cb) },
2410 #endif
2411   { "/WikiProtocolPage",            WIRESHARK_STOCK_WIKI,       "Wiki Protocol Page",                   NULL, NULL, G_CALLBACK(selected_ptree_info_cb) },
2412   { "/FilterFieldReference",    WIRESHARK_STOCK_INTERNET,       "Filter Field Reference",               NULL, NULL, G_CALLBACK(selected_ptree_ref_cb) },
2413   { "/ProtocolHelp",                                NULL,       "Protocol Help",                        NULL, NULL, NULL },
2414   { "/ProtocolPreferences",                         NULL,       "Protocol Preferences",                 NULL, NULL, NULL },
2415   { "/DecodeAs",                WIRESHARK_STOCK_DECODE_AS,      "Decode As...",                         NULL, NULL, G_CALLBACK(decode_as_cb) },
2416   { "/DisableProtocol",         WIRESHARK_STOCK_CHECKBOX,       "Disable Protocol...",                  NULL, NULL, G_CALLBACK(proto_disable_cb) },
2417   { "/ResolveName",                                 NULL,       "_Resolve Name",                        NULL, NULL, G_CALLBACK(resolve_name_cb) },
2418   { "/GotoCorrespondingPacket",                     NULL,       "_Go to Corresponding Packet",          NULL, NULL, G_CALLBACK(goto_framenum_cb) },
2419   { "/ShowPacketRefinNewWindow",                    NULL,       "Show Packet Reference in New Window",  NULL, NULL, G_CALLBACK(new_window_cb_ref) },
2420 };
2421
2422 static const char *ui_desc_bytes_menu_popup =
2423 "<ui>\n"
2424 "  <popup name='BytesMenuPopup' action='PopupAction'>\n"
2425 "     <menuitem name='HexView' action='/HexView'/>\n"
2426 "     <menuitem name='BitsView' action='/BitsView'/>\n"
2427 "  </popup>\n"
2428 "</ui>\n";
2429
2430 static const GtkRadioActionEntry bytes_menu_radio_action_entries [] =
2431 {
2432     /* name,    stock id,        label,      accel,  tooltip,  value */
2433     { "/HexView",   NULL,       "Hex View",   NULL,   NULL,     BYTES_HEX },
2434     { "/BitsView",  NULL,       "Bits View",  NULL,   NULL,     BYTES_BITS },
2435 };
2436
2437 static const char *ui_statusbar_profiles_menu_popup =
2438 "<ui>\n"
2439 "  <popup name='ProfilesMenuPopup' action='PopupAction'>\n"
2440 "     <menuitem name='Profiles' action='/Profiles'/>\n"
2441 "     <separator/>\n"
2442 "     <menuitem name='New' action='/New'/>\n"
2443 "     <menuitem name='Rename' action='/Rename'/>\n"
2444 "     <menuitem name='Delete' action='/Delete'/>\n"
2445 "     <separator/>\n"
2446 "     <menu name='Change' action='/Change'>\n"
2447 "        <menuitem name='Default' action='/Change/Default'/>\n"
2448 "     </menu>\n"
2449 "  </popup>\n"
2450 "</ui>\n";
2451 static const GtkActionEntry statusbar_profiles_menu_action_entries [] =
2452 {
2453     { "/Profiles",       GTK_STOCK_INDEX,   "Manage Profiles...", NULL, NULL, G_CALLBACK(profile_dialog_cb) },
2454     { "/New",            GTK_STOCK_NEW,     "New...",             NULL, NULL, G_CALLBACK(profile_new_cb) },
2455     { "/Rename",         GTK_STOCK_EDIT,    "Rename...",          NULL, NULL, G_CALLBACK(profile_rename_cb) },
2456     { "/Delete",         GTK_STOCK_DELETE,  "Delete",             NULL, NULL, G_CALLBACK(profile_delete_cb) },
2457     { "/Change",         GTK_STOCK_JUMP_TO, "Switch to",          NULL, NULL, NULL },
2458     { "/Change/Default", NULL,              "Default",            NULL, NULL, NULL },
2459 };
2460
2461 GtkWidget *
2462 main_menu_new(GtkAccelGroup ** table)
2463 {
2464     GtkWidget *menubar;
2465 #ifdef HAVE_IGE_MAC_INTEGRATION
2466     GtkWidget *quit_item, *about_item, *preferences_item;
2467     IgeMacMenuGroup *group;
2468 #endif
2469 #ifdef HAVE_GTKOSXAPPLICATION
2470     GtkosxApplication *theApp;
2471     GtkWidget * item;
2472     GtkWidget * dock_menu;
2473 #endif
2474
2475     grp = gtk_accel_group_new();
2476
2477     if (initialize)
2478         menus_init();
2479
2480     menubar = gtk_ui_manager_get_widget(ui_manager_main_menubar, "/Menubar");
2481 #ifdef HAVE_IGE_MAC_INTEGRATION
2482     if(prefs.gui_macosx_style) {
2483         ige_mac_menu_set_menu_bar(GTK_MENU_SHELL(menubar));
2484         ige_mac_menu_set_global_key_handler_enabled(TRUE);
2485
2486         /* Create menu items to populate the application menu with.  We have to
2487          * do this because we are still using the old GtkItemFactory API for
2488          * the main menu. */
2489         group = ige_mac_menu_add_app_menu_group();
2490         about_item = gtk_menu_item_new_with_label("About");
2491         g_signal_connect(about_item, "activate", G_CALLBACK(about_wireshark_cb),
2492                          NULL);
2493         ige_mac_menu_add_app_menu_item(group, GTK_MENU_ITEM(about_item), NULL);
2494
2495         group = ige_mac_menu_add_app_menu_group();
2496         preferences_item = gtk_menu_item_new_with_label("Preferences");
2497         g_signal_connect(preferences_item, "activate", G_CALLBACK(prefs_cb),
2498                          NULL);
2499         ige_mac_menu_add_app_menu_item(group, GTK_MENU_ITEM(preferences_item),
2500                                        NULL);
2501     }
2502
2503     /* The quit item in the application menu shows up whenever ige mac
2504      * integration is enabled, even if the OS X UI style in Wireshark isn't
2505      * turned on. */
2506     quit_item = gtk_menu_item_new_with_label("Quit");
2507     g_signal_connect(quit_item, "activate", G_CALLBACK(file_quit_cmd_cb), NULL);
2508     ige_mac_menu_set_quit_menu_item(GTK_MENU_ITEM(quit_item));
2509 #endif
2510
2511 #ifdef HAVE_GTKOSXAPPLICATION
2512     theApp = (GtkosxApplication *)g_object_new(GTKOSX_TYPE_APPLICATION, NULL);
2513
2514     if(prefs.gui_macosx_style) {
2515         gtk_widget_hide(menubar);
2516
2517         gtkosx_application_set_menu_bar(theApp, GTK_MENU_SHELL(menubar));
2518         gtkosx_application_set_use_quartz_accelerators(theApp, TRUE);
2519
2520         /* Construct a conventional looking OSX App menu */
2521
2522         item = gtk_ui_manager_get_widget(ui_manager_main_menubar, "/Menubar/HelpMenu/AboutWireshark");
2523         gtkosx_application_insert_app_menu_item(theApp, item, 0);
2524
2525         gtkosx_application_insert_app_menu_item(theApp, gtk_separator_menu_item_new(), 1);
2526
2527         item = gtk_ui_manager_get_widget(ui_manager_main_menubar, "/Menubar/EditMenu/Preferences");
2528         gtkosx_application_insert_app_menu_item(theApp, item, 2);
2529
2530         /* Set OSX help menu */
2531
2532         item = gtk_ui_manager_get_widget(ui_manager_main_menubar, "/Menubar/HelpMenu");
2533         gtkosx_application_set_help_menu(theApp,GTK_MENU_ITEM(item));
2534
2535         /* Hide the File menu Quit item (a Quit item is automagically placed within the OSX App menu) */
2536
2537         item = gtk_ui_manager_get_widget(ui_manager_main_menubar, "/Menubar/FileMenu/Quit");
2538         gtk_widget_hide(item);
2539     }
2540
2541     /* generate dock menu */
2542     dock_menu = gtk_menu_new();
2543
2544     item = gtk_menu_item_new_with_label("Start");
2545     g_signal_connect(item, "activate", G_CALLBACK (capture_start_cb), NULL);
2546     gtk_menu_shell_append(GTK_MENU_SHELL(dock_menu), item);
2547
2548     item = gtk_menu_item_new_with_label("Stop");
2549     g_signal_connect(item, "activate", G_CALLBACK (capture_stop_cb), NULL);
2550     gtk_menu_shell_append(GTK_MENU_SHELL(dock_menu), item);
2551
2552     item = gtk_menu_item_new_with_label("Restart");
2553     g_signal_connect(item, "activate", G_CALLBACK (capture_restart_cb), NULL);
2554     gtk_menu_shell_append(GTK_MENU_SHELL(dock_menu), item);
2555
2556     gtkosx_application_set_dock_menu(theApp, GTK_MENU_SHELL(dock_menu));
2557 #endif
2558
2559     if (table)
2560         *table = grp;
2561
2562     plugin_if_register_gui_cb(PLUGIN_IF_PREFERENCE_SAVE, plugin_if_menubar_preference);
2563
2564     return menubar;
2565 }
2566
2567 static void
2568 menu_dissector_filter_cb(GtkAction *action _U_,  gpointer callback_data)
2569 {
2570     conversation_filter_t  *filter_entry = (conversation_filter_t *)callback_data;
2571     GtkWidget               *filter_te;
2572     const char              *buf;
2573
2574     filter_te = gtk_bin_get_child(GTK_BIN(g_object_get_data(G_OBJECT(top_level), E_DFILTER_CM_KEY)));
2575
2576     /* XXX - this gets the packet_info of the last dissected packet, */
2577     /* which is not necessarily the last selected packet */
2578     /* e.g. "Update list of packets in real time" won't work correct */
2579     buf = filter_entry->build_filter_string(&cfile.edt->pi);
2580
2581     gtk_entry_set_text(GTK_ENTRY(filter_te), buf);
2582
2583     /* Run the display filter so it goes in effect - even if it's the
2584        same as the previous display filter. */
2585     main_filter_packets(&cfile, buf, TRUE);
2586
2587     g_free( (void *) buf);
2588 }
2589
2590 static gboolean
2591 menu_dissector_filter_spe_cb(frame_data *fd _U_, epan_dissect_t *edt, gpointer callback_data)
2592 {
2593     conversation_filter_t *filter_entry = (conversation_filter_t*)callback_data;
2594
2595     /* XXX - this gets the packet_info of the last dissected packet, */
2596     /* which is not necessarily the last selected packet */
2597     /* e.g. "Update list of packets in real time" won't work correct */
2598     return (edt != NULL) ? filter_entry->is_filter_valid(&edt->pi) : FALSE;
2599 }
2600
2601 static void
2602 menu_dissector_filter(capture_file *cf)
2603 {
2604     GList *list_entry = conv_filter_list;
2605     conversation_filter_t *filter_entry;
2606
2607     guint merge_id;
2608     GtkActionGroup *action_group;
2609     GtkAction *action;
2610     GtkWidget *submenu_dissector_filters;
2611     gchar *action_name;
2612     guint i = 0;
2613
2614
2615     merge_id = gtk_ui_manager_new_merge_id (ui_manager_main_menubar);
2616
2617     action_group = gtk_action_group_new ("dissector-filters-group");
2618
2619     submenu_dissector_filters = gtk_ui_manager_get_widget(ui_manager_main_menubar, "/Menubar/AnalyzeMenu/ConversationFilterMenu");
2620     if(!submenu_dissector_filters){
2621         g_warning("menu_dissector_filter: No submenu_dissector_filters found, path= /Menubar/AnalyzeMenu/ConversationFilterMenu");
2622     }
2623
2624     gtk_ui_manager_insert_action_group (ui_manager_main_menubar, action_group, 0);
2625     g_object_set_data (G_OBJECT (ui_manager_main_menubar),
2626                      "dissector-filters-merge-id", GUINT_TO_POINTER (merge_id));
2627
2628     /* no items */
2629     if (!list_entry){
2630
2631       action = (GtkAction *)g_object_new (GTK_TYPE_ACTION,
2632                  "name", "filter-list-empty",
2633                  "label", "No filters",
2634                  "sensitive", FALSE,
2635                  NULL);
2636       gtk_action_group_add_action (action_group, action);
2637       gtk_action_set_sensitive(action, FALSE);
2638       g_object_unref (action);
2639
2640       gtk_ui_manager_add_ui (ui_manager_main_menubar, merge_id,
2641                  "/Menubar/AnalyzeMenu/ConversationFilterMenu/Filters",
2642                  "filter-list-empty",
2643                  "filter-list-empty",
2644                  GTK_UI_MANAGER_MENUITEM,
2645                  FALSE);
2646
2647       return;
2648     }
2649
2650     while (list_entry != NULL) {
2651         filter_entry = (conversation_filter_t *)list_entry->data;
2652         action_name = g_strdup_printf ("filter-%u", i);
2653         /*g_warning("action_name %s, filter_entry->name %s",action_name,filter_entry->name);*/
2654         action = (GtkAction *)g_object_new (GTK_TYPE_ACTION,
2655                  "name", action_name,
2656                  "label", filter_entry->display_name,
2657                  "sensitive", menu_dissector_filter_spe_cb(/* frame_data *fd _U_*/ NULL, cf->edt, filter_entry),
2658                  NULL);
2659         g_signal_connect (action, "activate",
2660                         G_CALLBACK (menu_dissector_filter_cb), filter_entry);
2661         gtk_action_group_add_action (action_group, action);
2662         g_object_unref (action);
2663
2664         gtk_ui_manager_add_ui (ui_manager_main_menubar, merge_id,
2665                  "/Menubar/AnalyzeMenu/ConversationFilterMenu/Filters",
2666                  action_name,
2667                  action_name,
2668                  GTK_UI_MANAGER_MENUITEM,
2669                  FALSE);
2670         g_free(action_name);
2671         i++;
2672         list_entry = g_list_next(list_entry);
2673     }
2674 }
2675
2676 static void
2677 menu_endpoints_cb(GtkAction *action _U_, gpointer user_data)
2678 {
2679     register_ct_t *table = (register_ct_t*)user_data;
2680
2681     conversation_endpoint_cb(table);
2682 }
2683
2684 typedef struct {
2685     capture_file *cf;
2686     guint merge_id;
2687     GtkActionGroup *action_group;
2688     int counter;
2689 } conv_menu_t;
2690
2691 static void
2692 add_conversation_menuitem(gpointer data, gpointer user_data)
2693 {
2694     register_ct_t *table = (register_ct_t*)data;
2695     conv_menu_t *conv = (conv_menu_t*)user_data;
2696     gchar *action_name;
2697     GtkAction *action;
2698
2699     action_name = g_strdup_printf ("conversation-%u", conv->counter);
2700     /*g_warning("action_name %s, filter_entry->name %s",action_name,filter_entry->name);*/
2701     action = (GtkAction *)g_object_new (GTK_TYPE_ACTION,
2702                 "name", action_name,
2703                 "label", proto_get_protocol_short_name(find_protocol_by_id(get_conversation_proto_id(table))),
2704                 "sensitive", TRUE,
2705                 NULL);
2706     g_signal_connect (action, "activate",
2707                     G_CALLBACK (menu_endpoints_cb), table);
2708     gtk_action_group_add_action (conv->action_group, action);
2709     g_object_unref (action);
2710
2711     gtk_ui_manager_add_ui (ui_manager_main_menubar, conv->merge_id,
2712                 "/Menubar/StatisticsMenu/ConversationListMenu/Conversations",
2713                 action_name,
2714                 action_name,
2715                 GTK_UI_MANAGER_MENUITEM,
2716                 FALSE);
2717     g_free(action_name);
2718     conv->counter++;
2719 }
2720
2721 static void
2722 menu_conversation_list(capture_file *cf)
2723 {
2724     GtkWidget *submenu_conversation_list;
2725     conv_menu_t conv_data;
2726
2727     conv_data.merge_id = gtk_ui_manager_new_merge_id (ui_manager_main_menubar);
2728
2729     conv_data.action_group = gtk_action_group_new ("conversation-list-group");
2730
2731     submenu_conversation_list = gtk_ui_manager_get_widget(ui_manager_main_menubar, "/Menubar/StatisticsMenu/ConversationListMenu");
2732     if(!submenu_conversation_list){
2733         g_warning("menu_conversation_list: No submenu_conversation_list found, path= /Menubar/StatisticsMenu/ConversationListMenu");
2734     }
2735
2736     gtk_ui_manager_insert_action_group (ui_manager_main_menubar, conv_data.action_group, 0);
2737     g_object_set_data (G_OBJECT (ui_manager_main_menubar),
2738                      "conversation-list-merge-id", GUINT_TO_POINTER (conv_data.merge_id));
2739
2740     conv_data.cf = cf;
2741     conv_data.counter = 0;
2742     conversation_table_iterate_tables(add_conversation_menuitem, &conv_data);
2743 }
2744
2745 static void
2746 menu_hostlist_cb(GtkAction *action _U_, gpointer user_data)
2747 {
2748     register_ct_t *table = (register_ct_t*)user_data;
2749
2750     hostlist_endpoint_cb(table);
2751 }
2752
2753 static void
2754 add_hostlist_menuitem(gpointer data, gpointer user_data)
2755 {
2756     register_ct_t *table = (register_ct_t*)data;
2757     conv_menu_t *conv = (conv_menu_t*)user_data;
2758     gchar *action_name;
2759     GtkAction *action;
2760
2761     action_name = g_strdup_printf ("hostlist-%u", conv->counter);
2762     /*g_warning("action_name %s, filter_entry->name %s",action_name,filter_entry->name);*/
2763     action = (GtkAction *)g_object_new (GTK_TYPE_ACTION,
2764                 "name", action_name,
2765                 "label", proto_get_protocol_short_name(find_protocol_by_id(get_conversation_proto_id(table))),
2766                 "sensitive", TRUE,
2767                 NULL);
2768     g_signal_connect (action, "activate",
2769                     G_CALLBACK (menu_hostlist_cb), table);
2770     gtk_action_group_add_action (conv->action_group, action);
2771     g_object_unref (action);
2772
2773     gtk_ui_manager_add_ui (ui_manager_main_menubar, conv->merge_id,
2774                 "/Menubar/StatisticsMenu/EndpointListMenu/Endpoints",
2775                 action_name,
2776                 action_name,
2777                 GTK_UI_MANAGER_MENUITEM,
2778                 FALSE);
2779     g_free(action_name);
2780     conv->counter++;
2781 }
2782
2783 static void
2784 menu_hostlist_list(capture_file *cf)
2785 {
2786     GtkWidget *submenu_hostlist;
2787     conv_menu_t conv_data;
2788
2789     conv_data.merge_id = gtk_ui_manager_new_merge_id (ui_manager_main_menubar);
2790
2791     conv_data.action_group = gtk_action_group_new ("endpoint-list-group");
2792
2793     submenu_hostlist = gtk_ui_manager_get_widget(ui_manager_main_menubar, "/Menubar/StatisticsMenu/EndpointListMenu");
2794     if(!submenu_hostlist){
2795         g_warning("menu_hostlist_list: No submenu_conversation_list found, path= /Menubar/StatisticsMenu/EndpointListMenu");
2796     }
2797
2798     gtk_ui_manager_insert_action_group (ui_manager_main_menubar, conv_data.action_group, 0);
2799     g_object_set_data (G_OBJECT (ui_manager_main_menubar),
2800                      "endpoint-list-merge-id", GUINT_TO_POINTER (conv_data.merge_id));
2801
2802     conv_data.cf = cf;
2803     conv_data.counter = 0;
2804     conversation_table_iterate_tables(add_hostlist_menuitem, &conv_data);
2805 }
2806
2807 typedef struct {
2808     guint merge_id;
2809     GtkActionGroup *action_group;
2810     int counter;
2811 } eo_menu_t;
2812
2813 static void
2814 menu_exportobject_cb(GtkAction *action _U_, gpointer user_data)
2815 {
2816     register_eo_t *eo = (register_eo_t*)user_data;
2817
2818     exportobject_cb(eo);
2819 }
2820
2821 static void
2822 add_export_object_menuitem(gpointer data, gpointer user_data)
2823 {
2824     register_eo_t *eo = (register_eo_t*)data;
2825     eo_menu_t *eo_menu_data = (eo_menu_t*)user_data;
2826     gchar *action_name;
2827     GtkAction *action;
2828
2829     action_name = g_strdup_printf ("exportobject-%u", eo_menu_data->counter);
2830     /*g_warning("action_name %s, filter_entry->name %s",action_name,filter_entry->name);*/
2831     action = (GtkAction *)g_object_new (GTK_TYPE_ACTION,
2832                 "name", action_name,
2833                 "label", proto_get_protocol_short_name(find_protocol_by_id(get_eo_proto_id(eo))),
2834                 "sensitive", TRUE,
2835                 NULL);
2836     g_signal_connect (action, "activate",
2837                     G_CALLBACK (menu_exportobject_cb), eo);
2838     gtk_action_group_add_action (eo_menu_data->action_group, action);
2839     g_object_unref (action);
2840
2841     gtk_ui_manager_add_ui (ui_manager_main_menubar, eo_menu_data->merge_id,
2842                 "/Menubar/FileMenu/ExportObjectsMenu/ExportObjects",
2843                 action_name,
2844                 action_name,
2845                 GTK_UI_MANAGER_MENUITEM,
2846                 FALSE);
2847     g_free(action_name);
2848     eo_menu_data->counter++;
2849 }
2850
2851 static void
2852 menu_export_object_list(void)
2853 {
2854     GtkWidget *submenu_export_object;
2855     eo_menu_t eo_data;
2856
2857     eo_data.merge_id = gtk_ui_manager_new_merge_id (ui_manager_main_menubar);
2858
2859     eo_data.action_group = gtk_action_group_new ("exportobject-list-group");
2860
2861     submenu_export_object = gtk_ui_manager_get_widget(ui_manager_main_menubar, "/Menubar/FileMenu/ExportObjectsMenu");
2862     if(!submenu_export_object){
2863         g_warning("menu_export_object_list: No submenu_exportobject_list found, path= /Menubar/FileMenu/ExportObjectsMenu");
2864     }
2865
2866     gtk_ui_manager_insert_action_group (ui_manager_main_menubar, eo_data.action_group, 0);
2867     g_object_set_data (G_OBJECT (ui_manager_main_menubar),
2868                      "exportobject-list-merge-id", GUINT_TO_POINTER (eo_data.merge_id));
2869
2870     eo_data.counter = 0;
2871     eo_iterate_tables(add_export_object_menuitem, &eo_data);
2872 }
2873
2874 static void
2875 menu_conversation_display_filter_cb(GtkAction *action _U_, gpointer data)
2876 {
2877     conversation_filter_t *filter_entry = (conversation_filter_t *)data;
2878
2879     gchar     *filter;
2880     GtkWidget *filter_te;
2881
2882     if (cfile.current_frame) {
2883         /* create a filter-string based on the selected packet and action */
2884         filter = filter_entry->build_filter_string(&cfile.edt->pi);
2885
2886         /* Run the display filter so it goes in effect - even if it's the
2887         same as the previous display filter. */
2888         filter_te = gtk_bin_get_child(GTK_BIN(g_object_get_data(G_OBJECT(top_level), E_DFILTER_CM_KEY)));
2889
2890         gtk_entry_set_text(GTK_ENTRY(filter_te), filter);
2891         main_filter_packets(&cfile, filter, TRUE);
2892
2893         g_free(filter);
2894     }
2895 }
2896
2897 static gboolean
2898 menu_color_dissector_filter_spe_cb(frame_data *fd _U_, epan_dissect_t *edt, gpointer callback_data)
2899 {
2900     conversation_filter_t *filter_entry = (conversation_filter_t *)callback_data;
2901
2902     /* XXX - this gets the packet_info of the last dissected packet, */
2903     /* which is not necessarily the last selected packet */
2904     /* e.g. "Update list of packets in real time" won't work correct */
2905     return (edt != NULL) ? filter_entry->is_filter_valid(&edt->pi) : FALSE;
2906 }
2907
2908 #define MAX_NUM_COLOR_CONVERSATION_COLORS       10
2909
2910 static void
2911 menu_color_conversation_filter(capture_file *cf)
2912 {
2913     GtkWidget *submenu_conv_filters, *submenu_color_conv_filters;
2914     guint merge_id, color_merge_id;
2915     GtkActionGroup *action_group, *color_action_group;
2916     GList *list_entry = conv_filter_list;
2917     conversation_filter_t* color_filter;
2918     int conv_counter = 0;
2919
2920     static packet_list_menu_color_conv_color_cb_t callbacks[MAX_NUM_COLOR_CONVERSATION_COLORS] = {
2921         packet_list_menu_color_conv_color1_cb,
2922         packet_list_menu_color_conv_color2_cb,
2923         packet_list_menu_color_conv_color3_cb,
2924         packet_list_menu_color_conv_color4_cb,
2925         packet_list_menu_color_conv_color5_cb,
2926         packet_list_menu_color_conv_color6_cb,
2927         packet_list_menu_color_conv_color7_cb,
2928         packet_list_menu_color_conv_color8_cb,
2929         packet_list_menu_color_conv_color9_cb,
2930         packet_list_menu_color_conv_color10_cb,
2931     };
2932
2933     static const gchar *icons[MAX_NUM_COLOR_CONVERSATION_COLORS] = {
2934         WIRESHARK_STOCK_COLOR1,
2935         WIRESHARK_STOCK_COLOR2,
2936         WIRESHARK_STOCK_COLOR3,
2937         WIRESHARK_STOCK_COLOR4,
2938         WIRESHARK_STOCK_COLOR5,
2939         WIRESHARK_STOCK_COLOR6,
2940         WIRESHARK_STOCK_COLOR7,
2941         WIRESHARK_STOCK_COLOR8,
2942         WIRESHARK_STOCK_COLOR9,
2943         WIRESHARK_STOCK_COLOR0,
2944     };
2945
2946     merge_id = gtk_ui_manager_new_merge_id (ui_manager_packet_list_menu);
2947     action_group = gtk_action_group_new ("popup-conversation-filters-group");
2948     color_merge_id = gtk_ui_manager_new_merge_id (ui_manager_packet_list_menu);
2949     color_action_group = gtk_action_group_new ("popup-conv-color-filters-group");
2950
2951     submenu_conv_filters = gtk_ui_manager_get_widget(ui_manager_packet_list_menu, "/PacketListMenuPopup/ConversationFilter");
2952     if(!submenu_conv_filters){
2953         g_warning("menu_color_conversation_filter: No submenu_conversation_filters found, path= /PacketListMenuPopup/ConversationFilter");
2954     }
2955
2956     submenu_color_conv_filters = gtk_ui_manager_get_widget(ui_manager_packet_list_menu, "/PacketListMenuPopup/ColorizeConversation");
2957     if(!submenu_color_conv_filters){
2958         g_warning("menu_color_conversation_filter: No submenu_color_conversation_filters found, path= /PacketListMenuPopup/ColorizeConversation");
2959     }
2960
2961     gtk_ui_manager_insert_action_group (ui_manager_packet_list_menu, action_group, 0);
2962     g_object_set_data (G_OBJECT (ui_manager_packet_list_menu),
2963                      "popup-conversation-filters-merge-id", GUINT_TO_POINTER (merge_id));
2964     gtk_ui_manager_insert_action_group (ui_manager_packet_list_menu, color_action_group, 0);
2965     g_object_set_data (G_OBJECT (ui_manager_packet_list_menu),
2966                      "popup-conv-color-filters-merge-id", GUINT_TO_POINTER (color_merge_id));
2967
2968     while (list_entry != NULL) {
2969         gchar *action_name, *color_num_path_name;
2970         GtkAction *action, *color_action;
2971         GtkWidget *color_conv_filter_menuitem, *color_conv_filter_submenu, *color_conv_widget;
2972
2973         color_filter = (conversation_filter_t*)list_entry->data;
2974
2975         /* Create conversation filter menu item for each registered protocol */
2976         action_name = g_strdup_printf ("color_conversation-%u", conv_counter);
2977         conv_counter++;
2978         action = (GtkAction *)g_object_new (GTK_TYPE_ACTION,
2979                  "name", action_name,
2980                  "label", color_filter->display_name,
2981                  "sensitive", menu_color_dissector_filter_spe_cb(NULL, cf->edt, color_filter),
2982                  NULL);
2983         g_signal_connect (action, "activate", G_CALLBACK (menu_conversation_display_filter_cb), color_filter);
2984         gtk_action_group_add_action (action_group, action);
2985         g_object_unref (action);
2986
2987         gtk_ui_manager_add_ui (ui_manager_packet_list_menu, merge_id,
2988                     "/PacketListMenuPopup/ConversationFilter/Conversations",
2989                     action_name,
2990                     action_name,
2991                     GTK_UI_MANAGER_MENUITEM,
2992                     FALSE);
2993         g_free(action_name);
2994
2995         /* Create color filter menu item for each registered protocol */
2996         color_action = (GtkAction *)g_object_new (GTK_TYPE_ACTION,
2997                  "name", color_filter->display_name,
2998                  "label", color_filter->display_name,
2999                  "sensitive", menu_color_dissector_filter_spe_cb(NULL, cf->edt, color_filter),
3000                  NULL);
3001         gtk_action_group_add_action (color_action_group, color_action);
3002         g_object_unref (color_action);
3003
3004         gtk_ui_manager_add_ui (ui_manager_packet_list_menu, color_merge_id,
3005                     "/PacketListMenuPopup/ColorizeConversation/Colorize",
3006                     color_filter->display_name,
3007                     color_filter->display_name,
3008                     GTK_UI_MANAGER_MENUITEM,
3009                     FALSE);
3010
3011
3012         /* Create each "numbered" color filter menu item for each registered protocol */
3013         color_num_path_name = g_strdup_printf ("/PacketListMenuPopup/ColorizeConversation/Colorize/%s", color_filter->display_name);
3014         color_conv_widget = gtk_ui_manager_get_widget(ui_manager_packet_list_menu, color_num_path_name);
3015         if (color_conv_widget != NULL) {
3016             guint i;
3017             gchar *color_num_name;
3018
3019             color_conv_filter_submenu = gtk_menu_new();
3020             for (i = 0; i < MAX_NUM_COLOR_CONVERSATION_COLORS; i++) {
3021                 color_num_name = g_strdup_printf ("Color %d", i+1);
3022                 color_conv_filter_menuitem = gtk_image_menu_item_new_with_label(color_num_name);
3023                 gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM(color_conv_filter_menuitem),
3024                                        ws_gtk_image_new_from_stock(icons[i], GTK_ICON_SIZE_MENU));
3025                 g_signal_connect(color_conv_filter_menuitem, "activate", G_CALLBACK(callbacks[i]), color_filter);
3026                 gtk_menu_shell_append(GTK_MENU_SHELL(color_conv_filter_submenu), color_conv_filter_menuitem);
3027
3028                 gtk_widget_show (color_conv_filter_menuitem);
3029                 g_free(color_num_name);
3030             }
3031
3032             /* Create New Coloring Rule... menu item */
3033             color_conv_filter_menuitem = gtk_menu_item_new_with_label("New Coloring Rule...");
3034             g_signal_connect(color_conv_filter_menuitem, "activate", G_CALLBACK(packet_list_menu_color_conv_new_rule_cb), color_filter);
3035             gtk_menu_shell_append(GTK_MENU_SHELL(color_conv_filter_submenu), color_conv_filter_menuitem);
3036             gtk_widget_show (color_conv_filter_menuitem);
3037
3038             gtk_menu_item_set_submenu (GTK_MENU_ITEM(color_conv_widget), color_conv_filter_submenu);
3039         } else {
3040             g_warning("menu_color_conversation_filter: No submenu_color_conv_filters found, path= %s", color_num_path_name);
3041         }
3042         g_free(color_num_path_name);
3043
3044         list_entry = g_list_next(list_entry);
3045     }
3046 }
3047
3048 static void
3049 menus_init(void)
3050 {
3051     GtkActionGroup *packet_list_heading_action_group, *packet_list_action_group,
3052         *packet_list_details_action_group, *packet_list_byte_menu_action_group,
3053         *statusbar_profiles_action_group;
3054     GtkAction *name_res_action;
3055     GError *error = NULL;
3056     guint merge_id;
3057
3058     if (initialize) {
3059         initialize = FALSE;
3060
3061         popup_menu_object = gtk_menu_new();
3062
3063         /* packet list heading pop-up menu */
3064         packet_list_heading_action_group = gtk_action_group_new ("PacketListHeadingPopUpMenuActionGroup");
3065
3066         gtk_action_group_add_actions (packet_list_heading_action_group,            /* the action group */
3067             packet_list_heading_menu_popup_action_entries,               /* an array of action descriptions */
3068             G_N_ELEMENTS(packet_list_heading_menu_popup_action_entries),           /* the number of entries */
3069             popup_menu_object);                                                    /* data to pass to the action callbacks */
3070
3071         gtk_action_group_add_toggle_actions(packet_list_heading_action_group,                     /* the action group */
3072                                     (GtkToggleActionEntry *)packet_list_heading_menu_toggle_action_entries,     /* an array of action descriptions */
3073                                     G_N_ELEMENTS(packet_list_heading_menu_toggle_action_entries), /* the number of entries */
3074                                     NULL);                                                        /* data to pass to the action callbacks */
3075
3076         ui_manager_packet_list_heading = gtk_ui_manager_new ();
3077         gtk_ui_manager_insert_action_group (ui_manager_packet_list_heading,
3078             packet_list_heading_action_group,
3079             0); /* the position at which the group will be inserted.  */
3080
3081         gtk_ui_manager_add_ui_from_string (ui_manager_packet_list_heading,ui_desc_packet_list_heading_menu_popup, -1, &error);
3082         if (error != NULL)
3083         {
3084             fprintf (stderr, "Warning: building Packet List Heading Pop-Up failed: %s\n",
3085                     error->message);
3086             g_error_free (error);
3087             error = NULL;
3088         }
3089
3090         g_object_set_data(G_OBJECT(popup_menu_object), PM_PACKET_LIST_COL_KEY,
3091                        gtk_ui_manager_get_widget(ui_manager_packet_list_heading, "/PacketListHeadingPopup"));
3092
3093         popup_menu_list = g_slist_append((GSList *)popup_menu_list, ui_manager_packet_list_heading);
3094
3095         /* packet list pop-up menu */
3096         packet_list_action_group = gtk_action_group_new ("PacketListPopUpMenuActionGroup");
3097
3098         gtk_action_group_add_actions (packet_list_action_group,                    /* the action group */
3099             (GtkActionEntry *)packet_list_menu_popup_action_entries,                       /* an array of action descriptions */
3100             G_N_ELEMENTS(packet_list_menu_popup_action_entries),                   /* the number of entries */
3101             popup_menu_object);                                                    /* data to pass to the action callbacks */
3102
3103         /* Add the filter menu items */
3104         gtk_action_group_add_actions (packet_list_action_group,                    /* the action group */
3105             (GtkActionEntry *)apply_prepare_filter_action_entries,                         /* an array of action descriptions */
3106             G_N_ELEMENTS(apply_prepare_filter_action_entries),                     /* the number of entries */
3107             popup_menu_object);                                                    /* data to pass to the action callbacks */
3108
3109         ui_manager_packet_list_menu = gtk_ui_manager_new ();
3110
3111         gtk_ui_manager_insert_action_group (ui_manager_packet_list_menu,
3112             packet_list_action_group,
3113             0); /* the position at which the group will be inserted.  */
3114
3115         gtk_ui_manager_add_ui_from_string (ui_manager_packet_list_menu, ui_desc_packet_list_menu_popup, -1, &error);
3116         if (error != NULL)
3117         {
3118             fprintf (stderr, "Warning: building Packet List Pop-Up menu failed: %s\n",
3119                     error->message);
3120             g_error_free (error);
3121             error = NULL;
3122         }
3123
3124         g_object_set_data(G_OBJECT(popup_menu_object), PM_PACKET_LIST_KEY,
3125                         gtk_ui_manager_get_widget(ui_manager_packet_list_menu, "/PacketListMenuPopup"));
3126
3127         popup_menu_list = g_slist_append((GSList *)popup_menu_list, ui_manager_packet_list_menu);
3128
3129         menu_color_conversation_filter(&cfile);
3130
3131         /* packet detail pop-up menu */
3132         packet_list_details_action_group = gtk_action_group_new ("PacketListDetailsMenuPopUpActionGroup");
3133
3134         gtk_action_group_add_actions (packet_list_details_action_group,            /* the action group */
3135             (GtkActionEntry *)tree_view_menu_popup_action_entries,                 /* an array of action descriptions */
3136             G_N_ELEMENTS(tree_view_menu_popup_action_entries),                     /* the number of entries */
3137             popup_menu_object);                                                    /* data to pass to the action callbacks */
3138
3139         /* Add the filter menu items */
3140         gtk_action_group_add_actions (packet_list_details_action_group,            /* the action group */
3141             (GtkActionEntry *)apply_prepare_filter_action_entries,                 /* an array of action descriptions */
3142             G_N_ELEMENTS(apply_prepare_filter_action_entries),                     /* the number of entries */
3143             popup_menu_object);                                                    /* data to pass to the action callbacks */
3144
3145
3146         ui_manager_tree_view_menu = gtk_ui_manager_new ();
3147
3148         gtk_ui_manager_insert_action_group (ui_manager_tree_view_menu,
3149             packet_list_details_action_group,
3150             0); /* the position at which the group will be inserted.  */
3151         gtk_ui_manager_add_ui_from_string (ui_manager_tree_view_menu, ui_desc_tree_view_menu_popup, -1, &error);
3152 #if 0
3153         /* If we want to load the treewiew popup UI description from file */
3154         gui_desc_file_name_and_path = get_ui_file_path("tree-view-ui.xml");
3155         gtk_ui_manager_add_ui_from_file ( ui_manager_tree_view_menu, gui_desc_file_name_and_path, &error);
3156         g_free (gui_desc_file_name_and_path);
3157 #endif
3158         if (error != NULL)
3159         {
3160             fprintf (stderr, "Warning: building TreeView Pop-Up menu failed: %s\n",
3161                     error->message);
3162             g_error_free (error);
3163             error = NULL;
3164         }
3165
3166         g_object_set_data(G_OBJECT(popup_menu_object), PM_TREE_VIEW_KEY,
3167                          gtk_ui_manager_get_widget(ui_manager_tree_view_menu, "/TreeViewPopup"));
3168
3169         popup_menu_list = g_slist_append((GSList *)popup_menu_list, ui_manager_tree_view_menu);
3170
3171         /*
3172          * Hex dump pop-up menu.
3173          * We provide our own empty menu to suppress the default pop-up menu
3174          * for text widgets.
3175          */
3176         packet_list_byte_menu_action_group = gtk_action_group_new ("PacketListByteMenuPopUpActionGroup");
3177
3178
3179         gtk_action_group_add_radio_actions  (packet_list_byte_menu_action_group,            /* the action group */
3180                                     (GtkRadioActionEntry *)bytes_menu_radio_action_entries, /* an array of radio action descriptions  */
3181                                     G_N_ELEMENTS(bytes_menu_radio_action_entries),          /* the number of entries */
3182                                     recent.gui_bytes_view,                                  /* the value of the action to activate initially, or -1 if no action should be activated  */
3183                                     G_CALLBACK(select_bytes_view_cb),                       /* the callback to connect to the changed signal  */
3184                                     popup_menu_object);                                     /* data to pass to the action callbacks  */
3185
3186         ui_manager_bytes_menu = gtk_ui_manager_new ();
3187
3188         gtk_ui_manager_insert_action_group (ui_manager_bytes_menu,
3189             packet_list_byte_menu_action_group,
3190             0); /* the position at which the group will be inserted.  */
3191         gtk_ui_manager_add_ui_from_string (ui_manager_bytes_menu, ui_desc_bytes_menu_popup, -1, &error);
3192 #if 0
3193         /* If we want to load the bytesview poupup UI description from file */
3194         gui_desc_file_name_and_path = get_ui_file_path("bytes-view-ui.xml");
3195         gtk_ui_manager_add_ui_from_file ( ui_manager_bytes_menu, gui_desc_file_name_and_path, &error);
3196         g_free (gui_desc_file_name_and_path);
3197 #endif
3198         if (error != NULL)
3199         {
3200             fprintf (stderr, "Warning: building Bytes Pop-Up menu failed: %s\n",
3201                     error->message);
3202             g_error_free (error);
3203             error = NULL;
3204         }
3205         g_object_unref(packet_list_byte_menu_action_group);
3206
3207         g_object_set_data(G_OBJECT(popup_menu_object), PM_BYTES_VIEW_KEY,
3208                         gtk_ui_manager_get_widget(ui_manager_bytes_menu, "/BytesMenuPopup"));
3209
3210         popup_menu_list = g_slist_append((GSList *)popup_menu_list, ui_manager_bytes_menu);
3211
3212         /* main */
3213         main_menu_bar_action_group = gtk_action_group_new ("MenuActionGroup");
3214
3215         gtk_action_group_add_actions (main_menu_bar_action_group,                       /* the action group */
3216                                     main_menu_bar_entries,                              /* an array of action descriptions */
3217                                     G_N_ELEMENTS(main_menu_bar_entries),                /* the number of entries */
3218                                     NULL);                                              /* data to pass to the action callbacks */
3219
3220 #ifdef HAVE_LIBPCAP
3221         /* Add the capture menu actions */
3222         gtk_action_group_add_actions (main_menu_bar_action_group,                       /* the action group */
3223                                     capture_menu_entries,                               /* an array of action descriptions */
3224                                     G_N_ELEMENTS(capture_menu_entries),                 /* the number of entries */
3225                                     NULL);                                              /* data to pass to the action callbacks */
3226 #endif
3227
3228         /* Add the filter menu actions */
3229         gtk_action_group_add_actions (main_menu_bar_action_group,                       /* the action group */
3230                                     (GtkActionEntry *)apply_prepare_filter_action_entries,      /* an array of action descriptions */
3231                                     G_N_ELEMENTS(apply_prepare_filter_action_entries),  /* the number of entries */
3232                                     popup_menu_object);                                 /* data to pass to the action callbacks */
3233
3234         gtk_action_group_add_toggle_actions(main_menu_bar_action_group,                 /* the action group */
3235                                     main_menu_bar_toggle_action_entries,                /* an array of action descriptions */
3236                                     G_N_ELEMENTS(main_menu_bar_toggle_action_entries),  /* the number of entries */
3237                                     NULL);                                              /* data to pass to the action callbacks */
3238
3239         if (global_dissect_options.time_format != TS_NOT_SET) {
3240             recent.gui_time_format = global_dissect_options.time_format;
3241         }
3242         gtk_action_group_add_radio_actions  (main_menu_bar_action_group,                 /* the action group */
3243                                     main_menu_bar_radio_view_time_entries,               /* an array of radio action descriptions  */
3244                                     G_N_ELEMENTS(main_menu_bar_radio_view_time_entries), /* the number of entries */
3245                                     recent.gui_time_format,                              /* the value of the action to activate initially, or -1 if no action should be activated  */
3246                                     G_CALLBACK(timestamp_format_new_cb),                 /* the callback to connect to the changed signal  */
3247                                     NULL);                                               /* data to pass to the action callbacks  */
3248
3249         gtk_action_group_add_radio_actions  (main_menu_bar_action_group,                                    /* the action group */
3250                                     main_menu_bar_radio_view_time_fileformat_prec_entries,                  /* an array of radio action descriptions  */
3251                                     G_N_ELEMENTS(main_menu_bar_radio_view_time_fileformat_prec_entries),    /* the number of entries */
3252                                     recent.gui_time_precision,                                /* the value of the action to activate initially, or -1 if no action should be activated  */
3253                                     G_CALLBACK(timestamp_precision_new_cb),                   /* the callback to connect to the changed signal  */
3254                                     NULL);                                                    /* data to pass to the action callbacks  */
3255
3256
3257
3258         ui_manager_main_menubar = gtk_ui_manager_new ();
3259         gtk_ui_manager_insert_action_group (ui_manager_main_menubar, main_menu_bar_action_group, 0);
3260
3261         gtk_ui_manager_add_ui_from_string (ui_manager_main_menubar,ui_desc_menubar, -1, &error);
3262         if (error != NULL)
3263         {
3264             fprintf (stderr, "Warning: building main menubar failed: %s\n",
3265                     error->message);
3266             g_error_free (error);
3267             error = NULL;
3268         }
3269         g_object_unref(main_menu_bar_action_group);
3270         gtk_window_add_accel_group (GTK_WINDOW(top_level),
3271                                 gtk_ui_manager_get_accel_group(ui_manager_main_menubar));
3272
3273
3274         /* Add the recent files items to the menu
3275          * use place holders and
3276          * gtk_ui_manager_add_ui().
3277          */
3278         merge_id = gtk_ui_manager_new_merge_id (ui_manager_main_menubar);
3279         add_recent_items (merge_id, ui_manager_main_menubar);
3280
3281         /* Add statistics tap plug-in to the menu
3282          */
3283         merge_id = gtk_ui_manager_new_merge_id (ui_manager_main_menubar);
3284         add_tap_plugins (merge_id, ui_manager_main_menubar);
3285
3286         statusbar_profiles_action_group = gtk_action_group_new ("StatusBarProfilesPopUpMenuActionGroup");
3287
3288         gtk_action_group_add_actions (statusbar_profiles_action_group,   /* the action group */
3289             (GtkActionEntry *)statusbar_profiles_menu_action_entries,    /* an array of action descriptions */
3290             G_N_ELEMENTS(statusbar_profiles_menu_action_entries),        /* the number of entries */
3291             popup_menu_object);                                          /* data to pass to the action callbacks */
3292
3293         ui_manager_statusbar_profiles_menu = gtk_ui_manager_new ();
3294         gtk_ui_manager_insert_action_group (ui_manager_statusbar_profiles_menu,
3295             statusbar_profiles_action_group,
3296             0); /* the position at which the group will be inserted.  */
3297
3298         gtk_ui_manager_add_ui_from_string (ui_manager_statusbar_profiles_menu,ui_statusbar_profiles_menu_popup, -1, &error);
3299         if (error != NULL)
3300         {
3301             fprintf (stderr, "Warning: building StatusBar Profiles Pop-Up failed: %s\n",
3302                     error->message);
3303             g_error_free (error);
3304             error = NULL;
3305         }
3306
3307         g_object_unref(statusbar_profiles_action_group);
3308
3309         g_object_set_data(G_OBJECT(popup_menu_object), PM_STATUSBAR_PROFILES_KEY,
3310                        gtk_ui_manager_get_widget(ui_manager_statusbar_profiles_menu, "/ProfilesMenuPopup"));
3311
3312         popup_menu_list = g_slist_append((GSList *)popup_menu_list, ui_manager_statusbar_profiles_menu);
3313
3314         menu_dissector_filter(&cfile);
3315         menu_conversation_list(&cfile);
3316         menu_hostlist_list(&cfile);
3317         menu_export_object_list();
3318
3319         /* Add additional entries which may have been introduced by dissectors and/or plugins */
3320         ws_menubar_external_menus();
3321
3322         merge_menu_items(merge_menu_items_list);
3323
3324         /* Add external menus and items */
3325         ws_menubar_build_external_menus();
3326
3327         /* Initialize enabled/disabled state of menu items */
3328         set_menus_for_capture_file(NULL);
3329 #if 0
3330         /* Un-#if this when we actually implement Cut/Copy/Paste.
3331            Then make sure you enable them when they can be done. */
3332         set_menu_sensitivity_old("/Edit/Cut", FALSE);
3333         set_menu_sensitivity_old("/Edit/Copy", FALSE);
3334         set_menu_sensitivity_old("/Edit/Paste", FALSE);
3335 #endif
3336        /* Hide not usable menus */
3337
3338         set_menus_for_captured_packets(FALSE);
3339         set_menus_for_selected_packet(&cfile);
3340         set_menus_for_selected_tree_row(&cfile);
3341         set_menus_for_capture_in_progress(FALSE);
3342         set_menus_for_file_set(/* dialog */TRUE, /* previous file */ FALSE, /* next_file */ FALSE);
3343
3344         /* Set callback to update name resolution settings when activated */
3345         name_res_action = gtk_action_group_get_action(main_menu_bar_action_group, "/View/NameResolution");
3346         g_signal_connect (name_res_action, "activate", G_CALLBACK (menu_name_resolution_update_cb), NULL);
3347     }
3348 }
3349
3350 /* Get a merge id for the menubar */
3351 void
3352 ws_add_build_menubar_items_callback(gpointer callback)
3353 {
3354      build_menubar_items_callback_list = g_list_append(build_menubar_items_callback_list, callback);
3355
3356 }
3357
3358 static void
3359 ws_menubar_build_external_menus(void)
3360 {
3361     void (*callback)(gpointer);
3362
3363     while (build_menubar_items_callback_list != NULL) {
3364         callback = (void (*)(gpointer))build_menubar_items_callback_list->data;
3365         callback(ui_manager_main_menubar);
3366         build_menubar_items_callback_list = g_list_next(build_menubar_items_callback_list);
3367     }
3368
3369
3370 }
3371
3372 typedef struct _menu_item {
3373     const char   *gui_path;
3374     const char   *name;
3375     const char   *stock_id;
3376     const char   *label;
3377     const char   *accelerator;
3378     const gchar  *tooltip;
3379     GCallback    callback;
3380     gpointer     callback_data;
3381     gboolean     enabled;
3382     gboolean (*selected_packet_enabled)(frame_data *, epan_dissect_t *, gpointer callback_data);
3383     gboolean (*selected_tree_row_enabled)(field_info *, gpointer callback_data);
3384 } menu_item_t;
3385
3386 static gint
3387 insert_sorted_by_label(gconstpointer aparam, gconstpointer bparam)
3388 {
3389     const menu_item_t *a = (menu_item_t *)aparam;
3390     const menu_item_t *b = (menu_item_t *)bparam;
3391
3392     return g_ascii_strcasecmp(a->label, b->label);
3393 }
3394
3395 void register_menu_bar_menu_items(
3396     const char   *gui_path,
3397     const char   *name,
3398     const gchar  *stock_id,
3399     const char   *label,
3400     const char   *accelerator,
3401     const gchar  *tooltip,
3402     gpointer     callback,
3403     gpointer     callback_data,
3404     gboolean     enabled,
3405     gboolean (*selected_packet_enabled)(frame_data *, epan_dissect_t *, gpointer callback_data),
3406     gboolean (*selected_tree_row_enabled)(field_info *, gpointer callback_data))
3407 {
3408     menu_item_t *menu_item_data;
3409
3410     menu_item_data                   = g_new0(menu_item_t,1);
3411     menu_item_data->gui_path         = gui_path;
3412     menu_item_data->name             = name;
3413     menu_item_data->label            = label;
3414     menu_item_data->stock_id         = stock_id;
3415     menu_item_data->accelerator      = accelerator;
3416     menu_item_data->tooltip          = tooltip;
3417     menu_item_data->callback         = (GCallback)callback;
3418     menu_item_data->callback_data    = callback_data;
3419     menu_item_data->enabled          = enabled;
3420     menu_item_data->selected_packet_enabled = selected_packet_enabled;
3421     menu_item_data->selected_tree_row_enabled = selected_tree_row_enabled;
3422
3423     merge_menu_items_list = g_list_insert_sorted(merge_menu_items_list,
3424                                                  menu_item_data,
3425                                                  insert_sorted_by_label);
3426 }
3427
3428 #define XMENU_MAX_DEPTH         (1 + 32)        /* max number of menus in an xpath (+1 for Menubar) */
3429
3430 static void
3431 add_menu_item_to_main_menubar(const gchar *path, const gchar *name, const menu_item_t *menu_item_data)
3432 {
3433     gchar           *xpath;
3434     GString         *item_path;
3435     guint            merge_id;
3436     char           **p;
3437     char           **tokens, **name_action_tokens;
3438     char            *tok, *item_name, *action_name;
3439     size_t           len;
3440     int              i;
3441     GtkAction       *action;
3442
3443     /* no need to specify menu bar...skip it */
3444     len = strlen("/Menubar");
3445     if (g_ascii_strncasecmp(path, "/Menubar", len) == 0) {
3446         path += len;
3447     }
3448
3449     xpath = g_strdup_printf("%s/%s", path, name);
3450     item_path = g_string_new("/Menubar");
3451
3452     merge_id = gtk_ui_manager_new_merge_id(ui_manager_main_menubar);
3453
3454     /*
3455      * The last item in the path is treated as the menu item; all preceding path
3456      * elements are the names of parent menus. Path elements are stripped of
3457      * leading/trailing spaces.
3458      *
3459      * |'s separate an existing menu's name from its action.
3460      * If the action has a / in it, it must have been "escaped" into a # before
3461      * entering this function; this function will translate it back to a /.
3462      * There must be an easier way!
3463      *
3464      * Examples:
3465      *
3466      *   "/Foo/Bar|/BarAction/I_tem" creates a hierarchy of:
3467      *
3468      *     A menu with an action of "Foo"
3469      *         A menu with a name of "Bar" and an action of "/BarAction"
3470      *             A menu item with an action of "I_tem", which puts
3471      *               the shortcut on "t".
3472      *
3473      *   "/Foo/Bar|BarAction/-/Baz|BarAction#BazAction/Item" creates
3474      *     a hierarchy of:
3475      *
3476      *     A menu with an action of "Foo"
3477      *         A menu with a name of "Bar" and an action of "/BarAction"
3478      *         A separator
3479      *             A menu with a name of "Baz" and an action of
3480      *               "BarAction/BazAction"
3481      *                 A menu item with an action of "Item"
3482      */
3483     tokens = g_strsplit(xpath, "/", XMENU_MAX_DEPTH);
3484     for (p = tokens; (p != NULL) && (*p != NULL); p++) {
3485         tok = g_strstrip(*p);
3486         if (g_strcmp0(tok, "-") == 0) {
3487             /* Just a separator. */
3488             gtk_ui_manager_add_ui(ui_manager_main_menubar, merge_id,
3489                                   item_path->str,
3490                                   NULL,
3491                                   NULL,
3492                                   GTK_UI_MANAGER_SEPARATOR,
3493                                   FALSE);
3494         } else {
3495             if (*(p+1) == NULL) {
3496                 /*
3497                  * This is the last token; it's the name of a menu item,
3498                  * not of a menu.
3499                  *
3500                  * Allow a blank menu item name or else the item is hidden
3501                  * (and thus useless). Showing a blank menu item allows the
3502                  * developer to see the problem and fix it.
3503                  */
3504                 item_name = tok;
3505                 action_name = g_strconcat("/", tok, NULL);
3506                 if (menu_item_data != NULL) {
3507                     action = (GtkAction *)g_object_new (
3508                             GTK_TYPE_ACTION,
3509                             "name", action_name,
3510                             "label", menu_item_data->label,
3511                             "stock-id", menu_item_data->stock_id,
3512                             "tooltip", menu_item_data->tooltip,
3513                             "sensitive", menu_item_data->enabled,
3514                             NULL
3515                     );
3516                     if (menu_item_data->callback != NULL) {
3517                         g_signal_connect (
3518                                 action,
3519                                 "activate",
3520                                 G_CALLBACK (menu_item_data->callback),
3521                                 menu_item_data->callback_data
3522                         );
3523                     }
3524                     gtk_action_group_add_action (main_menu_bar_action_group, action);
3525                     g_object_unref (action);
3526                 }
3527                 gtk_ui_manager_add_ui(ui_manager_main_menubar, merge_id,
3528                                       item_path->str,
3529                                       item_name,
3530                                       action_name,
3531                                       GTK_UI_MANAGER_MENUITEM,
3532                                       FALSE);
3533                 g_free(action_name);
3534             } else {
3535                 /*
3536                  * This is not the last token; it's the name of an
3537                  * intermediate menu.
3538                  *
3539                  * If it's empty, just skip it.
3540                  */
3541                 if (tok[0] == '\0')
3542                     continue;
3543
3544                 /* Split the name of the menu from its action (if any) */
3545                 name_action_tokens = g_strsplit(tok, "|", 2);
3546                 if (name_action_tokens[1]) {
3547                     i = -1;
3548                     /* Replace #'s with /'s.
3549                      * Necessary for menus whose action includes a "/".
3550                      * There MUST be an easier way...
3551                      */
3552                     while (name_action_tokens[1][++i])
3553                         if (name_action_tokens[1][i] == '#')
3554                             name_action_tokens[1][i] = '/';
3555                     item_name = name_action_tokens[0];
3556                     action_name = g_strconcat("/", name_action_tokens[1], NULL);
3557                 } else {
3558                     item_name = tok;
3559                     action_name = g_strconcat("/", tok, NULL);
3560                 }
3561
3562                 if (menu_item_data != NULL) {
3563                     /*
3564                      * Add an action for this menu if it doesn't already
3565                      * exist.
3566                      */
3567                     if (gtk_action_group_get_action(main_menu_bar_action_group, action_name) == NULL) {
3568                         action = (GtkAction *)g_object_new (
3569                                 GTK_TYPE_ACTION,
3570                                 "name", action_name,
3571                                 "label", item_name,
3572                                 NULL
3573                         );
3574                         gtk_action_group_add_action (main_menu_bar_action_group, action);
3575                         g_object_unref (action);
3576                     }
3577                 }
3578                 gtk_ui_manager_add_ui(ui_manager_main_menubar, merge_id,
3579                                       item_path->str,
3580                                       item_name,
3581                                       action_name,
3582                                       GTK_UI_MANAGER_MENU,
3583                                       FALSE);
3584                 g_free(action_name);
3585
3586                 g_string_append_printf(item_path, "/%s", item_name);
3587                 g_strfreev(name_action_tokens);
3588             }
3589         }
3590     }
3591
3592     /* we're finished processing the tokens so free the list */
3593     g_strfreev(tokens);
3594
3595     g_string_free(item_path, TRUE);
3596     g_free(xpath);
3597 }
3598
3599 static void
3600 merge_menu_items(GList *lcl_merge_menu_items_list)
3601 {
3602     menu_item_t    *menu_item_data;
3603
3604     while (lcl_merge_menu_items_list != NULL) {
3605         menu_item_data = (menu_item_t *)lcl_merge_menu_items_list->data;
3606         add_menu_item_to_main_menubar(menu_item_data->gui_path, menu_item_data->name, menu_item_data);
3607         lcl_merge_menu_items_list = g_list_next(lcl_merge_menu_items_list);
3608     }
3609 }
3610
3611 const char *
3612 stat_group_name(register_stat_group_t group)
3613 {
3614     /* See add_menu_item_to_main_menubar() for an explanation of the string format */
3615     static const value_string group_name_vals[] = {
3616         {REGISTER_ANALYZE_GROUP_UNSORTED,            "/Menubar/AnalyzeMenu|Analyze"},                                                              /* unsorted analyze stuff */
3617         {REGISTER_ANALYZE_GROUP_CONVERSATION_FILTER, "/Menubar/AnalyzeMenu|Analyze/ConversationFilterMenu|Analyze#ConversationFilter"},            /* conversation filters */
3618         {REGISTER_STAT_GROUP_UNSORTED,               "/Menubar/StatisticsMenu|Statistics"},                                                        /* unsorted statistic function */
3619         {REGISTER_STAT_GROUP_GENERIC,                "/Menubar/StatisticsMenu|Statistics"},                                                        /* generic statistic function, not specific to a protocol */
3620         {REGISTER_STAT_GROUP_CONVERSATION_LIST,      "/Menubar/StatisticsMenu|Statistics/ConversationListMenu|Statistics#ConversationList"},       /* member of the conversation list */
3621         {REGISTER_STAT_GROUP_ENDPOINT_LIST,          "/Menubar/StatisticsMenu|Statistics/EndpointListMenu|Statistics#EndpointList"},               /* member of the endpoint list */
3622         {REGISTER_STAT_GROUP_RESPONSE_TIME,          "/Menubar/StatisticsMenu|Statistics/ServiceResponseTimeMenu|Statistics#ServiceResponseTime"}, /* member of the service response time list */
3623         {REGISTER_STAT_GROUP_TELEPHONY,              "/Menubar/TelephonyMenu|Telephony"},                                                          /* telephony specific */
3624         {REGISTER_STAT_GROUP_TELEPHONY_ANSI,         "/Menubar/TelephonyMenu|Telephony/ANSI|Telephony#ANSI"},                                      /* ANSI-specific */
3625         {REGISTER_STAT_GROUP_TELEPHONY_GSM,          "/Menubar/TelephonyMenu|Telephony/GSM|Telephony#GSM"},                                        /* GSM-specific */
3626         {REGISTER_STAT_GROUP_TELEPHONY_LTE,          "/Menubar/TelephonyMenu|Telephony/LTEmenu|Telephony#LTE"},                                    /* LTE-specific */
3627         {REGISTER_STAT_GROUP_TELEPHONY_MTP3,         "/Menubar/TelephonyMenu|Telephony/MTP3menu|Telephony#MTP3"},                                  /* MTP3-specific */
3628         {REGISTER_STAT_GROUP_TELEPHONY_SCTP,         "/Menubar/TelephonyMenu|Telephony/SCTPmenu|Telephony#SCTP"},                                  /* SCTP-specific */
3629         {REGISTER_TOOLS_GROUP_UNSORTED,              "/Menubar/ToolsMenu|Tools"},                                                                  /* unsorted tools */
3630         {0, NULL}
3631     };
3632     return val_to_str_const(group, group_name_vals, "/Menubar/ToolsMenu|Tools");
3633 }
3634
3635 /*
3636  * Enable/disable menu sensitivity.
3637  */
3638 static void
3639 set_menu_sensitivity(GtkUIManager *ui_manager, const gchar *path, gint val)
3640 {
3641     GtkAction *action;
3642
3643     action = gtk_ui_manager_get_action(ui_manager, path);
3644     if(!action){
3645         fprintf (stderr, "Warning: set_menu_sensitivity couldn't find action path= %s\n",
3646                 path);
3647         return;
3648     }
3649     gtk_action_set_sensitive (action, val); /* TRUE to make the action sensitive */
3650 }
3651
3652 static void
3653 set_menu_object_data_meat(GtkUIManager *ui_manager, const gchar *path, const gchar *key, gpointer data)
3654 {
3655     GtkWidget *menu = NULL;
3656
3657     if ((menu =  gtk_ui_manager_get_widget(ui_manager, path)) != NULL){
3658         g_object_set_data(G_OBJECT(menu), key, data);
3659     }else{
3660 #if 0
3661         g_warning("set_menu_object_data_meat: no menu, path: %s",path);
3662 #endif
3663     }
3664 }
3665
3666 void
3667 set_menu_object_data (const gchar *path, const gchar *key, gpointer data)
3668 {
3669     if (strncmp (path,"/Menubar",8) == 0){
3670         set_menu_object_data_meat(ui_manager_main_menubar, path, key, data);
3671     }else if (strncmp (path,"/PacketListMenuPopup",20) == 0){
3672         set_menu_object_data_meat(ui_manager_packet_list_menu, path, key, data);
3673     }else if (strncmp (path,"/TreeViewPopup",14) == 0){
3674         set_menu_object_data_meat(ui_manager_tree_view_menu, path, key, data);
3675     }else if (strncmp (path,"/BytesMenuPopup",15) == 0){
3676         set_menu_object_data_meat(ui_manager_bytes_menu, path, key, data);
3677     }else if (strncmp (path,"/ProfilesMenuPopup",18) == 0){
3678         set_menu_object_data_meat(ui_manager_statusbar_profiles_menu, path, key, data);
3679     }
3680 }
3681
3682
3683 /* Recently used capture files submenu:
3684  * Submenu containing the recently used capture files.
3685  * The capture filenames are always kept with the absolute path to be independent
3686  * of the current path.
3687  * They are only stored inside the labels of the submenu (no separate list). */
3688
3689 #define MENU_RECENT_FILES_PATH "/Menubar/FileMenu/OpenRecent"
3690 #define MENU_RECENT_FILES_KEY "Recent File Name"
3691
3692 /* Add a file name to the top of the list; if it's already present remove it first */
3693 static GList *
3694 remove_present_file_name(GList *recent_files_list, const gchar *cf_name)
3695 {
3696     GList *li, *next;
3697     gchar *widget_cf_name;
3698
3699     for (li = g_list_first(recent_files_list); li; li = next) {
3700         widget_cf_name = (gchar *)li->data;
3701         next = li->next;
3702         if (
3703 #ifdef _WIN32
3704             /* do a case insensitive compare on win32 */
3705             g_ascii_strncasecmp(widget_cf_name, cf_name, 1000) == 0){
3706 #else   /* _WIN32 */
3707             /* do a case sensitive compare on unix */
3708             strncmp(widget_cf_name, cf_name, 1000) == 0 ){
3709 #endif
3710             recent_files_list = g_list_remove(recent_files_list,widget_cf_name);
3711         }
3712     }
3713
3714     return recent_files_list;
3715 }
3716
3717 static void
3718 recent_changed_cb (GtkUIManager *ui_manager,
3719                    gpointer          user_data _U_)
3720 {
3721   guint  merge_id;
3722   GList *action_groups, *l;
3723
3724
3725   merge_id = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (ui_manager),
3726                                "recent-files-merge-id"));
3727
3728   /* remove the UI */
3729   gtk_ui_manager_remove_ui (ui_manager, merge_id);
3730
3731   /* remove the action group; gtk_ui_manager_remove_action_group()
3732    * should really take the action group's name instead of its
3733    * pointer.
3734    */
3735   action_groups = gtk_ui_manager_get_action_groups (ui_manager);
3736   for (l = action_groups; l != NULL; l = l->next)
3737   {
3738       GtkActionGroup *group = (GtkActionGroup *)l->data;
3739
3740       if (strcmp (gtk_action_group_get_name (group), "recent-files-group") == 0){
3741           /* this unrefs the action group and all of its actions */
3742           gtk_ui_manager_remove_action_group (ui_manager, group);
3743           break;
3744       }
3745   }
3746
3747   /* generate a new merge id and re-add everything */
3748   merge_id = gtk_ui_manager_new_merge_id (ui_manager);
3749   add_recent_items (merge_id, ui_manager);
3750 }
3751
3752 static void
3753 recent_clear_cb(GtkAction *action _U_, gpointer user_data _U_)
3754 {
3755     GtkWidget *submenu_recent_files;
3756     GList     *recent_files_list;
3757
3758     /* Get the list of recent files, free the list and store the empty list with the widget */
3759     submenu_recent_files = gtk_ui_manager_get_widget(ui_manager_main_menubar, MENU_RECENT_FILES_PATH);
3760     recent_files_list = (GList *)g_object_get_data(G_OBJECT(submenu_recent_files), "recent-files-list");
3761     /* Free the name strings ?? */
3762     g_list_free(recent_files_list);
3763     recent_files_list = NULL;
3764     g_object_set_data(G_OBJECT(submenu_recent_files), "recent-files-list", recent_files_list);
3765     /* Calling recent_changed_cb will rebuild the GUI call add_recent_items which will in turn call
3766      * main_welcome_reset_recent_capture_files
3767      */
3768     recent_changed_cb(ui_manager_main_menubar, NULL);
3769 }
3770
3771 static void
3772 add_recent_items (guint merge_id, GtkUIManager *ui_manager)
3773 {
3774     GtkActionGroup *action_group;
3775     GtkAction      *action;
3776     GtkWidget      *submenu_recent_files;
3777     GtkWidget      *submenu_recent_file;
3778     GList          *items, *l;
3779     gchar          *action_name;
3780     gchar          *recent_path;
3781     guint           i;
3782
3783     /* Reset the recent files list in the welcome screen */
3784     main_welcome_reset_recent_capture_files();
3785
3786     action_group = gtk_action_group_new ("recent-files-group");
3787
3788     submenu_recent_files = gtk_ui_manager_get_widget(ui_manager, MENU_RECENT_FILES_PATH);
3789     if(!submenu_recent_files){
3790         g_warning("add_recent_items: No submenu_recent_files found, path= MENU_RECENT_FILES_PATH");
3791     }
3792     items = (GList *)g_object_get_data(G_OBJECT(submenu_recent_files), "recent-files-list");
3793
3794     gtk_ui_manager_insert_action_group (ui_manager, action_group, 0);
3795     g_object_set_data (G_OBJECT (ui_manager),
3796                      "recent-files-merge-id", GUINT_TO_POINTER (merge_id));
3797
3798     /* no items */
3799     if (!items){
3800
3801       action = (GtkAction *)g_object_new (GTK_TYPE_ACTION,
3802                  "name", "recent-info-empty",
3803                  "label", "No recently used files",
3804                  "sensitive", FALSE,
3805                  NULL);
3806       gtk_action_group_add_action (action_group, action);
3807       gtk_action_set_sensitive(action, FALSE);
3808       g_object_unref (action);
3809
3810       gtk_ui_manager_add_ui (ui_manager, merge_id,
3811                  "/Menubar/FileMenu/OpenRecent/RecentFiles",
3812                  "recent-info-empty",
3813                  "recent-info-empty",
3814                  GTK_UI_MANAGER_MENUITEM,
3815                  FALSE);
3816
3817       return;
3818     }
3819
3820   for (i = 0, l = items;
3821        i < prefs.gui_recent_files_count_max && l != NULL;
3822        i +=1, l = l->next)
3823     {
3824       gchar *item_name = (gchar *)l->data;
3825       action_name = g_strdup_printf ("recent-info-%u", i);
3826
3827       action = (GtkAction *)g_object_new (GTK_TYPE_ACTION,
3828                  "name", action_name,
3829                  "label", item_name,
3830                  "stock_id", WIRESHARK_STOCK_SAVE,
3831                  NULL);
3832       g_signal_connect (action, "activate",
3833                         G_CALLBACK (menu_open_recent_file_cmd_cb), NULL);
3834 #if !GTK_CHECK_VERSION(2,16,0)
3835       g_object_set_data (G_OBJECT (action), "FileName", item_name);
3836 #endif
3837       gtk_action_group_add_action (action_group, action);
3838       g_object_unref (action);
3839
3840       gtk_ui_manager_add_ui (ui_manager, merge_id,
3841                  "/Menubar/FileMenu/OpenRecent/RecentFiles",
3842                  action_name,
3843                  action_name,
3844                  GTK_UI_MANAGER_MENUITEM,
3845                  FALSE);
3846
3847       /* Disable mnemonic accelerator key for recent file name */
3848       recent_path = g_strdup_printf ("/Menubar/FileMenu/OpenRecent/RecentFiles/recent-info-%u", i);
3849       submenu_recent_file = gtk_ui_manager_get_widget(ui_manager, recent_path);
3850       g_object_set(G_OBJECT (submenu_recent_file), "use-underline", 0, NULL);
3851
3852       /* Add the file name to the recent files list on the Welcome screen */
3853       main_welcome_add_recent_capture_file(item_name, G_OBJECT(action));
3854
3855       g_free (recent_path);
3856       g_free (action_name);
3857     }
3858     /* Add a Separator */
3859     gtk_ui_manager_add_ui (ui_manager, merge_id,
3860              "/Menubar/FileMenu/OpenRecent/RecentFiles",
3861              "separator-recent-info",
3862              NULL,
3863              GTK_UI_MANAGER_SEPARATOR,
3864              FALSE);
3865
3866     /* Add a clear Icon */
3867     action = (GtkAction *)g_object_new (GTK_TYPE_ACTION,
3868              "name", "clear-recent-info",
3869              "label", "Clear the recent files list",
3870              "stock_id", GTK_STOCK_CLEAR,
3871              NULL);
3872
3873     g_signal_connect (action, "activate",
3874                         G_CALLBACK (recent_clear_cb), NULL);
3875
3876     gtk_action_group_add_action (action_group, action);
3877     g_object_unref (action);
3878
3879     gtk_ui_manager_add_ui (ui_manager, merge_id,
3880              "/Menubar/FileMenu/OpenRecent/RecentFiles",
3881              "clear-recent-info",
3882              "clear-recent-info",
3883              GTK_UI_MANAGER_MENUITEM,
3884              FALSE);
3885
3886 }
3887
3888 #define MENU_STATISTICS_PATH "/Menubar/StatisticsMenu"
3889
3890 static void
3891 add_tap_plugins (guint merge_id, GtkUIManager *ui_manager)
3892 {
3893     GtkActionGroup *action_group;
3894     GtkAction      *action;
3895     GtkWidget      *submenu_statistics;
3896     GList          *cfg_list;
3897     GList          *iter;
3898     gchar          *action_name;
3899
3900     gchar          *submenu_path;
3901     gsize           submenu_path_size;
3902     gchar          *stat_name_buf;
3903     gchar          *stat_name;
3904     gchar          *sep;
3905
3906     action_group = gtk_action_group_new ("tap-plugins-group");
3907
3908     submenu_statistics = gtk_ui_manager_get_widget(ui_manager_main_menubar, MENU_STATISTICS_PATH);
3909     if(!submenu_statistics){
3910         g_warning("add_tap_plugins: No submenu_statistics found, path= MENU_STATISTICS_PATH");
3911         return;
3912     }
3913     gtk_ui_manager_insert_action_group (ui_manager_main_menubar, action_group, 0);
3914     g_object_set_data (G_OBJECT (ui_manager_main_menubar),
3915                      "tap-plugins-merge-id", GUINT_TO_POINTER (merge_id));
3916
3917     cfg_list = stats_tree_get_cfg_list();
3918     iter = g_list_first(cfg_list);
3919     while (iter) {
3920         stats_tree_cfg *cfg = (stats_tree_cfg*)iter->data;
3921         if (cfg->plugin) {
3922             stat_name_buf = g_strdup(cfg->name);
3923             submenu_path_size = (gsize)(strlen(MENU_STATISTICS_PATH)+strlen(cfg->name)+strlen(cfg->abbr)+1);   /* worst case length */
3924             submenu_path = (gchar *)g_malloc(submenu_path_size);
3925             g_strlcpy(submenu_path, MENU_STATISTICS_PATH, submenu_path_size);
3926
3927             sep = stat_name= stat_name_buf;
3928             while ((sep = strchr(sep,'/')) != NULL) {
3929                 if (*(++sep)=='/') {  /* escapeded slash - two slash characters after each other */
3930                     memmove(sep,sep+1,strlen(sep));
3931                 }
3932                 else {
3933                     /* we got a new submenu name - ignore the edge case where there is no text following this slash */
3934                     *(sep-1)= 0;
3935                     action_name = g_strdup_printf("%s/%s", submenu_path,stat_name);
3936                     if (!gtk_ui_manager_get_widget(ui_manager, action_name)) {
3937                         action = (GtkAction *)g_object_new (GTK_TYPE_ACTION,
3938                             "name", action_name,
3939                             "label", stat_name,
3940                             NULL);
3941                         gtk_action_group_add_action (action_group, action);
3942                         g_object_unref (action);
3943
3944                         gtk_ui_manager_add_ui (ui_manager, merge_id,
3945                             submenu_path,
3946                             stat_name,
3947                             action_name,
3948                             GTK_UI_MANAGER_MENU,
3949                             FALSE);
3950                     }
3951                     g_free (action_name);
3952
3953                     g_strlcat(submenu_path,"/",submenu_path_size);
3954                     g_strlcat(submenu_path,stat_name,submenu_path_size);
3955                     stat_name= sep;
3956                 }
3957             }
3958
3959             action_name = g_strdup_printf("%s/%s", submenu_path, cfg->abbr);
3960             action = (GtkAction *)g_object_new (GTK_TYPE_ACTION,
3961                  "name", action_name,
3962                  "label", stat_name,
3963                  NULL);
3964             g_signal_connect (action, "activate", G_CALLBACK (gtk_stats_tree_cb), NULL);
3965             gtk_action_group_add_action (action_group, action);
3966             g_object_unref (action);
3967
3968             gtk_ui_manager_add_ui (ui_manager, merge_id,
3969                  submenu_path,
3970                  action_name,
3971                  action_name,
3972                  GTK_UI_MANAGER_MENUITEM,
3973                 FALSE);
3974
3975             g_free (action_name);
3976             g_free (stat_name_buf);
3977             g_free (submenu_path);
3978         }
3979         iter = g_list_next(iter);
3980     }
3981     g_list_free(cfg_list);
3982 }
3983
3984 /* Open a file by its name
3985    (Beware: will not ask to close existing capture file!) */
3986 void
3987 menu_open_filename(gchar *cf_name)
3988 {
3989     GtkWidget *submenu_recent_files;
3990     int        err;
3991     GList     *recent_files_list;
3992
3993
3994     submenu_recent_files = gtk_ui_manager_get_widget(ui_manager_main_menubar, MENU_RECENT_FILES_PATH);
3995     if(!submenu_recent_files){
3996         g_warning("menu_open_filename: No submenu_recent_files found, path= MENU_RECENT_FILES_PATH");
3997     }
3998     recent_files_list = (GList *)g_object_get_data(G_OBJECT(submenu_recent_files), "recent-files-list");
3999     /* XXX: ask user to remove item, it's maybe only a temporary problem */
4000     /* open and read the capture file (this will close an existing file) */
4001     if (cf_open(&cfile, cf_name, WTAP_TYPE_AUTO, FALSE, &err) == CF_OK) {
4002         cf_read(&cfile, FALSE);
4003     }else{
4004         recent_files_list = remove_present_file_name(recent_files_list, cf_name);
4005         g_object_set_data(G_OBJECT(submenu_recent_files), "recent-files-list", recent_files_list);
4006         /* Calling recent_changed_cb will rebuild the GUI call add_recent_items which will in turn call
4007          * main_welcome_reset_recent_capture_files
4008          */
4009         recent_changed_cb(ui_manager_main_menubar, NULL);
4010     }
4011 }
4012
4013 /* callback, if the user pushed a recent file submenu item */
4014 static void
4015 menu_open_recent_file_cmd(GtkAction *action)
4016 {
4017     GtkWidget   *submenu_recent_files;
4018     GList       *recent_files_list;
4019     const gchar *cf_name;
4020     int          err;
4021
4022 #if GTK_CHECK_VERSION(2,16,0)
4023     cf_name = gtk_action_get_label(action);
4024 #else
4025     cf_name = (const gchar *)g_object_get_data(G_OBJECT(action), "FileName");
4026 #endif
4027
4028     /* open and read the capture file (this will close an existing file) */
4029     if (cf_open(&cfile, cf_name, WTAP_TYPE_AUTO, FALSE, &err) == CF_OK) {
4030         cf_read(&cfile, FALSE);
4031     } else {
4032         submenu_recent_files = gtk_ui_manager_get_widget(ui_manager_main_menubar, MENU_RECENT_FILES_PATH);
4033         recent_files_list = (GList *)g_object_get_data(G_OBJECT(submenu_recent_files), "recent-files-list");
4034
4035         recent_files_list = remove_present_file_name(recent_files_list, cf_name);
4036         g_object_set_data(G_OBJECT(submenu_recent_files), "recent-files-list", recent_files_list);
4037         /* Calling recent_changed_cb will rebuild the GUI call add_recent_items which will in turn call
4038          * main_welcome_reset_recent_capture_files
4039          */
4040         recent_changed_cb(ui_manager_main_menubar, NULL);
4041     }
4042 }
4043
4044 static void
4045 menu_open_recent_file_cmd_cb(GtkAction *action, gpointer data _U_)
4046 {
4047     /* If there's unsaved data, let the user save it first.
4048        If they cancel out of it, don't open the file. */
4049     if (do_file_close(&cfile, FALSE, " before opening a new capture file"))
4050         menu_open_recent_file_cmd(action);
4051 }
4052
4053 static void
4054 add_menu_recent_capture_file_absolute(const gchar *cf_name)
4055 {
4056     GtkWidget *submenu_recent_files;
4057     GList     *li;
4058     gchar     *widget_cf_name;
4059     gchar     *normalized_cf_name;
4060     guint      cnt;
4061     GList     *recent_files_list;
4062
4063     normalized_cf_name = g_strdup(cf_name);
4064 #ifdef _WIN32
4065     /* replace all slashes by backslashes */
4066     g_strdelimit(normalized_cf_name, "/", '\\');
4067 #endif
4068
4069     /* get the submenu container item */
4070     submenu_recent_files = gtk_ui_manager_get_widget(ui_manager_main_menubar, MENU_RECENT_FILES_PATH);
4071     if(!submenu_recent_files){
4072         g_warning("add_menu_recent_capture_file_absolute: No submenu_recent_files found, path= MENU_RECENT_FILES_PATH");
4073         g_free(normalized_cf_name);
4074         return;
4075     }
4076     recent_files_list = (GList *)g_object_get_data(G_OBJECT(submenu_recent_files), "recent-files-list");
4077     cnt = 1;
4078     for (li = g_list_first(recent_files_list); li; cnt++) {
4079         widget_cf_name = (gchar *)li->data;
4080
4081         /* Find the next element BEFORE we (possibly) free the current one below */
4082         li = li->next;
4083
4084         if (
4085 #ifdef _WIN32
4086             /* do a case insensitive compare on win32 */
4087             g_ascii_strncasecmp(widget_cf_name, normalized_cf_name, 1000) == 0 ||
4088 #else   /* _WIN32 */
4089             /* do a case sensitive compare on unix */
4090             strncmp(widget_cf_name, normalized_cf_name, 1000) == 0 ||
4091 #endif
4092             cnt >= prefs.gui_recent_files_count_max) {
4093             recent_files_list = g_list_remove(recent_files_list,widget_cf_name);
4094             cnt--;
4095         }
4096     }
4097     recent_files_list = g_list_prepend(recent_files_list, normalized_cf_name);
4098     g_object_set_data(G_OBJECT(submenu_recent_files), "recent-files-list", recent_files_list);
4099     recent_changed_cb( ui_manager_main_menubar, NULL);
4100 }
4101
4102
4103 /* add the capture filename to the "Recent Files" menu */
4104 /* (will change nothing, if this filename is already in the menu) */
4105 /*
4106  * XXX - We might want to call SHAddToRecentDocs under Windows 7:
4107  * http:                        //stackoverflow.com/questions/437212/how-do-you-register-a-most-recently-used-list-with-windows-in-preparation-for-win
4108  */
4109 void
4110 add_menu_recent_capture_file(const gchar *cf_name)
4111 {
4112     gchar *curr;
4113     gchar *absolute;
4114
4115     /* if this filename is an absolute path, we can use it directly */
4116     if (g_path_is_absolute(cf_name)) {
4117         add_menu_recent_capture_file_absolute(cf_name);
4118         return;
4119     }
4120
4121     /* this filename is not an absolute path, prepend the current dir */
4122     curr = g_get_current_dir();
4123     absolute = g_strdup_printf("%s%s%s", curr, G_DIR_SEPARATOR_S, cf_name);
4124     add_menu_recent_capture_file_absolute(absolute);
4125     g_free(curr);
4126     g_free(absolute);
4127 }
4128
4129
4130 /* write all capture filenames of the menu to the user's recent file */
4131 void
4132 menu_recent_file_write_all(FILE *rf)
4133 {
4134     GtkWidget *submenu_recent_files;
4135     gchar     *cf_name;
4136     GList     *recent_files_list, *list;
4137
4138     submenu_recent_files = gtk_ui_manager_get_widget(ui_manager_main_menubar, MENU_RECENT_FILES_PATH);
4139     if(!submenu_recent_files){
4140         g_warning("menu_recent_file_write_all: No submenu_recent_files found, path= MENU_RECENT_FILES_PATH");
4141     }
4142     recent_files_list = (GList *)g_object_get_data(G_OBJECT(submenu_recent_files), "recent-files-list");
4143     list =  g_list_last(recent_files_list);
4144     while (list != NULL) {
4145         cf_name = (gchar *)list->data;
4146         if (cf_name) {
4147             fprintf (rf, RECENT_KEY_CAPTURE_FILE ": %s\n", cf_name);
4148         }
4149         list = g_list_previous(list);
4150     }
4151     g_list_free(recent_files_list);
4152 }
4153
4154 void
4155 menu_name_resolution_changed(void)
4156 {
4157     GtkWidget *menu;
4158
4159     menu = gtk_ui_manager_get_widget(ui_manager_main_menubar, "/Menubar/ViewMenu/NameResolution/EnableforMACLayer");
4160     if(!menu){
4161         g_warning("menu_name_resolution_changed: No menu found, path= /Menubar/ViewMenu/NameResolution/EnableforMACLayer");
4162     }
4163     gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), gbl_resolv_flags.mac_name);
4164
4165     menu = gtk_ui_manager_get_widget(ui_manager_main_menubar, "/Menubar/ViewMenu/NameResolution/EnableforNetworkLayer");
4166     if(!menu){
4167         g_warning("menu_name_resolution_changed: No menu found, path= /Menubar/ViewMenu/NameResolution/EnableforNetworkLayer");
4168     }
4169     gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), gbl_resolv_flags.network_name);
4170
4171     menu = gtk_ui_manager_get_widget(ui_manager_main_menubar, "/Menubar/ViewMenu/NameResolution/EnableforTransportLayer");
4172     if(!menu){
4173         g_warning("menu_name_resolution_changed: No menu found, path= /Menubar/ViewMenu/NameResolution/EnableforTransportLayer");
4174     }
4175     gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), gbl_resolv_flags.transport_name);
4176
4177     menu = gtk_ui_manager_get_widget(ui_manager_main_menubar, "/Menubar/ViewMenu/NameResolution/UseExternalNetworkNameResolver");
4178     if(!menu){
4179         g_warning("menu_name_resolution_changed: No menu found, path= /Menubar/ViewMenu/NameResolution/UseExternalNetworkNameResolver");
4180     }
4181     gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), gbl_resolv_flags.use_external_net_name_resolver);
4182 }
4183
4184 static void
4185 menu_name_resolution_update_cb(GtkAction *action _U_, gpointer data _U_)
4186 {
4187     menu_name_resolution_changed();
4188 }
4189
4190 static void
4191 name_resolution_cb(GtkWidget *w, gpointer d _U_, gboolean* res_flag)
4192 {
4193     if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(w))) {
4194         *res_flag = TRUE;
4195     } else {
4196         *res_flag = FALSE;
4197     }
4198
4199     packet_list_recreate();
4200     redraw_packet_bytes_all();
4201 }
4202
4203 #ifdef HAVE_LIBPCAP
4204 void
4205 menu_auto_scroll_live_changed(gboolean auto_scroll_live_in)
4206 {
4207     GtkWidget *menu;
4208
4209     /* tell menu about it */
4210     menu = gtk_ui_manager_get_widget(ui_manager_main_menubar, "/Menubar/ViewMenu/AutoScrollinLiveCapture");
4211     if(!menu){
4212         g_warning("menu_auto_scroll_live_changed: No menu found, path= /Menubar/ViewMenu/AutoScrollinLiveCapture");
4213     }
4214     if( ((gboolean) gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menu)) != auto_scroll_live_in) ) {
4215         gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), auto_scroll_live_in);
4216     }
4217 }
4218 #endif /*HAVE_LIBPCAP */
4219
4220
4221
4222
4223 void
4224 menu_colorize_changed(gboolean packet_list_colorize)
4225 {
4226     GtkWidget *menu;
4227
4228     /* tell menu about it */
4229     menu = gtk_ui_manager_get_widget(ui_manager_main_menubar, "/Menubar/ViewMenu/ColorizePacketList");
4230     if(!menu){
4231         g_warning("menu_colorize_changed: No menu found, path= /Menubar/ViewMenu/ColorizePacketList");
4232     }
4233     if( (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menu)) != packet_list_colorize) ) {
4234         gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), packet_list_colorize);
4235     }
4236 }
4237
4238 static void
4239 colorize_cb(GtkWidget *w, gpointer d _U_)
4240 {
4241     main_colorize_changed(gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(w)));
4242 }
4243
4244
4245 /* the recent file read has finished, update the menu corresponding */
4246 void
4247 menu_recent_read_finished(void)
4248 {
4249     GtkWidget *menu;
4250
4251     menu = gtk_ui_manager_get_widget(ui_manager_main_menubar, "/Menubar/ViewMenu/MainToolbar");
4252     if(!menu){
4253         g_warning("menu_recent_read_finished: No menu found, path= /Menubar/ViewMenu/MainToolbar");
4254     }else{
4255         gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), recent.main_toolbar_show);
4256     }
4257     menu = gtk_ui_manager_get_widget(ui_manager_main_menubar, "/Menubar/ViewMenu/FilterToolbar");
4258     if(!menu){
4259         g_warning("menu_recent_read_finished: No menu found, path= /Menubar/ViewMenu/FilterToolbar");
4260     }else{
4261         gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), recent.filter_toolbar_show);
4262     };
4263     menu = gtk_ui_manager_get_widget(ui_manager_main_menubar, "/Menubar/ViewMenu/WirelessToolbar");
4264     if(!menu){
4265         g_warning("menu_recent_read_finished: No menu found, path= /Menubar/ViewMenu/WirelessToolbar");
4266     }else{
4267         gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), recent.wireless_toolbar_show);
4268     }
4269
4270     /* Fix me? */
4271     menu = gtk_ui_manager_get_widget(ui_manager_main_menubar, "/Menubar/ViewMenu/StatusBar");
4272     if(!menu){
4273         g_warning("menu_recent_read_finished: No menu found, path= /Menubar/ViewMenu/StatusBar");
4274     }else{
4275         gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), recent.statusbar_show);
4276     }
4277
4278     menu = gtk_ui_manager_get_widget(ui_manager_main_menubar, "/Menubar/ViewMenu/PacketList");
4279     if(!menu){
4280         g_warning("menu_recent_read_finished: No menu found, path= /Menubar/ViewMenu/PacketList");
4281     }else{
4282         gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), recent.packet_list_show);
4283     }
4284
4285     menu = gtk_ui_manager_get_widget(ui_manager_main_menubar, "/Menubar/ViewMenu/PacketDetails");
4286     if(!menu){
4287         g_warning("menu_recent_read_finished: No menu found, path= /Menubar/ViewMenu/PacketDetails");
4288     }else{
4289         gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), recent.tree_view_show);
4290     }
4291
4292     menu = gtk_ui_manager_get_widget(ui_manager_main_menubar, "/Menubar/ViewMenu/PacketBytes");
4293     if(!menu){
4294         g_warning("menu_recent_read_finished: No menu found, path= /Menubar/ViewMenu/PacketBytes");
4295     }else{
4296         gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), recent.byte_view_show);
4297     }
4298
4299     menu = gtk_ui_manager_get_widget(ui_manager_main_menubar, "/Menubar/ViewMenu/ColorizePacketList");
4300     if(!menu){
4301         g_warning("menu_recent_read_finished: No menu found, path= /Menubar/ViewMenu/ColorizePacketList");
4302     }else{
4303         gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), recent.packet_list_colorize);
4304     }
4305
4306     menu_name_resolution_changed();
4307
4308 #ifdef HAVE_LIBPCAP
4309     menu = gtk_ui_manager_get_widget(ui_manager_main_menubar, "/Menubar/ViewMenu/AutoScrollinLiveCapture");
4310     if(!menu){
4311         g_warning("menu_recent_read_finished: No menu found, path= /Menubar/ViewMenu/AutoScrollinLiveCapture");
4312     }else{
4313         gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), auto_scroll_live);
4314     }
4315 #endif
4316     main_widgets_rearrange();
4317
4318     /* Update the time format if we had a command line value. */
4319     if (global_dissect_options.time_format != TS_NOT_SET) {
4320         recent.gui_time_format = global_dissect_options.time_format;
4321     }
4322
4323     /* XXX Fix me */
4324     timestamp_set_type(recent.gui_time_format);
4325     /* This call adjusts column width */
4326     cf_timestamp_auto_precision(&cfile);
4327     packet_list_queue_draw();
4328     /* the actual precision will be set in packet_list_queue_draw() below */
4329     if (recent.gui_time_precision > TS_PREC_FIXED_NSEC) {
4330         timestamp_set_precision(TS_PREC_AUTO);
4331     } else {
4332         timestamp_set_precision(recent.gui_time_precision);
4333     }
4334     /* This call adjusts column width */
4335     cf_timestamp_auto_precision(&cfile);
4336     packet_list_queue_draw();
4337
4338     /* don't change the seconds format, if we had a command line value */
4339     if (timestamp_get_seconds_type() != TS_SECONDS_NOT_SET) {
4340         recent.gui_seconds_format = timestamp_get_seconds_type();
4341     }
4342     menu = gtk_ui_manager_get_widget(ui_manager_main_menubar, "/Menubar/ViewMenu/TimeDisplayFormat/DisplaySecondsWithHoursAndMinutes");
4343     if(!menu){
4344         g_warning("menu_recent_read_finished: No menu found, path= /Menubar/ViewMenu/TimeDisplayFormat/DisplaySecondsWithHoursAndMinutes");
4345     }
4346
4347     switch (recent.gui_seconds_format) {
4348     case TS_SECONDS_DEFAULT:
4349         recent.gui_seconds_format = (ts_seconds_type)-1;
4350         /* set_active will not trigger the callback when deactivating an inactive item! */
4351         gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), TRUE);
4352         gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), FALSE);
4353         break;
4354     case TS_SECONDS_HOUR_MIN_SEC:
4355         recent.gui_seconds_format = (ts_seconds_type)-1;
4356         /* set_active will not trigger the callback when activating an active item! */
4357         gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), FALSE);
4358         gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), TRUE);
4359         break;
4360     default:
4361         g_assert_not_reached();
4362     }
4363
4364     main_colorize_changed(recent.packet_list_colorize);
4365 }
4366
4367
4368 gboolean
4369 popup_menu_handler(GtkWidget *widget, GdkEvent *event, gpointer data)
4370 {
4371     GtkWidget      *menu         = (GtkWidget *)data;
4372     GdkEventButton *event_button = NULL;
4373     gint            row, column;
4374
4375     if(widget == NULL || event == NULL || data == NULL) {
4376         return FALSE;
4377     }
4378
4379     /*
4380      * If we ever want to make the menu differ based on what row
4381      * and/or column we're above, we'd use "eth_clist_get_selection_info()"
4382      * to find the row and column number for the coordinates; a CTree is,
4383      * I guess, like a CList with one column(?) and the expander widget
4384      * as a pixmap.
4385      */
4386     /* Check if we are on packet_list object */
4387     if (widget == g_object_get_data(G_OBJECT(popup_menu_object), E_MPACKET_LIST_KEY) &&
4388         ((GdkEventButton *)event)->button != 1) {
4389         gint physical_row;
4390         if (packet_list_get_event_row_column((GdkEventButton *)event, &physical_row, &row, &column)) {
4391             g_object_set_data(G_OBJECT(popup_menu_object), E_MPACKET_LIST_ROW_KEY,
4392                             GINT_TO_POINTER(row));
4393             g_object_set_data(G_OBJECT(popup_menu_object), E_MPACKET_LIST_COL_KEY,
4394                             GINT_TO_POINTER(column));
4395             packet_list_set_selected_row(row);
4396         }
4397     }
4398
4399     /* Check if we are on tree_view object */
4400     if (widget == tree_view_gbl) {
4401         tree_view_select(widget, (GdkEventButton *) event);
4402     }
4403
4404     /* context menu handler */
4405     if(event->type == GDK_BUTTON_PRESS) {
4406         event_button = (GdkEventButton *) event;
4407
4408         /* To quote the "Gdk Event Structures" doc:
4409          * "Normally button 1 is the left mouse button, 2 is the middle button, and 3 is the right button" */
4410         if(event_button->button == 3) {
4411             gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL,
4412                            event_button->button,
4413                            event_button->time);
4414             g_signal_stop_emission_by_name(widget, "button_press_event");
4415             return TRUE;
4416         }
4417     }
4418
4419     /* Check if we are on byte_view object */
4420     if(widget == get_notebook_bv_ptr(byte_nb_ptr_gbl)) {
4421         byte_view_select(widget, (GdkEventButton *) event);
4422     }
4423
4424     /* GDK_2BUTTON_PRESS is a doubleclick -> expand/collapse tree row */
4425     /* GTK version 1 seems to be doing this automatically */
4426     if (widget == tree_view_gbl && event->type == GDK_2BUTTON_PRESS) {
4427         GtkTreePath      *path;
4428
4429         if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(widget),
4430                                           (gint) (((GdkEventButton *)event)->x),
4431                                           (gint) (((GdkEventButton *)event)->y),
4432                                           &path, NULL, NULL, NULL))
4433         {
4434             if (gtk_tree_view_row_expanded(GTK_TREE_VIEW(widget), path))
4435                 gtk_tree_view_collapse_row(GTK_TREE_VIEW(widget), path);
4436             else
4437                 gtk_tree_view_expand_row(GTK_TREE_VIEW(widget), path,
4438                                          FALSE);
4439             gtk_tree_path_free(path);
4440         }
4441     }
4442     return FALSE;
4443 }
4444
4445 /* Enable or disable menu items based on whether you have a capture file
4446    you've finished reading and, if you have one, whether it's been saved
4447    and whether it could be saved except by copying the raw packet data. */
4448 void
4449 set_menus_for_capture_file(capture_file *cf)
4450 {
4451     if (cf == NULL || cf->state == FILE_READ_IN_PROGRESS) {
4452         /* We have no capture file or we're currently reading a file */
4453         set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/FileMenu/Merge", FALSE);
4454         set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/FileMenu/Close", FALSE);
4455         set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/FileMenu/Save", FALSE);
4456         set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/FileMenu/SaveAs", FALSE);
4457         set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/FileMenu/ExportSpecifiedPackets", FALSE);
4458         set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/FileMenu/ExportPacketDissections", FALSE);
4459         set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/FileMenu/ExportSelectedPacketBytes", FALSE);
4460         set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/FileMenu/ExportSSLSessionKeys", FALSE);
4461         set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/FileMenu/ExportObjectsMenu", FALSE);
4462         set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/FileMenu/ExportPDUs", FALSE);
4463         set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/ViewMenu/Reload", FALSE);
4464     } else {
4465         set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/FileMenu/Merge", cf_can_write_with_wiretap(cf));
4466         set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/FileMenu/Close", TRUE);
4467         set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/FileMenu/Save",
4468                              cf_can_save(cf));
4469         set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/FileMenu/SaveAs",
4470                              cf_can_save_as(cf));
4471         /*
4472          * "Export Specified Packets..." should be available only if
4473          * we can write the file out in at least one format.
4474          */
4475         set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/FileMenu/ExportSpecifiedPackets",
4476                              cf_can_write_with_wiretap(cf));
4477         set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/FileMenu/ExportPacketDissections", TRUE);
4478         set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/FileMenu/ExportSelectedPacketBytes", TRUE);
4479         set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/FileMenu/ExportSSLSessionKeys", TRUE);
4480         set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/FileMenu/ExportObjectsMenu", TRUE);
4481         set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/FileMenu/ExportPDUs", TRUE);
4482         set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/ViewMenu/Reload", TRUE);
4483     }
4484 }
4485
4486 /* Enable or disable menu items based on whether there's a capture in
4487    progress. */
4488 void
4489 set_menus_for_capture_in_progress(gboolean capture_in_progress)
4490 {
4491     /* Either a capture was started or stopped; in either case, it's not
4492        in the process of stopping, so allow quitting. */
4493     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/FileMenu/Quit",
4494                          TRUE);
4495
4496     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/FileMenu/Open",
4497                          !capture_in_progress);
4498     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/FileMenu/OpenRecent",
4499                          !capture_in_progress);
4500     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/FileMenu/ExportPacketDissections",
4501                          capture_in_progress);
4502     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/FileMenu/ExportSelectedPacketBytes",
4503                          capture_in_progress);
4504     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/FileMenu/ExportSSLSessionKeys",
4505                          capture_in_progress);
4506     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/FileMenu/ExportObjectsMenu",
4507                          capture_in_progress);
4508     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/FileMenu/Set",
4509                          !capture_in_progress);
4510     set_menu_sensitivity(ui_manager_packet_list_heading, "/PacketListHeadingPopup/SortAscending",
4511                          !capture_in_progress);
4512     set_menu_sensitivity(ui_manager_packet_list_heading, "/PacketListHeadingPopup/SortDescending",
4513                          !capture_in_progress);
4514     set_menu_sensitivity(ui_manager_packet_list_heading, "/PacketListHeadingPopup/NoSorting",
4515                          !capture_in_progress);
4516
4517 #ifdef HAVE_LIBPCAP
4518     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/CaptureMenu/Options",
4519                          !capture_in_progress);
4520     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/CaptureMenu/Start",
4521                          !capture_in_progress && global_capture_opts.num_selected > 0);
4522     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/CaptureMenu/Stop",
4523                          capture_in_progress);
4524     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/CaptureMenu/Restart",
4525                          capture_in_progress);
4526 #endif /* HAVE_LIBPCAP */
4527 }
4528
4529 #ifdef HAVE_LIBPCAP
4530 void
4531 set_menus_capture_start_sensitivity(gboolean enable)
4532 {
4533     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/CaptureMenu/Start",
4534                          enable);
4535 }
4536 #endif
4537
4538 /* Disable menu items while we're waiting for the capture child to
4539    finish.  We disallow quitting until it finishes, and also disallow
4540    stopping or restarting the capture. */
4541 void
4542 set_menus_for_capture_stopping(void)
4543 {
4544     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/FileMenu/Quit",
4545                          FALSE);
4546 #ifdef HAVE_LIBPCAP
4547     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/CaptureMenu/Stop",
4548                          FALSE);
4549     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/CaptureMenu/Restart",
4550                          FALSE);
4551 #endif /* HAVE_LIBPCAP */
4552 }
4553
4554
4555 void
4556 set_menus_for_captured_packets(gboolean have_captured_packets)
4557 {
4558     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/FileMenu/Print",
4559                          have_captured_packets);
4560     set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/Print",
4561                          have_captured_packets);
4562
4563     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/EditMenu/FindPacket",
4564                          have_captured_packets);
4565     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/EditMenu/FindNext",
4566                          have_captured_packets);
4567     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/EditMenu/FindPrevious",
4568                          have_captured_packets);
4569     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/ViewMenu/ZoomIn",
4570                          have_captured_packets);
4571     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/ViewMenu/ZoomOut",
4572                          have_captured_packets);
4573     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/ViewMenu/NormalSize",
4574                          have_captured_packets);
4575     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/GoMenu/Goto",
4576                          have_captured_packets);
4577     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/GoMenu/PreviousPacket",
4578                          have_captured_packets);
4579     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/GoMenu/NextPacket",
4580                          have_captured_packets);
4581     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/GoMenu/FirstPacket",
4582                          have_captured_packets);
4583     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/GoMenu/LastPacket",
4584                          have_captured_packets);
4585     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/GoMenu/PreviousPacketInConversation",
4586                          have_captured_packets);
4587     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/GoMenu/NextPacketInConversation",
4588                          have_captured_packets);
4589     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/StatisticsMenu/Summary",
4590                          have_captured_packets);
4591     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/StatisticsMenu/ShowCommentsSummary",
4592                          have_captured_packets);
4593     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/StatisticsMenu/ProtocolHierarchy",
4594                          have_captured_packets);
4595 }
4596
4597 void
4598 set_menus_for_selected_packet(capture_file *cf)
4599 {
4600     GList      *conv_filter_list_entry;
4601     guint       i          = 0;
4602     gboolean    properties = FALSE;
4603     const char *abbrev     = NULL;
4604     char       *prev_abbrev;
4605     gboolean is_ip = FALSE, is_tcp = FALSE, is_udp = FALSE, is_sctp = FALSE, is_ssl = FALSE, is_lte_rlc = FALSE, is_http = FALSE;
4606
4607     /* Making the menu context-sensitive allows for easier selection of the
4608        desired item and has the added benefit, with large captures, of
4609        avoiding needless looping through huge lists for marked, ignored,
4610        or time-referenced packets. */
4611     gboolean frame_selected = cf->current_frame != NULL;
4612         /* A frame is selected */
4613     gboolean have_marked = frame_selected && cf->marked_count > 0;
4614         /* We have marked frames.  (XXX - why check frame_selected?) */
4615     gboolean another_is_marked = have_marked &&
4616         !(cf->marked_count == 1 && cf->current_frame->flags.marked);
4617         /* We have a marked frame other than the current frame (i.e.,
4618            we have at least one marked frame, and either there's more
4619            than one marked frame or the current frame isn't marked). */
4620     gboolean have_time_ref = cf->ref_time_count > 0;
4621     gboolean another_is_time_ref = frame_selected && have_time_ref &&
4622         !(cf->ref_time_count == 1 && cf->current_frame->flags.ref_time);
4623         /* We have a time reference frame other than the current frame (i.e.,
4624            we have at least one time reference frame, and either there's more
4625            than one time reference frame or the current frame isn't a
4626            time reference frame). (XXX - why check frame_selected?) */
4627     if (cf->edt)
4628     {
4629         proto_get_frame_protocols(cf->edt->pi.layers, &is_ip, &is_tcp, &is_udp, &is_sctp, &is_ssl, NULL, &is_lte_rlc);
4630         is_http = proto_is_frame_protocol(cf->edt->pi.layers, "http");
4631     }
4632     if (cf->edt && cf->edt->tree) {
4633         GPtrArray          *ga;
4634         header_field_info  *hfinfo;
4635         field_info         *v;
4636         guint              ii;
4637
4638         ga = proto_all_finfos(cf->edt->tree);
4639
4640         for (ii = ga->len - 1; ii > 0 ; ii -= 1) {
4641
4642             v = (field_info *)g_ptr_array_index (ga, ii);
4643             hfinfo =  v->hfinfo;
4644
4645             if (!g_str_has_prefix(hfinfo->abbrev, "text") &&
4646                 !g_str_has_prefix(hfinfo->abbrev, "_ws.expert") &&
4647                 !g_str_has_prefix(hfinfo->abbrev, "_ws.malformed")) {
4648
4649                 if (hfinfo->parent == -1) {
4650                     abbrev = hfinfo->abbrev;
4651                 } else {
4652                     abbrev = proto_registrar_get_abbrev(hfinfo->parent);
4653                 }
4654                 properties = prefs_is_registered_protocol(abbrev);
4655                 break;
4656             }
4657         }
4658     }
4659
4660     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/EditMenu/MarkPacket",
4661                          frame_selected);
4662     set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/MarkPacket",
4663                          frame_selected);
4664     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/EditMenu/MarkAllDisplayedPackets",
4665                          cf->displayed_count > 0);
4666     /* Unlike un-ignore, do not allow unmark of all frames when no frames are displayed  */
4667     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/EditMenu/UnmarkAllDisplayedPackets",
4668                          have_marked);
4669     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/EditMenu/FindNextMark",
4670                          another_is_marked);
4671     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/EditMenu/FindPreviousMark",
4672                          another_is_marked);
4673
4674     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/EditMenu/IgnorePacket",
4675                          frame_selected);
4676 #ifdef WANT_PACKET_EDITOR
4677     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/EditMenu/EditPacket",
4678                          prefs.gui_packet_editor ? frame_selected : FALSE);
4679     set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/EditPacket",
4680                          prefs.gui_packet_editor ? frame_selected : FALSE);
4681 #endif /* WANT_PACKET_EDITOR */
4682     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/EditMenu/AddEditPktComment",
4683                          frame_selected && wtap_dump_can_write(cf->linktypes, WTAP_COMMENT_PER_PACKET));
4684     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/EditMenu/AddEditCaptureComment",
4685                          frame_selected && wtap_dump_can_write(cf->linktypes, WTAP_COMMENT_PER_PACKET));
4686     set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/IgnorePacket",
4687                          frame_selected);
4688     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/EditMenu/IgnoreAllDisplayedPackets",
4689                          cf->displayed_count > 0 && cf->displayed_count != cf->count);
4690     /* Allow un-ignore of all frames even with no frames currently displayed */
4691     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/EditMenu/Un-IgnoreAllPackets",
4692                          cf->ignored_count > 0);
4693
4694     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/EditMenu/SetTimeReference",
4695                          frame_selected);
4696     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/EditMenu/Un-TimeReferenceAllPackets",
4697                          have_time_ref);
4698     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/EditMenu/TimeShift",
4699                          cf->count > 0);
4700     set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/SetTimeReference",
4701                          frame_selected);
4702     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/EditMenu/FindNextTimeReference",
4703                          another_is_time_ref);
4704     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/EditMenu/FindPreviousTimeReference",
4705                          another_is_time_ref);
4706
4707     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/ViewMenu/ResizeAllColumns",
4708                          frame_selected);
4709     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/ViewMenu/CollapseAll",
4710                          frame_selected);
4711     set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/CollapseAll",
4712                          frame_selected);
4713     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/ViewMenu/ExpandAll",
4714                          frame_selected);
4715     set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/ExpandAll",
4716                          frame_selected);
4717     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/ViewMenu/ColorizeConversation",
4718                          frame_selected);
4719     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/ViewMenu/ResetColoring1-10",
4720                          tmp_color_filters_used());
4721     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/ViewMenu/ShowPacketinNewWindow",
4722                          frame_selected);
4723     set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/ShowPacketinNewWindow",
4724                          frame_selected);
4725     set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/ManuallyResolveAddress",
4726                          frame_selected ? is_ip : FALSE);
4727     set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/SCTP",
4728                          frame_selected ? is_sctp : FALSE);
4729     set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/FollowTCPStream",
4730                          is_tcp);
4731     set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/FollowTCPStream",
4732                          is_tcp);
4733     set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/FollowUDPStream",
4734                          frame_selected ? is_udp : FALSE);
4735     set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/FollowSSLStream",
4736                          frame_selected ? is_ssl : FALSE);
4737     set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/FollowHTTPStream",
4738                          frame_selected ? is_http : FALSE);
4739
4740     set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/FollowSSLStream",
4741                          frame_selected ? is_ssl : FALSE);
4742     set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/FollowUDPStream",
4743                          frame_selected ? is_udp : FALSE);
4744     set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/FollowHTTPStream",
4745                          frame_selected ? is_http : FALSE);
4746
4747     set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/ColorizeConversation",
4748                          frame_selected);
4749     set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/DecodeAs",
4750                          frame_selected && decode_as_ok());
4751
4752     if (properties) {
4753         prev_abbrev = (char *)g_object_get_data(G_OBJECT(ui_manager_packet_list_menu), "menu_abbrev");
4754         if (!prev_abbrev || (strcmp(prev_abbrev, abbrev) != 0)) {
4755           /*No previous protocol or protocol changed - update Protocol Preferences menu*/
4756             module_t *prefs_module_p = prefs_find_module(abbrev);
4757             rebuild_protocol_prefs_menu(prefs_module_p, properties, ui_manager_packet_list_menu, "/PacketListMenuPopup/ProtocolPreferences");
4758
4759             g_object_set_data(G_OBJECT(ui_manager_packet_list_menu), "menu_abbrev", g_strdup(abbrev));
4760             g_free (prev_abbrev);
4761         }
4762     }
4763
4764     set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/ProtocolPreferences",
4765                              properties);
4766     set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/DecodeAs",
4767                          frame_selected && decode_as_ok());
4768     set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/Copy",
4769                          frame_selected);
4770     set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/ApplyAsFilter",
4771                          frame_selected);
4772     set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/PrepareaFilter",
4773                          frame_selected);
4774     set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/ResolveName",
4775                          frame_selected && (gbl_resolv_flags.mac_name || gbl_resolv_flags.network_name ||
4776                                             gbl_resolv_flags.transport_name));
4777     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/AnalyzeMenu/FollowTCPStream",
4778                          is_tcp);
4779     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/AnalyzeMenu/FollowUDPStream",
4780                          frame_selected ? is_udp : FALSE);
4781     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/AnalyzeMenu/FollowSSLStream",
4782                          frame_selected ? is_ssl : FALSE);
4783     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/AnalyzeMenu/FollowHTTPStream",
4784                          frame_selected ? is_http : FALSE);
4785     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/AnalyzeMenu/DecodeAs",
4786                          frame_selected && decode_as_ok());
4787     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/ViewMenu/NameResolution/ResolveName",
4788                          frame_selected && (gbl_resolv_flags.mac_name || gbl_resolv_flags.network_name ||
4789                                             gbl_resolv_flags.transport_name));
4790     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/ToolsMenu/FirewallACLRules",
4791                          frame_selected);
4792     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/StatisticsMenu/TCPStreamGraphMenu",
4793                          is_tcp);
4794     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/TelephonyMenu/LTEmenu/LTE_RLC_Graph",
4795                          is_lte_rlc);
4796
4797     for (i = 0, conv_filter_list_entry = conv_filter_list;
4798          conv_filter_list_entry != NULL;
4799          conv_filter_list_entry = g_list_next(conv_filter_list_entry), i++) {
4800         conversation_filter_t *filter_entry;
4801         gchar *path;
4802
4803         filter_entry = (conversation_filter_t *)conv_filter_list_entry->data;
4804         path = g_strdup_printf("/Menubar/AnalyzeMenu/ConversationFilterMenu/Filters/filter-%u", i);
4805         set_menu_sensitivity(ui_manager_main_menubar, path,
4806             menu_dissector_filter_spe_cb(/* frame_data *fd _U_*/ NULL, cf->edt, filter_entry));
4807         g_free(path);
4808
4809         path = g_strdup_printf("/PacketListMenuPopup/ConversationFilter/Conversations/color_conversation-%d", i);
4810         set_menu_sensitivity(ui_manager_packet_list_menu, path,
4811             menu_color_dissector_filter_spe_cb(NULL, cf->edt, filter_entry));
4812         g_free(path);
4813
4814         path = g_strdup_printf("/PacketListMenuPopup/ColorizeConversation/Colorize/%s", filter_entry->display_name);
4815         set_menu_sensitivity(ui_manager_packet_list_menu, path,
4816             menu_color_dissector_filter_spe_cb(NULL, cf->edt, filter_entry));
4817         g_free(path);
4818     }
4819 }
4820
4821
4822 static void
4823 menu_prefs_toggle_bool (GtkWidget *w, gpointer data)
4824 {
4825     pref_t *pref = (pref_t*)data;
4826     module_t *module = (module_t *)g_object_get_data (G_OBJECT(w), "module");
4827
4828     module->prefs_changed = TRUE;
4829     prefs_invert_bool_value(pref, pref_current);
4830
4831     prefs_apply (module);
4832     if (!prefs.gui_use_pref_save) {
4833         prefs_main_write();
4834     }
4835     redissect_packets();
4836     redissect_all_packet_windows();
4837 }
4838
4839 static void
4840 menu_prefs_change_enum (GtkWidget *w, gpointer data)
4841 {
4842     pref_t   *pref      = (pref_t*)data;
4843     module_t *module    = (module_t *)g_object_get_data (G_OBJECT(w), "module");
4844     gint      new_value = GPOINTER_TO_INT(g_object_get_data (G_OBJECT(w), "enumval"));
4845
4846     if (!gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM(w)))
4847         return;
4848
4849     if (prefs_set_enum_value(pref, new_value, pref_current)) {
4850         module->prefs_changed = TRUE;
4851
4852         prefs_apply (module);
4853         if (!prefs.gui_use_pref_save) {
4854             prefs_main_write();
4855         }
4856         redissect_packets();
4857         redissect_all_packet_windows();
4858     }
4859 }
4860
4861 void
4862 menu_prefs_reset(void)
4863 {
4864     g_free (g_object_get_data(G_OBJECT(ui_manager_tree_view_menu), "menu_abbrev"));
4865     g_object_set_data(G_OBJECT(ui_manager_tree_view_menu), "menu_abbrev", NULL);
4866 }
4867
4868 static void
4869 menu_prefs_change_ok (GtkWidget *w, gpointer parent_w)
4870 {
4871     GtkWidget   *entry     = (GtkWidget *)g_object_get_data (G_OBJECT(w), "entry");
4872     module_t    *module    = (module_t *)g_object_get_data (G_OBJECT(w), "module");
4873     pref_t      *pref      = (pref_t *)g_object_get_data (G_OBJECT(w), "pref");
4874     const gchar *new_value = gtk_entry_get_text(GTK_ENTRY(entry));
4875     gchar       *p;
4876     guint        uval;
4877
4878     switch (prefs_get_type(pref)) {
4879     case PREF_UINT:
4880         uval = (guint)strtoul(new_value, &p, prefs_get_uint_base(pref));
4881         if (p == new_value || *p != '\0') {
4882             simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
4883                           "The value \"%s\" isn't a valid number.",
4884                           new_value);
4885             return;
4886         }
4887         module->prefs_changed |= prefs_set_uint_value(pref, uval, pref_current);
4888         break;
4889     case PREF_STRING:
4890         module->prefs_changed |= prefs_set_string_value(pref, new_value, pref_current);
4891         break;
4892     case PREF_RANGE:
4893         if (!prefs_set_range_value_work(pref, new_value, TRUE, &module->prefs_changed)) {
4894             simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
4895                           "The value \"%s\" isn't a valid range.",
4896                           new_value);
4897             return;
4898         }
4899         break;
4900     default:
4901         g_assert_not_reached();
4902         break;
4903     }
4904
4905     if (module->prefs_changed) {
4906         /* Ensure we reload the sub menu */
4907         menu_prefs_reset();
4908         prefs_apply (module);
4909         if (!prefs.gui_use_pref_save) {
4910             prefs_main_write();
4911         }
4912         redissect_packets();
4913         redissect_all_packet_windows();
4914     }
4915
4916     window_destroy(GTK_WIDGET(parent_w));
4917 }
4918
4919 static void
4920 menu_prefs_change_cancel (GtkWidget *w _U_, gpointer parent_w)
4921 {
4922     window_destroy(GTK_WIDGET(parent_w));
4923 }
4924
4925 static void
4926 menu_prefs_edit_dlg (GtkWidget *w, gpointer data)
4927 {
4928     pref_t    *pref   = (pref_t *)data;
4929     module_t  *module = (module_t *)g_object_get_data (G_OBJECT(w), "module");
4930     gchar     *value  = NULL, *label_str;
4931
4932     GtkWidget *win, *main_grid, *main_vb, *bbox, *cancel_bt, *ok_bt;
4933     GtkWidget *entry, *label;
4934
4935     value = prefs_pref_to_str(pref, pref_current);
4936
4937     win = dlg_window_new(module->description);
4938
4939     gtk_window_set_resizable(GTK_WINDOW(win),FALSE);
4940     gtk_window_resize(GTK_WINDOW(win), 400, 100);
4941
4942     main_vb = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 5, FALSE);
4943     gtk_container_add(GTK_CONTAINER(win), main_vb);
4944     gtk_container_set_border_width(GTK_CONTAINER(main_vb), 6);
4945
4946     main_grid = ws_gtk_grid_new();
4947     gtk_box_pack_start(GTK_BOX(main_vb), main_grid, FALSE, FALSE, 0);
4948     ws_gtk_grid_set_column_spacing(GTK_GRID(main_grid), 10);
4949
4950     label_str = g_strdup_printf("%s:", prefs_get_title(pref));
4951     label = gtk_label_new(label_str);
4952     g_free(label_str);
4953     ws_gtk_grid_attach_defaults(GTK_GRID(main_grid), label, 0, 1, 1, 1);
4954     gtk_misc_set_alignment(GTK_MISC(label), 1.0f, 0.5f);
4955     if (prefs_get_description(pref))
4956         gtk_widget_set_tooltip_text(label, prefs_get_description(pref));
4957
4958     entry = gtk_entry_new();
4959     ws_gtk_grid_attach_defaults(GTK_GRID(main_grid), entry, 1, 1, 1, 1);
4960     gtk_entry_set_text(GTK_ENTRY(entry), value);
4961     if (prefs_get_description(pref))
4962         gtk_widget_set_tooltip_text(entry, prefs_get_description(pref));
4963
4964     bbox = dlg_button_row_new(GTK_STOCK_CANCEL,GTK_STOCK_OK, NULL);
4965     gtk_box_pack_end(GTK_BOX(main_vb), bbox, FALSE, FALSE, 0);
4966
4967     ok_bt = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), GTK_STOCK_OK);
4968     g_object_set_data (G_OBJECT(ok_bt), "module", module);
4969     g_object_set_data (G_OBJECT(ok_bt), "entry", entry);
4970     g_object_set_data (G_OBJECT(ok_bt), "pref", pref);
4971     g_signal_connect(ok_bt, "clicked", G_CALLBACK(menu_prefs_change_ok), win);
4972
4973     dlg_set_activate(entry, ok_bt);
4974
4975     cancel_bt = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CANCEL);
4976     g_signal_connect(cancel_bt, "clicked", G_CALLBACK(menu_prefs_change_cancel), win);
4977     window_set_cancel_button(win, cancel_bt, NULL);
4978
4979     gtk_widget_grab_default(ok_bt);
4980     gtk_widget_show_all(win);
4981     g_free(value);
4982 }
4983
4984 static guint
4985 add_protocol_prefs_generic_menu(pref_t *pref, gpointer data, GtkUIManager *ui_menu, const char *path)
4986 {
4987     GtkWidget        *menu_preferences;
4988     GtkWidget        *menu_item, *menu_sub_item, *sub_menu;
4989     GSList           *group  = NULL;
4990     module_t         *module = (module_t *)data;
4991     const enum_val_t *enum_valp;
4992     gchar            *label  = NULL, *tmp_str;
4993
4994     switch (prefs_get_type(pref)) {
4995     case PREF_UINT:
4996         switch (prefs_get_uint_base(pref)) {
4997         case 8:
4998             label = g_strdup_printf ("%s: %o", prefs_get_title(pref), prefs_get_uint_value_real(pref, pref_current));
4999             break;
5000         case 10:
5001             label = g_strdup_printf ("%s: %u", prefs_get_title(pref), prefs_get_uint_value_real(pref, pref_current));
5002             break;
5003         case 16:
5004             label = g_strdup_printf ("%s: %x", prefs_get_title(pref), prefs_get_uint_value_real(pref, pref_current));
5005             break;
5006         default:
5007             g_assert_not_reached();
5008             break;
5009         }
5010         menu_item = gtk_menu_item_new_with_label(label);
5011         g_object_set_data (G_OBJECT(menu_item), "module", module);
5012         g_signal_connect(menu_item, "activate", G_CALLBACK(menu_prefs_edit_dlg), pref);
5013         g_free (label);
5014         break;
5015     case PREF_BOOL:
5016         menu_item = gtk_check_menu_item_new_with_label(prefs_get_title(pref));
5017         gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM(menu_item), prefs_get_bool_value(pref, pref_current));
5018         g_object_set_data (G_OBJECT(menu_item), "module", module);
5019         g_signal_connect(menu_item, "activate", G_CALLBACK(menu_prefs_toggle_bool), pref);
5020         break;
5021     case PREF_ENUM:
5022         menu_item = gtk_menu_item_new_with_label(prefs_get_title(pref));
5023         sub_menu = gtk_menu_new();
5024         gtk_menu_item_set_submenu (GTK_MENU_ITEM(menu_item), sub_menu);
5025         enum_valp = prefs_get_enumvals(pref);
5026         while (enum_valp->name != NULL) {
5027             menu_sub_item = gtk_radio_menu_item_new_with_label(group, enum_valp->description);
5028             group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (menu_sub_item));
5029             if (enum_valp->value == prefs_get_enum_value(pref, pref_current)) {
5030                 gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM(menu_sub_item), TRUE);
5031             }
5032             g_object_set_data (G_OBJECT(menu_sub_item), "module", module);
5033             g_object_set_data (G_OBJECT(menu_sub_item), "enumval", GINT_TO_POINTER(enum_valp->value));
5034             g_signal_connect(menu_sub_item, "activate", G_CALLBACK(menu_prefs_change_enum), pref);
5035             gtk_menu_shell_append (GTK_MENU_SHELL(sub_menu), menu_sub_item);
5036             gtk_widget_show (menu_sub_item);
5037             enum_valp++;
5038         }
5039         break;
5040     case PREF_STRING:
5041         label = g_strdup_printf ("%s: %s", prefs_get_title(pref), prefs_get_string_value(pref, pref_current));
5042         menu_item = gtk_menu_item_new_with_label(label);
5043         g_object_set_data (G_OBJECT(menu_item), "module", module);
5044         g_signal_connect(menu_item, "activate", G_CALLBACK(menu_prefs_edit_dlg), pref);
5045         g_free (label);
5046         break;
5047     case PREF_RANGE:
5048         tmp_str = range_convert_range (NULL, prefs_get_range_value_real(pref, pref_current));
5049         label = g_strdup_printf ("%s: %s", prefs_get_title(pref), tmp_str);
5050         wmem_free(NULL, tmp_str);
5051         menu_item = gtk_menu_item_new_with_label(label);
5052         g_object_set_data (G_OBJECT(menu_item), "module", module);
5053         g_signal_connect(menu_item, "activate", G_CALLBACK(menu_prefs_edit_dlg), pref);
5054         g_free (label);
5055         break;
5056     case PREF_UAT:
5057         label = g_strdup_printf ("%s...", prefs_get_title(pref));
5058         menu_item = gtk_menu_item_new_with_label(label);
5059         g_signal_connect (menu_item, "activate", G_CALLBACK(uat_window_cb), prefs_get_uat_value(pref));
5060         g_free (label);
5061         break;
5062
5063     case PREF_COLOR:
5064     case PREF_CUSTOM:
5065         /* currently not supported */
5066
5067     case PREF_STATIC_TEXT:
5068     case PREF_OBSOLETE:
5069     default:
5070         /* Nothing to add */
5071         return 0;
5072     }
5073
5074     menu_preferences = gtk_ui_manager_get_widget(ui_menu, path);
5075     if(!menu_preferences)
5076         g_warning("menu_preferences Not found path");
5077     sub_menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM(menu_preferences));
5078     gtk_menu_shell_append (GTK_MENU_SHELL(sub_menu), menu_item);
5079     gtk_widget_show (menu_item);
5080
5081     return 0;
5082 }
5083
5084 static guint
5085 add_protocol_prefs_menu(pref_t *pref, gpointer data)
5086 {
5087     return add_protocol_prefs_generic_menu(pref, data, ui_manager_tree_view_menu, "/TreeViewPopup/ProtocolPreferences");
5088 }
5089
5090 static guint
5091 add_protocol_prefs_packet_list_menu(pref_t *pref, gpointer data)
5092 {
5093     return add_protocol_prefs_generic_menu(pref, data, ui_manager_packet_list_menu, "/PacketListMenuPopup/ProtocolPreferences");
5094 }
5095
5096
5097 static void
5098 rebuild_protocol_prefs_menu(module_t *prefs_module_p, gboolean preferences,
5099         GtkUIManager *ui_menu, const char *path)
5100 {
5101     GtkWidget *menu_preferences, *menu_item;
5102     GtkWidget *sub_menu;
5103     gchar     *label;
5104
5105     menu_preferences = gtk_ui_manager_get_widget(ui_menu, path);
5106     if (prefs_module_p && preferences) {
5107         sub_menu = gtk_menu_new();
5108         gtk_menu_item_set_submenu (GTK_MENU_ITEM(menu_preferences), sub_menu);
5109
5110         label = g_strdup_printf ("%s Preferences...", prefs_module_p->description);
5111         menu_item = gtk_image_menu_item_new_with_label(label);
5112         gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM(menu_item),
5113                                        ws_gtk_image_new_from_stock(GTK_STOCK_PREFERENCES, GTK_ICON_SIZE_MENU));
5114         gtk_menu_shell_append(GTK_MENU_SHELL(sub_menu), menu_item);
5115         g_signal_connect_swapped(G_OBJECT(menu_item), "activate",
5116                                  G_CALLBACK(properties_cb), (GObject *) menu_item);
5117         gtk_widget_show(menu_item);
5118         g_free(label);
5119
5120         menu_item = gtk_menu_item_new();
5121         gtk_menu_shell_append(GTK_MENU_SHELL(sub_menu), menu_item);
5122         gtk_widget_show(menu_item);
5123
5124         if (ui_menu == ui_manager_tree_view_menu) {
5125             prefs_pref_foreach(prefs_module_p, add_protocol_prefs_menu, prefs_module_p);
5126         } else {
5127             prefs_pref_foreach(prefs_module_p, add_protocol_prefs_packet_list_menu, prefs_module_p);
5128         }
5129     } else {
5130         /* No preferences, remove sub menu */
5131         gtk_menu_item_set_submenu (GTK_MENU_ITEM(menu_preferences), NULL);
5132     }
5133
5134 }
5135
5136 static void
5137 menu_visible_column_toggle (GtkWidget *w _U_, gpointer data)
5138 {
5139     packet_list_toggle_visible_column (GPOINTER_TO_INT(data));
5140 }
5141
5142 void
5143 rebuild_visible_columns_menu (void)
5144 {
5145     GtkWidget *menu_columns[2], *menu_item;
5146     GtkWidget *sub_menu;
5147     GList     *clp;
5148     fmt_data  *cfmt;
5149     gchar     *title;
5150     gint       i, col_id;
5151
5152     menu_columns[0] = gtk_ui_manager_get_widget(ui_manager_main_menubar, "/Menubar/ViewMenu/DisplayedColumns");
5153     if(! menu_columns[0]){
5154         fprintf (stderr, "Warning: couldn't find menu_columns[0] path=/Menubar/ViewMenu/DisplayedColumns");
5155     }
5156     menu_columns[1] = gtk_ui_manager_get_widget(ui_manager_packet_list_heading, "/PacketListHeadingPopup/DisplayedColumns");
5157     /* Debug */
5158     if(! menu_columns[1]){
5159         fprintf (stderr, "Warning: couldn't find menu_columns[1] path=/PacketListHeadingPopup/DisplayedColumns");
5160     }
5161
5162     for (i = 0; i < 2; i++) {
5163         sub_menu = gtk_menu_new();
5164         gtk_menu_item_set_submenu (GTK_MENU_ITEM(menu_columns[i]), sub_menu);
5165
5166         clp = g_list_first (prefs.col_list);
5167         col_id = 0;
5168         while (clp) {
5169             cfmt = (fmt_data *) clp->data;
5170             if (cfmt->title[0]) {
5171                 if (cfmt->fmt == COL_CUSTOM) {
5172                     title = g_strdup_printf ("%s  (%s)", cfmt->title, cfmt->custom_fields);
5173                 } else {
5174                     title = g_strdup_printf ("%s  (%s)", cfmt->title, col_format_desc (cfmt->fmt));
5175                 }
5176             } else {
5177                 if (cfmt->fmt == COL_CUSTOM) {
5178                     title = g_strdup_printf ("(%s)", cfmt->custom_fields);
5179                 } else {
5180                     title = g_strdup_printf ("(%s)", col_format_desc (cfmt->fmt));
5181                 }
5182             }
5183             menu_item = gtk_check_menu_item_new_with_label(title);
5184             g_free (title);
5185             gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM(menu_item), cfmt->visible);
5186             g_signal_connect(menu_item, "activate", G_CALLBACK(menu_visible_column_toggle), GINT_TO_POINTER(col_id));
5187             gtk_menu_shell_append (GTK_MENU_SHELL(sub_menu), menu_item);
5188             gtk_widget_show (menu_item);
5189             clp = g_list_next (clp);
5190             col_id++;
5191         }
5192
5193         menu_item = gtk_separator_menu_item_new();
5194         gtk_menu_shell_append (GTK_MENU_SHELL(sub_menu), menu_item);
5195         gtk_widget_show (menu_item);
5196
5197         menu_item = gtk_menu_item_new_with_label ("Display All");
5198         gtk_menu_shell_append (GTK_MENU_SHELL(sub_menu), menu_item);
5199         g_signal_connect(menu_item, "activate", G_CALLBACK(packet_list_heading_activate_all_columns_cb), NULL);
5200         gtk_widget_show (menu_item);
5201     }
5202 }
5203
5204 void
5205 menus_set_column_resolved (gboolean resolved, gboolean can_resolve)
5206 {
5207     GtkWidget *menu;
5208
5209     menu = gtk_ui_manager_get_widget(ui_manager_packet_list_heading, "/PacketListHeadingPopup/ShowResolved");
5210     if(!menu){
5211         fprintf (stderr, "Warning: couldn't find menu path=/PacketListHeadingPopup/ShowResolved");
5212     }
5213     g_object_set_data(G_OBJECT(menu), "skip-update", (void *)1);
5214     gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), resolved && can_resolve);
5215     set_menu_sensitivity(ui_manager_packet_list_heading, "/PacketListHeadingPopup/ShowResolved", can_resolve);
5216     g_object_set_data(G_OBJECT(menu), "skip-update", NULL);
5217 }
5218
5219 void
5220 menus_set_column_align_default (gboolean right_justify)
5221 {
5222     GtkWidget   *submenu, *menu_item_child;
5223     GList       *child_list, *child_list_item;
5224     const gchar *menu_item_name;
5225     size_t       menu_item_len;
5226
5227     /* get the submenu container item */
5228     submenu = gtk_ui_manager_get_widget (ui_manager_packet_list_heading, "/PacketListHeadingPopup");
5229     if(!submenu){
5230         fprintf (stderr, "Warning: couldn't find submenu path=/PacketListHeadingPopup");
5231     }
5232
5233     /* find the corresponding menu items to update */
5234     child_list = gtk_container_get_children(GTK_CONTAINER(submenu));
5235     child_list_item = child_list;
5236     while (child_list_item) {
5237         menu_item_child = gtk_bin_get_child(GTK_BIN(child_list_item->data));
5238         if (menu_item_child != NULL) {
5239             menu_item_name = gtk_label_get_text(GTK_LABEL(menu_item_child));
5240             menu_item_len = strlen(menu_item_name);
5241             if(strncmp(menu_item_name, "Align Left", 10) == 0) {
5242                 if (!right_justify && menu_item_len == 10) {
5243                     gtk_label_set_text(GTK_LABEL(menu_item_child), "Align Left\t(default)");
5244                 } else if (right_justify && menu_item_len > 10) {
5245                     gtk_label_set_text(GTK_LABEL(menu_item_child), "Align Left");
5246                 }
5247             } else if (strncmp (menu_item_name, "Align Right", 11) == 0) {
5248                 if (right_justify && menu_item_len == 11) {
5249                     gtk_label_set_text(GTK_LABEL(menu_item_child), "Align Right\t(default)");
5250                 } else if (!right_justify && menu_item_len > 11) {
5251                     gtk_label_set_text(GTK_LABEL(menu_item_child), "Align Right");
5252                 }
5253             }
5254         }
5255         child_list_item = g_list_next(child_list_item);
5256     }
5257     g_list_free(child_list);
5258 }
5259
5260 void
5261 set_menus_for_selected_tree_row(capture_file *cf)
5262 {
5263     gboolean properties;
5264     gint     id;
5265
5266     if (cf->finfo_selected != NULL) {
5267         header_field_info *hfinfo = cf->finfo_selected->hfinfo;
5268         const char *abbrev;
5269         char *prev_abbrev;
5270
5271         if (hfinfo->parent == -1) {
5272             abbrev = hfinfo->abbrev;
5273             id = (hfinfo->type == FT_PROTOCOL) ? proto_get_id((protocol_t *)hfinfo->strings) : -1;
5274         } else {
5275             abbrev = proto_registrar_get_abbrev(hfinfo->parent);
5276             id = hfinfo->parent;
5277         }
5278         properties = prefs_is_registered_protocol(abbrev);
5279         set_menu_sensitivity(ui_manager_tree_view_menu,
5280                              "/TreeViewPopup/GotoCorrespondingPacket", hfinfo->type == FT_FRAMENUM);
5281         set_menu_sensitivity(ui_manager_tree_view_menu,
5282                              "/TreeViewPopup/ShowPacketRefinNewWindow", hfinfo->type == FT_FRAMENUM);
5283         set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/Copy",
5284                              TRUE);
5285         set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/Copy/AsFilter",
5286                              proto_can_match_selected(cf->finfo_selected, cf->edt));
5287         set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/ApplyasColumn",
5288                              hfinfo->type != FT_NONE);
5289         set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/ApplyAsFilter",
5290                              proto_can_match_selected(cf->finfo_selected, cf->edt));
5291         set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/PrepareaFilter",
5292                              proto_can_match_selected(cf->finfo_selected, cf->edt));
5293         set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/ColorizewithFilter",
5294                              proto_can_match_selected(cf->finfo_selected, cf->edt));
5295         set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/ProtocolPreferences",
5296                              properties);
5297         set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/DisableProtocol",
5298                              (id == -1) ? FALSE : proto_can_toggle_protocol(id));
5299         set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/ExpandSubtrees",
5300                              cf->finfo_selected->tree_type != -1);
5301         set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/CollapseSubtrees",
5302                              cf->finfo_selected->tree_type != -1);
5303 #ifdef WANT_PACKET_EDITOR
5304         set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/EditPacket",
5305                              prefs.gui_packet_editor ? TRUE : FALSE);
5306 #endif
5307         set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/WikiProtocolPage",
5308                              (id == -1) ? FALSE : TRUE);
5309         set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/FilterFieldReference",
5310                              (id == -1) ? FALSE : TRUE);
5311         set_menu_sensitivity(ui_manager_main_menubar,
5312                              "/Menubar/FileMenu/ExportSelectedPacketBytes", TRUE);
5313         set_menu_sensitivity(ui_manager_main_menubar,
5314                              "/Menubar/GoMenu/GotoCorrespondingPacket", hfinfo->type == FT_FRAMENUM);
5315         set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/EditMenu/Copy/Description",
5316                              proto_can_match_selected(cf->finfo_selected, cf->edt));
5317         set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/EditMenu/Copy/Fieldname",
5318                              proto_can_match_selected(cf->finfo_selected, cf->edt));
5319         set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/EditMenu/Copy/Value",
5320                              proto_can_match_selected(cf->finfo_selected, cf->edt));
5321         set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/EditMenu/Copy/AsFilter",
5322                              proto_can_match_selected(cf->finfo_selected, cf->edt));
5323         set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/AnalyzeMenu/ApplyasColumn",
5324                              hfinfo->type != FT_NONE);
5325         set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/AnalyzeMenu/ApplyAsFilter",
5326                              proto_can_match_selected(cf->finfo_selected, cf->edt));
5327         set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/AnalyzeMenu/PrepareaFilter",
5328                              proto_can_match_selected(cf->finfo_selected, cf->edt));
5329         set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/ViewMenu/ExpandSubtrees",
5330                              cf->finfo_selected->tree_type != -1);
5331         set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/ViewMenu/CollapseSubtrees",
5332                              cf->finfo_selected->tree_type != -1);
5333         prev_abbrev = (char *)g_object_get_data(G_OBJECT(ui_manager_tree_view_menu), "menu_abbrev");
5334         if (!prev_abbrev || (strcmp (prev_abbrev, abbrev) != 0)) {
5335             /* No previous protocol or protocol changed - update Protocol Preferences menu */
5336             module_t *prefs_module_p = prefs_find_module(abbrev);
5337             rebuild_protocol_prefs_menu(prefs_module_p, properties, ui_manager_tree_view_menu, "/TreeViewPopup/ProtocolPreferences");
5338
5339             g_object_set_data(G_OBJECT(ui_manager_tree_view_menu), "menu_abbrev", g_strdup(abbrev));
5340             g_free (prev_abbrev);
5341         }
5342     } else {
5343         set_menu_sensitivity(ui_manager_tree_view_menu,
5344                              "/TreeViewPopup/GotoCorrespondingPacket", FALSE);
5345         set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/Copy", FALSE);
5346         set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/ApplyasColumn", FALSE);
5347         set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/ApplyAsFilter", FALSE);
5348         set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/PrepareaFilter", FALSE);
5349         set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/ColorizewithFilter", FALSE);
5350         set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/ProtocolPreferences",
5351                              FALSE);
5352         set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/DisableProtocol", FALSE);
5353         set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/ExpandSubtrees", FALSE);
5354         set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/CollapseSubtrees", FALSE);
5355         set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/WikiProtocolPage",
5356                              FALSE);
5357         set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/FilterFieldReference",
5358                              FALSE);
5359         set_menu_sensitivity(ui_manager_main_menubar,
5360                              "/Menubar/FileMenu/ExportSelectedPacketBytes", FALSE);
5361         set_menu_sensitivity(ui_manager_main_menubar,
5362                              "/Menubar/GoMenu/GotoCorrespondingPacket", FALSE);
5363         set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/EditMenu/Copy/Description", FALSE);
5364         set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/EditMenu/Copy/Fieldname", FALSE);
5365         set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/EditMenu/Copy/Value", FALSE);
5366         set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/EditMenu/Copy/AsFilter", FALSE);
5367         set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/AnalyzeMenu/ApplyasColumn", FALSE);
5368         set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/AnalyzeMenu/ApplyAsFilter", FALSE);
5369         set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/AnalyzeMenu/PrepareaFilter", FALSE);
5370         set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/ViewMenu/ExpandSubtrees", FALSE);
5371         set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/ViewMenu/CollapseSubtrees", FALSE);
5372     }
5373 }
5374
5375 void set_menus_for_packet_history(gboolean back_history, gboolean forward_history)
5376 {
5377     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/GoMenu/Back", back_history);
5378     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/GoMenu/Forward", forward_history);
5379 }
5380
5381
5382 void set_menus_for_file_set(gboolean file_set, gboolean previous_file, gboolean next_file)
5383 {
5384     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/FileMenu/Set/ListFiles", file_set);
5385     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/FileMenu/Set/PreviousFile", previous_file);
5386     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/FileMenu/Set/NextFile", next_file);
5387 }
5388
5389 GtkWidget *menus_get_profiles_rename_menu (void)
5390 {
5391     return gtk_ui_manager_get_widget(ui_manager_statusbar_profiles_menu, "/ProfilesMenuPopup/Rename");
5392 }
5393
5394 GtkWidget *menus_get_profiles_delete_menu (void)
5395 {
5396     return gtk_ui_manager_get_widget(ui_manager_statusbar_profiles_menu, "/ProfilesMenuPopup/Delete");
5397 }
5398
5399 GtkWidget *menus_get_profiles_change_menu (void)
5400 {
5401     return gtk_ui_manager_get_widget(ui_manager_statusbar_profiles_menu, "/ProfilesMenuPopup/Change");
5402 }
5403
5404 void set_menus_for_profiles(gboolean default_profile)
5405 {
5406     set_menu_sensitivity(ui_manager_statusbar_profiles_menu, "/ProfilesMenuPopup/Rename", !default_profile);
5407     set_menu_sensitivity(ui_manager_statusbar_profiles_menu, "/ProfilesMenuPopup/Delete", !default_profile);
5408 }
5409
5410 static void
5411 ws_menubar_external_cb(GtkAction *action _U_, gpointer data _U_)
5412 {
5413     ext_menubar_t *entry = NULL;
5414     gchar *url = NULL;
5415
5416     if ( data != NULL )
5417     {
5418         entry = (ext_menubar_t *)data;
5419         if ( entry->type == EXT_MENUBAR_ITEM )
5420         {
5421             entry->callback(EXT_MENUBAR_GTK_GUI, (gpointer) ((void *)GTK_WINDOW(top_level)), entry->user_data);
5422         }
5423         else if ( entry->type == EXT_MENUBAR_URL )
5424         {
5425             url = (gchar *)entry->user_data;
5426
5427             if(url != NULL)
5428                 browser_open_url(url);
5429         }
5430     }
5431 }
5432
5433 static void
5434 ws_menubar_create_ui(ext_menu_t * menu, const char * xpath_parent, GtkActionGroup * action_group, gint depth)
5435 {
5436     ext_menubar_t * item = NULL;
5437     GList * children = NULL;
5438     gchar * xpath, * submenu_xpath;
5439     GtkAction * menu_action;
5440     gchar *action_name;
5441     gchar ** paths = NULL;
5442
5443     /* There must exists an xpath parent */
5444     g_assert(xpath_parent != NULL && strlen(xpath_parent) > 0);
5445
5446     /* If the depth counter exceeds, something must have gone wrong */
5447     g_assert(depth < EXT_MENUBAR_MAX_DEPTH);
5448
5449     /* Create a correct xpath, and just keep the necessary action ref [which will be paths [1]] */
5450     xpath = g_strconcat(xpath_parent, menu->name, NULL);
5451
5452     /* Create the action for the menu item and add it to the action group */
5453     action_name = g_strconcat("/", menu->name, NULL);
5454     menu_action = (GtkAction *)g_object_new ( GTK_TYPE_ACTION,
5455             "name", action_name, "label", menu->label, NULL );
5456     g_free(action_name);
5457
5458     gtk_action_group_add_action(action_group, menu_action);
5459     g_object_unref(menu_action);
5460
5461     children = menu->children;
5462
5463     /* Iterate children to create submenus */
5464     while ( children != NULL && children->data != NULL )
5465     {
5466         item = (ext_menubar_t *) children->data;
5467
5468         if ( item->type == EXT_MENUBAR_MENU )
5469         {
5470             /* Handle Submenu entry */
5471             submenu_xpath = g_strconcat(xpath, "/", NULL);
5472             ws_menubar_create_ui(item, submenu_xpath, action_group, depth++);
5473             g_free(submenu_xpath);
5474         }
5475         else if ( item->type != EXT_MENUBAR_SEPARATOR )
5476         {
5477             action_name = g_strconcat("/", item->name, NULL);
5478             menu_action = (GtkAction*) g_object_new( GTK_TYPE_ACTION,
5479                     "name", action_name,
5480                     "label", item->label,
5481                     "tooltip", item->tooltip,
5482                     NULL);
5483             g_signal_connect(menu_action, "activate", G_CALLBACK(ws_menubar_external_cb), item );
5484             gtk_action_group_add_action(action_group, menu_action);
5485             g_object_unref(menu_action);
5486             g_free(action_name);
5487
5488             /* Create the correct action path */
5489             paths = g_strsplit(xpath, "|", -1);
5490
5491             /* Ensures that the above operation has not failed. If this fails, it is a major issue,
5492              * so an assertion is appropriate here */
5493             g_assert(paths != NULL && paths[1] != NULL && strlen(paths[1]) > 0);
5494
5495             /* Handle a menu bar item. This cannot be done by register_menu_bar_menu_items, as it
5496              * will create it's own action group, assuming that the menu actions and submenu actions
5497              * have been pre-registered and globally defined names. This is not the case here. Also
5498              * register_menu_bar_menu_items adds a sorted list, completely destroying any sorting,
5499              * a plugin might have intended */
5500 #if 0
5501             /* Left here as a reminder, that the code below does basically the same */
5502             register_menu_bar_menu_items( g_strdup(paths[1]), item->name, NULL, item->label,
5503                     NULL, item->tooltip, ws_menubar_external_cb, item, TRUE, NULL, NULL);
5504 #endif
5505
5506             /* Creating menu from entry */
5507             add_menu_item_to_main_menubar(g_strdup(paths[1]), item->name, NULL);
5508             g_strfreev(paths);
5509         }
5510
5511         /* Iterate Loop */
5512         children = g_list_next(children);
5513     }
5514
5515     /* Cleanup */
5516     g_free(xpath);
5517 }
5518
5519 static void
5520 ws_menubar_external_menus(void)
5521 {
5522     GList * user_menu = NULL;
5523     ext_menu_t * menu = NULL;
5524     GtkActionGroup  *action_group = NULL;
5525     gchar groupdef[20], * xpath;
5526     guint8 cnt = 1;
5527
5528     user_menu = ext_menubar_get_entries();
5529
5530     while ( ( user_menu != NULL ) && ( user_menu->data != NULL ) )
5531     {
5532         menu = (ext_menu_t *) user_menu->data;
5533
5534         /* On this level only menu items should exist. Not doing an assert here,
5535          * as it could be an honest mistake */
5536         if ( menu->type != EXT_MENUBAR_MENU )
5537         {
5538             user_menu = g_list_next(user_menu);
5539             continue;
5540         }
5541
5542         /* Create unique main actiongroup name */
5543         g_snprintf(groupdef, 20, "UserDefined%02d", cnt);
5544         xpath = g_strconcat( "/MenuBar/", groupdef, "Menu|", NULL );
5545
5546         /* Create an action group per menu */
5547         action_group = gtk_action_group_new(groupdef);
5548
5549         /* Register action structure for each menu */
5550         gtk_ui_manager_insert_action_group(ui_manager_main_menubar, action_group, 0);
5551
5552         /* Now we iterate over the items and add them to the UI. This has to be done after the action
5553          * group for this menu has been added, otherwise the actions will not be found */
5554         ws_menubar_create_ui(menu, xpath, action_group, 0 );
5555
5556         /* Cleanup */
5557         g_free(xpath);
5558         g_object_unref(action_group);
5559
5560         /* Iterate Loop */
5561         user_menu = g_list_next (user_menu);
5562         cnt++;
5563     }
5564 }
5565
5566 void plugin_if_menubar_preference(gconstpointer user_data)
5567 {
5568     if ( user_data != NULL )
5569     {
5570         GHashTable * dataSet = (GHashTable *) user_data;
5571         const char * module_name;
5572         const char * pref_name;
5573         const char * pref_value;
5574         if ( g_hash_table_lookup_extended(dataSet, "pref_module", NULL, (void**)&module_name ) &&
5575                 g_hash_table_lookup_extended(dataSet, "pref_key", NULL, (void**)&pref_name ) &&
5576                 g_hash_table_lookup_extended(dataSet, "pref_value", NULL, (void**)&pref_value ) )
5577         {
5578             if ( prefs_store_ext(module_name, pref_name, pref_value) )
5579             {
5580                 redissect_packets();
5581                 redissect_all_packet_windows();
5582             }
5583         }
5584     }
5585 }
5586
5587 /*
5588  * Editor modelines
5589  *
5590  * Local Variables:
5591  * c-basic-offset: 4
5592  * tab-width: 8
5593  * indent-tabs-mode: nil
5594  * End:
5595  *
5596  * ex: set shiftwidth=4 tabstop=8 expandtab:
5597  * :indentSize=4:tabSize=8:noTabs=true:
5598  */