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