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