c6d4041c65e43eaa8cbbd993355696031945f9cf
[obnox/wireshark/wip.git] / gtk / menus.c
1 /* menus.c
2  * Menu routines
3  *
4  * $Id$
5  *
6  * Wireshark - Network traffic analyzer
7  * By Gerald Combs <gerald@wireshark.org>
8  * Copyright 1998 Gerald Combs
9  *
10  * This program is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU General Public License
12  * as published by the Free Software Foundation; either version 2
13  * of the License, or (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
23  */
24
25 #ifdef HAVE_CONFIG_H
26 # include "config.h"
27 #endif
28
29 #include <gtk/gtk.h>
30
31 #include <stdio.h>
32 #include <string.h>
33
34 #include <epan/packet.h>
35 #include <epan/addr_resolv.h>
36 #include <epan/prefs.h>
37 #include <epan/prefs-int.h>
38 #include <epan/tap.h>
39 #include <epan/timestamp.h>
40 #include <epan/etypes.h>
41 #include <epan/ipproto.h>
42 #include <epan/dissector_filters.h>
43 #include <epan/strutil.h>
44 #include <epan/plugins.h>
45 #include <epan/epan_dissect.h>
46 #include <epan/column.h>
47
48 #include "../print.h"
49 #include "../ui_util.h"
50 #include "../simple_dialog.h"
51 #include "../color_filters.h"
52 #include "../stat_menu.h"
53
54 #include "gtk/about_dlg.h"
55 #include "gtk/capture_dlg.h"
56 #include "gtk/capture_if_dlg.h"
57 #include "gtk/color_dlg.h"
58 #include "gtk/filter_dlg.h"
59 #include "gtk/profile_dlg.h"
60 #include "gtk/dlg_utils.h"
61 #include "gtk/capture_file_dlg.h"
62 #include "gtk/fileset_dlg.h"
63 #include "gtk/find_dlg.h"
64 #include "gtk/goto_dlg.h"
65 #include "gtk/summary_dlg.h"
66 #include "gtk/prefs_dlg.h"
67 #include "gtk/packet_win.h"
68 #include "gtk/follow_tcp.h"
69 #include "gtk/follow_udp.h"
70 #include "gtk/follow_ssl.h"
71 #include "gtk/decode_as_dlg.h"
72 #include "gtk/help_dlg.h"
73 #include "gtk/supported_protos_dlg.h"
74 #include "gtk/proto_dlg.h"
75 #include "gtk/proto_hier_stats_dlg.h"
76 #include "gtk/keys.h"
77 #include "gtk/stock_icons.h"
78 #include "gtk/gtkglobals.h"
79 #include "gtk/recent.h"
80 #include "gtk/main_proto_draw.h"
81 #include "gtk/conversations_table.h"
82 #include "gtk/hostlist_table.h"
83 #include "gtk/packet_history.h"
84 #include "gtk/sctp_stat.h"
85 #include "gtk/firewall_dlg.h"
86 #include "gtk/u3.h"
87 #include "gtk/macros_dlg.h"
88 #include "gtk/export_object.h"
89 #include "gtk/gui_stat_menu.h"
90 #include "gtk/main.h"
91 #include "gtk/menus.h"
92 #include "gtk/main_toolbar.h"
93 #include "gtk/main_welcome.h"
94 #include "gtk/uat_gui.h"
95 #include "gtk/gui_utils.h"
96 #include "gtk/manual_addr_resolv.h"
97 #include "gtk/proto_help.h"
98 #include "gtk/dissector_tables_dlg.h"
99 #include "gtk/utf8_entities.h"
100
101 #ifdef NEW_PACKET_LIST
102 #include "gtk/new_packet_list.h"
103 #else
104 #include "gtk/main_packet_list.h"
105 #endif
106
107 #ifdef HAVE_IGE_MAC_INTEGRATION
108 #include <ige-mac-menu.h>
109 #endif
110
111 #ifdef HAVE_GTKOSXAPPLICATION
112 #include <igemacintegration/gtkosxapplication.h>
113 #endif
114
115 typedef struct _menu_item {
116     char    *name;
117     gint    group;
118     const char *stock_id;
119     gboolean enabled;
120     GtkItemFactoryCallback callback;
121     gpointer callback_data;
122     gboolean (*selected_packet_enabled)(frame_data *, epan_dissect_t *, gpointer callback_data);
123     gboolean (*selected_tree_row_enabled)(field_info *, gpointer callback_data);
124     GList *children;
125 } menu_item_t;
126
127 static GList *tap_menu_tree_root = NULL;
128
129 GtkWidget *popup_menu_object;
130
131
132 #define GTK_MENU_FUNC(a) ((GtkItemFactoryCallback)(a))
133
134 static void merge_all_tap_menus(GList *node);
135 static void clear_menu_recent_capture_file_cmd_cb(GtkWidget *w, gpointer unused _U_);
136
137 static void menus_init(void);
138 static void set_menu_sensitivity (GtkUIManager *ui_manager, const gchar *, gint);
139 #ifndef MAIN_MENU_USE_UIMANAGER
140 static void set_menu_sensitivity_old (const gchar *, gint);
141 #endif /* MAIN_MENU_USE_UIMANAGER */
142 static void show_hide_cb(GtkWidget *w, gpointer data, gint action);
143 #ifndef MAIN_MENU_USE_UIMANAGER
144 static void timestamp_format_cb(GtkWidget *w, gpointer d, gint action);
145 static void timestamp_precision_cb(GtkWidget *w, gpointer d, gint action);
146 #endif
147 static void timestamp_seconds_time_cb(GtkWidget *w, gpointer d, gint action);
148 static void name_resolution_cb(GtkWidget *w, gpointer d, gint action);
149 #ifdef HAVE_LIBPCAP
150 #ifndef MAIN_MENU_USE_UIMANAGER
151 static void auto_scroll_live_cb(GtkWidget *w, gpointer d);
152 #endif
153 #endif
154 static void colorize_cb(GtkWidget *w, gpointer d);
155
156
157 /*  As a general GUI guideline, we try to follow the Gnome Human Interface Guidelines, which can be found at:
158     http://developer.gnome.org/projects/gup/hig/1.0/index.html
159
160 Please note: there are some differences between the Gnome HIG menu suggestions and our implementation:
161
162 File/Open Recent:   the Gnome HIG suggests putting the list of recently used files as elements into the File menuitem.
163                     As this is ok for only a few items, this will become unhandy for 10 or even more list entries.
164                     For this reason, we use a submenu for this.
165
166 File/Close:         the Gnome HIG suggests putting this item just above the Quit item.
167                     This results in unintuitive behaviour as both Close and Quit items are very near together.
168                     By putting the Close item near the open item(s), it better suggests that it will close the
169                     currently opened/captured file only.
170 */
171
172 typedef enum {
173     SHOW_HIDE_MAIN_TOOLBAR = 1,
174     SHOW_HIDE_FILTER_TOOLBAR,
175     SHOW_HIDE_AIRPCAP_TOOLBAR,
176     SHOW_HIDE_STATUSBAR,
177     SHOW_HIDE_PACKET_LIST,
178     SHOW_HIDE_TREE_VIEW,
179     SHOW_HIDE_BYTE_VIEW
180 } show_hide_values_e;
181
182 typedef enum {
183     CONV_ETHER = 1,
184     CONV_IP,
185     CONV_TCP,
186     CONV_UDP,
187     CONV_CBA
188 } conv_values_e;
189
190 static char *
191 build_conversation_filter(int action, gboolean show_dialog)
192 {
193     packet_info *pi = &cfile.edt->pi;
194     char        *buf;
195
196
197     switch(action) {
198     case(CONV_CBA):
199         if (pi->profinet_type == 0) {
200             if (show_dialog) {
201                 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
202                     "Error filtering conversation.  Please make\n"
203                     "sure you have a PROFINET CBA packet selected.");
204             }
205             return NULL;
206         }
207
208         if( pi->net_src.type == AT_IPv4 && pi->net_dst.type == AT_IPv4
209         && pi->ipproto == IP_PROTO_TCP ) {
210             /* IPv4 */
211             switch(pi->profinet_type) {
212             case(1):
213                 buf = g_strdup_printf("(ip.src eq %s and ip.dst eq %s and cba.acco.dcom == 1) || (ip.src eq %s and ip.dst eq %s and cba.acco.dcom == 0)",
214                     ip_to_str( pi->net_dst.data),
215                     ip_to_str( pi->net_src.data),
216                     ip_to_str( pi->net_src.data),
217                     ip_to_str( pi->net_dst.data));
218                 break;
219             case(2):
220                 buf = g_strdup_printf("(ip.src eq %s and ip.dst eq %s and cba.acco.dcom == 1) || (ip.src eq %s and ip.dst eq %s and cba.acco.dcom == 0)",
221                     ip_to_str( pi->net_src.data),
222                     ip_to_str( pi->net_dst.data),
223                     ip_to_str( pi->net_dst.data),
224                     ip_to_str( pi->net_src.data));
225                 break;
226             case(3):
227                 buf = g_strdup_printf("(ip.src eq %s and ip.dst eq %s and cba.acco.srt == 1) || (ip.src eq %s and ip.dst eq %s and cba.acco.srt == 0)",
228                     ip_to_str( pi->net_dst.data),
229                     ip_to_str( pi->net_src.data),
230                     ip_to_str( pi->net_src.data),
231                     ip_to_str( pi->net_dst.data));
232                 break;
233             case(4):
234                 buf = g_strdup_printf("(ip.src eq %s and ip.dst eq %s and cba.acco.srt == 1) || (ip.src eq %s and ip.dst eq %s and cba.acco.srt == 0)",
235                     ip_to_str( pi->net_src.data),
236                     ip_to_str( pi->net_dst.data),
237                     ip_to_str( pi->net_dst.data),
238                     ip_to_str( pi->net_src.data));
239                 break;
240             default:
241                 return NULL;
242             }
243         } else {
244             return NULL;
245         }
246         break;
247     case(CONV_TCP):
248         if (pi->ipproto != IP_PROTO_TCP) {
249             if (show_dialog) {
250                 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
251                     "Error filtering conversation.  Please make\n"
252                     "sure you have a TCP packet selected.");
253             }
254             return NULL;
255         }
256
257         if( pi->net_src.type == AT_IPv4 && pi->net_dst.type == AT_IPv4 ) {
258             /* TCP over IPv4 */
259             buf = g_strdup_printf("(ip.addr eq %s and ip.addr eq %s) and (tcp.port eq %d and tcp.port eq %d)",
260                 ip_to_str( pi->net_src.data),
261                 ip_to_str( pi->net_dst.data),
262                 pi->srcport, pi->destport );
263         } else if( pi->net_src.type == AT_IPv6 && pi->net_dst.type == AT_IPv6 ) {
264             /* TCP over IPv6 */
265             buf = g_strdup_printf("(ipv6.addr eq %s and ipv6.addr eq %s) and (tcp.port eq %d and tcp.port eq %d)",
266                 ip6_to_str((const struct e_in6_addr *)pi->net_src.data),
267                 ip6_to_str((const struct e_in6_addr *)pi->net_dst.data),
268                 pi->srcport, pi->destport );
269         } else {
270             return NULL;
271         }
272         break;
273     case(CONV_UDP):
274         if (pi->ipproto != IP_PROTO_UDP) {
275             if (show_dialog) {
276                 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
277                     "Error filtering conversation.  Please make\n"
278                     "sure you have a UDP packet selected.");
279             }
280             return NULL;
281         }
282
283         if( pi->net_src.type == AT_IPv4 && pi->net_dst.type == AT_IPv4 ) {
284             /* UDP over IPv4 */
285             buf = g_strdup_printf("(ip.addr eq %s and ip.addr eq %s) and (udp.port eq %d and udp.port eq %d)",
286                 ip_to_str( pi->net_src.data),
287                 ip_to_str( pi->net_dst.data),
288                 pi->srcport, pi->destport );
289         } else if( pi->net_src.type == AT_IPv6 && pi->net_dst.type == AT_IPv6 ) {
290             /* UDP over IPv6 */
291             buf = g_strdup_printf("(ipv6.addr eq %s and ipv6.addr eq %s) and (udp.port eq %d and udp.port eq %d)",
292                 ip6_to_str((const struct e_in6_addr *)pi->net_src.data),
293                 ip6_to_str((const struct e_in6_addr *)pi->net_dst.data),
294                 pi->srcport, pi->destport );
295         } else {
296             return NULL;
297         }
298         break;
299     case(CONV_IP):
300         if ((pi->ethertype != ETHERTYPE_IP) && (pi->ethertype != ETHERTYPE_IPv6)) {
301             if (show_dialog) {
302                 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
303                     "Error filtering conversation.  Please make\n"
304                     "sure you have a IP packet selected.");
305             }
306             return NULL;
307         }
308
309         if( pi->net_src.type == AT_IPv4 && pi->net_dst.type == AT_IPv4 ) {
310             /* IPv4 */
311             buf = g_strdup_printf("ip.addr eq %s and ip.addr eq %s",
312                 ip_to_str( pi->net_src.data),
313                 ip_to_str( pi->net_dst.data));
314         } else if( pi->net_src.type == AT_IPv6 && pi->net_dst.type == AT_IPv6 ) {
315             /* IPv6 */
316             buf = g_strdup_printf("ipv6.addr eq %s and ipv6.addr eq %s",
317                 ip6_to_str((const struct e_in6_addr *)pi->net_src.data),
318                 ip6_to_str((const struct e_in6_addr *)pi->net_dst.data));
319         } else {
320             return NULL;
321         }
322         break;
323     case(CONV_ETHER):
324         /* XXX - is this the right way to check for Ethernet? */
325         /* check for the data link address type */
326         /* (ethertype will be 0 when used as length field) */
327         if (pi->dl_src.type != AT_ETHER) {
328             if (show_dialog) {
329                 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
330                     "Error filtering conversation.  Please make\n"
331                     "sure you have a Ethernet packet selected.");
332             }
333             return NULL;
334         }
335
336         if( pi->dl_src.type == AT_ETHER && pi->dl_dst.type == AT_ETHER ) {
337             /* Ethernet */
338             buf = g_strdup_printf("eth.addr eq %s and eth.addr eq %s",
339                 ether_to_str( pi->dl_src.data),
340                 ether_to_str( pi->dl_dst.data));
341         } else {
342             return NULL;
343         }
344         break;
345     default:
346         return NULL;
347     }
348
349     return buf;
350 }
351
352 void
353 conversation_cb(GtkWidget * w, gpointer data _U_, int action)
354 {
355     gchar       *filter;
356     GtkWidget   *filter_te;
357
358     if (cfile.current_frame) {
359         /* create a filter-string based on the selected packet and action */
360         filter = build_conversation_filter(action, TRUE);
361
362         /* Run the display filter so it goes in effect - even if it's the
363         same as the previous display filter. */
364         filter_te = g_object_get_data(G_OBJECT(w), E_DFILTER_TE_KEY);
365         gtk_entry_set_text(GTK_ENTRY(filter_te), filter);
366         main_filter_packets(&cfile, filter, TRUE);
367
368         g_free(filter);
369     }
370 }
371
372 void
373 colorize_conversation_cb(GtkWidget * w _U_, gpointer data _U_, int action)
374 {
375     gchar        *filter = NULL;
376
377     if( (action>>8) == 255 ) {
378         color_filters_reset_tmp();
379 #ifdef NEW_PACKET_LIST
380         new_packet_list_colorize_packets();
381 #else
382         cf_colorize_packets(&cfile);
383 #endif
384     } else if (cfile.current_frame) {
385         if( (action&0xff) == 0 ) {
386             /* colorize_conversation_cb was called from the window-menu
387              * or through an accelerator key. Try to build a conversation
388              * filter in the order TCP, UDP, IP, Ethernet and apply the
389              * coloring */
390             filter = build_conversation_filter(CONV_TCP,FALSE);
391             if( filter == NULL )
392                 filter = build_conversation_filter(CONV_UDP,FALSE);
393             if( filter == NULL )
394                 filter = build_conversation_filter(CONV_IP,FALSE);
395             if( filter == NULL )
396                 filter = build_conversation_filter(CONV_ETHER,FALSE);
397             if( filter == NULL ) {
398                 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "Unable to build conversation filter.");
399                 return;
400             }
401         } else {
402             /* create a filter-string based on the selected packet and action */
403             filter = build_conversation_filter(action&0xff, TRUE);
404         }
405
406         if( (action>>8) == 0) {
407             /* Open the "new coloring filter" dialog with the filter */
408             color_display_with_filter(filter);
409         } else {
410             /* Set one of the temporary coloring filters */
411             color_filters_set_tmp((guint8)(action>>8),filter,FALSE);
412 #ifdef NEW_PACKET_LIST
413             new_packet_list_colorize_packets();
414 #else
415             cf_colorize_packets(&cfile);
416 #endif
417         }
418
419         g_free(filter);
420     }
421 }
422
423 void
424 goto_conversation_frame(gboolean dir)
425 {
426         gchar *filter;
427         dfilter_t *dfcode = NULL;
428         gboolean found_packet=FALSE;
429
430         filter = build_conversation_filter(CONV_TCP,FALSE);
431         if( filter == NULL )
432             filter = build_conversation_filter(CONV_UDP,FALSE);
433         if( filter == NULL )
434             filter = build_conversation_filter(CONV_IP,FALSE);
435         if( filter == NULL ) {
436             simple_status("Unable to build conversation filter.");
437             g_free(filter);
438             return;
439         }
440
441         if (!dfilter_compile(filter, &dfcode)) {
442             /* The attempt failed; report an error. */
443             simple_status("Error compiling filter for this conversation.");
444             g_free(filter);
445             return;
446         }
447
448         found_packet = cf_find_packet_dfilter(&cfile, dfcode, dir);
449
450         if (!found_packet) {
451             /* We didn't find a packet */
452             simple_status("No previous/next packet in conversation.");
453         }
454
455         dfilter_free(dfcode);
456         g_free(filter);
457 }
458
459 void
460 goto_next_frame_conversation_cb(GtkWidget *w _U_, gpointer d _U_)
461 {
462     goto_conversation_frame(FALSE);
463 }
464
465 void
466 goto_previous_frame_conversation_cb(GtkWidget *w _U_, gpointer d _U_)
467 {
468     goto_conversation_frame(TRUE);
469 }
470
471 /*Apply a filter */
472
473 static void
474 tree_view_menu_apply_selected_cb(GtkWidget *widget, gpointer user_data)
475 {
476         match_selected_ptree_cb( widget , user_data, MATCH_SELECTED_REPLACE|MATCH_SELECTED_APPLY_NOW);
477 }
478
479 static void
480 tree_view_menu_apply_not_selected_cb(GtkWidget *widget, gpointer user_data)
481 {
482         match_selected_ptree_cb( widget , user_data, MATCH_SELECTED_NOT|MATCH_SELECTED_APPLY_NOW);
483 }
484
485 static void
486 tree_view_menu_apply_and_selected_cb(GtkWidget *widget, gpointer user_data)
487 {
488         match_selected_ptree_cb( widget , user_data, MATCH_SELECTED_AND|MATCH_SELECTED_APPLY_NOW);
489 }
490
491 static void
492 tree_view_menu_apply_or_selected_cb(GtkWidget *widget, gpointer user_data)
493 {
494         match_selected_ptree_cb( widget , user_data, MATCH_SELECTED_OR|MATCH_SELECTED_APPLY_NOW);
495 }
496
497 static void
498 tree_view_menu_apply_and_not_selected_cb(GtkWidget *widget, gpointer user_data)
499 {
500         match_selected_ptree_cb( widget , user_data, MATCH_SELECTED_AND_NOT|MATCH_SELECTED_APPLY_NOW);
501 }
502
503 static void
504 tree_view_menu_apply_or_not_selected_cb(GtkWidget *widget, gpointer user_data)
505 {
506         match_selected_ptree_cb( widget , user_data,MATCH_SELECTED_OR_NOT|MATCH_SELECTED_APPLY_NOW);
507 }
508 /* Prepare a filter */
509 static void
510 tree_view_menu_prepare_selected_cb(GtkWidget *widget, gpointer user_data)
511 {
512         match_selected_ptree_cb( widget , user_data, MATCH_SELECTED_REPLACE);
513 }
514
515 static void
516 tree_view_menu_prepare_not_selected_cb(GtkWidget *widget, gpointer user_data)
517 {
518         match_selected_ptree_cb( widget , user_data, MATCH_SELECTED_NOT);
519 }
520
521 static void
522 tree_view_menu_prepare_and_selected_cb(GtkWidget *widget, gpointer user_data)
523 {
524         match_selected_ptree_cb( widget , user_data, MATCH_SELECTED_AND);
525 }
526
527 static void
528 tree_view_menu_prepare_or_selected_cb(GtkWidget *widget, gpointer user_data)
529 {
530         match_selected_ptree_cb( widget , user_data, MATCH_SELECTED_OR);
531 }
532
533 static void
534 tree_view_menu_prepare_and_not_selected_cb(GtkWidget *widget, gpointer user_data)
535 {
536         match_selected_ptree_cb( widget , user_data, MATCH_SELECTED_AND_NOT);
537 }
538
539 static void
540 tree_view_menu_prepare_or_not_selected_cb(GtkWidget *widget, gpointer user_data)
541 {
542         match_selected_ptree_cb( widget , user_data, MATCH_SELECTED_OR_NOT);
543 }
544
545 #ifdef MAIN_MENU_USE_UIMANAGER 
546 /* Prepare for use of GTKUImanager */
547 GtkUIManager *ui_manager_main_menubar = NULL;
548 guint merge_id = 0;
549
550 static void
551 copy_description_cb(GtkWidget *widget, gpointer user_data)
552 {
553         copy_selected_plist_cb( widget , user_data, COPY_SELECTED_DESCRIPTION);
554 }
555
556 static void
557 copy_fieldname_cb(GtkWidget *widget, gpointer user_data)
558 {
559         copy_selected_plist_cb( widget , user_data, COPY_SELECTED_FIELDNAME);
560 }
561
562 static void
563 copy_value_cb(GtkWidget *widget, gpointer user_data)
564 {
565         copy_selected_plist_cb( widget , user_data, COPY_SELECTED_VALUE);
566 }
567
568 static void
569 copy_as_filter_cb(GtkWidget *widget, gpointer user_data)
570 {
571         match_selected_ptree_cb( widget , user_data, MATCH_SELECTED_REPLACE|MATCH_SELECTED_COPY_ONLY);
572 }
573
574 static void
575 set_reftime_cb(GtkWidget *widget, gpointer user_data)
576 {
577         reftime_frame_cb( widget , user_data, REFTIME_TOGGLE);
578 }
579
580 static void
581 find_next_ref_time_cb(GtkWidget *widget, gpointer user_data)
582 {
583         reftime_frame_cb( widget , user_data, REFTIME_FIND_NEXT);
584 }
585
586 static void
587 find_previous_ref_time_cb(GtkWidget *widget, gpointer user_data)
588 {
589         reftime_frame_cb( widget , user_data, REFTIME_FIND_PREV);
590 }
591
592 static void
593 menus_prefs_cb(GtkWidget *widget, gpointer user_data)
594 {
595         prefs_page_cb( widget , user_data, PREFS_PAGE_USER_INTERFACE);
596 }
597
598 static void
599 main_toolbar_show_hide_cb(GtkAction *action _U_, gpointer user_data)
600 {
601         GtkWidget *widget = gtk_ui_manager_get_widget(ui_manager_main_menubar, "/Menubar/ViewMenu/MainToolbar");
602
603         if (!widget){
604                 g_warning("main_toolbar_show_hide_cb: No widget found");
605         }else{
606                 show_hide_cb( widget, user_data, SHOW_HIDE_MAIN_TOOLBAR);
607         }
608 }
609
610 static void
611 filter_toolbar_show_hide_cb(GtkAction * action _U_, gpointer user_data)
612 {
613         GtkWidget *widget = gtk_ui_manager_get_widget(ui_manager_main_menubar, "/Menubar/ViewMenu/FilterToolbar");
614         if (!widget){
615                 g_warning("filter_toolbar_show_hide_cb: No widget found");
616         }else{
617                 show_hide_cb( widget, user_data, SHOW_HIDE_FILTER_TOOLBAR);
618         }
619 }
620
621 #ifdef HAVE_AIRPCAP
622 static void
623 wireless_toolbar_show_hide_cb(GtkAction *action _U_, gpointer user_data)
624 {
625         GtkWidget *widget = gtk_ui_manager_get_widget(ui_manager_main_menubar, "/Menubar/ViewMenu/WirelessToolbar");
626         if (!widget){
627                 g_warning("wireless_toolbar_show_hide_cb: No widget found");
628         }else{
629                 show_hide_cb( widget, user_data, SHOW_HIDE_AIRPCAP_TOOLBAR);
630         }
631 }
632 #endif /* HAVE_AIRPCAP */
633
634 static void
635 status_bar_show_hide_cb(GtkAction *action _U_, gpointer user_data)
636 {
637         GtkWidget *widget = gtk_ui_manager_get_widget(ui_manager_main_menubar, "/Menubar/ViewMenu/Statusbar");
638         if (!widget){
639                 g_warning("status_bar_show_hide_cb: No widget found");
640         }else{
641                 show_hide_cb( widget, user_data, SHOW_HIDE_STATUSBAR);
642         }
643 }
644 static void
645 packet_list_show_hide_cb(GtkAction *action _U_, gpointer user_data)
646 {
647         GtkWidget *widget = gtk_ui_manager_get_widget(ui_manager_main_menubar, "/Menubar/ViewMenu/PacketList");
648         if (!widget){
649                 g_warning("packet_list_show_hide_cb: No widget found");
650         }else{
651                 show_hide_cb( widget, user_data, SHOW_HIDE_PACKET_LIST);
652         }
653 }
654 static void
655 packet_details_show_hide_cb(GtkAction *action _U_, gpointer user_data)
656 {
657         GtkWidget *widget = gtk_ui_manager_get_widget(ui_manager_main_menubar, "/Menubar/ViewMenu/PacketDetails");
658         if (!widget){
659                 g_warning("packet_details_show_hide_cb: No widget found");
660         }else{
661                 show_hide_cb( widget, user_data, SHOW_HIDE_TREE_VIEW);
662         }
663 }
664 static void
665 packet_bytes_show_hide_cb(GtkAction *action _U_, gpointer user_data)
666 {
667         GtkWidget *widget = gtk_ui_manager_get_widget(ui_manager_main_menubar, "/Menubar/ViewMenu/PacketBytes");
668         if (!widget){
669                 g_warning("packet_bytes_show_hide_cb: No widget found");
670         }else{
671                 show_hide_cb( widget, user_data, SHOW_HIDE_BYTE_VIEW);
672         }
673 }
674
675 static void
676 timestamp_format_new_cb (GtkRadioAction *action, GtkRadioAction *current _U_, gpointer user_data  _U_)
677 {
678     gint value;
679
680     value = gtk_radio_action_get_current_value (action);
681     g_warning("timestamp_format_new_cb, value %u, recent.gui_time_format %u",value, recent.gui_time_format);
682     if (recent.gui_time_format != value) {
683         timestamp_set_type(value);
684         recent.gui_time_format = value;
685 #ifdef NEW_PACKET_LIST
686         /* This call adjusts column width */
687         cf_timestamp_auto_precision(&cfile);
688         new_packet_list_queue_draw();
689 #else
690         cf_change_time_formats(&cfile);
691 #endif
692     }
693
694 }
695
696 static void
697 timestamp_precision_new_cb (GtkRadioAction *action, GtkRadioAction *current _U_, gpointer user_data _U_)
698 {
699     gint value;
700
701     value = gtk_radio_action_get_current_value (action);
702     g_warning("timestamp_precision_new_cb, value %u, recent.gui_time_precision %u",value, recent.gui_time_precision);
703     if (recent.gui_time_precision != value) {
704         /* the actual precision will be set in cf_change_time_formats() below */
705         if (value == TS_PREC_AUTO) {
706             timestamp_set_precision(TS_PREC_AUTO_SEC);
707         } else {
708             timestamp_set_precision(value);
709         }
710         recent.gui_time_precision  = value;
711 #ifdef NEW_PACKET_LIST
712         /* This call adjusts column width */
713         cf_timestamp_auto_precision(&cfile);
714         new_packet_list_queue_draw();
715 #else
716         cf_change_time_formats(&cfile);
717 #endif
718     }
719 }
720
721
722 static void
723 view_menu_seconds_time_cb(GtkAction *action _U_, gpointer user_data)
724 {
725         GtkWidget *widget = gtk_ui_manager_get_widget(ui_manager_main_menubar, "/Menubar/ViewMenu/TimeDisplayFormat/DisplaySecondsWithHoursAndMinutes");
726         if (!widget){
727                 g_warning("view_menu_seconds_time_cb: No widget found");
728         }else{
729                 timestamp_seconds_time_cb(widget, user_data, 0);
730         }
731 }
732
733 static void
734 view_menu_en_for_MAC_cb(GtkAction *action _U_, gpointer user_data)
735 {
736         GtkWidget *widget = gtk_ui_manager_get_widget(ui_manager_main_menubar, "/Menubar/ViewMenu/NameResolution/EnableforMACLayer");
737         if (!widget){
738                 g_warning("view_menu_en_for_MAC_cb: No widget found");
739         }else{
740                 name_resolution_cb( widget , user_data, RESOLV_MAC);
741         }
742 }
743
744 static void
745 view_menu_en_for_network_cb(GtkAction *action _U_, gpointer user_data)
746 {
747         GtkWidget *widget = gtk_ui_manager_get_widget(ui_manager_main_menubar, "/Menubar/ViewMenu/NameResolution/EnableforNetworkLayer");
748         if (!widget){
749                 g_warning("view_menu_en_for_network_cb: No widget found");
750         }else{
751                 name_resolution_cb( widget , user_data, RESOLV_NETWORK);
752         }
753 }
754
755 static void
756 view_menu_en_for_transport_cb(GtkAction *action _U_, gpointer user_data)
757 {
758         GtkWidget *widget = gtk_ui_manager_get_widget(ui_manager_main_menubar, "/Menubar/ViewMenu/NameResolution/EnableforTransportLayer");
759         if (!widget){
760                 g_warning("view_menu_en_for_transport_cb: No widget found");
761         }else{
762                 name_resolution_cb( widget , user_data, RESOLV_TRANSPORT);
763         }
764 }
765
766 static void
767 view_menu_colorize_pkt_lst_cb(GtkAction *action _U_, gpointer user_data)
768 {
769         GtkWidget *widget = gtk_ui_manager_get_widget(ui_manager_main_menubar, "/Menubar/ViewMenu/ColorizePacketList");
770         if (!widget){
771                 g_warning("view_menu_colorize_pkt_lst_cb: No widget found");
772         }else{
773                 colorize_cb( widget , user_data);
774         }
775
776 }
777
778 static void
779 view_menu_colorize_auto_scroll_live_cb(GtkAction *action _U_, gpointer user_data _U_)
780 {
781         GtkWidget *widget = gtk_ui_manager_get_widget(ui_manager_main_menubar, "/Menubar/ViewMenu/AutoScrollinLiveCapture");
782
783         if (!widget){
784                 g_warning("view_menu_colorize_auto_scroll_live_cb: No widget found");
785         }else{
786                 menu_auto_scroll_live_changed(GTK_CHECK_MENU_ITEM(widget)->active);
787         }
788 }
789
790 static void
791 view_menu_color_conv_color1_cb(GtkWidget *widget, gpointer user_data)
792 {
793         colorize_conversation_cb( widget , user_data, 1*256);
794
795 }
796
797 static void
798 view_menu_color_conv_color2_cb(GtkWidget *widget, gpointer user_data)
799 {
800         colorize_conversation_cb( widget , user_data, 2*256);
801
802 }
803 static void
804 view_menu_color_conv_color3_cb(GtkWidget *widget, gpointer user_data)
805 {
806         colorize_conversation_cb( widget , user_data, 3*256);
807
808 }
809 static void
810 view_menu_color_conv_color4_cb(GtkWidget *widget, gpointer user_data)
811 {
812         colorize_conversation_cb( widget , user_data, 4*256);
813
814 }
815 static void
816 view_menu_color_conv_color5_cb(GtkWidget *widget, gpointer user_data)
817 {
818         colorize_conversation_cb( widget , user_data, 5*256);
819
820 }
821 static void
822 view_menu_color_conv_color6_cb(GtkWidget *widget, gpointer user_data)
823 {
824         colorize_conversation_cb( widget , user_data, 6*256);
825
826 }
827 static void
828 view_menu_color_conv_color7_cb(GtkWidget *widget, gpointer user_data)
829 {
830         colorize_conversation_cb( widget , user_data, 7*256);
831
832 }
833 static void
834 view_menu_color_conv_color8_cb(GtkWidget *widget, gpointer user_data)
835 {
836         colorize_conversation_cb( widget , user_data, 8*256);
837
838 }
839 static void
840 view_menu_color_conv_color9_cb(GtkWidget *widget, gpointer user_data)
841 {
842         colorize_conversation_cb( widget , user_data, 9*256);
843
844 }
845 static void
846 view_menu_color_conv_color10_cb(GtkWidget *widget, gpointer user_data)
847 {
848         colorize_conversation_cb( widget , user_data, 10*256);
849
850 }
851
852 static void
853 view_menu_color_conv_new_rule_cb(GtkWidget *widget, gpointer user_data)
854 {
855         colorize_conversation_cb( widget , user_data, 0);
856
857 }
858
859 static void
860 view_menu_reset_coloring_cb(GtkWidget *widget, gpointer user_data)
861 {
862         colorize_conversation_cb( widget , user_data, 255*256);
863
864 }
865
866 static void
867 help_menu_cont_cb(GtkWidget *widget, gpointer user_data _U_)
868 {
869         topic_menu_cb(widget/* _U_ */, NULL /*GdkEventButton *event _U_*/, GINT_TO_POINTER(HELP_CONTENT));
870 }
871
872 static void
873 help_menu_faq_cb(GtkWidget *widget, gpointer user_data _U_)
874 {
875         topic_menu_cb(widget/* _U_ */, NULL /*GdkEventButton *event _U_*/, GINT_TO_POINTER(ONLINEPAGE_FAQ));
876 }
877
878 static void
879 help_menu_wireshark_cb(GtkWidget *widget, gpointer user_data _U_)
880 {
881         topic_menu_cb(widget/* _U_ */, NULL /*GdkEventButton *event _U_*/, GINT_TO_POINTER(LOCALPAGE_MAN_WIRESHARK));
882 }
883
884 static void
885 help_menu_wireshark_flt_cb(GtkWidget *widget, gpointer user_data _U_)
886 {
887         topic_menu_cb(widget/* _U_ */, NULL /*GdkEventButton *event _U_*/, GINT_TO_POINTER(LOCALPAGE_MAN_WIRESHARK_FILTER)); 
888 }
889
890 static void
891 help_menu_Tshark_cb(GtkWidget *widget, gpointer user_data _U_)
892 {
893         topic_menu_cb(widget/* _U_ */, NULL /*GdkEventButton *event _U_*/, GINT_TO_POINTER(LOCALPAGE_MAN_TSHARK)); 
894 }
895
896 static void
897 help_menu_RawShark_cb(GtkWidget *widget, gpointer user_data _U_)
898 {
899         topic_menu_cb(widget/* _U_ */, NULL /*GdkEventButton *event _U_*/, GINT_TO_POINTER(LOCALPAGE_MAN_RAWSHARK));  
900 }
901
902 static void
903 help_menu_Dumpcap_cb(GtkWidget *widget, gpointer user_data _U_)
904 {
905         topic_menu_cb(widget/* _U_ */, NULL /*GdkEventButton *event _U_*/, GINT_TO_POINTER(LOCALPAGE_MAN_DUMPCAP));   
906 }
907
908 static void
909 help_menu_Mergecap_cb(GtkWidget *widget, gpointer user_data _U_)
910 {
911         topic_menu_cb(widget/* _U_ */, NULL /*GdkEventButton *event _U_*/, GINT_TO_POINTER(LOCALPAGE_MAN_MERGECAP));   
912 }
913
914 static void
915 help_menu_Editcap_cb(GtkWidget *widget, gpointer user_data _U_)
916 {
917         topic_menu_cb(widget/* _U_ */, NULL /*GdkEventButton *event _U_*/, GINT_TO_POINTER(LOCALPAGE_MAN_EDITCAP));   
918 }
919
920 static void
921 help_menu_Text2pcap_cb(GtkWidget *widget, gpointer user_data _U_)
922 {
923         topic_menu_cb(widget/* _U_ */, NULL /*GdkEventButton *event _U_*/, GINT_TO_POINTER(LOCALPAGE_MAN_TEXT2PCAP));   
924 }
925
926 static void
927 help_menu_Website_cb(GtkWidget *widget, gpointer user_data _U_)
928 {
929         topic_menu_cb(widget/* _U_ */, NULL /*GdkEventButton *event _U_*/, GINT_TO_POINTER(ONLINEPAGE_HOME));   
930 }
931
932 static void
933 help_menu_Wiki_cb(GtkWidget *widget, gpointer user_data _U_)
934 {
935         topic_menu_cb(widget/* _U_ */, NULL /*GdkEventButton *event _U_*/, GINT_TO_POINTER(ONLINEPAGE_WIKI));   
936 }
937
938 static void
939 help_menu_Downloads_cb(GtkWidget *widget, gpointer user_data _U_)
940 {
941         topic_menu_cb(widget/* _U_ */, NULL /*GdkEventButton *event _U_*/, GINT_TO_POINTER(ONLINEPAGE_DOWNLOAD));   
942 }
943
944 static void
945 help_menu_SampleCaptures_cb(GtkWidget *widget, gpointer user_data _U_)
946 {
947         topic_menu_cb(widget/* _U_ */, NULL /*GdkEventButton *event _U_*/, GINT_TO_POINTER(ONLINEPAGE_SAMPLE_FILES));   
948 }
949
950 static const char *ui_desc_menubar =
951 "<ui>\n"
952 "  <menubar name ='Menubar'>\n"
953 "    <menu name= 'FileMenu' action='/File'>\n"
954 "      <menuitem name='Open' action='/File/Open'/>\n"
955 "      <menuitem name='OpenRecent' action='/File/OpenRecent'/>\n"
956 "      <menuitem name='Merge' action='/File/Merge'/>\n"
957 "      <menuitem name='Close' action='/File/Close'/>\n"
958 "      <separator/>\n"
959 "      <menuitem name='Save' action='/File/Save'/>\n"
960 "      <menuitem name='SaveAs' action='/File/SaveAs'/>\n"
961 "      <separator/>\n"
962 "      <menu name= 'Set' action='/File/Set'>\n"
963 "        <menuitem name='ListFiles' action='/File/Set/ListFiles'/>\n"
964 "        <menuitem name='NextFile' action='/File/Set/NextFile'/>\n"
965 "        <menuitem name='PreviousFile' action='/File/Set/PreviousFile'/>\n"
966 "      </menu>\n"
967 "      <separator/>\n"
968 "      <menu name= 'Export' action='/File/Export'>\n"
969 #if _WIN32
970 "        <menuitem name='File' action='/File/Export/File'/>\n"
971 #else
972 "        <menu name= 'File' action='/File/Export/File'>\n"
973 "          <menuitem name='AsTxt' action='/File/Export/File/Text'/>\n"
974 "          <menuitem name='AsPostScript' action='/File/Export/File/PostScript'/>\n"
975 "          <menuitem name='AsCSV' action='/File/Export/File/CSV'/>\n"
976 "          <menuitem name='AsCArrays' action='/File/Export/File/CArrays'/>\n"
977 "          <separator/>\n"
978 "          <menuitem name='AsPSML' action='/File/Export/File/PSML'/>\n"
979 "          <menuitem name='AsPDML' action='/File/Export/File/PDML'/>\n"
980 "          <separator/>\n"
981 "        </menu>\n"
982 #endif /* _WIN32 */
983 "      <menuitem name='SelectedPacketBytes' action='/File/Export/SelectedPacketBytes'/>\n"
984 "        <menu name= 'Objects' action='/File/Export/Objects'>\n"
985 "          <menuitem name='HTTP' action='/File/Export/Objects/HTTP'/>\n"
986 "          <menuitem name='DICOM' action='/File/Export/Objects/DICOM'/>\n"
987 "          <menuitem name='SMB' action='/File/Export/Objects/SMB'/>\n"
988 "        </menu>\n"
989 "      </menu>\n"
990 "      <separator/>\n"
991 "      <menuitem name='Print' action='/File/Print'/>\n"
992 "      <separator/>\n"
993 "        <menuitem name='Quit' action='/File/Quit'/>\n"
994 "    </menu>\n"
995 "    <menu name= 'EditMenu' action='/Edit'>\n"
996 "        <menu name= 'Copy' action='/Edit/Copy'>\n"
997 "          <menuitem name='Description' action='/Edit/Copy/Description'/>\n"
998 "          <menuitem name='Fieldname' action='/Edit/Copy/Fieldname'/>\n"
999 "          <menuitem name='Value' action='/Edit/Copy/Value'/>\n"
1000 "          <separator/>\n"
1001 "          <menuitem name='AsFilter' action='/Edit/Copy/AsFilter'/>\n"
1002 "        </menu>\n"
1003 "        <menuitem name='FindPacket' action='/Edit/FindPacket'/>\n"
1004 "        <menuitem name='FindNext' action='/Edit/FindNext'/>\n"
1005 "        <menuitem name='FindPrevious' action='/Edit/FindPrevious'/>\n"
1006 "        <separator/>\n"
1007 #ifdef NEW_PACKET_LIST
1008 "        <menuitem name='MarkPacket' action='/Edit/MarkPacket'/>\n"
1009 "        <menuitem name='MarkAllDisplayedPackets' action='/Edit/MarkAllDisplayedPackets'/>\n"
1010 "        <menuitem name='UnmarkAllPackets' action='/Edit/UnmarkAllPackets'/>\n"
1011 "        <menuitem name='FindNextMark' action='/Edit/FindNextMark'/>\n"
1012 "        <menuitem name='FindPreviousMark' action='/Edit/FindPreviousMark'/>\n"
1013 "        <separator/>\n"
1014 "        <menuitem name='IgnorePacket' action='/Edit/IgnorePacket'/>\n"
1015 "        <menuitem name='IgnoreAllDisplayedPackets' action='/Edit/IgnoreAllDisplayedPackets'/>\n"
1016 "        <menuitem name='Un-IgnoreAllPackets' action='/Edit/Un-IgnoreAllPackets'/>\n"
1017 "        <separator/>\n"
1018 "        <menuitem name='SetTimeReference' action='/Edit/SetTimeReference'/>\n"
1019 "        <menuitem name='Un-TimeReferenceAllPackets' action='/Edit/Un-TimeReferenceAllPackets'/>\n"
1020 "        <menuitem name='FindNextTimeReference' action='/Edit/FindNextTimeReference'/>\n"
1021 "        <menuitem name='FindPreviousTimeReference' action='/Edit/FindPreviousTimeReference'/>\n"
1022 "        <separator/>\n"
1023 #else /* NEW_PACKET_LIST */
1024 #error "You must use the new packet list if you are using GTKUIManager for menus"
1025 #endif
1026 "        <menuitem name='ConfigurationProfiles' action='/Edit/ConfigurationProfiles'/>\n"
1027 "        <menuitem name='Preferences' action='/Edit/Preferences'/>\n"
1028 "    </menu>\n"
1029 "    <menu name= 'ViewMenu' action='/View'>\n"
1030 "      <menuitem name='MainToolbar' action='/View/MainToolbar'/>\n"
1031 "      <menuitem name='FilterToolbar' action='/View/FilterToolbar'/>\n"
1032 #ifdef HAVE_AIRPCAP
1033 "      <menuitem name='WirelessToolbar' action='/View/WirelessToolbar'/>\n"
1034 #endif
1035 "      <menuitem name='Statusbar' action='/View/Statusbar'/>\n"
1036 "      <separator/>\n"
1037 "      <menuitem name='PacketList' action='/View/PacketList'/>\n"
1038 "      <menuitem name='PacketDetails' action='/View/PacketDetails'/>\n"
1039 "      <menuitem name='PacketBytes' action='/View/PacketBytes'/>\n"
1040 "      <separator/>\n"
1041 "      <menu name= 'TimeDisplayFormat' action='/View/TimeDisplayFormat'>\n"
1042 "        <menuitem name='DateandTimeofDay' action='/View/TimeDisplayFormat/DateandTimeofDay'/>\n"
1043 "        <menuitem name='TimeofDay' action='/View/TimeDisplayFormat/TimeofDay'/>\n"
1044 "        <menuitem name='SecondsSinceEpoch' action='/View/TimeDisplayFormat/SecondsSinceEpoch'/>\n"
1045 "        <menuitem name='SecondsSinceBeginningofCapture' action='/View/TimeDisplayFormat/SecondsSinceBeginningofCapture'/>\n"
1046 "        <menuitem name='SecondsSincePreviousCapturedPacket' action='/View/TimeDisplayFormat/SecondsSincePreviousCapturedPacket'/>\n"
1047 "        <menuitem name='SecondsSincePreviousDisplayedPacket' action='/View/TimeDisplayFormat/SecondsSincePreviousDisplayedPacket'/>\n"
1048 "        <separator/>\n"
1049 "        <menuitem name='FileFormatPrecision-Automatic' action='/View/TimeDisplayFormat/FileFormatPrecision-Automatic'/>\n"
1050 "        <menuitem name='FileFormatPrecision-Seconds' action='/View/TimeDisplayFormat/FileFormatPrecision-Seconds'/>\n"
1051 "        <menuitem name='FileFormatPrecision-Deciseconds' action='/View/TimeDisplayFormat/FileFormatPrecision-Deciseconds'/>\n"
1052 "        <menuitem name='FileFormatPrecision-Centiseconds' action='/View/TimeDisplayFormat/FileFormatPrecision-Centiseconds'/>\n"
1053 "        <menuitem name='FileFormatPrecision-Milliseconds' action='/View/TimeDisplayFormat/FileFormatPrecision-Milliseconds'/>\n"
1054 "        <menuitem name='FileFormatPrecision-Microseconds' action='/View/TimeDisplayFormat/FileFormatPrecision-Microseconds'/>\n"
1055 "        <menuitem name='FileFormatPrecision-Nanoseconds' action='/View/TimeDisplayFormat/FileFormatPrecision-Nanoseconds'/>\n"
1056 "        <separator/>\n"
1057 "        <menuitem name='DisplaySecondsWithHoursAndMinutes' action='/View/TimeDisplayFormat/DisplaySecondsWithHoursAndMinutes'/>\n"
1058 "      </menu>\n"
1059 "      <menu name= 'NameResolution' action='/View/NameResolution'>\n"
1060 "         <menuitem name='ResolveName' action='/View/NameResolution/ResolveName'/>\n"
1061 "         <separator/>\n"
1062 "         <menuitem name='EnableforMACLayer' action='/View/NameResolution/EnableforMACLayer'/>\n"
1063 "         <menuitem name='EnableforNetworkLayer' action='/View/NameResolution/EnableforNetworkLayer'/>\n"
1064 "         <menuitem name='EnableforTransportLayer' action='/View/NameResolution/EnableforTransportLayer'/>\n"
1065 "      </menu>\n"
1066 "      <menuitem name='ColorizePacketList' action='/View/ColorizePacketList'/>\n"
1067 "      <menuitem name='AutoScrollinLiveCapture' action='/View/AutoScrollinLiveCapture'/>\n"
1068 "      <separator/>\n"
1069 "      <menuitem name='ZoomIn' action='/View/ZoomIn'/>\n"
1070 "      <menuitem name='ZoomOut' action='/View/ZoomOut'/>\n"
1071 "      <menuitem name='NormalSize' action='/View/NormalSize'/>\n"
1072 "      <separator/>\n"
1073 "      <menuitem name='ResizeAllColumns' action='/View/ResizeAllColumns'/>\n"
1074 "      <menuitem name='DisplayedColumns' action='/View/DisplayedColumns'/>\n"
1075 "      <separator/>\n"
1076 "      <menuitem name='ExpandSubtrees' action='/View/ExpandSubtrees'/>\n"
1077 "      <menuitem name='ExpandAll' action='/View/ExpandAll'/>\n"
1078 "      <menuitem name='CollapseAll' action='/View/CollapseAll'/>\n"
1079 "      <separator/>\n"
1080 "      <menu name= 'ColorizeConversation' action='/View/ColorizeConversation'>\n"
1081 "         <menuitem name='Color1' action='/View/ColorizeConversation/Color 1'/>\n"
1082 "         <menuitem name='Color2' action='/View/ColorizeConversation/Color 2'/>\n"
1083 "         <menuitem name='Color3' action='/View/ColorizeConversation/Color 3'/>\n"
1084 "         <menuitem name='Color4' action='/View/ColorizeConversation/Color 4'/>\n"
1085 "         <menuitem name='Color5' action='/View/ColorizeConversation/Color 5'/>\n"
1086 "         <menuitem name='Color6' action='/View/ColorizeConversation/Color 6'/>\n"
1087 "         <menuitem name='Color7' action='/View/ColorizeConversation/Color 7'/>\n"
1088 "         <menuitem name='Color8' action='/View/ColorizeConversation/Color 8'/>\n"
1089 "         <menuitem name='Color9' action='/View/ColorizeConversation/Color 9'/>\n"
1090 "         <menuitem name='Color10' action='/View/ColorizeConversation/Color 10'/>\n"
1091 "         <menuitem name='NewColoringRule' action='/View/ColorizeConversation/NewColoringRule'/>\n"
1092 "      </menu>\n"
1093 "      <separator/>\n"
1094 "      <menuitem name='ResetColoring1-10' action='/View/ResetColoring1-10'/>\n"
1095 "      <menuitem name='ColoringRules' action='/View/ColoringRules'/>\n"
1096 "      <separator/>\n"
1097 "      <menuitem name='ShowPacketinNewWindow' action='/View/ShowPacketinNewWindow'/>\n"
1098 "      <menuitem name='Reload' action='/View/Reload'/>\n"
1099 "    </menu>\n"
1100 "    <menu name= 'GoMenu' action='/Go'>\n"
1101 "      <menuitem name='Back' action='/Go/Back'/>\n"
1102 "      <menuitem name='Forward' action='/Go/Forward'/>\n"
1103 "      <menuitem name='GotoCorrespondingPacket' action='/Go/GotoCorrespondingPacket'/>\n"
1104 "      <separator/>\n"
1105 "      <menuitem name='PreviousPacket' action='/Go/PreviousPacket'/>\n"
1106 "      <menuitem name='NextPacket' action='/Go/NextPacket'/>\n"
1107 "      <menuitem name='FirstPacket' action='/Go/FirstPacket'/>\n"
1108 "      <menuitem name='LastPacket' action='/Go/LastPacket'/>\n"
1109 "      <menuitem name='PreviousPacketInConversation' action='/Go/PreviousPacketInConversation'/>\n"
1110 "      <menuitem name='NextPacketInConversation' action='/Go/NextPacketInConversation'/>\n"
1111 "    </menu>\n"
1112 #ifdef HAVE_LIBPCAP
1113 "    <menu name= 'CaptureMenu' action='/Capture'>\n"
1114 "      <menuitem name='Interfaces' action='/Capture/Interfaces'/>\n"
1115 "      <menuitem name='Options' action='/Capture/Options'/>\n"
1116 "      <menuitem name='Start' action='/Capture/Start'/>\n"
1117 "      <menuitem name='Stop' action='/Capture/Stop'/>\n"
1118 "      <menuitem name='Restart' action='/Capture/Restart'/>\n"
1119 "      <menuitem name='CaptureFilters' action='/Capture/CaptureFilters'/>\n"
1120 "    </menu>\n"
1121 #endif /* HAVE_LIBPCAP */
1122 "    <menu name= 'AnalyzeMenu' action='/Analyze'>\n"
1123 "      <menuitem name='DisplayFilters' action='/Analyze/DisplayFilters'/>\n"
1124 "      <separator/>\n"
1125 "      <menuitem name='ApplyasColumn' action='/Analyze/ApplyasColumn'/>\n"
1126 "      <menu name= 'ApplyAsFilter' action='/Analyze/ApplyasFilter'>\n"
1127 "        <menuitem name='Selected' action='/Analyze/ApplyasFilter/Selected'/>\n"
1128 "        <menuitem name='NotSelected' action='/Analyze/ApplyasFilter/NotSelected'/>\n"
1129 "        <menuitem name='AndSelected' action='/Analyze/ApplyasFilter/AndSelected'/>\n"
1130 "        <menuitem name='OrSelected' action='/Analyze/ApplyasFilter/OrSelected'/>\n"
1131 "        <menuitem name='AndNotSelected' action='/Analyze/ApplyasFilter/AndNotSelected'/>\n"
1132 "        <menuitem name='OrNotSelected' action='/Analyze/ApplyasFilter/OrNotSelected'/>\n"
1133 "      </menu>\n"
1134 "      <menu name= 'PrepareaFilter' action='/Analyze/PrepareaFilter'>\n"
1135 "        <menuitem name='Selected' action='/Analyze/PrepareaFilter/Selected'/>\n"
1136 "        <menuitem name='NotSelected' action='/Analyze/PrepareaFilter/NotSelected'/>\n"
1137 "        <menuitem name='AndSelected' action='/Analyze/PrepareaFilter/AndSelected'/>\n"
1138 "        <menuitem name='OrSelected' action='/Analyze/PrepareaFilter/OrSelected'/>\n"
1139 "        <menuitem name='AndNotSelected' action='/Analyze/PrepareaFilter/AndNotSelected'/>\n"
1140 "        <menuitem name='OrNotSelected' action='/Analyze/PrepareaFilter/OrNotSelected'/>\n"
1141 "      </menu>\n"
1142 "      <menuitem name='EnabledProtocols' action='/Analyze/EnabledProtocols'/>\n"
1143 "      <menuitem name='DecodeAs' action='/Analyze/DecodeAs'/>\n"
1144 "      <menuitem name='UserSpecifiedDecodes' action='/Analyze/UserSpecifiedDecodes'/>\n"
1145 "      <separator/>\n"
1146 "      <menuitem name='FollowTCPStream' action='/Analyze/FollowTCPStream'/>\n"
1147 "      <menuitem name='FollowUDPStream' action='/Analyze/FollowUDPStream'/>\n"
1148 "      <menuitem name='FollowSSLStream' action='/Analyze/FollowSSLStream'/>\n"
1149 "    </menu>\n"
1150 "    <menu name= 'StatisticsMenu' action='/Statistics'>\n"
1151 "      <menuitem name='Summary' action='/Statistics/Summary'/>\n"
1152 "      <menuitem name='ProtocolHierarchy' action='/Statistics/ProtocolHierarchy'/>\n"
1153 "      <menuitem name='Conversations' action='/Statistics/Conversations'/>\n"
1154 "      <menuitem name='Endpoints' action='/Statistics/Endpoints'/>\n"
1155 "    </menu>\n"
1156 "    <menu name= 'TelephonyMenu' action='/Telephony'>\n"
1157 "    </menu>\n"
1158 "    <menu name= 'ToolsMenu' action='/Tools'>\n"
1159 "      <menuitem name='FirewallACLRules' action='/Tools/FirewallACLRules'/>\n"
1160 "    </menu>\n"
1161 "    <menu name= 'WSinternalMenu' action='/WSinternal'>\n"
1162 "      <menuitem name='Dissectortables' action='/WSinternal/Dissectortables'/>\n"
1163 "    </menu>\n"
1164 "    <menu name= 'HelpMenu' action='/Help'>\n"
1165 "      <menuitem name='Contents' action='/Help/Contents'/>\n"
1166 "      <menuitem name='FAQs' action='/Help/FAQs'/>\n"
1167 "      <menu name= 'ManualPages' action='/Help/ManualPages'>\n"
1168 "        <menuitem name='Wireshark' action='/Help/ManualPages/Wireshark'/>\n"
1169 "        <menuitem name='WiresharkFilter' action='/Help/ManualPages/WiresharkFilter'/>\n"
1170 "        <separator/>\n"
1171 "        <menuitem name='TShark' action='/Help/ManualPages/TShark'/>\n"
1172 "        <menuitem name='RawShark' action='/Help/ManualPages/RawShark'/>\n"
1173 "        <menuitem name='Dumpcap' action='/Help/ManualPages/Dumpcap'/>\n"
1174 "        <menuitem name='Mergecap' action='/Help/ManualPages/Mergecap'/>\n"
1175 "        <menuitem name='Editcap' action='/Help/ManualPages/Editcap'/>\n"
1176 "        <menuitem name='Text2pcap' action='/Help/ManualPages/Text2pcap'/>\n"
1177 "      </menu>\n"
1178 "      <separator/>\n"
1179 "      <menuitem name='Website' action='/Help/Website'/>\n"
1180 "      <menuitem name='Wiki' action='/Help/Wiki'/>\n"
1181 "      <menuitem name='Downloads' action='/Help/Downloads'/>\n"
1182 "      <menuitem name='SampleCaptures' action='/Help/SampleCaptures'/>\n"
1183 "      <separator/>\n"
1184 "      <menuitem name='SupportedProtocols' action='/Help/SupportedProtocols'/>\n"
1185 "      <separator/>\n"
1186 "      <menuitem name='AboutWireshark' action='/Help/AboutWireshark'/>\n"
1187 "    </menu>\n"
1188 "  </menubar>\n"
1189 "</ui>\n";
1190
1191
1192 /*
1193  * Main menu.
1194  *
1195  * Please do not use keystrokes that are used as "universal" shortcuts in
1196  * various desktop environments:
1197  *
1198  *   Windows:
1199  *      http://support.microsoft.com/kb/126449
1200  *
1201  *   GNOME:
1202  *      http://library.gnome.org/users/user-guide/nightly/keyboard-skills.html.en
1203  *
1204  *   KDE:
1205  *      http://developer.kde.org/documentation/standards/kde/style/keys/shortcuts.html
1206  *
1207  * In particular, do not use the following <control> sequences for anything
1208  * other than their standard purposes:
1209  *
1210  *      <control>O      File->Open
1211  *      <control>S      File->Save
1212  *      <control>P      File->Print
1213  *      <control>W      File->Close
1214  *      <control>Q      File->Quit
1215  *      <control>Z      Edit->Undo (which we don't currently have)
1216  *      <control>X      Edit->Cut (which we don't currently have)
1217  *      <control>C      Edit->Copy (which we don't currently have)
1218  *      <control>V      Edit->Paste (which we don't currently have)
1219  *      <control>A      Edit->Select All (which we don't currently have)
1220  *
1221  * Note that some if not all of the Edit keys above already perform those
1222  * functions in text boxes, such as the Filter box.  Do no, under any
1223  * circumstances, make a change that keeps them from doing so.
1224  */
1225
1226 /* 
1227  * GtkActionEntry
1228  * typedef struct {
1229  *   const gchar     *name;
1230  *   const gchar     *stock_id;
1231  *   const gchar     *label;
1232  *   const gchar     *accelerator;
1233  *   const gchar     *tooltip;
1234  *   GCallback  callback;
1235  * } GtkActionEntry;
1236  * const gchar *name;                   The name of the action.  
1237  * const gchar *stock_id;               The stock id for the action, or the name of an icon from the icon theme.  
1238  * const gchar *label;                  The label for the action. This field should typically be marked for translation, 
1239  *                                                              see gtk_action_group_set_translation_domain(). 
1240  *                                                              If label is NULL, the label of the stock item with id stock_id is used.  
1241  * const gchar *accelerator;    The accelerator for the action, in the format understood by gtk_accelerator_parse().  
1242  * const gchar *tooltip;                The tooltip for the action. This field should typically be marked for translation, 
1243  *                              see gtk_action_group_set_translation_domain().  
1244  * GCallback callback;                  The function to call when the action is activated.  
1245  *
1246  */
1247 static const GtkActionEntry main_menu_bar_entries[] = {
1248   /* Top level */ 
1249   { "/File",                                    NULL,                                                   "_File",                        NULL,                                   NULL,                   NULL },
1250   { "/Edit",                                    NULL,                                                   "_Edit",                        NULL,                                   NULL,                   NULL },
1251   { "/View",                                    NULL,                                                   "_View",                        NULL,                                   NULL,                   NULL },
1252   { "/Go",                                              NULL,                                                   "_Go",                          NULL,                                   NULL,                   NULL },
1253 #ifdef HAVE_LIBPCAP
1254   { "/Capture",                                 NULL,                                                   "_Capture",                     NULL,                                   NULL,                   NULL },
1255 #endif
1256   { "/Analyze",                                 NULL,                                                   "_Analyze",                     NULL,                                   NULL,                   NULL },
1257   { "/Statistics",                              NULL,                                                   "_Statistics",          NULL,                                   NULL,                   NULL },
1258   { "/Telephony",                               NULL,                                                   "Telephon_y",           NULL,                                   NULL,                   NULL },
1259   { "/Tools",                                   NULL,                                                   "_Tools",                       NULL,                                   NULL,                   NULL },
1260   { "/WSinternal",                              NULL,                                                   "WS internal",          NULL,                                   NULL,                   NULL },
1261   { "/Help",                                    NULL,                                                   "_Help",                        NULL,                                   NULL,                   NULL },
1262
1263   { "/File/Open",                               GTK_STOCK_OPEN,                                 "_Open...",                     "<control>O",                   "Open a file",  G_CALLBACK(file_open_cmd_cb) },
1264   { "/File/OpenRecent",                 NULL,                                                   "Open _Recent",         NULL,                                   NULL,                   NULL },
1265   { "/File/Merge",                              NULL,                                                   "_Merge...",            NULL,                                   NULL,                   G_CALLBACK(file_merge_cmd_cb) },
1266   { "/File/Close",                              GTK_STOCK_CLOSE,                                "_Close",                       "<control>W",                   NULL,                   G_CALLBACK(file_close_cmd_cb) },
1267
1268   { "/File/Save",                               GTK_STOCK_SAVE,                                 "_Save",                        "<control>S",                   NULL,                   G_CALLBACK(file_save_cmd_cb) },
1269   { "/File/SaveAs",                             GTK_STOCK_SAVE_AS,                              "Save _As...",          "<shift><control>S",    NULL,                   G_CALLBACK(file_save_as_cmd_cb) },
1270
1271   { "/File/Set",                                NULL,                                                   "File Set",                     NULL,                                   NULL,                   NULL },
1272   { "/File/Export",                             NULL,                                                   "Export",                       NULL,                                   NULL,                   NULL },
1273   { "/File/Print",                              GTK_STOCK_PRINT,                                "_Print...",            "<control>P",                   NULL,                   G_CALLBACK(file_print_cmd_cb) },
1274   { "/File/Quit",                               GTK_STOCK_QUIT,                                 "_Quit",                        "<control>Q",                   NULL,                   G_CALLBACK(file_quit_cmd_cb) },
1275
1276   { "/File/Set/ListFiles",      WIRESHARK_STOCK_FILE_SET_LIST,  "List Files",           NULL,                                   NULL,                   G_CALLBACK(fileset_cb) },
1277   { "/File/Set/NextFile",       WIRESHARK_STOCK_FILE_SET_NEXT,  "Next File",            NULL,                                   NULL,                   G_CALLBACK(fileset_next_cb) },
1278   { "/File/Set/PreviousFile",WIRESHARK_STOCK_FILE_SET_PREVIOUS, "Previous File",        NULL,                           NULL,                   G_CALLBACK(fileset_previous_cb) },
1279
1280 #if _WIN32
1281   { "/File/Export/File",                                NULL,           "File...",                                              NULL,                                   NULL,                   G_CALLBACK(export_text_cmd_cb) },
1282 #else
1283   { "/File/Export/File",                                NULL,           "File...",                                              NULL,                                   NULL,                   NULL },
1284   { "/File/Export/File/Text",                   NULL,           "as \"Plain _Text\" file...",   NULL,                                   NULL,                   G_CALLBACK(export_text_cmd_cb) },
1285   { "/File/Export/File/PostScript",             NULL,           "as \"_PostScript\" file...",   NULL,                                   NULL,                   G_CALLBACK(export_ps_cmd_cb) },
1286   { "/File/Export/File/CSV",                    NULL,           "as \"_CSV\" (Comma Separated Values packet summary) file...",
1287                                                                                                                                                                         NULL,                                   NULL,                   G_CALLBACK(export_csv_cmd_cb) },
1288   { "/File/Export/File/CArrays",                NULL,           "as \"C _Arrays\" (packet bytes) file...",
1289                                                                                                                                                                         NULL,                                   NULL,                   G_CALLBACK(export_carrays_cmd_cb) },
1290   { "/File/Export/File/PSML",                   NULL,           "as XML - \"P_SML\" (packet summary) file...",
1291                                                                                                                                                                         NULL,                                   NULL,                   G_CALLBACK(export_psml_cmd_cb) },
1292   { "/File/Export/File/PDML",                   NULL,           "as XML - \"P_DML\" (packet details) file...",  
1293                                                                                                                                                                         NULL,                                   NULL,                   G_CALLBACK(export_pdml_cmd_cb) },
1294 #endif /* _WIN32 */
1295   { "/File/Export/SelectedPacketBytes", NULL,           "Selected Packet _Bytes...",    "<control>H",                   NULL,                   G_CALLBACK(savehex_cb) },
1296   { "/File/Export/Objects",                             NULL,           "Objects",                                              NULL,                                   NULL,                   NULL },
1297   { "/File/Export/Objects/HTTP",                NULL,           "_HTTP",                                                NULL,                                   NULL,                   G_CALLBACK(eo_http_cb) },
1298   { "/File/Export/Objects/DICOM",               NULL,           "_DICOM",                                               NULL,                                   NULL,                   G_CALLBACK(eo_dicom_cb) },
1299   { "/File/Export/Objects/SMB",                 NULL,           "_SMB",                                                 NULL,                                   NULL,                   G_CALLBACK(eo_smb_cb) },
1300
1301
1302   { "/Edit/Copy",                                               NULL,           "Copy",                                                 NULL,                                   NULL,                   NULL },
1303
1304   { "/Edit/Copy/Description",                   NULL,           "Description",                                  "<shift><control>D",    NULL,                   G_CALLBACK(copy_description_cb) },
1305   { "/Edit/Copy/Fieldname",                             NULL,           "Fieldname",                                    "<shift><control>F",    NULL,                   G_CALLBACK(copy_fieldname_cb) },
1306   { "/Edit/Copy/Value",                                 NULL,           "Value",                                                "<shift><control>V",    NULL,                   G_CALLBACK(copy_value_cb) },
1307   { "/Edit/Copy/AsFilter",                              NULL,           "As Filter",                                    "<shift><control>C",    NULL,                   G_CALLBACK(copy_as_filter_cb) },
1308
1309 #if 0
1310     /*
1311      * Un-#if this when we actually implement Cut/Copy/Paste for the
1312      * packet list and packet detail windows.
1313      *
1314      * Note: when we implement Cut/Copy/Paste in those windows, we
1315      * will almost certainly want to allow multiple packets to be
1316      * selected in the packet list pane and multiple packet detail
1317      * items to be selected in the packet detail pane, so that
1318      * the user can, for example, copy the summaries of multiple
1319      * packets to the clipboard from the packet list pane and multiple
1320      * packet detail items - perhaps *all* packet detail items - from
1321      * the packet detail pane.  Given that, we'll also want to
1322      * implement Select All.
1323      *
1324      * If multiple packets are selected, we would probably display nothing
1325      * in the packet detail pane, just as we do if no packet is selected,
1326      * and any menu items etc. that would pertain only to a single packet
1327      * would be disabled.
1328      *
1329      * If multiple packet detail items are selected, we would probably
1330      * disable all items that pertain only to a single packet detail
1331      * item, such as some items in the status bar.
1332      *
1333      * XXX - the actions for these will be different depending on what
1334      * widget we're in; ^C should copy from the filter text widget if
1335      * we're in that widget, the packet list if we're in that widget
1336      * (presumably copying the summaries of selected packets to the
1337      * clipboard, e.g. the text copy would be the text of the columns),
1338      * the packet detail if we're in that widget (presumably copying
1339      * the contents of selected protocol tree items to the clipboard,
1340      * e.g. the text copy would be the text displayed for those items),
1341      * etc..
1342      *
1343      * Given that those menu items should also affect text widgets
1344      * such as the filter box, we would again want Select All, and,
1345      * at least for the filter box, we would also want Undo and Redo.
1346      * We would only want Cut, Paste, Undo, and Redo for the packet
1347      * list and packet detail panes if we support modifying them.
1348      */
1349     {"/Edit/_Undo", "<control>Z", NULL,
1350                              0, "<StockItem>", GTK_STOCK_UNDO,},
1351     {"/Edit/_Redo", "<shift><control>Z", NULL,
1352                              0, "<StockItem>", GTK_STOCK_REDO,},
1353     {"/Edit/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
1354     {"/Edit/Cu_t", "<control>X", NULL,
1355                              0, "<StockItem>", GTK_STOCK_CUT,},
1356     {"/Edit/_Copy", "<control>C", NULL,
1357                              0, "<StockItem>", GTK_STOCK_COPY,},
1358     {"/Edit/_Paste", "<control>V", NULL,
1359                              0, "<StockItem>", GTK_STOCK_PASTE,},
1360     {"/Edit/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
1361     {"/Edit/Select _All", "<control>A", NULL, 0,
1362 #ifdef GTK_STOCK_SELECT_ALL     /* first appeared in 2.10 */
1363                              "<StockItem>", GTK_STOCK_SELECT_ALL,
1364 #else
1365                              NULL, NULL,
1366 #endif /* GTK_STOCK_SELECT_ALL */
1367 #endif /* 0 */
1368    { "/Edit/FindPacket",                                GTK_STOCK_FIND,         "_Find Packet...",                                              "<control>F",                   NULL,                   G_CALLBACK(find_frame_cb) },
1369    { "/Edit/FindNext",                                  NULL,                           "Find Ne_xt",                                                   "<control>N",                   NULL,                   G_CALLBACK(find_next_cb) },
1370    { "/Edit/FindPrevious",                              NULL,                           "Find Pre_vious",                                               "<control>B",                   NULL,                   G_CALLBACK(find_previous_cb) },
1371
1372 #ifdef NEW_PACKET_LIST
1373    { "/Edit/MarkPacket",                                NULL,                           "_Mark Packet (toggle)",                                "<control>M",                   NULL,                   G_CALLBACK(new_packet_list_mark_frame_cb) },
1374    { "/Edit/FindNextMark",                              NULL,                           "Find Next Mark",                                               "<shift><control>N",    NULL,                   G_CALLBACK(find_next_mark_cb) },
1375    { "/Edit/FindPreviousMark",                  NULL,                           "Find Next Mark",                                               "<shift><control>B",    NULL,                   G_CALLBACK(find_prev_mark_cb) },
1376    { "/Edit/MarkAllDisplayedPackets",   NULL,                           "Mark All Displayed Packets (toggle)",  "<control>A",                   NULL,                   G_CALLBACK(new_packet_list_mark_all_displayed_frames_cb) },
1377    { "/Edit/UnmarkAllPackets",                  NULL,                           "_Unmark All Packets",                                  "<control>D",                   NULL,                   G_CALLBACK(new_packet_list_unmark_all_frames_cb) },
1378
1379   { "/Edit/IgnorePacket",                               NULL,                           "_Ignore Packet (toggle)",                              "<control>X",                   NULL,                   G_CALLBACK(new_packet_list_ignore_frame_cb) },
1380     /*
1381      * XXX - this next one overrides /Edit/Copy/Description
1382      */
1383    { "/Edit/IgnoreAllDisplayedPackets", NULL,                           "_Ignore All Displayed Packets (toggle)","<alt><shift><control>X",      NULL,                   G_CALLBACK(new_packet_list_ignore_all_displayed_frames_cb) },
1384    { "/Edit/Un-IgnoreAllPackets",               NULL,                           "U_n-Ignore All Packets",                               "<shift><control>X",            NULL,                   G_CALLBACK(new_packet_list_unignore_all_frames_cb) },
1385    { "/Edit/SetTimeReference",                  WIRESHARK_STOCK_TIME,   "Set Time Reference (toggle)",                  "<control>T",                   NULL,                   G_CALLBACK(set_reftime_cb) },
1386    { "/Edit/Un-TimeReferenceAllPackets",NULL,                           "Un-Time Reference All Packets",                "<alt><control>T",                      NULL,                   G_CALLBACK(new_packet_list_untime_reference_all_frames_cb) },
1387    { "/Edit/FindNextTimeReference",             NULL,                           "Find Next Time Reference",                             "<alt><control>N",                      NULL,                   G_CALLBACK(find_next_ref_time_cb) },
1388    { "/Edit/FindPreviousTimeReference", NULL,                           "Find Previous Time Reference",                 "<alt><control>B",                      NULL,                   G_CALLBACK(find_previous_ref_time_cb) },
1389
1390 #else /* NEW_PACKET_LIST */
1391 #error "You must use the new packet list if you are using GTKUIManager for menus"
1392 #endif /* NEW_PACKET_LIST */
1393    { "/Edit/ConfigurationProfiles",     NULL,                                   "_Configuration Profiles...",                   "<shift><control>A",            NULL,                   G_CALLBACK(profile_dialog_cb) },
1394    { "/Edit/Preferences",                       GTK_STOCK_PREFERENCES,  "_Preferences...",                                              "<shift><control>P",            NULL,                   G_CALLBACK(menus_prefs_cb) },
1395
1396
1397    { "/View/TimeDisplayFormat",         NULL,                                   "_Time Display Format",                                 NULL,                                           NULL,                   NULL },
1398
1399   { "/View/NameResolution",                     NULL,                                   "Name Resol_ution",                                             NULL,                                           NULL,                   NULL },
1400   { "/View/NameResolution/ResolveName", NULL,                           "_Resolve Name",                                                NULL,                                           NULL,                   G_CALLBACK(resolve_name_cb) },
1401    { "/View/ZoomIn",                            GTK_STOCK_ZOOM_IN,              "_Zoom In",                                                             "<control>plus",                        NULL,                   G_CALLBACK(view_zoom_in_cb) },
1402    { "/View/ZoomOut",                           GTK_STOCK_ZOOM_OUT,             "Zoom _Out",                                                    "<control>minus",                       NULL,                   G_CALLBACK(view_zoom_out_cb) },
1403    { "/View/NormalSize",                        GTK_STOCK_ZOOM_100,             "_Normal Size",                                                 "<control>equal",                       NULL,                   G_CALLBACK(view_zoom_100_cb) },
1404 #ifdef NEW_PACKET_LIST
1405    { "/View/ResizeAllColumns",          WIRESHARK_STOCK_RESIZE_COLUMNS, "Resize All Columns",                   "<shift><control>R",            NULL,                   G_CALLBACK(new_packet_list_resize_columns_cb) },
1406    { "/View/DisplayedColumns",          NULL,                                   "Displayed Columns",                    NULL,           NULL,                   NULL },
1407 #else
1408 #error "You must use the new packet list if you are using GTKUIManager for menus"
1409 #endif /* NEW_PACKET_LIST */
1410    { "/View/ExpandSubtrees",            NULL,                                   "Expand Subtrees",              NULL,                                   NULL,                   G_CALLBACK(expand_tree_cb) },
1411    { "/View/ExpandAll",                         NULL,                                   "Expand All",                   NULL,                                   NULL,                   G_CALLBACK(expand_all_cb) },
1412    { "/View/CollapseAll",                       NULL,                                   "Collapse All",                 NULL,                                   NULL,                   G_CALLBACK(collapse_all_cb) },
1413    { "/View/ColorizeConversation",      NULL,                                   "Colorize Conversation",NULL,                                   NULL,                   NULL },
1414
1415    { "/View/ColorizeConversation/Color 1",      WIRESHARK_STOCK_COLOR1, "Color 1",                                      NULL, NULL, G_CALLBACK(view_menu_color_conv_color1_cb) },
1416    { "/View/ColorizeConversation/Color 2",      WIRESHARK_STOCK_COLOR2, "Color 2",                                      NULL, NULL, G_CALLBACK(view_menu_color_conv_color2_cb) },
1417    { "/View/ColorizeConversation/Color 3",      WIRESHARK_STOCK_COLOR3, "Color 3",                                      NULL, NULL, G_CALLBACK(view_menu_color_conv_color3_cb) },
1418    { "/View/ColorizeConversation/Color 4",      WIRESHARK_STOCK_COLOR4, "Color 4",                                      NULL, NULL, G_CALLBACK(view_menu_color_conv_color4_cb) },
1419    { "/View/ColorizeConversation/Color 5",      WIRESHARK_STOCK_COLOR5, "Color 5",                                      NULL, NULL, G_CALLBACK(view_menu_color_conv_color5_cb) },
1420    { "/View/ColorizeConversation/Color 6",      WIRESHARK_STOCK_COLOR6, "Color 6",                                      NULL, NULL, G_CALLBACK(view_menu_color_conv_color6_cb) },
1421    { "/View/ColorizeConversation/Color 7",      WIRESHARK_STOCK_COLOR7, "Color 7",                                      NULL, NULL, G_CALLBACK(view_menu_color_conv_color7_cb) },
1422    { "/View/ColorizeConversation/Color 8",      WIRESHARK_STOCK_COLOR8, "Color 8",                                      NULL, NULL, G_CALLBACK(view_menu_color_conv_color8_cb) },
1423    { "/View/ColorizeConversation/Color 9",      WIRESHARK_STOCK_COLOR9, "Color 9",                                      NULL, NULL, G_CALLBACK(view_menu_color_conv_color9_cb) },
1424    { "/View/ColorizeConversation/Color 10",     WIRESHARK_STOCK_COLOR0, "Color 10",                                     NULL, NULL, G_CALLBACK(view_menu_color_conv_color10_cb) },
1425    { "/View/ColorizeConversation/NewColoringRule",      NULL,                   "New Coloring Rule...",         NULL, NULL, G_CALLBACK(view_menu_color_conv_new_rule_cb) },
1426
1427    { "/View/ResetColoring1-10",         NULL,                                   "Reset Coloring 1-10",                          "<control>space",                               NULL,                           G_CALLBACK(view_menu_reset_coloring_cb) },
1428    { "/View/ColoringRules",                     GTK_STOCK_SELECT_COLOR, "_Coloring Rules...",                           NULL,                                                   NULL,                           G_CALLBACK(color_display_cb) },
1429    { "/View/ShowPacketinNewWindow",     NULL,                                   "Show Packet in New _Window",           NULL,                                                   NULL,                           G_CALLBACK(new_window_cb) },
1430    { "/View/Reload",                            GTK_STOCK_REFRESH,              "_Reload",                                                      "<control>R",                                   NULL,                           G_CALLBACK(file_reload_cmd_cb) },
1431
1432
1433    { "/Go/Back",                                        GTK_STOCK_GO_BACK,              "_Back",                                                        "<alt>Left",                                    NULL,                           G_CALLBACK(history_back_cb) },
1434    { "/Go/Forward",                                     GTK_STOCK_JUMP_TO,              "_Forward",                                                     "<control>G",                                   NULL,                           G_CALLBACK(goto_frame_cb) },
1435    { "/Go/GotoCorrespondingPacket",     NULL,                                   "Go to _Corresponding Packet",          NULL,                                                   NULL,                           G_CALLBACK(goto_framenum_cb) },
1436
1437    { "/Go/PreviousPacket",                      GTK_STOCK_GO_UP,                "Previous Packet",                                      "<control>Up",                                  NULL,                           G_CALLBACK(goto_previous_frame_cb) },
1438    { "/Go/NextPacket",                          GTK_STOCK_GO_DOWN,              "Next Packet",                                          "<control>Down",                                NULL,                           G_CALLBACK(goto_next_frame_cb) },
1439    { "/Go/FirstPacket",                         GTK_STOCK_GOTO_TOP,             "F_irst Packet",                                        "<control>Home",                                NULL,                           G_CALLBACK(goto_top_frame_cb) },
1440    { "/Go/LastPacket",                          GTK_STOCK_GOTO_BOTTOM,  "_Last Packet",                                         "<control>End",                                 NULL,                           G_CALLBACK(goto_bottom_frame_cb) },
1441    { "/Go/PreviousPacketInConversation",                        GTK_STOCK_GO_UP,                "Previous Packet In Conversation",                                      "<control>bracketleft",                                 NULL,                           G_CALLBACK(goto_previous_frame_conversation_cb) },
1442    { "/Go/NextPacketInConversation",                            GTK_STOCK_GO_DOWN,              "Next Packet In Conversation",                                          "<control>bracketright",                                NULL,                           G_CALLBACK(goto_next_frame_conversation_cb) },
1443
1444 #ifdef HAVE_LIBPCAP
1445    { "/Capture/Interfaces",                     WIRESHARK_STOCK_CAPTURE_INTERFACES,     "_Interfaces...",               "<control>I",                                   NULL,                           G_CALLBACK(capture_if_cb) },
1446    { "/Capture/Options",                        WIRESHARK_STOCK_CAPTURE_OPTIONS,        "_Options...",                  "<control>K",                                   NULL,                           G_CALLBACK(capture_prep_cb) },
1447    { "/Capture/Start",                          WIRESHARK_STOCK_CAPTURE_START,          "_Start",                               "<control>E",                                   NULL,                           G_CALLBACK(capture_start_cb) },
1448    { "/Capture/Stop",                           WIRESHARK_STOCK_CAPTURE_STOP,           "S_top",                                "<control>E",                                   NULL,                           G_CALLBACK(capture_stop_cb) },
1449    { "/Capture/Restart",                        WIRESHARK_STOCK_CAPTURE_RESTART,        "_Restart",                             "<control>R",                                   NULL,                           G_CALLBACK(capture_restart_cb) },
1450    { "/Capture/CaptureFilters",         WIRESHARK_STOCK_CAPTURE_FILTER,         "Capture _Filters...",  NULL,                                                   NULL,                           G_CALLBACK(cfilter_dialog_cb) },
1451
1452 #endif /* HAVE_LIBPCAP */
1453    { "/Analyze/DisplayFilters",         WIRESHARK_STOCK_DISPLAY_FILTER,         "_Display Filters...",  NULL,                                                   NULL,                           G_CALLBACK(dfilter_dialog_cb) },
1454
1455    { "/Analyze/DisplayFilterMacros",                    NULL,                                   "Display Filter _Macros...",    NULL,                                   NULL,                           G_CALLBACK(macros_dialog_cb) },
1456    { "/Analyze/ApplyasColumn",                                  NULL,                                                   "Apply as Column",              NULL,                                   NULL,                           G_CALLBACK(apply_as_custom_column_cb) },
1457    { "/Analyze/ApplyasFilter",                                  NULL,                                                   "Apply as Filter",              NULL,                                   NULL,                           NULL },
1458
1459    { "/Analyze/ApplyasFilter/Selected",                 NULL, "_Selected" ,                             NULL, NULL, G_CALLBACK(tree_view_menu_apply_selected_cb) },
1460    { "/Analyze/ApplyasFilter/NotSelected",              NULL, "_Not Selected",                  NULL, NULL, G_CALLBACK(tree_view_menu_apply_not_selected_cb) },
1461    { "/Analyze/ApplyasFilter/AndSelected",              NULL, UTF8_HORIZONTAL_ELLIPSIS " _and Selected",                NULL, NULL, G_CALLBACK(tree_view_menu_apply_and_selected_cb) },
1462    { "/Analyze/ApplyasFilter/OrSelected",               NULL, UTF8_HORIZONTAL_ELLIPSIS " _or Selected",         NULL, NULL, G_CALLBACK(tree_view_menu_apply_or_selected_cb) },
1463    { "/Analyze/ApplyasFilter/AndNotSelected",   NULL, UTF8_HORIZONTAL_ELLIPSIS " a_nd not Selected",    NULL, NULL, G_CALLBACK(tree_view_menu_apply_and_not_selected_cb) },
1464    { "/Analyze/ApplyasFilter/OrNotSelected",    NULL, UTF8_HORIZONTAL_ELLIPSIS " o_r not Selected",     NULL, NULL, G_CALLBACK(tree_view_menu_apply_or_not_selected_cb) },
1465
1466    { "/Analyze/PrepareaFilter",                                 NULL, "Prepare a Filter",               NULL, NULL, NULL },
1467    { "/Analyze/PrepareaFilter/Selected",                NULL, "_Selected" ,                             NULL, NULL, G_CALLBACK(tree_view_menu_prepare_selected_cb) },
1468    { "/Analyze/PrepareaFilter/NotSelected",             NULL, "_Not Selected",                  NULL, NULL, G_CALLBACK(tree_view_menu_prepare_not_selected_cb) },
1469    { "/Analyze/PrepareaFilter/AndSelected",             NULL, UTF8_HORIZONTAL_ELLIPSIS " _and Selected",                NULL, NULL, G_CALLBACK(tree_view_menu_prepare_and_selected_cb) },
1470    { "/Analyze/PrepareaFilter/OrSelected",              NULL, UTF8_HORIZONTAL_ELLIPSIS " _or Selected",         NULL, NULL, G_CALLBACK(tree_view_menu_prepare_or_selected_cb) },
1471    { "/Analyze/PrepareaFilter/AndNotSelected",  NULL, UTF8_HORIZONTAL_ELLIPSIS " a_nd not Selected",    NULL, NULL, G_CALLBACK(tree_view_menu_prepare_and_not_selected_cb) },
1472    { "/Analyze/PrepareaFilter/OrNotSelected",   NULL, UTF8_HORIZONTAL_ELLIPSIS " o_r not Selected",     NULL, NULL, G_CALLBACK(tree_view_menu_prepare_or_not_selected_cb) },
1473
1474    { "/Analyze/EnabledProtocols",       WIRESHARK_STOCK_CHECKBOX, "_Enabled Protocols...",      "<shift><control>E", NULL, G_CALLBACK(proto_cb) },
1475    { "/Analyze/DecodeAs",       WIRESHARK_STOCK_DECODE_AS, "Decode _As...",                     NULL, NULL, G_CALLBACK(decode_as_cb) },
1476    { "/Analyze/UserSpecifiedDecodes",   WIRESHARK_STOCK_DECODE_AS, "_User Specified Decodes...",                        NULL, NULL, G_CALLBACK(decode_show_cb) },
1477
1478    { "/Analyze/FollowTCPStream",                                                        NULL,           "Follow TCP Stream",                                    NULL, NULL, G_CALLBACK(follow_tcp_stream_cb) },
1479    { "/Analyze/FollowUDPStream",                                                        NULL,           "Follow UDP Stream",                                    NULL, NULL, G_CALLBACK(follow_udp_stream_cb) },
1480    { "/Analyze/FollowSSLStream",                                                        NULL,           "Follow SSL Stream",                                    NULL, NULL, G_CALLBACK(follow_ssl_stream_cb) },
1481
1482  
1483    { "/Statistics/Summary",                     GTK_STOCK_PROPERTIES,                   "_Summary",                             NULL,                                                   NULL,                           G_CALLBACK(summary_open_cb) },
1484    { "/Statistics/ProtocolHierarchy",                           NULL,                   "_Protocol Hierarchy",  NULL,                                                   NULL,                           G_CALLBACK(proto_hier_stats_cb) },
1485    { "/Statistics/Conversations",       WIRESHARK_STOCK_CONVERSATIONS,  "Conversations",                NULL,                                                   NULL,                           G_CALLBACK(init_conversation_notebook_cb) },
1486    { "/Statistics/Endpoints",   WIRESHARK_STOCK_ENDPOINTS,                      "Endpoints",                    NULL,                                                   NULL,                           G_CALLBACK(init_hostlist_notebook_cb) },
1487
1488    { "/Tools/FirewallACLRules",         NULL,                                                   "Firewall ACL Rules",   NULL,                                                   NULL,                           G_CALLBACK(firewall_rule_cb) },
1489
1490    { "/WSinternal/Dissectortables",     NULL,                                                   "Dissector tables",             NULL,                                                   NULL,                           G_CALLBACK(dissector_tables_dlg_cb) },
1491
1492    { "/Help/Contents",                          GTK_STOCK_HELP,                                 "_Contents",                    "F1",                                                   NULL,                           G_CALLBACK(help_menu_cont_cb) },
1493    { "/Help/FAQs",                  NULL,                           "FAQ's",                NULL,                           NULL,               G_CALLBACK(help_menu_faq_cb) },
1494    { "/Help/ManualPages",           NULL,                           "ManualPages",          NULL,                           NULL,               NULL },
1495    { "/Help/ManualPages/Wireshark", NULL,                           "Wireshark",            NULL,                           NULL,               G_CALLBACK(help_menu_wireshark_cb) },
1496    { "/Help/ManualPages/WiresharkFilter", NULL,                     "Wireshark Filter",     NULL,                           NULL,               G_CALLBACK(help_menu_wireshark_flt_cb) },
1497    { "/Help/ManualPages/TShark",        NULL,                                                   "Wireshark",                    NULL,                                                   NULL,                           G_CALLBACK(help_menu_Tshark_cb) },
1498    { "/Help/ManualPages/RawShark",      NULL,                                                   "RawShark",                             NULL,                                                   NULL,                           G_CALLBACK(help_menu_RawShark_cb) },
1499    { "/Help/ManualPages/Dumpcap",       NULL,                                                   "Dumpcap",                              NULL,                                                   NULL,                           G_CALLBACK(help_menu_Dumpcap_cb) },
1500    { "/Help/ManualPages/Mergecap",      NULL,                                                   "Mergecap",                             NULL,                                                   NULL,                           G_CALLBACK(help_menu_Mergecap_cb) },
1501    { "/Help/ManualPages/Editcap",       NULL,                                                   "Editcap",                              NULL,                                                   NULL,                           G_CALLBACK(help_menu_Editcap_cb) },
1502    { "/Help/ManualPages/Text2pcap",     NULL,                                                   "Text2pcap",                    NULL,                                                   NULL,                           G_CALLBACK(help_menu_Text2pcap_cb) },
1503
1504    { "/Help/Website",                           GTK_STOCK_HOME,                                 "Website",                              NULL,                                                   NULL,                           G_CALLBACK(help_menu_Website_cb) },
1505    { "/Help/Wiki",                                      WIRESHARK_STOCK_WIKI,                   "Wiki",                                 NULL,                                                   NULL,                           G_CALLBACK(help_menu_Wiki_cb) },
1506    { "/Help/Downloads",                         NULL,                                                   "Downloads",                    NULL,                                                   NULL,                           G_CALLBACK(help_menu_Downloads_cb) },
1507    { "/Help/SampleCaptures",            NULL,                                                   "Sample Captures",              NULL,                                                   NULL,                           G_CALLBACK(help_menu_SampleCaptures_cb) },
1508    { "/Help/SupportedProtocols",        NULL,                                   "_Supported Protocols (slow!)", NULL,                                                   NULL,                           G_CALLBACK(supported_cb) },
1509    { "/Help/AboutWireshark",            WIRESHARK_STOCK_ABOUT,                  "_About Wireshark",             NULL,                                                   NULL,                           G_CALLBACK(about_wireshark_cb) },
1510 };
1511
1512 static const GtkToggleActionEntry main_menu_bar_toggle_action_entries[] = 
1513 {
1514         /* name, stock id, label, accel, tooltip, callback, is_active */
1515         {"/View/MainToolbar",   NULL, "_Main Toolbar",  NULL, NULL,     G_CALLBACK(main_toolbar_show_hide_cb), TRUE}, 
1516         {"/View/FilterToolbar", NULL, "_FilterToolbar", NULL, NULL,     G_CALLBACK(filter_toolbar_show_hide_cb), TRUE}, 
1517 #ifdef HAVE_AIRPCAP
1518         {"/View/WirelessToolbar", NULL, "_WirelessToolbar", NULL, NULL, G_CALLBACK(wireless_toolbar_show_hide_cb), TRUE}, 
1519 #endif /* HAVE_AIRPCAP */
1520         {"/View/Statusbar",             NULL, "_Statusbar", NULL, NULL, G_CALLBACK(status_bar_show_hide_cb), TRUE}, 
1521         {"/View/PacketList",    NULL, "Packet _List", NULL, NULL,       G_CALLBACK(packet_list_show_hide_cb), TRUE}, 
1522         {"/View/PacketDetails", NULL, "Packet _Details", NULL, NULL,    G_CALLBACK(packet_details_show_hide_cb), TRUE}, 
1523         {"/View/PacketBytes",   NULL, "Packet _Bytes", NULL, NULL,      G_CALLBACK(packet_bytes_show_hide_cb), TRUE}, 
1524         {"/View/TimeDisplayFormat/DisplaySecondsWithHoursAndMinutes",   NULL, "Display Seconds with hours and minutes", NULL, NULL,     G_CALLBACK(view_menu_seconds_time_cb), FALSE}, 
1525         {"/View/NameResolution/EnableforMACLayer",                                              NULL, "Enable for _MAC Layer",                                  NULL, NULL, G_CALLBACK(view_menu_en_for_MAC_cb), TRUE},
1526         {"/View/NameResolution/EnableforNetworkLayer",                                  NULL, "Enable for _Network Layer",                              NULL, NULL, G_CALLBACK(view_menu_en_for_network_cb), TRUE },
1527         {"/View/NameResolution/EnableforTransportLayer",                                NULL, "Enable for _Transport Layer",                    NULL, NULL, G_CALLBACK(view_menu_en_for_transport_cb), TRUE },
1528         {"/View/ColorizePacketList",                                                                    NULL, "Colorize Packet List",                                   NULL, NULL, G_CALLBACK(view_menu_colorize_pkt_lst_cb), TRUE },
1529 #ifdef HAVE_LIBPCAP
1530         {"/View/AutoScrollinLiveCapture",                                                               NULL, "Auto Scroll in Li_ve Capture",                   NULL, NULL, G_CALLBACK(view_menu_colorize_auto_scroll_live_cb), TRUE },
1531 #endif
1532 };
1533
1534
1535
1536 static const GtkRadioActionEntry main_menu_bar_radio_view_time_entries [] =
1537 {
1538         /* name, stock id, label, accel, tooltip,  value */
1539         { "/View/TimeDisplayFormat/DateandTimeofDay",                                   NULL, "Date and Time of Day:   1970-01-01 01:02:03.123456", "<alt><control>1", NULL, TS_ABSOLUTE_WITH_DATE },
1540         { "/View/TimeDisplayFormat/TimeofDay",                                                  NULL, "Time of Day:   01:02:03.123456", "<alt><control>2", NULL, TS_ABSOLUTE },
1541         { "/View/TimeDisplayFormat/SecondsSinceEpoch",                                  NULL, "Seconds Since Epoch (1970-01-01):   1234567890.123456", "<alt><control>3", NULL, TS_EPOCH },
1542         { "/View/TimeDisplayFormat/SecondsSinceBeginningofCapture",             NULL, "Seconds Since Beginning of Capture:   123.123456", "<alt><control>4", NULL, TS_RELATIVE },
1543         { "/View/TimeDisplayFormat/SecondsSincePreviousCapturedPacket", NULL, "Seconds Since Previous Captured Packet:   1.123456", "<alt><control>5", NULL, TS_DELTA },
1544         { "/View/TimeDisplayFormat/SecondsSincePreviousDisplayedPacket",NULL, "Seconds Since Previous Displayed Packet:   1.123456", "<alt><control>6", NULL, TS_DELTA_DIS },
1545 };
1546
1547 static const GtkRadioActionEntry main_menu_bar_radio_view_time_fileformat_prec_entries [] =
1548 {
1549         /* name, stock id, label, accel, tooltip,  value */
1550         { "/View/TimeDisplayFormat/FileFormatPrecision-Automatic",              NULL, "Automatic (File Format Precision)",      NULL, NULL, TS_PREC_AUTO },
1551         { "/View/TimeDisplayFormat/FileFormatPrecision-Seconds",                NULL, "Seconds:   0",                                       NULL, NULL, TS_PREC_FIXED_SEC },
1552         { "/View/TimeDisplayFormat/FileFormatPrecision-Deciseconds",    NULL, "Deciseconds:   0.1",                                     NULL, NULL, TS_PREC_FIXED_DSEC },
1553         { "/View/TimeDisplayFormat/FileFormatPrecision-Centiseconds",   NULL, "Centiseconds:  0.12",                            NULL, NULL, TS_PREC_FIXED_CSEC },
1554         { "/View/TimeDisplayFormat/FileFormatPrecision-Milliseconds",   NULL, "Milliseconds:  0.123",                           NULL, NULL, TS_PREC_FIXED_MSEC },
1555         { "/View/TimeDisplayFormat/FileFormatPrecision-Microseconds",   NULL, "Microseconds:  0.123456",                        NULL, NULL, TS_PREC_FIXED_USEC },
1556         { "/View/TimeDisplayFormat/FileFormatPrecision-Nanoseconds",    NULL, "Nanoseconds:   0.123456789",                     NULL, NULL, TS_PREC_FIXED_NSEC },
1557 };
1558 #else /* MAIN_MENU_USE_UIMANAGER */
1559 /*
1560  * Main menu.
1561  *
1562  * Please do not use keystrokes that are used as "universal" shortcuts in
1563  * various desktop environments:
1564  *
1565  *   Windows:
1566  *      http://support.microsoft.com/kb/126449
1567  *
1568  *   GNOME:
1569  *      http://library.gnome.org/users/user-guide/nightly/keyboard-skills.html.en
1570  *
1571  *   KDE:
1572  *      http://developer.kde.org/documentation/standards/kde/style/keys/shortcuts.html
1573  *
1574  * In particular, do not use the following <control> sequences for anything
1575  * other than their standard purposes:
1576  *
1577  *      <control>O      File->Open
1578  *      <control>S      File->Save
1579  *      <control>P      File->Print
1580  *      <control>W      File->Close
1581  *      <control>Q      File->Quit
1582  *      <control>Z      Edit->Undo (which we don't currently have)
1583  *      <control>X      Edit->Cut (which we don't currently have)
1584  *      <control>C      Edit->Copy (which we don't currently have)
1585  *      <control>V      Edit->Paste (which we don't currently have)
1586  *      <control>A      Edit->Select All (which we don't currently have)
1587  *
1588  * Note that some if not all of the Edit keys above already perform those
1589  * functions in text boxes, such as the Filter box.  Do no, under any
1590  * circumstances, make a change that keeps them from doing so.
1591  */
1592
1593 /* This is the GtkItemFactoryEntry structure used to generate new menus.
1594        Item 1: The menu path. The letter after the underscore indicates an
1595                accelerator key once the menu is open.
1596        Item 2: The accelerator key for the entry
1597        Item 3: The callback function.
1598        Item 4: The callback action.  This changes the parameters with
1599                which the function is called.  The default is 0.
1600        Item 5: The item type, used to define what kind of an item it is.
1601                Here are the possible values:
1602
1603                NULL               -> "<Item>"
1604                ""                 -> "<Item>"
1605                "<Title>"          -> create a title item
1606                "<Item>"           -> create a simple item
1607                "<ImageItem>"      -> create an item holding an image
1608                "<StockItem>"      -> create an item holding a stock image
1609                "<CheckItem>"      -> create a check item
1610                "<ToggleItem>"     -> create a toggle item
1611                "<RadioItem>"      -> create a radio item
1612                <path>             -> path of a radio item to link against
1613                "<Separator>"      -> create a separator
1614                "<Tearoff>"        -> create a tearoff separator
1615                "<Branch>"         -> create an item to hold sub items (optional)
1616                "<LastBranch>"     -> create a right justified branch
1617        Item 6: extra data needed for ImageItem and StockItem
1618     */
1619 static GtkItemFactoryEntry menu_items[] =
1620 {
1621     {"/_File", NULL, NULL, 0, "<Branch>", NULL,},
1622     {"/File/_Open...", "<control>O", GTK_MENU_FUNC(file_open_cmd_cb),
1623                              0, "<StockItem>", GTK_STOCK_OPEN,},
1624     {"/File/Open _Recent", NULL, NULL, 0, "<Branch>", NULL,},
1625     {"/File/_Merge...", NULL, GTK_MENU_FUNC(file_merge_cmd_cb), 0, NULL, NULL,},
1626     {"/File/_Close", "<control>W", GTK_MENU_FUNC(file_close_cmd_cb),
1627                              0, "<StockItem>", GTK_STOCK_CLOSE,},
1628     {"/File/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
1629     {"/File/_Save", "<control>S", GTK_MENU_FUNC(file_save_cmd_cb),
1630                              0, "<StockItem>", GTK_STOCK_SAVE,},
1631     {"/File/Save _As...", "<shift><control>S", GTK_MENU_FUNC(file_save_as_cmd_cb),
1632                              0, "<StockItem>", GTK_STOCK_SAVE_AS,},
1633     {"/File/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
1634     {"/File/File Set", NULL, NULL, 0, "<Branch>", NULL,},
1635     {"/File/File Set/List Files", NULL, GTK_MENU_FUNC(fileset_cb), 0, "<StockItem>", WIRESHARK_STOCK_FILE_SET_LIST,},
1636     {"/File/File Set/Next File", NULL, GTK_MENU_FUNC(fileset_next_cb), 0, "<StockItem>", WIRESHARK_STOCK_FILE_SET_NEXT,},
1637     {"/File/File Set/Previous File", NULL, GTK_MENU_FUNC(fileset_previous_cb), 0, "<StockItem>", WIRESHARK_STOCK_FILE_SET_PREVIOUS,},
1638     {"/File/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
1639     {"/File/_Export", NULL, NULL, 0, "<Branch>", NULL,},
1640 #if _WIN32
1641     {"/File/Export/File...", NULL, GTK_MENU_FUNC(export_text_cmd_cb),
1642                          0, NULL, NULL,},
1643 #else
1644     {"/File/Export/as \"Plain _Text\" file...", NULL, GTK_MENU_FUNC(export_text_cmd_cb),
1645                              0, NULL, NULL,},
1646     {"/File/Export/as \"_PostScript\" file...", NULL, GTK_MENU_FUNC(export_ps_cmd_cb),
1647                              0, NULL, NULL,},
1648     {"/File/Export/as \"_CSV\" (Comma Separated Values packet summary) file...",
1649                              NULL, GTK_MENU_FUNC(export_csv_cmd_cb), 0, NULL, NULL,},
1650     {"/File/Export/as \"C _Arrays\" (packet bytes) file...", NULL, GTK_MENU_FUNC(export_carrays_cmd_cb),
1651                              0, NULL, NULL,},
1652     {"/File/Export/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
1653     {"/File/Export/as XML - \"P_SML\" (packet summary) file...", NULL, GTK_MENU_FUNC(export_psml_cmd_cb),
1654                              0, NULL, NULL,},
1655     {"/File/Export/as XML - \"P_DML\" (packet details) file...", NULL, GTK_MENU_FUNC(export_pdml_cmd_cb),
1656                              0, NULL, NULL,},
1657     {"/File/Export/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
1658 #endif
1659     {"/File/Export/Selected Packet _Bytes...", "<control>H", GTK_MENU_FUNC(savehex_cb),
1660                              0, NULL, NULL,},
1661     {"/File/Export/_Objects/_HTTP", NULL, GTK_MENU_FUNC(eo_http_cb), 0, NULL, NULL,},
1662     {"/File/Export/_Objects/_DICOM", NULL, GTK_MENU_FUNC(eo_dicom_cb), 0, NULL, NULL,},
1663     {"/File/Export/_Objects/_SMB", NULL, GTK_MENU_FUNC(eo_smb_cb), 0, NULL, NULL,},
1664     {"/File/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
1665     {"/File/_Print...", "<control>P", GTK_MENU_FUNC(file_print_cmd_cb),
1666                              0, "<StockItem>", GTK_STOCK_PRINT,},
1667     {"/File/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
1668     {"/File/_Quit", "<control>Q", GTK_MENU_FUNC(file_quit_cmd_cb),
1669                              0, "<StockItem>", GTK_STOCK_QUIT,},
1670     {"/_Edit", NULL, NULL, 0, "<Branch>", NULL,},
1671     {"/Edit/Copy", NULL, NULL, 0, "<Branch>", NULL,},
1672     {"/Edit/Copy/Description", "<shift><control>D", GTK_MENU_FUNC(copy_selected_plist_cb), COPY_SELECTED_DESCRIPTION, NULL, NULL,},
1673     {"/Edit/Copy/Fieldname", "<shift><control>F", GTK_MENU_FUNC(copy_selected_plist_cb), COPY_SELECTED_FIELDNAME, NULL, NULL,},
1674     {"/Edit/Copy/Value", "<shift><control>V", GTK_MENU_FUNC(copy_selected_plist_cb), COPY_SELECTED_VALUE, NULL, NULL,},
1675     {"/Edit/Copy/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
1676     {"/Edit/Copy/As Filter", "<shift><control>C", GTK_MENU_FUNC(match_selected_ptree_cb),
1677                        MATCH_SELECTED_REPLACE|MATCH_SELECTED_COPY_ONLY, NULL, NULL,},
1678 #if 0
1679     /*
1680      * Un-#if this when we actually implement Cut/Copy/Paste for the
1681      * packet list and packet detail windows.
1682      *
1683      * Note: when we implement Cut/Copy/Paste in those windows, we
1684      * will almost certainly want to allow multiple packets to be
1685      * selected in the packet list pane and multiple packet detail
1686      * items to be selected in the packet detail pane, so that
1687      * the user can, for example, copy the summaries of multiple
1688      * packets to the clipboard from the packet list pane and multiple
1689      * packet detail items - perhaps *all* packet detail items - from
1690      * the packet detail pane.  Given that, we'll also want to
1691      * implement Select All.
1692      *
1693      * If multiple packets are selected, we would probably display nothing
1694      * in the packet detail pane, just as we do if no packet is selected,
1695      * and any menu items etc. that would pertain only to a single packet
1696      * would be disabled.
1697      *
1698      * If multiple packet detail items are selected, we would probably
1699      * disable all items that pertain only to a single packet detail
1700      * item, such as some items in the status bar.
1701      *
1702      * XXX - the actions for these will be different depending on what
1703      * widget we're in; ^C should copy from the filter text widget if
1704      * we're in that widget, the packet list if we're in that widget
1705      * (presumably copying the summaries of selected packets to the
1706      * clipboard, e.g. the text copy would be the text of the columns),
1707      * the packet detail if we're in that widget (presumably copying
1708      * the contents of selected protocol tree items to the clipboard,
1709      * e.g. the text copy would be the text displayed for those items),
1710      * etc..
1711      *
1712      * Given that those menu items should also affect text widgets
1713      * such as the filter box, we would again want Select All, and,
1714      * at least for the filter box, we would also want Undo and Redo.
1715      * We would only want Cut, Paste, Undo, and Redo for the packet
1716      * list and packet detail panes if we support modifying them.
1717      */
1718     {"/Edit/_Undo", "<control>Z", NULL,
1719                              0, "<StockItem>", GTK_STOCK_UNDO,},
1720     {"/Edit/_Redo", "<shift><control>Z", NULL,
1721                              0, "<StockItem>", GTK_STOCK_REDO,},
1722     {"/Edit/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
1723     {"/Edit/Cu_t", "<control>X", NULL,
1724                              0, "<StockItem>", GTK_STOCK_CUT,},
1725     {"/Edit/_Copy", "<control>C", NULL,
1726                              0, "<StockItem>", GTK_STOCK_COPY,},
1727     {"/Edit/_Paste", "<control>V", NULL,
1728                              0, "<StockItem>", GTK_STOCK_PASTE,},
1729     {"/Edit/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
1730     {"/Edit/Select _All", "<control>A", NULL, 0,
1731 #ifdef GTK_STOCK_SELECT_ALL     /* first appeared in 2.10 */
1732                              "<StockItem>", GTK_STOCK_SELECT_ALL,
1733 #else
1734                              NULL, NULL,
1735 #endif /* GTK_STOCK_SELECT_ALL */
1736     },
1737 #endif /* 0 */
1738     {"/Edit/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
1739     {"/Edit/_Find Packet...",                             "<control>F", GTK_MENU_FUNC(find_frame_cb), 0, "<StockItem>", GTK_STOCK_FIND,},
1740     {"/Edit/Find Ne_xt",                                  "<control>N", GTK_MENU_FUNC(find_next_cb), 0, NULL, NULL,},
1741     {"/Edit/Find Pre_vious",                              "<control>B", GTK_MENU_FUNC(find_previous_cb), 0, NULL, NULL,},
1742     {"/Edit/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
1743 #ifdef NEW_PACKET_LIST
1744     {"/Edit/_Mark Packet (toggle)",                       "<control>M", GTK_MENU_FUNC(new_packet_list_mark_frame_cb),0, NULL, NULL,},
1745     {"/Edit/Mark All Displayed Packets (toggle)",  "<shift><control>M", GTK_MENU_FUNC(new_packet_list_mark_all_displayed_frames_cb), 0, NULL, NULL,},
1746     {"/Edit/Unmark All Packets",                     "<alt><control>M", GTK_MENU_FUNC(new_packet_list_unmark_all_frames_cb), 0, NULL, NULL,},
1747     {"/Edit/Find Next Mark",                       "<shift><control>N", GTK_MENU_FUNC(find_next_mark_cb), 0, NULL, NULL,},
1748     {"/Edit/Find Previous Mark",                   "<shift><control>B", GTK_MENU_FUNC(find_prev_mark_cb), 0, NULL, NULL,},
1749     {"/Edit/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
1750     {"/Edit/_Ignore Packet (toggle)",                     "<control>D", GTK_MENU_FUNC(new_packet_list_ignore_frame_cb), 0, NULL, NULL,},
1751     /*
1752      * XXX - this next one overrides /Edit/Copy/Description
1753      */
1754     {"/Edit/Ignore All Displayed Packets (toggle)","<shift><control>D", GTK_MENU_FUNC(new_packet_list_ignore_all_displayed_frames_cb), 0, NULL, NULL,},
1755     {"/Edit/U_n-Ignore All Packets",                 "<alt><control>D", GTK_MENU_FUNC(new_packet_list_unignore_all_frames_cb), 0, NULL, NULL,},
1756     {"/Edit/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
1757     {"/Edit/Set Time Reference (toggle)",                 "<control>T", GTK_MENU_FUNC(reftime_frame_cb), REFTIME_TOGGLE, "<StockItem>", WIRESHARK_STOCK_TIME,},
1758     {"/Edit/Un-Time Reference All Packets",          "<alt><control>T", GTK_MENU_FUNC(new_packet_list_untime_reference_all_frames_cb), 0, NULL, NULL,},
1759     {"/Edit/Find Next Time Reference",               "<alt><control>N", GTK_MENU_FUNC(reftime_frame_cb), REFTIME_FIND_NEXT, NULL, NULL,},
1760     {"/Edit/Find Previous Time Reference",           "<alt><control>B", GTK_MENU_FUNC(reftime_frame_cb), REFTIME_FIND_PREV, NULL, NULL,},
1761 #else /* NEW_PACKET_LIST */
1762     /*
1763      * XXX - this should be changed to match the list used with the new
1764      * packet list, assuming we don't just drop the old packet list
1765      * code first.
1766      */
1767     {"/Edit/_Mark Packet (toggle)", "<control>M", GTK_MENU_FUNC(packet_list_mark_frame_cb),
1768                        0, NULL, NULL,},
1769     {"/Edit/Find Next Mark", "<shift><control>N", GTK_MENU_FUNC(find_next_mark_cb),
1770                        0, NULL, NULL,},
1771     {"/Edit/Find Previous Mark", "<shift><control>B", GTK_MENU_FUNC(find_prev_mark_cb),
1772                        0, NULL, NULL,},
1773     {"/Edit/Mark _All Displayed Packets (toggle)", "<shift><control>M", GTK_MENU_FUNC(packet_list_mark_all_frames_cb), 0, NULL, NULL,},
1774     {"/Edit/_Unmark All Packets", "<alt><control>M", GTK_MENU_FUNC(packet_list_unmark_all_frames_cb), 0, NULL, NULL,},
1775     {"/Edit/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
1776     {"/Edit/_Ignore Packet (toggle)", "<control>D", GTK_MENU_FUNC(packet_list_ignore_frame_cb),
1777                        0, NULL, NULL,},
1778     {"/Edit/Ignore All Displayed Packets (toggle)", "<shift><control>D", GTK_MENU_FUNC(packet_list_ignore_all_frames_cb),
1779                        0, NULL, NULL,},
1780     {"/Edit/U_n-Ignore All Packets", "<alt><control>D", GTK_MENU_FUNC(packet_list_unignore_all_frames_cb),
1781                        0, NULL, NULL,},
1782     {"/Edit/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
1783     {"/Edit/Set Time Reference (toggle)", "<control>T", GTK_MENU_FUNC(reftime_frame_cb),
1784                         REFTIME_TOGGLE, "<StockItem>", WIRESHARK_STOCK_TIME,},
1785     {"/Edit/Find Next Time Reference", "<alt><shift><control>N", GTK_MENU_FUNC(reftime_frame_cb), REFTIME_FIND_NEXT, NULL, NULL,},
1786     {"/Edit/Find Previous Time Reference", "<alt><shift><control>B", GTK_MENU_FUNC(reftime_frame_cb), REFTIME_FIND_PREV, NULL, NULL,},
1787 #endif /* NEW_PACKET_LIST */
1788     {"/Edit/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
1789     {"/Edit/_Configuration Profiles...", "<shift><control>A", GTK_MENU_FUNC(profile_dialog_cb), 0, NULL, NULL,},
1790     {"/Edit/_Preferences...", "<shift><control>P", GTK_MENU_FUNC(prefs_page_cb),
1791                              PREFS_PAGE_USER_INTERFACE, "<StockItem>", GTK_STOCK_PREFERENCES,},
1792     {"/_View", NULL, NULL, 0, "<Branch>", NULL,},
1793     {"/View/_Main Toolbar", NULL, GTK_MENU_FUNC(show_hide_cb), SHOW_HIDE_MAIN_TOOLBAR, "<CheckItem>", NULL,},
1794     {"/View/_Filter Toolbar", NULL, GTK_MENU_FUNC(show_hide_cb), SHOW_HIDE_FILTER_TOOLBAR, "<CheckItem>", NULL,},
1795 #ifdef HAVE_AIRPCAP
1796     {"/View/_Wireless Toolbar", NULL, GTK_MENU_FUNC(show_hide_cb), SHOW_HIDE_AIRPCAP_TOOLBAR, "<CheckItem>", NULL,},
1797 #endif
1798     {"/View/_Statusbar", NULL, GTK_MENU_FUNC(show_hide_cb), SHOW_HIDE_STATUSBAR, "<CheckItem>", NULL,},
1799     {"/View/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
1800     {"/View/Packet _List", NULL, GTK_MENU_FUNC(show_hide_cb), SHOW_HIDE_PACKET_LIST, "<CheckItem>", NULL,},
1801     {"/View/Packet _Details", NULL, GTK_MENU_FUNC(show_hide_cb), SHOW_HIDE_TREE_VIEW, "<CheckItem>", NULL,},
1802     {"/View/Packet _Bytes", NULL, GTK_MENU_FUNC(show_hide_cb), SHOW_HIDE_BYTE_VIEW, "<CheckItem>", NULL,},
1803     {"/View/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
1804     {"/View/_Time Display Format", NULL, NULL, 0, "<Branch>", NULL,},
1805     {"/View/Time Display Format/Date and Time of Day:   1970-01-01 01:02:03.123456", "<alt><control>1", GTK_MENU_FUNC(timestamp_format_cb),
1806                         TS_ABSOLUTE_WITH_DATE, "<RadioItem>", NULL,},
1807     {"/View/Time Display Format/Time of Day:   01:02:03.123456", "<alt><control>2", GTK_MENU_FUNC(timestamp_format_cb),
1808                         TS_ABSOLUTE, "/View/Time Display Format/Date and Time of Day:   1970-01-01 01:02:03.123456", NULL,},
1809     {"/View/Time Display Format/Seconds Since Epoch (1970-01-01):   1234567890.123456", "<alt><control>3", GTK_MENU_FUNC(timestamp_format_cb),
1810                         TS_EPOCH, "/View/Time Display Format/Date and Time of Day:   1970-01-01 01:02:03.123456", NULL,},
1811     {"/View/Time Display Format/Seconds Since Beginning of Capture:   123.123456", "<alt><control>4", GTK_MENU_FUNC(timestamp_format_cb),
1812                         TS_RELATIVE, "/View/Time Display Format/Date and Time of Day:   1970-01-01 01:02:03.123456", NULL,},
1813     {"/View/Time Display Format/Seconds Since Previous Captured Packet:   1.123456", "<alt><control>5", GTK_MENU_FUNC(timestamp_format_cb),
1814                         TS_DELTA, "/View/Time Display Format/Date and Time of Day:   1970-01-01 01:02:03.123456", NULL,},
1815     {"/View/Time Display Format/Seconds Since Previous Displayed Packet:   1.123456", "<alt><control>6", GTK_MENU_FUNC(timestamp_format_cb),
1816                         TS_DELTA_DIS, "/View/Time Display Format/Date and Time of Day:   1970-01-01 01:02:03.123456", NULL,},
1817     {"/View/Time Display Format/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
1818     {"/View/Time Display Format/Automatic (File Format Precision)", NULL, GTK_MENU_FUNC(timestamp_precision_cb),
1819                         TS_PREC_AUTO, "<RadioItem>", NULL,},
1820     {"/View/Time Display Format/Seconds:   0", NULL, GTK_MENU_FUNC(timestamp_precision_cb),
1821                         TS_PREC_FIXED_SEC, "/View/Time Display Format/Automatic (File Format Precision)", NULL,},
1822     {"/View/Time Display Format/Deciseconds:   0.1", NULL, GTK_MENU_FUNC(timestamp_precision_cb),
1823                         TS_PREC_FIXED_DSEC, "/View/Time Display Format/Automatic (File Format Precision)", NULL,},
1824     {"/View/Time Display Format/Centiseconds:   0.12", NULL, GTK_MENU_FUNC(timestamp_precision_cb),
1825                         TS_PREC_FIXED_CSEC, "/View/Time Display Format/Automatic (File Format Precision)", NULL,},
1826     {"/View/Time Display Format/Milliseconds:   0.123", NULL, GTK_MENU_FUNC(timestamp_precision_cb),
1827                         TS_PREC_FIXED_MSEC, "/View/Time Display Format/Automatic (File Format Precision)", NULL,},
1828     {"/View/Time Display Format/Microseconds:   0.123456", NULL, GTK_MENU_FUNC(timestamp_precision_cb),
1829                         TS_PREC_FIXED_USEC, "/View/Time Display Format/Automatic (File Format Precision)", NULL,},
1830     {"/View/Time Display Format/Nanoseconds:   0.123456789", NULL, GTK_MENU_FUNC(timestamp_precision_cb),
1831                         TS_PREC_FIXED_NSEC, "/View/Time Display Format/Automatic (File Format Precision)", NULL,},
1832     {"/View/Time Display Format/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
1833     {"/View/Time Display Format/Display Seconds with hours and minutes", "<alt><control>0", GTK_MENU_FUNC(timestamp_seconds_time_cb), 0, "<CheckItem>", NULL,},
1834     {"/View/Name Resol_ution", NULL, NULL, 0, "<Branch>", NULL,},
1835     {"/View/Name Resolution/_Resolve Name", NULL, GTK_MENU_FUNC(resolve_name_cb), 0, NULL, NULL,},
1836     {"/View/Name Resolution/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
1837     {"/View/Name Resolution/Enable for _MAC Layer", NULL, GTK_MENU_FUNC(name_resolution_cb), RESOLV_MAC, "<CheckItem>", NULL,},
1838     {"/View/Name Resolution/Enable for _Network Layer", NULL, GTK_MENU_FUNC(name_resolution_cb), RESOLV_NETWORK, "<CheckItem>", NULL,},
1839     {"/View/Name Resolution/Enable for _Transport Layer", NULL, GTK_MENU_FUNC(name_resolution_cb), RESOLV_TRANSPORT, "<CheckItem>", NULL,},
1840     {"/View/Colorize Packet List", NULL, colorize_cb, 0, "<CheckItem>", NULL,},
1841 #ifdef HAVE_LIBPCAP
1842     {"/View/Auto Scroll in Li_ve Capture", NULL, GTK_MENU_FUNC(auto_scroll_live_cb), 0, "<CheckItem>", NULL,},
1843 #endif
1844     {"/View/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
1845     {"/View/_Zoom In", "<control>plus", GTK_MENU_FUNC(view_zoom_in_cb),
1846                              0, "<StockItem>", GTK_STOCK_ZOOM_IN,},
1847     {"/View/Zoom _Out", "<control>minus", GTK_MENU_FUNC(view_zoom_out_cb),
1848                              0, "<StockItem>", GTK_STOCK_ZOOM_OUT,},
1849     {"/View/_Normal Size", "<control>equal", GTK_MENU_FUNC(view_zoom_100_cb),
1850                              0, "<StockItem>", GTK_STOCK_ZOOM_100,},
1851 #ifdef NEW_PACKET_LIST
1852     {"/View/Resize All Columns", "<shift><control>R", GTK_MENU_FUNC(new_packet_list_resize_columns_cb),
1853                        0, "<StockItem>", WIRESHARK_STOCK_RESIZE_COLUMNS,},
1854     {"/View/Displayed Columns", NULL, NULL, 0, NULL, NULL,},
1855 #else
1856     {"/View/Resize All Columns", "<shift><control>R", GTK_MENU_FUNC(packet_list_resize_columns_cb),
1857                        0, "<StockItem>", WIRESHARK_STOCK_RESIZE_COLUMNS,},
1858 #endif /* NEW_PACKET_LIST */
1859     {"/View/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
1860     {"/View/E_xpand Subtrees", "<shift>Right", GTK_MENU_FUNC(expand_tree_cb), 0, NULL, NULL,},
1861     {"/View/_Expand All", "<control>Right", GTK_MENU_FUNC(expand_all_cb),
1862                        0, NULL, NULL,},
1863     {"/View/Collapse _All", "<control>Left", GTK_MENU_FUNC(collapse_all_cb),
1864                        0, NULL, NULL,},
1865     {"/View/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
1866     {"/View/Colorize Conversation", NULL, NULL, 0, "<Branch>",NULL,},
1867     {"/View/Colorize Conversation/Color 1", "<control>1",
1868                        GTK_MENU_FUNC(colorize_conversation_cb), 1*256, "<StockItem>", WIRESHARK_STOCK_COLOR1,},
1869     {"/View/Colorize Conversation/Color 2", "<control>2",
1870                        GTK_MENU_FUNC(colorize_conversation_cb), 2*256, "<StockItem>", WIRESHARK_STOCK_COLOR2,},
1871     {"/View/Colorize Conversation/Color 3", "<control>3",
1872                        GTK_MENU_FUNC(colorize_conversation_cb), 3*256, "<StockItem>", WIRESHARK_STOCK_COLOR3,},
1873     {"/View/Colorize Conversation/Color 4", "<control>4",
1874                        GTK_MENU_FUNC(colorize_conversation_cb), 4*256, "<StockItem>", WIRESHARK_STOCK_COLOR4,},
1875     {"/View/Colorize Conversation/Color 5", "<control>5",
1876                        GTK_MENU_FUNC(colorize_conversation_cb), 5*256, "<StockItem>", WIRESHARK_STOCK_COLOR5,},
1877     {"/View/Colorize Conversation/Color 6", "<control>6",
1878                        GTK_MENU_FUNC(colorize_conversation_cb), 6*256, "<StockItem>", WIRESHARK_STOCK_COLOR6,},
1879     {"/View/Colorize Conversation/Color 7", "<control>7",
1880                        GTK_MENU_FUNC(colorize_conversation_cb), 7*256, "<StockItem>", WIRESHARK_STOCK_COLOR7,},
1881     {"/View/Colorize Conversation/Color 8", "<control>8",
1882                        GTK_MENU_FUNC(colorize_conversation_cb), 8*256, "<StockItem>", WIRESHARK_STOCK_COLOR8,},
1883     {"/View/Colorize Conversation/Color 9", "<control>9",
1884                        GTK_MENU_FUNC(colorize_conversation_cb), 9*256, "<StockItem>", WIRESHARK_STOCK_COLOR9,},
1885     {"/View/Colorize Conversation/Color 10", "<control>0",
1886                        GTK_MENU_FUNC(colorize_conversation_cb), 10*256, "<StockItem>", WIRESHARK_STOCK_COLOR0,},
1887     {"/View/Colorize Conversation/<separator>", NULL,
1888                        NULL, 0, "<Separator>",NULL,},
1889     {"/View/Colorize Conversation/New Coloring Rule...", NULL,
1890                        GTK_MENU_FUNC(colorize_conversation_cb), 0, "<StockItem>", GTK_STOCK_SELECT_COLOR,},
1891     {"/View/Reset Coloring 1-10", "<control>space",
1892                        GTK_MENU_FUNC(colorize_conversation_cb), 255*256, NULL, NULL,},
1893     {"/View/_Coloring Rules...", NULL, color_display_cb,
1894                        0, "<StockItem>", GTK_STOCK_SELECT_COLOR,},
1895     {"/View/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
1896
1897
1898     {"/View/Show Packet in New _Window", NULL,
1899                        GTK_MENU_FUNC(new_window_cb), 0, NULL, NULL,},
1900     {"/View/_Reload", "<control>R", GTK_MENU_FUNC(file_reload_cmd_cb),
1901                              0, "<StockItem>", GTK_STOCK_REFRESH,},
1902     {"/_Go", NULL, NULL, 0, "<Branch>", NULL,},
1903     {"/Go/_Back", "<alt>Left",
1904                              GTK_MENU_FUNC(history_back_cb), 0, "<StockItem>", GTK_STOCK_GO_BACK,},
1905     {"/Go/_Forward", "<alt>Right",
1906                              GTK_MENU_FUNC(history_forward_cb), 0, "<StockItem>", GTK_STOCK_GO_FORWARD,},
1907     {"/Go/_Go to Packet...", "<control>G",
1908                              GTK_MENU_FUNC(goto_frame_cb), 0, "<StockItem>", GTK_STOCK_JUMP_TO,},
1909     {"/Go/Go to _Corresponding Packet", NULL, GTK_MENU_FUNC(goto_framenum_cb),
1910                        0, NULL, NULL,},
1911     {"/Go/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
1912     {"/Go/Previous Packet", "<control>Up",
1913                              GTK_MENU_FUNC(goto_previous_frame_cb), 0, "<StockItem>", GTK_STOCK_GO_UP,},
1914     {"/Go/Next Packet", "<control>Down",
1915                              GTK_MENU_FUNC(goto_next_frame_cb), 0, "<StockItem>", GTK_STOCK_GO_DOWN,},
1916     {"/Go/F_irst Packet", "<control>Home",
1917                              GTK_MENU_FUNC(goto_top_frame_cb), 0, "<StockItem>", GTK_STOCK_GOTO_TOP,},
1918     {"/Go/_Last Packet", "<control>End",
1919                              GTK_MENU_FUNC(goto_bottom_frame_cb), 0, "<StockItem>", GTK_STOCK_GOTO_BOTTOM,},
1920     {"/Go/Previous Packet In Conversation", "<control>bracketleft",
1921                              GTK_MENU_FUNC(goto_previous_frame_conversation_cb), 0, NULL, NULL,},
1922     {"/Go/Next Packet In Conversation", "<control>bracketright",
1923                              GTK_MENU_FUNC(goto_next_frame_conversation_cb), 0, NULL, NULL,},
1924 #ifdef HAVE_LIBPCAP
1925     {"/_Capture", NULL, NULL, 0, "<Branch>", NULL,},
1926     {"/Capture/_Interfaces...", "<control>I",
1927                              GTK_MENU_FUNC(capture_if_cb), 0, "<StockItem>", WIRESHARK_STOCK_CAPTURE_INTERFACES,},
1928     {"/Capture/_Options...", "<control>K",
1929                              GTK_MENU_FUNC(capture_prep_cb), 0, "<StockItem>", WIRESHARK_STOCK_CAPTURE_OPTIONS,},
1930     {"/Capture/_Start", "<control>E",
1931                              GTK_MENU_FUNC(capture_start_cb), 0, "<StockItem>", WIRESHARK_STOCK_CAPTURE_START,},
1932     {"/Capture/S_top", "<control>E", GTK_MENU_FUNC(capture_stop_cb),
1933                              0, "<StockItem>", WIRESHARK_STOCK_CAPTURE_STOP,},
1934     {"/Capture/_Restart", "<control>R", GTK_MENU_FUNC(capture_restart_cb),
1935                              0, "<StockItem>", WIRESHARK_STOCK_CAPTURE_RESTART,},
1936     {"/Capture/Capture _Filters...", NULL, GTK_MENU_FUNC(cfilter_dialog_cb),
1937                        0, "<StockItem>", WIRESHARK_STOCK_CAPTURE_FILTER,},
1938 #endif /* HAVE_LIBPCAP */
1939     {"/_Analyze", NULL, NULL, 0, "<Branch>", NULL,},
1940     {"/Analyze/_Display Filters...", NULL, GTK_MENU_FUNC(dfilter_dialog_cb),
1941                        0, "<StockItem>", WIRESHARK_STOCK_DISPLAY_FILTER,},
1942     {"/Analyze/Display Filter _Macros...", NULL, GTK_MENU_FUNC(macros_dialog_cb), 0, NULL, NULL,},
1943     {"/Analyze/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
1944     {"/Analyze/Apply as Column", NULL, GTK_MENU_FUNC(apply_as_custom_column_cb), 0, NULL, NULL},
1945     {"/Analyze/Appl_y as Filter", NULL, NULL, 0, "<Branch>", NULL,},
1946     {"/Analyze/Apply as Filter/_Selected", NULL, GTK_MENU_FUNC(match_selected_ptree_cb),
1947                        MATCH_SELECTED_REPLACE|MATCH_SELECTED_APPLY_NOW, NULL, NULL,},
1948     {"/Analyze/Apply as Filter/_Not Selected", NULL, GTK_MENU_FUNC(match_selected_ptree_cb),
1949                        MATCH_SELECTED_NOT|MATCH_SELECTED_APPLY_NOW, NULL, NULL,},
1950     {"/Analyze/Apply as Filter/" UTF8_HORIZONTAL_ELLIPSIS " _and Selected", NULL, GTK_MENU_FUNC(match_selected_ptree_cb),
1951                        MATCH_SELECTED_AND|MATCH_SELECTED_APPLY_NOW, NULL, NULL,},
1952     {"/Analyze/Apply as Filter/" UTF8_HORIZONTAL_ELLIPSIS " _or Selected", NULL, GTK_MENU_FUNC(match_selected_ptree_cb),
1953                        MATCH_SELECTED_OR|MATCH_SELECTED_APPLY_NOW, NULL, NULL,},
1954     {"/Analyze/Apply as Filter/" UTF8_HORIZONTAL_ELLIPSIS " a_nd not Selected", NULL, GTK_MENU_FUNC(match_selected_ptree_cb),
1955                        MATCH_SELECTED_AND_NOT|MATCH_SELECTED_APPLY_NOW, NULL, NULL,},
1956     {"/Analyze/Apply as Filter/" UTF8_HORIZONTAL_ELLIPSIS " o_r not Selected", NULL, GTK_MENU_FUNC(match_selected_ptree_cb),
1957                        MATCH_SELECTED_OR_NOT|MATCH_SELECTED_APPLY_NOW, NULL, NULL,},
1958     {"/Analyze/_Prepare a Filter", NULL, NULL, 0, "<Branch>", NULL,},
1959     {"/Analyze/Prepare a Filter/_Selected", NULL, GTK_MENU_FUNC(match_selected_ptree_cb),
1960                        MATCH_SELECTED_REPLACE, NULL, NULL,},
1961     {"/Analyze/Prepare a Filter/_Not Selected", NULL, GTK_MENU_FUNC(match_selected_ptree_cb),
1962                        MATCH_SELECTED_NOT, NULL, NULL,},
1963     {"/Analyze/Prepare a Filter/" UTF8_HORIZONTAL_ELLIPSIS " _and Selected", NULL, GTK_MENU_FUNC(match_selected_ptree_cb),
1964                        MATCH_SELECTED_AND, NULL, NULL,},
1965     {"/Analyze/Prepare a Filter/" UTF8_HORIZONTAL_ELLIPSIS " _or Selected", NULL, GTK_MENU_FUNC(match_selected_ptree_cb),
1966                        MATCH_SELECTED_OR, NULL, NULL,},
1967     {"/Analyze/Prepare a Filter/" UTF8_HORIZONTAL_ELLIPSIS " a_nd not Selected", NULL, GTK_MENU_FUNC(match_selected_ptree_cb),
1968                        MATCH_SELECTED_AND_NOT, NULL, NULL,},
1969     {"/Analyze/Prepare a Filter/" UTF8_HORIZONTAL_ELLIPSIS " o_r not Selected", NULL, GTK_MENU_FUNC(match_selected_ptree_cb),
1970                        MATCH_SELECTED_OR_NOT, NULL, NULL,},
1971     {"/Analyze/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
1972     {"/Analyze/_Enabled Protocols...", "<shift><control>E", GTK_MENU_FUNC(proto_cb),
1973                        0, "<StockItem>", WIRESHARK_STOCK_CHECKBOX,},
1974     {"/Analyze/Decode _As...", NULL, GTK_MENU_FUNC(decode_as_cb),
1975                        0, "<StockItem>", WIRESHARK_STOCK_DECODE_AS,},
1976     {"/Analyze/_User Specified Decodes...", NULL,
1977                        GTK_MENU_FUNC(decode_show_cb), 0, "<StockItem>", WIRESHARK_STOCK_DECODE_AS,},
1978     {"/Analyze/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
1979     {"/Analyze/_Follow TCP Stream", NULL,
1980                        GTK_MENU_FUNC(follow_tcp_stream_cb), 0, NULL, NULL,},
1981     {"/Analyze/_Follow UDP Stream", NULL,
1982                        GTK_MENU_FUNC(follow_udp_stream_cb), 0, NULL, NULL,},
1983     {"/Analyze/_Follow SSL Stream", NULL,
1984                        GTK_MENU_FUNC(follow_ssl_stream_cb), 0, NULL, NULL,},
1985     {"/_Statistics", NULL, NULL, 0, "<Branch>", NULL,},
1986     {"/Statistics/_Summary", NULL, GTK_MENU_FUNC(summary_open_cb), 0, "<StockItem>", GTK_STOCK_PROPERTIES,},
1987     {"/Statistics/_Protocol Hierarchy", NULL,
1988                        GTK_MENU_FUNC(proto_hier_stats_cb), 0, NULL, NULL,},
1989     {"/Statistics/Conversations", NULL,
1990                        GTK_MENU_FUNC(init_conversation_notebook_cb), 0, "<StockItem>", WIRESHARK_STOCK_CONVERSATIONS,},
1991     {"/Statistics/Endpoints", NULL,
1992                        GTK_MENU_FUNC(init_hostlist_notebook_cb), 0, "<StockItem>", WIRESHARK_STOCK_ENDPOINTS,},
1993     {"/Telephon_y", NULL, NULL, 0, "<Branch>", NULL,},
1994     {"/_Tools", NULL, NULL, 0, "<Branch>", NULL,},
1995     {"/Tools/Firewall ACL Rules", NULL,
1996                        firewall_rule_cb, 0, NULL, NULL,},
1997     {"/WS internal", NULL, NULL, 0, "<Branch>", NULL,},
1998     {"/WS internal/Dissector tables", NULL, GTK_MENU_FUNC(dissector_tables_dlg_cb),
1999                          0, NULL, NULL,},
2000     {"/_Help", NULL, NULL, 0, "<Branch>", NULL,},
2001     {"/Help/_Contents", "F1", GTK_MENU_FUNC(topic_menu_cb), HELP_CONTENT, "<StockItem>", GTK_STOCK_HELP,},
2002     {"/Help/FAQ's", NULL, GTK_MENU_FUNC(topic_menu_cb), ONLINEPAGE_FAQ, NULL, NULL,},
2003     {"/Help/Manual Pages", NULL, NULL, 0, "<Branch>", NULL,},
2004     {"/Help/Manual Pages/Wireshark", NULL, GTK_MENU_FUNC(topic_menu_cb), LOCALPAGE_MAN_WIRESHARK, NULL, NULL,},
2005     {"/Help/Manual Pages/Wireshark Filter", NULL, GTK_MENU_FUNC(topic_menu_cb), LOCALPAGE_MAN_WIRESHARK_FILTER, NULL, NULL,},
2006     {"/Help/Manual Pages/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
2007     {"/Help/Manual Pages/TShark", NULL, GTK_MENU_FUNC(topic_menu_cb), LOCALPAGE_MAN_TSHARK, NULL, NULL,},
2008     {"/Help/Manual Pages/RawShark", NULL, GTK_MENU_FUNC(topic_menu_cb), LOCALPAGE_MAN_RAWSHARK, NULL, NULL,},
2009     {"/Help/Manual Pages/Dumpcap", NULL, GTK_MENU_FUNC(topic_menu_cb), LOCALPAGE_MAN_DUMPCAP, NULL, NULL,},
2010     {"/Help/Manual Pages/Mergecap", NULL, GTK_MENU_FUNC(topic_menu_cb), LOCALPAGE_MAN_MERGECAP, NULL, NULL,},
2011     {"/Help/Manual Pages/Editcap", NULL, GTK_MENU_FUNC(topic_menu_cb), LOCALPAGE_MAN_EDITCAP, NULL, NULL,},
2012     {"/Help/Manual Pages/Text2pcap", NULL, GTK_MENU_FUNC(topic_menu_cb), LOCALPAGE_MAN_TEXT2PCAP, NULL, NULL,},
2013     {"/Help/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
2014     {"/Help/Website", NULL, GTK_MENU_FUNC(topic_menu_cb), ONLINEPAGE_HOME, "<StockItem>", GTK_STOCK_HOME,},
2015     {"/Help/Wiki", NULL, GTK_MENU_FUNC(topic_menu_cb), ONLINEPAGE_WIKI, "<StockItem>", WIRESHARK_STOCK_WIKI,},
2016     {"/Help/Downloads", NULL, GTK_MENU_FUNC(topic_menu_cb), ONLINEPAGE_DOWNLOAD, NULL, NULL,},
2017     {"/Help/Sample Captures", NULL, GTK_MENU_FUNC(topic_menu_cb), ONLINEPAGE_SAMPLE_FILES, NULL, NULL,},
2018     {"/Help/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
2019     {"/Help/_Supported Protocols (slow!)", NULL, GTK_MENU_FUNC(supported_cb), 0, NULL, NULL,},
2020     {"/Help/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
2021     {"/Help/_About Wireshark", NULL, GTK_MENU_FUNC(about_wireshark_cb),
2022                        0, "<StockItem>", WIRESHARK_STOCK_ABOUT}
2023 };
2024
2025 /* calculate the number of menu_items */
2026 static int nmenu_items = sizeof(menu_items) / sizeof(menu_items[0]);
2027 #endif /* MAIN_MENU_USE_UIMANAGER */
2028
2029 static int initialize = TRUE;
2030 #ifdef MAIN_MENU_USE_UIMANAGER
2031     GtkActionGroup    *main_menu_bar_action_group;
2032 #else
2033 static GtkItemFactory *main_menu_factory = NULL;
2034 #endif
2035 static GtkUIManager *ui_manager_packet_list_heading = NULL;
2036 static GtkUIManager *ui_manager_packet_list_menu = NULL;
2037 static GtkUIManager *ui_manager_tree_view_menu = NULL;
2038 static GtkUIManager *ui_manager_bytes_menu = NULL;
2039 static GtkUIManager *ui_manager_statusbar_profiles_menu = NULL;
2040 static GSList *popup_menu_list = NULL;
2041
2042 static GtkAccelGroup *grp;
2043
2044 static void
2045 select_bytes_view_cb (GtkRadioAction *action, GtkRadioAction *current _U_, gpointer user_data _U_)
2046 {
2047         gint value;
2048
2049         value = gtk_radio_action_get_current_value (action);
2050         /* Fix me */
2051         select_bytes_view( NULL, NULL, value);
2052 }
2053
2054 static void
2055 sort_ascending_cb(GtkWidget *widget, gpointer user_data)
2056 {
2057         new_packet_list_column_menu_cb( widget , user_data, COLUMN_SELECTED_SORT_ASCENDING);
2058 }
2059
2060 static void
2061 sort_descending_cb(GtkWidget *widget, gpointer user_data)
2062 {
2063         new_packet_list_column_menu_cb( widget , user_data, COLUMN_SELECTED_SORT_DESCENDING);
2064 }
2065
2066 static void
2067 no_sorting_cb(GtkWidget *widget, gpointer user_data)
2068 {
2069         new_packet_list_column_menu_cb( widget , user_data, COLUMN_SELECTED_SORT_NONE);
2070 }
2071
2072 static void
2073 packet_list_heading_show_resolved_cb(GtkAction *action _U_, gpointer user_data _U_)
2074 {
2075         GtkWidget *widget = gtk_ui_manager_get_widget(ui_manager_packet_list_heading, "/PacketListHeadingPopup/ShowResolved");
2076
2077         new_packet_list_column_menu_cb( widget , user_data, COLUMN_SELECTED_TOGGLE_RESOLVED);
2078 }
2079
2080 static void
2081 packet_list_heading_align_left_cb(GtkWidget *widget, gpointer user_data)
2082 {
2083         new_packet_list_column_menu_cb( widget , user_data, COLUMN_SELECTED_ALIGN_LEFT);
2084 }
2085
2086 static void
2087 packet_list_heading_align_center_cb(GtkWidget *widget, gpointer user_data)
2088 {
2089         new_packet_list_column_menu_cb( widget , user_data, COLUMN_SELECTED_ALIGN_CENTER);
2090 }
2091
2092 static void
2093 packet_list_heading_align_right_cb(GtkWidget *widget, gpointer user_data)
2094 {
2095         new_packet_list_column_menu_cb( widget , user_data, COLUMN_SELECTED_ALIGN_RIGHT);
2096 }
2097
2098 static void
2099 packet_list_heading_col_pref_cb(GtkWidget *widget, gpointer user_data)
2100 {
2101         prefs_page_cb( widget , user_data, PREFS_PAGE_COLUMNS);
2102 }
2103
2104 static void
2105 packet_list_heading_resize_col_cb(GtkWidget *widget, gpointer user_data)
2106 {
2107         new_packet_list_column_menu_cb( widget , user_data, COLUMN_SELECTED_RESIZE);
2108 }
2109
2110 static void
2111 packet_list_heading_rename_col_cb(GtkWidget *widget, gpointer user_data)
2112 {
2113         new_packet_list_column_menu_cb( widget , user_data, COLUMN_SELECTED_RENAME);
2114 }
2115
2116 static void
2117 packet_list_heading_activate_all_columns(GtkWidget *widget _U_, gpointer user_data _U_)
2118 {
2119         new_packet_list_set_all_columns_visible ();
2120 }
2121
2122 static void
2123 packet_list_heading_hide_col_cb(GtkWidget *widget, gpointer user_data)
2124 {
2125         new_packet_list_column_menu_cb( widget , user_data, COLUMN_SELECTED_HIDE);
2126 }
2127
2128 static void
2129 packet_list_heading_remove_col_cb(GtkWidget *widget, gpointer user_data)
2130 {
2131         new_packet_list_column_menu_cb( widget , user_data, COLUMN_SELECTED_REMOVE);
2132 }
2133
2134 static void
2135 packet_list_menu_set_ref_time_cb(GtkWidget *widget, gpointer user_data)
2136 {
2137         reftime_frame_cb( widget , user_data, REFTIME_TOGGLE);
2138 }
2139
2140
2141 static void
2142 packet_list_menu_apply_selected_cb(GtkWidget *widget, gpointer user_data)
2143 {
2144         match_selected_plist_cb( widget , user_data, MATCH_SELECTED_REPLACE|MATCH_SELECTED_APPLY_NOW);
2145 }
2146
2147 static void
2148 packet_list_menu_apply_not_selected_cb(GtkWidget *widget, gpointer user_data)
2149 {
2150         match_selected_plist_cb( widget , user_data, MATCH_SELECTED_NOT|MATCH_SELECTED_APPLY_NOW);
2151 }
2152
2153 static void
2154 packet_list_menu_apply_and_selected_cb(GtkWidget *widget, gpointer user_data)
2155 {
2156         match_selected_plist_cb( widget , user_data, MATCH_SELECTED_AND|MATCH_SELECTED_APPLY_NOW);
2157 }
2158
2159 static void
2160 packet_list_menu_apply_or_selected_cb(GtkWidget *widget, gpointer user_data)
2161 {
2162         match_selected_plist_cb( widget , user_data, MATCH_SELECTED_OR|MATCH_SELECTED_APPLY_NOW);
2163 }
2164
2165 static void
2166 packet_list_menu_apply_and_not_selected_cb(GtkWidget *widget, gpointer user_data)
2167 {
2168         match_selected_plist_cb( widget , user_data, MATCH_SELECTED_AND_NOT|MATCH_SELECTED_APPLY_NOW);
2169 }
2170
2171 static void
2172 packet_list_menu_apply_or_not_selected_cb(GtkWidget *widget, gpointer user_data)
2173 {
2174         match_selected_plist_cb( widget , user_data,MATCH_SELECTED_OR_NOT|MATCH_SELECTED_APPLY_NOW);
2175 }
2176 /* Prepare a filter */
2177 static void
2178 packet_list_menu_prepare_selected_cb(GtkWidget *widget, gpointer user_data)
2179 {
2180         match_selected_plist_cb( widget , user_data, MATCH_SELECTED_REPLACE);
2181 }
2182
2183 static void
2184 packet_list_menu_prepare_not_selected_cb(GtkWidget *widget, gpointer user_data)
2185 {
2186         match_selected_plist_cb( widget , user_data, MATCH_SELECTED_NOT);
2187 }
2188
2189 static void
2190 packet_list_menu_prepare_and_selected_cb(GtkWidget *widget, gpointer user_data)
2191 {
2192         match_selected_plist_cb( widget , user_data, MATCH_SELECTED_AND);
2193 }
2194
2195 static void
2196 packet_list_menu_prepare_or_selected_cb(GtkWidget *widget, gpointer user_data)
2197 {
2198         match_selected_plist_cb( widget , user_data, MATCH_SELECTED_OR);
2199 }
2200
2201 static void
2202 packet_list_menu_prepare_and_not_selected_cb(GtkWidget *widget, gpointer user_data)
2203 {
2204         match_selected_plist_cb( widget , user_data, MATCH_SELECTED_AND_NOT);
2205 }
2206
2207 static void
2208 packet_list_menu_prepare_or_not_selected_cb(GtkWidget *widget, gpointer user_data)
2209 {
2210         match_selected_plist_cb( widget , user_data, MATCH_SELECTED_OR_NOT);
2211 }
2212
2213 static void
2214 packet_list_menu_conversation_ethernet_cb(GtkWidget *widget, gpointer user_data)
2215 {
2216         conversation_cb( widget , user_data, CONV_ETHER);
2217 }
2218
2219 static void
2220 packet_list_menu_conversation_ip_cb(GtkWidget *widget, gpointer user_data)
2221 {
2222         conversation_cb( widget , user_data, CONV_IP);
2223 }
2224
2225 static void
2226 packet_list_menu_conversation_tcp_cb(GtkWidget *widget, gpointer user_data)
2227 {
2228         conversation_cb( widget , user_data, CONV_TCP);
2229 }
2230
2231 static void
2232 packet_list_menu_conversation_udp_cb(GtkWidget *widget, gpointer user_data)
2233 {
2234         conversation_cb( widget , user_data, CONV_UDP);
2235 }
2236
2237 static void
2238 packet_list_menu_conversation_pn_cba_cb(GtkWidget *widget, gpointer user_data)
2239 {
2240         conversation_cb( widget , user_data, CONV_CBA);
2241 }
2242
2243 /* Ethernet */
2244
2245 static void
2246 packet_list_menu_color_conv_ethernet_color1_cb(GtkWidget *widget, gpointer user_data)
2247 {
2248         colorize_conversation_cb( widget , user_data, CONV_ETHER+1*256);
2249
2250 }
2251
2252 static void
2253 packet_list_menu_color_conv_ethernet_color2_cb(GtkWidget *widget, gpointer user_data)
2254 {
2255         colorize_conversation_cb( widget , user_data, CONV_ETHER+1*256);
2256
2257 }
2258 static void
2259 packet_list_menu_color_conv_ethernet_color3_cb(GtkWidget *widget, gpointer user_data)
2260 {
2261         colorize_conversation_cb( widget , user_data, CONV_ETHER+3*256);
2262
2263 }
2264 static void
2265 packet_list_menu_color_conv_ethernet_color4_cb(GtkWidget *widget, gpointer user_data)
2266 {
2267         colorize_conversation_cb( widget , user_data, CONV_ETHER+4*256);
2268
2269 }
2270 static void
2271 packet_list_menu_color_conv_ethernet_color5_cb(GtkWidget *widget, gpointer user_data)
2272 {
2273         colorize_conversation_cb( widget , user_data, CONV_ETHER+5*256);
2274
2275 }
2276 static void
2277 packet_list_menu_color_conv_ethernet_color6_cb(GtkWidget *widget, gpointer user_data)
2278 {
2279         colorize_conversation_cb( widget , user_data, CONV_ETHER+6*256);
2280
2281 }
2282 static void
2283 packet_list_menu_color_conv_ethernet_color7_cb(GtkWidget *widget, gpointer user_data)
2284 {
2285         colorize_conversation_cb( widget , user_data, CONV_ETHER+7*256);
2286
2287 }
2288 static void
2289 packet_list_menu_color_conv_ethernet_color8_cb(GtkWidget *widget, gpointer user_data)
2290 {
2291         colorize_conversation_cb( widget , user_data, CONV_ETHER+8*256);
2292
2293 }
2294 static void
2295 packet_list_menu_color_conv_ethernet_color9_cb(GtkWidget *widget, gpointer user_data)
2296 {
2297         colorize_conversation_cb( widget , user_data, CONV_ETHER+9*256);
2298
2299 }
2300 static void
2301 packet_list_menu_color_conv_ethernet_color10_cb(GtkWidget *widget, gpointer user_data)
2302 {
2303         colorize_conversation_cb( widget , user_data, CONV_ETHER+10*256);
2304
2305 }
2306
2307 static void
2308 packet_list_menu_color_conv_ethernet_new_rule_cb(GtkWidget *widget, gpointer user_data)
2309 {
2310         colorize_conversation_cb( widget , user_data, CONV_ETHER);
2311
2312 }
2313
2314 /* IP */
2315
2316 static void
2317 packet_list_menu_color_conv_ip_color1_cb(GtkWidget *widget, gpointer user_data)
2318 {
2319         colorize_conversation_cb( widget , user_data, CONV_IP+1*256);
2320
2321 }
2322
2323 static void
2324 packet_list_menu_color_conv_ip_color2_cb(GtkWidget *widget, gpointer user_data)
2325 {
2326         colorize_conversation_cb( widget , user_data, CONV_IP+1*256);
2327
2328 }
2329 static void
2330 packet_list_menu_color_conv_ip_color3_cb(GtkWidget *widget, gpointer user_data)
2331 {
2332         colorize_conversation_cb( widget , user_data, CONV_IP+3*256);
2333
2334 }
2335 static void
2336 packet_list_menu_color_conv_ip_color4_cb(GtkWidget *widget, gpointer user_data)
2337 {
2338         colorize_conversation_cb( widget , user_data, CONV_IP+4*256);
2339
2340 }
2341 static void
2342 packet_list_menu_color_conv_ip_color5_cb(GtkWidget *widget, gpointer user_data)
2343 {
2344         colorize_conversation_cb( widget , user_data, CONV_IP+5*256);
2345
2346 }
2347 static void
2348 packet_list_menu_color_conv_ip_color6_cb(GtkWidget *widget, gpointer user_data)
2349 {
2350         colorize_conversation_cb( widget , user_data, CONV_IP+6*256);
2351
2352 }
2353 static void
2354 packet_list_menu_color_conv_ip_color7_cb(GtkWidget *widget, gpointer user_data)
2355 {
2356         colorize_conversation_cb( widget , user_data, CONV_IP+7*256);
2357
2358 }
2359 static void
2360 packet_list_menu_color_conv_ip_color8_cb(GtkWidget *widget, gpointer user_data)
2361 {
2362         colorize_conversation_cb( widget , user_data, CONV_IP+8*256);
2363
2364 }
2365 static void
2366 packet_list_menu_color_conv_ip_color9_cb(GtkWidget *widget, gpointer user_data)
2367 {
2368         colorize_conversation_cb( widget , user_data, CONV_IP+9*256);
2369
2370 }
2371 static void
2372 packet_list_menu_color_conv_ip_color10_cb(GtkWidget *widget, gpointer user_data)
2373 {
2374         colorize_conversation_cb( widget , user_data, CONV_IP+10*256);
2375
2376 }
2377
2378 static void
2379 packet_list_menu_color_conv_ip_new_rule_cb(GtkWidget *widget, gpointer user_data)
2380 {
2381         colorize_conversation_cb( widget , user_data, CONV_TCP);
2382
2383 }
2384
2385 /* TCP */
2386 static void
2387 packet_list_menu_color_conv_tcp_color1_cb(GtkWidget *widget, gpointer user_data)
2388 {
2389         colorize_conversation_cb( widget , user_data, CONV_TCP+1*256);
2390
2391 }
2392
2393 static void
2394 packet_list_menu_color_conv_tcp_color2_cb(GtkWidget *widget, gpointer user_data)
2395 {
2396         colorize_conversation_cb( widget , user_data, CONV_TCP+1*256);
2397
2398 }
2399 static void
2400 packet_list_menu_color_conv_tcp_color3_cb(GtkWidget *widget, gpointer user_data)
2401 {
2402         colorize_conversation_cb( widget , user_data, CONV_TCP+3*256);
2403
2404 }
2405 static void
2406 packet_list_menu_color_conv_tcp_color4_cb(GtkWidget *widget, gpointer user_data)
2407 {
2408         colorize_conversation_cb( widget , user_data, CONV_TCP+4*256);
2409
2410 }
2411 static void
2412 packet_list_menu_color_conv_tcp_color5_cb(GtkWidget *widget, gpointer user_data)
2413 {
2414         colorize_conversation_cb( widget , user_data, CONV_TCP+5*256);
2415
2416 }
2417 static void
2418 packet_list_menu_color_conv_tcp_color6_cb(GtkWidget *widget, gpointer user_data)
2419 {
2420         colorize_conversation_cb( widget , user_data, CONV_TCP+6*256);
2421
2422 }
2423 static void
2424 packet_list_menu_color_conv_tcp_color7_cb(GtkWidget *widget, gpointer user_data)
2425 {
2426         colorize_conversation_cb( widget , user_data, CONV_TCP+7*256);
2427
2428 }
2429 static void
2430 packet_list_menu_color_conv_tcp_color8_cb(GtkWidget *widget, gpointer user_data)
2431 {
2432         colorize_conversation_cb( widget , user_data, CONV_TCP+8*256);
2433
2434 }
2435 static void
2436 packet_list_menu_color_conv_tcp_color9_cb(GtkWidget *widget, gpointer user_data)
2437 {
2438         colorize_conversation_cb( widget , user_data, CONV_TCP+9*256);
2439
2440 }
2441 static void
2442 packet_list_menu_color_conv_tcp_color10_cb(GtkWidget *widget, gpointer user_data)
2443 {
2444         colorize_conversation_cb( widget , user_data, CONV_TCP+10*256);
2445
2446 }
2447
2448 static void
2449 packet_list_menu_color_conv_tcp_new_rule_cb(GtkWidget *widget, gpointer user_data)
2450 {
2451         colorize_conversation_cb( widget , user_data, CONV_TCP);
2452
2453 }
2454
2455 /* UDP */
2456 static void
2457 packet_list_menu_color_conv_udp_color1_cb(GtkWidget *widget, gpointer user_data)
2458 {
2459         colorize_conversation_cb( widget , user_data, CONV_UDP+1*256);
2460
2461 }
2462
2463 static void
2464 packet_list_menu_color_conv_udp_color2_cb(GtkWidget *widget, gpointer user_data)
2465 {
2466         colorize_conversation_cb( widget , user_data, CONV_UDP+1*256);
2467
2468 }
2469 static void
2470 packet_list_menu_color_conv_udp_color3_cb(GtkWidget *widget, gpointer user_data)
2471 {
2472         colorize_conversation_cb( widget , user_data, CONV_UDP+3*256);
2473
2474 }
2475 static void
2476 packet_list_menu_color_conv_udp_color4_cb(GtkWidget *widget, gpointer user_data)
2477 {
2478         colorize_conversation_cb( widget , user_data, CONV_UDP+4*256);
2479
2480 }
2481 static void
2482 packet_list_menu_color_conv_udp_color5_cb(GtkWidget *widget, gpointer user_data)
2483 {
2484         colorize_conversation_cb( widget , user_data, CONV_UDP+5*256);
2485
2486 }
2487 static void
2488 packet_list_menu_color_conv_udp_color6_cb(GtkWidget *widget, gpointer user_data)
2489 {
2490         colorize_conversation_cb( widget , user_data, CONV_UDP+6*256);
2491
2492 }
2493 static void
2494 packet_list_menu_color_conv_udp_color7_cb(GtkWidget *widget, gpointer user_data)
2495 {
2496         colorize_conversation_cb( widget , user_data, CONV_UDP+7*256);
2497
2498 }
2499 static void
2500 packet_list_menu_color_conv_udp_color8_cb(GtkWidget *widget, gpointer user_data)
2501 {
2502         colorize_conversation_cb( widget , user_data, CONV_UDP+8*256);
2503
2504 }
2505 static void
2506 packet_list_menu_color_conv_udp_color9_cb(GtkWidget *widget, gpointer user_data)
2507 {
2508         colorize_conversation_cb( widget , user_data, CONV_UDP+9*256);
2509
2510 }
2511 static void
2512 packet_list_menu_color_conv_udp_color10_cb(GtkWidget *widget, gpointer user_data)
2513 {
2514         colorize_conversation_cb( widget , user_data, CONV_UDP+10*256);
2515
2516 }
2517
2518 static void
2519 packet_list_menu_color_conv_udp_new_rule_cb(GtkWidget *widget, gpointer user_data)
2520 {
2521         colorize_conversation_cb( widget , user_data, CONV_UDP);
2522
2523 }
2524
2525 /* CONV_CBA */
2526
2527 static void
2528 packet_list_menu_color_conv_cba_color1_cb(GtkWidget *widget, gpointer user_data)
2529 {
2530         colorize_conversation_cb( widget , user_data, CONV_CBA+1*256);
2531
2532 }
2533
2534 static void
2535 packet_list_menu_color_conv_cba_color2_cb(GtkWidget *widget, gpointer user_data)
2536 {
2537         colorize_conversation_cb( widget , user_data, CONV_CBA+1*256);
2538
2539 }
2540 static void
2541 packet_list_menu_color_conv_cba_color3_cb(GtkWidget *widget, gpointer user_data)
2542 {
2543         colorize_conversation_cb( widget , user_data, CONV_CBA+3*256);
2544
2545 }
2546 static void
2547 packet_list_menu_color_conv_cba_color4_cb(GtkWidget *widget, gpointer user_data)
2548 {
2549         colorize_conversation_cb( widget , user_data, CONV_CBA+4*256);
2550
2551 }
2552 static void
2553 packet_list_menu_color_conv_cba_color5_cb(GtkWidget *widget, gpointer user_data)
2554 {
2555         colorize_conversation_cb( widget , user_data, CONV_CBA+5*256);
2556
2557 }
2558 static void
2559 packet_list_menu_color_conv_cba_color6_cb(GtkWidget *widget, gpointer user_data)
2560 {
2561         colorize_conversation_cb( widget , user_data, CONV_CBA+6*256);
2562
2563 }
2564 static void
2565 packet_list_menu_color_conv_cba_color7_cb(GtkWidget *widget, gpointer user_data)
2566 {
2567         colorize_conversation_cb( widget , user_data, CONV_CBA+7*256);
2568
2569 }
2570 static void
2571 packet_list_menu_color_conv_cba_color8_cb(GtkWidget *widget, gpointer user_data)
2572 {
2573         colorize_conversation_cb( widget , user_data, CONV_CBA+8*256);
2574
2575 }
2576 static void
2577 packet_list_menu_color_conv_cba_color9_cb(GtkWidget *widget, gpointer user_data)
2578 {
2579         colorize_conversation_cb( widget , user_data, CONV_CBA+9*256);
2580
2581 }
2582 static void
2583 packet_list_menu_color_conv_cba_color10_cb(GtkWidget *widget, gpointer user_data)
2584 {
2585         colorize_conversation_cb( widget , user_data, CONV_CBA+10*256);
2586
2587 }
2588
2589 static void
2590 packet_list_menu_color_conv_cba_new_rule_cb(GtkWidget *widget, gpointer user_data)
2591 {
2592         colorize_conversation_cb( widget , user_data, CONV_CBA);
2593
2594 }
2595
2596 static void
2597 packet_list_menu_copy_sum_txt(GtkWidget *widget, gpointer user_data)
2598 {
2599         copy_hex_cb( widget , user_data, CS_TEXT);
2600
2601 }
2602
2603 static void
2604 packet_list_menu_copy_sum_csv(GtkWidget *widget, gpointer user_data)
2605 {
2606         copy_hex_cb( widget , user_data, CS_CSV);
2607
2608 }
2609
2610 static void
2611 packet_list_menu_copy_as_flt(GtkWidget *widget, gpointer user_data)
2612 {
2613         copy_hex_cb( widget , user_data, MATCH_SELECTED_REPLACE|MATCH_SELECTED_COPY_ONLY);
2614
2615 }
2616
2617 static void
2618 packet_list_menu_copy_bytes_oht_cb(GtkWidget *widget, gpointer user_data)
2619 {
2620         copy_hex_cb( widget , user_data,  CD_ALLINFO | CD_FLAGS_SELECTEDONLY);
2621
2622 }
2623
2624 static void
2625 packet_list_menu_copy_bytes_oh_cb(GtkWidget *widget, gpointer user_data)
2626 {
2627         copy_hex_cb( widget , user_data, CD_HEXCOLUMNS | CD_FLAGS_SELECTEDONLY);
2628
2629 }
2630
2631 static void
2632 packet_list_menu_copy_bytes_text_cb(GtkWidget *widget, gpointer user_data)
2633 {
2634         copy_hex_cb( widget , user_data, CD_TEXTONLY | CD_FLAGS_SELECTEDONLY);
2635
2636 }
2637
2638 static void
2639 packet_list_menu_copy_bytes_hex_strm_cb(GtkWidget *widget, gpointer user_data)
2640 {
2641         copy_hex_cb( widget , user_data,  CD_HEX | CD_FLAGS_SELECTEDONLY);
2642
2643 }
2644
2645 static void
2646 packet_list_menu_copy_bytes_bin_strm_cb(GtkWidget *widget, gpointer user_data)
2647 {
2648         copy_hex_cb( widget , user_data, CD_BINARY | CD_FLAGS_SELECTEDONLY);
2649
2650 }
2651
2652 /* tree */
2653
2654
2655 static void
2656 tree_view_menu_color_with_flt_color1_cb(GtkWidget *widget, gpointer user_data)
2657 {
2658         colorize_selected_ptree_cb( widget , user_data, 1);
2659
2660 }
2661
2662 static void
2663 tree_view_menu_color_with_flt_color2_cb(GtkWidget *widget, gpointer user_data)
2664 {
2665         colorize_selected_ptree_cb( widget , user_data, 2);
2666
2667 }
2668 static void
2669 tree_view_menu_color_with_flt_color3_cb(GtkWidget *widget, gpointer user_data)
2670 {
2671         colorize_selected_ptree_cb( widget , user_data, 3);
2672
2673 }
2674 static void
2675 tree_view_menu_color_with_flt_color4_cb(GtkWidget *widget, gpointer user_data)
2676 {
2677         colorize_selected_ptree_cb( widget , user_data, 4);
2678
2679 }
2680 static void
2681 tree_view_menu_color_with_flt_color5_cb(GtkWidget *widget, gpointer user_data)
2682 {
2683         colorize_selected_ptree_cb( widget , user_data, 5);
2684
2685 }
2686 static void
2687 tree_view_menu_color_with_flt_color6_cb(GtkWidget *widget, gpointer user_data)
2688 {
2689         colorize_selected_ptree_cb( widget , user_data, 6);
2690
2691 }
2692 static void
2693 tree_view_menu_color_with_flt_color7_cb(GtkWidget *widget, gpointer user_data)
2694 {
2695         colorize_selected_ptree_cb( widget , user_data, 7);
2696
2697 }
2698 static void
2699 tree_view_menu_color_with_flt_color8_cb(GtkWidget *widget, gpointer user_data)
2700 {
2701         colorize_selected_ptree_cb( widget , user_data, 8);
2702
2703 }
2704 static void
2705 tree_view_menu_color_with_flt_color9_cb(GtkWidget *widget, gpointer user_data)
2706 {
2707         colorize_selected_ptree_cb( widget , user_data, 9);
2708
2709 }
2710 static void
2711 tree_view_menu_color_with_flt_color10_cb(GtkWidget *widget, gpointer user_data)
2712 {
2713         colorize_selected_ptree_cb( widget , user_data, 10);
2714
2715 }
2716
2717 static void
2718 tree_view_menu_color_with_flt_new_rule_cb(GtkWidget *widget, gpointer user_data)
2719 {
2720         colorize_selected_ptree_cb( widget , user_data, 0);
2721
2722 }
2723
2724 static void
2725 tree_view_menu_copy_desc(GtkWidget *widget, gpointer user_data)
2726 {
2727         copy_selected_plist_cb( widget , user_data, COPY_SELECTED_DESCRIPTION);
2728
2729 }
2730
2731 static void
2732 tree_view_menu_copy_field(GtkWidget *widget, gpointer user_data)
2733 {
2734         copy_selected_plist_cb( widget , user_data, COPY_SELECTED_FIELDNAME);
2735
2736 }
2737
2738 static void
2739 tree_view_menu_copy_value(GtkWidget *widget, gpointer user_data)
2740 {
2741         copy_selected_plist_cb( widget , user_data, COPY_SELECTED_VALUE);
2742
2743 }
2744
2745 static void
2746 tree_view_menu_copy_as_flt(GtkWidget *widget, gpointer user_data)
2747 {
2748         match_selected_ptree_cb( widget , user_data, MATCH_SELECTED_REPLACE|MATCH_SELECTED_COPY_ONLY);
2749
2750 }
2751
2752 static const char *ui_desc_packet_list_heading_menu_popup =
2753 "<ui>\n"
2754 "  <popup name='PacketListHeadingPopup' action='PopupAction'>\n"
2755 "     <menuitem name='SortAscending' action='/Sort Ascending'/>\n"
2756 "     <menuitem name='SortDescending' action='/Sort Descending'/>\n"
2757 "     <menuitem name='NoSorting' action='/No Sorting'/>\n"
2758 "     <separator/>\n"
2759 "     <menuitem name='ShowResolved' action='/Show Resolved'/>\n"
2760 "     <separator/>\n"
2761 "     <menuitem name='AlignLeft' action='/Align Left'/>\n"
2762 "     <menuitem name='AlignCenter' action='/Align Center'/>\n"
2763 "     <menuitem name='AlignRight' action='/Align Right'/>\n"
2764 "     <separator/>\n"
2765 "     <menuitem name='ColumnPreferences' action='/Column Preferences'/>\n"
2766 "     <menuitem name='ResizeColumn' action='/Resize Column'/>\n"
2767 "     <menuitem name='RenameColumnTitle' action='/Rename Column Title'/>\n"
2768 "     <separator/>\n"
2769 "     <menu name='DisplayedColumns' action='/Displayed Columns'>\n"
2770 "       <menuitem name='Display All' action='/Displayed Columns/Display All'/>\n"
2771 "     </menu>\n"
2772 "     <menuitem name='HideColumn' action='/Hide Column'/>\n"
2773 "     <menuitem name='RemoveColumn' action='/Remove Column'/>\n"
2774 "  </popup>\n"
2775 "</ui>\n";
2776
2777 static const GtkActionEntry packet_list_heading_menu_popup_action_entries[] = {
2778   { "/Sort Ascending",                                  GTK_STOCK_SORT_ASCENDING,                       "Sort Ascending",                       NULL,   NULL,   G_CALLBACK(sort_ascending_cb) },
2779   { "/Sort Descending",                                 GTK_STOCK_SORT_DESCENDING,                      "Sort Descending",                      NULL,   NULL,   G_CALLBACK(sort_descending_cb) },
2780   { "/No Sorting",                                              NULL,                                                           "No Sorting",                           NULL,   NULL,   G_CALLBACK(no_sorting_cb) },
2781   { "/Align Left",                                              GTK_STOCK_JUSTIFY_LEFT,                         "Align Left",                           NULL,   NULL,   G_CALLBACK(packet_list_heading_align_left_cb) },
2782   { "/Align Center",                                    GTK_STOCK_JUSTIFY_CENTER,                       "Align Center",                         NULL,   NULL,   G_CALLBACK(packet_list_heading_align_center_cb) },
2783   { "/Align Right",                                             GTK_STOCK_JUSTIFY_RIGHT,                        "Align Right",                          NULL,   NULL,   G_CALLBACK(packet_list_heading_align_right_cb) },
2784   { "/Column Preferences",                              GTK_STOCK_PREFERENCES,                          "Column Preferences...",        NULL,   NULL,   G_CALLBACK(packet_list_heading_col_pref_cb) },
2785   { "/Resize Column",                                   WIRESHARK_STOCK_RESIZE_COLUMNS,         "Resize Column",                        NULL,   NULL,   G_CALLBACK(packet_list_heading_resize_col_cb) },
2786   { "/Rename Column Title",                             GTK_STOCK_BOLD,                                         "Rename Column Title...",       NULL,   NULL,   G_CALLBACK(packet_list_heading_rename_col_cb) },
2787   { "/Displayed Columns",                               NULL,                                                           "Displayed Columns",            NULL,   NULL,   NULL },
2788   { "/Displayed Columns/Display All",                           NULL,                                   "Display All",                          NULL,   NULL,   G_CALLBACK(packet_list_heading_activate_all_columns) },
2789   { "/Hide Column",                                             NULL,                                                           "Hide Column",                          NULL,   NULL,   G_CALLBACK(packet_list_heading_hide_col_cb) },
2790   { "/Remove Column",                                   GTK_STOCK_DELETE,                                       "Remove Column",                        NULL,   NULL,   G_CALLBACK(packet_list_heading_remove_col_cb) },
2791 };
2792
2793 static const GtkToggleActionEntry packet_list_heading_menu_toggle_action_entries[] =
2794 {
2795         /* name, stock id, label, accel, tooltip, callback, is_active */
2796         {"/Show Resolved",      NULL, "Show Resolved",  NULL, NULL,     G_CALLBACK(packet_list_heading_show_resolved_cb), FALSE},
2797 };
2798
2799 static const char *ui_desc_packet_list_menu_popup =
2800 "<ui>\n"
2801 "  <popup name='PacketListMenuPopup' action='PopupAction'>\n"
2802 "     <menuitem name='MarkPacket' action='/MarkPacket'/>\n"
2803 "     <menuitem name='IgnorePacket' action='/IgnorePacket'/>\n"
2804 "     <menuitem name='SetTimeReference' action='/Set Time Reference'/>\n"
2805 "     <separator/>\n"
2806 "     <menuitem name='ManuallyResolveAddress' action='/ManuallyResolveAddress'/>\n"
2807 "     <separator/>\n"
2808 "     <menu name= 'ApplyAsFilter' action='/Apply as Filter'>\n"
2809 "       <menuitem name='Selected' action='/Apply as Filter/Selected'/>\n"
2810 "       <menuitem name='NotSelected' action='/Apply as Filter/Not Selected'/>\n"
2811 "       <menuitem name='AndSelected' action='/Apply as Filter/AndSelected'/>\n"
2812 "       <menuitem name='OrSelected' action='/Apply as Filter/OrSelected'/>\n"
2813 "       <menuitem name='AndNotSelected' action='/Apply as Filter/AndNotSelected'/>\n"
2814 "       <menuitem name='OrNotSelected' action='/Apply as Filter/OrNotSelected'/>\n"
2815 "     </menu>\n"
2816 "     <menu name= 'PrepareaFilter' action='/Prepare a Filter'>\n"
2817 "       <menuitem name='Selected' action='/Prepare a Filter/Selected'/>\n"
2818 "       <menuitem name='NotSelected' action='/Prepare a Filter/Not Selected'/>\n"
2819 "       <menuitem name='AndSelected' action='/Prepare a Filter/AndSelected'/>\n"
2820 "       <menuitem name='OrSelected' action='/Prepare a Filter/OrSelected'/>\n"
2821 "       <menuitem name='AndNotSelected' action='/Prepare a Filter/AndNotSelected'/>\n"
2822 "       <menuitem name='OrNotSelected' action='/Prepare a Filter/OrNotSelected'/>\n"
2823 "     </menu>\n"
2824 "     <menu name= 'ConversationFilter' action='/Conversation Filter'>\n"
2825 "       <menuitem name='Ethernet' action='/Conversation Filter/Ethernet'/>\n"
2826 "       <menuitem name='IP' action='/Conversation Filter/IP'/>\n"
2827 "       <menuitem name='TCP' action='/Conversation Filter/TCP'/>\n"
2828 "       <menuitem name='UDP' action='/Conversation Filter/UDP'/>\n"
2829 "       <menuitem name='PN-CBA' action='/Conversation Filter/PN-CBA'/>\n"
2830 "     </menu>\n"
2831 "     <menu name= 'ColorizeConversation' action='/Colorize Conversation'>\n"
2832 "        <menu name= 'Ethernet' action='/Colorize Conversation/Ethernet'>\n"
2833 "          <menuitem name='Color1' action='/Colorize Conversation/Ethernet/Color 1'/>\n"
2834 "          <menuitem name='Color2' action='/Colorize Conversation/Ethernet/Color 2'/>\n"
2835 "          <menuitem name='Color3' action='/Colorize Conversation/Ethernet/Color 3'/>\n"
2836 "          <menuitem name='Color4' action='/Colorize Conversation/Ethernet/Color 4'/>\n"
2837 "          <menuitem name='Color5' action='/Colorize Conversation/Ethernet/Color 5'/>\n"
2838 "          <menuitem name='Color6' action='/Colorize Conversation/Ethernet/Color 6'/>\n"
2839 "          <menuitem name='Color7' action='/Colorize Conversation/Ethernet/Color 7'/>\n"
2840 "          <menuitem name='Color8' action='/Colorize Conversation/Ethernet/Color 8'/>\n"
2841 "          <menuitem name='Color9' action='/Colorize Conversation/Ethernet/Color 9'/>\n"
2842 "          <menuitem name='Color10' action='/Colorize Conversation/Ethernet/Color 10'/>\n"
2843 "          <menuitem name='NewColoringRule' action='/Colorize Conversation/Ethernet/New Coloring Rule'/>\n"
2844 "        </menu>\n"
2845 "        <menu name= 'IP' action='/Colorize Conversation/IP'>\n"
2846 "          <menuitem name='Color1' action='/Colorize Conversation/IP/Color 1'/>\n"
2847 "          <menuitem name='Color2' action='/Colorize Conversation/IP/Color 2'/>\n"
2848 "          <menuitem name='Color3' action='/Colorize Conversation/IP/Color 3'/>\n"
2849 "          <menuitem name='Color4' action='/Colorize Conversation/IP/Color 4'/>\n"
2850 "          <menuitem name='Color5' action='/Colorize Conversation/IP/Color 5'/>\n"
2851 "          <menuitem name='Color6' action='/Colorize Conversation/IP/Color 6'/>\n"
2852 "          <menuitem name='Color7' action='/Colorize Conversation/IP/Color 7'/>\n"
2853 "          <menuitem name='Color8' action='/Colorize Conversation/IP/Color 8'/>\n"
2854 "          <menuitem name='Color9' action='/Colorize Conversation/IP/Color 9'/>\n"
2855 "          <menuitem name='Color10' action='/Colorize Conversation/IP/Color 10'/>\n"
2856 "          <menuitem name='NewColoringRule' action='/Colorize Conversation/IP/New Coloring Rule'/>\n"
2857 "        </menu>\n"
2858 "        <menu name= 'TCP' action='/Colorize Conversation/TCP'>\n"
2859 "          <menuitem name='Color1' action='/Colorize Conversation/TCP/Color 1'/>\n"
2860 "          <menuitem name='Color2' action='/Colorize Conversation/TCP/Color 2'/>\n"
2861 "          <menuitem name='Color3' action='/Colorize Conversation/TCP/Color 3'/>\n"
2862 "          <menuitem name='Color4' action='/Colorize Conversation/TCP/Color 4'/>\n"
2863 "          <menuitem name='Color5' action='/Colorize Conversation/TCP/Color 5'/>\n"
2864 "          <menuitem name='Color6' action='/Colorize Conversation/TCP/Color 6'/>\n"
2865 "          <menuitem name='Color7' action='/Colorize Conversation/TCP/Color 7'/>\n"
2866 "          <menuitem name='Color8' action='/Colorize Conversation/TCP/Color 8'/>\n"
2867 "          <menuitem name='Color9' action='/Colorize Conversation/TCP/Color 9'/>\n"
2868 "          <menuitem name='Color10' action='/Colorize Conversation/TCP/Color 10'/>\n"
2869 "          <menuitem name='NewColoringRule' action='/Colorize Conversation/TCP/New Coloring Rule'/>\n"
2870 "        </menu>\n"
2871 "        <menu name= 'UDP' action='/Colorize Conversation/UDP'>\n"
2872 "          <menuitem name='Color1' action='/Colorize Conversation/UDP/Color 1'/>\n"
2873 "          <menuitem name='Color2' action='/Colorize Conversation/UDP/Color 2'/>\n"
2874 "          <menuitem name='Color3' action='/Colorize Conversation/UDP/Color 3'/>\n"
2875 "          <menuitem name='Color4' action='/Colorize Conversation/UDP/Color 4'/>\n"
2876 "          <menuitem name='Color5' action='/Colorize Conversation/UDP/Color 5'/>\n"
2877 "          <menuitem name='Color6' action='/Colorize Conversation/UDP/Color 6'/>\n"
2878 "          <menuitem name='Color7' action='/Colorize Conversation/UDP/Color 7'/>\n"
2879 "          <menuitem name='Color8' action='/Colorize Conversation/UDP/Color 8'/>\n"
2880 "          <menuitem name='Color9' action='/Colorize Conversation/UDP/Color 9'/>\n"
2881 "          <menuitem name='Color10' action='/Colorize Conversation/UDP/Color 10'/>\n"
2882 "          <menuitem name='NewColoringRule' action='/Colorize Conversation/UDP/New Coloring Rule'/>\n"
2883 "        </menu>\n"
2884 "        <menu name= 'PN-CBA' action='/Colorize Conversation/PN-CBA'>\n"
2885 "          <menuitem name='Color1' action='/Colorize Conversation/PN-CBA/Color 1'/>\n"
2886 "          <menuitem name='Color2' action='/Colorize Conversation/PN-CBA/Color 2'/>\n"
2887 "          <menuitem name='Color3' action='/Colorize Conversation/PN-CBA/Color 3'/>\n"
2888 "          <menuitem name='Color4' action='/Colorize Conversation/PN-CBA/Color 4'/>\n"
2889 "          <menuitem name='Color5' action='/Colorize Conversation/PN-CBA/Color 5'/>\n"
2890 "          <menuitem name='Color6' action='/Colorize Conversation/PN-CBA/Color 6'/>\n"
2891 "          <menuitem name='Color7' action='/Colorize Conversation/PN-CBA/Color 7'/>\n"
2892 "          <menuitem name='Color8' action='/Colorize Conversation/PN-CBA/Color 8'/>\n"
2893 "          <menuitem name='Color9' action='/Colorize Conversation/PN-CBA/Color 9'/>\n"
2894 "          <menuitem name='Color10' action='/Colorize Conversation/PN-CBA/Color 10'/>\n"
2895 "          <menuitem name='NewColoringRule' action='/Colorize Conversation/PN-CBA/New Coloring Rule'/>\n"
2896 "        </menu>\n"
2897 "     </menu>\n"
2898 "     <menu name= 'SCTP' action='/SCTP'>\n"
2899 "        <menuitem name='AnalysethisAssociation' action='/SCTP/Analyse this Association'/>\n"
2900 "        <menuitem name='PrepareFilterforthisAssociation' action='/SCTP/Prepare Filter for this Association'/>\n"
2901 "     </menu>\n"
2902 "     <menuitem name='FollowTCPStream' action='/Follow TCP Stream'/>\n"
2903 "     <menuitem name='FollowUDPStream' action='/Follow UDP Stream'/>\n"
2904 "     <menuitem name='FollowSSLStream' action='/Follow SSL Stream'/>\n"
2905 "     <separator/>\n"
2906 "     <menu name= 'Copy' action='/Copy'>\n"
2907 "        <menuitem name='SummaryTxt' action='/Copy/SummaryTxt'/>\n"
2908 "        <menuitem name='SummaryCSV' action='/Copy/SummaryCSV'/>\n"
2909 "        <menuitem name='AsFilter' action='/Copy/AsFilter'/>\n"
2910 "        <separator/>\n"
2911 "        <menu name= 'Bytes' action='/Copy/Bytes'>\n"
2912 "           <menuitem name='OffsetHexText' action='/Copy/Bytes/OffsetHexText'/>\n"
2913 "           <menuitem name='OffsetHex' action='/Copy/Bytes/OffsetHex'/>\n"
2914 "           <menuitem name='PrintableTextOnly' action='/Copy/Bytes/PrintableTextOnly'/>\n"
2915 "           <separator/>\n"
2916 "           <menuitem name='HexStream' action='/Copy/Bytes/HexStream'/>\n"
2917 "           <menuitem name='BinaryStream' action='/Copy/Bytes/BinaryStream'/>\n"
2918 "        </menu>\n"
2919 "     </menu>\n"
2920 "     <separator/>\n"
2921 "     <menuitem name='DecodeAs' action='/DecodeAs'/>\n"
2922 "     <menuitem name='Print' action='/Print'/>\n"
2923 "     <menuitem name='ShowPacketinNewWindow' action='/ShowPacketinNewWindow'/>\n"
2924 "  </popup>\n"
2925 "</ui>\n";
2926
2927 static const GtkActionEntry packet_list_menu_popup_action_entries[] = {
2928   { "/MarkPacket",                                              NULL,                                   "Mark Packet (toggle)",                 NULL,                                   NULL,                   G_CALLBACK(new_packet_list_mark_frame_cb) },
2929   { "/IgnorePacket",                                    NULL,                                   "Ignore Packet (toggle)",               NULL,                                   NULL,                   G_CALLBACK(new_packet_list_ignore_frame_cb) },
2930   { "/Set Time Reference",                              WIRESHARK_STOCK_TIME,   "Set Time Reference (toggle)",  NULL,                                   NULL,                   G_CALLBACK(packet_list_menu_set_ref_time_cb) },
2931   { "/ManuallyResolveAddress",                  NULL,                                   "Manually Resolve Address",             NULL,                                   NULL,                   G_CALLBACK(manual_addr_resolv_dlg) },
2932   { "/Apply as Filter",                                 NULL,                                   "Apply as Filter",                              NULL,                                   NULL,                   NULL },
2933
2934   { "/Apply as Filter/Selected",                NULL, "_Selected" ,                             NULL, NULL, G_CALLBACK(packet_list_menu_apply_selected_cb) },
2935   { "/Apply as Filter/Not Selected",    NULL, "_Not Selected",                  NULL, NULL, G_CALLBACK(packet_list_menu_apply_not_selected_cb) },
2936   { "/Apply as Filter/AndSelected",             NULL, UTF8_HORIZONTAL_ELLIPSIS " _and Selected",                NULL, NULL, G_CALLBACK(packet_list_menu_apply_and_selected_cb) },
2937   { "/Apply as Filter/OrSelected",              NULL, UTF8_HORIZONTAL_ELLIPSIS " _or Selected",         NULL, NULL, G_CALLBACK(packet_list_menu_apply_or_selected_cb) },
2938   { "/Apply as Filter/AndNotSelected",  NULL, UTF8_HORIZONTAL_ELLIPSIS " a_nd not Selected",    NULL, NULL, G_CALLBACK(packet_list_menu_apply_and_not_selected_cb) },
2939   { "/Apply as Filter/OrNotSelected",   NULL, UTF8_HORIZONTAL_ELLIPSIS " o_r not Selected",     NULL, NULL, G_CALLBACK(packet_list_menu_apply_or_not_selected_cb) },
2940
2941   { "/Prepare a Filter",                                NULL, "Prepare a Filter",               NULL, NULL, NULL },
2942   { "/Prepare a Filter/Selected",               NULL, "_Selected" ,                             NULL, NULL, G_CALLBACK(packet_list_menu_prepare_selected_cb) },
2943   { "/Prepare a Filter/Not Selected",   NULL, "_Not Selected",                  NULL, NULL, G_CALLBACK(packet_list_menu_prepare_not_selected_cb) },
2944   { "/Prepare a Filter/AndSelected",    NULL, UTF8_HORIZONTAL_ELLIPSIS " _and Selected",                NULL, NULL, G_CALLBACK(packet_list_menu_prepare_and_selected_cb) },
2945   { "/Prepare a Filter/OrSelected",             NULL, UTF8_HORIZONTAL_ELLIPSIS " _or Selected",         NULL, NULL, G_CALLBACK(packet_list_menu_prepare_or_selected_cb) },
2946   { "/Prepare a Filter/AndNotSelected", NULL, UTF8_HORIZONTAL_ELLIPSIS " a_nd not Selected",    NULL, NULL, G_CALLBACK(packet_list_menu_prepare_and_not_selected_cb) },
2947   { "/Prepare a Filter/OrNotSelected",  NULL, UTF8_HORIZONTAL_ELLIPSIS " o_r not Selected",     NULL, NULL, G_CALLBACK(packet_list_menu_prepare_or_not_selected_cb) },
2948
2949   { "/Conversation Filter",                             NULL, "Conversation Filter",    NULL, NULL, NULL },
2950   { "/Conversation Filter/Ethernet",    NULL, "Ethernet",                               NULL, NULL, G_CALLBACK(packet_list_menu_conversation_ethernet_cb) },
2951   { "/Conversation Filter/IP",                  NULL, "IP",                                             NULL, NULL, G_CALLBACK(packet_list_menu_conversation_ip_cb) },
2952   { "/Conversation Filter/TCP",                 NULL, "TCP",                                    NULL, NULL, G_CALLBACK(packet_list_menu_conversation_tcp_cb) },
2953   { "/Conversation Filter/UDP",                 NULL, "UDP",                                    NULL, NULL, G_CALLBACK(packet_list_menu_conversation_udp_cb) },
2954   { "/Conversation Filter/PN-CBA",              NULL, "PN-CBA",                                 NULL, NULL, G_CALLBACK(packet_list_menu_conversation_pn_cba_cb) },
2955
2956   { "/Colorize Conversation",                   NULL, "Colorize Conversation",  NULL, NULL, NULL },
2957
2958   { "/Colorize Conversation/Ethernet",  NULL, "Ethernet",                               NULL, NULL, NULL },
2959
2960   { "/Colorize Conversation/Ethernet/Color 1",  WIRESHARK_STOCK_COLOR1, "Color 1",                                      NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_ethernet_color1_cb) },
2961   { "/Colorize Conversation/Ethernet/Color 2",  WIRESHARK_STOCK_COLOR2, "Color 2",                                      NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_ethernet_color2_cb) },
2962   { "/Colorize Conversation/Ethernet/Color 3",  WIRESHARK_STOCK_COLOR3, "Color 3",                                      NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_ethernet_color3_cb) },
2963   { "/Colorize Conversation/Ethernet/Color 4",  WIRESHARK_STOCK_COLOR4, "Color 4",                                      NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_ethernet_color4_cb) },
2964   { "/Colorize Conversation/Ethernet/Color 5",  WIRESHARK_STOCK_COLOR5, "Color 5",                                      NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_ethernet_color5_cb) },
2965   { "/Colorize Conversation/Ethernet/Color 6",  WIRESHARK_STOCK_COLOR6, "Color 6",                                      NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_ethernet_color6_cb) },
2966   { "/Colorize Conversation/Ethernet/Color 7",  WIRESHARK_STOCK_COLOR7, "Color 7",                                      NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_ethernet_color7_cb) },
2967   { "/Colorize Conversation/Ethernet/Color 8",  WIRESHARK_STOCK_COLOR8, "Color 8",                                      NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_ethernet_color8_cb) },
2968   { "/Colorize Conversation/Ethernet/Color 9",  WIRESHARK_STOCK_COLOR9, "Color 9",                                      NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_ethernet_color9_cb) },
2969   { "/Colorize Conversation/Ethernet/Color 10", WIRESHARK_STOCK_COLOR0, "Color 10",                                     NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_ethernet_color10_cb) },
2970   { "/Colorize Conversation/Ethernet/New Coloring Rule",        NULL,           "New Coloring Rule...",         NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_ethernet_new_rule_cb) },
2971
2972   { "/Colorize Conversation/IP",                NULL, "IP",                             NULL, NULL, NULL },
2973
2974   { "/Colorize Conversation/IP/Color 1",                WIRESHARK_STOCK_COLOR1, "Color 1",                                      NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_ip_color1_cb) },
2975   { "/Colorize Conversation/IP/Color 2",                WIRESHARK_STOCK_COLOR2, "Color 2",                                      NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_ip_color2_cb) },
2976   { "/Colorize Conversation/IP/Color 3",                WIRESHARK_STOCK_COLOR3, "Color 3",                                      NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_ip_color3_cb) },
2977   { "/Colorize Conversation/IP/Color 4",                WIRESHARK_STOCK_COLOR4, "Color 4",                                      NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_ip_color4_cb) },
2978   { "/Colorize Conversation/IP/Color 5",                WIRESHARK_STOCK_COLOR5, "Color 5",                                      NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_ip_color5_cb) },
2979   { "/Colorize Conversation/IP/Color 6",                WIRESHARK_STOCK_COLOR6, "Color 6",                                      NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_ip_color6_cb) },
2980   { "/Colorize Conversation/IP/Color 7",                WIRESHARK_STOCK_COLOR7, "Color 7",                                      NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_ip_color7_cb) },
2981   { "/Colorize Conversation/IP/Color 8",                WIRESHARK_STOCK_COLOR8, "Color 8",                                      NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_ip_color8_cb) },
2982   { "/Colorize Conversation/IP/Color 9",                WIRESHARK_STOCK_COLOR9, "Color 9",                                      NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_ip_color9_cb) },
2983   { "/Colorize Conversation/IP/Color 10",               WIRESHARK_STOCK_COLOR0, "Color 10",                                     NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_ip_color10_cb) },
2984   { "/Colorize Conversation/IP/New Coloring Rule",      NULL,           "New Coloring Rule...",                         NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_ip_new_rule_cb) },
2985
2986   { "/Colorize Conversation/TCP",               NULL, "TCP",                            NULL, NULL, NULL },
2987
2988   { "/Colorize Conversation/TCP/Color 1",               WIRESHARK_STOCK_COLOR1, "Color 1",                                      NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_tcp_color1_cb) },
2989   { "/Colorize Conversation/TCP/Color 2",               WIRESHARK_STOCK_COLOR2, "Color 2",                                      NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_tcp_color2_cb) },
2990   { "/Colorize Conversation/TCP/Color 3",               WIRESHARK_STOCK_COLOR3, "Color 3",                                      NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_tcp_color3_cb) },
2991   { "/Colorize Conversation/TCP/Color 4",               WIRESHARK_STOCK_COLOR4, "Color 4",                                      NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_tcp_color4_cb) },
2992   { "/Colorize Conversation/TCP/Color 5",               WIRESHARK_STOCK_COLOR5, "Color 5",                                      NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_tcp_color5_cb) },
2993   { "/Colorize Conversation/TCP/Color 6",               WIRESHARK_STOCK_COLOR6, "Color 6",                                      NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_tcp_color6_cb) },
2994   { "/Colorize Conversation/TCP/Color 7",               WIRESHARK_STOCK_COLOR7, "Color 7",                                      NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_tcp_color7_cb) },
2995   { "/Colorize Conversation/TCP/Color 8",               WIRESHARK_STOCK_COLOR8, "Color 8",                                      NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_tcp_color8_cb) },
2996   { "/Colorize Conversation/TCP/Color 9",               WIRESHARK_STOCK_COLOR9, "Color 9",                                      NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_tcp_color9_cb) },
2997   { "/Colorize Conversation/TCP/Color 10",              WIRESHARK_STOCK_COLOR0, "Color 10",                                     NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_tcp_color10_cb) },
2998   { "/Colorize Conversation/TCP/New Coloring Rule",     NULL,           "New Coloring Rule...",                         NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_tcp_new_rule_cb) },
2999
3000   { "/Colorize Conversation/UDP",               NULL, "UDP",                            NULL, NULL, NULL },
3001
3002   { "/Colorize Conversation/UDP/Color 1",               WIRESHARK_STOCK_COLOR1, "Color 1",                                      NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_udp_color1_cb) },
3003   { "/Colorize Conversation/UDP/Color 2",               WIRESHARK_STOCK_COLOR2, "Color 2",                                      NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_udp_color2_cb) },
3004   { "/Colorize Conversation/UDP/Color 3",               WIRESHARK_STOCK_COLOR3, "Color 3",                                      NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_udp_color3_cb) },
3005   { "/Colorize Conversation/UDP/Color 4",               WIRESHARK_STOCK_COLOR4, "Color 4",                                      NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_udp_color4_cb) },
3006   { "/Colorize Conversation/UDP/Color 5",               WIRESHARK_STOCK_COLOR5, "Color 5",                                      NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_udp_color5_cb) },
3007   { "/Colorize Conversation/UDP/Color 6",               WIRESHARK_STOCK_COLOR6, "Color 6",                                      NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_udp_color6_cb) },
3008   { "/Colorize Conversation/UDP/Color 7",               WIRESHARK_STOCK_COLOR7, "Color 7",                                      NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_udp_color7_cb) },
3009   { "/Colorize Conversation/UDP/Color 8",               WIRESHARK_STOCK_COLOR8, "Color 8",                                      NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_udp_color8_cb) },
3010   { "/Colorize Conversation/UDP/Color 9",               WIRESHARK_STOCK_COLOR9, "Color 9",                                      NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_udp_color9_cb) },
3011   { "/Colorize Conversation/UDP/Color 10",              WIRESHARK_STOCK_COLOR0, "Color 10",                                     NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_udp_color10_cb) },
3012   { "/Colorize Conversation/UDP/New Coloring Rule",     NULL,           "New Coloring Rule...",                         NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_udp_new_rule_cb) },
3013
3014   { "/Colorize Conversation/PN-CBA",            NULL, "PN-CBA Server",                          NULL, NULL, NULL },
3015
3016   { "/Colorize Conversation/PN-CBA/Color 1",            WIRESHARK_STOCK_COLOR1, "Color 1",                                      NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_cba_color1_cb) },
3017   { "/Colorize Conversation/PN-CBA/Color 2",            WIRESHARK_STOCK_COLOR2, "Color 2",                                      NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_cba_color2_cb) },
3018   { "/Colorize Conversation/PN-CBA/Color 3",            WIRESHARK_STOCK_COLOR3, "Color 3",                                      NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_cba_color3_cb) },
3019   { "/Colorize Conversation/PN-CBA/Color 4",            WIRESHARK_STOCK_COLOR4, "Color 4",                                      NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_cba_color4_cb) },
3020   { "/Colorize Conversation/PN-CBA/Color 5",            WIRESHARK_STOCK_COLOR5, "Color 5",                                      NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_cba_color5_cb) },
3021   { "/Colorize Conversation/PN-CBA/Color 6",            WIRESHARK_STOCK_COLOR6, "Color 6",                                      NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_cba_color6_cb) },
3022   { "/Colorize Conversation/PN-CBA/Color 7",            WIRESHARK_STOCK_COLOR7, "Color 7",                                      NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_cba_color7_cb) },
3023   { "/Colorize Conversation/PN-CBA/Color 8",            WIRESHARK_STOCK_COLOR8, "Color 8",                                      NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_cba_color8_cb) },
3024   { "/Colorize Conversation/PN-CBA/Color 9",            WIRESHARK_STOCK_COLOR9, "Color 9",                                      NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_cba_color9_cb) },
3025   { "/Colorize Conversation/PN-CBA/Color 10",           WIRESHARK_STOCK_COLOR0, "Color 10",                                     NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_cba_color10_cb) },
3026   { "/Colorize Conversation/PN-CBA/New Coloring Rule",  NULL,           "New Coloring Rule...",                         NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_cba_new_rule_cb) },
3027
3028   { "/SCTP",            NULL, "SCTP",                           NULL, NULL, NULL },
3029   { "/SCTP/Analyse this Association",                           NULL,           "Analyse this Association",                             NULL, NULL, G_CALLBACK(sctp_analyse_start) },
3030   { "/SCTP/Prepare Filter for this Association",        NULL,           "Prepare Filter for this Association",  NULL, NULL, G_CALLBACK(sctp_set_assoc_filter) },
3031
3032
3033   { "/Follow TCP Stream",                                                       NULL,           "Follow TCP Stream",                                    NULL, NULL, G_CALLBACK(follow_tcp_stream_cb) },
3034   { "/Follow UDP Stream",                                                       NULL,           "Follow UDP Stream",                                    NULL, NULL, G_CALLBACK(follow_udp_stream_cb) },
3035   { "/Follow SSL Stream",                                                       NULL,           "Follow SSL Stream",                                    NULL, NULL, G_CALLBACK(follow_ssl_stream_cb) },
3036
3037   { "/Copy",            NULL, "Copy",                                   NULL, NULL, NULL },
3038   { "/Copy/SummaryTxt",                                                         NULL,           "Summary (Text)",                                               NULL, NULL, G_CALLBACK(packet_list_menu_copy_sum_txt) },
3039   { "/Copy/SummaryCSV",                                                         NULL,           "Summary (CSV)",                                                NULL, NULL, G_CALLBACK(packet_list_menu_copy_sum_csv) },
3040   { "/Copy/AsFilter",                                                           NULL,           "As Filter",                                                    NULL, NULL, G_CALLBACK(packet_list_menu_copy_as_flt) },
3041
3042
3043   { "/Copy/Bytes",                                                                      NULL,           "Bytes",                                        NULL, NULL, NULL },
3044   { "/Copy/Bytes/OffsetHexText",                                        NULL,           "Offset Hex Text",                                              NULL, NULL, G_CALLBACK(packet_list_menu_copy_bytes_oht_cb) },
3045   { "/Copy/Bytes/OffsetHex",                                            NULL,           "Offset Hex",                                                   NULL, NULL, G_CALLBACK(packet_list_menu_copy_bytes_oh_cb) },
3046   { "/Copy/Bytes/PrintableTextOnly",                            NULL,           "Printable Text Only",                                  NULL, NULL, G_CALLBACK(packet_list_menu_copy_bytes_text_cb) },
3047
3048   { "/Copy/Bytes/HexStream",                                            NULL,           "Hex Stream",                                                   NULL, NULL, G_CALLBACK(packet_list_menu_copy_bytes_hex_strm_cb) },
3049   { "/Copy/Bytes/BinaryStream",                                         NULL,           "Binary Stream",                                                NULL, NULL, G_CALLBACK(packet_list_menu_copy_bytes_bin_strm_cb) },
3050
3051   { "/DecodeAs",                                                                        WIRESHARK_STOCK_DECODE_AS,      "Decode As...",                 NULL, NULL, G_CALLBACK(decode_as_cb) },
3052   { "/Print",                                                                           GTK_STOCK_PRINT,                        "Print...",                             NULL, NULL, G_CALLBACK(file_print_selected_cmd_cb) },
3053   { "/ShowPacketinNewWindow",                                           NULL,                   "Show Packet in New Window",            NULL, NULL, G_CALLBACK(new_window_cb) },
3054
3055 };
3056
3057 static const char *ui_desc_tree_view_menu_popup =
3058 "<ui>\n"
3059 "  <popup name='TreeViewPopup' action='PopupAction'>\n"
3060 "     <menuitem name='ExpandSubtrees' action='/ExpandSubtrees'/>\n"
3061 "     <menuitem name='ExpandAll' action='/ExpandAll'/>\n"
3062 "     <menuitem name='CollapseAll' action='/CollapseAll'/>\n"
3063 "     <separator/>\n"
3064 "     <menuitem name='ApplyasColumn' action='/Apply as Column'/>\n"
3065 "     <separator/>\n"
3066 "     <menu name= 'ApplyAsFilter' action='/Apply as Filter'>\n"
3067 "       <menuitem name='Selected' action='/Apply as Filter/Selected'/>\n"
3068 "       <menuitem name='NotSelected' action='/Apply as Filter/Not Selected'/>\n"
3069 "       <menuitem name='AndSelected' action='/Apply as Filter/AndSelected'/>\n"
3070 "       <menuitem name='OrSelected' action='/Apply as Filter/OrSelected'/>\n"
3071 "       <menuitem name='AndNotSelected' action='/Apply as Filter/AndNotSelected'/>\n"
3072 "       <menuitem name='OrNotSelected' action='/Apply as Filter/OrNotSelected'/>\n"
3073 "     </menu>\n"
3074 "     <menu name= 'PrepareaFilter' action='/Prepare a Filter'>\n"
3075 "       <menuitem name='Selected' action='/Prepare a Filter/Selected'/>\n"
3076 "       <menuitem name='NotSelected' action='/Prepare a Filter/Not Selected'/>\n"
3077 "       <menuitem name='AndSelected' action='/Prepare a Filter/AndSelected'/>\n"
3078 "       <menuitem name='OrSelected' action='/Prepare a Filter/OrSelected'/>\n"
3079 "       <menuitem name='AndNotSelected' action='/Prepare a Filter/AndNotSelected'/>\n"
3080 "       <menuitem name='OrNotSelected' action='/Prepare a Filter/OrNotSelected'/>\n"
3081 "     </menu>\n"
3082 "     <menu name= 'ColorizewithFilter' action='/Colorize with Filter'>\n"
3083 "       <menuitem name='Color1' action='/Colorize with Filter/Color 1'/>\n"
3084 "       <menuitem name='Color2' action='/Colorize with Filter/Color 2'/>\n"
3085 "       <menuitem name='Color3' action='/Colorize with Filter/Color 3'/>\n"
3086 "       <menuitem name='Color4' action='/Colorize with Filter/Color 4'/>\n"
3087 "       <menuitem name='Color5' action='/Colorize with Filter/Color 5'/>\n"
3088 "       <menuitem name='Color6' action='/Colorize with Filter/Color 6'/>\n"
3089 "       <menuitem name='Color7' action='/Colorize with Filter/Color 7'/>\n"
3090 "       <menuitem name='Color8' action='/Colorize with Filter/Color 8'/>\n"
3091 "       <menuitem name='Color9' action='/Colorize with Filter/Color 9'/>\n"
3092 "       <menuitem name='Color10' action='/Colorize with Filter/Color 10'/>\n"
3093 "       <menuitem name='NewColoringRule' action='/Colorize with Filter/New Coloring Rule'/>\n"
3094 "     </menu>\n"
3095 "     <menuitem name='FollowTCPStream' action='/Follow TCP Stream'/>\n"
3096 "     <menuitem name='FollowUDPStream' action='/Follow UDP Stream'/>\n"
3097 "     <menuitem name='FollowSSLStream' action='/Follow SSL Stream'/>\n"
3098 "     <separator/>\n"
3099 "     <menu name= 'Copy' action='/Copy'>\n"
3100 "        <menuitem name='Description' action='/Copy/Description'/>\n"
3101 "        <menuitem name='Fieldname' action='/Copy/Fieldname'/>\n"
3102 "        <menuitem name='Value' action='/Copy/Value'/>\n"
3103 "        <separator/>\n"
3104 "        <menuitem name='AsFilter' action='/Copy/AsFilter'/>\n"
3105 "        <separator/>\n"
3106 "        <menu name= 'Bytes' action='/Copy/Bytes'>\n"
3107 "           <menuitem name='OffsetHexText' action='/Copy/Bytes/OffsetHexText'/>\n"
3108 "           <menuitem name='OffsetHex' action='/Copy/Bytes/OffsetHex'/>\n"
3109 "           <menuitem name='PrintableTextOnly' action='/Copy/Bytes/PrintableTextOnly'/>\n"
3110 "           <separator/>\n"
3111 "           <menuitem name='HexStream' action='/Copy/Bytes/HexStream'/>\n"
3112 "           <menuitem name='BinaryStream' action='/Copy/Bytes/BinaryStream'/>\n"
3113 "        </menu>\n"
3114 "     </menu>\n"
3115 "     <menuitem name='ExportSelectedPacketBytes' action='/ExportSelectedPacketBytes'/>\n"
3116 "     <separator/>\n"
3117 "     <menuitem name='WikiProtocolPage' action='/WikiProtocolPage'/>\n"
3118 "     <menuitem name='FilterFieldReference' action='/FilterFieldReference'/>\n"
3119 #if GLIB_CHECK_VERSION(2,14,0) /* GRegex */
3120 "     <menuitem name='ProtocolHelp' action='/ProtocolHelp'/>\n"
3121 #endif /* GLIB_CHECK_VERSION(2,14,0) */
3122 "     <menuitem name='ProtocolPreferences' action='/ProtocolPreferences'/>\n"
3123 "     <separator/>\n"
3124 "     <menuitem name='DecodeAs' action='/DecodeAs'/>\n"
3125 "     <menuitem name='DisableProtocol' action='/DisableProtocol'/>\n"
3126 "     <menuitem name='ResolveName' action='/ResolveName'/>\n"
3127 "     <menuitem name='GotoCorrespondingPacket' action='/GotoCorrespondingPacket'/>\n"
3128 "  </popup>\n"
3129 "</ui>\n";
3130
3131 static const GtkActionEntry tree_view_menu_popup_action_entries[] = {
3132   { "/ExpandSubtrees",                                  NULL,                                                   "Expand Subtrees",              NULL,                                   NULL,                   G_CALLBACK(expand_tree_cb) },
3133   { "/ExpandAll",                                               NULL,                                                   "Expand All",                   NULL,                                   NULL,                   G_CALLBACK(expand_all_cb) },
3134   { "/CollapseAll",                                             NULL,                                                   "Collapse All",                 NULL,                                   NULL,                   G_CALLBACK(collapse_all_cb) },
3135   { "/Apply as Column",                                 NULL,                                                   "Apply as Column",              NULL,                                   NULL,                   G_CALLBACK(apply_as_custom_column_cb) },
3136   { "/Apply as Filter",                                 NULL,                                                   "Apply as Filter",              NULL,                                   NULL,                   NULL },
3137
3138   { "/Apply as Filter/Selected",                NULL, "_Selected" ,                             NULL, NULL, G_CALLBACK(tree_view_menu_apply_selected_cb) },
3139   { "/Apply as Filter/Not Selected",    NULL, "_Not Selected",                  NULL, NULL, G_CALLBACK(tree_view_menu_apply_not_selected_cb) },
3140   { "/Apply as Filter/AndSelected",             NULL, UTF8_HORIZONTAL_ELLIPSIS " _and Selected",                NULL, NULL, G_CALLBACK(tree_view_menu_apply_and_selected_cb) },
3141   { "/Apply as Filter/OrSelected",              NULL, UTF8_HORIZONTAL_ELLIPSIS " _or Selected",         NULL, NULL, G_CALLBACK(tree_view_menu_apply_or_selected_cb) },
3142   { "/Apply as Filter/AndNotSelected",  NULL, UTF8_HORIZONTAL_ELLIPSIS " a_nd not Selected",    NULL, NULL, G_CALLBACK(tree_view_menu_apply_and_not_selected_cb) },
3143   { "/Apply as Filter/OrNotSelected",   NULL, UTF8_HORIZONTAL_ELLIPSIS " o_r not Selected",     NULL, NULL, G_CALLBACK(tree_view_menu_apply_or_not_selected_cb) },
3144
3145   { "/Prepare a Filter",                                NULL, "Prepare a Filter",               NULL, NULL, NULL },
3146   { "/Prepare a Filter/Selected",               NULL, "_Selected" ,                             NULL, NULL, G_CALLBACK(tree_view_menu_prepare_selected_cb) },
3147   { "/Prepare a Filter/Not Selected",   NULL, "_Not Selected",                  NULL, NULL, G_CALLBACK(tree_view_menu_prepare_not_selected_cb) },
3148   { "/Prepare a Filter/AndSelected",    NULL, UTF8_HORIZONTAL_ELLIPSIS " _and Selected",                NULL, NULL, G_CALLBACK(tree_view_menu_prepare_and_selected_cb) },
3149   { "/Prepare a Filter/OrSelected",             NULL, UTF8_HORIZONTAL_ELLIPSIS " _or Selected",         NULL, NULL, G_CALLBACK(tree_view_menu_prepare_or_selected_cb) },
3150   { "/Prepare a Filter/AndNotSelected", NULL, UTF8_HORIZONTAL_ELLIPSIS " a_nd not Selected",    NULL, NULL, G_CALLBACK(tree_view_menu_prepare_and_not_selected_cb) },
3151   { "/Prepare a Filter/OrNotSelected",  NULL, UTF8_HORIZONTAL_ELLIPSIS " o_r not Selected",     NULL, NULL, G_CALLBACK(tree_view_menu_prepare_or_not_selected_cb) },
3152
3153   { "/Colorize with Filter",                    NULL, "Colorize with Filter",   NULL, NULL, NULL },
3154   { "/Colorize with Filter/Color 1",            WIRESHARK_STOCK_COLOR1, "Color 1",                                      NULL, NULL, G_CALLBACK(tree_view_menu_color_with_flt_color1_cb) },
3155   { "/Colorize with Filter/Color 2",            WIRESHARK_STOCK_COLOR2, "Color 2",                                      NULL, NULL, G_CALLBACK(tree_view_menu_color_with_flt_color2_cb) },
3156   { "/Colorize with Filter/Color 3",            WIRESHARK_STOCK_COLOR3, "Color 3",                                      NULL, NULL, G_CALLBACK(tree_view_menu_color_with_flt_color3_cb) },
3157   { "/Colorize with Filter/Color 4",            WIRESHARK_STOCK_COLOR4, "Color 4",                                      NULL, NULL, G_CALLBACK(tree_view_menu_color_with_flt_color4_cb) },
3158   { "/Colorize with Filter/Color 5",            WIRESHARK_STOCK_COLOR5, "Color 5",                                      NULL, NULL, G_CALLBACK(tree_view_menu_color_with_flt_color5_cb) },
3159   { "/Colorize with Filter/Color 6",            WIRESHARK_STOCK_COLOR6, "Color 6",                                      NULL, NULL, G_CALLBACK(tree_view_menu_color_with_flt_color6_cb) },
3160   { "/Colorize with Filter/Color 7",            WIRESHARK_STOCK_COLOR7, "Color 7",                                      NULL, NULL, G_CALLBACK(tree_view_menu_color_with_flt_color7_cb) },
3161   { "/Colorize with Filter/Color 8",            WIRESHARK_STOCK_COLOR8, "Color 8",                                      NULL, NULL, G_CALLBACK(tree_view_menu_color_with_flt_color8_cb) },
3162   { "/Colorize with Filter/Color 9",            WIRESHARK_STOCK_COLOR9, "Color 9",                                      NULL, NULL, G_CALLBACK(tree_view_menu_color_with_flt_color9_cb) },
3163   { "/Colorize with Filter/Color 10",           WIRESHARK_STOCK_COLOR0, "Color 10",                                     NULL, NULL, G_CALLBACK(tree_view_menu_color_with_flt_color10_cb) },
3164   { "/Colorize with Filter/New Coloring Rule",  NULL,           "New Coloring Rule...",                         NULL, NULL, G_CALLBACK(tree_view_menu_color_with_flt_new_rule_cb) },
3165
3166   { "/Follow TCP Stream",                                                       NULL,           "Follow TCP Stream",                                    NULL, NULL, G_CALLBACK(follow_tcp_stream_cb) },
3167   { "/Follow UDP Stream",                                                       NULL,           "Follow UDP Stream",                                    NULL, NULL, G_CALLBACK(follow_udp_stream_cb) },
3168   { "/Follow SSL Stream",                                                       NULL,           "Follow SSL Stream",                                    NULL, NULL, G_CALLBACK(follow_ssl_stream_cb) },
3169
3170   { "/Copy",            NULL, "Copy",                                   NULL, NULL, NULL },
3171   { "/Copy/Description",                                                        NULL,           "Description",                                          NULL, NULL, G_CALLBACK(tree_view_menu_copy_desc) },
3172   { "/Copy/Fieldname",                                                          NULL,           "Fieldname",                                            NULL, NULL, G_CALLBACK(tree_view_menu_copy_field) },
3173   { "/Copy/Value",                                                                      NULL,           "Value",                                                        NULL, NULL, G_CALLBACK(tree_view_menu_copy_value) },
3174
3175   { "/Copy/AsFilter",                                                           NULL,           "As Filter",                                            NULL, NULL, G_CALLBACK(tree_view_menu_copy_as_flt) },
3176
3177   { "/Copy/Bytes",                                                                      NULL,           "Bytes",                                                                NULL, NULL, NULL },
3178   { "/Copy/Bytes/OffsetHexText",                                        NULL,           "Offset Hex Text",                                              NULL, NULL, G_CALLBACK(packet_list_menu_copy_bytes_oht_cb) },
3179   { "/Copy/Bytes/OffsetHex",                                            NULL,           "Offset Hex",                                                   NULL, NULL, G_CALLBACK(packet_list_menu_copy_bytes_oh_cb) },
3180   { "/Copy/Bytes/PrintableTextOnly",                            NULL,           "Printable Text Only",                                  NULL, NULL, G_CALLBACK(packet_list_menu_copy_bytes_text_cb) },
3181
3182   { "/Copy/Bytes/HexStream",                                            NULL,           "Hex Stream",                                                   NULL, NULL, G_CALLBACK(packet_list_menu_copy_bytes_hex_strm_cb) },
3183   { "/Copy/Bytes/BinaryStream",                                         NULL,           "Binary Stream",                                                NULL, NULL, G_CALLBACK(packet_list_menu_copy_bytes_bin_strm_cb) },
3184
3185   { "/ExportSelectedPacketBytes",                                       NULL,           "Export Selected Packet Bytes...",              NULL, NULL, G_CALLBACK(savehex_cb) },
3186
3187   { "/WikiProtocolPage",                        WIRESHARK_STOCK_WIKI,           "Wiki Protocol Page",                                   NULL, NULL, G_CALLBACK(selected_ptree_info_cb) },
3188   { "/FilterFieldReference",    WIRESHARK_STOCK_INTERNET,               "Filter Field Reference",                               NULL, NULL, G_CALLBACK(selected_ptree_ref_cb) },
3189 #if GLIB_CHECK_VERSION(2,14,0) /* GRegex */
3190   { "/ProtocolHelp",                                                            NULL,           "Protocol Help",                                                NULL, NULL, NULL },
3191 #endif /* GLIB_CHECK_VERSION(2,14,0) */
3192   { "/ProtocolPreferences",                                                     NULL,           "Protocol Preferences",                                 NULL, NULL, NULL },
3193   { "/DecodeAs",                                WIRESHARK_STOCK_DECODE_AS,              "Decode As...",                                                 NULL, NULL, G_CALLBACK(decode_as_cb) },
3194   { "/DisableProtocol",                 WIRESHARK_STOCK_CHECKBOX,               "Disable Protocol...",                                  NULL, NULL, G_CALLBACK(proto_disable_cb) },
3195   { "/ResolveName",                                                                     NULL,           "_Resolve Name",                                                NULL, NULL, G_CALLBACK(resolve_name_cb) },
3196   { "/GotoCorrespondingPacket",                                         NULL,           "_Go to Corresponding Packet",                  NULL, NULL, G_CALLBACK(goto_framenum_cb) },
3197 };
3198
3199 static const char *ui_desc_bytes_menu_popup =
3200 "<ui>\n"
3201 "  <popup name='BytesMenuPopup' action='PopupAction'>\n"
3202 "     <menuitem name='HexView' action='/HexView'/>\n"
3203 "     <menuitem name='BitsView' action='/BitsView'/>\n"
3204 "  </popup>\n"
3205 "</ui>\n";
3206 static const GtkRadioActionEntry bytes_menu_radio_action_entries [] =
3207 {
3208         /* name,        stock id,       label,          accel,  tooltip,  value */
3209         { "/HexView",   NULL,           "Hex View",     NULL,   NULL,     BYTES_HEX },
3210         { "/BitsView",  NULL,           "Bits View",    NULL,   NULL,     BYTES_BITS },
3211 };
3212
3213 static const char *ui_statusbar_profiles_menu_popup =
3214 "<ui>\n"
3215 "  <popup name='ProfilesMenuPopup' action='PopupAction'>\n"
3216 "     <menuitem name='Profiles' action='/Profiles'/>\n"
3217 "     <separator/>\n"
3218 "     <menuitem name='New' action='/New'/>\n"
3219 "     <menuitem name='Copy' action='/Copy'/>\n"
3220 "     <menuitem name='Delete' action='/Delete'/>\n"
3221 "     <menuitem name='Rename' action='/Rename'/>\n"
3222 "     <separator/>\n"
3223 "     <menu name='Change' action='/Change'>\n"
3224 "        <menuitem name='Default' action='/Change/Default'/>\n"
3225 "     </menu>\n"
3226 "  </popup>\n"
3227 "</ui>\n";
3228 static const GtkActionEntry statusbar_profiles_menu_action_entries [] =
3229 {
3230         { "/Profiles",  NULL,   "Configuration Profiles...",    NULL,   NULL,     G_CALLBACK(profile_dialog_cb) },
3231         { "/New",       GTK_STOCK_NEW,  "New...",       NULL,   NULL,     G_CALLBACK(profile_new_cb) },
3232         { "/Copy",      GTK_STOCK_COPY, "Copy...",      NULL,   NULL,     G_CALLBACK(profile_copy_cb) },
3233         { "/Delete",    GTK_STOCK_DELETE,       "Delete",       NULL,   NULL,     G_CALLBACK(profile_delete_cb) },
3234 #if GLIB_CHECK_VERSION(2,6,0)
3235         { "/Rename",    GTK_STOCK_EDIT, "Rename...",    NULL,   NULL,     G_CALLBACK(profile_rename_cb) },
3236 #else
3237         { "/Rename",    NULL,   "Rename...",    NULL,   NULL,     G_CALLBACK(profile_rename_cb) },
3238 #endif
3239         { "/Change",    NULL,           "Change",       NULL,   NULL,   NULL },
3240         { "/Change/Default",    NULL,   "Default",      NULL,   NULL,     NULL },
3241 };
3242
3243 GtkWidget *
3244 main_menu_new(GtkAccelGroup ** table) {
3245     GtkWidget *menubar;
3246 #ifdef HAVE_IGE_MAC_INTEGRATION
3247     GtkWidget *quit_item, *about_item, *preferences_item;
3248     IgeMacMenuGroup *group;
3249 #endif
3250 #ifdef HAVE_GTKOSXAPPLICATION
3251     GtkOSXApplication *theApp;
3252     GtkWidget * item;
3253     GtkOSXApplicationMenuGroup *group;
3254     GtkWidget * dock_menu;
3255 #endif
3256
3257     grp = gtk_accel_group_new();
3258
3259     if (initialize)
3260         menus_init();
3261
3262 #ifdef MAIN_MENU_USE_UIMANAGER
3263     menubar = gtk_ui_manager_get_widget(ui_manager_main_menubar, "/Menubar");
3264 #else
3265     menubar = main_menu_factory->widget;
3266 #endif
3267 #ifdef HAVE_IGE_MAC_INTEGRATION
3268     if(prefs.gui_macosx_style) {
3269         ige_mac_menu_set_menu_bar(GTK_MENU_SHELL(menubar));
3270         ige_mac_menu_set_global_key_handler_enabled(TRUE);
3271
3272         /* Create menu items to populate the application menu with.  We have to
3273          * do this because we are still using the old GtkItemFactory API for
3274          * the main menu. */
3275         group = ige_mac_menu_add_app_menu_group();
3276         about_item = gtk_menu_item_new_with_label("About");
3277         g_signal_connect(about_item, "activate", G_CALLBACK(about_wireshark_cb),
3278                          NULL);
3279         ige_mac_menu_add_app_menu_item(group, GTK_MENU_ITEM(about_item), NULL);
3280
3281         group = ige_mac_menu_add_app_menu_group();
3282         preferences_item = gtk_menu_item_new_with_label("Preferences");
3283         g_signal_connect(preferences_item, "activate", G_CALLBACK(prefs_cb),
3284                          NULL);
3285         ige_mac_menu_add_app_menu_item(group, GTK_MENU_ITEM(preferences_item),
3286                                        NULL);
3287     }
3288
3289     /* The quit item in the application menu shows up whenever ige mac
3290      * integration is enabled, even if the OS X UI style in Wireshark isn't
3291      * turned on. */
3292     quit_item = gtk_menu_item_new_with_label("Quit");
3293     g_signal_connect(quit_item, "activate", G_CALLBACK(file_quit_cmd_cb), NULL);
3294     ige_mac_menu_set_quit_menu_item(GTK_MENU_ITEM(quit_item));
3295 #endif
3296
3297 #ifdef HAVE_GTKOSXAPPLICATION
3298     theApp = g_object_new(GTK_TYPE_OSX_APPLICATION, NULL);
3299
3300     if(prefs.gui_macosx_style) {
3301         gtk_osxapplication_set_menu_bar(theApp, GTK_MENU_SHELL(menubar));
3302         gtk_osxapplication_set_use_quartz_accelerators(theApp, TRUE);
3303
3304         group = gtk_osxapplication_add_app_menu_group (theApp);
3305         item = gtk_item_factory_get_item(main_menu_factory,"/Help/About Wireshark");
3306         gtk_osxapplication_add_app_menu_item(theApp, group,GTK_MENU_ITEM (item));
3307
3308         group = gtk_osxapplication_add_app_menu_group (theApp);
3309         item = gtk_item_factory_get_item(main_menu_factory,"/Edit/Preferences...");
3310         gtk_osxapplication_add_app_menu_item(theApp, group,GTK_MENU_ITEM (item));
3311
3312         group = gtk_osxapplication_add_app_menu_group (theApp);
3313         item = gtk_item_factory_get_item(main_menu_factory,"/Help");
3314         gtk_osxapplication_set_help_menu(theApp,GTK_MENU_ITEM(item));
3315
3316         /* Quit item is not needed */
3317         gtk_item_factory_delete_item(main_menu_factory,"/File/Quit");
3318     }
3319
3320     /* generate dock menu */
3321     dock_menu = gtk_menu_new();
3322
3323     item = gtk_menu_item_new_with_label("Start");
3324     g_signal_connect(item, "activate", G_CALLBACK (capture_start_cb), NULL);
3325     gtk_menu_shell_append(GTK_MENU_SHELL(dock_menu), item);
3326
3327     item = gtk_menu_item_new_with_label("Stop");
3328     g_signal_connect(item, "activate", G_CALLBACK (capture_stop_cb), NULL);
3329     gtk_menu_shell_append(GTK_MENU_SHELL(dock_menu), item);
3330
3331     item = gtk_menu_item_new_with_label("Restart");
3332     g_signal_connect(item, "activate", G_CALLBACK (capture_restart_cb), NULL);
3333     gtk_menu_shell_append(GTK_MENU_SHELL(dock_menu), item);
3334
3335     gtk_osxapplication_set_dock_menu(theApp, GTK_MENU_SHELL(dock_menu));
3336 #endif
3337
3338     if (table)
3339         *table = grp;
3340
3341     return menubar;
3342 }
3343
3344
3345 void menu_dissector_filter_cb(  GtkWidget *widget _U_,
3346                                 gpointer callback_data,
3347                                 guint callback_action _U_)
3348 {
3349     dissector_filter_t      *filter_entry = callback_data;
3350     GtkWidget               *filter_te;
3351     const char              *buf;
3352
3353     filter_te = g_object_get_data(G_OBJECT(popup_menu_object), E_DFILTER_TE_KEY);
3354
3355     /* XXX - this gets the packet_info of the last dissected packet, */
3356     /* which is not necessarily the last selected packet */
3357     /* e.g. "Update list of packets in real time" won't work correct */
3358     buf = filter_entry->build_filter_string(&cfile.edt->pi);
3359
3360     gtk_entry_set_text(GTK_ENTRY(filter_te), buf);
3361
3362     /* Run the display filter so it goes in effect - even if it's the
3363        same as the previous display filter. */
3364     main_filter_packets(&cfile, buf, TRUE);
3365
3366     g_free( (void *) buf);
3367 }
3368
3369 gboolean menu_dissector_filter_spe_cb(frame_data *fd _U_, epan_dissect_t *edt, gpointer callback_data) {
3370     dissector_filter_t *filter_entry = callback_data;
3371
3372     /* XXX - this gets the packet_info of the last dissected packet, */
3373     /* which is not necessarily the last selected packet */
3374     /* e.g. "Update list of packets in real time" won't work correct */
3375     return (edt != NULL) ? filter_entry->is_filter_valid(&edt->pi) : FALSE;
3376 }
3377
3378 void menu_dissector_filter(void) {
3379     GList *list_entry = dissector_filter_list;
3380     dissector_filter_t *filter_entry;
3381
3382     while(list_entry != NULL) {
3383         filter_entry = list_entry->data;
3384
3385         register_stat_menu_item(filter_entry->name, REGISTER_ANALYZE_GROUP_CONVERSATION_FILTER,
3386             menu_dissector_filter_cb,
3387             menu_dissector_filter_spe_cb,
3388             NULL /* selected_tree_row_enabled */,
3389             filter_entry);
3390
3391         list_entry = g_list_next(list_entry);
3392     }
3393 }
3394
3395
3396 static void
3397 menus_init(void) {
3398     GtkActionGroup *packet_list_heading_action_group, *packet_list_action_group,
3399         *packet_list_details_action_group, *packet_list_byte_menu_action_group,
3400         *statusbar_profiles_action_group;
3401     GError *error = NULL;
3402
3403     if (initialize) {
3404         initialize = FALSE;
3405
3406         popup_menu_object = gtk_menu_new();
3407
3408         /* packet list heading pop-up menu */
3409         packet_list_heading_action_group = gtk_action_group_new ("PacketListHeadingPopUpMenuActionGroup");
3410
3411         gtk_action_group_add_actions (packet_list_heading_action_group,            /* the action group */
3412             packet_list_heading_menu_popup_action_entries,                        /* an array of action descriptions */
3413             G_N_ELEMENTS(packet_list_heading_menu_popup_action_entries),        /* the number of entries */
3414             popup_menu_object);                                                    /* data to pass to the action callbacks */
3415
3416         gtk_action_group_add_toggle_actions(packet_list_heading_action_group,          /* the action group */
3417                                     packet_list_heading_menu_toggle_action_entries,    /* an array of action descriptions */
3418                                     G_N_ELEMENTS(packet_list_heading_menu_toggle_action_entries), /* the number of entries */
3419                                     NULL);                                                /* data to pass to the action callbacks */
3420
3421         ui_manager_packet_list_heading = gtk_ui_manager_new ();
3422         gtk_ui_manager_insert_action_group (ui_manager_packet_list_heading,
3423             packet_list_heading_action_group,
3424             0); /* the position at which the group will be inserted.  */
3425
3426         gtk_ui_manager_add_ui_from_string (ui_manager_packet_list_heading,ui_desc_packet_list_heading_menu_popup, -1, &error);
3427         if (error != NULL)
3428         {
3429             fprintf (stderr, "Warning: building Packet List Heading Pop-Up failed: %s\n",
3430                     error->message);
3431             g_error_free (error);
3432             error = NULL;
3433         }
3434
3435         g_object_set_data(G_OBJECT(popup_menu_object), PM_PACKET_LIST_COL_KEY,
3436                        gtk_ui_manager_get_widget(ui_manager_packet_list_heading, "/PacketListHeadingPopup"));
3437
3438         popup_menu_list = g_slist_append((GSList *)popup_menu_list, ui_manager_packet_list_heading);
3439
3440         /* packet list pop-up menu */
3441         packet_list_action_group = gtk_action_group_new ("PacketListPopUpMenuActionGroup");
3442
3443         gtk_action_group_add_actions (packet_list_action_group,                    /* the action group */
3444             packet_list_menu_popup_action_entries,                                /* an array of action descriptions */
3445             G_N_ELEMENTS(packet_list_menu_popup_action_entries),                /* the number of entries */
3446             popup_menu_object);                                                    /* data to pass to the action callbacks */
3447
3448         ui_manager_packet_list_menu = gtk_ui_manager_new ();
3449
3450         gtk_ui_manager_insert_action_group (ui_manager_packet_list_menu,
3451             packet_list_action_group,
3452             0); /* the position at which the group will be inserted.  */
3453
3454         gtk_ui_manager_add_ui_from_string (ui_manager_packet_list_menu, ui_desc_packet_list_menu_popup, -1, &error);
3455         if (error != NULL)
3456         {
3457             fprintf (stderr, "Warning: building Packet List Pop-Up menu failed: %s\n",
3458                     error->message);
3459             g_error_free (error);
3460             error = NULL;
3461         }
3462
3463         g_object_set_data(G_OBJECT(popup_menu_object), PM_PACKET_LIST_KEY,
3464                         gtk_ui_manager_get_widget(ui_manager_packet_list_menu, "/PacketListMenuPopup"));
3465
3466         popup_menu_list = g_slist_append((GSList *)popup_menu_list, ui_manager_packet_list_menu);
3467
3468
3469         /* packet detail pop-up menu */
3470         packet_list_details_action_group = gtk_action_group_new ("PacketListDetailsMenuPopUpActionGroup");
3471
3472         gtk_action_group_add_actions (packet_list_details_action_group,            /* the action group */
3473             tree_view_menu_popup_action_entries,                                /* an array of action descriptions */
3474             G_N_ELEMENTS(tree_view_menu_popup_action_entries),                    /* the number of entries */
3475             popup_menu_object);                                                    /* data to pass to the action callbacks */
3476
3477         ui_manager_tree_view_menu = gtk_ui_manager_new ();
3478
3479         gtk_ui_manager_insert_action_group (ui_manager_tree_view_menu,
3480             packet_list_details_action_group,
3481             0); /* the position at which the group will be inserted.  */
3482
3483         gtk_ui_manager_add_ui_from_string (ui_manager_tree_view_menu, ui_desc_tree_view_menu_popup, -1, &error);
3484         if (error != NULL)
3485         {
3486             fprintf (stderr, "Warning: building TreeWiew Pop-Up menu failed: %s\n",
3487                     error->message);
3488             g_error_free (error);
3489             error = NULL;
3490         }
3491
3492         g_object_set_data(G_OBJECT(popup_menu_object), PM_TREE_VIEW_KEY,
3493                          gtk_ui_manager_get_widget(ui_manager_tree_view_menu, "/TreeViewPopup"));
3494
3495         popup_menu_list = g_slist_append((GSList *)popup_menu_list, ui_manager_tree_view_menu);
3496
3497         /*
3498          * Hex dump pop-up menu.
3499          * We provide our own empty menu to suppress the default pop-up menu
3500          * for text widgets.
3501          */
3502         packet_list_byte_menu_action_group = gtk_action_group_new ("PacketListByteMenuPopUpActionGroup");
3503
3504
3505         gtk_action_group_add_radio_actions  (packet_list_byte_menu_action_group,            /* the action group */
3506                                     bytes_menu_radio_action_entries,                        /* an array of radio action descriptions  */
3507                                     G_N_ELEMENTS(bytes_menu_radio_action_entries),            /* the number of entries */
3508                                     recent.gui_bytes_view,                                    /* the value of the action to activate initially, or -1 if no action should be activated  */
3509                                     G_CALLBACK(select_bytes_view_cb),                        /* the callback to connect to the changed signal  */
3510                                     popup_menu_object);                                        /* data to pass to the action callbacks  */
3511
3512         ui_manager_bytes_menu = gtk_ui_manager_new ();
3513
3514         gtk_ui_manager_insert_action_group (ui_manager_bytes_menu,
3515             packet_list_byte_menu_action_group,
3516             0); /* the position at which the group will be inserted.  */
3517
3518         gtk_ui_manager_add_ui_from_string (ui_manager_bytes_menu, ui_desc_bytes_menu_popup, -1, &error);
3519         if (error != NULL)
3520         {
3521             fprintf (stderr, "Warning: building Bytes Pop-Up menu failed: %s\n",
3522                     error->message);
3523             g_error_free (error);
3524             error = NULL;
3525         }
3526
3527         g_object_set_data(G_OBJECT(popup_menu_object), PM_BYTES_VIEW_KEY,
3528                         gtk_ui_manager_get_widget(ui_manager_bytes_menu, "/BytesMenuPopup"));
3529
3530         popup_menu_list = g_slist_append((GSList *)popup_menu_list, ui_manager_bytes_menu);
3531
3532         /* main */
3533 #ifdef MAIN_MENU_USE_UIMANAGER
3534         main_menu_bar_action_group = gtk_action_group_new ("MenuActionGroup"); 
3535         gtk_action_group_add_actions (main_menu_bar_action_group,                            /* the action group */
3536                                     main_menu_bar_entries,                    /* an array of action descriptions */
3537                                     G_N_ELEMENTS(main_menu_bar_entries),    /* the number of entries */
3538                                     NULL);                                    /* data to pass to the action callbacks */
3539
3540         gtk_action_group_add_toggle_actions(main_menu_bar_action_group,                              /* the action group */
3541                                     main_menu_bar_toggle_action_entries,               /* an array of action descriptions */
3542                                     G_N_ELEMENTS(main_menu_bar_toggle_action_entries), /* the number of entries */
3543                                     NULL);                                             /* data to pass to the action callbacks */
3544
3545         gtk_action_group_add_radio_actions  (main_menu_bar_action_group,                                    /* the action group */
3546                                     main_menu_bar_radio_view_time_entries,                    /* an array of radio action descriptions  */
3547                                     G_N_ELEMENTS(main_menu_bar_radio_view_time_entries),    /* the number of entries */
3548                                     recent.gui_time_format,                                    /* the value of the action to activate initially, or -1 if no action should be activated  */
3549                                     G_CALLBACK(timestamp_format_new_cb),                    /* the callback to connect to the changed signal  */
3550                                     NULL);                                                    /* data to pass to the action callbacks  */
3551
3552         gtk_action_group_add_radio_actions  (main_menu_bar_action_group,                                    /* the action group */
3553                                     main_menu_bar_radio_view_time_fileformat_prec_entries,  /* an array of radio action descriptions  */
3554                                     G_N_ELEMENTS(main_menu_bar_radio_view_time_fileformat_prec_entries),    /* the number of entries */
3555                                     recent.gui_time_precision,                                /* the value of the action to activate initially, or -1 if no action should be activated  */
3556                                     G_CALLBACK(timestamp_precision_new_cb),                    /* the callback to connect to the changed signal  */
3557                                     NULL);                                                    /* data to pass to the action callbacks  */
3558
3559
3560
3561         ui_manager_main_menubar = gtk_ui_manager_new ();
3562         gtk_ui_manager_insert_action_group (ui_manager_main_menubar, main_menu_bar_action_group, 0);
3563         gtk_ui_manager_add_ui_from_string (ui_manager_main_menubar,ui_desc_menubar, -1, &error); 
3564         if (error != NULL) 
3565         { 
3566             fprintf (stderr, "Warning: building main menubar failed: %s\n", 
3567                     error->message); 
3568             g_error_free (error); 
3569             error = NULL; 
3570         } 
3571 #else /* MAIN_MENU_USE_UIMANAGER */
3572         main_menu_factory = gtk_item_factory_new(GTK_TYPE_MENU_BAR, "<main>", grp);
3573         gtk_item_factory_create_items_ac(main_menu_factory, nmenu_items, menu_items, NULL, 2);
3574 #endif /* MAIN_MENU_USE_UIMANAGER */
3575
3576         statusbar_profiles_action_group = gtk_action_group_new ("StatusBarProfilesPopUpMenuActionGroup");
3577
3578         gtk_action_group_add_actions (statusbar_profiles_action_group,            /* the action group */
3579             statusbar_profiles_menu_action_entries,                        /* an array of action descriptions */
3580             G_N_ELEMENTS(statusbar_profiles_menu_action_entries),        /* the number of entries */
3581             popup_menu_object);                                                    /* data to pass to the action callbacks */
3582
3583         ui_manager_statusbar_profiles_menu = gtk_ui_manager_new ();
3584         gtk_ui_manager_insert_action_group (ui_manager_statusbar_profiles_menu,
3585             statusbar_profiles_action_group,
3586             0); /* the position at which the group will be inserted.  */
3587
3588         gtk_ui_manager_add_ui_from_string (ui_manager_statusbar_profiles_menu,ui_statusbar_profiles_menu_popup, -1, &error);
3589         if (error != NULL)
3590         {
3591             fprintf (stderr, "Warning: building Statusbar Profiles Pop-Up failed: %s\n",
3592                     error->message);
3593             g_error_free (error);
3594             error = NULL;
3595         }
3596
3597         g_object_set_data(G_OBJECT(popup_menu_object), PM_STATUSBAR_PROFILES_KEY,
3598                        gtk_ui_manager_get_widget(ui_manager_statusbar_profiles_menu, "/ProfilesMenuPopup"));
3599
3600         popup_menu_list = g_slist_append((GSList *)popup_menu_list, ui_manager_statusbar_profiles_menu);
3601
3602         menu_dissector_filter();
3603         merge_all_tap_menus(tap_menu_tree_root);
3604
3605         /* Initialize enabled/disabled state of menu items */
3606         set_menus_for_capture_file(NULL);
3607 #if 0
3608         /* Un-#if this when we actually implement Cut/Copy/Paste.
3609            Then make sure you enable them when they can be done. */
3610         set_menu_sensitivity_old("/Edit/Cut", FALSE);
3611         set_menu_sensitivity_old("/Edit/Copy", FALSE);
3612         set_menu_sensitivity_old("/Edit/Paste", FALSE);
3613 #endif
3614
3615         set_menus_for_captured_packets(FALSE);
3616         set_menus_for_selected_packet(&cfile);
3617         set_menus_for_selected_tree_row(&cfile);
3618         set_menus_for_capture_in_progress(FALSE);
3619         set_menus_for_file_set(/* dialog */TRUE, /* previous file */ FALSE, /* next_file */ FALSE);
3620
3621         /* Init with an empty recent files list */
3622         clear_menu_recent_capture_file_cmd_cb(NULL, NULL);
3623
3624         /* Protocol help links */
3625         proto_help_menu_init(gtk_ui_manager_get_widget(ui_manager_tree_view_menu, "/TreeViewPopup"));
3626     }
3627 }
3628
3629
3630 static gint tap_menu_item_add_compare(gconstpointer a, gconstpointer b)
3631 {
3632     return strcmp(
3633         ((const menu_item_t *) a)->name,
3634         ((const menu_item_t *) b)->name);
3635 }
3636
3637
3638 /* add a menuitem below the current node */
3639 static GList * tap_menu_item_add(
3640     char *name,
3641     gint group,
3642     const char *stock_id,
3643     GtkItemFactoryCallback callback,
3644     gboolean (*selected_packet_enabled)(frame_data *, epan_dissect_t *, gpointer callback_data),
3645     gboolean (*selected_tree_row_enabled)(field_info *, gpointer callback_data),
3646     gpointer callback_data,
3647     GList *curnode)
3648 {
3649     menu_item_t *curr;
3650     menu_item_t *child;
3651
3652
3653     child = g_malloc(sizeof (menu_item_t));
3654     child->name             = name;
3655     child->group            = group;
3656     child->stock_id         = stock_id;
3657     child->callback         = callback;
3658     child->selected_packet_enabled = selected_packet_enabled;
3659     child->selected_tree_row_enabled = selected_tree_row_enabled;
3660     child->callback_data    = callback_data;
3661     child->enabled          = FALSE;
3662     child->children         = NULL;
3663
3664     /* insert the new child node into the parent */
3665     curr = curnode->data;
3666     curr->children = g_list_insert_sorted(curr->children, child, tap_menu_item_add_compare);
3667
3668     /* return the new node */
3669     /* XXX: improve this */
3670     return g_list_find(curr->children, child);
3671 }
3672
3673 /*
3674  * Add a new menu item for a tap.
3675  * This must be called after we've created the main menu, so it can't
3676  * be called from the routine that registers taps - we have to introduce
3677  * another per-tap registration routine.
3678  *
3679  * "callback" gets called when the menu item is selected; it should do
3680  * the work of creating the tap window.
3681  *
3682  * "selected_packet_enabled" gets called by "set_menus_for_selected_packet()";
3683  * it's passed a Boolean that's TRUE if a packet is selected and FALSE
3684  * otherwise, and should return TRUE if the tap will work now (which
3685  * might depend on whether a packet is selected and, if one is, on the
3686  * packet) and FALSE if not.
3687  *
3688  * "selected_tree_row_enabled" gets called by
3689  * "set_menus_for_selected_tree_row()"; it's passed a Boolean that's TRUE if
3690  * a protocol tree row is selected and FALSE otherwise, and should return
3691  * TRUE if the tap will work now (which might depend on whether a tree row
3692  * is selected and, if one is, on the tree row) and FALSE if not.
3693  */
3694 void
3695 register_stat_menu_item_stock(
3696     const char *name,
3697     register_stat_group_t group,
3698     const char *stock_id,
3699     GtkItemFactoryCallback callback,
3700     gboolean (*selected_packet_enabled)(frame_data *, epan_dissect_t *, gpointer callback_data),
3701     gboolean (*selected_tree_row_enabled)(field_info *, gpointer callback_data),
3702     gpointer callback_data)
3703 {
3704     /*static const char toolspath[] = "/Statistics/";*/
3705     const char *toolspath;
3706     const char *p;
3707     char *menupath;
3708     size_t menupathlen;
3709     menu_item_t *child;
3710     GList *curnode;
3711     GList *childnode;
3712
3713     /*
3714      * The menu path must be relative.
3715      */
3716     g_assert(*name != '/');
3717
3718     switch(group) {
3719     case(REGISTER_STAT_GROUP_GENERIC): toolspath = "/Statistics/"; break;
3720     case(REGISTER_STAT_GROUP_CONVERSATION_LIST): toolspath = "/Statistics/_Conversation List/"; break;
3721     case(REGISTER_STAT_GROUP_ENDPOINT_LIST): toolspath = "/Statistics/_Endpoint List/"; break;
3722     case(REGISTER_STAT_GROUP_RESPONSE_TIME): toolspath = "/Statistics/Service _Response Time/"; break;
3723     case(REGISTER_STAT_GROUP_UNSORTED): toolspath = "/Statistics/"; break;
3724     case(REGISTER_ANALYZE_GROUP_UNSORTED): toolspath = "/Analyze/"; break;
3725     case(REGISTER_ANALYZE_GROUP_CONVERSATION_FILTER): toolspath = "/Analyze/Conversation Filter/"; break;
3726     case(REGISTER_STAT_GROUP_TELEPHONY): toolspath = "/Telephony/"; break;
3727     case(REGISTER_TOOLS_GROUP_UNSORTED): toolspath = "/Tools/"; break;
3728     default:
3729         g_assert(!"no such menu group");
3730         toolspath = NULL;
3731     }
3732
3733     /* add the (empty) root node, if not already done */
3734     if(tap_menu_tree_root == NULL) {
3735         child = g_malloc0(sizeof (menu_item_t));
3736         tap_menu_tree_root = g_list_append(NULL, child);
3737     }
3738
3739     /*
3740      * Create any submenus required.
3741      */
3742     curnode = tap_menu_tree_root;
3743     p = name;
3744     while ((p = strchr(p, '/')) != NULL) {
3745         /*
3746          * OK, everything between "name" and "p" is
3747          * a menu relative subtree into which the menu item
3748          * will be placed.
3749          *
3750          * Construct the absolute path name of that subtree.
3751          */
3752         menupathlen = strlen(toolspath) + 1 + (p - name);
3753         menupath = g_malloc(menupathlen);
3754         g_strlcpy(menupath, toolspath, menupathlen);
3755         g_strlcat(menupath, name, menupathlen);
3756
3757         /*
3758          * Does there exist an entry with that path at this
3759          * level of the Analyze menu tree?
3760          */
3761         child = curnode->data;
3762         for (childnode = child->children; childnode != NULL; childnode = childnode->next) {
3763             child = childnode->data;
3764             if (strcmp(child->name, menupath) == 0)
3765                 break;
3766         }
3767         if (childnode == NULL) {
3768             /*
3769              * No.  Create such an item as a subtree, and
3770              * add it to the Tools menu tree.
3771              */
3772             childnode = tap_menu_item_add(
3773                 menupath, group, "", NULL, NULL ,NULL, NULL, curnode);
3774         } else {
3775             /*
3776              * Yes.  We don't need this "menupath" any longer.
3777              */
3778             g_free(menupath);
3779         }
3780         curnode = childnode;
3781
3782         /*
3783          * Skip over the '/' we found.
3784          */
3785         p++;
3786     }
3787
3788     /*
3789      * Construct the main menu path for the menu item.
3790      */
3791     menupathlen = strlen(toolspath) + 1 + strlen(name);
3792     menupath = g_malloc(menupathlen);
3793     g_strlcpy(menupath, toolspath, menupathlen);
3794     g_strlcat(menupath, name, menupathlen);
3795
3796     /*
3797      * Construct an item factory entry for the item, and add it to
3798      * the main menu.
3799      */
3800     tap_menu_item_add(
3801         menupath, group, stock_id, callback,
3802         selected_packet_enabled, selected_tree_row_enabled,
3803         callback_data, curnode);
3804 }
3805
3806 /*
3807  * Add a new menu item for a stat.
3808  * This must be called after we've created the main menu, so it can't
3809  * be called from the routine that registers stats - we have to introduce
3810  * another per-stat registration routine.
3811  *
3812  * @param name the menu label
3813  *
3814  * @param group the menu group this stat should be registered to
3815  *
3816  * @param callback gets called when the menu item is selected; it should do
3817  * the work of creating the stat window.
3818  *
3819  * @param selected_packet_enabled gets called by set_menus_for_selected_packet();
3820  * it's passed a pointer to the "frame_data" structure for the current frame,
3821  * if any, and to the "epan_dissect_t" structure for that frame, if any, and
3822  * should return TRUE if the stat will work now (which might depend on whether
3823  * a frame is selected and, if one is, on the frame) and FALSE if not.
3824  *
3825  * @param selected_tree_row_enabled gets called by
3826  * set_menus_for_selected_tree_row(); it's passed a pointer to the
3827  * "field_info" structure for the currently selected field, if any,
3828  * and should return TRUE if the stat will work now (which might depend on
3829  * whether a tree row is selected and, if one is, on the tree row) and
3830  * FALSE if not.
3831  *
3832  * @param callback_data data for callback function
3833  */
3834 void
3835 register_stat_menu_item(
3836     const char *name,
3837     register_stat_group_t group,
3838     GtkItemFactoryCallback callback,
3839     gboolean (*selected_packet_enabled)(frame_data *, epan_dissect_t *, gpointer callback_data),
3840     gboolean (*selected_tree_row_enabled)(field_info *, gpointer callback_data),
3841     gpointer callback_data)
3842 {
3843     register_stat_menu_item_stock(
3844         name,
3845         group,
3846         NULL,
3847         callback,
3848         selected_packet_enabled,
3849         selected_tree_row_enabled,
3850         callback_data);
3851 }
3852
3853 static guint merge_tap_menus_layered(GList *node, gint group) {
3854 #ifdef MAIN_MENU_USE_UIMANAGER
3855         gchar *p;
3856         GtkAction *action;
3857 #else
3858 #endif /* MAIN_MENU_USE_UIMANAGER */
3859     GtkItemFactoryEntry *entry;
3860
3861     GList       *child;
3862     guint       added = 0;
3863     menu_item_t *node_data = node->data;
3864
3865     /*
3866      * Is this a leaf node or an interior node?
3867      */
3868     if (node_data->children == NULL) {
3869         /*
3870          * It's a leaf node.
3871          */
3872
3873         /*
3874          * The root node doesn't correspond to a menu tree item; it
3875          * has a null name pointer.
3876          */
3877         if (node_data->name != NULL && group == node_data->group) {
3878             entry = g_malloc0(sizeof (GtkItemFactoryEntry));
3879             entry->path = node_data->name;
3880             entry->callback = node_data->callback;
3881             switch(group) {
3882             case(REGISTER_STAT_GROUP_UNSORTED):
3883                 break;
3884             case(REGISTER_STAT_GROUP_GENERIC):
3885                 break;
3886             case(REGISTER_STAT_GROUP_CONVERSATION_LIST):
3887                 entry->item_type = "<StockItem>";
3888                 entry->extra_data = WIRESHARK_STOCK_CONVERSATIONS;
3889                 break;
3890             case(REGISTER_STAT_GROUP_ENDPOINT_LIST):
3891                 entry->item_type = "<StockItem>";
3892                 entry->extra_data = WIRESHARK_STOCK_ENDPOINTS;
3893                 break;
3894             case(REGISTER_STAT_GROUP_RESPONSE_TIME):
3895                 entry->item_type = "<StockItem>";
3896                 entry->extra_data = WIRESHARK_STOCK_TIME;
3897                 break;
3898             case(REGISTER_STAT_GROUP_TELEPHONY):
3899                 break;
3900             case(REGISTER_ANALYZE_GROUP_UNSORTED):
3901                 break;
3902             case(REGISTER_ANALYZE_GROUP_CONVERSATION_FILTER):
3903                 break;
3904             case(REGISTER_TOOLS_GROUP_UNSORTED):
3905                 break;
3906             default:
3907                 g_assert_not_reached();
3908             }
3909             if(node_data->stock_id!= NULL) {
3910                 entry->item_type = "<StockItem>";
3911                 entry->extra_data = node_data->stock_id;
3912             }
3913 #ifdef MAIN_MENU_USE_UIMANAGER
3914 #if 0
3915                         g_warning("entry->path = %s",entry->path);
3916                         action = gtk_action_new(entry->path,    /* name */
3917                            const gchar *label,          /* label */
3918                            NULL,                                        /* tooltip */
3919                            node_data->stock_id);        /* stock_id */
3920                         gtk_action_group_add_action_with_accel(main_menu_bar_action_group,
3921                                                    action,
3922                                                    NULL); /*the accelerator for the action, 
3923                                                                                                                                                            * in the format understood by gtk_accelerator_parse(), 
3924                                                                                                                                                            * or "" for no accelerator, or NULL to use the stock accelerator.
3925                                                                                                                                                            * [allow-none]
3926                                                                                                                                                            */
3927                         g_signal_connect (action, "activate",
3928                                   G_CALLBACK (node_data->callback),
3929                                   node_data->callback_data);
3930 #endif /* 0 */
3931 #else
3932             gtk_item_factory_create_item(main_menu_factory, entry, node_data->callback_data, /* callback_type */ 2);
3933             set_menu_sensitivity_old(node_data->name, FALSE); /* no capture file yet */
3934 #endif /* MAIN_MENU_USE_UIMANAGER */
3935             added++;
3936             g_free(entry);
3937         }
3938     } else {
3939         /*
3940          * It's an interior node; call
3941          * "merge_tap_menus_layered()" on all its children
3942          */
3943
3944         /*
3945          * The root node doesn't correspond to a menu tree item; it
3946          * has a null name pointer.
3947          */
3948         if (node_data->name != NULL && group == node_data->group) {
3949             entry = g_malloc0(sizeof (GtkItemFactoryEntry));
3950             entry->path = node_data->name;
3951             entry->item_type = "<Branch>";
3952 #ifdef MAIN_MENU_USE_UIMANAGER
3953             p = strrchr(node_data->name,'/');
3954             if(p){
3955                 p++;
3956                 action = gtk_action_new(entry->path,    /* name */
3957                                p,                        /* label */
3958                                NULL,                    /* tooltip */
3959                                node_data->stock_id);    /* stock_id */
3960                 gtk_action_group_add_action_with_accel(main_menu_bar_action_group,
3961                                                        action,
3962                                                        NULL); /*the accelerator for the action, 
3963                                                                * in the format understood by gtk_accelerator_parse(), 
3964                                                                * or "" for no accelerator, or NULL to use the stock accelerator.
3965                                                                * [allow-none]
3966                                                                */
3967                 if(group==REGISTER_STAT_GROUP_RESPONSE_TIME){
3968                     gtk_ui_manager_add_ui (ui_manager_main_menubar, merge_id,
3969                            "/Menubar/StatisticsMenu",            /* path */
3970                            p,                                    /* name */
3971                            entry->path,                            /* action */
3972                            GTK_UI_MANAGER_MENU,                    /* type */
3973                            FALSE);                                /* "top" if TRUE, the UI element is added before its siblings */
3974                 }
3975             }
3976 #else
3977             gtk_item_factory_create_item(main_menu_factory, entry,
3978                 NULL, 2);
3979             set_menu_sensitivity_old(node_data->name,
3980                 FALSE);    /* no children yet */
3981 #endif /* MAIN_MENU_USE_UIMANAGER */
3982             added++;
3983             g_free(entry);
3984         }
3985
3986         for (child = node_data->children; child != NULL; child =
3987             child->next) {
3988             added += merge_tap_menus_layered(child, group);
3989         }
3990     }
3991
3992     return added;
3993 }
3994
3995
3996 void merge_all_tap_menus(GList *node) {
3997     GtkItemFactoryEntry *sep_entry;
3998
3999     sep_entry = g_malloc0(sizeof (GtkItemFactoryEntry));
4000     sep_entry->item_type = "<Separator>";
4001     sep_entry->path = "/Statistics/";
4002 #ifdef MAIN_MENU_USE_UIMANAGER
4003     /* build the new menus */
4004     merge_id = gtk_ui_manager_new_merge_id (ui_manager_main_menubar);
4005
4006 #endif
4007     /*
4008      * merge only the menu items of the specific group,
4009      * and then append a seperator
4010      */
4011     if (merge_tap_menus_layered(node, REGISTER_STAT_GROUP_GENERIC)) {
4012 #ifdef MAIN_MENU_USE_UIMANAGER
4013         /* XXX fix me */
4014 #else
4015         gtk_item_factory_create_item(main_menu_factory, sep_entry, NULL, 2);
4016 #endif /* MAIN_MENU_USE_UIMANAGER */
4017     }
4018     if (merge_tap_menus_layered(node, REGISTER_STAT_GROUP_CONVERSATION_LIST)) {
4019         /*gtk_item_factory_create_item(main_menu_factory, sep_entry, NULL, 2);*/
4020     }
4021     if (merge_tap_menus_layered(node, REGISTER_STAT_GROUP_ENDPOINT_LIST)) {
4022         /*gtk_item_factory_create_item(main_menu_factory, sep_entry, NULL, 2);*/
4023     }
4024     if (merge_tap_menus_layered(node, REGISTER_STAT_GROUP_RESPONSE_TIME)) {
4025 #ifdef MAIN_MENU_USE_UIMANAGER
4026         /* XXX fix me */
4027 #else
4028         gtk_item_factory_create_item(main_menu_factory, sep_entry, NULL, 2);
4029 #endif /* MAIN_MENU_USE_UIMANAGER */
4030     }
4031     if (merge_tap_menus_layered(node, REGISTER_STAT_GROUP_TELEPHONY)) {
4032         /*gtk_item_factory_create_item(main_menu_factory, sep_entry, NULL, 2);*/
4033     }
4034     if (merge_tap_menus_layered(node, REGISTER_STAT_GROUP_UNSORTED)) {
4035         /*gtk_item_factory_create_item(main_menu_factory, sep_entry, NULL, 2);*/
4036     }
4037     if (merge_tap_menus_layered(node, REGISTER_ANALYZE_GROUP_UNSORTED)) {
4038         sep_entry->path = "/Analyze/";
4039         /*gtk_item_factory_create_item(main_menu_factory, sep_entry, NULL, 2);*/
4040     }
4041     if (merge_tap_menus_layered(node, REGISTER_ANALYZE_GROUP_CONVERSATION_FILTER)) {
4042         sep_entry->path = "/Analyze/Conversation Filter/";
4043         /*gtk_item_factory_create_item(main_menu_factory, sep_entry, NULL, 2);*/
4044     }
4045     if (merge_tap_menus_layered(node, REGISTER_TOOLS_GROUP_UNSORTED)) {
4046         /*gtk_item_factory_create_item(main_menu_factory, sep_entry, NULL, 2);*/
4047     }
4048
4049     g_free (sep_entry);
4050 }
4051
4052 /*
4053  * Enable/disable menu sensitivity.
4054  */
4055 static void
4056 set_menu_sensitivity(GtkUIManager *ui_manager, const gchar *path, gint val)
4057 {
4058     GtkAction *action;
4059
4060     action = gtk_ui_manager_get_action(ui_manager, path);
4061     if(!action){
4062         fprintf (stderr, "Warning: couldn't find action path= %s\n",
4063                 path);
4064         return;
4065     }
4066 #if GLIB_CHECK_VERSION(2,6,0)
4067     gtk_action_set_sensitive (action,
4068         val); /* TRUE to make the action sensitive */
4069 #else
4070     g_object_set (G_OBJECT (action), "sensitive", val, NULL);
4071 #endif
4072 }
4073
4074 #ifndef MAIN_MENU_USE_UIMANAGER
4075 /*
4076  * Enable/disable menu sensitivity for the old menubar code.
4077  */
4078 static void
4079 set_menu_sensitivity_old(const gchar *path, gint val)
4080 {
4081     GtkWidget *menu_item;
4082     gchar *dup;
4083     gchar *dest;
4084     /* the underscore character regularly confuses things, as it will prevent finding
4085      * the menu_item, so it has to be removed first */
4086     dup = g_strdup(path);
4087     dest = dup;
4088     while(*path) {
4089         if (*path != '_') {
4090             *dest = *path;
4091             dest++;
4092         }
4093         path++;
4094     }
4095     *dest = '\0';
4096
4097     if ((menu_item = gtk_item_factory_get_widget(main_menu_factory, dup)) != NULL) {
4098         if (GTK_IS_MENU(menu_item)) {
4099             /*
4100              * "dup" refers to a submenu; "gtk_item_factory_get_widget()"
4101              * gets the menu, not the item that, when selected, pops up
4102              * the submenu.
4103              *
4104              * We have to change the latter item's sensitivity, so that
4105              * it shows up normally if sensitive and grayed-out if
4106              * insensitive.
4107              */
4108             menu_item = gtk_menu_get_attach_widget(GTK_MENU(menu_item));
4109         }
4110         gtk_widget_set_sensitive(menu_item, val);
4111     } else{
4112 #ifndef NEW_PACKET_LIST
4113         /* be sure this menu item *is* existing */
4114         g_assert_not_reached();
4115 #endif
4116     }
4117
4118     g_free(dup);
4119 }
4120
4121 #endif /* MAIN_MENU_USE_UIMANAGER */
4122
4123 static void
4124 set_menu_object_data_meat(GtkUIManager *ui_manager, const gchar *path, const gchar *key, gpointer data)
4125 {
4126     GtkWidget *menu = NULL;
4127
4128     if ((menu =  gtk_ui_manager_get_widget(ui_manager, path)) != NULL)
4129         g_object_set_data(G_OBJECT(menu), key, data);
4130 }
4131
4132 #ifndef MAIN_MENU_USE_UIMANAGER
4133 static void
4134 set_menu_object_data_meat_old(GtkItemFactory *ifactory, const gchar *path, const gchar *key, gpointer data)
4135 {
4136     GtkWidget *menu = NULL;
4137
4138     if ((menu = gtk_item_factory_get_widget(ifactory, path)) != NULL)
4139         g_object_set_data(G_OBJECT(menu), key, data);
4140 }
4141 #endif
4142
4143 void
4144 set_menu_object_data (const gchar *path, const gchar *key, gpointer data) {
4145     GSList *menu_list = popup_menu_list;
4146     gchar *shortpath = strrchr(path, '/');
4147
4148 #ifdef MAIN_MENU_USE_UIMANAGER
4149    set_menu_object_data_meat(ui_manager_main_menubar, path, key, data);
4150 #else
4151     set_menu_object_data_meat_old(main_menu_factory, path, key, data);
4152 #endif /* MAIN_MENU_USE_UIMANAGER */
4153     while (menu_list != NULL) {
4154         set_menu_object_data_meat(menu_list->data, shortpath, key, data);
4155         set_menu_object_data_meat(menu_list->data, path, key, data);
4156         menu_list = g_slist_next(menu_list);
4157     }
4158 }
4159
4160
4161 /* Recently used capture files submenu:
4162  * Submenu containing the recently used capture files.
4163  * The capture filenames are always kept with the absolute path, to be independant
4164  * of the current path.
4165  * They are only stored inside the labels of the submenu (no separate list). */
4166
4167 #define MENU_RECENT_FILES_PATH_OLD "/File/Open Recent"
4168 #define MENU_RECENT_FILES_PATH "/Menubar/FileMenu/OpenRecent"
4169 #define MENU_RECENT_FILES_KEY "Recent File Name"
4170
4171
4172
4173 static void
4174 update_menu_recent_capture_file1(GtkWidget *widget, gpointer cnt) {
4175     gchar *widget_cf_name;
4176
4177     widget_cf_name = g_object_get_data(G_OBJECT(widget), MENU_RECENT_FILES_KEY);
4178
4179     /* if this menu item is a file, count it */
4180     if (widget_cf_name) {
4181         (*(guint *)cnt)++;
4182         main_welcome_add_recent_capture_files(widget_cf_name);
4183     }
4184 }
4185
4186
4187
4188 /* update the menu */
4189 static void
4190 update_menu_recent_capture_file(GtkWidget *submenu_recent_files) {
4191     guint cnt = 0;
4192
4193
4194     main_welcome_reset_recent_capture_files();
4195
4196     gtk_container_foreach(GTK_CONTAINER(submenu_recent_files),
4197                           update_menu_recent_capture_file1, &cnt);
4198
4199     /* make parent menu item sensitive only, if we have any valid files in the list */
4200 #ifdef MAIN_MENU_USE_UIMANAGER
4201     set_menu_sensitivity(ui_manager_main_menubar, MENU_RECENT_FILES_PATH, cnt);
4202 #else
4203     set_menu_sensitivity_old(MENU_RECENT_FILES_PATH_OLD, cnt);
4204 #endif
4205 }
4206
4207
4208
4209 /* remove the capture filename from the "Recent Files" menu */
4210 static void
4211 remove_menu_recent_capture_filename(gchar *cf_name) {
4212     GtkWidget *submenu_recent_files;
4213     GList* child_list;
4214     GList* child_list_item;
4215     GtkWidget    *menu_item_child;
4216     const gchar *menu_item_cf_name;
4217
4218     /* get the submenu container item */
4219 #ifdef MAIN_MENU_USE_UIMANAGER
4220     submenu_recent_files = gtk_ui_manager_get_widget(ui_manager_main_menubar, MENU_RECENT_FILES_PATH);
4221     if(!submenu_recent_files){
4222         g_warning("remove_menu_recent_capture_filename: No submenu_recent_files found, path= MENU_RECENT_FILES_PATH");
4223     }
4224 #else
4225     submenu_recent_files = gtk_item_factory_get_widget(main_menu_factory, MENU_RECENT_FILES_PATH_OLD);
4226 #endif
4227     /* find the corresponding menu item to be removed */
4228     child_list = gtk_container_get_children(GTK_CONTAINER(submenu_recent_files));
4229     child_list_item = child_list;
4230     while(child_list_item) {
4231         menu_item_child = (GTK_BIN(child_list_item->data))->child;
4232         if (menu_item_child != NULL) { /* Note: there are two "extra" items on the end of the child_list: */
4233                                        /*  - a separator (with no menu_item_child and thus no text label) */
4234                                        /*  - a 2nd item with a menu_child with text label "Clear"         */
4235                                        /*       [See add_menu_recent_capture_file_absolute() ]            */
4236                                        /* 'if (menu_item_child != NULL)' skips the separator item;        */
4237                                        /* An absolute filename in cf_name will never match  "Clear".      */
4238             menu_item_cf_name = gtk_label_get_text(GTK_LABEL(menu_item_child));
4239             if(strcmp(menu_item_cf_name, cf_name) == 0) {
4240                 /* XXX: is this all we need to do, to free the menu item and its label?
4241                    The reference count of widget will go to 0, so it'll be freed;
4242                    will that free the label? */
4243                 gtk_container_remove(GTK_CONTAINER(submenu_recent_files), child_list_item->data);
4244             }
4245         }
4246         child_list_item = g_list_next(child_list_item);
4247     }
4248     g_list_free(child_list);
4249
4250     update_menu_recent_capture_file(submenu_recent_files);
4251 }
4252
4253
4254 /* remove the capture filename from the "Recent Files" menu */
4255 static void
4256 remove_menu_recent_capture_file(GtkWidget *widget, gpointer unused _U_) {
4257     GtkWidget *submenu_recent_files;
4258     gchar *widget_cf_name;
4259
4260
4261     widget_cf_name = g_object_get_data(G_OBJECT(widget), MENU_RECENT_FILES_KEY);
4262     g_free(widget_cf_name);
4263
4264     /* get the submenu container item */
4265 #ifdef MAIN_MENU_USE_UIMANAGER
4266     submenu_recent_files = gtk_ui_manager_get_widget(ui_manager_main_menubar, MENU_RECENT_FILES_PATH);
4267     if(!submenu_recent_files){
4268         g_warning("remove_menu_recent_capture_file: No submenu_recent_files found, path= MENU_RECENT_FILES_PATH");
4269     }
4270 #else
4271     submenu_recent_files = gtk_item_factory_get_widget(main_menu_factory, MENU_RECENT_FILES_PATH_OLD);
4272 #endif
4273     /* XXX: is this all we need to do, to free the menu item and its label?
4274        The reference count of widget will go to 0, so it'll be freed;
4275        will that free the label? */
4276     gtk_container_remove(GTK_CONTAINER(submenu_recent_files), widget);
4277 }
4278
4279
4280 /* callback, if the user pushed the <Clear> menu item */
4281 static void
4282 clear_menu_recent_capture_file_cmd_cb(GtkWidget *w _U_, gpointer unused _U_) {
4283     GtkWidget *submenu_recent_files;
4284
4285 #ifdef MAIN_MENU_USE_UIMANAGER
4286     submenu_recent_files = gtk_ui_manager_get_widget(ui_manager_main_menubar, MENU_RECENT_FILES_PATH);
4287     if(!submenu_recent_files){
4288         g_warning("clear_menu_recent_capture_file_cmd_cb: No submenu_recent_files found, path= MENU_RECENT_FILES_PATH");
4289     }
4290 #else
4291     submenu_recent_files = gtk_item_factory_get_widget(main_menu_factory, MENU_RECENT_FILES_PATH_OLD);
4292 #endif
4293
4294     gtk_container_foreach(GTK_CONTAINER(submenu_recent_files),
4295                           remove_menu_recent_capture_file, NULL);
4296
4297     update_menu_recent_capture_file(submenu_recent_files);
4298 }
4299
4300
4301 /* Open a file by it's name
4302    (Beware: will not ask to close existing capture file!) */
4303 void
4304 menu_open_filename(gchar *cf_name)
4305 {
4306     GtkWidget *submenu_recent_files;
4307     int       err;
4308
4309 #ifdef MAIN_MENU_USE_UIMANAGER
4310     submenu_recent_files = gtk_ui_manager_get_widget(ui_manager_main_menubar, MENU_RECENT_FILES_PATH);
4311     if(!submenu_recent_files){
4312         g_warning("menu_open_filename: No submenu_recent_files found, path= MENU_RECENT_FILES_PATH");
4313     }
4314 #else
4315     submenu_recent_files = gtk_item_factory_get_widget(main_menu_factory, MENU_RECENT_FILES_PATH_OLD);
4316 #endif
4317     /* open and read the capture file (this will close an existing file) */
4318     if (cf_open(&cfile, cf_name, FALSE, &err) == CF_OK) {
4319         cf_read(&cfile, FALSE);
4320     } else {
4321         /* the capture file apparently no longer exists; remove menu item    */
4322         /* XXX: ask user to remove item, it's maybe only a temporary problem */
4323         remove_menu_recent_capture_filename(cf_name);
4324     }
4325
4326     update_menu_recent_capture_file(submenu_recent_files);
4327 }
4328
4329
4330 /* callback, if the user pushed a recent file submenu item */
4331 void
4332 menu_open_recent_file_cmd(GtkWidget *w)
4333 {
4334     GtkWidget   *submenu_recent_files;
4335     GtkWidget   *menu_item_child;
4336     const gchar *cf_name;
4337     int         err;
4338
4339 #ifdef MAIN_MENU_USE_UIMANAGER
4340     submenu_recent_files = gtk_ui_manager_get_widget(ui_manager_main_menubar, MENU_RECENT_FILES_PATH);
4341     if(!submenu_recent_files){
4342         g_warning("menu_open_recent_file_cmd: No submenu_recent_files found, path= MENU_RECENT_FILES_PATH");
4343     }
4344 #else
4345     submenu_recent_files = gtk_item_factory_get_widget(main_menu_factory, MENU_RECENT_FILES_PATH_OLD);
4346 #endif
4347     /* get capture filename from the menu item label */
4348     menu_item_child = (GTK_BIN(w))->child;
4349     cf_name = gtk_label_get_text(GTK_LABEL(menu_item_child));
4350
4351     /* open and read the capture file (this will close an existing file) */
4352     if (cf_open(&cfile, cf_name, FALSE, &err) == CF_OK) {
4353         cf_read(&cfile, FALSE);
4354     } else {
4355         /* the capture file apparently no longer exists; remove menu item    */
4356         /* XXX: ask user to remove item, it's maybe only a temporary problem */
4357         remove_menu_recent_capture_file(w, NULL);
4358     }
4359
4360     update_menu_recent_capture_file(submenu_recent_files);
4361 }
4362
4363 static void menu_open_recent_file_answered_cb(gpointer dialog _U_, gint btn, gpointer data)
4364 {
4365     switch(btn) {
4366     case(ESD_BTN_YES):
4367         /* save file first */
4368         file_save_as_cmd(after_save_open_recent_file, data);
4369         break;
4370     case(ESD_BTN_NO):
4371         cf_close(&cfile);
4372         menu_open_recent_file_cmd(data);
4373         break;
4374     case(ESD_BTN_CANCEL):
4375         break;
4376     default:
4377         g_assert_not_reached();
4378     }
4379 }
4380
4381 static void
4382 menu_open_recent_file_cmd_cb(GtkWidget *widget, gpointer data _U_) {
4383     gpointer  dialog;
4384
4385
4386     if((cfile.state != FILE_CLOSED) && !cfile.user_saved && prefs.gui_ask_unsaved) {
4387         /* user didn't saved his current file, ask him */
4388         dialog = simple_dialog(ESD_TYPE_CONFIRMATION, ESD_BTNS_YES_NO_CANCEL,
4389                                "%sSave capture file before opening a new one?%s\n\n"
4390                                "If you open a new capture file without saving, your current capture data will be discarded.",
4391                                simple_dialog_primary_start(), simple_dialog_primary_end());
4392         simple_dialog_set_cb(dialog, menu_open_recent_file_answered_cb, widget);
4393     } else {
4394         /* unchanged file */
4395         menu_open_recent_file_cmd(widget);
4396     }
4397 }
4398
4399 /* add the capture filename (with an absolute path) to the "Recent Files" menu */
4400 static void
4401 add_menu_recent_capture_file_absolute(gchar *cf_name) {
4402     GtkWidget *submenu_recent_files;
4403     GList *menu_item_list;
4404     GList *li;
4405     gchar *widget_cf_name;
4406     gchar *normalized_cf_name;
4407     GtkWidget *menu_item;
4408     guint cnt;
4409
4410
4411
4412     normalized_cf_name = g_strdup(cf_name);
4413 #ifdef _WIN32
4414     /* replace all slashes by backslashes */
4415     g_strdelimit(normalized_cf_name, "/", '\\');
4416 #endif
4417
4418     /* get the submenu container item */
4419 #ifdef MAIN_MENU_USE_UIMANAGER
4420     submenu_recent_files = gtk_ui_manager_get_widget(ui_manager_main_menubar, MENU_RECENT_FILES_PATH);
4421     if(!submenu_recent_files){
4422         g_warning("add_menu_recent_capture_file_absolute: No submenu_recent_files found, path= MENU_RECENT_FILES_PATH");
4423     }
4424 #else
4425     submenu_recent_files = gtk_item_factory_get_widget(main_menu_factory, MENU_RECENT_FILES_PATH_OLD);
4426 #endif
4427     /* convert container to a GList */
4428     menu_item_list = gtk_container_get_children(GTK_CONTAINER(submenu_recent_files));
4429
4430     /* iterate through list items of menu_item_list,
4431      * removing special items, a maybe duplicate entry and every item above count_max */
4432     cnt = 1;
4433     for (li = g_list_first(menu_item_list); li; li = li->next, cnt++) {
4434         /* get capture filename */
4435         menu_item = GTK_WIDGET(li->data);
4436         widget_cf_name = g_object_get_data(G_OBJECT(menu_item), MENU_RECENT_FILES_KEY);
4437
4438         /* if this element string is one of our special items (seperator, ...) or
4439          * already in the list or
4440          * this element is above maximum count (too old), remove it */
4441         if (!widget_cf_name ||
4442 #ifdef _WIN32
4443             /* do a case insensitive compare on win32 */
4444             g_ascii_strncasecmp(widget_cf_name, normalized_cf_name, 1000) == 0 ||
4445 #else   /* _WIN32 */
4446             /* do a case sensitive compare on unix */
4447             strncmp(widget_cf_name, normalized_cf_name, 1000) == 0 ||
4448 #endif
4449             cnt >= prefs.gui_recent_files_count_max) {
4450             remove_menu_recent_capture_file(li->data, NULL);
4451             cnt--;
4452         }
4453     }
4454
4455     g_list_free(menu_item_list);
4456
4457     /* add new item at latest position */
4458     menu_item = gtk_menu_item_new_with_label(normalized_cf_name);
4459     g_object_set_data(G_OBJECT(menu_item), MENU_RECENT_FILES_KEY, normalized_cf_name);
4460     gtk_menu_shell_prepend (GTK_MENU_SHELL(submenu_recent_files), menu_item);
4461     g_signal_connect_swapped(GTK_OBJECT(menu_item), "activate",
4462                              G_CALLBACK(menu_open_recent_file_cmd_cb), (GtkObject *) menu_item);
4463     gtk_widget_show (menu_item);
4464
4465     /* add seperator at last position */
4466     menu_item = gtk_menu_item_new();
4467     gtk_menu_shell_append (GTK_MENU_SHELL(submenu_recent_files), menu_item);
4468     gtk_widget_show (menu_item);
4469
4470     /* add new "clear list" item at last position */
4471     menu_item = gtk_image_menu_item_new_from_stock(GTK_STOCK_CLEAR, NULL);
4472     gtk_menu_shell_append (GTK_MENU_SHELL(submenu_recent_files), menu_item);
4473     g_signal_connect_swapped(GTK_OBJECT(menu_item), "activate",
4474                              G_CALLBACK(clear_menu_recent_capture_file_cmd_cb), (GtkObject *) menu_item);
4475     gtk_widget_show (menu_item);
4476
4477     update_menu_recent_capture_file(submenu_recent_files);
4478 }
4479
4480
4481 /* add the capture filename to the "Recent Files" menu */
4482 /* (will change nothing, if this filename is already in the menu) */
4483 /*
4484  * XXX - We might want to call SHAddToRecentDocs under Windows 7:
4485  * http://stackoverflow.com/questions/437212/how-do-you-register-a-most-recently-used-list-with-windows-in-preparation-for-win
4486  */
4487 void
4488 add_menu_recent_capture_file(gchar *cf_name) {
4489     gchar *curr;
4490     gchar *absolute;
4491
4492
4493     /* if this filename is an absolute path, we can use it directly */
4494     if (g_path_is_absolute(cf_name)) {
4495         add_menu_recent_capture_file_absolute(cf_name);
4496         return;
4497     }
4498
4499     /* this filename is not an absolute path, prepend the current dir */
4500     curr = g_get_current_dir();
4501     absolute = g_strdup_printf("%s%s%s", curr, G_DIR_SEPARATOR_S, cf_name);
4502     add_menu_recent_capture_file_absolute(absolute);
4503     g_free(curr);
4504     g_free(absolute);
4505 }
4506
4507
4508 /* write all capture filenames of the menu to the user's recent file */
4509 void
4510 menu_recent_file_write_all(FILE *rf) {
4511     GtkWidget   *submenu_recent_files;
4512     GList       *children;
4513     GList       *child;
4514     gchar       *cf_name;
4515
4516 #ifdef MAIN_MENU_USE_UIMANAGER
4517     submenu_recent_files = gtk_ui_manager_get_widget(ui_manager_main_menubar, MENU_RECENT_FILES_PATH);
4518     if(!submenu_recent_files){
4519         g_warning("add_menu_recent_capture_file_absolute: No submenu_recent_files found, path= MENU_RECENT_FILES_PATH");
4520     }
4521 #else
4522     submenu_recent_files = gtk_item_factory_get_widget(main_menu_factory, MENU_RECENT_FILES_PATH_OLD);
4523 #endif
4524     /* we have to iterate backwards through the children's list,
4525      * so we get the latest item last in the file.
4526      * (don't use gtk_container_foreach() here, it will return the wrong iteration order) */
4527     children = gtk_container_get_children(GTK_CONTAINER(submenu_recent_files));
4528     child = g_list_last(children);
4529     while(child != NULL) {
4530         /* get capture filename from the menu item label */
4531         cf_name = g_object_get_data(G_OBJECT(child->data), MENU_RECENT_FILES_KEY);
4532         if (cf_name) {
4533             if(u3_active())
4534                 fprintf (rf, RECENT_KEY_CAPTURE_FILE ": %s\n", u3_contract_device_path(cf_name));
4535             else
4536                 fprintf (rf, RECENT_KEY_CAPTURE_FILE ": %s\n", cf_name);
4537         }
4538
4539         child = g_list_previous(child);
4540     }
4541
4542     g_list_free(children);
4543 }
4544
4545
4546 static void
4547 show_hide_cb(GtkWidget *w, gpointer data _U_, gint action)
4548 {
4549
4550     /* save current setting in recent */
4551     switch(action) {
4552         case(SHOW_HIDE_MAIN_TOOLBAR):
4553         recent.main_toolbar_show = GTK_CHECK_MENU_ITEM(w)->active;
4554         break;
4555         case(SHOW_HIDE_FILTER_TOOLBAR):
4556         recent.filter_toolbar_show = GTK_CHECK_MENU_ITEM(w)->active;
4557         break;
4558 #ifdef HAVE_AIRPCAP
4559         case(SHOW_HIDE_AIRPCAP_TOOLBAR):
4560         recent.airpcap_toolbar_show = GTK_CHECK_MENU_ITEM(w)->active;
4561         break;
4562 #endif
4563         case(SHOW_HIDE_STATUSBAR):
4564         recent.statusbar_show = GTK_CHECK_MENU_ITEM(w)->active;
4565         break;
4566         case(SHOW_HIDE_PACKET_LIST):
4567         recent.packet_list_show = GTK_CHECK_MENU_ITEM(w)->active;
4568         break;
4569         case(SHOW_HIDE_TREE_VIEW):
4570         recent.tree_view_show = GTK_CHECK_MENU_ITEM(w)->active;
4571         break;
4572         case(SHOW_HIDE_BYTE_VIEW):
4573         recent.byte_view_show = GTK_CHECK_MENU_ITEM(w)->active;
4574         break;
4575         default:
4576             g_assert_not_reached();
4577     }
4578
4579     main_widgets_show_or_hide();
4580 }
4581
4582 #ifndef MAIN_MENU_USE_UIMANAGER
4583 static void
4584 timestamp_format_cb(GtkWidget *w _U_, gpointer d _U_, gint action)
4585 {
4586     if (recent.gui_time_format != action) {
4587         timestamp_set_type(action);
4588         recent.gui_time_format = action;
4589 #ifdef NEW_PACKET_LIST
4590         /* This call adjusts column width */
4591         cf_timestamp_auto_precision(&cfile);
4592         new_packet_list_queue_draw();
4593 #else
4594         cf_change_time_formats(&cfile);
4595 #endif
4596     }
4597 }
4598
4599
4600 static void
4601 timestamp_precision_cb(GtkWidget *w _U_, gpointer d _U_, gint action)
4602 {
4603     if (recent.gui_time_precision != action) {
4604         /* the actual precision will be set in cf_change_time_formats() below */
4605         if (action == TS_PREC_AUTO) {
4606             timestamp_set_precision(TS_PREC_AUTO_SEC);
4607         } else {
4608             timestamp_set_precision(action);
4609         }
4610         recent.gui_time_precision  = action;
4611 #ifdef NEW_PACKET_LIST
4612         /* This call adjusts column width */
4613         cf_timestamp_auto_precision(&cfile);
4614         new_packet_list_queue_draw();
4615 #else
4616         cf_change_time_formats(&cfile);
4617 #endif
4618     }
4619 }
4620 #endif
4621
4622 static void
4623 timestamp_seconds_time_cb(GtkWidget *w, gpointer d _U_, gint action _U_)
4624 {
4625     if (GTK_CHECK_MENU_ITEM(w)->active) {
4626         recent.gui_seconds_format = TS_SECONDS_HOUR_MIN_SEC;
4627     } else {
4628         recent.gui_seconds_format = TS_SECONDS_DEFAULT;
4629     }
4630     timestamp_set_seconds_type (recent.gui_seconds_format);
4631
4632 #ifdef NEW_PACKET_LIST
4633     /* This call adjusts column width */
4634     cf_timestamp_auto_precision(&cfile);
4635     new_packet_list_queue_draw();
4636 #else
4637     cf_change_time_formats(&cfile);
4638 #endif
4639 }
4640
4641 void
4642 menu_name_resolution_changed(void)
4643 {
4644     GtkWidget *menu = NULL;
4645 #ifdef MAIN_MENU_USE_UIMANAGER
4646     menu = gtk_ui_manager_get_widget(ui_manager_main_menubar, "/Menubar/ViewMenu/NameResolution/EnableforMACLayer");
4647     if(!menu){
4648         g_warning("menu_name_resolution_changed: No menu found, path= /Menubar/ViewMenu/NameResolution/EnableforMACLayer");
4649     }
4650     gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), g_resolv_flags & RESOLV_MAC);
4651
4652     menu = gtk_ui_manager_get_widget(ui_manager_main_menubar, "/Menubar/ViewMenu/NameResolution/EnableforNetworkLayer");
4653     if(!menu){
4654         g_warning("menu_name_resolution_changed: No menu found, path= /Menubar/ViewMenu/NameResolution/EnableforNetworkLayer");
4655     }
4656     gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), g_resolv_flags & RESOLV_NETWORK);
4657
4658     menu = gtk_ui_manager_get_widget(ui_manager_main_menubar, "/Menubar/ViewMenu/NameResolution/EnableforTransportLayer");
4659     if(!menu){
4660         g_warning("menu_name_resolution_changed: No menu found, path= /Menubar/ViewMenu/NameResolution/EnableforTransportLayer");
4661     }
4662     gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), g_resolv_flags & RESOLV_TRANSPORT);
4663
4664 #else
4665     menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Name Resolution/Enable for MAC Layer");
4666     gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), g_resolv_flags & RESOLV_MAC);
4667
4668     menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Name Resolution/Enable for Network Layer");
4669     gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), g_resolv_flags & RESOLV_NETWORK);
4670
4671     menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Name Resolution/Enable for Transport Layer");
4672     gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), g_resolv_flags & RESOLV_TRANSPORT);
4673 #endif /* MAIN_MENU_USE_UIMANAGER */
4674 }
4675
4676 static void
4677 name_resolution_cb(GtkWidget *w, gpointer d _U_, gint action)
4678 {
4679     if (GTK_CHECK_MENU_ITEM(w)->active) {
4680         g_resolv_flags |= action;
4681     } else {
4682         g_resolv_flags &= ~action;
4683     }
4684 }
4685
4686 #ifdef HAVE_LIBPCAP
4687 void
4688 menu_auto_scroll_live_changed(gboolean auto_scroll_live_in) {
4689     GtkWidget *menu;
4690
4691
4692     /* tell menu about it */
4693 #ifdef MAIN_MENU_USE_UIMANAGER
4694     menu = gtk_ui_manager_get_widget(ui_manager_main_menubar, "/Menubar/ViewMenu/AutoScrollinLiveCapture");
4695     if(!menu){
4696         g_warning("menu_auto_scroll_live_changed: No menu found, path= /Menubar/ViewMenu/AutoScrollinLiveCapture");
4697     }
4698 #else
4699     menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Auto Scroll in Live Capture");
4700 #endif /* MAIN_MENU_USE_UIMANAGER */
4701     if( ((gboolean) GTK_CHECK_MENU_ITEM(menu)->active) != auto_scroll_live_in) {
4702         gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), auto_scroll_live_in);
4703     }
4704
4705     /* tell toolbar about it */
4706     toolbar_auto_scroll_live_changed(auto_scroll_live_in);
4707
4708     /* change auto scroll */
4709     if(auto_scroll_live_in != auto_scroll_live) {
4710         auto_scroll_live  = auto_scroll_live_in;
4711     }
4712 }
4713
4714 #ifndef MAIN_MENU_USE_UIMANAGER
4715 static void
4716 auto_scroll_live_cb(GtkWidget *w _U_, gpointer d _U_)
4717 {
4718     menu_auto_scroll_live_changed(GTK_CHECK_MENU_ITEM(w)->active);
4719 }
4720 #endif
4721
4722 #endif
4723
4724
4725 void
4726 menu_colorize_changed(gboolean packet_list_colorize) {
4727     GtkWidget *menu;
4728
4729
4730     /* tell menu about it */
4731 #ifdef MAIN_MENU_USE_UIMANAGER
4732     menu = gtk_ui_manager_get_widget(ui_manager_main_menubar, "/Menubar/ViewMenu/ColorizePacketList");
4733     if(!menu){
4734         g_warning("menu_colorize_changed: No menu found, path= /Menubar/ViewMenu/ColorizePacketList");
4735     }
4736 #else
4737     menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Colorize Packet List");
4738 #endif /* MAIN_MENU_USE_UIMANAGER */
4739     if( ((gboolean) GTK_CHECK_MENU_ITEM(menu)->active) != packet_list_colorize) {
4740         gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), packet_list_colorize);
4741     }
4742
4743     /* tell toolbar about it */
4744     toolbar_colorize_changed(packet_list_colorize);
4745
4746     /* change colorization */
4747     if(packet_list_colorize != recent.packet_list_colorize) {
4748         recent.packet_list_colorize = packet_list_colorize;
4749         color_filters_enable(packet_list_colorize);
4750 #ifdef NEW_PACKET_LIST
4751         new_packet_list_colorize_packets();
4752 #else
4753         cf_colorize_packets(&cfile);
4754 #endif
4755     }
4756 }
4757
4758 static void
4759 colorize_cb(GtkWidget *w, gpointer d _U_)
4760 {
4761     menu_colorize_changed(GTK_CHECK_MENU_ITEM(w)->active);
4762 }
4763
4764
4765 /* the recent file read has finished, update the menu corresponding */
4766 void
4767 menu_recent_read_finished(void) {
4768     GtkWidget *menu = NULL;
4769
4770 #ifdef MAIN_MENU_USE_UIMANAGER
4771     menu = gtk_ui_manager_get_widget(ui_manager_main_menubar, "/Menubar/ViewMenu/MainToolbar");
4772     if(!menu){
4773         g_warning("menu_recent_read_finished: No menu found, path= /Menubar/ViewMenu/MainToolbar");
4774     }else{
4775         gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), recent.main_toolbar_show);
4776     }
4777     menu = gtk_ui_manager_get_widget(ui_manager_main_menubar, "/Menubar/ViewMenu/FilterToolbar");
4778     if(!menu){
4779         g_warning("menu_recent_read_finished: No menu found, path= /Menubar/ViewMenu/FilterToolbar");
4780     }else{
4781         gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), recent.filter_toolbar_show);
4782     };
4783
4784 #else
4785     menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Main Toolbar");
4786     gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), recent.main_toolbar_show);
4787
4788     menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Filter Toolbar");
4789     gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), recent.filter_toolbar_show);
4790 #endif /* MAIN_MENU_USE_UIMANAGER*/
4791 #ifdef HAVE_AIRPCAP
4792 #ifdef MAIN_MENU_USE_UIMANAGER
4793     menu = gtk_ui_manager_get_widget(ui_manager_main_menubar, "/Menubar/ViewMenu/WirelessToolbar");
4794     if(!menu){
4795         g_warning("menu_recent_read_finished: No menu found, path= /Menubar/ViewMenu/WirelessToolbar");
4796     }else{
4797         gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), recent.airpcap_toolbar_show);
4798     }
4799 #else
4800     menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Wireless Toolbar");
4801     gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), recent.airpcap_toolbar_show);
4802 #endif /* MAIN_MENU_USE_UIMANAGER */
4803 #endif /* HAVE_AIRPCAP */
4804
4805 #ifdef MAIN_MENU_USE_UIMANAGER
4806     /* Fix me? */
4807     menu = gtk_ui_manager_get_widget(ui_manager_main_menubar, "/Menubar/ViewMenu/Statusbar");
4808     if(!menu){
4809         g_warning("menu_recent_read_finished: No menu found, path= /Menubar/ViewMenu/Statusbar");
4810     }else{
4811         gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), recent.statusbar_show);
4812     }
4813
4814     menu = gtk_ui_manager_get_widget(ui_manager_main_menubar, "/Menubar/ViewMenu/PacketList");
4815     if(!menu){
4816         g_warning("menu_recent_read_finished: No menu found, path= /Menubar/ViewMenu/PacketList");
4817     }else{
4818         gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), recent.packet_list_show);
4819     }
4820
4821     menu = gtk_ui_manager_get_widget(ui_manager_main_menubar, "/Menubar/ViewMenu/PacketDetails");
4822     if(!menu){
4823         g_warning("menu_recent_read_finished: No menu found, path= /Menubar/ViewMenu/PacketDetails");
4824     }else{
4825         gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), recent.tree_view_show);
4826     }
4827
4828     menu = gtk_ui_manager_get_widget(ui_manager_main_menubar, "/Menubar/ViewMenu/PacketBytes");
4829     if(!menu){
4830         g_warning("menu_recent_read_finished: No menu found, path= /Menubar/ViewMenu/PacketBytes");
4831     }else{
4832         gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), recent.byte_view_show);
4833     }
4834
4835     menu = gtk_ui_manager_get_widget(ui_manager_main_menubar, "/Menubar/ViewMenu/ColorizePacketList");
4836     if(!menu){
4837         g_warning("menu_recent_read_finished: No menu found, path= /Menubar/ViewMenu/ColorizePacketList");
4838     }else{
4839         gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), recent.packet_list_colorize);
4840     }
4841
4842 #else
4843     menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Statusbar");
4844     gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), recent.statusbar_show);
4845
4846     menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Packet List");
4847     gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), recent.packet_list_show);
4848
4849     menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Packet Details");
4850     gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), recent.tree_view_show);
4851
4852     menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Packet Bytes");
4853     gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), recent.byte_view_show);
4854
4855     menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Colorize Packet List");
4856     gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), recent.packet_list_colorize);
4857 #endif /* MAIN_MENU_USE_UIMANAGER*/
4858
4859     menu_name_resolution_changed();
4860
4861 #ifdef HAVE_LIBPCAP
4862 #ifdef MAIN_MENU_USE_UIMANAGER
4863     menu = gtk_ui_manager_get_widget(ui_manager_main_menubar, "/Menubar/ViewMenu/AutoScrollinLiveCapture");
4864     if(!menu){
4865         g_warning("menu_recent_read_finished: No menu found, path= /Menubar/ViewMenu/AutoScrollinLiveCapture");
4866     }else{
4867         gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), auto_scroll_live);
4868     }
4869 #else
4870     menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Auto Scroll in Live Capture");
4871     gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), auto_scroll_live);
4872 #endif /* MAIN_MENU_USE_UIMANAGER*/
4873 #endif
4874
4875     main_widgets_rearrange();
4876
4877     /* don't change the time format, if we had a command line value */
4878     if (timestamp_get_type() != TS_NOT_SET) {
4879         recent.gui_time_format = timestamp_get_type();
4880     }
4881
4882 #ifdef MAIN_MENU_USE_UIMANAGER
4883     /* XXX Fix me */
4884         timestamp_set_type(recent.gui_time_format);
4885 #ifdef NEW_PACKET_LIST
4886         /* This call adjusts column width */
4887         cf_timestamp_auto_precision(&cfile);
4888         new_packet_list_queue_draw();
4889 #else
4890         cf_change_time_formats(&cfile);
4891 #endif
4892 #if 0
4893 /* This should not be needed as we set the active radioItem when we crate the actiongroup */
4894     switch(recent.gui_time_format) {
4895     case(TS_ABSOLUTE_WITH_DATE):
4896         menu = gtk_ui_manager_get_widget(ui_manager_main_menubar, "/Menubar/ViewMenu/TimeDisplayFormat/DateandTimeofDay");
4897         if(!menu){
4898             g_warning("menu_recent_read_finished: No menu found, path= /Menubar/ViewMenu/TimeDisplayFormat/DateandTimeofDay");
4899         }
4900         break;
4901     case(TS_ABSOLUTE):
4902         menu = gtk_ui_manager_get_widget(ui_manager_main_menubar, "/Menubar/ViewMenu/TimeDisplayFormat/TimeofDay");
4903         if(!menu){
4904             g_warning("menu_recent_read_finished: No menu found, path= /Menubar/ViewMenu/TimeDisplayFormat/TimeofDay");
4905         }
4906         break;
4907     case(TS_RELATIVE):
4908         g_warning("TS_RELATIVE");
4909         action = gtk_ui_manager_get_action(ui_manager_main_menubar, "/Menubar/ViewMenu/TimeDisplayFormat/SecondsSinceBeginningofCapture");
4910         gtk_action_activate(action);
4911         if(gtk_action_is_sensitive(action))
4912             g_warning("ACTION IS SENSIBLE");
4913         if(!action)
4914             g_warning("NO ACTION");
4915
4916
4917         menu = gtk_ui_manager_get_widget(ui_manager_main_menubar, "/Menubar/ViewMenu/TimeDisplayFormat/SecondsSinceBeginningofCapture");
4918         if(!menu){
4919             g_warning("menu_recent_read_finished: No menu found, path= /Menubar/ViewMenu/TimeDisplayFormat/SecondsSinceBeginningofCapture");
4920         }
4921         break;
4922     case(TS_DELTA):
4923         menu = gtk_ui_manager_get_widget(ui_manager_main_menubar, "/Menubar/ViewMenu/TimeDisplayFormat/SecondsSincePreviousCapturedPacket");
4924         if(!menu){
4925             g_warning("menu_recent_read_finished: No menu found, path= /Menubar/ViewMenu/TimeDisplayFormat/SecondsSincePreviousCapturedPacket");
4926         }
4927         break;
4928     case(TS_DELTA_DIS):
4929         menu = gtk_ui_manager_get_widget(ui_manager_main_menubar, "/Menubar/ViewMenu/TimeDisplayFormat/SecondsSincePreviousDisplayedPacket");
4930         if(!menu){
4931             g_warning("menu_recent_read_finished: No menu found, path= /Menubar/ViewMenu/TimeDisplayFormat/SecondsSincePreviousDisplayedPacket");
4932         }
4933         break;
4934     case(TS_EPOCH):
4935         menu = gtk_ui_manager_get_widget(ui_manager_main_menubar, "/Menubar/ViewMenu/TimeDisplayFormat/SecondsSinceEpoch");
4936         if(!menu){
4937             g_warning("menu_recent_read_finished: No menu found, path= /Menubar/ViewMenu/TimeDisplayFormat/SecondsSinceEpoch");
4938         }
4939         break;
4940     default:
4941         g_assert_not_reached();
4942     }
4943     /* set_active will not trigger the callback when activating an active item! */
4944     recent.gui_time_format = -1;
4945     gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), FALSE);
4946     gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), TRUE);
4947 #endif /* 0 */
4948 #else
4949     switch(recent.gui_time_format) {
4950     case(TS_ABSOLUTE_WITH_DATE):
4951         menu = gtk_item_factory_get_widget(main_menu_factory,
4952             "/View/Time Display Format/Date and Time of Day:   1970-01-01 01:02:03.123456");
4953         break;
4954     case(TS_ABSOLUTE):
4955         menu = gtk_item_factory_get_widget(main_menu_factory,
4956             "/View/Time Display Format/Time of Day:   01:02:03.123456");
4957         break;
4958     case(TS_RELATIVE):
4959         menu = gtk_item_factory_get_widget(main_menu_factory,
4960             "/View/Time Display Format/Seconds Since Beginning of Capture:   123.123456");
4961         break;
4962     case(TS_DELTA):
4963         menu = gtk_item_factory_get_widget(main_menu_factory,
4964             "/View/Time Display Format/Seconds Since Previous Captured Packet:   1.123456");
4965         break;
4966     case(TS_DELTA_DIS):
4967         menu = gtk_item_factory_get_widget(main_menu_factory,
4968             "/View/Time Display Format/Seconds Since Previous Displayed Packet:   1.123456");
4969         break;
4970     case(TS_EPOCH):
4971         menu = gtk_item_factory_get_widget(main_menu_factory,
4972             "/View/Time Display Format/Seconds Since Epoch (1970-01-01):   1234567890.123456");
4973         break;
4974     default:
4975         g_assert_not_reached();
4976     }
4977     /* set_active will not trigger the callback when activating an active item! */
4978     recent.gui_time_format = -1;
4979     gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), FALSE);
4980     gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), TRUE);
4981 #endif /* MAIN_MENU_USE_UIMANAGER */
4982 #ifdef MAIN_MENU_USE_UIMANAGER
4983     /* the actual precision will be set in cf_change_time_formats() below */
4984     if (recent.gui_time_precision == TS_PREC_AUTO) {
4985         timestamp_set_precision(TS_PREC_AUTO_SEC);
4986     } else {
4987         timestamp_set_precision(recent.gui_time_precision);
4988     }
4989 #ifdef NEW_PACKET_LIST
4990     /* This call adjusts column width */
4991     cf_timestamp_auto_precision(&cfile);
4992     new_packet_list_queue_draw();
4993 #else
4994     cf_change_time_formats(&cfile);
4995 #endif
4996
4997 #else
4998     switch(recent.gui_time_precision) {
4999     case(TS_PREC_AUTO):
5000         menu = gtk_item_factory_get_widget(main_menu_factory,
5001             "/View/Time Display Format/Automatic (File Format Precision)");
5002         break;
5003     case(TS_PREC_FIXED_SEC):
5004         menu = gtk_item_factory_get_widget(main_menu_factory,
5005             "/View/Time Display Format/Seconds:   0");
5006         break;
5007     case(TS_PREC_FIXED_DSEC):
5008         menu = gtk_item_factory_get_widget(main_menu_factory,
5009             "/View/Time Display Format/Deciseconds:   0.1");
5010         break;
5011     case(TS_PREC_FIXED_CSEC):
5012         menu = gtk_item_factory_get_widget(main_menu_factory,
5013             "/View/Time Display Format/Centiseconds:   0.12");
5014         break;
5015     case(TS_PREC_FIXED_MSEC):
5016         menu = gtk_item_factory_get_widget(main_menu_factory,
5017             "/View/Time Display Format/Milliseconds:   0.123");
5018         break;
5019     case(TS_PREC_FIXED_USEC):
5020         menu = gtk_item_factory_get_widget(main_menu_factory,
5021             "/View/Time Display Format/Microseconds:   0.123456");
5022         break;
5023     case(TS_PREC_FIXED_NSEC):
5024         menu = gtk_item_factory_get_widget(main_menu_factory,
5025             "/View/Time Display Format/Nanoseconds:   0.123456789");
5026         break;
5027     default:
5028         g_assert_not_reached();
5029     }
5030
5031     /* set_active will not trigger the callback when activating an active item! */
5032     recent.gui_time_precision = -1;
5033     gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), FALSE);
5034     gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), TRUE);
5035 #endif /* MAIN_MENU_USE_UIMANAGER */
5036
5037     /* don't change the seconds format, if we had a command line value */
5038     if (timestamp_get_seconds_type() != TS_SECONDS_NOT_SET) {
5039         recent.gui_seconds_format = timestamp_get_seconds_type();
5040     }
5041 #ifdef MAIN_MENU_USE_UIMANAGER
5042     menu = gtk_ui_manager_get_widget(ui_manager_main_menubar, "/Menubar/ViewMenu/TimeDisplayFormat/DisplaySecondsWithHoursAndMinutes");
5043     if(!menu){
5044         g_warning("menu_recent_read_finished: No menu found, path= /Menubar/ViewMenu/TimeDisplayFormat/DisplaySecondsWithHoursAndMinutes");
5045     }
5046
5047 #else
5048     menu = gtk_item_factory_get_widget(main_menu_factory,
5049             "/View/Time Display Format/Display Seconds with hours and minutes");
5050 #endif /* MAIN_MENU_USE_UIMANAGER */
5051
5052     switch (recent.gui_seconds_format) {
5053     case TS_SECONDS_DEFAULT:
5054         recent.gui_seconds_format = -1;
5055         /* set_active will not trigger the callback when deactivating an inactive item! */
5056         gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), TRUE);
5057         gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), FALSE);
5058         break;
5059     case TS_SECONDS_HOUR_MIN_SEC:
5060         recent.gui_seconds_format = -1;
5061         /* set_active will not trigger the callback when activating an active item! */
5062         gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), FALSE);
5063         gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), TRUE);
5064         break;
5065     default:
5066         g_assert_not_reached();
5067     }
5068
5069     menu_colorize_changed(recent.packet_list_colorize);
5070 }
5071
5072
5073 gboolean
5074 popup_menu_handler(GtkWidget *widget, GdkEvent *event, gpointer data)
5075 {
5076     GtkWidget *menu = (GtkWidget *)data;
5077     GdkEventButton *event_button = NULL;
5078     gint row, column;
5079
5080     if(widget == NULL || event == NULL || data == NULL) {
5081         return FALSE;
5082     }
5083
5084     /*
5085      * If we ever want to make the menu differ based on what row
5086      * and/or column we're above, we'd use "eth_clist_get_selection_info()"
5087      * to find the row and column number for the coordinates; a CTree is,
5088      * I guess, like a CList with one column(?) and the expander widget
5089      * as a pixmap.
5090      */
5091     /* Check if we are on packet_list object */
5092     if (widget == g_object_get_data(G_OBJECT(popup_menu_object), E_MPACKET_LIST_KEY) &&
5093         ((GdkEventButton *)event)->button != 1) {
5094 #ifdef NEW_PACKET_LIST
5095         gint physical_row;
5096         if (new_packet_list_get_event_row_column((GdkEventButton *)event, &physical_row, &row, &column)) {
5097 #else
5098         if (packet_list_get_event_row_column(widget, (GdkEventButton *)event, &row, &column)) {
5099 #endif
5100             g_object_set_data(G_OBJECT(popup_menu_object), E_MPACKET_LIST_ROW_KEY,
5101 #ifdef NEW_PACKET_LIST
5102                             GINT_TO_POINTER(row));
5103 #else
5104                             GINT_TO_POINTER(row));
5105 #endif
5106             g_object_set_data(G_OBJECT(popup_menu_object), E_MPACKET_LIST_COL_KEY,
5107                             GINT_TO_POINTER(column));
5108 #ifdef NEW_PACKET_LIST
5109             new_packet_list_set_selected_row(row);
5110 #else
5111             packet_list_set_selected_row(row);
5112 #endif
5113         }
5114     }
5115
5116     /* Check if we are on tree_view object */
5117     if (widget == tree_view_gbl) {
5118         tree_view_select(widget, (GdkEventButton *) event);
5119     }
5120
5121     /* context menu handler */
5122     if(event->type == GDK_BUTTON_PRESS) {
5123         event_button = (GdkEventButton *) event;
5124
5125         /* To quote the "Gdk Event Structures" doc:
5126          * "Normally button 1 is the left mouse button, 2 is the middle button, and 3 is the right button" */
5127         if(event_button->button == 3) {
5128             gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL,
5129                            event_button->button,
5130                            event_button->time);
5131             g_signal_stop_emission_by_name(widget, "button_press_event");
5132             return TRUE;
5133         }
5134     }
5135
5136     /* Check if we are on byte_view object */
5137     if(widget == get_notebook_bv_ptr(byte_nb_ptr_gbl)) {
5138         byte_view_select(widget, (GdkEventButton *) event);
5139     }
5140
5141     /* GDK_2BUTTON_PRESS is a doubleclick -> expand/collapse tree row */
5142     /* GTK version 1 seems to be doing this automatically */
5143     if (widget == tree_view_gbl && event->type == GDK_2BUTTON_PRESS) {
5144         GtkTreePath      *path;
5145
5146         if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(widget),
5147                                           (gint) (((GdkEventButton *)event)->x),
5148                                           (gint) (((GdkEventButton *)event)->y),
5149                                           &path, NULL, NULL, NULL))
5150         {
5151             if (gtk_tree_view_row_expanded(GTK_TREE_VIEW(widget), path))
5152                 gtk_tree_view_collapse_row(GTK_TREE_VIEW(widget), path);
5153             else
5154                 gtk_tree_view_expand_row(GTK_TREE_VIEW(widget), path,
5155                                          FALSE);
5156             gtk_tree_path_free(path);
5157         }
5158     }
5159     return FALSE;
5160 }
5161
5162 /* Enable or disable menu items based on whether you have a capture file
5163    you've finished reading and, if you have one, whether it's been saved
5164    and whether it could be saved except by copying the raw packet data. */
5165 void
5166 set_menus_for_capture_file(capture_file *cf)
5167 {
5168     if (cf == NULL) {
5169         /* We have no capture file */
5170 #ifdef MAIN_MENU_USE_UIMANAGER
5171         set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/FileMenu/Merge", FALSE);
5172         set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/FileMenu/Close", FALSE);
5173         set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/FileMenu/Save", FALSE);
5174         set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/FileMenu/SaveAs", FALSE);
5175         set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/FileMenu/Export", FALSE);
5176         set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/ViewMenu/Reload", FALSE);
5177 #else
5178         set_menu_sensitivity_old("/File/Merge...", FALSE);
5179         set_menu_sensitivity_old("/File/Close", FALSE);
5180         set_menu_sensitivity_old("/File/Save", FALSE);
5181         set_menu_sensitivity_old("/File/Save As...", FALSE);
5182         set_menu_sensitivity_old("/File/Export", FALSE);
5183         set_menu_sensitivity_old("/View/Reload", FALSE);
5184 #endif /* MAIN_MENU_USE_UIMANAGER */
5185
5186         set_toolbar_for_capture_file(FALSE);
5187         set_toolbar_for_unsaved_capture_file(FALSE);
5188     } else {
5189 #ifdef MAIN_MENU_USE_UIMANAGER
5190         set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/FileMenu/Merge", TRUE);
5191         set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/FileMenu/Close", TRUE);
5192         set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/FileMenu/Save", !cf->user_saved);
5193         /*
5194          * "Save As..." works only if we can write the file out in at least
5195          * one format (so we can save the whole file or just a subset) or
5196          * if we have an unsaved capture (so writing the whole file out
5197          * with a raw data copy makes sense).
5198          */
5199         set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/FileMenu/SaveAs",
5200                              cf_can_save_as(cf) || !cf->user_saved);
5201         set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/FileMenu/Export", TRUE);
5202         set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/ViewMenu/Reload", TRUE);
5203 #else
5204         set_menu_sensitivity_old("/File/Merge...", TRUE);
5205         set_menu_sensitivity_old("/File/Close", TRUE);
5206         set_menu_sensitivity_old("/File/Save", !cf->user_saved);
5207         /*
5208          * "Save As..." works only if we can write the file out in at least
5209          * one format (so we can save the whole file or just a subset) or
5210          * if we have an unsaved capture (so writing the whole file out
5211          * with a raw data copy makes sense).
5212          */
5213         set_menu_sensitivity_old("/File/Save As...",
5214                              cf_can_save_as(cf) || !cf->user_saved);
5215         set_menu_sensitivity_old("/File/Export", TRUE);
5216         set_menu_sensitivity_old("/View/Reload", TRUE);
5217 #endif /* MAIN_MENU_USE_UIMANAGER */
5218         set_toolbar_for_unsaved_capture_file(!cf->user_saved);
5219         set_toolbar_for_capture_file(TRUE);
5220     }
5221 }
5222
5223 /* Enable or disable menu items based on whether there's a capture in
5224    progress. */
5225 void
5226 set_menus_for_capture_in_progress(gboolean capture_in_progress)
5227 {
5228 #ifdef MAIN_MENU_USE_UIMANAGER
5229     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/FileMenu/Open",
5230                          !capture_in_progress);
5231     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/FileMenu/OpenRecent",
5232                          !capture_in_progress);
5233     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/FileMenu/Export",
5234                          capture_in_progress);
5235     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/FileMenu/Set",
5236                          !capture_in_progress);
5237 #else
5238
5239     set_menu_sensitivity_old("/File/Open...",
5240                          !capture_in_progress);
5241     set_menu_sensitivity_old("/File/Open Recent",
5242                          !capture_in_progress);
5243     set_menu_sensitivity_old("/File/Export",
5244                          capture_in_progress);
5245     set_menu_sensitivity_old("/File/File Set",
5246                          !capture_in_progress);
5247 #endif /* MAIN_MENU_USE_UIMANAGER */
5248     set_menu_sensitivity(ui_manager_packet_list_heading, "/PacketListHeadingPopup/SortAscending",
5249                          !capture_in_progress);
5250     set_menu_sensitivity(ui_manager_packet_list_heading, "/PacketListHeadingPopup/SortDescending",
5251                          !capture_in_progress);
5252     set_menu_sensitivity(ui_manager_packet_list_heading, "/PacketListHeadingPopup/NoSorting",
5253                          !capture_in_progress);
5254
5255 #ifdef HAVE_LIBPCAP
5256 #ifdef MAIN_MENU_USE_UIMANAGER
5257     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/CaptureMenu/Options",
5258                          !capture_in_progress);
5259     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/CaptureMenu/Start",
5260                          !capture_in_progress);
5261     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/CaptureMenu/Stop",
5262                          capture_in_progress);
5263     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/CaptureMenu/Restart",
5264                          capture_in_progress);
5265 #else
5266     set_menu_sensitivity_old("/Capture/Options...",
5267                          !capture_in_progress);
5268     set_menu_sensitivity_old("/Capture/Start",
5269                          !capture_in_progress);
5270     set_menu_sensitivity_old("/Capture/Stop",
5271                          capture_in_progress);
5272     set_menu_sensitivity_old("/Capture/Restart",
5273                          capture_in_progress);
5274 #endif /* MAIN_MENU_USE_UIMANAGER */
5275     set_toolbar_for_capture_in_progress(capture_in_progress);
5276
5277     set_capture_if_dialog_for_capture_in_progress(capture_in_progress);
5278 #endif /* HAVE_LIBPCAP */
5279 }
5280
5281 /* Enable or disable menu items based on whether you have some captured
5282    packets. */
5283 static gboolean
5284 walk_menu_tree_for_captured_packets(GList *node,
5285     gboolean have_captured_packets)
5286 {
5287     gboolean    is_enabled;
5288     GList       *child;
5289     menu_item_t *node_data = node->data;
5290
5291     /*
5292      * Is this a leaf node or an interior node?
5293      */
5294     if (node_data->children == NULL) {
5295         /*
5296          * It's a leaf node.
5297          *
5298          * If it has no "selected_packet_enabled()" or
5299          * "selected_tree_row_enabled()" routines, we enable
5300          * it.  This allows tap windows to be popped up even
5301          * if you have no capture file; this is done to let
5302          * the user pop up multiple tap windows before reading
5303          * in a capture file, so that they can be processed in
5304          * parallel while the capture file is being read rather
5305          * than one at at time as you pop up the windows, and to
5306          * let the user pop up tap windows before starting an
5307          * "Update list of packets in real time" capture, so that
5308          * the statistics can be displayed while the capture is
5309          * in progress.
5310          *
5311          * If it has either of those routines, we disable it for
5312          * now - as long as, when a capture is first available,
5313          * we don't get called after a packet or tree row is
5314          * selected, that's OK.
5315          * XXX - that should be done better.
5316          */
5317         if (node_data->selected_packet_enabled == NULL &&
5318             node_data->selected_tree_row_enabled == NULL)
5319             node_data->enabled = TRUE;
5320         else
5321             node_data->enabled = FALSE;
5322     } else {
5323         /*
5324          * It's an interior node; call
5325          * "walk_menu_tree_for_captured_packets()" on all its
5326          * children and, if any of them are enabled, enable
5327          * this node, otherwise disable it.
5328          *
5329          * XXX - should we just leave all interior nodes enabled?
5330          * Which is a better UI choice?
5331          */
5332         is_enabled = FALSE;
5333         for (child = node_data->children; child != NULL; child =
5334                  child->next) {
5335             if (walk_menu_tree_for_captured_packets(child,
5336                                                     have_captured_packets))
5337                 is_enabled = TRUE;
5338         }
5339         node_data->enabled = is_enabled;
5340     }
5341
5342     /*
5343      * The root node doesn't correspond to a menu tree item; it
5344      * has a null name pointer.
5345      */
5346     if (node_data->name != NULL) {
5347 #ifdef MAIN_MENU_USE_UIMANAGER
5348         set_menu_sensitivity(ui_manager_main_menubar, node_data->name,
5349                               node_data->enabled);
5350 #else
5351         set_menu_sensitivity_old(node_data->name,
5352                              node_data->enabled);
5353 #endif
5354     }
5355     return node_data->enabled;
5356 }
5357
5358 void
5359 set_menus_for_captured_packets(gboolean have_captured_packets)
5360 {
5361 #ifdef MAIN_MENU_USE_UIMANAGER
5362     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/FileMenu/Print",
5363                          have_captured_packets);
5364 #else
5365     set_menu_sensitivity_old("/File/Print...",
5366                          have_captured_packets);
5367 #endif /* MAIN_MENU_USE_UIMANAGER */
5368     set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/Print",
5369                          have_captured_packets);
5370
5371 #ifdef MAIN_MENU_USE_UIMANAGER
5372     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/EditMenu/FindPacket",
5373                          have_captured_packets);
5374     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/EditMenu/FindNext",
5375                          have_captured_packets);
5376     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/EditMenu/FindPrevious",
5377                          have_captured_packets);
5378     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/ViewMenu/ZoomIn",
5379                          have_captured_packets);
5380     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/ViewMenu/ZoomOut",
5381                          have_captured_packets);
5382     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/ViewMenu/NormalSize",
5383                          have_captured_packets);
5384     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/GoMenu/GotoCorrespondingPacket",
5385                          have_captured_packets);
5386     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/GoMenu/PreviousPacket",
5387                          have_captured_packets);
5388     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/GoMenu/NextPacket",
5389                          have_captured_packets);
5390     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/GoMenu/FirstPacket",
5391                          have_captured_packets);
5392     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/GoMenu/LastPacket",
5393                          have_captured_packets);
5394     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/GoMenu/PreviousPacketInConversation",
5395                          have_captured_packets);
5396     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/GoMenu/NextPacketInConversation",
5397                          have_captured_packets);
5398     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/StatisticsMenu/Summary",
5399                          have_captured_packets);
5400     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/StatisticsMenu/ProtocolHierarchy",
5401                          have_captured_packets);
5402 #else
5403     set_menu_sensitivity_old("/Edit/Find Packet...",
5404                          have_captured_packets);
5405     set_menu_sensitivity_old("/Edit/Find Next",
5406                          have_captured_packets);
5407     set_menu_sensitivity_old("/Edit/Find Previous",
5408                          have_captured_packets);
5409     set_menu_sensitivity_old("/View/Zoom In",
5410                          have_captured_packets);
5411     set_menu_sensitivity_old("/View/Zoom Out",
5412                          have_captured_packets);
5413     set_menu_sensitivity_old("/View/Normal Size",
5414                          have_captured_packets);
5415     set_menu_sensitivity_old("/Go/Go to Packet...",
5416                          have_captured_packets);
5417     set_menu_sensitivity_old("/Go/Previous Packet",
5418                          have_captured_packets);
5419     set_menu_sensitivity_old("/Go/Next Packet",
5420                          have_captured_packets);
5421     set_menu_sensitivity_old("/Go/First Packet",
5422                          have_captured_packets);
5423     set_menu_sensitivity_old("/Go/Last Packet",
5424                          have_captured_packets);
5425     set_menu_sensitivity_old("/Go/Previous Packet In Conversation",
5426                          have_captured_packets);
5427     set_menu_sensitivity_old("/Go/Next Packet In Conversation",
5428                          have_captured_packets);
5429     set_menu_sensitivity_old("/Statistics/Summary",
5430                          have_captured_packets);
5431     set_menu_sensitivity_old("/Statistics/Protocol Hierarchy",
5432                          have_captured_packets);
5433 #endif /* MAIN_MENU_USE_UIMANAGER */
5434     walk_menu_tree_for_captured_packets(tap_menu_tree_root,
5435                                         have_captured_packets);
5436     set_toolbar_for_captured_packets(have_captured_packets);
5437 }
5438
5439 /* Enable or disable menu items based on whether a packet is selected and,
5440    if so, on the properties of the packet. */
5441 static gboolean
5442 walk_menu_tree_for_selected_packet(GList *node, frame_data *fd,
5443     epan_dissect_t *edt)
5444 {
5445     gboolean is_enabled;
5446     GList *child;
5447     menu_item_t *node_data = node->data;
5448
5449     /*
5450      * Is this a leaf node or an interior node?
5451      */
5452     if (node_data->children == NULL) {
5453         /*
5454          * It's a leaf node.
5455          *
5456          * If it has no "selected_packet_enabled()" routine,
5457          * leave its enabled/disabled status alone - it
5458          * doesn't depend on whether we have a packet selected
5459          * or not or on the selected packet.
5460          *
5461          * If it has a "selected_packet_enabled()" routine,
5462          * call it and set the item's enabled/disabled status
5463          * based on its return value.
5464          */
5465         if (node_data->selected_packet_enabled != NULL)
5466             node_data->enabled = node_data->selected_packet_enabled(fd, edt, node_data->callback_data);
5467     } else {
5468         /*
5469          * It's an interior node; call
5470          * "walk_menu_tree_for_selected_packet()" on all its
5471          * children and, if any of them are enabled, enable
5472          * this node, otherwise disable it.
5473          *
5474          * XXX - should we just leave all interior nodes enabled?
5475          * Which is a better UI choice?
5476          */
5477         is_enabled = FALSE;
5478         for (child = node_data->children; child != NULL; child =
5479                  child->next) {
5480             if (walk_menu_tree_for_selected_packet(child, fd, edt))
5481                 is_enabled = TRUE;
5482         }
5483         node_data->enabled = is_enabled;
5484     }
5485
5486     /*
5487      * The root node doesn't correspond to a menu tree item; it
5488      * has a null name pointer.
5489      */
5490     if (node_data->name != NULL) {
5491 #ifdef MAIN_MENU_USE_UIMANAGER
5492         set_menu_sensitivity(ui_manager_main_menubar, node_data->name,
5493                               node_data->enabled);
5494 #else
5495         set_menu_sensitivity_old(node_data->name,
5496                              node_data->enabled);
5497 #endif /* MAIN_MENU_USE_UIMANAGER */
5498     }
5499     return node_data->enabled;
5500 }
5501
5502 gboolean
5503 packet_is_ssl(epan_dissect_t* edt)
5504 {
5505     GPtrArray* array;
5506     int ssl_id;
5507     gboolean is_ssl;
5508
5509     if (!edt || !edt->tree)
5510         return FALSE;
5511     ssl_id = proto_get_id_by_filter_name("ssl");
5512     if (ssl_id < 0)
5513         return FALSE;
5514     array = proto_find_finfo(edt->tree, ssl_id);
5515     is_ssl = (array->len > 0) ? TRUE : FALSE;
5516     g_ptr_array_free(array, TRUE);
5517     return is_ssl;
5518 }
5519
5520 void
5521 set_menus_for_selected_packet(capture_file *cf)
5522 {
5523     /* Making the menu context-sensitive allows for easier selection of the
5524        desired item and has the added benefit, with large captures, of
5525        avoiding needless looping through huge lists for marked, ignored,
5526        or time-referenced packets. */
5527     gboolean is_ssl = packet_is_ssl(cf->edt);
5528     gboolean frame_selected = cf->current_frame != NULL;
5529         /* A frame is selected */
5530     gboolean have_marked = frame_selected && cf->marked_count > 0;
5531         /* We have marked frames.  (XXX - why check frame_selected?) */
5532     gboolean another_is_marked = have_marked &&
5533         !(cf->marked_count == 1 && cf->current_frame->flags.marked);
5534         /* We have a marked frame other than the current frame (i.e.,
5535            we have at least one marked frame, and either there's more
5536            than one marked frame or the current frame isn't marked). */
5537     gboolean have_time_ref = cf->ref_time_count > 0;
5538     gboolean another_is_time_ref = frame_selected && have_time_ref &&
5539         !(cf->ref_time_count == 1 && cf->current_frame->flags.ref_time);
5540         /* We have a time reference frame other than the current frame (i.e.,
5541            we have at least one time reference frame, and either there's more
5542            than one time reference frame or the current frame isn't a
5543            time reference frame). (XXX - why check frame_selected?) */
5544
5545 #ifdef MAIN_MENU_USE_UIMANAGER
5546     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/EditMenu/MarkPacket",
5547                          frame_selected);
5548 #else
5549     set_menu_sensitivity_old("/Edit/Mark Packet (toggle)",
5550                          frame_selected);
5551 #endif /* MAIN_MENU_USE_UIMANAGER */
5552     set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/MarkPacket",
5553                          frame_selected);
5554 #ifdef MAIN_MENU_USE_UIMANAGER
5555     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/EditMenu/MarkAllDisplayedPackets",
5556                          cf->displayed_count > 0);
5557     /* Unlike un-ignore, do not allow unmark of all frames when no frames are displayed  */
5558     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/EditMenu/UnmarkAllPackets",
5559                          have_marked);
5560     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/EditMenu/FindNextMark",
5561                          another_is_marked);
5562     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/EditMenu/FindPreviousMark",
5563                          another_is_marked);
5564
5565     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/EditMenu/IgnorePacket",
5566                          frame_selected);
5567 #else
5568     set_menu_sensitivity_old("/Edit/Mark All Displayed Packets (toggle)",
5569                          cf->displayed_count > 0);
5570     /* Unlike un-ignore, do not allow unmark of all frames when no frames are displayed  */
5571     set_menu_sensitivity_old("/Edit/Unmark All Packets",
5572                          have_marked);
5573     set_menu_sensitivity_old("/Edit/Find Next Mark",
5574                          another_is_marked);
5575     set_menu_sensitivity_old("/Edit/Find Previous Mark",
5576                          another_is_marked);
5577
5578     set_menu_sensitivity_old("/Edit/Ignore Packet (toggle)",
5579                          frame_selected);
5580 #endif /* MAIN_MENU_USE_UIMANAGER */
5581    set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/IgnorePacket",
5582                          frame_selected);
5583 #ifdef MAIN_MENU_USE_UIMANAGER
5584     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/EditMenu/IgnoreAllDisplayedPackets",
5585                          cf->displayed_count > 0 && cf->displayed_count != cf->count);
5586     /* Allow un-ignore of all frames even with no frames currently displayed */
5587     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/EditMenu/Un-IgnoreAllPackets",
5588                          cf->ignored_count > 0);
5589
5590     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/EditMenu/SetTimeReference",
5591                          frame_selected);
5592 #else
5593     set_menu_sensitivity_old("/Edit/Ignore All Displayed Packets (toggle)",
5594                          cf->displayed_count > 0 && cf->displayed_count != cf->count);
5595     /* Allow un-ignore of all frames even with no frames currently displayed */
5596     set_menu_sensitivity_old("/Edit/Un-Ignore All Packets",
5597                          cf->ignored_count > 0);
5598
5599     set_menu_sensitivity_old("/Edit/Set Time Reference (toggle)",
5600                          frame_selected);
5601 #endif /* MAIN_MENU_USE_UIMANAGER */
5602 #ifdef NEW_PACKET_LIST
5603 #ifdef MAIN_MENU_USE_UIMANAGER
5604     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/EditMenu/Un-TimeReferenceAllPackets",
5605                          have_time_ref);
5606 #else
5607     set_menu_sensitivity_old("/Edit/Un-Time Reference All Packets",
5608                          have_time_ref);
5609 #endif /* MAIN_MENU_USE_UIMANAGER */
5610 #endif /* NEW_PACKET_LIST */
5611     set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/SetTimeReference",
5612                          frame_selected);
5613 #ifdef MAIN_MENU_USE_UIMANAGER
5614     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/EditMenu/FindNextTimeReference",
5615                          another_is_time_ref);
5616     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/EditMenu/FindPreviousTimeReference",
5617                          another_is_time_ref);
5618
5619     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/ViewMenu/ResizeAllColumns",
5620                          frame_selected);
5621     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/ViewMenu/CollapseAll",
5622                          frame_selected);
5623 #else
5624     set_menu_sensitivity_old("/Edit/Find Next Time Reference",
5625                          another_is_time_ref);
5626     set_menu_sensitivity_old("/Edit/Find Previous Time Reference",
5627                          another_is_time_ref);
5628
5629     set_menu_sensitivity_old("/View/Resize All Columns",
5630                          frame_selected);
5631     set_menu_sensitivity_old("/View/Collapse All",
5632                          frame_selected);
5633 #endif /* MAIN_MENU_USE_UIMANAGER */
5634     set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/CollapseAll",
5635                          frame_selected);
5636 #ifdef MAIN_MENU_USE_UIMANAGER
5637     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/ViewMenu/ExpandAll",
5638                          frame_selected);
5639 #else
5640      set_menu_sensitivity_old("/View/Expand All",
5641                           frame_selected);
5642 #endif /* MAIN_MENU_USE_UIMANAGER */
5643     set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/ExpandAll",
5644                          frame_selected);
5645 #ifdef MAIN_MENU_USE_UIMANAGER
5646     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/ViewMenu/ColorizeConversation",
5647                          frame_selected);
5648     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/ViewMenu/ResetColoring1-10",
5649                          tmp_color_filters_used());
5650     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/ViewMenu/ShowPacketinNewWindow",
5651                          frame_selected);
5652 #else
5653     set_menu_sensitivity_old("/View/Colorize Conversation",
5654                          frame_selected);
5655     set_menu_sensitivity_old("/View/Reset Coloring 1-10",
5656                          tmp_color_filters_used());
5657     set_menu_sensitivity_old("/View/Show Packet in New Window",
5658                          frame_selected);
5659 #endif /* MAIN_MENU_USE_UIMANAGER */
5660     set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/ShowPacketinNewWindow",
5661                          frame_selected);
5662     set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/ManuallyResolveAddress",
5663                          frame_selected ? ((cf->edt->pi.ethertype == ETHERTYPE_IP)||(cf->edt->pi.ethertype == ETHERTYPE_IPv6)) : FALSE);
5664     set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/SCTP",
5665                          frame_selected ? (cf->edt->pi.ipproto == IP_PROTO_SCTP) : FALSE);
5666     set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/FollowTCPStream",
5667                          frame_selected ? (cf->edt->pi.ipproto == IP_PROTO_TCP) : FALSE);
5668     set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/FollowTCPStream",
5669                          frame_selected ? (cf->edt->pi.ipproto == IP_PROTO_TCP) : FALSE);
5670     set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/FollowUDPStream",
5671                          frame_selected ? (cf->edt->pi.ipproto == IP_PROTO_UDP) : FALSE);
5672     set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/FollowSSLStream",
5673                          frame_selected ? is_ssl : FALSE);
5674     set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/FollowSSLStream",
5675                          frame_selected ? is_ssl : FALSE);
5676     set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/ConversationFilter",
5677                          frame_selected);
5678     set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/ConversationFilter/Ethernet",
5679                          frame_selected ? (cf->edt->pi.dl_src.type == AT_ETHER) : FALSE);
5680     set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/ConversationFilter/IP",
5681                          frame_selected ? ((cf->edt->pi.ethertype == ETHERTYPE_IP)||(cf->edt->pi.ethertype == ETHERTYPE_IPv6)) : FALSE);
5682     set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/ConversationFilter/TCP",
5683                          frame_selected ? (cf->edt->pi.ipproto == IP_PROTO_TCP) : FALSE);
5684     set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/ConversationFilter/UDP",
5685                          frame_selected ? (cf->edt->pi.ipproto == IP_PROTO_UDP) : FALSE);
5686     set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/FollowUDPStream",
5687                          frame_selected ? (cf->edt->pi.ipproto == IP_PROTO_UDP) : FALSE);
5688     set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/ConversationFilter/PN-CBA",
5689                          frame_selected ? (cf->edt->pi.profinet_type != 0 && cf->edt->pi.profinet_type < 10) : FALSE);
5690     set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/ColorizeConversation",
5691                          frame_selected);
5692     set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/ColorizeConversation/Ethernet",
5693                          frame_selected ? (cf->edt->pi.dl_src.type == AT_ETHER) : FALSE);
5694     set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/ColorizeConversation/IP",
5695                          frame_selected ? ((cf->edt->pi.ethertype == ETHERTYPE_IP)||(cf->edt->pi.ethertype == ETHERTYPE_IPv6)) : FALSE);
5696     set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/ColorizeConversation/TCP",
5697                          frame_selected ? (cf->edt->pi.ipproto == IP_PROTO_TCP) : FALSE);
5698     set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/ColorizeConversation/UDP",
5699                          frame_selected ? (cf->edt->pi.ipproto == IP_PROTO_UDP) : FALSE);
5700     set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/ColorizeConversation/PN-CBA",
5701                          frame_selected ? (cf->edt->pi.profinet_type != 0 && cf->edt->pi.profinet_type < 10) : FALSE);
5702     set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/DecodeAs",
5703                          frame_selected && decode_as_ok());
5704     set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/DecodeAs",
5705                          frame_selected && decode_as_ok());
5706     set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/Copy",
5707                          frame_selected);
5708     set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/ApplyAsFilter",
5709                          frame_selected);
5710     set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/PrepareaFilter",
5711                          frame_selected);
5712     set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/ResolveName",
5713                          frame_selected && (g_resolv_flags & RESOLV_ALL_ADDRS) != RESOLV_ALL_ADDRS);
5714 #ifdef MAIN_MENU_USE_UIMANAGER
5715     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/AnalyzeMenu/FollowTCPStream",
5716                          frame_selected ? (cf->edt->pi.ipproto == IP_PROTO_TCP) : FALSE);
5717     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/AnalyzeMenu/FollowUDPStream",
5718                          frame_selected ? (cf->edt->pi.ipproto == IP_PROTO_UDP) : FALSE);
5719     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/AnalyzeMenu/FollowSSLStream",
5720                          frame_selected ? is_ssl : FALSE);
5721     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/AnalyzeMenu/DecodeAs",
5722                          frame_selected && decode_as_ok());
5723     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/ViewMenu/NameResolution/ResolveName",
5724                          frame_selected && (g_resolv_flags & RESOLV_ALL_ADDRS) != RESOLV_ALL_ADDRS);
5725     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/ToolsMenu/FirewallACLRules",
5726                          frame_selected);
5727
5728 #else
5729     set_menu_sensitivity_old("/Analyze/Follow TCP Stream",
5730                          frame_selected ? (cf->edt->pi.ipproto == IP_PROTO_TCP) : FALSE);
5731     set_menu_sensitivity_old("/Analyze/Follow UDP Stream",
5732                          frame_selected ? (cf->edt->pi.ipproto == IP_PROTO_UDP) : FALSE);
5733     set_menu_sensitivity_old("/Analyze/Follow SSL Stream",
5734                          frame_selected ? is_ssl : FALSE);
5735     set_menu_sensitivity_old("/Analyze/Decode As...",
5736                          frame_selected && decode_as_ok());
5737     set_menu_sensitivity_old("/View/Name Resolution/Resolve Name",
5738                          frame_selected && (g_resolv_flags & RESOLV_ALL_ADDRS) != RESOLV_ALL_ADDRS);
5739     set_menu_sensitivity_old("/Tools/Firewall ACL Rules",
5740                          frame_selected);
5741 #endif /* MAIN_MENU_USE_UIMANAGER */
5742     walk_menu_tree_for_selected_packet(tap_menu_tree_root, cf->current_frame,
5743                                        cf->edt);
5744 }
5745
5746 /* Enable or disable menu items based on whether a tree row is selected
5747    and, if so, on the properties of the tree row. */
5748 static gboolean
5749 walk_menu_tree_for_selected_tree_row(GList *node, field_info *fi)
5750 {
5751     gboolean is_enabled;
5752     GList *child;
5753     menu_item_t *node_data = node->data;
5754
5755     /*
5756      * Is this a leaf node or an interior node?
5757      */
5758     if (node_data->children == NULL) {
5759         /*
5760          * It's a leaf node.
5761          *
5762          * If it has no "selected_tree_row_enabled()" routine,
5763          * leave its enabled/disabled status alone - it
5764          * doesn't depend on whether we have a tree row selected
5765          * or not or on the selected tree row.
5766          *
5767          * If it has a "selected_tree_row_enabled()" routine,
5768          * call it and set the item's enabled/disabled status
5769          * based on its return value.
5770          */
5771         if (node_data->selected_tree_row_enabled != NULL)
5772             node_data->enabled = node_data->selected_tree_row_enabled(fi, node_data->callback_data);
5773     } else {
5774         /*
5775          * It's an interior node; call
5776          * "walk_menu_tree_for_selected_tree_row()" on all its
5777          * children and, if any of them are enabled, enable
5778          * this node, otherwise disable it.
5779          *
5780          * XXX - should we just leave all interior nodes enabled?
5781          * Which is a better UI choice?
5782          */
5783         is_enabled = FALSE;
5784         for (child = node_data->children; child != NULL; child =
5785                  child->next) {
5786             if (walk_menu_tree_for_selected_tree_row(child, fi))
5787                 is_enabled = TRUE;
5788         }
5789         node_data->enabled = is_enabled;
5790     }
5791
5792     /*
5793      * The root node doesn't correspond to a menu tree item; it
5794      * has a null name pointer.
5795      */
5796     if (node_data->name != NULL) {
5797 #ifdef MAIN_MENU_USE_UIMANAGER
5798         set_menu_sensitivity(ui_manager_main_menubar, node_data->name,
5799                              node_data->enabled);
5800 #else
5801         set_menu_sensitivity_old(node_data->name,
5802                              node_data->enabled);
5803 #endif /* MAIN_MENU_USE_UIMANAGER */
5804     }
5805     return node_data->enabled;
5806 }
5807
5808 static void
5809 menu_prefs_toggle_bool (GtkWidget *w, gpointer data)
5810 {
5811     gboolean *value = data;
5812     module_t *module = g_object_get_data (G_OBJECT(w), "module");
5813
5814     module->prefs_changed = TRUE;
5815     *value = !(*value);
5816
5817     prefs_apply (module);
5818     if (!prefs.gui_use_pref_save) {
5819         prefs_main_write();
5820     }
5821     redissect_packets();
5822 }
5823
5824 static void
5825 menu_prefs_change_enum (GtkWidget *w, gpointer data)
5826 {
5827     gint *value = data;
5828     module_t *module = g_object_get_data (G_OBJECT(w), "module");
5829     gint new_value = GPOINTER_TO_INT(g_object_get_data (G_OBJECT(w), "enumval"));
5830
5831     if (!gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM(w)))
5832         return;
5833
5834     if (*value != new_value) {
5835         module->prefs_changed = TRUE;
5836         *value = new_value;
5837
5838         prefs_apply (module);
5839         if (!prefs.gui_use_pref_save) {
5840             prefs_main_write();
5841         }
5842         redissect_packets();
5843     }
5844 }
5845
5846 void
5847 menu_prefs_reset(void)
5848 {
5849         g_free (g_object_get_data(G_OBJECT(ui_manager_tree_view_menu), "menu_abbrev"));
5850         g_object_set_data(G_OBJECT(ui_manager_tree_view_menu), "menu_abbrev", NULL);
5851 }
5852
5853 static void
5854 menu_prefs_change_ok (GtkWidget *w, gpointer parent_w)
5855 {
5856     GtkWidget *entry = g_object_get_data (G_OBJECT(w), "entry");
5857     module_t *module = g_object_get_data (G_OBJECT(w), "module");
5858     pref_t *pref = g_object_get_data (G_OBJECT(w), "pref");
5859     const gchar *new_value =  gtk_entry_get_text(GTK_ENTRY(entry));
5860     range_t *newrange;
5861     gchar *p;
5862     guint uval;
5863
5864     switch (pref->type) {
5865     case PREF_UINT:
5866         uval = strtoul(new_value, &p, pref->info.base);
5867         if (p == new_value || *p != '\0') {
5868             simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
5869                           "The value \"%s\" isn't a valid number.",
5870                           new_value);
5871             return;
5872         }
5873         if (*pref->varp.uint != uval) {
5874             module->prefs_changed = TRUE;
5875             *pref->varp.uint = uval;
5876         }
5877         break;
5878     case PREF_STRING:
5879         if (strcmp (*pref->varp.string, new_value) != 0) {
5880             module->prefs_changed = TRUE;
5881             g_free((void*)*pref->varp.string);
5882             *pref->varp.string = g_strdup(new_value);
5883         }
5884         break;
5885     case PREF_RANGE:
5886         if (range_convert_str(&newrange, new_value, pref->info.max_value) != CVT_NO_ERROR) {
5887             simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
5888                           "The value \"%s\" isn't a valid range.",
5889                           new_value);
5890             return;
5891         }
5892         if (!ranges_are_equal(*pref->varp.range, newrange)) {
5893             module->prefs_changed = TRUE;
5894             g_free(*pref->varp.range);
5895             *pref->varp.range = newrange;
5896         } else {
5897             g_free (newrange);
5898         }
5899         break;
5900     default:
5901         g_assert_not_reached();
5902         break;
5903     }
5904
5905     if (module->prefs_changed) {
5906         /* Ensure we reload the sub menu */
5907         menu_prefs_reset();
5908         prefs_apply (module);
5909         if (!prefs.gui_use_pref_save) {
5910             prefs_main_write();
5911         }
5912         redissect_packets();
5913     }
5914
5915     window_destroy(GTK_WIDGET(parent_w));
5916 }
5917
5918 static void
5919 menu_prefs_change_cancel (GtkWidget *w _U_, gpointer parent_w)
5920 {
5921     window_destroy(GTK_WIDGET(parent_w));
5922 }
5923
5924 static void
5925 menu_prefs_edit_dlg (GtkWidget *w, gpointer data)
5926 {
5927     pref_t *pref = data;
5928     module_t *module = g_object_get_data (G_OBJECT(w), "module");
5929     gchar *value = NULL;
5930
5931     GtkWidget *win, *main_tb, *main_vb, *bbox, *cancel_bt, *ok_bt;
5932     GtkWidget *entry, *label;
5933     GtkTooltips *tooltips;
5934
5935     switch (pref->type) {
5936     case PREF_UINT:
5937         switch (pref->info.base) {
5938         case 8:
5939             value = g_strdup_printf("%o", *pref->varp.uint);
5940             break;
5941         case 10:
5942             value = g_strdup_printf("%u", *pref->varp.uint);
5943             break;
5944         case 16:
5945             value = g_strdup_printf("%x", *pref->varp.uint);
5946             break;
5947         default:
5948             g_assert_not_reached();
5949             break;
5950         }
5951         break;
5952     case PREF_STRING:
5953         value = g_strdup(*pref->varp.string);
5954         break;
5955     case PREF_RANGE:
5956         value = g_strdup(range_convert_range (*pref->varp.range));
5957         break;
5958     default:
5959         g_assert_not_reached();
5960         break;
5961     }
5962
5963     tooltips = gtk_tooltips_new();
5964
5965     win = dlg_window_new(module->description);
5966
5967     gtk_window_set_resizable(GTK_WINDOW(win),FALSE);
5968     gtk_window_resize(GTK_WINDOW(win), 400, 100);
5969
5970     main_vb = gtk_vbox_new(FALSE, 5);
5971     gtk_container_add(GTK_CONTAINER(win), main_vb);
5972     gtk_container_set_border_width(GTK_CONTAINER(main_vb), 6);
5973
5974     main_tb = gtk_table_new(2, 2, FALSE);
5975     gtk_box_pack_start(GTK_BOX(main_vb), main_tb, FALSE, FALSE, 0);
5976     gtk_table_set_col_spacings(GTK_TABLE(main_tb), 10);
5977
5978     label = gtk_label_new(ep_strdup_printf("%s:", pref->title));
5979     gtk_table_attach_defaults(GTK_TABLE(main_tb), label, 0, 1, 1, 2);
5980     gtk_misc_set_alignment(GTK_MISC(label), 1.0f, 0.5f);
5981     if (pref->description)
5982         gtk_tooltips_set_tip(tooltips, label, pref->description, NULL);
5983
5984     entry = gtk_entry_new();
5985     gtk_table_attach_defaults(GTK_TABLE(main_tb), entry, 1, 2, 1, 2);
5986     gtk_entry_set_text(GTK_ENTRY(entry), value);
5987     if (pref->description)
5988         gtk_tooltips_set_tip(tooltips, entry, pref->description, NULL);
5989
5990     bbox = dlg_button_row_new(GTK_STOCK_CANCEL,GTK_STOCK_OK, NULL);
5991     gtk_box_pack_end(GTK_BOX(main_vb), bbox, FALSE, FALSE, 0);
5992
5993     ok_bt = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_OK);
5994     g_object_set_data (G_OBJECT(ok_bt), "module", module);
5995     g_object_set_data (G_OBJECT(ok_bt), "entry", entry);
5996     g_object_set_data (G_OBJECT(ok_bt), "pref", pref);
5997     g_signal_connect(ok_bt, "clicked", G_CALLBACK(menu_prefs_change_ok), win);
5998
5999     dlg_set_activate(entry, ok_bt);
6000
6001     cancel_bt = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CANCEL);
6002     g_signal_connect(cancel_bt, "clicked", G_CALLBACK(menu_prefs_change_cancel), win);
6003     window_set_cancel_button(win, cancel_bt, NULL);
6004
6005     gtk_widget_grab_default(ok_bt);
6006     gtk_widget_show_all(win);
6007     g_free(value);
6008 }
6009
6010 static guint
6011 add_protocol_prefs_menu (pref_t *pref, gpointer data)
6012 {
6013     GtkWidget *menu_preferences;
6014     GtkWidget *menu_item, *menu_sub_item, *sub_menu;
6015     GSList *group = NULL;
6016     module_t *module = data;
6017     const enum_val_t *enum_valp;
6018     gchar *label = NULL;
6019
6020     switch (pref->type) {
6021     case PREF_UINT:
6022         switch (pref->info.base) {
6023         case 8:
6024             label = g_strdup_printf ("%s: %o", pref->title, *pref->varp.uint);
6025             break;
6026         case 10:
6027             label = g_strdup_printf ("%s: %u", pref->title, *pref->varp.uint);
6028             break;
6029         case 16:
6030             label = g_strdup_printf ("%s: %x", pref->title, *pref->varp.uint);
6031             break;
6032         default:
6033             g_assert_not_reached();
6034             break;
6035         }
6036         menu_item = gtk_menu_item_new_with_label(label);
6037         g_object_set_data (G_OBJECT(menu_item), "module", module);
6038         g_signal_connect(menu_item, "activate", G_CALLBACK(menu_prefs_edit_dlg), pref);
6039         g_free (label);
6040         break;
6041     case PREF_BOOL:
6042         menu_item = gtk_check_menu_item_new_with_label(pref->title);
6043         gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM(menu_item), *pref->varp.boolp);
6044         g_object_set_data (G_OBJECT(menu_item), "module", module);
6045         g_signal_connect(menu_item, "activate", G_CALLBACK(menu_prefs_toggle_bool), pref->varp.boolp);
6046         break;
6047     case PREF_ENUM:
6048         menu_item = gtk_menu_item_new_with_label(pref->title);
6049         sub_menu = gtk_menu_new();
6050         gtk_menu_item_set_submenu (GTK_MENU_ITEM(menu_item), sub_menu);
6051         enum_valp = pref->info.enum_info.enumvals;
6052         while (enum_valp->name != NULL) {
6053             menu_sub_item = gtk_radio_menu_item_new_with_label(group, enum_valp->description);
6054             group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (menu_sub_item));
6055             if (enum_valp->value == *pref->varp.enump) {
6056                 gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM(menu_sub_item), TRUE);
6057             }
6058             g_object_set_data (G_OBJECT(menu_sub_item), "module", module);
6059             g_object_set_data (G_OBJECT(menu_sub_item), "enumval", GINT_TO_POINTER(enum_valp->value));
6060             g_signal_connect(menu_sub_item, "activate", G_CALLBACK(menu_prefs_change_enum), pref->varp.enump);
6061             gtk_menu_shell_append (GTK_MENU_SHELL(sub_menu), menu_sub_item);
6062             gtk_widget_show (menu_sub_item);
6063             enum_valp++;
6064         }
6065         break;
6066     case PREF_STRING:
6067         label = g_strdup_printf ("%s: %s", pref->title, *pref->varp.string);
6068         menu_item = gtk_menu_item_new_with_label(label);
6069         g_object_set_data (G_OBJECT(menu_item), "module", module);
6070         g_signal_connect(menu_item, "activate", G_CALLBACK(menu_prefs_edit_dlg), pref);
6071         g_free (label);
6072         break;
6073     case PREF_RANGE:
6074         label = g_strdup_printf ("%s: %s", pref->title, range_convert_range (*pref->varp.range));
6075         menu_item = gtk_menu_item_new_with_label(label);
6076         g_object_set_data (G_OBJECT(menu_item), "module", module);
6077         g_signal_connect(menu_item, "activate", G_CALLBACK(menu_prefs_edit_dlg), pref);
6078         g_free (label);
6079         break;
6080     case PREF_UAT:
6081         label = g_strdup_printf ("%s...", pref->title);
6082         menu_item = gtk_menu_item_new_with_label(label);
6083         g_signal_connect (menu_item, "activate", G_CALLBACK(uat_window_cb), pref->varp.uat);
6084         g_free (label);
6085         break;
6086     case PREF_STATIC_TEXT:
6087     case PREF_OBSOLETE:
6088     default:
6089         /* Nothing to add */
6090         return 0;
6091     }
6092
6093     menu_preferences = gtk_ui_manager_get_widget(ui_manager_tree_view_menu, "/TreeViewPopup/ProtocolPreferences");
6094     if(!menu_preferences)
6095         g_warning("menu_preferences Not found path:TreeViewPopup/ProtocolPreferences");
6096     sub_menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM(menu_preferences));
6097     gtk_menu_shell_append (GTK_MENU_SHELL(sub_menu), menu_item);
6098     gtk_widget_show (menu_item);
6099
6100     return 0;
6101 }
6102
6103 static void
6104 rebuild_protocol_prefs_menu (module_t *prefs_module_p, gboolean preferences)
6105 {
6106     GtkWidget *menu_preferences, *menu_item;
6107     GtkWidget *sub_menu;
6108     gchar *label;
6109
6110     menu_preferences = gtk_ui_manager_get_widget(ui_manager_tree_view_menu, "/TreeViewPopup/ProtocolPreferences");
6111     if (preferences) {
6112         sub_menu = gtk_menu_new();
6113         gtk_menu_item_set_submenu (GTK_MENU_ITEM(menu_preferences), sub_menu);
6114
6115         label = g_strdup_printf ("%s Preferences...", prefs_module_p->description);
6116         menu_item = gtk_image_menu_item_new_with_label (label);
6117         gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM(menu_item),
6118                                        gtk_image_new_from_stock(GTK_STOCK_PREFERENCES, GTK_ICON_SIZE_MENU));
6119         gtk_menu_shell_append (GTK_MENU_SHELL(sub_menu), menu_item);
6120         g_signal_connect_swapped(GTK_OBJECT(menu_item), "activate",
6121                                  G_CALLBACK(properties_cb), (GtkObject *) menu_item);
6122         gtk_widget_show (menu_item);
6123         g_free (label);
6124
6125         menu_item = gtk_menu_item_new();
6126         gtk_menu_shell_append (GTK_MENU_SHELL(sub_menu), menu_item);
6127         gtk_widget_show (menu_item);
6128
6129         prefs_pref_foreach(prefs_module_p, add_protocol_prefs_menu, prefs_module_p);
6130     } else {
6131         /* No preferences, remove sub menu */
6132         gtk_menu_item_set_submenu (GTK_MENU_ITEM(menu_preferences), NULL);
6133     }
6134
6135 }
6136
6137 #ifdef NEW_PACKET_LIST
6138 static void
6139 menu_visible_column_toggle (GtkWidget *w _U_, gpointer data)
6140 {
6141     new_packet_list_toggle_visible_column (GPOINTER_TO_INT(data));
6142 }
6143
6144 void
6145 rebuild_visible_columns_menu (void)
6146 {
6147     GtkWidget *menu_columns[2], *menu_item;
6148     GtkWidget *sub_menu;
6149     GList     *clp;
6150     fmt_data  *cfmt;
6151     gchar     *title;
6152     gint       i, col_id, cur_fmt;
6153 #ifdef MAIN_MENU_USE_UIMANAGER
6154     menu_columns[0] = gtk_ui_manager_get_widget(ui_manager_main_menubar, "/Menubar/ViewMenu/DisplayedColumns");
6155     if(! menu_columns[0]){
6156         fprintf (stderr, "Warning: couldn't find menu_columns[0] path=/Menubar/ViewMenu/DisplayedColumns");
6157     }
6158 #else
6159     menu_columns[0] = gtk_item_factory_get_widget(main_menu_factory, "/View/Displayed Columns");
6160 #endif /* MAIN_MENU_USE_UIMANAGER */
6161     menu_columns[1] = gtk_ui_manager_get_widget(ui_manager_packet_list_heading, "/PacketListHeadingPopup/DisplayedColumns");
6162     /* Debug */
6163     if(! menu_columns[1]){
6164         fprintf (stderr, "Warning: couldn't find menu_columns[1] path=/PacketListHeadingPopup/DisplayedColumns");
6165     }
6166
6167     for (i = 0; i < 2; i++) {
6168         sub_menu = gtk_menu_new();
6169         gtk_menu_item_set_submenu (GTK_MENU_ITEM(menu_columns[i]), sub_menu);
6170
6171         clp = g_list_first (prefs.col_list);
6172         col_id = 0;
6173         while (clp) {
6174             cfmt = (fmt_data *) clp->data;
6175             cur_fmt = get_column_format_from_str(cfmt->fmt);
6176             if (cur_fmt == COL_CUSTOM) {
6177                 title = g_strdup_printf ("%s  (%s)", cfmt->title, cfmt->custom_field);
6178             } else {
6179                 title = g_strdup_printf ("%s  (%s)", cfmt->title, col_format_desc (cur_fmt));
6180             }
6181             menu_item = gtk_check_menu_item_new_with_label(title);
6182             g_free (title);
6183             gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM(menu_item), cfmt->visible);
6184             g_signal_connect(menu_item, "activate", G_CALLBACK(menu_visible_column_toggle), GINT_TO_POINTER(col_id));
6185             gtk_menu_shell_append (GTK_MENU_SHELL(sub_menu), menu_item);
6186             gtk_widget_show (menu_item);
6187             clp = g_list_next (clp);
6188             col_id++;
6189         }
6190
6191         menu_item = gtk_menu_item_new();
6192         gtk_menu_shell_append (GTK_MENU_SHELL(sub_menu), menu_item);
6193         gtk_widget_show (menu_item);
6194
6195         menu_item = gtk_menu_item_new_with_label ("Display All");
6196         gtk_menu_shell_append (GTK_MENU_SHELL(sub_menu), menu_item);
6197         g_signal_connect(menu_item, "activate", G_CALLBACK(packet_list_heading_activate_all_columns), NULL);
6198         gtk_widget_show (menu_item);
6199     }
6200 }
6201 #endif
6202
6203 void
6204 menus_set_column_resolved (gboolean resolved, gboolean can_resolve)
6205 {
6206     GtkWidget *menu;
6207
6208     menu = gtk_ui_manager_get_widget(ui_manager_packet_list_heading, "/PacketListHeadingPopup/ShowResolved");
6209     if(!menu){
6210         fprintf (stderr, "Warning: couldn't find menu path=/PacketListHeadingPopup/ShowResolved");
6211     }
6212     g_object_set_data(G_OBJECT(menu), "skip-update", (void *)1);
6213     gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), resolved && can_resolve);
6214     set_menu_sensitivity(ui_manager_packet_list_heading, "/PacketListHeadingPopup/ShowResolved", can_resolve);
6215     g_object_set_data(G_OBJECT(menu), "skip-update", NULL);
6216 }
6217
6218 void
6219 menus_set_column_align_default (gboolean right_justify)
6220 {
6221     GtkWidget   *submenu, *menu_item_child;
6222     GList       *child_list, *child_list_item;
6223     const gchar *menu_item_name;
6224     size_t       menu_item_len;
6225
6226     /* get the submenu container item */
6227     submenu = gtk_ui_manager_get_widget (ui_manager_packet_list_heading, "/PacketListHeadingPopup");
6228     if(!submenu){
6229         fprintf (stderr, "Warning: couldn't find submenu path=/PacketListHeadingPopup");
6230     }
6231
6232     /* find the corresponding menu items to update */
6233     child_list = gtk_container_get_children(GTK_CONTAINER(submenu));
6234     child_list_item = child_list;
6235     while(child_list_item) {
6236         menu_item_child = (GTK_BIN(child_list_item->data))->child;
6237         if (menu_item_child != NULL) {
6238             menu_item_name = gtk_label_get_text(GTK_LABEL(menu_item_child));
6239             menu_item_len = strlen (menu_item_name);
6240             if(strncmp(menu_item_name, "Align Left", 10) == 0) {
6241                 if (!right_justify && menu_item_len == 10) {
6242                     gtk_label_set_text(GTK_LABEL(menu_item_child), "Align Left\t(default)");
6243                 } else if (right_justify && menu_item_len > 10) {
6244                     gtk_label_set_text(GTK_LABEL(menu_item_child), "Align Left");
6245                 }
6246             } else if (strncmp (menu_item_name, "Align Right", 11) == 0) {
6247                 if (right_justify && menu_item_len == 11) {
6248                     gtk_label_set_text(GTK_LABEL(menu_item_child), "Align Right\t(default)");
6249                 } else if (!right_justify && menu_item_len > 11) {
6250                     gtk_label_set_text(GTK_LABEL(menu_item_child), "Align Right");
6251                 }
6252             }
6253         }
6254         child_list_item = g_list_next(child_list_item);
6255     }
6256     g_list_free(child_list);
6257 }
6258
6259 void
6260 set_menus_for_selected_tree_row(capture_file *cf)
6261 {
6262     gboolean properties;
6263     gint id;
6264
6265     if (cf->finfo_selected != NULL) {
6266         header_field_info *hfinfo = cf->finfo_selected->hfinfo;
6267         const char *abbrev;
6268         char *prev_abbrev;
6269
6270         if (hfinfo->parent == -1) {
6271             abbrev = hfinfo->abbrev;
6272             id = (hfinfo->type == FT_PROTOCOL) ? proto_get_id((protocol_t *)hfinfo->strings) : -1;
6273         } else {
6274             abbrev = proto_registrar_get_abbrev(hfinfo->parent);
6275             id = hfinfo->parent;
6276         }
6277         properties = prefs_is_registered_protocol(abbrev);
6278         set_menu_sensitivity(ui_manager_tree_view_menu,
6279                              "/TreeViewPopup/GotoCorrespondingPacket", hfinfo->type == FT_FRAMENUM);
6280         set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/Copy",
6281                              TRUE);
6282         set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/Copy/AsFilter",
6283                              proto_can_match_selected(cf->finfo_selected, cf->edt));
6284         set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/ApplyasColumn",
6285                              hfinfo->type != FT_NONE);
6286         set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/ApplyAsFilter",
6287                              proto_can_match_selected(cf->finfo_selected, cf->edt));
6288         set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/PrepareaFilter",
6289                              proto_can_match_selected(cf->finfo_selected, cf->edt));
6290         set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/ColorizewithFilter",
6291                              proto_can_match_selected(cf->finfo_selected, cf->edt));
6292         set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/ProtocolPreferences",
6293                              properties);
6294         set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/DisableProtocol",
6295                              (id == -1) ? FALSE : proto_can_toggle_protocol(id));
6296         set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/ExpandSubtrees",
6297                              cf->finfo_selected->tree_type != -1);
6298         set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/WikiProtocolPage",
6299                              (id == -1) ? FALSE : TRUE);
6300         set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/FilterFieldReference",
6301                              (id == -1) ? FALSE : TRUE);
6302 #ifdef MAIN_MENU_USE_UIMANAGER
6303         set_menu_sensitivity(ui_manager_tree_view_menu,
6304                              "/Menubar/MenuFile/Export/SelectedPacketBytes", TRUE);
6305         set_menu_sensitivity(ui_manager_tree_view_menu,
6306                              "/Menubar/MenuGo/GotoCorrespondingPacket", hfinfo->type == FT_FRAMENUM);
6307         set_menu_sensitivity(ui_manager_tree_view_menu, "/Menubar/MenuEdit/Copy/Description",
6308                              proto_can_match_selected(cf->finfo_selected, cf->edt));
6309         set_menu_sensitivity(ui_manager_tree_view_menu, "/Menubar/MenuEdit/Copy/Fieldname",
6310                              proto_can_match_selected(cf->finfo_selected, cf->edt));
6311         set_menu_sensitivity(ui_manager_tree_view_menu, "/Menubar/MenuEdit/Copy/Value",
6312                              proto_can_match_selected(cf->finfo_selected, cf->edt));
6313         set_menu_sensitivity(ui_manager_tree_view_menu, "/Menubar/MenuEdit/Copy/AsFilter",
6314                              proto_can_match_selected(cf->finfo_selected, cf->edt));
6315         set_menu_sensitivity(ui_manager_tree_view_menu, "/Menubar/MenuAnalyze/ApplyasColumn",
6316                              hfinfo->type != FT_NONE);
6317         set_menu_sensitivity(ui_manager_tree_view_menu, "/Menubar/MenuAnalyze/ApplyAsFilter",
6318                              proto_can_match_selected(cf->finfo_selected, cf->edt));
6319         set_menu_sensitivity(ui_manager_tree_view_menu, "/Menubar/MenuAnalyze/PrepareaFilter",
6320                              proto_can_match_selected(cf->finfo_selected, cf->edt));
6321         set_menu_sensitivity(ui_manager_tree_view_menu, "/Menubar/MenuView/ExpandSubtrees",
6322                              cf->finfo_selected->tree_type != -1);
6323 #else
6324         set_menu_sensitivity_old(
6325                              "/File/Export/Selected Packet Bytes...", TRUE);
6326         set_menu_sensitivity_old(
6327                              "/Go/Go to Corresponding Packet", hfinfo->type == FT_FRAMENUM);
6328         set_menu_sensitivity_old("/Edit/Copy/Description",
6329                              proto_can_match_selected(cf->finfo_selected, cf->edt));
6330         set_menu_sensitivity_old("/Edit/Copy/Fieldname",
6331                              proto_can_match_selected(cf->finfo_selected, cf->edt));
6332         set_menu_sensitivity_old("/Edit/Copy/Value",
6333                              proto_can_match_selected(cf->finfo_selected, cf->edt));
6334         set_menu_sensitivity_old("/Edit/Copy/As Filter",
6335                              proto_can_match_selected(cf->finfo_selected, cf->edt));
6336         set_menu_sensitivity_old("/Analyze/Apply as Column",
6337                              hfinfo->type != FT_NONE);
6338         set_menu_sensitivity_old("/Analyze/Apply as Filter",
6339                              proto_can_match_selected(cf->finfo_selected, cf->edt));
6340         set_menu_sensitivity_old("/Analyze/Prepare a Filter",
6341                              proto_can_match_selected(cf->finfo_selected, cf->edt));
6342         set_menu_sensitivity_old("/View/Expand Subtrees",
6343                              cf->finfo_selected->tree_type != -1);
6344 #endif
6345         prev_abbrev = g_object_get_data(G_OBJECT(ui_manager_tree_view_menu), "menu_abbrev");
6346         if (!prev_abbrev || (strcmp (prev_abbrev, abbrev) != 0)) {
6347             /* No previous protocol or protocol changed - update Protocol Preferences menu */
6348             module_t *prefs_module_p = prefs_find_module(abbrev);
6349             rebuild_protocol_prefs_menu (prefs_module_p, properties);
6350
6351             g_object_set_data(G_OBJECT(ui_manager_tree_view_menu), "menu_abbrev", g_strdup(abbrev));
6352             g_free (prev_abbrev);
6353         }
6354     } else {
6355         set_menu_sensitivity(ui_manager_tree_view_menu,
6356                              "/TreeViewPopup/GotoCorrespondingPacket", FALSE);
6357         set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/Copy", FALSE);
6358         set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/ApplyasColumn", FALSE);
6359         set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/ApplyAsFilter", FALSE);
6360         set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/PrepareaFilter", FALSE);
6361         set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/ColorizewithFilter", FALSE);
6362         set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/ProtocolPreferences",
6363                              FALSE);
6364         set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/DisableProtocol", FALSE);
6365         set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/ExpandSubtrees", FALSE);
6366         set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/WikiProtocolPage",
6367                              FALSE);
6368         set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/FilterFieldReference",
6369                              FALSE);
6370 #ifdef MAIN_MENU_USE_UIMANAGER
6371         set_menu_sensitivity(ui_manager_main_menubar,
6372                              "/Menubar/FileMenu/Export/SelectedPacketBytes", FALSE);
6373         set_menu_sensitivity(ui_manager_main_menubar,
6374                              "/Menubar/GoMenu/GotoCorrespondingPacket", FALSE);
6375         set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/EditMenu/Copy/Description", FALSE);
6376         set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/EditMenu/Copy/Fieldname", FALSE);
6377         set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/EditMenu/Copy/Value", FALSE);
6378         set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/EditMenu/Copy/AsFilter", FALSE);
6379         set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/AnalyzeMenu/ApplyasColumn", FALSE);
6380         set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/AnalyzeMenu/ApplyAsFilter", FALSE);
6381         set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/AnalyzeMenu/PrepareaFilter", FALSE);
6382         set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/ViewMenu/ExpandSubtrees", FALSE);
6383 #else
6384         set_menu_sensitivity_old("/File/Export/Selected Packet Bytes...", FALSE);
6385         set_menu_sensitivity_old("/Go/Go to Corresponding Packet", FALSE);
6386         set_menu_sensitivity_old("/Edit/Copy/Description", FALSE);
6387         set_menu_sensitivity_old("/Edit/Copy/Fieldname", FALSE);
6388         set_menu_sensitivity_old("/Edit/Copy/Value", FALSE);
6389         set_menu_sensitivity_old("/Edit/Copy/As Filter", FALSE);
6390         set_menu_sensitivity_old("/Analyze/Apply as Column", FALSE);
6391         set_menu_sensitivity_old("/Analyze/Apply as Filter", FALSE);
6392         set_menu_sensitivity_old("/Analyze/Prepare a Filter", FALSE);
6393         set_menu_sensitivity_old("/View/Expand Subtrees", FALSE);
6394 #endif /* MAIN_MENU_USE_UIMANAGER */
6395     }
6396
6397     walk_menu_tree_for_selected_tree_row(tap_menu_tree_root, cf->finfo_selected);
6398 }
6399
6400 void set_menus_for_packet_history(gboolean back_history, gboolean forward_history) {
6401 #ifdef MAIN_MENU_USE_UIMANAGER
6402     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/GoMenu/Back", back_history);
6403     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/GoMenu/Forward", forward_history);
6404 #else
6405     set_menu_sensitivity_old("/Go/Back", back_history);
6406     set_menu_sensitivity_old("/Go/Forward", forward_history);
6407 #endif /* MAIN_MENU_USE_UIMANAGER */
6408     set_toolbar_for_packet_history(back_history, forward_history);
6409 }
6410
6411
6412 void set_menus_for_file_set(gboolean file_set, gboolean previous_file, gboolean next_file) {
6413 #ifdef MAIN_MENU_USE_UIMANAGER
6414     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/FileMenu/Set/ListFiles", file_set);
6415     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/FileMenu/Set/PreviousFile", previous_file);
6416     set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/FileMenu/Set/NextFile", next_file);
6417 #else
6418     set_menu_sensitivity_old("/File/File Set/List Files", file_set);
6419     set_menu_sensitivity_old("/File/File Set/Previous File", previous_file);
6420     set_menu_sensitivity_old("/File/File Set/Next File", next_file);
6421 #endif /* MAIN_MENU_USE_UIMANAGER */
6422 }
6423
6424 GtkWidget *menus_get_profiles_menu (void)
6425 {
6426     return gtk_ui_manager_get_widget(ui_manager_statusbar_profiles_menu, "/ProfilesMenuPopup/Change");
6427 }
6428
6429 void set_menus_for_profiles(gboolean default_profile)
6430 {
6431     set_menu_sensitivity(ui_manager_statusbar_profiles_menu, "/ProfilesMenuPopup/Delete", !default_profile);
6432     set_menu_sensitivity(ui_manager_statusbar_profiles_menu, "/ProfilesMenuPopup/Rename", !default_profile);
6433 }
6434
6435 /*
6436  * Editor modelines
6437  *
6438  * Local Variables:
6439  * c-basic-offset: 4
6440  * tab-width: 8
6441  * indent-tabs-mode: nil
6442  * End:
6443  *
6444  * ex: set shiftwidth=4 tabstop=8 expandtab
6445  * :indentSize=4:tabSize=8:noTabs=true:
6446  */
6447