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