Fix the wireless settings button for AirPCap devices in the
[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 #ifdef HAVE_CONFIG_H
25 # include "config.h"
26 #endif
27
28 #ifndef MAIN_MENU_USE_UIMANAGER
29 /* UIManager code is in main_menubar.c */
30
31 #undef GTK_DISABLE_DEPRECATED
32
33 #include <gtk/gtk.h>
34
35 #include <stdio.h>
36 #include <string.h>
37
38 #include <epan/packet.h>
39 #include <epan/addr_resolv.h>
40 #include <epan/prefs.h>
41 #include <epan/prefs-int.h>
42 #include <epan/tap.h>
43 #include <epan/timestamp.h>
44 #include <epan/etypes.h>
45 #include <epan/ipproto.h>
46 #include <epan/dissector_filters.h>
47 #include <epan/strutil.h>
48 #include <epan/plugins.h>
49 #include <epan/epan_dissect.h>
50 #include <epan/column.h>
51
52 #include "../print.h"
53 #include "../ui_util.h"
54 #include "../simple_dialog.h"
55 #include "../main_statusbar.h"
56 #include "../color_filters.h"
57 #include "../stat_menu.h"
58 #include "../u3.h"
59
60 #include "gtk/about_dlg.h"
61 #include "gtk/capture_dlg.h"
62 #include "gtk/capture_if_dlg.h"
63 #include "gtk/color_dlg.h"
64 #include "gtk/filter_dlg.h"
65 #include "gtk/profile_dlg.h"
66 #include "gtk/dlg_utils.h"
67 #include "gtk/capture_file_dlg.h"
68 #include "gtk/fileset_dlg.h"
69 #include "gtk/file_import_dlg.h"
70 #include "gtk/find_dlg.h"
71 #include "gtk/goto_dlg.h"
72 #include "gtk/summary_dlg.h"
73 #include "gtk/prefs_dlg.h"
74 #include "gtk/packet_win.h"
75 #include "gtk/follow_tcp.h"
76 #include "gtk/follow_udp.h"
77 #include "gtk/follow_ssl.h"
78 #include "gtk/decode_as_dlg.h"
79 #include "gtk/help_dlg.h"
80 #include "gtk/supported_protos_dlg.h"
81 #include "gtk/proto_dlg.h"
82 #include "gtk/proto_hier_stats_dlg.h"
83 #include "gtk/keys.h"
84 #include "gtk/stock_icons.h"
85 #include "gtk/gtkglobals.h"
86 #include "gtk/recent.h"
87 #include "gtk/main_proto_draw.h"
88 #include "gtk/conversations_table.h"
89 #include "gtk/hostlist_table.h"
90 #include "gtk/packet_history.h"
91 #include "gtk/sctp_stat.h"
92 #include "gtk/firewall_dlg.h"
93 #include "gtk/macros_dlg.h"
94 #include "gtk/export_object.h"
95 #include "epan/dissectors/packet-ssl-utils.h"
96 #include "gtk/export_sslkeys.h"
97 #include "gtk/gui_stat_menu.h"
98 #include "gtk/main.h"
99 #include "gtk/menus.h"
100 #include "gtk/main_toolbar.h"
101 #include "gtk/main_welcome.h"
102 #include "gtk/uat_gui.h"
103 #include "gtk/gui_utils.h"
104 #include "gtk/manual_addr_resolv.h"
105 #include "gtk/proto_help.h"
106 #include "gtk/dissector_tables_dlg.h"
107 #include "gtk/utf8_entities.h"
108 #include "gtk/expert_comp_dlg.h"
109 #include "gtk/time_shift_dlg.h"
110
111 #include "gtk/new_packet_list.h"
112
113 #ifdef HAVE_LIBPCAP
114 #include "capture_opts.h"
115 #include "gtk/capture_globals.h"
116 #endif
117 #ifdef HAVE_IGE_MAC_INTEGRATION
118 #include <ige-mac-menu.h>
119 #endif
120
121 #ifdef HAVE_GTKOSXAPPLICATION
122 #include <igemacintegration/gtkosxapplication.h>
123 #endif
124
125 static int initialize = TRUE;
126 static GtkItemFactory *main_menu_factory = NULL;
127 static GtkUIManager *ui_manager_packet_list_heading = NULL;
128 static GtkUIManager *ui_manager_packet_list_menu = NULL;
129 static GtkUIManager *ui_manager_tree_view_menu = NULL;
130 static GtkUIManager *ui_manager_bytes_menu = NULL;
131 static GtkUIManager *ui_manager_statusbar_profiles_menu = NULL;
132 static GSList *popup_menu_list = NULL;
133
134 static GtkAccelGroup *grp;
135
136 typedef struct _menu_item {
137     gint          group;
138     const char   *gui_path;
139     const char   *name;
140     const char   *stock_id;
141     const char   *label;
142     const char   *accelerator;
143     const gchar  *tooltip;
144     GtkItemFactoryCallback callback;
145     gboolean enabled;
146     gpointer callback_data;
147     gboolean (*selected_packet_enabled)(frame_data *, epan_dissect_t *, gpointer callback_data);
148     gboolean (*selected_tree_row_enabled)(field_info *, gpointer callback_data);
149     GList *children;
150 } menu_item_t;
151
152 static GList *tap_menu_tree_root = NULL;
153
154 GtkWidget *popup_menu_object;
155
156
157 #define GTK_MENU_FUNC(a) ((GtkItemFactoryCallback)(a))
158
159 static void merge_all_tap_menus(GList *node);
160
161 static void menus_init(void);
162 static void set_menu_sensitivity (GtkUIManager *ui_manager, const gchar *, gint);
163 static void clear_menu_recent_capture_file_cmd_cb(GtkWidget *w, gpointer unused _U_);
164 static void set_menu_sensitivity_old (const gchar *, gint);
165 static void show_hide_cb(GtkWidget *w, gpointer data, gint action);
166 static void timestamp_format_cb(GtkWidget *w, gpointer d, gint action);
167 static void timestamp_precision_cb(GtkWidget *w, gpointer d, gint action);
168 static void timestamp_seconds_time_cb(GtkWidget *w, gpointer d, gint action);
169 static void name_resolution_cb(GtkWidget *w, gpointer d, gint action);
170 #ifdef HAVE_LIBPCAP
171 static void auto_scroll_live_cb(GtkWidget *w, gpointer d);
172 #endif
173 static void colorize_cb(GtkWidget *w, gpointer d);
174
175
176 /*  As a general GUI guideline, we try to follow the Gnome Human Interface Guidelines, which can be found at:
177     http://developer.gnome.org/projects/gup/hig/1.0/index.html
178
179 Please note: there are some differences between the Gnome HIG menu suggestions and our implementation:
180
181 File/Open Recent:   the Gnome HIG suggests putting the list of recently used files as elements into the File menuitem.
182                     As this is ok for only a few items, this will become unhandy for 10 or even more list entries.
183                     For this reason, we use a submenu for this.
184
185 File/Close:         the Gnome HIG suggests putting this item just above the Quit item.
186                     This results in unintuitive behaviour as both Close and Quit items are very near together.
187                     By putting the Close item near the open item(s), it better suggests that it will close the
188                     currently opened/captured file only.
189 */
190
191 typedef enum {
192     SHOW_HIDE_MAIN_TOOLBAR = 1,
193     SHOW_HIDE_FILTER_TOOLBAR,
194     SHOW_HIDE_AIRPCAP_TOOLBAR,
195     SHOW_HIDE_STATUSBAR,
196     SHOW_HIDE_PACKET_LIST,
197     SHOW_HIDE_TREE_VIEW,
198     SHOW_HIDE_BYTE_VIEW
199 } show_hide_values_e;
200
201 typedef enum {
202     CONV_ETHER = 1,
203     CONV_IP,
204     CONV_TCP,
205     CONV_UDP,
206     CONV_CBA
207 } conv_values_e;
208
209 static char *
210 build_conversation_filter(int action, gboolean show_dialog)
211 {
212     packet_info *pi = &cfile.edt->pi;
213     char        *buf;
214
215
216     switch(action) {
217     case(CONV_CBA):
218         if (pi->profinet_type == 0) {
219             if (show_dialog) {
220                 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
221                     "Error filtering conversation.  Please make\n"
222                     "sure you have a PROFINET CBA packet selected.");
223             }
224             return NULL;
225         }
226
227         if( pi->net_src.type == AT_IPv4 && pi->net_dst.type == AT_IPv4
228         && pi->ipproto == IP_PROTO_TCP ) {
229             /* IPv4 */
230             switch(pi->profinet_type) {
231             case(1):
232                 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)",
233                     ip_to_str( pi->net_dst.data),
234                     ip_to_str( pi->net_src.data),
235                     ip_to_str( pi->net_src.data),
236                     ip_to_str( pi->net_dst.data));
237                 break;
238             case(2):
239                 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)",
240                     ip_to_str( pi->net_src.data),
241                     ip_to_str( pi->net_dst.data),
242                     ip_to_str( pi->net_dst.data),
243                     ip_to_str( pi->net_src.data));
244                 break;
245             case(3):
246                 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)",
247                     ip_to_str( pi->net_dst.data),
248                     ip_to_str( pi->net_src.data),
249                     ip_to_str( pi->net_src.data),
250                     ip_to_str( pi->net_dst.data));
251                 break;
252             case(4):
253                 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)",
254                     ip_to_str( pi->net_src.data),
255                     ip_to_str( pi->net_dst.data),
256                     ip_to_str( pi->net_dst.data),
257                     ip_to_str( pi->net_src.data));
258                 break;
259             default:
260                 return NULL;
261             }
262         } else {
263             return NULL;
264         }
265         break;
266     case(CONV_TCP):
267         if (pi->ipproto != IP_PROTO_TCP) {
268             if (show_dialog) {
269                 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
270                     "Error filtering conversation.  Please make\n"
271                     "sure you have a TCP packet selected.");
272             }
273             return NULL;
274         }
275
276         if( pi->net_src.type == AT_IPv4 && pi->net_dst.type == AT_IPv4 ) {
277             /* TCP over IPv4 */
278             buf = g_strdup_printf("(ip.addr eq %s and ip.addr eq %s) and (tcp.port eq %d and tcp.port eq %d)",
279                 ip_to_str( pi->net_src.data),
280                 ip_to_str( pi->net_dst.data),
281                 pi->srcport, pi->destport );
282         } else if( pi->net_src.type == AT_IPv6 && pi->net_dst.type == AT_IPv6 ) {
283             /* TCP over IPv6 */
284             buf = g_strdup_printf("(ipv6.addr eq %s and ipv6.addr eq %s) and (tcp.port eq %d and tcp.port eq %d)",
285                 ip6_to_str((const struct e_in6_addr *)pi->net_src.data),
286                 ip6_to_str((const struct e_in6_addr *)pi->net_dst.data),
287                 pi->srcport, pi->destport );
288         } else {
289             return NULL;
290         }
291         break;
292     case(CONV_UDP):
293         if (pi->ipproto != IP_PROTO_UDP) {
294             if (show_dialog) {
295                 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
296                     "Error filtering conversation.  Please make\n"
297                     "sure you have a UDP packet selected.");
298             }
299             return NULL;
300         }
301
302         if( pi->net_src.type == AT_IPv4 && pi->net_dst.type == AT_IPv4 ) {
303             /* UDP over IPv4 */
304             buf = g_strdup_printf("(ip.addr eq %s and ip.addr eq %s) and (udp.port eq %d and udp.port eq %d)",
305                 ip_to_str( pi->net_src.data),
306                 ip_to_str( pi->net_dst.data),
307                 pi->srcport, pi->destport );
308         } else if( pi->net_src.type == AT_IPv6 && pi->net_dst.type == AT_IPv6 ) {
309             /* UDP over IPv6 */
310             buf = g_strdup_printf("(ipv6.addr eq %s and ipv6.addr eq %s) and (udp.port eq %d and udp.port eq %d)",
311                 ip6_to_str((const struct e_in6_addr *)pi->net_src.data),
312                 ip6_to_str((const struct e_in6_addr *)pi->net_dst.data),
313                 pi->srcport, pi->destport );
314         } else {
315             return NULL;
316         }
317         break;
318     case(CONV_IP):
319         if ((pi->ethertype != ETHERTYPE_IP) && (pi->ethertype != ETHERTYPE_IPv6)) {
320             if (show_dialog) {
321                 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
322                     "Error filtering conversation.  Please make\n"
323                     "sure you have a IP packet selected.");
324             }
325             return NULL;
326         }
327
328         if( pi->net_src.type == AT_IPv4 && pi->net_dst.type == AT_IPv4 ) {
329             /* IPv4 */
330             buf = g_strdup_printf("ip.addr eq %s and ip.addr eq %s",
331                 ip_to_str( pi->net_src.data),
332                 ip_to_str( pi->net_dst.data));
333         } else if( pi->net_src.type == AT_IPv6 && pi->net_dst.type == AT_IPv6 ) {
334             /* IPv6 */
335             buf = g_strdup_printf("ipv6.addr eq %s and ipv6.addr eq %s",
336                 ip6_to_str((const struct e_in6_addr *)pi->net_src.data),
337                 ip6_to_str((const struct e_in6_addr *)pi->net_dst.data));
338         } else {
339             return NULL;
340         }
341         break;
342     case(CONV_ETHER):
343         /* XXX - is this the right way to check for Ethernet? */
344         /* check for the data link address type */
345         /* (ethertype will be 0 when used as length field) */
346         if (pi->dl_src.type != AT_ETHER) {
347             if (show_dialog) {
348                 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
349                     "Error filtering conversation.  Please make\n"
350                     "sure you have a Ethernet packet selected.");
351             }
352             return NULL;
353         }
354
355         if( pi->dl_src.type == AT_ETHER && pi->dl_dst.type == AT_ETHER ) {
356             /* Ethernet */
357             buf = g_strdup_printf("eth.addr eq %s and eth.addr eq %s",
358                 ether_to_str( pi->dl_src.data),
359                 ether_to_str( pi->dl_dst.data));
360         } else {
361             return NULL;
362         }
363         break;
364     default:
365         return NULL;
366     }
367
368     return buf;
369 }
370
371 static void
372 new_window_cb(GtkWidget *widget)
373 {
374         new_packet_window(widget, FALSE);
375 }
376
377 #ifdef WANT_PACKET_EDITOR
378 static void
379 edit_window_cb(GtkWidget *widget)
380 {
381         new_packet_window(widget, TRUE);
382 }
383 #endif
384
385 static void
386 conversation_cb(GtkAction *a _U_, gpointer data _U_, int action)
387 {
388     gchar       *filter;
389     GtkWidget   *filter_te;
390
391     if (cfile.current_frame) {
392         /* create a filter-string based on the selected packet and action */
393         filter = build_conversation_filter(action, TRUE);
394
395         /* Run the display filter so it goes in effect - even if it's the
396         same as the previous display filter. */
397         filter_te = gtk_bin_get_child(GTK_BIN(g_object_get_data(G_OBJECT(top_level), E_DFILTER_CM_KEY)));
398
399         gtk_entry_set_text(GTK_ENTRY(filter_te), filter);
400         main_filter_packets(&cfile, filter, TRUE);
401
402         g_free(filter);
403     }
404 }
405
406 static void
407 colorize_conversation_cb(GtkWidget * w _U_, gpointer data _U_, int action)
408 {
409     gchar        *filter = NULL;
410
411     if( (action>>8) == 255 ) {
412         color_filters_reset_tmp();
413         new_packet_list_colorize_packets();
414     } else if (cfile.current_frame) {
415         if( (action&0xff) == 0 ) {
416             /* colorize_conversation_cb was called from the window-menu
417              * or through an accelerator key. Try to build a conversation
418              * filter in the order TCP, UDP, IP, Ethernet and apply the
419              * coloring */
420             filter = build_conversation_filter(CONV_TCP,FALSE);
421             if( filter == NULL )
422                 filter = build_conversation_filter(CONV_UDP,FALSE);
423             if( filter == NULL )
424                 filter = build_conversation_filter(CONV_IP,FALSE);
425             if( filter == NULL )
426                 filter = build_conversation_filter(CONV_ETHER,FALSE);
427             if( filter == NULL ) {
428                 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "Unable to build conversation filter.");
429                 return;
430             }
431         } else {
432             /* create a filter-string based on the selected packet and action */
433             filter = build_conversation_filter(action&0xff, TRUE);
434         }
435
436         if( (action>>8) == 0) {
437             /* Open the "new coloring filter" dialog with the filter */
438             color_display_with_filter(filter);
439         } else {
440             /* Set one of the temporary coloring filters */
441             color_filters_set_tmp((guint8)(action>>8),filter,FALSE);
442             new_packet_list_colorize_packets();
443         }
444
445         g_free(filter);
446     }
447 }
448
449 static void
450 goto_conversation_frame(gboolean dir)
451 {
452         gchar *filter;
453         dfilter_t *dfcode = NULL;
454         gboolean found_packet=FALSE;
455
456         filter = build_conversation_filter(CONV_TCP,FALSE);
457         if( filter == NULL )
458             filter = build_conversation_filter(CONV_UDP,FALSE);
459         if( filter == NULL )
460             filter = build_conversation_filter(CONV_IP,FALSE);
461         if( filter == NULL ) {
462             statusbar_push_temporary_msg("Unable to build conversation filter.");
463             g_free(filter);
464             return;
465         }
466
467         if (!dfilter_compile(filter, &dfcode)) {
468             /* The attempt failed; report an error. */
469             statusbar_push_temporary_msg("Error compiling filter for this conversation.");
470             g_free(filter);
471             return;
472         }
473
474         found_packet = cf_find_packet_dfilter(&cfile, dfcode, dir);
475
476         if (!found_packet) {
477             /* We didn't find a packet */
478             statusbar_push_temporary_msg("No previous/next packet in conversation.");
479         }
480
481         dfilter_free(dfcode);
482         g_free(filter);
483 }
484
485 static void
486 goto_next_frame_conversation_cb(GtkWidget *w _U_, gpointer d _U_)
487 {
488     goto_conversation_frame(FALSE);
489 }
490
491 static void
492 goto_previous_frame_conversation_cb(GtkWidget *w _U_, gpointer d _U_)
493 {
494     goto_conversation_frame(TRUE);
495 }
496
497
498
499 /*Apply a filter */
500
501 static void
502 tree_view_menu_apply_selected_cb(GtkAction *action _U_, gpointer user_data)
503 {
504         GtkWidget *widget = gtk_ui_manager_get_widget(ui_manager_tree_view_menu, "/TreeViewPopup/ApplyAsFilter/Selected");
505         match_selected_ptree_cb( widget , user_data, MATCH_SELECTED_REPLACE|MATCH_SELECTED_APPLY_NOW);
506 }
507
508 static void
509 tree_view_menu_apply_not_selected_cb(GtkAction *action _U_, gpointer user_data)
510 {
511         GtkWidget *widget = gtk_ui_manager_get_widget(ui_manager_tree_view_menu, "/TreeViewPopup/ApplyAsFilter/NotSelected");
512         match_selected_ptree_cb( widget , user_data, MATCH_SELECTED_NOT|MATCH_SELECTED_APPLY_NOW);
513 }
514
515 static void
516 tree_view_menu_apply_and_selected_cb(GtkAction *action _U_, gpointer user_data)
517 {
518         GtkWidget *widget = gtk_ui_manager_get_widget(ui_manager_tree_view_menu, "/TreeViewPopup/ApplyAsFilter/AndSelected");
519         match_selected_ptree_cb( widget , user_data, MATCH_SELECTED_AND|MATCH_SELECTED_APPLY_NOW);
520 }
521
522 static void
523 tree_view_menu_apply_or_selected_cb(GtkAction *action _U_, gpointer user_data)
524 {
525         GtkWidget *widget = gtk_ui_manager_get_widget(ui_manager_tree_view_menu, "/TreeViewPopup/ApplyAsFilter/OrSelected");
526         match_selected_ptree_cb( widget , user_data, MATCH_SELECTED_OR|MATCH_SELECTED_APPLY_NOW);
527 }
528
529 static void
530 tree_view_menu_apply_and_not_selected_cb(GtkAction *action _U_, gpointer user_data)
531 {
532         GtkWidget *widget = gtk_ui_manager_get_widget(ui_manager_tree_view_menu, "/TreeViewPopup/ApplyAsFilter/AndNotSelected");
533         match_selected_ptree_cb( widget , user_data, MATCH_SELECTED_AND_NOT|MATCH_SELECTED_APPLY_NOW);
534 }
535
536 static void
537 tree_view_menu_apply_or_not_selected_cb(GtkAction *action _U_, gpointer user_data)
538 {
539         GtkWidget *widget = gtk_ui_manager_get_widget(ui_manager_tree_view_menu, "/TreeViewPopup/ApplyAsFilter/OrNotSelected");
540         match_selected_ptree_cb( widget , user_data,MATCH_SELECTED_OR_NOT|MATCH_SELECTED_APPLY_NOW);
541 }
542 /* Prepare a filter */
543 static void
544 tree_view_menu_prepare_selected_cb(GtkAction *action _U_, gpointer user_data)
545 {
546         GtkWidget *widget = gtk_ui_manager_get_widget(ui_manager_tree_view_menu, "/TreeViewPopup/PrepareaFilter/Selected");
547         match_selected_ptree_cb( widget , user_data, MATCH_SELECTED_REPLACE);
548 }
549
550 static void
551 tree_view_menu_prepare_not_selected_cb(GtkAction *action _U_, gpointer user_data)
552 {
553         GtkWidget *widget = gtk_ui_manager_get_widget(ui_manager_tree_view_menu, "/TreeViewPopup/PrepareaFilter/NotSelected");
554         match_selected_ptree_cb( widget , user_data, MATCH_SELECTED_NOT);
555 }
556
557 static void
558 tree_view_menu_prepare_and_selected_cb(GtkAction *action _U_, gpointer user_data)
559 {
560         GtkWidget *widget = gtk_ui_manager_get_widget(ui_manager_tree_view_menu, "/TreeViewPopup/PrepareaFilter/AndSelected");
561         match_selected_ptree_cb( widget , user_data, MATCH_SELECTED_AND);
562 }
563
564 static void
565 tree_view_menu_prepare_or_selected_cb(GtkAction *action _U_, gpointer user_data)
566 {
567         GtkWidget *widget = gtk_ui_manager_get_widget(ui_manager_tree_view_menu, "/TreeViewPopup/PrepareaFilter/OrSelected");
568         match_selected_ptree_cb( widget , user_data, MATCH_SELECTED_OR);
569 }
570
571 static void
572 tree_view_menu_prepare_and_not_selected_cb(GtkAction *action _U_, gpointer user_data)
573 {
574         GtkWidget *widget = gtk_ui_manager_get_widget(ui_manager_tree_view_menu, "/TreeViewPopup/PrepareaFilter/AndNotSelected");
575         match_selected_ptree_cb( widget , user_data, MATCH_SELECTED_AND_NOT);
576 }
577
578 static void
579 tree_view_menu_prepare_or_not_selected_cb(GtkAction *action _U_, gpointer user_data)
580 {
581         GtkWidget *widget = gtk_ui_manager_get_widget(ui_manager_tree_view_menu, "/TreeViewPopup/PrepareaFilter/OrNotSelected");
582         match_selected_ptree_cb( widget , user_data, MATCH_SELECTED_OR_NOT);
583 }
584
585 /* Prepare for use of GTKUImanager */
586 /*
587  * Main menu.
588  *
589  * Please do not use keystrokes that are used as "universal" shortcuts in
590  * various desktop environments:
591  *
592  *   Windows:
593  *      http://support.microsoft.com/kb/126449
594  *
595  *   GNOME:
596  *      http://library.gnome.org/users/user-guide/nightly/keyboard-skills.html.en
597  *
598  *   KDE:
599  *      http://developer.kde.org/documentation/standards/kde/style/keys/shortcuts.html
600  *
601  * In particular, do not use the following <control> sequences for anything
602  * other than their standard purposes:
603  *
604  *      <control>O      File->Open
605  *      <control>S      File->Save
606  *      <control>P      File->Print
607  *      <control>W      File->Close
608  *      <control>Q      File->Quit
609  *      <control>Z      Edit->Undo (which we don't currently have)
610  *      <control>X      Edit->Cut (which we don't currently have)
611  *      <control>C      Edit->Copy (which we don't currently have)
612  *      <control>V      Edit->Paste (which we don't currently have)
613  *      <control>A      Edit->Select All (which we don't currently have)
614  *
615  * Note that some if not all of the Edit keys above already perform those
616  * functions in text boxes, such as the Filter box.  Do no, under any
617  * circumstances, make a change that keeps them from doing so.
618  */
619
620 /* This is the GtkItemFactoryEntry structure used to generate new menus.
621        Item 1: The menu path. The letter after the underscore indicates an
622                accelerator key once the menu is open.
623        Item 2: The accelerator key for the entry
624        Item 3: The callback function.
625        Item 4: The callback action.  This changes the parameters with
626                which the function is called.  The default is 0.
627        Item 5: The item type, used to define what kind of an item it is.
628                Here are the possible values:
629
630                NULL               -> "<Item>"
631                ""                 -> "<Item>"
632                "<Title>"          -> create a title item
633                "<Item>"           -> create a simple item
634                "<ImageItem>"      -> create an item holding an image
635                "<StockItem>"      -> create an item holding a stock image
636                "<CheckItem>"      -> create a check item
637                "<ToggleItem>"     -> create a toggle item
638                "<RadioItem>"      -> create a radio item
639                <path>             -> path of a radio item to link against
640                "<Separator>"      -> create a separator
641                "<Tearoff>"        -> create a tearoff separator
642                "<Branch>"         -> create an item to hold sub items (optional)
643                "<LastBranch>"     -> create a right justified branch
644        Item 6: extra data needed for ImageItem and StockItem
645     */
646 static GtkItemFactoryEntry menu_items[] =
647 {
648     {"/_File", NULL, NULL, 0, "<Branch>", NULL,},
649     {"/File/_Open...", "<control>O", GTK_MENU_FUNC(file_open_cmd_cb),
650                              0, "<StockItem>", GTK_STOCK_OPEN,},
651     {"/File/Open _Recent", NULL, NULL, 0, "<Branch>", NULL,},
652     {"/File/_Merge...", NULL, GTK_MENU_FUNC(file_merge_cmd_cb), 0, NULL, NULL,},
653     {"/File/_Import...", NULL, GTK_MENU_FUNC(file_import_cmd_cb), 0, NULL, NULL,},
654     {"/File/_Close", "<control>W", GTK_MENU_FUNC(file_close_cmd_cb),
655                              0, "<StockItem>", GTK_STOCK_CLOSE,},
656     {"/File/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
657     {"/File/_Save", "<control>S", GTK_MENU_FUNC(file_save_cmd_cb),
658                              0, "<StockItem>", GTK_STOCK_SAVE,},
659     {"/File/Save _As...", "<shift><control>S", GTK_MENU_FUNC(file_save_as_cmd_cb),
660                              0, "<StockItem>", GTK_STOCK_SAVE_AS,},
661     {"/File/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
662     {"/File/File Set", NULL, NULL, 0, "<Branch>", NULL,},
663     {"/File/File Set/List Files", NULL, GTK_MENU_FUNC(fileset_cb), 0, "<StockItem>", WIRESHARK_STOCK_FILE_SET_LIST,},
664     {"/File/File Set/Next File", NULL, GTK_MENU_FUNC(fileset_next_cb), 0, "<StockItem>", WIRESHARK_STOCK_FILE_SET_NEXT,},
665     {"/File/File Set/Previous File", NULL, GTK_MENU_FUNC(fileset_previous_cb), 0, "<StockItem>", WIRESHARK_STOCK_FILE_SET_PREVIOUS,},
666     {"/File/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
667     {"/File/_Export", NULL, NULL, 0, "<Branch>", NULL,},
668 #if _WIN32
669     {"/File/Export/File...", NULL, GTK_MENU_FUNC(export_text_cmd_cb),
670                          0, NULL, NULL,},
671 #else
672     {"/File/Export/as \"Plain _Text\" file...", NULL, GTK_MENU_FUNC(export_text_cmd_cb),
673                              0, NULL, NULL,},
674     {"/File/Export/as \"_PostScript\" file...", NULL, GTK_MENU_FUNC(export_ps_cmd_cb),
675                              0, NULL, NULL,},
676     {"/File/Export/as \"_CSV\" (Comma Separated Values packet summary) file...",
677                              NULL, GTK_MENU_FUNC(export_csv_cmd_cb), 0, NULL, NULL,},
678     {"/File/Export/as \"C _Arrays\" (packet bytes) file...", NULL, GTK_MENU_FUNC(export_carrays_cmd_cb),
679                              0, NULL, NULL,},
680     {"/File/Export/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
681     {"/File/Export/as XML - \"P_SML\" (packet summary) file...", NULL, GTK_MENU_FUNC(export_psml_cmd_cb),
682                              0, NULL, NULL,},
683     {"/File/Export/as XML - \"P_DML\" (packet details) file...", NULL, GTK_MENU_FUNC(export_pdml_cmd_cb),
684                              0, NULL, NULL,},
685     {"/File/Export/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
686 #endif
687     {"/File/Export/Selected Packet _Bytes...", "<control>H", GTK_MENU_FUNC(savehex_cb),
688                              0, NULL, NULL,},
689     {"/File/Export/SSL Session Keys...", NULL, GTK_MENU_FUNC(savesslkeys_cb),
690                              0, NULL, NULL,},
691     {"/File/Export/_Objects/_HTTP", NULL, GTK_MENU_FUNC(eo_http_cb), 0, NULL, NULL,},
692     {"/File/Export/_Objects/_DICOM", NULL, GTK_MENU_FUNC(eo_dicom_cb), 0, NULL, NULL,},
693     {"/File/Export/_Objects/_SMB", NULL, GTK_MENU_FUNC(eo_smb_cb), 0, NULL, NULL,},
694     {"/File/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
695     {"/File/_Print...", "<control>P", GTK_MENU_FUNC(file_print_cmd_cb),
696                              0, "<StockItem>", GTK_STOCK_PRINT,},
697     {"/File/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
698     {"/File/_Quit", "<control>Q", GTK_MENU_FUNC(file_quit_cmd_cb),
699                              0, "<StockItem>", GTK_STOCK_QUIT,},
700     {"/_Edit", NULL, NULL, 0, "<Branch>", NULL,},
701     {"/Edit/Copy", NULL, NULL, 0, "<Branch>", NULL,},
702     {"/Edit/Copy/Description", "<shift><control>D", GTK_MENU_FUNC(copy_selected_plist_cb), COPY_SELECTED_DESCRIPTION, NULL, NULL,},
703     {"/Edit/Copy/Fieldname", "<shift><control>F", GTK_MENU_FUNC(copy_selected_plist_cb), COPY_SELECTED_FIELDNAME, NULL, NULL,},
704     {"/Edit/Copy/Value", "<shift><control>V", GTK_MENU_FUNC(copy_selected_plist_cb), COPY_SELECTED_VALUE, NULL, NULL,},
705     {"/Edit/Copy/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
706     {"/Edit/Copy/As Filter", "<shift><control>C", GTK_MENU_FUNC(match_selected_ptree_cb),
707                        MATCH_SELECTED_REPLACE|MATCH_SELECTED_COPY_ONLY, NULL, NULL,},
708 #if 0
709     /*
710      * Un-#if this when we actually implement Cut/Copy/Paste for the
711      * packet list and packet detail windows.
712      *
713      * Note: when we implement Cut/Copy/Paste in those windows, we
714      * will almost certainly want to allow multiple packets to be
715      * selected in the packet list pane and multiple packet detail
716      * items to be selected in the packet detail pane, so that
717      * the user can, for example, copy the summaries of multiple
718      * packets to the clipboard from the packet list pane and multiple
719      * packet detail items - perhaps *all* packet detail items - from
720      * the packet detail pane.  Given that, we'll also want to
721      * implement Select All.
722      *
723      * If multiple packets are selected, we would probably display nothing
724      * in the packet detail pane, just as we do if no packet is selected,
725      * and any menu items etc. that would pertain only to a single packet
726      * would be disabled.
727      *
728      * If multiple packet detail items are selected, we would probably
729      * disable all items that pertain only to a single packet detail
730      * item, such as some items in the status bar.
731      *
732      * XXX - the actions for these will be different depending on what
733      * widget we're in; ^C should copy from the filter text widget if
734      * we're in that widget, the packet list if we're in that widget
735      * (presumably copying the summaries of selected packets to the
736      * clipboard, e.g. the text copy would be the text of the columns),
737      * the packet detail if we're in that widget (presumably copying
738      * the contents of selected protocol tree items to the clipboard,
739      * e.g. the text copy would be the text displayed for those items),
740      * etc..
741      *
742      * Given that those menu items should also affect text widgets
743      * such as the filter box, we would again want Select All, and,
744      * at least for the filter box, we would also want Undo and Redo.
745      * We would only want Cut, Paste, Undo, and Redo for the packet
746      * list and packet detail panes if we support modifying them.
747      */
748     {"/Edit/_Undo", "<control>Z", NULL,
749                              0, "<StockItem>", GTK_STOCK_UNDO,},
750     {"/Edit/_Redo", "<shift><control>Z", NULL,
751                              0, "<StockItem>", GTK_STOCK_REDO,},
752     {"/Edit/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
753     {"/Edit/Cu_t", "<control>X", NULL,
754                              0, "<StockItem>", GTK_STOCK_CUT,},
755     {"/Edit/_Copy", "<control>C", NULL,
756                              0, "<StockItem>", GTK_STOCK_COPY,},
757     {"/Edit/_Paste", "<control>V", NULL,
758                              0, "<StockItem>", GTK_STOCK_PASTE,},
759     {"/Edit/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
760     {"/Edit/Select _All", "<control>A", NULL, 0,
761 #ifdef GTK_STOCK_SELECT_ALL     /* first appeared in 2.10 */
762                              "<StockItem>", GTK_STOCK_SELECT_ALL,
763 #else
764                              NULL, NULL,
765 #endif /* GTK_STOCK_SELECT_ALL */
766     },
767 #endif /* 0 */
768     {"/Edit/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
769     {"/Edit/_Find Packet...",                             "<control>F", GTK_MENU_FUNC(find_frame_cb), 0, "<StockItem>", GTK_STOCK_FIND,},
770     {"/Edit/Find Ne_xt",                                  "<control>N", GTK_MENU_FUNC(find_next_cb), 0, NULL, NULL,},
771     {"/Edit/Find Pre_vious",                              "<control>B", GTK_MENU_FUNC(find_previous_cb), 0, NULL, NULL,},
772     {"/Edit/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
773     {"/Edit/_Mark Packet (toggle)",                       "<control>M", GTK_MENU_FUNC(new_packet_list_mark_frame_cb),0, NULL, NULL,},
774     {"/Edit/Toggle Marking Of All Displayed Packets",        "<shift><alt><control>M", GTK_MENU_FUNC(new_packet_list_toggle_mark_all_displayed_frames_cb), 0, NULL, NULL,},
775     {"/Edit/Mark All Displayed Packets",                  "<shift><control>M", GTK_MENU_FUNC(new_packet_list_mark_all_displayed_frames_cb), 0, NULL, NULL,},
776     {"/Edit/Unmark All Displayed Packets",                "<alt><control>M", GTK_MENU_FUNC(new_packet_list_unmark_all_displayed_frames_cb), 0, NULL, NULL,},
777     {"/Edit/Find Next Mark",                       "<shift><control>N", GTK_MENU_FUNC(find_next_mark_cb), 0, NULL, NULL,},
778     {"/Edit/Find Previous Mark",                   "<shift><control>B", GTK_MENU_FUNC(find_prev_mark_cb), 0, NULL, NULL,},
779     {"/Edit/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
780     {"/Edit/_Ignore Packet (toggle)",                     "<control>D", GTK_MENU_FUNC(new_packet_list_ignore_frame_cb), 0, NULL, NULL,},
781     /*
782      * XXX - this next one overrides /Edit/Copy/Description
783      */
784     {"/Edit/Ignore All Displayed Packets (toggle)","<shift><control>D", GTK_MENU_FUNC(new_packet_list_ignore_all_displayed_frames_cb), 0, NULL, NULL,},
785     {"/Edit/U_n-Ignore All Packets",                 "<alt><control>D", GTK_MENU_FUNC(new_packet_list_unignore_all_frames_cb), 0, NULL, NULL,},
786     {"/Edit/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
787     {"/Edit/Set Time Reference (toggle)",                 "<control>T", GTK_MENU_FUNC(reftime_frame_cb), REFTIME_TOGGLE, "<StockItem>", WIRESHARK_STOCK_TIME,},
788     {"/Edit/Un-Time Reference All Packets",          "<alt><control>T", GTK_MENU_FUNC(new_packet_list_untime_reference_all_frames_cb), 0, NULL, NULL,},
789     {"/Edit/Time Shift...",                          NULL, GTK_MENU_FUNC(time_shift_cb), 0, "<StockItem>", WIRESHARK_STOCK_TIME,},
790     {"/Edit/Find Next Time Reference",               "<alt><control>N", GTK_MENU_FUNC(reftime_frame_cb), REFTIME_FIND_NEXT, NULL, NULL,},
791     {"/Edit/Find Previous Time Reference",           "<alt><control>B", GTK_MENU_FUNC(reftime_frame_cb), REFTIME_FIND_PREV, NULL, NULL,},
792     {"/Edit/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
793 #ifdef WANT_PACKET_EDITOR
794     {"/Edit/Edit packet",                                                       NULL,                           GTK_MENU_FUNC(edit_window_cb), 0, NULL, NULL, },
795     {"/Edit/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
796 #endif
797     {"/Edit/_Configuration Profiles...", "<shift><control>A", GTK_MENU_FUNC(profile_dialog_cb), 0, NULL, NULL,},
798     {"/Edit/_Preferences...", "<shift><control>P", GTK_MENU_FUNC(prefs_page_cb),
799                              PREFS_PAGE_USER_INTERFACE, "<StockItem>", GTK_STOCK_PREFERENCES,},
800     {"/_View", NULL, NULL, 0, "<Branch>", NULL,},
801     {"/View/_Main Toolbar", NULL, GTK_MENU_FUNC(show_hide_cb), SHOW_HIDE_MAIN_TOOLBAR, "<CheckItem>", NULL,},
802     {"/View/_Filter Toolbar", NULL, GTK_MENU_FUNC(show_hide_cb), SHOW_HIDE_FILTER_TOOLBAR, "<CheckItem>", NULL,},
803 #ifdef HAVE_AIRPCAP
804     {"/View/_Wireless Toolbar", NULL, GTK_MENU_FUNC(show_hide_cb), SHOW_HIDE_AIRPCAP_TOOLBAR, "<CheckItem>", NULL,},
805 #endif
806     {"/View/_Statusbar", NULL, GTK_MENU_FUNC(show_hide_cb), SHOW_HIDE_STATUSBAR, "<CheckItem>", NULL,},
807     {"/View/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
808     {"/View/Packet _List", NULL, GTK_MENU_FUNC(show_hide_cb), SHOW_HIDE_PACKET_LIST, "<CheckItem>", NULL,},
809     {"/View/Packet _Details", NULL, GTK_MENU_FUNC(show_hide_cb), SHOW_HIDE_TREE_VIEW, "<CheckItem>", NULL,},
810     {"/View/Packet _Bytes", NULL, GTK_MENU_FUNC(show_hide_cb), SHOW_HIDE_BYTE_VIEW, "<CheckItem>", NULL,},
811     {"/View/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
812     {"/View/_Time Display Format", NULL, NULL, 0, "<Branch>", NULL,},
813     {"/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),
814                         TS_ABSOLUTE_WITH_DATE, "<RadioItem>", NULL,},
815     {"/View/Time Display Format/Time of Day:   01:02:03.123456", "<alt><control>2", GTK_MENU_FUNC(timestamp_format_cb),
816                         TS_ABSOLUTE, "/View/Time Display Format/Date and Time of Day:   1970-01-01 01:02:03.123456", NULL,},
817     {"/View/Time Display Format/Seconds Since Epoch (1970-01-01):   1234567890.123456", "<alt><control>3", GTK_MENU_FUNC(timestamp_format_cb),
818                         TS_EPOCH, "/View/Time Display Format/Date and Time of Day:   1970-01-01 01:02:03.123456", NULL,},
819     {"/View/Time Display Format/Seconds Since Beginning of Capture:   123.123456", "<alt><control>4", GTK_MENU_FUNC(timestamp_format_cb),
820                         TS_RELATIVE, "/View/Time Display Format/Date and Time of Day:   1970-01-01 01:02:03.123456", NULL,},
821     {"/View/Time Display Format/Seconds Since Previous Captured Packet:   1.123456", "<alt><control>5", GTK_MENU_FUNC(timestamp_format_cb),
822                         TS_DELTA, "/View/Time Display Format/Date and Time of Day:   1970-01-01 01:02:03.123456", NULL,},
823     {"/View/Time Display Format/Seconds Since Previous Displayed Packet:   1.123456", "<alt><control>6", GTK_MENU_FUNC(timestamp_format_cb),
824                         TS_DELTA_DIS, "/View/Time Display Format/Date and Time of Day:   1970-01-01 01:02:03.123456", NULL,},
825     {"/View/Time Display Format/UTC Date and Time of Day:   1970-01-01 01:02:03.123456", "<alt><control>7", GTK_MENU_FUNC(timestamp_format_cb),
826                         TS_UTC_WITH_DATE, "/View/Time Display Format/Date and Time of Day:   1970-01-01 01:02:03.123456", NULL,},
827     {"/View/Time Display Format/UTC Time of Day:   01:02:03.123456", "<alt><control>8", GTK_MENU_FUNC(timestamp_format_cb),
828                         TS_UTC, "/View/Time Display Format/Date and Time of Day:   1970-01-01 01:02:03.123456", NULL,},
829     {"/View/Time Display Format/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
830     {"/View/Time Display Format/Automatic (File Format Precision)", NULL, GTK_MENU_FUNC(timestamp_precision_cb),
831                         TS_PREC_AUTO, "<RadioItem>", NULL,},
832     {"/View/Time Display Format/Seconds:   0", NULL, GTK_MENU_FUNC(timestamp_precision_cb),
833                         TS_PREC_FIXED_SEC, "/View/Time Display Format/Automatic (File Format Precision)", NULL,},
834     {"/View/Time Display Format/Deciseconds:   0.1", NULL, GTK_MENU_FUNC(timestamp_precision_cb),
835                         TS_PREC_FIXED_DSEC, "/View/Time Display Format/Automatic (File Format Precision)", NULL,},
836     {"/View/Time Display Format/Centiseconds:   0.12", NULL, GTK_MENU_FUNC(timestamp_precision_cb),
837                         TS_PREC_FIXED_CSEC, "/View/Time Display Format/Automatic (File Format Precision)", NULL,},
838     {"/View/Time Display Format/Milliseconds:   0.123", NULL, GTK_MENU_FUNC(timestamp_precision_cb),
839                         TS_PREC_FIXED_MSEC, "/View/Time Display Format/Automatic (File Format Precision)", NULL,},
840     {"/View/Time Display Format/Microseconds:   0.123456", NULL, GTK_MENU_FUNC(timestamp_precision_cb),
841                         TS_PREC_FIXED_USEC, "/View/Time Display Format/Automatic (File Format Precision)", NULL,},
842     {"/View/Time Display Format/Nanoseconds:   0.123456789", NULL, GTK_MENU_FUNC(timestamp_precision_cb),
843                         TS_PREC_FIXED_NSEC, "/View/Time Display Format/Automatic (File Format Precision)", NULL,},
844     {"/View/Time Display Format/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
845     {"/View/Time Display Format/Display Seconds with hours and minutes", "<alt><control>0", GTK_MENU_FUNC(timestamp_seconds_time_cb), 0, "<CheckItem>", NULL,},
846     {"/View/Name Resol_ution", NULL, NULL, 0, "<Branch>", NULL,},
847     {"/View/Name Resolution/_Resolve Name", NULL, GTK_MENU_FUNC(resolve_name_cb), 0, NULL, NULL,},
848     {"/View/Name Resolution/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
849     {"/View/Name Resolution/Enable for _MAC Layer", NULL, GTK_MENU_FUNC(name_resolution_cb), RESOLV_MAC, "<CheckItem>", NULL,},
850     {"/View/Name Resolution/Enable for _Network Layer", NULL, GTK_MENU_FUNC(name_resolution_cb), RESOLV_NETWORK, "<CheckItem>", NULL,},
851     {"/View/Name Resolution/Enable for _Transport Layer", NULL, GTK_MENU_FUNC(name_resolution_cb), RESOLV_TRANSPORT, "<CheckItem>", NULL,},
852     {"/View/Colorize Packet List", NULL, colorize_cb, 0, "<CheckItem>", NULL,},
853 #ifdef HAVE_LIBPCAP
854     {"/View/Auto Scroll in Li_ve Capture", NULL, GTK_MENU_FUNC(auto_scroll_live_cb), 0, "<CheckItem>", NULL,},
855 #endif
856     {"/View/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
857     {"/View/_Zoom In", "<control>plus", GTK_MENU_FUNC(view_zoom_in_cb),
858                              0, "<StockItem>", GTK_STOCK_ZOOM_IN,},
859     {"/View/Zoom _Out", "<control>minus", GTK_MENU_FUNC(view_zoom_out_cb),
860                              0, "<StockItem>", GTK_STOCK_ZOOM_OUT,},
861     {"/View/_Normal Size", "<control>equal", GTK_MENU_FUNC(view_zoom_100_cb),
862                              0, "<StockItem>", GTK_STOCK_ZOOM_100,},
863     {"/View/Resize All Columns", "<shift><control>R", GTK_MENU_FUNC(new_packet_list_resize_columns_cb),
864                        0, "<StockItem>", WIRESHARK_STOCK_RESIZE_COLUMNS,},
865     {"/View/Displayed Columns", NULL, NULL, 0, NULL, NULL,},
866     {"/View/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
867     {"/View/E_xpand Subtrees", "<shift>Right", GTK_MENU_FUNC(expand_tree_cb), 0, NULL, NULL,},
868     {"/View/_Expand All", "<control>Right", GTK_MENU_FUNC(expand_all_cb),
869                        0, NULL, NULL,},
870     {"/View/Collapse _All", "<control>Left", GTK_MENU_FUNC(collapse_all_cb),
871                        0, NULL, NULL,},
872     {"/View/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
873     {"/View/Colorize Conversation", NULL, NULL, 0, "<Branch>",NULL,},
874     {"/View/Colorize Conversation/Color 1", "<control>1",
875                        GTK_MENU_FUNC(colorize_conversation_cb), 1*256, "<StockItem>", WIRESHARK_STOCK_COLOR1,},
876     {"/View/Colorize Conversation/Color 2", "<control>2",
877                        GTK_MENU_FUNC(colorize_conversation_cb), 2*256, "<StockItem>", WIRESHARK_STOCK_COLOR2,},
878     {"/View/Colorize Conversation/Color 3", "<control>3",
879                        GTK_MENU_FUNC(colorize_conversation_cb), 3*256, "<StockItem>", WIRESHARK_STOCK_COLOR3,},
880     {"/View/Colorize Conversation/Color 4", "<control>4",
881                        GTK_MENU_FUNC(colorize_conversation_cb), 4*256, "<StockItem>", WIRESHARK_STOCK_COLOR4,},
882     {"/View/Colorize Conversation/Color 5", "<control>5",
883                        GTK_MENU_FUNC(colorize_conversation_cb), 5*256, "<StockItem>", WIRESHARK_STOCK_COLOR5,},
884     {"/View/Colorize Conversation/Color 6", "<control>6",
885                        GTK_MENU_FUNC(colorize_conversation_cb), 6*256, "<StockItem>", WIRESHARK_STOCK_COLOR6,},
886     {"/View/Colorize Conversation/Color 7", "<control>7",
887                        GTK_MENU_FUNC(colorize_conversation_cb), 7*256, "<StockItem>", WIRESHARK_STOCK_COLOR7,},
888     {"/View/Colorize Conversation/Color 8", "<control>8",
889                        GTK_MENU_FUNC(colorize_conversation_cb), 8*256, "<StockItem>", WIRESHARK_STOCK_COLOR8,},
890     {"/View/Colorize Conversation/Color 9", "<control>9",
891                        GTK_MENU_FUNC(colorize_conversation_cb), 9*256, "<StockItem>", WIRESHARK_STOCK_COLOR9,},
892     {"/View/Colorize Conversation/Color 10", "<control>0",
893                        GTK_MENU_FUNC(colorize_conversation_cb), 10*256, "<StockItem>", WIRESHARK_STOCK_COLOR0,},
894     {"/View/Colorize Conversation/<separator>", NULL,
895                        NULL, 0, "<Separator>",NULL,},
896     {"/View/Colorize Conversation/New Coloring Rule...", NULL,
897                        GTK_MENU_FUNC(colorize_conversation_cb), 0, "<StockItem>", GTK_STOCK_SELECT_COLOR,},
898     {"/View/Reset Coloring 1-10", "<control>space",
899                        GTK_MENU_FUNC(colorize_conversation_cb), 255*256, NULL, NULL,},
900     {"/View/_Coloring Rules...", NULL, color_display_cb,
901                        0, "<StockItem>", GTK_STOCK_SELECT_COLOR,},
902     {"/View/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
903
904
905     {"/View/Show Packet in New _Window", NULL,
906                        GTK_MENU_FUNC(new_window_cb), 0, NULL, NULL,},
907     {"/View/_Reload", "<control>R", GTK_MENU_FUNC(file_reload_cmd_cb),
908                              0, "<StockItem>", GTK_STOCK_REFRESH,},
909     {"/_Go", NULL, NULL, 0, "<Branch>", NULL,},
910     {"/Go/_Back", "<alt>Left",
911                              GTK_MENU_FUNC(history_back_cb), 0, "<StockItem>", GTK_STOCK_GO_BACK,},
912     {"/Go/_Forward", "<alt>Right",
913                              GTK_MENU_FUNC(history_forward_cb), 0, "<StockItem>", GTK_STOCK_GO_FORWARD,},
914     {"/Go/_Go to Packet...", "<control>G",
915                              GTK_MENU_FUNC(goto_frame_cb), 0, "<StockItem>", GTK_STOCK_JUMP_TO,},
916     {"/Go/Go to _Corresponding Packet", NULL, GTK_MENU_FUNC(goto_framenum_cb),
917                        0, NULL, NULL,},
918     {"/Go/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
919     {"/Go/Previous Packet", "<control>Up",
920                              GTK_MENU_FUNC(goto_previous_frame_cb), 0, "<StockItem>", GTK_STOCK_GO_UP,},
921     {"/Go/Next Packet", "<control>Down",
922                              GTK_MENU_FUNC(goto_next_frame_cb), 0, "<StockItem>", GTK_STOCK_GO_DOWN,},
923     {"/Go/F_irst Packet", "<control>Home",
924                              GTK_MENU_FUNC(goto_top_frame_cb), 0, "<StockItem>", GTK_STOCK_GOTO_TOP,},
925     {"/Go/_Last Packet", "<control>End",
926                              GTK_MENU_FUNC(goto_bottom_frame_cb), 0, "<StockItem>", GTK_STOCK_GOTO_BOTTOM,},
927     {"/Go/Previous Packet In Conversation", "<control>comma",
928                              GTK_MENU_FUNC(goto_previous_frame_conversation_cb), 0, NULL, NULL,},
929     {"/Go/Next Packet In Conversation", "<control>period",
930                              GTK_MENU_FUNC(goto_next_frame_conversation_cb), 0, NULL, NULL,},
931 #ifdef HAVE_LIBPCAP
932     {"/_Capture", NULL, NULL, 0, "<Branch>", NULL,},
933     {"/Capture/_Interfaces...", "<control>I",
934                              GTK_MENU_FUNC(capture_if_cb), 0, "<StockItem>", WIRESHARK_STOCK_CAPTURE_INTERFACES,},
935     {"/Capture/_Options...", "<control>K",
936                              GTK_MENU_FUNC(capture_prep_cb), 0, "<StockItem>", WIRESHARK_STOCK_CAPTURE_OPTIONS,},
937     {"/Capture/_Start", "<control>E",
938                              GTK_MENU_FUNC(capture_start_cb), 0, "<StockItem>", WIRESHARK_STOCK_CAPTURE_START,},
939     {"/Capture/S_top", "<control>E", GTK_MENU_FUNC(capture_stop_cb),
940                              0, "<StockItem>", WIRESHARK_STOCK_CAPTURE_STOP,},
941     {"/Capture/_Restart", "<control>R", GTK_MENU_FUNC(capture_restart_cb),
942                              0, "<StockItem>", WIRESHARK_STOCK_CAPTURE_RESTART,},
943     {"/Capture/Capture _Filters...", NULL, GTK_MENU_FUNC(cfilter_dialog_cb),
944                        0, "<StockItem>", WIRESHARK_STOCK_CAPTURE_FILTER,},
945 #endif /* HAVE_LIBPCAP */
946     {"/_Analyze", NULL, NULL, 0, "<Branch>", NULL,},
947     {"/Analyze/_Display Filters...", NULL, GTK_MENU_FUNC(dfilter_dialog_cb),
948                        0, "<StockItem>", WIRESHARK_STOCK_DISPLAY_FILTER,},
949     {"/Analyze/Display Filter _Macros...", NULL, GTK_MENU_FUNC(macros_dialog_cb), 0, NULL, NULL,},
950     {"/Analyze/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
951     {"/Analyze/Apply as Column", NULL, GTK_MENU_FUNC(apply_as_custom_column_cb), 0, NULL, NULL},
952     {"/Analyze/Appl_y as Filter", NULL, NULL, 0, "<Branch>", NULL,},
953     {"/Analyze/Apply as Filter/_Selected", NULL, GTK_MENU_FUNC(match_selected_ptree_cb),
954                        MATCH_SELECTED_REPLACE|MATCH_SELECTED_APPLY_NOW, NULL, NULL,},
955     {"/Analyze/Apply as Filter/_Not Selected", NULL, GTK_MENU_FUNC(match_selected_ptree_cb),
956                        MATCH_SELECTED_NOT|MATCH_SELECTED_APPLY_NOW, NULL, NULL,},
957     {"/Analyze/Apply as Filter/" UTF8_HORIZONTAL_ELLIPSIS " _and Selected", NULL, GTK_MENU_FUNC(match_selected_ptree_cb),
958                        MATCH_SELECTED_AND|MATCH_SELECTED_APPLY_NOW, NULL, NULL,},
959     {"/Analyze/Apply as Filter/" UTF8_HORIZONTAL_ELLIPSIS " _or Selected", NULL, GTK_MENU_FUNC(match_selected_ptree_cb),
960                        MATCH_SELECTED_OR|MATCH_SELECTED_APPLY_NOW, NULL, NULL,},
961     {"/Analyze/Apply as Filter/" UTF8_HORIZONTAL_ELLIPSIS " a_nd not Selected", NULL, GTK_MENU_FUNC(match_selected_ptree_cb),
962                        MATCH_SELECTED_AND_NOT|MATCH_SELECTED_APPLY_NOW, NULL, NULL,},
963     {"/Analyze/Apply as Filter/" UTF8_HORIZONTAL_ELLIPSIS " o_r not Selected", NULL, GTK_MENU_FUNC(match_selected_ptree_cb),
964                        MATCH_SELECTED_OR_NOT|MATCH_SELECTED_APPLY_NOW, NULL, NULL,},
965     {"/Analyze/_Prepare a Filter", NULL, NULL, 0, "<Branch>", NULL,},
966     {"/Analyze/Prepare a Filter/_Selected", NULL, GTK_MENU_FUNC(match_selected_ptree_cb),
967                        MATCH_SELECTED_REPLACE, NULL, NULL,},
968     {"/Analyze/Prepare a Filter/_Not Selected", NULL, GTK_MENU_FUNC(match_selected_ptree_cb),
969                        MATCH_SELECTED_NOT, NULL, NULL,},
970     {"/Analyze/Prepare a Filter/" UTF8_HORIZONTAL_ELLIPSIS " _and Selected", NULL, GTK_MENU_FUNC(match_selected_ptree_cb),
971                        MATCH_SELECTED_AND, NULL, NULL,},
972     {"/Analyze/Prepare a Filter/" UTF8_HORIZONTAL_ELLIPSIS " _or Selected", NULL, GTK_MENU_FUNC(match_selected_ptree_cb),
973                        MATCH_SELECTED_OR, NULL, NULL,},
974     {"/Analyze/Prepare a Filter/" UTF8_HORIZONTAL_ELLIPSIS " a_nd not Selected", NULL, GTK_MENU_FUNC(match_selected_ptree_cb),
975                        MATCH_SELECTED_AND_NOT, NULL, NULL,},
976     {"/Analyze/Prepare a Filter/" UTF8_HORIZONTAL_ELLIPSIS " o_r not Selected", NULL, GTK_MENU_FUNC(match_selected_ptree_cb),
977                        MATCH_SELECTED_OR_NOT, NULL, NULL,},
978     {"/Analyze/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
979     {"/Analyze/_Enabled Protocols...", "<shift><control>E", GTK_MENU_FUNC(proto_cb),
980                        0, "<StockItem>", WIRESHARK_STOCK_CHECKBOX,},
981     {"/Analyze/Decode _As...", NULL, GTK_MENU_FUNC(decode_as_cb),
982                        0, "<StockItem>", WIRESHARK_STOCK_DECODE_AS,},
983     {"/Analyze/_User Specified Decodes...", NULL,
984                        GTK_MENU_FUNC(decode_show_cb), 0, "<StockItem>", WIRESHARK_STOCK_DECODE_AS,},
985     {"/Analyze/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
986     {"/Analyze/_Follow TCP Stream", NULL,
987                        GTK_MENU_FUNC(follow_tcp_stream_cb), 0, NULL, NULL,},
988     {"/Analyze/_Follow UDP Stream", NULL,
989                        GTK_MENU_FUNC(follow_udp_stream_cb), 0, NULL, NULL,},
990     {"/Analyze/_Follow SSL Stream", NULL,
991                        GTK_MENU_FUNC(follow_ssl_stream_cb), 0, NULL, NULL,},
992     {"/_Statistics", NULL, NULL, 0, "<Branch>", NULL,},
993     {"/Statistics/_Summary", NULL, GTK_MENU_FUNC(summary_open_cb), 0, "<StockItem>", GTK_STOCK_PROPERTIES,},
994     {"/Statistics/_Protocol Hierarchy", NULL,
995                        GTK_MENU_FUNC(proto_hier_stats_cb), 0, NULL, NULL,},
996     {"/Statistics/Conversations", NULL,
997                        GTK_MENU_FUNC(init_conversation_notebook_cb), 0, "<StockItem>", WIRESHARK_STOCK_CONVERSATIONS,},
998     {"/Statistics/Endpoints", NULL,
999                        GTK_MENU_FUNC(init_hostlist_notebook_cb), 0, "<StockItem>", WIRESHARK_STOCK_ENDPOINTS,},
1000     {"/Telephon_y", NULL, NULL, 0, "<Branch>", NULL,},
1001     {"/_Tools", NULL, NULL, 0, "<Branch>", NULL,},
1002     {"/Tools/Firewall ACL Rules", NULL,
1003                        firewall_rule_cb, 0, NULL, NULL,},
1004     {"/_Internals", NULL, NULL, 0, "<Branch>", NULL,},
1005     {"/Internals/_Dissector tables", NULL, GTK_MENU_FUNC(dissector_tables_dlg_cb), 0, NULL, NULL,},
1006     {"/Internals/_Supported Protocols (slow!)", NULL, GTK_MENU_FUNC(supported_cb), 0, NULL, NULL,},
1007     {"/_Help", NULL, NULL, 0, "<Branch>", NULL,},
1008     {"/Help/_Contents", "F1", GTK_MENU_FUNC(topic_menu_cb), HELP_CONTENT, "<StockItem>", GTK_STOCK_HELP,},
1009     {"/Help/Manual Pages", NULL, NULL, 0, "<Branch>", NULL,},
1010     {"/Help/Manual Pages/Wireshark", NULL, GTK_MENU_FUNC(topic_menu_cb), LOCALPAGE_MAN_WIRESHARK, NULL, NULL,},
1011     {"/Help/Manual Pages/Wireshark Filter", NULL, GTK_MENU_FUNC(topic_menu_cb), LOCALPAGE_MAN_WIRESHARK_FILTER, NULL, NULL,},
1012     {"/Help/Manual Pages/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
1013     {"/Help/Manual Pages/TShark", NULL, GTK_MENU_FUNC(topic_menu_cb), LOCALPAGE_MAN_TSHARK, NULL, NULL,},
1014     {"/Help/Manual Pages/RawShark", NULL, GTK_MENU_FUNC(topic_menu_cb), LOCALPAGE_MAN_RAWSHARK, NULL, NULL,},
1015     {"/Help/Manual Pages/Dumpcap", NULL, GTK_MENU_FUNC(topic_menu_cb), LOCALPAGE_MAN_DUMPCAP, NULL, NULL,},
1016     {"/Help/Manual Pages/Mergecap", NULL, GTK_MENU_FUNC(topic_menu_cb), LOCALPAGE_MAN_MERGECAP, NULL, NULL,},
1017     {"/Help/Manual Pages/Editcap", NULL, GTK_MENU_FUNC(topic_menu_cb), LOCALPAGE_MAN_EDITCAP, NULL, NULL,},
1018     {"/Help/Manual Pages/Text2pcap", NULL, GTK_MENU_FUNC(topic_menu_cb), LOCALPAGE_MAN_TEXT2PCAP, NULL, NULL,},
1019     {"/Help/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
1020     {"/Help/Website", NULL, GTK_MENU_FUNC(topic_menu_cb), ONLINEPAGE_HOME, "<StockItem>", GTK_STOCK_HOME,},
1021     {"/Help/FAQ's", NULL, GTK_MENU_FUNC(topic_menu_cb), ONLINEPAGE_FAQ, NULL, NULL,},
1022     {"/Help/Downloads", NULL, GTK_MENU_FUNC(topic_menu_cb), ONLINEPAGE_DOWNLOAD, NULL, NULL,},
1023     {"/Help/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
1024     {"/Help/Wiki", NULL, GTK_MENU_FUNC(topic_menu_cb), ONLINEPAGE_WIKI, "<StockItem>", WIRESHARK_STOCK_WIKI,},
1025     {"/Help/Sample Captures", NULL, GTK_MENU_FUNC(topic_menu_cb), ONLINEPAGE_SAMPLE_FILES, NULL, NULL,},
1026     {"/Help/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
1027     {"/Help/_About Wireshark", NULL, GTK_MENU_FUNC(about_wireshark_cb),
1028                        0, "<StockItem>", WIRESHARK_STOCK_ABOUT}
1029 };
1030
1031 /* calculate the number of menu_items */
1032 static int nmenu_items = sizeof(menu_items) / sizeof(menu_items[0]);
1033
1034
1035 static void
1036 select_bytes_view_cb (GtkRadioAction *action, GtkRadioAction *current _U_, gpointer user_data _U_)
1037 {
1038         gint value;
1039
1040         value = gtk_radio_action_get_current_value (action);
1041         /* Fix me */
1042         select_bytes_view( NULL, NULL, value);
1043 }
1044
1045 static void
1046 sort_ascending_cb(GtkAction *action _U_, gpointer user_data)
1047 {
1048         GtkWidget *widget = gtk_ui_manager_get_widget(ui_manager_packet_list_heading, "/PacketListHeadingPopup/SortAscending");
1049         new_packet_list_column_menu_cb( widget , user_data, COLUMN_SELECTED_SORT_ASCENDING);
1050 }
1051
1052 static void
1053 sort_descending_cb(GtkAction *action _U_, gpointer user_data)
1054 {
1055         GtkWidget *widget = gtk_ui_manager_get_widget(ui_manager_packet_list_heading, "/PacketListHeadingPopup/SortDescending");
1056         new_packet_list_column_menu_cb( widget , user_data, COLUMN_SELECTED_SORT_DESCENDING);
1057 }
1058
1059 static void
1060 no_sorting_cb(GtkAction *action _U_, gpointer user_data)
1061 {
1062         GtkWidget *widget = gtk_ui_manager_get_widget(ui_manager_packet_list_heading, "/PacketListHeadingPopup/NoSorting");
1063         new_packet_list_column_menu_cb( widget , user_data, COLUMN_SELECTED_SORT_NONE);
1064 }
1065
1066 static void
1067 packet_list_heading_show_resolved_cb(GtkAction *action _U_, gpointer user_data _U_)
1068 {
1069         GtkWidget *widget = gtk_ui_manager_get_widget(ui_manager_packet_list_heading, "/PacketListHeadingPopup/ShowResolved");
1070
1071         new_packet_list_column_menu_cb( widget , user_data, COLUMN_SELECTED_TOGGLE_RESOLVED);
1072 }
1073
1074 static void
1075 packet_list_heading_align_left_cb(GtkAction *action _U_, gpointer user_data)
1076 {
1077         GtkWidget *widget = gtk_ui_manager_get_widget(ui_manager_packet_list_heading, "/PacketListHeadingPopup/AlignLeft");
1078         new_packet_list_column_menu_cb( widget , user_data, COLUMN_SELECTED_ALIGN_LEFT);
1079 }
1080
1081 static void
1082 packet_list_heading_align_center_cb(GtkAction *action _U_, gpointer user_data)
1083 {
1084         GtkWidget *widget = gtk_ui_manager_get_widget(ui_manager_packet_list_heading, "/PacketListHeadingPopup/AlignCenter");
1085         new_packet_list_column_menu_cb( widget , user_data, COLUMN_SELECTED_ALIGN_CENTER);
1086 }
1087
1088 static void
1089 packet_list_heading_align_right_cb(GtkAction *action _U_, gpointer user_data)
1090 {
1091         GtkWidget *widget = gtk_ui_manager_get_widget(ui_manager_packet_list_heading, "/PacketListHeadingPopup/AlignRight");
1092         new_packet_list_column_menu_cb( widget , user_data, COLUMN_SELECTED_ALIGN_RIGHT);
1093 }
1094
1095 static void
1096 packet_list_heading_col_pref_cb(GtkAction *action _U_, gpointer user_data)
1097 {
1098         GtkWidget *widget = gtk_ui_manager_get_widget(ui_manager_packet_list_heading, "/PacketListHeadingPopup/ColumnPreferences");
1099         prefs_page_cb( widget , user_data, PREFS_PAGE_COLUMNS);
1100 }
1101
1102 static void
1103 packet_list_heading_resize_col_cb(GtkAction *action _U_, gpointer user_data)
1104 {
1105         GtkWidget *widget = gtk_ui_manager_get_widget(ui_manager_packet_list_heading, "/PacketListHeadingPopup/ResizeColumn");
1106         new_packet_list_column_menu_cb( widget , user_data, COLUMN_SELECTED_RESIZE);
1107 }
1108
1109 static void
1110 packet_list_heading_change_col_cb(GtkAction *action _U_, gpointer user_data)
1111 {
1112         GtkWidget *widget = gtk_ui_manager_get_widget(ui_manager_packet_list_heading, "/PacketListHeadingPopup/EditColumnDetails");
1113         new_packet_list_column_menu_cb( widget , user_data, COLUMN_SELECTED_CHANGE);
1114 }
1115
1116 static void
1117 packet_list_heading_activate_all_columns_cb(GtkAction *action _U_, gpointer user_data _U_)
1118 {
1119         new_packet_list_set_all_columns_visible ();
1120 }
1121
1122 static void
1123 packet_list_heading_hide_col_cb(GtkAction *action _U_, gpointer user_data)
1124 {
1125         GtkWidget *widget = gtk_ui_manager_get_widget(ui_manager_packet_list_heading, "/PacketListHeadingPopup/HideColumn");
1126         new_packet_list_column_menu_cb( widget , user_data, COLUMN_SELECTED_HIDE);
1127 }
1128
1129 static void
1130 packet_list_heading_remove_col_cb(GtkAction *action _U_, gpointer user_data)
1131 {
1132         GtkWidget *widget = gtk_ui_manager_get_widget(ui_manager_packet_list_heading, "/PacketListHeadingPopup/RemoveColumn");
1133         new_packet_list_column_menu_cb( widget , user_data, COLUMN_SELECTED_REMOVE);
1134 }
1135
1136 static void
1137 packet_list_menu_set_ref_time_cb(GtkAction *action _U_, gpointer user_data)
1138 {
1139         reftime_frame_cb( NULL /* widget _U_ */ , user_data, REFTIME_TOGGLE);
1140 }
1141
1142
1143 static void
1144 packet_list_menu_apply_selected_cb(GtkAction *action _U_, gpointer user_data)
1145 {
1146         match_selected_plist_cb( NULL /* widget _U_ */, user_data, MATCH_SELECTED_REPLACE|MATCH_SELECTED_APPLY_NOW);
1147 }
1148
1149 static void
1150 packet_list_menu_apply_not_selected_cb(GtkAction *action _U_, gpointer user_data)
1151 {
1152         match_selected_plist_cb(  NULL /* widget _U_ */ , user_data, MATCH_SELECTED_NOT|MATCH_SELECTED_APPLY_NOW);
1153 }
1154
1155 static void
1156 packet_list_menu_apply_and_selected_cb(GtkAction *action _U_, gpointer user_data)
1157 {
1158         match_selected_plist_cb(  NULL /* widget _U_ */ , user_data, MATCH_SELECTED_AND|MATCH_SELECTED_APPLY_NOW);
1159 }
1160
1161 static void
1162 packet_list_menu_apply_or_selected_cb(GtkAction *action _U_, gpointer user_data)
1163 {
1164         match_selected_plist_cb(  NULL /* widget _U_ */ , user_data, MATCH_SELECTED_OR|MATCH_SELECTED_APPLY_NOW);
1165 }
1166
1167 static void
1168 packet_list_menu_apply_and_not_selected_cb(GtkAction *action _U_, gpointer user_data)
1169 {
1170         match_selected_plist_cb(  NULL /* widget _U_ */ , user_data, MATCH_SELECTED_AND_NOT|MATCH_SELECTED_APPLY_NOW);
1171 }
1172
1173 static void
1174 packet_list_menu_apply_or_not_selected_cb(GtkAction *action _U_, gpointer user_data)
1175 {
1176         match_selected_plist_cb(  NULL /* widget _U_ */ , user_data,MATCH_SELECTED_OR_NOT|MATCH_SELECTED_APPLY_NOW);
1177 }
1178 /* Prepare a filter */
1179 static void
1180 packet_list_menu_prepare_selected_cb(GtkAction *action _U_, gpointer user_data)
1181 {
1182         match_selected_plist_cb(  NULL /* widget _U_ */ , user_data, MATCH_SELECTED_REPLACE);
1183 }
1184
1185 static void
1186 packet_list_menu_prepare_not_selected_cb(GtkAction *action _U_, gpointer user_data)
1187 {
1188         match_selected_plist_cb(  NULL /* widget _U_ */ , user_data, MATCH_SELECTED_NOT);
1189 }
1190
1191 static void
1192 packet_list_menu_prepare_and_selected_cb(GtkAction *action _U_, gpointer user_data)
1193 {
1194         match_selected_plist_cb(  NULL /* widget _U_ */ , user_data, MATCH_SELECTED_AND);
1195 }
1196
1197 static void
1198 packet_list_menu_prepare_or_selected_cb(GtkAction *action _U_, gpointer user_data)
1199 {
1200         match_selected_plist_cb(  NULL /* widget _U_ */ , user_data, MATCH_SELECTED_OR);
1201 }
1202
1203 static void
1204 packet_list_menu_prepare_and_not_selected_cb(GtkAction *action _U_, gpointer user_data)
1205 {
1206         match_selected_plist_cb(  NULL /* widget _U_ */ , user_data, MATCH_SELECTED_AND_NOT);
1207 }
1208
1209 static void
1210 packet_list_menu_prepare_or_not_selected_cb(GtkAction *action _U_, gpointer user_data)
1211 {
1212         match_selected_plist_cb(  NULL /* widget _U_ */ , user_data, MATCH_SELECTED_OR_NOT);
1213 }
1214
1215 static void
1216 packet_list_menu_conversation_ethernet_cb(GtkAction *action, gpointer user_data)
1217 {
1218         conversation_cb(  action, user_data, CONV_ETHER);
1219 }
1220
1221 static void
1222 packet_list_menu_conversation_ip_cb(GtkAction *action _U_, gpointer user_data)
1223 {
1224         conversation_cb( action, user_data, CONV_IP);
1225 }
1226
1227 static void
1228 packet_list_menu_conversation_tcp_cb(GtkAction *action _U_, gpointer user_data)
1229 {
1230         conversation_cb(  action, user_data, CONV_TCP);
1231 }
1232
1233 static void
1234 packet_list_menu_conversation_udp_cb(GtkAction *action _U_, gpointer user_data)
1235 {
1236         conversation_cb(  action, user_data, CONV_UDP);
1237 }
1238
1239 static void
1240 packet_list_menu_conversation_pn_cba_cb(GtkAction *action _U_, gpointer user_data)
1241 {
1242         conversation_cb(  action, user_data, CONV_CBA);
1243 }
1244
1245 /* Ethernet */
1246
1247 static void
1248 packet_list_menu_color_conv_ethernet_color1_cb(GtkAction *action _U_, gpointer user_data)
1249 {
1250         colorize_conversation_cb( NULL /* widget _U_ */, user_data, CONV_ETHER+1*256);
1251 }
1252
1253 static void
1254 packet_list_menu_color_conv_ethernet_color2_cb(GtkAction *action _U_, gpointer user_data)
1255 {
1256         colorize_conversation_cb( NULL/* widget _U_ */ , user_data, CONV_ETHER+1*256);
1257 }
1258
1259 static void
1260 packet_list_menu_color_conv_ethernet_color3_cb(GtkAction *action _U_, gpointer user_data)
1261 {
1262         colorize_conversation_cb( NULL /* widget _U_ */ , user_data, CONV_ETHER+3*256);
1263 }
1264
1265 static void
1266 packet_list_menu_color_conv_ethernet_color4_cb(GtkAction *action _U_, gpointer user_data)
1267 {
1268         colorize_conversation_cb( NULL /* widget _U_ */ , user_data, CONV_ETHER+4*256);
1269 }
1270
1271 static void
1272 packet_list_menu_color_conv_ethernet_color5_cb(GtkAction *action _U_, gpointer user_data)
1273 {
1274         colorize_conversation_cb( NULL /* widget _U_ */ , user_data, CONV_ETHER+5*256);
1275 }
1276
1277 static void
1278 packet_list_menu_color_conv_ethernet_color6_cb(GtkAction *action _U_, gpointer user_data)
1279 {
1280         colorize_conversation_cb( NULL /* widget _U_ */ , user_data, CONV_ETHER+6*256);
1281 }
1282
1283 static void
1284 packet_list_menu_color_conv_ethernet_color7_cb(GtkAction *action _U_, gpointer user_data)
1285 {
1286         colorize_conversation_cb( NULL /* widget _U_ */ , user_data, CONV_ETHER+7*256);
1287 }
1288
1289 static void
1290 packet_list_menu_color_conv_ethernet_color8_cb(GtkAction *action _U_, gpointer user_data)
1291 {
1292         colorize_conversation_cb( NULL /* widget _U_ */ , user_data, CONV_ETHER+8*256);
1293 }
1294
1295 static void
1296 packet_list_menu_color_conv_ethernet_color9_cb(GtkAction *action _U_, gpointer user_data)
1297 {
1298         colorize_conversation_cb( NULL /* widget _U_ */ , user_data, CONV_ETHER+9*256);
1299 }
1300
1301 static void
1302 packet_list_menu_color_conv_ethernet_color10_cb(GtkAction *action _U_, gpointer user_data)
1303 {
1304         colorize_conversation_cb( NULL /* widget _U_ */ , user_data, CONV_ETHER+10*256);
1305 }
1306
1307 static void
1308 packet_list_menu_color_conv_ethernet_new_rule_cb(GtkAction *action _U_, gpointer user_data)
1309 {
1310         colorize_conversation_cb( NULL /* widget _U_ */ , user_data, CONV_ETHER);
1311 }
1312
1313 /* IP */
1314
1315 static void
1316 packet_list_menu_color_conv_ip_color1_cb(GtkAction *action _U_, gpointer user_data)
1317 {
1318         colorize_conversation_cb( NULL /* widget _U_ */ , user_data, CONV_IP+1*256);
1319 }
1320
1321 static void
1322 packet_list_menu_color_conv_ip_color2_cb(GtkAction *action _U_, gpointer user_data)
1323 {
1324         colorize_conversation_cb( NULL /* widget _U_ */ , user_data, CONV_IP+1*256);
1325 }
1326
1327 static void
1328 packet_list_menu_color_conv_ip_color3_cb(GtkAction *action _U_, gpointer user_data)
1329 {
1330         colorize_conversation_cb( NULL /* widget _U_ */ , user_data, CONV_IP+3*256);
1331 }
1332
1333 static void
1334 packet_list_menu_color_conv_ip_color4_cb(GtkAction *action _U_, gpointer user_data)
1335 {
1336         colorize_conversation_cb( NULL /* widget _U_ */ , user_data, CONV_IP+4*256);
1337 }
1338
1339 static void
1340 packet_list_menu_color_conv_ip_color5_cb(GtkAction *action _U_, gpointer user_data)
1341 {
1342         colorize_conversation_cb( NULL /* widget _U_ */ , user_data, CONV_IP+5*256);
1343 }
1344
1345 static void
1346 packet_list_menu_color_conv_ip_color6_cb(GtkAction *action _U_, gpointer user_data)
1347 {
1348         colorize_conversation_cb( NULL /* widget _U_ */ , user_data, CONV_IP+6*256);
1349 }
1350
1351 static void
1352 packet_list_menu_color_conv_ip_color7_cb(GtkAction *action _U_, gpointer user_data)
1353 {
1354         colorize_conversation_cb( NULL /* widget _U_ */ , user_data, CONV_IP+7*256);
1355 }
1356
1357 static void
1358 packet_list_menu_color_conv_ip_color8_cb(GtkAction *action _U_, gpointer user_data)
1359 {
1360         colorize_conversation_cb( NULL /* widget _U_ */ , user_data, CONV_IP+8*256);
1361 }
1362
1363 static void
1364 packet_list_menu_color_conv_ip_color9_cb(GtkAction *action _U_, gpointer user_data)
1365 {
1366         colorize_conversation_cb( NULL /* widget _U_ */ , user_data, CONV_IP+9*256);
1367 }
1368
1369 static void
1370 packet_list_menu_color_conv_ip_color10_cb(GtkAction *action _U_, gpointer user_data)
1371 {
1372         colorize_conversation_cb( NULL /* widget _U_ */ , user_data, CONV_IP+10*256);
1373 }
1374
1375 static void
1376 packet_list_menu_color_conv_ip_new_rule_cb(GtkAction *action _U_, gpointer user_data)
1377 {
1378         colorize_conversation_cb( NULL /* widget _U_ */ , user_data, CONV_TCP);
1379 }
1380
1381 /* TCP */
1382
1383 static void
1384 packet_list_menu_color_conv_tcp_color1_cb(GtkAction *action _U_, gpointer user_data)
1385 {
1386         colorize_conversation_cb( NULL /* widget _U_ */ , user_data, CONV_TCP+1*256);
1387 }
1388
1389 static void
1390 packet_list_menu_color_conv_tcp_color2_cb(GtkAction *action _U_, gpointer user_data)
1391 {
1392         colorize_conversation_cb( NULL /* widget _U_ */ , user_data, CONV_TCP+1*256);
1393 }
1394
1395 static void
1396 packet_list_menu_color_conv_tcp_color3_cb(GtkAction *action _U_, gpointer user_data)
1397 {
1398         colorize_conversation_cb( NULL /* widget _U_ */ , user_data, CONV_TCP+3*256);
1399 }
1400
1401 static void
1402 packet_list_menu_color_conv_tcp_color4_cb(GtkAction *action _U_, gpointer user_data)
1403 {
1404         colorize_conversation_cb( NULL /* widget _U_ */ , user_data, CONV_TCP+4*256);
1405 }
1406
1407 static void
1408 packet_list_menu_color_conv_tcp_color5_cb(GtkAction *action _U_, gpointer user_data)
1409 {
1410         colorize_conversation_cb( NULL /* widget _U_ */ , user_data, CONV_TCP+5*256);
1411 }
1412
1413 static void
1414 packet_list_menu_color_conv_tcp_color6_cb(GtkAction *action _U_, gpointer user_data)
1415 {
1416         colorize_conversation_cb( NULL /* widget _U_ */ , user_data, CONV_TCP+6*256);
1417 }
1418
1419 static void
1420 packet_list_menu_color_conv_tcp_color7_cb(GtkAction *action _U_, gpointer user_data)
1421 {
1422         colorize_conversation_cb( NULL /* widget _U_ */ , user_data, CONV_TCP+7*256);
1423 }
1424
1425 static void
1426 packet_list_menu_color_conv_tcp_color8_cb(GtkAction *action _U_, gpointer user_data)
1427 {
1428         colorize_conversation_cb( NULL /* widget _U_ */ , user_data, CONV_TCP+8*256);
1429 }
1430
1431 static void
1432 packet_list_menu_color_conv_tcp_color9_cb(GtkAction *action _U_, gpointer user_data)
1433 {
1434         colorize_conversation_cb( NULL /* widget _U_ */ , user_data, CONV_TCP+9*256);
1435 }
1436
1437 static void
1438 packet_list_menu_color_conv_tcp_color10_cb(GtkAction *action _U_, gpointer user_data)
1439 {
1440         colorize_conversation_cb( NULL /* widget _U_ */ , user_data, CONV_TCP+10*256);
1441 }
1442
1443 static void
1444 packet_list_menu_color_conv_tcp_new_rule_cb(GtkAction *action _U_, gpointer user_data)
1445 {
1446         colorize_conversation_cb( NULL /* widget _U_ */ , user_data, CONV_TCP);
1447 }
1448
1449 /* UDP */
1450
1451 static void
1452 packet_list_menu_color_conv_udp_color1_cb(GtkAction *action _U_, gpointer user_data)
1453 {
1454         colorize_conversation_cb( NULL /* widget _U_ */ , user_data, CONV_UDP+1*256);
1455 }
1456
1457 static void
1458 packet_list_menu_color_conv_udp_color2_cb(GtkAction *action _U_, gpointer user_data)
1459 {
1460         colorize_conversation_cb( NULL /* widget _U_ */ , user_data, CONV_UDP+1*256);
1461 }
1462
1463 static void
1464 packet_list_menu_color_conv_udp_color3_cb(GtkAction *action _U_, gpointer user_data)
1465 {
1466         colorize_conversation_cb( NULL /* widget _U_ */ , user_data, CONV_UDP+3*256);
1467 }
1468
1469 static void
1470 packet_list_menu_color_conv_udp_color4_cb(GtkAction *action _U_, gpointer user_data)
1471 {
1472         colorize_conversation_cb( NULL /* widget _U_ */ , user_data, CONV_UDP+4*256);
1473 }
1474
1475 static void
1476 packet_list_menu_color_conv_udp_color5_cb(GtkAction *action _U_, gpointer user_data)
1477 {
1478         colorize_conversation_cb( NULL /* widget _U_ */ , user_data, CONV_UDP+5*256);
1479 }
1480
1481 static void
1482 packet_list_menu_color_conv_udp_color6_cb(GtkAction *action _U_, gpointer user_data)
1483 {
1484         colorize_conversation_cb( NULL /* widget _U_ */ , user_data, CONV_UDP+6*256);
1485 }
1486
1487 static void
1488 packet_list_menu_color_conv_udp_color7_cb(GtkAction *action _U_, gpointer user_data)
1489 {
1490         colorize_conversation_cb( NULL /* widget _U_ */ , user_data, CONV_UDP+7*256);
1491 }
1492
1493 static void
1494 packet_list_menu_color_conv_udp_color8_cb(GtkAction *action _U_, gpointer user_data)
1495 {
1496         colorize_conversation_cb( NULL /* widget _U_ */ , user_data, CONV_UDP+8*256);
1497 }
1498
1499 static void
1500 packet_list_menu_color_conv_udp_color9_cb(GtkAction *action _U_, gpointer user_data)
1501 {
1502         colorize_conversation_cb( NULL /* widget _U_ */ , user_data, CONV_UDP+9*256);
1503 }
1504
1505 static void
1506 packet_list_menu_color_conv_udp_color10_cb(GtkAction *action _U_, gpointer user_data)
1507 {
1508         colorize_conversation_cb( NULL /* widget _U_ */ , user_data, CONV_UDP+10*256);
1509 }
1510
1511 static void
1512 packet_list_menu_color_conv_udp_new_rule_cb(GtkAction *action _U_, gpointer user_data)
1513 {
1514         colorize_conversation_cb( NULL /* widget _U_ */ , user_data, CONV_UDP);
1515 }
1516
1517 /* CONV_CBA */
1518
1519 static void
1520 packet_list_menu_color_conv_cba_color1_cb(GtkAction *action _U_, gpointer user_data)
1521 {
1522         colorize_conversation_cb( NULL /* widget _U_ */ , user_data, CONV_CBA+1*256);
1523 }
1524
1525 static void
1526 packet_list_menu_color_conv_cba_color2_cb(GtkAction *action _U_, gpointer user_data)
1527 {
1528         colorize_conversation_cb( NULL /* widget _U_ */ , user_data, CONV_CBA+1*256);
1529 }
1530
1531 static void
1532 packet_list_menu_color_conv_cba_color3_cb(GtkAction *action _U_, gpointer user_data)
1533 {
1534         colorize_conversation_cb( NULL /* widget _U_ */ , user_data, CONV_CBA+3*256);
1535 }
1536
1537 static void
1538 packet_list_menu_color_conv_cba_color4_cb(GtkAction *action _U_, gpointer user_data)
1539 {
1540         colorize_conversation_cb( NULL /* widget _U_ */ , user_data, CONV_CBA+4*256);
1541 }
1542
1543 static void
1544 packet_list_menu_color_conv_cba_color5_cb(GtkAction *action _U_, gpointer user_data)
1545 {
1546         colorize_conversation_cb( NULL /* widget _U_ */ , user_data, CONV_CBA+5*256);
1547 }
1548
1549 static void
1550 packet_list_menu_color_conv_cba_color6_cb(GtkAction *action _U_, gpointer user_data)
1551 {
1552         colorize_conversation_cb( NULL /* widget _U_ */ , user_data, CONV_CBA+6*256);
1553 }
1554
1555 static void
1556 packet_list_menu_color_conv_cba_color7_cb(GtkAction *action _U_, gpointer user_data)
1557 {
1558         colorize_conversation_cb( NULL /* widget _U_ */ , user_data, CONV_CBA+7*256);
1559 }
1560
1561 static void
1562 packet_list_menu_color_conv_cba_color8_cb(GtkAction *action _U_, gpointer user_data)
1563 {
1564         colorize_conversation_cb( NULL /* widget _U_ */ , user_data, CONV_CBA+8*256);
1565 }
1566
1567 static void
1568 packet_list_menu_color_conv_cba_color9_cb(GtkAction *action _U_, gpointer user_data)
1569 {
1570         colorize_conversation_cb( NULL /* widget _U_ */ , user_data, CONV_CBA+9*256);
1571 }
1572
1573 static void
1574 packet_list_menu_color_conv_cba_color10_cb(GtkAction *action _U_, gpointer user_data)
1575 {
1576         colorize_conversation_cb( NULL /* widget _U_ */ , user_data, CONV_CBA+10*256);
1577 }
1578
1579 static void
1580 packet_list_menu_color_conv_cba_new_rule_cb(GtkAction *action _U_, gpointer user_data)
1581 {
1582         colorize_conversation_cb( NULL /* widget _U_ */ , user_data, CONV_CBA);
1583 }
1584
1585 static void
1586 packet_list_menu_copy_sum_txt(GtkAction *action _U_, gpointer user_data)
1587 {
1588         new_packet_list_copy_summary_cb(user_data, CS_TEXT);
1589 }
1590
1591 static void
1592 packet_list_menu_copy_sum_csv(GtkAction *action _U_, gpointer user_data)
1593 {
1594         new_packet_list_copy_summary_cb(user_data, CS_CSV);
1595 }
1596
1597 static void
1598 packet_list_menu_copy_as_flt(GtkAction *action _U_, gpointer user_data)
1599 {
1600         match_selected_plist_cb( NULL /* widget _U_ */ , user_data, MATCH_SELECTED_REPLACE|MATCH_SELECTED_COPY_ONLY);
1601 }
1602
1603 static void
1604 packet_list_menu_copy_bytes_oht_cb(GtkAction *action _U_, gpointer user_data)
1605 {
1606         copy_hex_cb( NULL /* widget _U_ */ , user_data,  CD_ALLINFO | CD_FLAGS_SELECTEDONLY);
1607 }
1608
1609 static void
1610 packet_list_menu_copy_bytes_oh_cb(GtkAction *action _U_, gpointer user_data)
1611 {
1612         copy_hex_cb( NULL /* widget _U_ */ , user_data, CD_HEXCOLUMNS | CD_FLAGS_SELECTEDONLY);
1613 }
1614
1615 static void
1616 packet_list_menu_copy_bytes_text_cb(GtkAction *action _U_, gpointer user_data)
1617 {
1618         copy_hex_cb( NULL /* widget _U_ */ , user_data, CD_TEXTONLY | CD_FLAGS_SELECTEDONLY);
1619 }
1620
1621 static void
1622 packet_list_menu_copy_bytes_hex_strm_cb(GtkAction *action _U_, gpointer user_data)
1623 {
1624         copy_hex_cb( NULL /* widget _U_ */ , user_data,  CD_HEX | CD_FLAGS_SELECTEDONLY);
1625 }
1626
1627 static void
1628 packet_list_menu_copy_bytes_bin_strm_cb(GtkAction *action _U_, gpointer user_data)
1629 {
1630         copy_hex_cb( NULL /* widget _U_ */ , user_data, CD_BINARY | CD_FLAGS_SELECTEDONLY);
1631 }
1632
1633 /* tree */
1634
1635 static void
1636 tree_view_menu_color_with_flt_color1_cb(GtkAction *action _U_, gpointer user_data)
1637 {
1638         colorize_selected_ptree_cb( NULL /* widget _U_ */ , user_data, 1);
1639 }
1640
1641 static void
1642 tree_view_menu_color_with_flt_color2_cb(GtkAction *action _U_, gpointer user_data)
1643 {
1644         colorize_selected_ptree_cb( NULL /* widget _U_ */ , user_data, 2);
1645 }
1646
1647 static void
1648 tree_view_menu_color_with_flt_color3_cb(GtkAction *action _U_, gpointer user_data)
1649 {
1650         colorize_selected_ptree_cb( NULL /* widget _U_ */ , user_data, 3);
1651 }
1652
1653 static void
1654 tree_view_menu_color_with_flt_color4_cb(GtkAction *action _U_, gpointer user_data)
1655 {
1656         colorize_selected_ptree_cb( NULL /* widget _U_ */ , user_data, 4);
1657 }
1658
1659 static void
1660 tree_view_menu_color_with_flt_color5_cb(GtkAction *action _U_, gpointer user_data)
1661 {
1662         colorize_selected_ptree_cb( NULL /* widget _U_ */ , user_data, 5);
1663 }
1664
1665 static void
1666 tree_view_menu_color_with_flt_color6_cb(GtkAction *action _U_, gpointer user_data)
1667 {
1668         colorize_selected_ptree_cb( NULL /* widget _U_ */ , user_data, 6);
1669 }
1670
1671 static void
1672 tree_view_menu_color_with_flt_color7_cb(GtkAction *action _U_, gpointer user_data)
1673 {
1674         colorize_selected_ptree_cb( NULL /* widget _U_ */ , user_data, 7);
1675 }
1676
1677 static void
1678 tree_view_menu_color_with_flt_color8_cb(GtkAction *action _U_, gpointer user_data)
1679 {
1680         colorize_selected_ptree_cb( NULL /* widget _U_ */ , user_data, 8);
1681 }
1682
1683 static void
1684 tree_view_menu_color_with_flt_color9_cb(GtkAction *action _U_, gpointer user_data)
1685 {
1686         colorize_selected_ptree_cb( NULL /* widget _U_ */ , user_data, 9);
1687 }
1688
1689 static void
1690 tree_view_menu_color_with_flt_color10_cb(GtkAction *action _U_, gpointer user_data)
1691 {
1692         colorize_selected_ptree_cb( NULL /* widget _U_ */ , user_data, 10);
1693 }
1694
1695 static void
1696 tree_view_menu_color_with_flt_new_rule_cb(GtkAction *action _U_, gpointer user_data)
1697 {
1698         colorize_selected_ptree_cb( NULL /* widget _U_ */ , user_data, 0);
1699 }
1700
1701
1702 static void
1703 tree_view_menu_copy_desc(GtkAction *action _U_, gpointer user_data)
1704 {
1705         copy_selected_plist_cb( NULL /* widget _U_ */ , user_data, COPY_SELECTED_DESCRIPTION);
1706 }
1707
1708 static void
1709 tree_view_menu_copy_field(GtkAction *action _U_, gpointer user_data)
1710 {
1711         copy_selected_plist_cb( NULL /* widget _U_ */ , user_data, COPY_SELECTED_FIELDNAME);
1712 }
1713
1714 static void
1715 tree_view_menu_copy_value(GtkAction *action _U_, gpointer user_data)
1716 {
1717         copy_selected_plist_cb( NULL /* widget _U_ */ , user_data, COPY_SELECTED_VALUE);
1718 }
1719
1720 static void
1721 tree_view_menu_copy_as_flt(GtkAction *action _U_, gpointer user_data)
1722 {
1723         GtkWidget *widget = gtk_ui_manager_get_widget(ui_manager_tree_view_menu, "/TreeViewPopup/Copy/AsFilter");
1724         match_selected_ptree_cb( widget , user_data, MATCH_SELECTED_REPLACE|MATCH_SELECTED_COPY_ONLY);
1725 }
1726
1727 static const char *ui_desc_packet_list_heading_menu_popup =
1728 "<ui>\n"
1729 "  <popup name='PacketListHeadingPopup' action='PopupAction'>\n"
1730 "     <menuitem name='SortAscending' action='/Sort Ascending'/>\n"
1731 "     <menuitem name='SortDescending' action='/Sort Descending'/>\n"
1732 "     <menuitem name='NoSorting' action='/No Sorting'/>\n"
1733 "     <separator/>\n"
1734 "     <menuitem name='ShowResolved' action='/Show Resolved'/>\n"
1735 "     <separator/>\n"
1736 "     <menuitem name='AlignLeft' action='/Align Left'/>\n"
1737 "     <menuitem name='AlignCenter' action='/Align Center'/>\n"
1738 "     <menuitem name='AlignRight' action='/Align Right'/>\n"
1739 "     <separator/>\n"
1740 "     <menuitem name='ColumnPreferences' action='/Column Preferences'/>\n"
1741 "     <menuitem name='EditColumnDetails' action='/Edit Column Details'/>\n"
1742 "     <menuitem name='ResizeColumn' action='/Resize Column'/>\n"
1743 "     <separator/>\n"
1744 "     <menu name='DisplayedColumns' action='/Displayed Columns'>\n"
1745 "       <menuitem name='Display All' action='/Displayed Columns/Display All'/>\n"
1746 "     </menu>\n"
1747 "     <menuitem name='HideColumn' action='/Hide Column'/>\n"
1748 "     <menuitem name='RemoveColumn' action='/Remove Column'/>\n"
1749 "  </popup>\n"
1750 "</ui>\n";
1751
1752 static const GtkActionEntry packet_list_heading_menu_popup_action_entries[] = {
1753   { "/Sort Ascending",                                  GTK_STOCK_SORT_ASCENDING,                       "Sort Ascending",                       NULL,   NULL,   G_CALLBACK(sort_ascending_cb) },
1754   { "/Sort Descending",                                 GTK_STOCK_SORT_DESCENDING,                      "Sort Descending",                      NULL,   NULL,   G_CALLBACK(sort_descending_cb) },
1755   { "/No Sorting",                                              NULL,                                                           "No Sorting",                           NULL,   NULL,   G_CALLBACK(no_sorting_cb) },
1756   { "/Align Left",                                              GTK_STOCK_JUSTIFY_LEFT,                         "Align Left",                           NULL,   NULL,   G_CALLBACK(packet_list_heading_align_left_cb) },
1757   { "/Align Center",                                    GTK_STOCK_JUSTIFY_CENTER,                       "Align Center",                         NULL,   NULL,   G_CALLBACK(packet_list_heading_align_center_cb) },
1758   { "/Align Right",                                             GTK_STOCK_JUSTIFY_RIGHT,                        "Align Right",                          NULL,   NULL,   G_CALLBACK(packet_list_heading_align_right_cb) },
1759   { "/Column Preferences",                              GTK_STOCK_PREFERENCES,                          "Column Preferences...",        NULL,   NULL,   G_CALLBACK(packet_list_heading_col_pref_cb) },
1760   { "/Edit Column Details",                             WIRESHARK_STOCK_EDIT,                   "Edit Column Details...",       NULL,   NULL,   G_CALLBACK(packet_list_heading_change_col_cb) },
1761   { "/Resize Column",                                   WIRESHARK_STOCK_RESIZE_COLUMNS,         "Resize Column",                        NULL,   NULL,   G_CALLBACK(packet_list_heading_resize_col_cb) },
1762   { "/Displayed Columns",                               NULL,                                                           "Displayed Columns",            NULL,   NULL,   NULL },
1763   { "/Displayed Columns/Display All",                           NULL,                                   "Display All",                          NULL,   NULL,   G_CALLBACK(packet_list_heading_activate_all_columns_cb) },
1764   { "/Hide Column",                                             NULL,                                                           "Hide Column",                          NULL,   NULL,   G_CALLBACK(packet_list_heading_hide_col_cb) },
1765   { "/Remove Column",                                   GTK_STOCK_DELETE,                                       "Remove Column",                        NULL,   NULL,   G_CALLBACK(packet_list_heading_remove_col_cb) },
1766 };
1767
1768 static const GtkToggleActionEntry packet_list_heading_menu_toggle_action_entries[] =
1769 {
1770         /* name, stock id, label, accel, tooltip, callback, is_active */
1771         {"/Show Resolved",      NULL, "Show Resolved",  NULL, NULL,     G_CALLBACK(packet_list_heading_show_resolved_cb), FALSE},
1772 };
1773
1774 static const char *ui_desc_packet_list_menu_popup =
1775 "<ui>\n"
1776 "  <popup name='PacketListMenuPopup' action='PopupAction'>\n"
1777 "     <menuitem name='MarkPacket' action='/MarkPacket'/>\n"
1778 "     <menuitem name='IgnorePacket' action='/IgnorePacket'/>\n"
1779 "     <menuitem name='SetTimeReference' action='/Set Time Reference'/>\n"
1780 "     <menuitem name='TimeShift' action='/TimeShift'/>\n"
1781 "     <separator/>\n"
1782 "     <menuitem name='ManuallyResolveAddress' action='/ManuallyResolveAddress'/>\n"
1783 "     <separator/>\n"
1784 "     <menu name= 'ApplyAsFilter' action='/Apply as Filter'>\n"
1785 "       <menuitem name='Selected' action='/Apply as Filter/Selected'/>\n"
1786 "       <menuitem name='NotSelected' action='/Apply as Filter/Not Selected'/>\n"
1787 "       <menuitem name='AndSelected' action='/Apply as Filter/AndSelected'/>\n"
1788 "       <menuitem name='OrSelected' action='/Apply as Filter/OrSelected'/>\n"
1789 "       <menuitem name='AndNotSelected' action='/Apply as Filter/AndNotSelected'/>\n"
1790 "       <menuitem name='OrNotSelected' action='/Apply as Filter/OrNotSelected'/>\n"
1791 "     </menu>\n"
1792 "     <menu name= 'PrepareaFilter' action='/Prepare a Filter'>\n"
1793 "       <menuitem name='Selected' action='/Prepare a Filter/Selected'/>\n"
1794 "       <menuitem name='NotSelected' action='/Prepare a Filter/Not Selected'/>\n"
1795 "       <menuitem name='AndSelected' action='/Prepare a Filter/AndSelected'/>\n"
1796 "       <menuitem name='OrSelected' action='/Prepare a Filter/OrSelected'/>\n"
1797 "       <menuitem name='AndNotSelected' action='/Prepare a Filter/AndNotSelected'/>\n"
1798 "       <menuitem name='OrNotSelected' action='/Prepare a Filter/OrNotSelected'/>\n"
1799 "     </menu>\n"
1800 "     <menu name= 'ConversationFilter' action='/Conversation Filter'>\n"
1801 "       <menuitem name='Ethernet' action='/Conversation Filter/Ethernet'/>\n"
1802 "       <menuitem name='IP' action='/Conversation Filter/IP'/>\n"
1803 "       <menuitem name='TCP' action='/Conversation Filter/TCP'/>\n"
1804 "       <menuitem name='UDP' action='/Conversation Filter/UDP'/>\n"
1805 "       <menuitem name='PN-CBA' action='/Conversation Filter/PN-CBA'/>\n"
1806 "     </menu>\n"
1807 "     <menu name= 'ColorizeConversation' action='/Colorize Conversation'>\n"
1808 "        <menu name= 'Ethernet' action='/Colorize Conversation/Ethernet'>\n"
1809 "          <menuitem name='Color1' action='/Colorize Conversation/Ethernet/Color 1'/>\n"
1810 "          <menuitem name='Color2' action='/Colorize Conversation/Ethernet/Color 2'/>\n"
1811 "          <menuitem name='Color3' action='/Colorize Conversation/Ethernet/Color 3'/>\n"
1812 "          <menuitem name='Color4' action='/Colorize Conversation/Ethernet/Color 4'/>\n"
1813 "          <menuitem name='Color5' action='/Colorize Conversation/Ethernet/Color 5'/>\n"
1814 "          <menuitem name='Color6' action='/Colorize Conversation/Ethernet/Color 6'/>\n"
1815 "          <menuitem name='Color7' action='/Colorize Conversation/Ethernet/Color 7'/>\n"
1816 "          <menuitem name='Color8' action='/Colorize Conversation/Ethernet/Color 8'/>\n"
1817 "          <menuitem name='Color9' action='/Colorize Conversation/Ethernet/Color 9'/>\n"
1818 "          <menuitem name='Color10' action='/Colorize Conversation/Ethernet/Color 10'/>\n"
1819 "          <menuitem name='NewColoringRule' action='/Colorize Conversation/Ethernet/New Coloring Rule'/>\n"
1820 "        </menu>\n"
1821 "        <menu name= 'IP' action='/Colorize Conversation/IP'>\n"
1822 "          <menuitem name='Color1' action='/Colorize Conversation/IP/Color 1'/>\n"
1823 "          <menuitem name='Color2' action='/Colorize Conversation/IP/Color 2'/>\n"
1824 "          <menuitem name='Color3' action='/Colorize Conversation/IP/Color 3'/>\n"
1825 "          <menuitem name='Color4' action='/Colorize Conversation/IP/Color 4'/>\n"
1826 "          <menuitem name='Color5' action='/Colorize Conversation/IP/Color 5'/>\n"
1827 "          <menuitem name='Color6' action='/Colorize Conversation/IP/Color 6'/>\n"
1828 "          <menuitem name='Color7' action='/Colorize Conversation/IP/Color 7'/>\n"
1829 "          <menuitem name='Color8' action='/Colorize Conversation/IP/Color 8'/>\n"
1830 "          <menuitem name='Color9' action='/Colorize Conversation/IP/Color 9'/>\n"
1831 "          <menuitem name='Color10' action='/Colorize Conversation/IP/Color 10'/>\n"
1832 "          <menuitem name='NewColoringRule' action='/Colorize Conversation/IP/New Coloring Rule'/>\n"
1833 "        </menu>\n"
1834 "        <menu name= 'TCP' action='/Colorize Conversation/TCP'>\n"
1835 "          <menuitem name='Color1' action='/Colorize Conversation/TCP/Color 1'/>\n"
1836 "          <menuitem name='Color2' action='/Colorize Conversation/TCP/Color 2'/>\n"
1837 "          <menuitem name='Color3' action='/Colorize Conversation/TCP/Color 3'/>\n"
1838 "          <menuitem name='Color4' action='/Colorize Conversation/TCP/Color 4'/>\n"
1839 "          <menuitem name='Color5' action='/Colorize Conversation/TCP/Color 5'/>\n"
1840 "          <menuitem name='Color6' action='/Colorize Conversation/TCP/Color 6'/>\n"
1841 "          <menuitem name='Color7' action='/Colorize Conversation/TCP/Color 7'/>\n"
1842 "          <menuitem name='Color8' action='/Colorize Conversation/TCP/Color 8'/>\n"
1843 "          <menuitem name='Color9' action='/Colorize Conversation/TCP/Color 9'/>\n"
1844 "          <menuitem name='Color10' action='/Colorize Conversation/TCP/Color 10'/>\n"
1845 "          <menuitem name='NewColoringRule' action='/Colorize Conversation/TCP/New Coloring Rule'/>\n"
1846 "        </menu>\n"
1847 "        <menu name= 'UDP' action='/Colorize Conversation/UDP'>\n"
1848 "          <menuitem name='Color1' action='/Colorize Conversation/UDP/Color 1'/>\n"
1849 "          <menuitem name='Color2' action='/Colorize Conversation/UDP/Color 2'/>\n"
1850 "          <menuitem name='Color3' action='/Colorize Conversation/UDP/Color 3'/>\n"
1851 "          <menuitem name='Color4' action='/Colorize Conversation/UDP/Color 4'/>\n"
1852 "          <menuitem name='Color5' action='/Colorize Conversation/UDP/Color 5'/>\n"
1853 "          <menuitem name='Color6' action='/Colorize Conversation/UDP/Color 6'/>\n"
1854 "          <menuitem name='Color7' action='/Colorize Conversation/UDP/Color 7'/>\n"
1855 "          <menuitem name='Color8' action='/Colorize Conversation/UDP/Color 8'/>\n"
1856 "          <menuitem name='Color9' action='/Colorize Conversation/UDP/Color 9'/>\n"
1857 "          <menuitem name='Color10' action='/Colorize Conversation/UDP/Color 10'/>\n"
1858 "          <menuitem name='NewColoringRule' action='/Colorize Conversation/UDP/New Coloring Rule'/>\n"
1859 "        </menu>\n"
1860 "        <menu name= 'PN-CBA' action='/Colorize Conversation/PN-CBA'>\n"
1861 "          <menuitem name='Color1' action='/Colorize Conversation/PN-CBA/Color 1'/>\n"
1862 "          <menuitem name='Color2' action='/Colorize Conversation/PN-CBA/Color 2'/>\n"
1863 "          <menuitem name='Color3' action='/Colorize Conversation/PN-CBA/Color 3'/>\n"
1864 "          <menuitem name='Color4' action='/Colorize Conversation/PN-CBA/Color 4'/>\n"
1865 "          <menuitem name='Color5' action='/Colorize Conversation/PN-CBA/Color 5'/>\n"
1866 "          <menuitem name='Color6' action='/Colorize Conversation/PN-CBA/Color 6'/>\n"
1867 "          <menuitem name='Color7' action='/Colorize Conversation/PN-CBA/Color 7'/>\n"
1868 "          <menuitem name='Color8' action='/Colorize Conversation/PN-CBA/Color 8'/>\n"
1869 "          <menuitem name='Color9' action='/Colorize Conversation/PN-CBA/Color 9'/>\n"
1870 "          <menuitem name='Color10' action='/Colorize Conversation/PN-CBA/Color 10'/>\n"
1871 "          <menuitem name='NewColoringRule' action='/Colorize Conversation/PN-CBA/New Coloring Rule'/>\n"
1872 "        </menu>\n"
1873 "     </menu>\n"
1874 "     <menu name= 'SCTP' action='/SCTP'>\n"
1875 "        <menuitem name='AnalysethisAssociation' action='/SCTP/Analyse this Association'/>\n"
1876 "        <menuitem name='PrepareFilterforthisAssociation' action='/SCTP/Prepare Filter for this Association'/>\n"
1877 "     </menu>\n"
1878 "     <menuitem name='FollowTCPStream' action='/Follow TCP Stream'/>\n"
1879 "     <menuitem name='FollowUDPStream' action='/Follow UDP Stream'/>\n"
1880 "     <menuitem name='FollowSSLStream' action='/Follow SSL Stream'/>\n"
1881 "     <separator/>\n"
1882 "     <menu name= 'Copy' action='/Copy'>\n"
1883 "        <menuitem name='SummaryTxt' action='/Copy/SummaryTxt'/>\n"
1884 "        <menuitem name='SummaryCSV' action='/Copy/SummaryCSV'/>\n"
1885 "        <menuitem name='AsFilter' action='/Copy/AsFilter'/>\n"
1886 "        <separator/>\n"
1887 "        <menu name= 'Bytes' action='/Copy/Bytes'>\n"
1888 "           <menuitem name='OffsetHexText' action='/Copy/Bytes/OffsetHexText'/>\n"
1889 "           <menuitem name='OffsetHex' action='/Copy/Bytes/OffsetHex'/>\n"
1890 "           <menuitem name='PrintableTextOnly' action='/Copy/Bytes/PrintableTextOnly'/>\n"
1891 "           <separator/>\n"
1892 "           <menuitem name='HexStream' action='/Copy/Bytes/HexStream'/>\n"
1893 "           <menuitem name='BinaryStream' action='/Copy/Bytes/BinaryStream'/>\n"
1894 "        </menu>\n"
1895 "     </menu>\n"
1896 "     <separator/>\n"
1897 "     <menuitem name='DecodeAs' action='/DecodeAs'/>\n"
1898 "     <menuitem name='Print' action='/Print'/>\n"
1899 "     <menuitem name='ShowPacketinNewWindow' action='/ShowPacketinNewWindow'/>\n"
1900 "  </popup>\n"
1901 "</ui>\n";
1902
1903 static const GtkActionEntry packet_list_menu_popup_action_entries[] = {
1904   { "/MarkPacket",                                              NULL,                                   "Mark Packet (toggle)",                 NULL,                                   NULL,                   G_CALLBACK(new_packet_list_mark_frame_cb) },
1905   { "/IgnorePacket",                                    NULL,                                   "Ignore Packet (toggle)",               NULL,                                   NULL,                   G_CALLBACK(new_packet_list_ignore_frame_cb) },
1906   { "/Set Time Reference",                              WIRESHARK_STOCK_TIME,   "Set Time Reference (toggle)",  NULL,                                   NULL,                   G_CALLBACK(packet_list_menu_set_ref_time_cb) },
1907   { "/TimeShift",                                               WIRESHARK_STOCK_TIME,   "Time Shift...",                                        NULL,                                   NULL,                   G_CALLBACK(time_shift_cb) },
1908   { "/ManuallyResolveAddress",                  NULL,                                   "Manually Resolve Address",             NULL,                                   NULL,                   G_CALLBACK(manual_addr_resolv_dlg) },
1909   { "/Apply as Filter",                                 NULL,                                   "Apply as Filter",                              NULL,                                   NULL,                   NULL },
1910
1911   { "/Apply as Filter/Selected",                NULL, "_Selected" ,                             NULL, NULL, G_CALLBACK(packet_list_menu_apply_selected_cb) },
1912   { "/Apply as Filter/Not Selected",    NULL, "_Not Selected",                  NULL, NULL, G_CALLBACK(packet_list_menu_apply_not_selected_cb) },
1913   { "/Apply as Filter/AndSelected",             NULL, UTF8_HORIZONTAL_ELLIPSIS " _and Selected",                NULL, NULL, G_CALLBACK(packet_list_menu_apply_and_selected_cb) },
1914   { "/Apply as Filter/OrSelected",              NULL, UTF8_HORIZONTAL_ELLIPSIS " _or Selected",         NULL, NULL, G_CALLBACK(packet_list_menu_apply_or_selected_cb) },
1915   { "/Apply as Filter/AndNotSelected",  NULL, UTF8_HORIZONTAL_ELLIPSIS " a_nd not Selected",    NULL, NULL, G_CALLBACK(packet_list_menu_apply_and_not_selected_cb) },
1916   { "/Apply as Filter/OrNotSelected",   NULL, UTF8_HORIZONTAL_ELLIPSIS " o_r not Selected",     NULL, NULL, G_CALLBACK(packet_list_menu_apply_or_not_selected_cb) },
1917
1918   { "/Prepare a Filter",                                NULL, "Prepare a Filter",               NULL, NULL, NULL },
1919   { "/Prepare a Filter/Selected",               NULL, "_Selected" ,                             NULL, NULL, G_CALLBACK(packet_list_menu_prepare_selected_cb) },
1920   { "/Prepare a Filter/Not Selected",   NULL, "_Not Selected",                  NULL, NULL, G_CALLBACK(packet_list_menu_prepare_not_selected_cb) },
1921   { "/Prepare a Filter/AndSelected",    NULL, UTF8_HORIZONTAL_ELLIPSIS " _and Selected",                NULL, NULL, G_CALLBACK(packet_list_menu_prepare_and_selected_cb) },
1922   { "/Prepare a Filter/OrSelected",             NULL, UTF8_HORIZONTAL_ELLIPSIS " _or Selected",         NULL, NULL, G_CALLBACK(packet_list_menu_prepare_or_selected_cb) },
1923   { "/Prepare a Filter/AndNotSelected", NULL, UTF8_HORIZONTAL_ELLIPSIS " a_nd not Selected",    NULL, NULL, G_CALLBACK(packet_list_menu_prepare_and_not_selected_cb) },
1924   { "/Prepare a Filter/OrNotSelected",  NULL, UTF8_HORIZONTAL_ELLIPSIS " o_r not Selected",     NULL, NULL, G_CALLBACK(packet_list_menu_prepare_or_not_selected_cb) },
1925
1926   { "/Conversation Filter",                             NULL, "Conversation Filter",    NULL, NULL, NULL },
1927   { "/Conversation Filter/Ethernet",    NULL, "Ethernet",                               NULL, NULL, G_CALLBACK(packet_list_menu_conversation_ethernet_cb) },
1928   { "/Conversation Filter/IP",                  NULL, "IP",                                             NULL, NULL, G_CALLBACK(packet_list_menu_conversation_ip_cb) },
1929   { "/Conversation Filter/TCP",                 NULL, "TCP",                                    NULL, NULL, G_CALLBACK(packet_list_menu_conversation_tcp_cb) },
1930   { "/Conversation Filter/UDP",                 NULL, "UDP",                                    NULL, NULL, G_CALLBACK(packet_list_menu_conversation_udp_cb) },
1931   { "/Conversation Filter/PN-CBA",              NULL, "PN-CBA",                                 NULL, NULL, G_CALLBACK(packet_list_menu_conversation_pn_cba_cb) },
1932
1933   { "/Colorize Conversation",                   NULL, "Colorize Conversation",  NULL, NULL, NULL },
1934
1935   { "/Colorize Conversation/Ethernet",  NULL, "Ethernet",                               NULL, NULL, NULL },
1936
1937   { "/Colorize Conversation/Ethernet/Color 1",  WIRESHARK_STOCK_COLOR1, "Color 1",                                      NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_ethernet_color1_cb) },
1938   { "/Colorize Conversation/Ethernet/Color 2",  WIRESHARK_STOCK_COLOR2, "Color 2",                                      NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_ethernet_color2_cb) },
1939   { "/Colorize Conversation/Ethernet/Color 3",  WIRESHARK_STOCK_COLOR3, "Color 3",                                      NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_ethernet_color3_cb) },
1940   { "/Colorize Conversation/Ethernet/Color 4",  WIRESHARK_STOCK_COLOR4, "Color 4",                                      NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_ethernet_color4_cb) },
1941   { "/Colorize Conversation/Ethernet/Color 5",  WIRESHARK_STOCK_COLOR5, "Color 5",                                      NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_ethernet_color5_cb) },
1942   { "/Colorize Conversation/Ethernet/Color 6",  WIRESHARK_STOCK_COLOR6, "Color 6",                                      NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_ethernet_color6_cb) },
1943   { "/Colorize Conversation/Ethernet/Color 7",  WIRESHARK_STOCK_COLOR7, "Color 7",                                      NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_ethernet_color7_cb) },
1944   { "/Colorize Conversation/Ethernet/Color 8",  WIRESHARK_STOCK_COLOR8, "Color 8",                                      NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_ethernet_color8_cb) },
1945   { "/Colorize Conversation/Ethernet/Color 9",  WIRESHARK_STOCK_COLOR9, "Color 9",                                      NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_ethernet_color9_cb) },
1946   { "/Colorize Conversation/Ethernet/Color 10", WIRESHARK_STOCK_COLOR0, "Color 10",                                     NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_ethernet_color10_cb) },
1947   { "/Colorize Conversation/Ethernet/New Coloring Rule",        NULL,           "New Coloring Rule...",         NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_ethernet_new_rule_cb) },
1948
1949   { "/Colorize Conversation/IP",                NULL, "IP",                             NULL, NULL, NULL },
1950
1951   { "/Colorize Conversation/IP/Color 1",                WIRESHARK_STOCK_COLOR1, "Color 1",                                      NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_ip_color1_cb) },
1952   { "/Colorize Conversation/IP/Color 2",                WIRESHARK_STOCK_COLOR2, "Color 2",                                      NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_ip_color2_cb) },
1953   { "/Colorize Conversation/IP/Color 3",                WIRESHARK_STOCK_COLOR3, "Color 3",                                      NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_ip_color3_cb) },
1954   { "/Colorize Conversation/IP/Color 4",                WIRESHARK_STOCK_COLOR4, "Color 4",                                      NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_ip_color4_cb) },
1955   { "/Colorize Conversation/IP/Color 5",                WIRESHARK_STOCK_COLOR5, "Color 5",                                      NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_ip_color5_cb) },
1956   { "/Colorize Conversation/IP/Color 6",                WIRESHARK_STOCK_COLOR6, "Color 6",                                      NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_ip_color6_cb) },
1957   { "/Colorize Conversation/IP/Color 7",                WIRESHARK_STOCK_COLOR7, "Color 7",                                      NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_ip_color7_cb) },
1958   { "/Colorize Conversation/IP/Color 8",                WIRESHARK_STOCK_COLOR8, "Color 8",                                      NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_ip_color8_cb) },
1959   { "/Colorize Conversation/IP/Color 9",                WIRESHARK_STOCK_COLOR9, "Color 9",                                      NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_ip_color9_cb) },
1960   { "/Colorize Conversation/IP/Color 10",               WIRESHARK_STOCK_COLOR0, "Color 10",                                     NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_ip_color10_cb) },
1961   { "/Colorize Conversation/IP/New Coloring Rule",      NULL,           "New Coloring Rule...",                         NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_ip_new_rule_cb) },
1962
1963   { "/Colorize Conversation/TCP",               NULL, "TCP",                            NULL, NULL, NULL },
1964
1965   { "/Colorize Conversation/TCP/Color 1",               WIRESHARK_STOCK_COLOR1, "Color 1",                                      NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_tcp_color1_cb) },
1966   { "/Colorize Conversation/TCP/Color 2",               WIRESHARK_STOCK_COLOR2, "Color 2",                                      NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_tcp_color2_cb) },
1967   { "/Colorize Conversation/TCP/Color 3",               WIRESHARK_STOCK_COLOR3, "Color 3",                                      NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_tcp_color3_cb) },
1968   { "/Colorize Conversation/TCP/Color 4",               WIRESHARK_STOCK_COLOR4, "Color 4",                                      NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_tcp_color4_cb) },
1969   { "/Colorize Conversation/TCP/Color 5",               WIRESHARK_STOCK_COLOR5, "Color 5",                                      NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_tcp_color5_cb) },
1970   { "/Colorize Conversation/TCP/Color 6",               WIRESHARK_STOCK_COLOR6, "Color 6",                                      NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_tcp_color6_cb) },
1971   { "/Colorize Conversation/TCP/Color 7",               WIRESHARK_STOCK_COLOR7, "Color 7",                                      NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_tcp_color7_cb) },
1972   { "/Colorize Conversation/TCP/Color 8",               WIRESHARK_STOCK_COLOR8, "Color 8",                                      NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_tcp_color8_cb) },
1973   { "/Colorize Conversation/TCP/Color 9",               WIRESHARK_STOCK_COLOR9, "Color 9",                                      NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_tcp_color9_cb) },
1974   { "/Colorize Conversation/TCP/Color 10",              WIRESHARK_STOCK_COLOR0, "Color 10",                                     NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_tcp_color10_cb) },
1975   { "/Colorize Conversation/TCP/New Coloring Rule",     NULL,           "New Coloring Rule...",                         NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_tcp_new_rule_cb) },
1976
1977   { "/Colorize Conversation/UDP",               NULL, "UDP",                            NULL, NULL, NULL },
1978
1979   { "/Colorize Conversation/UDP/Color 1",               WIRESHARK_STOCK_COLOR1, "Color 1",                                      NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_udp_color1_cb) },
1980   { "/Colorize Conversation/UDP/Color 2",               WIRESHARK_STOCK_COLOR2, "Color 2",                                      NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_udp_color2_cb) },
1981   { "/Colorize Conversation/UDP/Color 3",               WIRESHARK_STOCK_COLOR3, "Color 3",                                      NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_udp_color3_cb) },
1982   { "/Colorize Conversation/UDP/Color 4",               WIRESHARK_STOCK_COLOR4, "Color 4",                                      NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_udp_color4_cb) },
1983   { "/Colorize Conversation/UDP/Color 5",               WIRESHARK_STOCK_COLOR5, "Color 5",                                      NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_udp_color5_cb) },
1984   { "/Colorize Conversation/UDP/Color 6",               WIRESHARK_STOCK_COLOR6, "Color 6",                                      NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_udp_color6_cb) },
1985   { "/Colorize Conversation/UDP/Color 7",               WIRESHARK_STOCK_COLOR7, "Color 7",                                      NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_udp_color7_cb) },
1986   { "/Colorize Conversation/UDP/Color 8",               WIRESHARK_STOCK_COLOR8, "Color 8",                                      NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_udp_color8_cb) },
1987   { "/Colorize Conversation/UDP/Color 9",               WIRESHARK_STOCK_COLOR9, "Color 9",                                      NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_udp_color9_cb) },
1988   { "/Colorize Conversation/UDP/Color 10",              WIRESHARK_STOCK_COLOR0, "Color 10",                                     NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_udp_color10_cb) },
1989   { "/Colorize Conversation/UDP/New Coloring Rule",     NULL,           "New Coloring Rule...",                         NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_udp_new_rule_cb) },
1990
1991   { "/Colorize Conversation/PN-CBA",            NULL, "PN-CBA Server",                          NULL, NULL, NULL },
1992
1993   { "/Colorize Conversation/PN-CBA/Color 1",            WIRESHARK_STOCK_COLOR1, "Color 1",                                      NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_cba_color1_cb) },
1994   { "/Colorize Conversation/PN-CBA/Color 2",            WIRESHARK_STOCK_COLOR2, "Color 2",                                      NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_cba_color2_cb) },
1995   { "/Colorize Conversation/PN-CBA/Color 3",            WIRESHARK_STOCK_COLOR3, "Color 3",                                      NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_cba_color3_cb) },
1996   { "/Colorize Conversation/PN-CBA/Color 4",            WIRESHARK_STOCK_COLOR4, "Color 4",                                      NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_cba_color4_cb) },
1997   { "/Colorize Conversation/PN-CBA/Color 5",            WIRESHARK_STOCK_COLOR5, "Color 5",                                      NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_cba_color5_cb) },
1998   { "/Colorize Conversation/PN-CBA/Color 6",            WIRESHARK_STOCK_COLOR6, "Color 6",                                      NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_cba_color6_cb) },
1999   { "/Colorize Conversation/PN-CBA/Color 7",            WIRESHARK_STOCK_COLOR7, "Color 7",                                      NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_cba_color7_cb) },
2000   { "/Colorize Conversation/PN-CBA/Color 8",            WIRESHARK_STOCK_COLOR8, "Color 8",                                      NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_cba_color8_cb) },
2001   { "/Colorize Conversation/PN-CBA/Color 9",            WIRESHARK_STOCK_COLOR9, "Color 9",                                      NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_cba_color9_cb) },
2002   { "/Colorize Conversation/PN-CBA/Color 10",           WIRESHARK_STOCK_COLOR0, "Color 10",                                     NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_cba_color10_cb) },
2003   { "/Colorize Conversation/PN-CBA/New Coloring Rule",  NULL,           "New Coloring Rule...",                         NULL, NULL, G_CALLBACK(packet_list_menu_color_conv_cba_new_rule_cb) },
2004
2005   { "/SCTP",            NULL, "SCTP",                           NULL, NULL, NULL },
2006   { "/SCTP/Analyse this Association",                           NULL,           "Analyse this Association",                             NULL, NULL, G_CALLBACK(sctp_analyse_start) },
2007   { "/SCTP/Prepare Filter for this Association",        NULL,           "Prepare Filter for this Association",  NULL, NULL, G_CALLBACK(sctp_set_assoc_filter) },
2008
2009
2010   { "/Follow TCP Stream",                                                       NULL,           "Follow TCP Stream",                                    NULL, NULL, G_CALLBACK(follow_tcp_stream_cb) },
2011   { "/Follow UDP Stream",                                                       NULL,           "Follow UDP Stream",                                    NULL, NULL, G_CALLBACK(follow_udp_stream_cb) },
2012   { "/Follow SSL Stream",                                                       NULL,           "Follow SSL Stream",                                    NULL, NULL, G_CALLBACK(follow_ssl_stream_cb) },
2013
2014   { "/Copy",            NULL, "Copy",                                   NULL, NULL, NULL },
2015   { "/Copy/SummaryTxt",                                                         NULL,           "Summary (Text)",                                               NULL, NULL, G_CALLBACK(packet_list_menu_copy_sum_txt) },
2016   { "/Copy/SummaryCSV",                                                         NULL,           "Summary (CSV)",                                                NULL, NULL, G_CALLBACK(packet_list_menu_copy_sum_csv) },
2017   { "/Copy/AsFilter",                                                           NULL,           "As Filter",                                                    NULL, NULL, G_CALLBACK(packet_list_menu_copy_as_flt) },
2018
2019
2020   { "/Copy/Bytes",                                                                      NULL,           "Bytes",                                        NULL, NULL, NULL },
2021   { "/Copy/Bytes/OffsetHexText",                                        NULL,           "Offset Hex Text",                                              NULL, NULL, G_CALLBACK(packet_list_menu_copy_bytes_oht_cb) },
2022   { "/Copy/Bytes/OffsetHex",                                            NULL,           "Offset Hex",                                                   NULL, NULL, G_CALLBACK(packet_list_menu_copy_bytes_oh_cb) },
2023   { "/Copy/Bytes/PrintableTextOnly",                            NULL,           "Printable Text Only",                                  NULL, NULL, G_CALLBACK(packet_list_menu_copy_bytes_text_cb) },
2024
2025   { "/Copy/Bytes/HexStream",                                            NULL,           "Hex Stream",                                                   NULL, NULL, G_CALLBACK(packet_list_menu_copy_bytes_hex_strm_cb) },
2026   { "/Copy/Bytes/BinaryStream",                                         NULL,           "Binary Stream",                                                NULL, NULL, G_CALLBACK(packet_list_menu_copy_bytes_bin_strm_cb) },
2027
2028   { "/DecodeAs",                                                                        WIRESHARK_STOCK_DECODE_AS,      "Decode As...",                 NULL, NULL, G_CALLBACK(decode_as_cb) },
2029   { "/Print",                                                                           GTK_STOCK_PRINT,                        "Print...",                             NULL, NULL, G_CALLBACK(file_print_selected_cmd_cb) },
2030   { "/ShowPacketinNewWindow",                                           NULL,                   "Show Packet in New Window",            NULL, NULL, G_CALLBACK(new_window_cb) },
2031
2032 };
2033
2034 static const char *ui_desc_tree_view_menu_popup =
2035 "<ui>\n"
2036 "  <popup name='TreeViewPopup' action='PopupAction'>\n"
2037 "     <menuitem name='ExpandSubtrees' action='/ExpandSubtrees'/>\n"
2038 "     <menuitem name='ExpandAll' action='/ExpandAll'/>\n"
2039 "     <menuitem name='CollapseAll' action='/CollapseAll'/>\n"
2040 "     <separator/>\n"
2041 "     <menuitem name='ApplyasColumn' action='/Apply as Column'/>\n"
2042 "     <separator/>\n"
2043 "     <menu name= 'ApplyAsFilter' action='/Apply as Filter'>\n"
2044 "       <menuitem name='Selected' action='/Apply as Filter/Selected'/>\n"
2045 "       <menuitem name='NotSelected' action='/Apply as Filter/Not Selected'/>\n"
2046 "       <menuitem name='AndSelected' action='/Apply as Filter/AndSelected'/>\n"
2047 "       <menuitem name='OrSelected' action='/Apply as Filter/OrSelected'/>\n"
2048 "       <menuitem name='AndNotSelected' action='/Apply as Filter/AndNotSelected'/>\n"
2049 "       <menuitem name='OrNotSelected' action='/Apply as Filter/OrNotSelected'/>\n"
2050 "     </menu>\n"
2051 "     <menu name= 'PrepareaFilter' action='/Prepare a Filter'>\n"
2052 "       <menuitem name='Selected' action='/Prepare a Filter/Selected'/>\n"
2053 "       <menuitem name='NotSelected' action='/Prepare a Filter/Not Selected'/>\n"
2054 "       <menuitem name='AndSelected' action='/Prepare a Filter/AndSelected'/>\n"
2055 "       <menuitem name='OrSelected' action='/Prepare a Filter/OrSelected'/>\n"
2056 "       <menuitem name='AndNotSelected' action='/Prepare a Filter/AndNotSelected'/>\n"
2057 "       <menuitem name='OrNotSelected' action='/Prepare a Filter/OrNotSelected'/>\n"
2058 "     </menu>\n"
2059 "     <menu name= 'ColorizewithFilter' action='/Colorize with Filter'>\n"
2060 "       <menuitem name='Color1' action='/Colorize with Filter/Color 1'/>\n"
2061 "       <menuitem name='Color2' action='/Colorize with Filter/Color 2'/>\n"
2062 "       <menuitem name='Color3' action='/Colorize with Filter/Color 3'/>\n"
2063 "       <menuitem name='Color4' action='/Colorize with Filter/Color 4'/>\n"
2064 "       <menuitem name='Color5' action='/Colorize with Filter/Color 5'/>\n"
2065 "       <menuitem name='Color6' action='/Colorize with Filter/Color 6'/>\n"
2066 "       <menuitem name='Color7' action='/Colorize with Filter/Color 7'/>\n"
2067 "       <menuitem name='Color8' action='/Colorize with Filter/Color 8'/>\n"
2068 "       <menuitem name='Color9' action='/Colorize with Filter/Color 9'/>\n"
2069 "       <menuitem name='Color10' action='/Colorize with Filter/Color 10'/>\n"
2070 "       <menuitem name='NewColoringRule' action='/Colorize with Filter/New Coloring Rule'/>\n"
2071 "     </menu>\n"
2072 "     <menuitem name='FollowTCPStream' action='/Follow TCP Stream'/>\n"
2073 "     <menuitem name='FollowUDPStream' action='/Follow UDP Stream'/>\n"
2074 "     <menuitem name='FollowSSLStream' action='/Follow SSL Stream'/>\n"
2075 "     <separator/>\n"
2076 "     <menu name= 'Copy' action='/Copy'>\n"
2077 "        <menuitem name='Description' action='/Copy/Description'/>\n"
2078 "        <menuitem name='Fieldname' action='/Copy/Fieldname'/>\n"
2079 "        <menuitem name='Value' action='/Copy/Value'/>\n"
2080 "        <separator/>\n"
2081 "        <menuitem name='AsFilter' action='/Copy/AsFilter'/>\n"
2082 "        <separator/>\n"
2083 "        <menu name= 'Bytes' action='/Copy/Bytes'>\n"
2084 "           <menuitem name='OffsetHexText' action='/Copy/Bytes/OffsetHexText'/>\n"
2085 "           <menuitem name='OffsetHex' action='/Copy/Bytes/OffsetHex'/>\n"
2086 "           <menuitem name='PrintableTextOnly' action='/Copy/Bytes/PrintableTextOnly'/>\n"
2087 "           <separator/>\n"
2088 "           <menuitem name='HexStream' action='/Copy/Bytes/HexStream'/>\n"
2089 "           <menuitem name='BinaryStream' action='/Copy/Bytes/BinaryStream'/>\n"
2090 "        </menu>\n"
2091 "     </menu>\n"
2092 "     <menuitem name='ExportSelectedPacketBytes' action='/ExportSelectedPacketBytes'/>\n"
2093 "     <separator/>\n"
2094 "     <menuitem name='WikiProtocolPage' action='/WikiProtocolPage'/>\n"
2095 "     <menuitem name='FilterFieldReference' action='/FilterFieldReference'/>\n"
2096 "     <menuitem name='ProtocolHelp' action='/ProtocolHelp'/>\n"
2097 "     <menuitem name='ProtocolPreferences' action='/ProtocolPreferences'/>\n"
2098 "     <separator/>\n"
2099 "     <menuitem name='DecodeAs' action='/DecodeAs'/>\n"
2100 "     <menuitem name='DisableProtocol' action='/DisableProtocol'/>\n"
2101 "     <menuitem name='ResolveName' action='/ResolveName'/>\n"
2102 "     <menuitem name='GotoCorrespondingPacket' action='/GotoCorrespondingPacket'/>\n"
2103 "  </popup>\n"
2104 "</ui>\n";
2105
2106 static const GtkActionEntry tree_view_menu_popup_action_entries[] = {
2107   { "/ExpandSubtrees",                                  NULL,                                                   "Expand Subtrees",              NULL,                                   NULL,                   G_CALLBACK(expand_tree_cb) },
2108   { "/ExpandAll",                                               NULL,                                                   "Expand All",                   NULL,                                   NULL,                   G_CALLBACK(expand_all_cb) },
2109   { "/CollapseAll",                                             NULL,                                                   "Collapse All",                 NULL,                                   NULL,                   G_CALLBACK(collapse_all_cb) },
2110   { "/Apply as Column",                                 NULL,                                                   "Apply as Column",              NULL,                                   NULL,                   G_CALLBACK(apply_as_custom_column_cb) },
2111   { "/Apply as Filter",                                 NULL,                                                   "Apply as Filter",              NULL,                                   NULL,                   NULL },
2112
2113   { "/Apply as Filter/Selected",                NULL, "_Selected" ,                             NULL, NULL, G_CALLBACK(tree_view_menu_apply_selected_cb) },
2114   { "/Apply as Filter/Not Selected",    NULL, "_Not Selected",                  NULL, NULL, G_CALLBACK(tree_view_menu_apply_not_selected_cb) },
2115   { "/Apply as Filter/AndSelected",             NULL, UTF8_HORIZONTAL_ELLIPSIS " _and Selected",                NULL, NULL, G_CALLBACK(tree_view_menu_apply_and_selected_cb) },
2116   { "/Apply as Filter/OrSelected",              NULL, UTF8_HORIZONTAL_ELLIPSIS " _or Selected",         NULL, NULL, G_CALLBACK(tree_view_menu_apply_or_selected_cb) },
2117   { "/Apply as Filter/AndNotSelected",  NULL, UTF8_HORIZONTAL_ELLIPSIS " a_nd not Selected",    NULL, NULL, G_CALLBACK(tree_view_menu_apply_and_not_selected_cb) },
2118   { "/Apply as Filter/OrNotSelected",   NULL, UTF8_HORIZONTAL_ELLIPSIS " o_r not Selected",     NULL, NULL, G_CALLBACK(tree_view_menu_apply_or_not_selected_cb) },
2119
2120   { "/Prepare a Filter",                                NULL, "Prepare a Filter",               NULL, NULL, NULL },
2121   { "/Prepare a Filter/Selected",               NULL, "_Selected" ,                             NULL, NULL, G_CALLBACK(tree_view_menu_prepare_selected_cb) },
2122   { "/Prepare a Filter/Not Selected",   NULL, "_Not Selected",                  NULL, NULL, G_CALLBACK(tree_view_menu_prepare_not_selected_cb) },
2123   { "/Prepare a Filter/AndSelected",    NULL, UTF8_HORIZONTAL_ELLIPSIS " _and Selected",                NULL, NULL, G_CALLBACK(tree_view_menu_prepare_and_selected_cb) },
2124   { "/Prepare a Filter/OrSelected",             NULL, UTF8_HORIZONTAL_ELLIPSIS " _or Selected",         NULL, NULL, G_CALLBACK(tree_view_menu_prepare_or_selected_cb) },
2125   { "/Prepare a Filter/AndNotSelected", NULL, UTF8_HORIZONTAL_ELLIPSIS " a_nd not Selected",    NULL, NULL, G_CALLBACK(tree_view_menu_prepare_and_not_selected_cb) },
2126   { "/Prepare a Filter/OrNotSelected",  NULL, UTF8_HORIZONTAL_ELLIPSIS " o_r not Selected",     NULL, NULL, G_CALLBACK(tree_view_menu_prepare_or_not_selected_cb) },
2127
2128   { "/Colorize with Filter",                    NULL, "Colorize with Filter",   NULL, NULL, NULL },
2129   { "/Colorize with Filter/Color 1",            WIRESHARK_STOCK_COLOR1, "Color 1",                                      NULL, NULL, G_CALLBACK(tree_view_menu_color_with_flt_color1_cb) },
2130   { "/Colorize with Filter/Color 2",            WIRESHARK_STOCK_COLOR2, "Color 2",                                      NULL, NULL, G_CALLBACK(tree_view_menu_color_with_flt_color2_cb) },
2131   { "/Colorize with Filter/Color 3",            WIRESHARK_STOCK_COLOR3, "Color 3",                                      NULL, NULL, G_CALLBACK(tree_view_menu_color_with_flt_color3_cb) },
2132   { "/Colorize with Filter/Color 4",            WIRESHARK_STOCK_COLOR4, "Color 4",                                      NULL, NULL, G_CALLBACK(tree_view_menu_color_with_flt_color4_cb) },
2133   { "/Colorize with Filter/Color 5",            WIRESHARK_STOCK_COLOR5, "Color 5",                                      NULL, NULL, G_CALLBACK(tree_view_menu_color_with_flt_color5_cb) },
2134   { "/Colorize with Filter/Color 6",            WIRESHARK_STOCK_COLOR6, "Color 6",                                      NULL, NULL, G_CALLBACK(tree_view_menu_color_with_flt_color6_cb) },
2135   { "/Colorize with Filter/Color 7",            WIRESHARK_STOCK_COLOR7, "Color 7",                                      NULL, NULL, G_CALLBACK(tree_view_menu_color_with_flt_color7_cb) },
2136   { "/Colorize with Filter/Color 8",            WIRESHARK_STOCK_COLOR8, "Color 8",                                      NULL, NULL, G_CALLBACK(tree_view_menu_color_with_flt_color8_cb) },
2137   { "/Colorize with Filter/Color 9",            WIRESHARK_STOCK_COLOR9, "Color 9",                                      NULL, NULL, G_CALLBACK(tree_view_menu_color_with_flt_color9_cb) },
2138   { "/Colorize with Filter/Color 10",           WIRESHARK_STOCK_COLOR0, "Color 10",                                     NULL, NULL, G_CALLBACK(tree_view_menu_color_with_flt_color10_cb) },
2139   { "/Colorize with Filter/New Coloring Rule",  NULL,           "New Coloring Rule...",                         NULL, NULL, G_CALLBACK(tree_view_menu_color_with_flt_new_rule_cb) },
2140
2141   { "/Follow TCP Stream",                                                       NULL,           "Follow TCP Stream",                                    NULL, NULL, G_CALLBACK(follow_tcp_stream_cb) },
2142   { "/Follow UDP Stream",                                                       NULL,           "Follow UDP Stream",                                    NULL, NULL, G_CALLBACK(follow_udp_stream_cb) },
2143   { "/Follow SSL Stream",                                                       NULL,           "Follow SSL Stream",                                    NULL, NULL, G_CALLBACK(follow_ssl_stream_cb) },
2144
2145   { "/Copy",            NULL, "Copy",                                   NULL, NULL, NULL },
2146   { "/Copy/Description",                                                        NULL,           "Description",                                          NULL, NULL, G_CALLBACK(tree_view_menu_copy_desc) },
2147   { "/Copy/Fieldname",                                                          NULL,           "Fieldname",                                            NULL, NULL, G_CALLBACK(tree_view_menu_copy_field) },
2148   { "/Copy/Value",                                                                      NULL,           "Value",                                                        NULL, NULL, G_CALLBACK(tree_view_menu_copy_value) },
2149
2150   { "/Copy/AsFilter",                                                           NULL,           "As Filter",                                            NULL, NULL, G_CALLBACK(tree_view_menu_copy_as_flt) },
2151
2152   { "/Copy/Bytes",                                                                      NULL,           "Bytes",                                                                NULL, NULL, NULL },
2153   { "/Copy/Bytes/OffsetHexText",                                        NULL,           "Offset Hex Text",                                              NULL, NULL, G_CALLBACK(packet_list_menu_copy_bytes_oht_cb) },
2154   { "/Copy/Bytes/OffsetHex",                                            NULL,           "Offset Hex",                                                   NULL, NULL, G_CALLBACK(packet_list_menu_copy_bytes_oh_cb) },
2155   { "/Copy/Bytes/PrintableTextOnly",                            NULL,           "Printable Text Only",                                  NULL, NULL, G_CALLBACK(packet_list_menu_copy_bytes_text_cb) },
2156
2157   { "/Copy/Bytes/HexStream",                                            NULL,           "Hex Stream",                                                   NULL, NULL, G_CALLBACK(packet_list_menu_copy_bytes_hex_strm_cb) },
2158   { "/Copy/Bytes/BinaryStream",                                         NULL,           "Binary Stream",                                                NULL, NULL, G_CALLBACK(packet_list_menu_copy_bytes_bin_strm_cb) },
2159
2160   { "/ExportSelectedPacketBytes",                                       NULL,           "Export Selected Packet Bytes...",              NULL, NULL, G_CALLBACK(savehex_cb) },
2161
2162   { "/WikiProtocolPage",                        WIRESHARK_STOCK_WIKI,           "Wiki Protocol Page",                                   NULL, NULL, G_CALLBACK(selected_ptree_info_cb) },
2163   { "/FilterFieldReference",    WIRESHARK_STOCK_INTERNET,               "Filter Field Reference",                               NULL, NULL, G_CALLBACK(selected_ptree_ref_cb) },
2164   { "/ProtocolHelp",                                                            NULL,           "Protocol Help",                                                NULL, NULL, NULL },
2165   { "/ProtocolPreferences",                                                     NULL,           "Protocol Preferences",                                 NULL, NULL, NULL },
2166   { "/DecodeAs",                                WIRESHARK_STOCK_DECODE_AS,              "Decode As...",                                                 NULL, NULL, G_CALLBACK(decode_as_cb) },
2167   { "/DisableProtocol",                 WIRESHARK_STOCK_CHECKBOX,               "Disable Protocol...",                                  NULL, NULL, G_CALLBACK(proto_disable_cb) },
2168   { "/ResolveName",                                                                     NULL,           "_Resolve Name",                                                NULL, NULL, G_CALLBACK(resolve_name_cb) },
2169   { "/GotoCorrespondingPacket",                                         NULL,           "_Go to Corresponding Packet",                  NULL, NULL, G_CALLBACK(goto_framenum_cb) },
2170 };
2171
2172 static const char *ui_desc_bytes_menu_popup =
2173 "<ui>\n"
2174 "  <popup name='BytesMenuPopup' action='PopupAction'>\n"
2175 "     <menuitem name='HexView' action='/HexView'/>\n"
2176 "     <menuitem name='BitsView' action='/BitsView'/>\n"
2177 "  </popup>\n"
2178 "</ui>\n";
2179 static const GtkRadioActionEntry bytes_menu_radio_action_entries [] =
2180 {
2181         /* name,        stock id,       label,          accel,  tooltip,  value */
2182         { "/HexView",   NULL,           "Hex View",     NULL,   NULL,     BYTES_HEX },
2183         { "/BitsView",  NULL,           "Bits View",    NULL,   NULL,     BYTES_BITS },
2184 };
2185
2186 static const char *ui_statusbar_profiles_menu_popup =
2187 "<ui>\n"
2188 "  <popup name='ProfilesMenuPopup' action='PopupAction'>\n"
2189 "     <menuitem name='Profiles' action='/Profiles'/>\n"
2190 "     <separator/>\n"
2191 "     <menuitem name='New' action='/New'/>\n"
2192 "     <menuitem name='Edit' action='/Edit'/>\n"
2193 "     <menuitem name='Delete' action='/Delete'/>\n"
2194 "     <separator/>\n"
2195 "     <menu name='Change' action='/Change'>\n"
2196 "        <menuitem name='Default' action='/Change/Default'/>\n"
2197 "     </menu>\n"
2198 "  </popup>\n"
2199 "</ui>\n";
2200 static const GtkActionEntry statusbar_profiles_menu_action_entries [] =
2201 {
2202         { "/Profiles",  NULL,   "Configuration Profiles...",    NULL,   NULL,     G_CALLBACK(profile_dialog_cb) },
2203         { "/New",       GTK_STOCK_NEW,  "New...",       NULL,   NULL,     G_CALLBACK(profile_new_cb) },
2204         { "/Edit",      GTK_STOCK_EDIT, "Edit...",      NULL,   NULL,     G_CALLBACK(profile_edit_cb) },
2205         { "/Delete",    GTK_STOCK_DELETE,       "Delete",       NULL,   NULL,     G_CALLBACK(profile_delete_cb) },
2206         { "/Change",    NULL,           "Change",       NULL,   NULL,   NULL },
2207         { "/Change/Default",    NULL,   "Default",      NULL,   NULL,     NULL },
2208 };
2209
2210 GtkWidget *
2211 main_menu_new(GtkAccelGroup ** table) {
2212     GtkWidget *menubar;
2213 #ifdef HAVE_IGE_MAC_INTEGRATION
2214     GtkWidget *quit_item, *about_item, *preferences_item;
2215     IgeMacMenuGroup *group;
2216 #endif
2217 #ifdef HAVE_GTKOSXAPPLICATION
2218     GtkOSXApplication *theApp;
2219     GtkWidget * item;
2220     GtkOSXApplicationMenuGroup *group;
2221     GtkWidget * dock_menu;
2222 #endif
2223
2224     grp = gtk_accel_group_new();
2225
2226     if (initialize)
2227         menus_init();
2228
2229     menubar = main_menu_factory->widget;
2230 #ifdef HAVE_IGE_MAC_INTEGRATION
2231     if(prefs.gui_macosx_style) {
2232         ige_mac_menu_set_menu_bar(GTK_MENU_SHELL(menubar));
2233         ige_mac_menu_set_global_key_handler_enabled(TRUE);
2234
2235         /* Create menu items to populate the application menu with.  We have to
2236          * do this because we are still using the old GtkItemFactory API for
2237          * the main menu. */
2238         group = ige_mac_menu_add_app_menu_group();
2239         about_item = gtk_menu_item_new_with_label("About");
2240         g_signal_connect(about_item, "activate", G_CALLBACK(about_wireshark_cb),
2241                          NULL);
2242         ige_mac_menu_add_app_menu_item(group, GTK_MENU_ITEM(about_item), NULL);
2243
2244         group = ige_mac_menu_add_app_menu_group();
2245         preferences_item = gtk_menu_item_new_with_label("Preferences");
2246         g_signal_connect(preferences_item, "activate", G_CALLBACK(prefs_cb),
2247                          NULL);
2248         ige_mac_menu_add_app_menu_item(group, GTK_MENU_ITEM(preferences_item),
2249                                        NULL);
2250     }
2251
2252     /* The quit item in the application menu shows up whenever ige mac
2253      * integration is enabled, even if the OS X UI style in Wireshark isn't
2254      * turned on. */
2255     quit_item = gtk_menu_item_new_with_label("Quit");
2256     g_signal_connect(quit_item, "activate", G_CALLBACK(file_quit_cmd_cb), NULL);
2257     ige_mac_menu_set_quit_menu_item(GTK_MENU_ITEM(quit_item));
2258 #endif
2259
2260 #ifdef HAVE_GTKOSXAPPLICATION
2261     theApp = g_object_new(GTK_TYPE_OSX_APPLICATION, NULL);
2262
2263     if(prefs.gui_macosx_style) {
2264         gtk_osxapplication_set_menu_bar(theApp, GTK_MENU_SHELL(menubar));
2265         gtk_osxapplication_set_use_quartz_accelerators(theApp, TRUE);
2266
2267         group = gtk_osxapplication_add_app_menu_group (theApp);
2268         item = gtk_item_factory_get_item(main_menu_factory,"/Help/About Wireshark");
2269         gtk_osxapplication_add_app_menu_item(theApp, group,GTK_MENU_ITEM (item));
2270
2271         group = gtk_osxapplication_add_app_menu_group (theApp);
2272         item = gtk_item_factory_get_item(main_menu_factory,"/Edit/Preferences...");
2273         gtk_osxapplication_add_app_menu_item(theApp, group,GTK_MENU_ITEM (item));
2274
2275         group = gtk_osxapplication_add_app_menu_group (theApp);
2276         item = gtk_item_factory_get_item(main_menu_factory,"/Help");
2277         gtk_osxapplication_set_help_menu(theApp,GTK_MENU_ITEM(item));
2278
2279         /* Quit item is not needed */
2280         gtk_item_factory_delete_item(main_menu_factory,"/File/Quit");
2281     }
2282
2283     /* generate dock menu */
2284     dock_menu = gtk_menu_new();
2285
2286     item = gtk_menu_item_new_with_label("Start");
2287     g_signal_connect(item, "activate", G_CALLBACK (capture_start_cb), NULL);
2288     gtk_menu_shell_append(GTK_MENU_SHELL(dock_menu), item);
2289
2290     item = gtk_menu_item_new_with_label("Stop");
2291     g_signal_connect(item, "activate", G_CALLBACK (capture_stop_cb), NULL);
2292     gtk_menu_shell_append(GTK_MENU_SHELL(dock_menu), item);
2293
2294     item = gtk_menu_item_new_with_label("Restart");
2295     g_signal_connect(item, "activate", G_CALLBACK (capture_restart_cb), NULL);
2296     gtk_menu_shell_append(GTK_MENU_SHELL(dock_menu), item);
2297
2298     gtk_osxapplication_set_dock_menu(theApp, GTK_MENU_SHELL(dock_menu));
2299 #endif
2300
2301     if (table)
2302         *table = grp;
2303
2304     return menubar;
2305 }
2306
2307 static void
2308 menu_dissector_filter_cb(  GtkWidget *widget _U_,
2309                                 gpointer callback_data,
2310                                 guint callback_action _U_)
2311 {
2312     dissector_filter_t      *filter_entry = callback_data;
2313     GtkWidget               *filter_te;
2314     const char              *buf;
2315
2316     filter_te = gtk_bin_get_child(GTK_BIN(g_object_get_data(G_OBJECT(top_level), E_DFILTER_CM_KEY)));
2317
2318     /* XXX - this gets the packet_info of the last dissected packet, */
2319     /* which is not necessarily the last selected packet */
2320     /* e.g. "Update list of packets in real time" won't work correct */
2321     buf = filter_entry->build_filter_string(&cfile.edt->pi);
2322
2323     gtk_entry_set_text(GTK_ENTRY(filter_te), buf);
2324
2325     /* Run the display filter so it goes in effect - even if it's the
2326        same as the previous display filter. */
2327     main_filter_packets(&cfile, buf, TRUE);
2328
2329     g_free( (void *) buf);
2330 }
2331
2332 static gboolean menu_dissector_filter_spe_cb(frame_data *fd _U_, epan_dissect_t *edt, gpointer callback_data) {
2333     dissector_filter_t *filter_entry = callback_data;
2334
2335     /* XXX - this gets the packet_info of the last dissected packet, */
2336     /* which is not necessarily the last selected packet */
2337     /* e.g. "Update list of packets in real time" won't work correct */
2338     return (edt != NULL) ? filter_entry->is_filter_valid(&edt->pi) : FALSE;
2339 }
2340
2341 static void menu_dissector_filter(void) {
2342     GList *list_entry = dissector_filter_list;
2343     dissector_filter_t *filter_entry;
2344
2345     while(list_entry != NULL) {
2346         filter_entry = list_entry->data;
2347
2348         register_stat_menu_item(filter_entry->name, REGISTER_ANALYZE_GROUP_CONVERSATION_FILTER,
2349             menu_dissector_filter_cb,
2350             menu_dissector_filter_spe_cb,
2351             NULL /* selected_tree_row_enabled */,
2352             filter_entry);
2353
2354                 list_entry = g_list_next(list_entry);
2355     }
2356 }
2357
2358
2359 static void
2360 menus_init(void) {
2361     GtkActionGroup *packet_list_heading_action_group, *packet_list_action_group,
2362         *packet_list_details_action_group, *packet_list_byte_menu_action_group,
2363         *statusbar_profiles_action_group;
2364     GError *error = NULL;
2365
2366     if (initialize) {
2367         initialize = FALSE;
2368
2369         popup_menu_object = gtk_menu_new();
2370
2371         /* packet list heading pop-up menu */
2372         packet_list_heading_action_group = gtk_action_group_new ("PacketListHeadingPopUpMenuActionGroup");
2373
2374         gtk_action_group_add_actions (packet_list_heading_action_group,            /* the action group */
2375             (gpointer)packet_list_heading_menu_popup_action_entries,               /* an array of action descriptions */
2376             G_N_ELEMENTS(packet_list_heading_menu_popup_action_entries),           /* the number of entries */
2377             popup_menu_object);                                                    /* data to pass to the action callbacks */
2378
2379         gtk_action_group_add_toggle_actions(packet_list_heading_action_group,                     /* the action group */
2380                                     (gpointer)packet_list_heading_menu_toggle_action_entries,     /* an array of action descriptions */
2381                                     G_N_ELEMENTS(packet_list_heading_menu_toggle_action_entries), /* the number of entries */
2382                                     NULL);                                                        /* data to pass to the action callbacks */
2383
2384         ui_manager_packet_list_heading = gtk_ui_manager_new ();
2385         gtk_ui_manager_insert_action_group (ui_manager_packet_list_heading,
2386             packet_list_heading_action_group,
2387             0); /* the position at which the group will be inserted.  */
2388
2389         gtk_ui_manager_add_ui_from_string (ui_manager_packet_list_heading,ui_desc_packet_list_heading_menu_popup, -1, &error);
2390         if (error != NULL)
2391         {
2392             fprintf (stderr, "Warning: building Packet List Heading Pop-Up failed: %s\n",
2393                     error->message);
2394             g_error_free (error);
2395             error = NULL;
2396         }
2397
2398         g_object_set_data(G_OBJECT(popup_menu_object), PM_PACKET_LIST_COL_KEY,
2399                        gtk_ui_manager_get_widget(ui_manager_packet_list_heading, "/PacketListHeadingPopup"));
2400
2401         popup_menu_list = g_slist_append((GSList *)popup_menu_list, ui_manager_packet_list_heading);
2402
2403         /* packet list pop-up menu */
2404         packet_list_action_group = gtk_action_group_new ("PacketListPopUpMenuActionGroup");
2405
2406         gtk_action_group_add_actions (packet_list_action_group,                    /* the action group */
2407             (gpointer)packet_list_menu_popup_action_entries,                       /* an array of action descriptions */
2408             G_N_ELEMENTS(packet_list_menu_popup_action_entries),                   /* the number of entries */
2409             popup_menu_object);                                                    /* data to pass to the action callbacks */
2410
2411         ui_manager_packet_list_menu = gtk_ui_manager_new ();
2412
2413         gtk_ui_manager_insert_action_group (ui_manager_packet_list_menu,
2414             packet_list_action_group,
2415             0); /* the position at which the group will be inserted.  */
2416
2417         gtk_ui_manager_add_ui_from_string (ui_manager_packet_list_menu, ui_desc_packet_list_menu_popup, -1, &error);
2418         if (error != NULL)
2419         {
2420             fprintf (stderr, "Warning: building Packet List Pop-Up menu failed: %s\n",
2421                     error->message);
2422             g_error_free (error);
2423             error = NULL;
2424         }
2425
2426         g_object_set_data(G_OBJECT(popup_menu_object), PM_PACKET_LIST_KEY,
2427                         gtk_ui_manager_get_widget(ui_manager_packet_list_menu, "/PacketListMenuPopup"));
2428
2429         popup_menu_list = g_slist_append((GSList *)popup_menu_list, ui_manager_packet_list_menu);
2430
2431
2432         /* packet detail pop-up menu */
2433         packet_list_details_action_group = gtk_action_group_new ("PacketListDetailsMenuPopUpActionGroup");
2434
2435         gtk_action_group_add_actions (packet_list_details_action_group,            /* the action group */
2436             (gpointer)tree_view_menu_popup_action_entries,                         /* an array of action descriptions */
2437             G_N_ELEMENTS(tree_view_menu_popup_action_entries),                     /* the number of entries */
2438             popup_menu_object);                                                    /* data to pass to the action callbacks */
2439
2440         ui_manager_tree_view_menu = gtk_ui_manager_new ();
2441
2442         gtk_ui_manager_insert_action_group (ui_manager_tree_view_menu,
2443             packet_list_details_action_group,
2444             0); /* the position at which the group will be inserted.  */
2445
2446         gtk_ui_manager_add_ui_from_string (ui_manager_tree_view_menu, ui_desc_tree_view_menu_popup, -1, &error);
2447         if (error != NULL)
2448         {
2449             fprintf (stderr, "Warning: building TreeWiew Pop-Up menu failed: %s\n",
2450                     error->message);
2451             g_error_free (error);
2452             error = NULL;
2453         }
2454
2455         g_object_set_data(G_OBJECT(popup_menu_object), PM_TREE_VIEW_KEY,
2456                          gtk_ui_manager_get_widget(ui_manager_tree_view_menu, "/TreeViewPopup"));
2457
2458         popup_menu_list = g_slist_append((GSList *)popup_menu_list, ui_manager_tree_view_menu);
2459
2460         /*
2461          * Hex dump pop-up menu.
2462          * We provide our own empty menu to suppress the default pop-up menu
2463          * for text widgets.
2464          */
2465         packet_list_byte_menu_action_group = gtk_action_group_new ("PacketListByteMenuPopUpActionGroup");
2466
2467
2468         gtk_action_group_add_radio_actions  (packet_list_byte_menu_action_group,            /* the action group */
2469                                     (gpointer)bytes_menu_radio_action_entries,              /* an array of radio action descriptions  */
2470                                     G_N_ELEMENTS(bytes_menu_radio_action_entries),          /* the number of entries */
2471                                     recent.gui_bytes_view,                                  /* the value of the action to activate initially, or -1 if no action should be activated  */
2472                                     G_CALLBACK(select_bytes_view_cb),                       /* the callback to connect to the changed signal  */
2473                                     popup_menu_object);                                     /* data to pass to the action callbacks  */
2474
2475         ui_manager_bytes_menu = gtk_ui_manager_new ();
2476
2477         gtk_ui_manager_insert_action_group (ui_manager_bytes_menu,
2478             packet_list_byte_menu_action_group,
2479             0); /* the position at which the group will be inserted.  */
2480
2481         gtk_ui_manager_add_ui_from_string (ui_manager_bytes_menu, ui_desc_bytes_menu_popup, -1, &error);
2482         if (error != NULL)
2483         {
2484             fprintf (stderr, "Warning: building Bytes Pop-Up menu failed: %s\n",
2485                     error->message);
2486             g_error_free (error);
2487             error = NULL;
2488         }
2489
2490         g_object_unref(packet_list_byte_menu_action_group);
2491
2492         g_object_set_data(G_OBJECT(popup_menu_object), PM_BYTES_VIEW_KEY,
2493                         gtk_ui_manager_get_widget(ui_manager_bytes_menu, "/BytesMenuPopup"));
2494
2495         popup_menu_list = g_slist_append((GSList *)popup_menu_list, ui_manager_bytes_menu);
2496
2497         /* main */
2498         main_menu_factory = gtk_item_factory_new(GTK_TYPE_MENU_BAR, "<main>", grp);
2499         gtk_item_factory_create_items_ac(main_menu_factory, nmenu_items, menu_items, NULL, 2);
2500
2501         statusbar_profiles_action_group = gtk_action_group_new ("StatusBarProfilesPopUpMenuActionGroup");
2502
2503         gtk_action_group_add_actions (statusbar_profiles_action_group,   /* the action group */
2504             (gpointer)statusbar_profiles_menu_action_entries,            /* an array of action descriptions */
2505             G_N_ELEMENTS(statusbar_profiles_menu_action_entries),        /* the number of entries */
2506             popup_menu_object);                                          /* data to pass to the action callbacks */
2507
2508         ui_manager_statusbar_profiles_menu = gtk_ui_manager_new ();
2509         gtk_ui_manager_insert_action_group (ui_manager_statusbar_profiles_menu,
2510             statusbar_profiles_action_group,
2511             0); /* the position at which the group will be inserted.  */
2512
2513         gtk_ui_manager_add_ui_from_string (ui_manager_statusbar_profiles_menu,ui_statusbar_profiles_menu_popup, -1, &error);
2514         if (error != NULL)
2515         {
2516             fprintf (stderr, "Warning: building Statusbar Profiles Pop-Up failed: %s\n",
2517                     error->message);
2518             g_error_free (error);
2519             error = NULL;
2520         }
2521
2522         g_object_unref(statusbar_profiles_action_group);
2523
2524         g_object_set_data(G_OBJECT(popup_menu_object), PM_STATUSBAR_PROFILES_KEY,
2525                        gtk_ui_manager_get_widget(ui_manager_statusbar_profiles_menu, "/ProfilesMenuPopup"));
2526
2527         popup_menu_list = g_slist_append((GSList *)popup_menu_list, ui_manager_statusbar_profiles_menu);
2528
2529         menu_dissector_filter();
2530         merge_all_tap_menus(tap_menu_tree_root);
2531
2532         /* Initialize enabled/disabled state of menu items */
2533         set_menus_for_capture_file(NULL);
2534 #if 0
2535         /* Un-#if this when we actually implement Cut/Copy/Paste.
2536            Then make sure you enable them when they can be done. */
2537         set_menu_sensitivity_old("/Edit/Cut", FALSE);
2538         set_menu_sensitivity_old("/Edit/Copy", FALSE);
2539         set_menu_sensitivity_old("/Edit/Paste", FALSE);
2540 #endif
2541
2542         set_menus_for_captured_packets(FALSE);
2543         set_menus_for_selected_packet(&cfile);
2544         set_menus_for_selected_tree_row(&cfile);
2545         set_menus_for_capture_in_progress(FALSE);
2546         set_menus_for_file_set(/* dialog */TRUE, /* previous file */ FALSE, /* next_file */ FALSE);
2547
2548         /* Init with an empty recent files list */
2549         clear_menu_recent_capture_file_cmd_cb(NULL, NULL);
2550         /* Protocol help links */
2551         proto_help_menu_init(gtk_ui_manager_get_widget(ui_manager_tree_view_menu, "/TreeViewPopup"));
2552     }
2553 }
2554
2555
2556 static gint tap_menu_item_add_compare(gconstpointer a, gconstpointer b)
2557 {
2558     return strcmp(
2559         ((const menu_item_t *) a)->name,
2560         ((const menu_item_t *) b)->name);
2561 }
2562
2563
2564 /* add a menuitem below the current node */
2565 static GList * tap_menu_item_add(
2566     gint        group,
2567     const char *gui_path,
2568     const char *name,
2569     const char *label,
2570     const char *stock_id,
2571     const char *accelerator,
2572     const char *tooltip,
2573     GtkItemFactoryCallback callback,
2574     gboolean    enabled,
2575     gboolean (*selected_packet_enabled)(frame_data *, epan_dissect_t *, gpointer callback_data),
2576     gboolean (*selected_tree_row_enabled)(field_info *, gpointer callback_data),
2577     gpointer callback_data,
2578     GList *curnode)
2579 {
2580     menu_item_t *curr;
2581     menu_item_t *child;
2582
2583     child = g_malloc(sizeof (menu_item_t));
2584     child->group            = group;
2585     child->gui_path         = gui_path;
2586     child->name             = name;
2587     child->label            = label;
2588     child->stock_id         = stock_id;
2589     child->accelerator      = accelerator;
2590     child->stock_id         = stock_id;
2591     child->tooltip          = tooltip;
2592     child->callback         = callback;
2593         child->enabled          = enabled;
2594     child->selected_packet_enabled = selected_packet_enabled;
2595     child->selected_tree_row_enabled = selected_tree_row_enabled;
2596     child->callback_data    = callback_data;
2597     child->children         = NULL;
2598
2599     /* insert the new child node into the parent */
2600     curr = curnode->data;
2601     curr->children = g_list_insert_sorted(curr->children, child, tap_menu_item_add_compare);
2602
2603     /* return the new node */
2604     /* XXX: improve this */
2605     return g_list_find(curr->children, child);
2606 }
2607
2608 /*
2609  * Add a new menu item for a tap.
2610  * This must be called after we've created the main menu, so it can't
2611  * be called from the routine that registers taps - we have to introduce
2612  * another per-tap registration routine.
2613  *
2614  * "callback" gets called when the menu item is selected; it should do
2615  * the work of creating the tap window.
2616  *
2617  * "selected_packet_enabled" gets called by "set_menus_for_selected_packet()";
2618  * it's passed a Boolean that's TRUE if a packet is selected and FALSE
2619  * otherwise, and should return TRUE if the tap will work now (which
2620  * might depend on whether a packet is selected and, if one is, on the
2621  * packet) and FALSE if not.
2622  *
2623  * "selected_tree_row_enabled" gets called by
2624  * "set_menus_for_selected_tree_row()"; it's passed a Boolean that's TRUE if
2625  * a protocol tree row is selected and FALSE otherwise, and should return
2626  * TRUE if the tap will work now (which might depend on whether a tree row
2627  * is selected and, if one is, on the tree row) and FALSE if not.
2628  */
2629
2630 void
2631 register_stat_menu_item_stock(
2632     const char *name,
2633     register_stat_group_t group,
2634     const char *stock_id,
2635     gpointer callback,
2636     gboolean (*selected_packet_enabled)(frame_data *, epan_dissect_t *, gpointer callback_data),
2637     gboolean (*selected_tree_row_enabled)(field_info *, gpointer callback_data),
2638     gpointer callback_data
2639 )
2640 {
2641 const char *gui_path = NULL;
2642 const char *label = name;
2643 const char *accelerator = NULL;
2644 const char *tooltip = NULL;
2645 gboolean    enabled = FALSE;
2646     /*static const char toolspath[] = "/Statistics/";*/
2647     const char *toolspath;
2648     const char *p;
2649     char *menupath;
2650     size_t menupathlen;
2651     menu_item_t *child;
2652     GList *curnode;
2653     GList *childnode;
2654
2655     /*
2656      * The menu path must be relative.
2657      */
2658     g_assert(*name != '/');
2659     switch(group) {
2660     case(REGISTER_STAT_GROUP_GENERIC): toolspath = "/Statistics/"; break;
2661     case(REGISTER_STAT_GROUP_CONVERSATION_LIST): toolspath = "/Statistics/_Conversation List/"; break;
2662     case(REGISTER_STAT_GROUP_ENDPOINT_LIST): toolspath = "/Statistics/_Endpoint List/"; break;
2663     case(REGISTER_STAT_GROUP_RESPONSE_TIME): toolspath = "/Statistics/Service _Response Time/"; break;
2664     case(REGISTER_STAT_GROUP_UNSORTED): toolspath = "/Statistics/"; break;
2665     case(REGISTER_ANALYZE_GROUP_UNSORTED): toolspath = "/Analyze/"; break;
2666     case(REGISTER_ANALYZE_GROUP_CONVERSATION_FILTER): toolspath = "/Analyze/Conversation Filter/"; break;
2667     case(REGISTER_STAT_GROUP_TELEPHONY): toolspath = "/Telephony/"; break;
2668     case(REGISTER_TOOLS_GROUP_UNSORTED): toolspath = "/Tools/"; break;
2669     default:
2670         g_assert(!"no such menu group");
2671         toolspath = NULL;
2672     }
2673     /* add the (empty) root node, if not already done */
2674     if(tap_menu_tree_root == NULL) {
2675         child = g_malloc0(sizeof (menu_item_t));
2676         tap_menu_tree_root = g_list_append(NULL, child);
2677     }
2678
2679     /*
2680      * Create any submenus required.
2681      */
2682     curnode = tap_menu_tree_root;
2683     p = name;
2684     while ((p = strchr(p, '/')) != NULL) {
2685         /*
2686          * OK, everything between "name" and "p" is
2687          * a menu relative subtree into which the menu item
2688          * will be placed.
2689          *
2690          * Construct the absolute path name of that subtree.
2691          */
2692         menupathlen = strlen(toolspath) + 1 + (p - name);
2693         menupath = g_malloc(menupathlen);
2694         g_strlcpy(menupath, toolspath, menupathlen);
2695         g_strlcat(menupath, name, menupathlen);
2696
2697         /*
2698          * Does there exist an entry with that path at this
2699          * level of the Analyze menu tree?
2700          */
2701         child = curnode->data;
2702         for (childnode = child->children; childnode != NULL; childnode = childnode->next) {
2703             child = childnode->data;
2704             if (strcmp(child->gui_path, menupath) == 0)
2705                 break;
2706         }
2707         if (childnode == NULL) {
2708             /*
2709              * No.  Create such an item as a subtree, and
2710              * add it to the Tools menu tree.
2711              */
2712             childnode = tap_menu_item_add(
2713                 group, (const char*)menupath, name, name, NULL, NULL, NULL, NULL ,FALSE, NULL, NULL, NULL, curnode);
2714         } else {
2715             /*
2716              * Yes.  We don't need this "menupath" any longer.
2717              */
2718             g_free(menupath);
2719         }
2720         curnode = childnode;
2721
2722         /*
2723          * Skip over the '/' we found.
2724          */
2725         p++;
2726     }
2727
2728     /*
2729      * Construct the main menu path for the menu item.
2730      */
2731     menupathlen = strlen(toolspath) + 1 + strlen(name);
2732     menupath = g_malloc(menupathlen);
2733     g_strlcpy(menupath, toolspath, menupathlen);
2734     g_strlcat(menupath, name, menupathlen);
2735
2736         gui_path = menupath;
2737     /*
2738      * Construct an item factory entry for the item, and add it to
2739      * the main menu.
2740      */
2741     tap_menu_item_add(
2742         group, gui_path, name, label, stock_id,
2743         accelerator, tooltip, callback, enabled,
2744         selected_packet_enabled, selected_tree_row_enabled,
2745         callback_data, curnode);
2746 }
2747
2748 /*
2749  * Add a new menu item for a stat.
2750  * This must be called after we've created the main menu, so it can't
2751  * be called from the routine that registers stats - we have to introduce
2752  * another per-stat registration routine.
2753  *
2754  * @param name the menu label
2755  *
2756  * @param group the menu group this stat should be registered to
2757  *
2758  * @param callback gets called when the menu item is selected; it should do
2759  * the work of creating the stat window.
2760  *
2761  * @param selected_packet_enabled gets called by set_menus_for_selected_packet();
2762  * it's passed a pointer to the "frame_data" structure for the current frame,
2763  * if any, and to the "epan_dissect_t" structure for that frame, if any, and
2764  * should return TRUE if the stat will work now (which might depend on whether
2765  * a frame is selected and, if one is, on the frame) and FALSE if not.
2766  *
2767  * @param selected_tree_row_enabled gets called by
2768  * set_menus_for_selected_tree_row(); it's passed a pointer to the
2769  * "field_info" structure for the currently selected field, if any,
2770  * and should return TRUE if the stat will work now (which might depend on
2771  * whether a tree row is selected and, if one is, on the tree row) and
2772  * FALSE if not.
2773  *
2774  * @param callback_data data for callback function
2775  */
2776 void
2777 register_stat_menu_item(
2778     const char *name,
2779     register_stat_group_t group,
2780     gpointer callback,
2781     gboolean (*selected_packet_enabled)(frame_data *, epan_dissect_t *, gpointer callback_data),
2782     gboolean (*selected_tree_row_enabled)(field_info *, gpointer callback_data),
2783     gpointer callback_data)
2784 {
2785     register_stat_menu_item_stock(
2786         name,
2787         group,
2788                 NULL,         /* stock_id */
2789         callback,
2790         selected_packet_enabled,
2791         selected_tree_row_enabled,
2792         callback_data);
2793 }
2794
2795 static guint merge_tap_menus_layered(GList *node, gint group) {
2796     GtkItemFactoryEntry *entry;
2797
2798     GList       *child;
2799     guint       added = 0;
2800     menu_item_t *node_data = node->data;
2801         size_t          namelen;
2802
2803     /*
2804      * Is this a leaf node or an interior node?
2805      */
2806     if (node_data->children == NULL) {
2807         /*
2808          * It's a leaf node.
2809          */
2810
2811         /*
2812          * The root node doesn't correspond to a menu tree item; it
2813          * has a null name pointer.
2814          */
2815         if (node_data->gui_path != NULL && group == node_data->group) {
2816             entry = g_malloc0(sizeof (GtkItemFactoryEntry));
2817                         namelen = strlen(node_data->gui_path) + 1;
2818                         entry->path = g_malloc(namelen);
2819                         g_strlcpy(entry->path, node_data->gui_path, namelen);
2820             entry->callback = node_data->callback;
2821             switch(group) {
2822             case(REGISTER_STAT_GROUP_UNSORTED):
2823                 break;
2824             case(REGISTER_STAT_GROUP_GENERIC):
2825                 break;
2826             case(REGISTER_STAT_GROUP_CONVERSATION_LIST):
2827                 entry->item_type = "<StockItem>";
2828                 entry->extra_data = WIRESHARK_STOCK_CONVERSATIONS;
2829                 break;
2830             case(REGISTER_STAT_GROUP_ENDPOINT_LIST):
2831                 entry->item_type = "<StockItem>";
2832                 entry->extra_data = WIRESHARK_STOCK_ENDPOINTS;
2833                 break;
2834             case(REGISTER_STAT_GROUP_RESPONSE_TIME):
2835                 entry->item_type = "<StockItem>";
2836                 entry->extra_data = WIRESHARK_STOCK_TIME;
2837                 break;
2838             case(REGISTER_STAT_GROUP_TELEPHONY):
2839                 break;
2840             case(REGISTER_ANALYZE_GROUP_UNSORTED):
2841                 break;
2842             case(REGISTER_ANALYZE_GROUP_CONVERSATION_FILTER):
2843                 break;
2844             case(REGISTER_TOOLS_GROUP_UNSORTED):
2845                 break;
2846             default:
2847                 g_assert_not_reached();
2848             }
2849             if(node_data->stock_id!= NULL) {
2850                 entry->item_type = "<StockItem>";
2851                 entry->extra_data = node_data->stock_id;
2852             }
2853             gtk_item_factory_create_item(main_menu_factory, entry, node_data->callback_data, /* callback_type */ 2);
2854             set_menu_sensitivity_old(node_data->gui_path, FALSE); /* no capture file yet */
2855             added++;
2856             g_free(entry);
2857         }
2858     } else {
2859         /*
2860          * It's an interior node; call
2861          * "merge_tap_menus_layered()" on all its children
2862          */
2863
2864         /*
2865          * The root node doesn't correspond to a menu tree item; it
2866          * has a null name pointer.
2867          */
2868         if (node_data->gui_path != NULL && group == node_data->group) {
2869             entry = g_malloc0(sizeof (GtkItemFactoryEntry));
2870                         namelen = strlen(node_data->gui_path) + 1;
2871                         entry->path = g_malloc(namelen);
2872                         g_strlcpy(entry->path, node_data->gui_path, namelen);
2873             entry->item_type = "<Branch>";
2874
2875             gtk_item_factory_create_item(main_menu_factory, entry,
2876                 NULL, 2);
2877             set_menu_sensitivity_old(node_data->gui_path, FALSE);    /* no children yet */
2878             added++;
2879             g_free(entry);
2880         }
2881
2882         for (child = node_data->children; child != NULL; child =
2883             child->next) {
2884             added += merge_tap_menus_layered(child, group);
2885         }
2886     }
2887
2888     return added;
2889 }
2890
2891
2892
2893 static void merge_all_tap_menus(GList *node) {
2894     GtkItemFactoryEntry *sep_entry;
2895
2896     sep_entry = g_malloc0(sizeof (GtkItemFactoryEntry));
2897     sep_entry->item_type = "<Separator>";
2898     sep_entry->path = "/Statistics/";
2899     /*
2900      * merge only the menu items of the specific group,
2901      * and then append a seperator
2902      */
2903     if (merge_tap_menus_layered(node, REGISTER_STAT_GROUP_GENERIC)) {
2904         gtk_item_factory_create_item(main_menu_factory, sep_entry, NULL, 2);
2905     }
2906     if (merge_tap_menus_layered(node, REGISTER_STAT_GROUP_CONVERSATION_LIST)) {
2907         /*gtk_item_factory_create_item(main_menu_factory, sep_entry, NULL, 2);*/
2908     }
2909     if (merge_tap_menus_layered(node, REGISTER_STAT_GROUP_ENDPOINT_LIST)) {
2910         /*gtk_item_factory_create_item(main_menu_factory, sep_entry, NULL, 2);*/
2911     }
2912     if (merge_tap_menus_layered(node, REGISTER_STAT_GROUP_RESPONSE_TIME)) {
2913         gtk_item_factory_create_item(main_menu_factory, sep_entry, NULL, 2);
2914     }
2915     if (merge_tap_menus_layered(node, REGISTER_STAT_GROUP_TELEPHONY)) {
2916         /*gtk_item_factory_create_item(main_menu_factory, sep_entry, NULL, 2);*/
2917     }
2918     if (merge_tap_menus_layered(node, REGISTER_STAT_GROUP_UNSORTED)) {
2919         /*gtk_item_factory_create_item(main_menu_factory, sep_entry, NULL, 2);*/
2920     }
2921     if (merge_tap_menus_layered(node, REGISTER_ANALYZE_GROUP_UNSORTED)) {
2922        /* sep_entry->path = "/Analyze/";*/
2923         /*gtk_item_factory_create_item(main_menu_factory, sep_entry, NULL, 2);*/
2924     }
2925     if (merge_tap_menus_layered(node, REGISTER_ANALYZE_GROUP_CONVERSATION_FILTER)) {
2926         /*sep_entry->path = "/Analyze/Conversation Filter/";*/
2927         /*gtk_item_factory_create_item(main_menu_factory, sep_entry, NULL, 2);*/
2928     }
2929     if (merge_tap_menus_layered(node, REGISTER_TOOLS_GROUP_UNSORTED)) {
2930         /*gtk_item_factory_create_item(main_menu_factory, sep_entry, NULL, 2);*/
2931     }
2932     g_free (sep_entry);
2933 }
2934
2935 /*
2936  * Enable/disable menu sensitivity.
2937  */
2938 static void
2939 set_menu_sensitivity(GtkUIManager *ui_manager, const gchar *path, gint val)
2940 {
2941     GtkAction *action;
2942
2943     action = gtk_ui_manager_get_action(ui_manager, path);
2944     if(!action){
2945 #if 0
2946         fprintf (stderr, "Warning: couldn't find action path= %s\n",
2947                 path);
2948 #endif
2949         return;
2950     }
2951     gtk_action_set_sensitive (action,
2952         val); /* TRUE to make the action sensitive */
2953 }
2954
2955 /*
2956  * Enable/disable menu sensitivity for the old menubar code.
2957  */
2958 static void
2959 set_menu_sensitivity_old(const gchar *path, gint val)
2960 {
2961     GtkWidget *menu_item;
2962     gchar *dup;
2963     gchar *dest;
2964     /* the underscore character regularly confuses things, as it will prevent finding
2965      * the menu_item, so it has to be removed first */
2966     dup = g_strdup(path);
2967     dest = dup;
2968     while(*path) {
2969         if (*path != '_') {
2970             *dest = *path;
2971             dest++;
2972         }
2973         path++;
2974     }
2975     *dest = '\0';
2976
2977     if ((menu_item = gtk_item_factory_get_widget(main_menu_factory, dup)) != NULL) {
2978         if (GTK_IS_MENU(menu_item)) {
2979             /*
2980              * "dup" refers to a submenu; "gtk_item_factory_get_widget()"
2981              * gets the menu, not the item that, when selected, pops up
2982              * the submenu.
2983              *
2984              * We have to change the latter item's sensitivity, so that
2985              * it shows up normally if sensitive and grayed-out if
2986              * insensitive.
2987              */
2988             menu_item = gtk_menu_get_attach_widget(GTK_MENU(menu_item));
2989         }
2990         gtk_widget_set_sensitive(menu_item, val);
2991     }
2992
2993     g_free(dup);
2994 }
2995
2996
2997 static void
2998 set_menu_object_data_meat_old(const gchar *path, const gchar *key, gpointer data)
2999 {
3000     GtkWidget *menu = NULL;
3001
3002     if ((menu = gtk_item_factory_get_widget(main_menu_factory, path)) != NULL){
3003         g_object_set_data(G_OBJECT(menu), key, data);
3004     }
3005 }
3006
3007 void
3008 set_menu_object_data (const gchar *path, const gchar *key, gpointer data) {
3009     set_menu_object_data_meat_old(path, key, data);
3010 }
3011
3012
3013 /* Recently used capture files submenu:
3014  * Submenu containing the recently used capture files.
3015  * The capture filenames are always kept with the absolute path, to be independant
3016  * of the current path.
3017  * They are only stored inside the labels of the submenu (no separate list). */
3018
3019 #define MENU_RECENT_FILES_PATH_OLD "/File/Open Recent"
3020 #define MENU_RECENT_FILES_PATH "/Menubar/FileMenu/OpenRecent"
3021 #define MENU_RECENT_FILES_KEY "Recent File Name"
3022
3023
3024 static void
3025 update_menu_recent_capture_file1(GtkWidget *widget, gpointer cnt) {
3026     gchar *widget_cf_name;
3027
3028     widget_cf_name = g_object_get_data(G_OBJECT(widget), MENU_RECENT_FILES_KEY);
3029
3030     /* if this menu item is a file, count it */
3031     if (widget_cf_name) {
3032         (*(guint *)cnt)++;
3033         gtk_widget_set_sensitive(widget, FALSE);
3034         main_welcome_add_recent_capture_file(widget_cf_name, G_OBJECT(widget));
3035     }
3036 }
3037
3038 /* update the menu */
3039 static void
3040 update_menu_recent_capture_file(GtkWidget *submenu_recent_files) {
3041     guint cnt = 0;
3042     GtkWidget    *menu_item;
3043
3044
3045     main_welcome_reset_recent_capture_files();
3046
3047     gtk_container_foreach(GTK_CONTAINER(submenu_recent_files),
3048                           update_menu_recent_capture_file1, &cnt);
3049
3050     if (cnt == 0) {
3051         /* Empty list */
3052         menu_item = gtk_menu_item_new_with_label("No recently used files");
3053         gtk_menu_shell_append (GTK_MENU_SHELL(submenu_recent_files), menu_item);
3054         gtk_widget_set_sensitive(menu_item, FALSE);
3055         gtk_widget_show (menu_item);
3056     }
3057 }
3058
3059
3060 /* remove the capture filename from the "Recent Files" menu */
3061 static void
3062 remove_menu_recent_capture_filename(gchar *cf_name) {
3063     GtkWidget *submenu_recent_files;
3064     GList* child_list;
3065     GList* child_list_item;
3066     GtkWidget    *menu_item_child;
3067     const gchar *menu_item_cf_name;
3068
3069     /* get the submenu container item */
3070     submenu_recent_files = gtk_item_factory_get_widget(main_menu_factory, MENU_RECENT_FILES_PATH_OLD);
3071     /* find the corresponding menu item to be removed */
3072     child_list = gtk_container_get_children(GTK_CONTAINER(submenu_recent_files));
3073     child_list_item = child_list;
3074     while(child_list_item) {
3075         menu_item_child = gtk_bin_get_child(GTK_BIN(child_list_item->data));
3076         if (menu_item_child != NULL) { /* Note: there are two "extra" items on the end of the child_list: */
3077                                        /*  - a separator (with no menu_item_child and thus no text label) */
3078                                        /*  - a 2nd item with a menu_child with text label "Clear"         */
3079                                        /*       [See add_menu_recent_capture_file_absolute() ]            */
3080                                        /* 'if (menu_item_child != NULL)' skips the separator item;        */
3081                                        /* An absolute filename in cf_name will never match  "Clear".      */
3082             menu_item_cf_name = gtk_label_get_text(GTK_LABEL(menu_item_child));
3083             if(strcmp(menu_item_cf_name, cf_name) == 0) {
3084                 /* XXX: is this all we need to do, to free the menu item and its label?
3085                    The reference count of widget will go to 0, so it'll be freed;
3086                    will that free the label? */
3087                 gtk_container_remove(GTK_CONTAINER(submenu_recent_files), child_list_item->data);
3088             }
3089         }
3090         child_list_item = g_list_next(child_list_item);
3091     }
3092     g_list_free(child_list);
3093
3094     update_menu_recent_capture_file(submenu_recent_files);
3095 }
3096
3097 /* remove the capture filename from the "Recent Files" menu */
3098 static void
3099 remove_menu_recent_capture_file(GtkWidget *widget, gpointer unused _U_) {
3100     GtkWidget *submenu_recent_files;
3101     gchar *widget_cf_name;
3102
3103
3104     widget_cf_name = g_object_get_data(G_OBJECT(widget), MENU_RECENT_FILES_KEY);
3105     g_free(widget_cf_name);
3106
3107     /* get the submenu container item */
3108     submenu_recent_files = gtk_item_factory_get_widget(main_menu_factory, MENU_RECENT_FILES_PATH_OLD);
3109     /* XXX: is this all we need to do, to free the menu item and its label?
3110        The reference count of widget will go to 0, so it'll be freed;
3111        will that free the label? */
3112     gtk_container_remove(GTK_CONTAINER(submenu_recent_files), widget);
3113 }
3114
3115
3116 /* callback, if the user pushed the <Clear> menu item */
3117 static void
3118 clear_menu_recent_capture_file_cmd_cb(GtkWidget *w _U_, gpointer unused _U_) {
3119     GtkWidget *submenu_recent_files;
3120
3121     submenu_recent_files = gtk_item_factory_get_widget(main_menu_factory, MENU_RECENT_FILES_PATH_OLD);
3122
3123     gtk_container_foreach(GTK_CONTAINER(submenu_recent_files),
3124                           remove_menu_recent_capture_file, NULL);
3125
3126     update_menu_recent_capture_file(submenu_recent_files);
3127 }
3128
3129 /* Open a file by it's name
3130    (Beware: will not ask to close existing capture file!) */
3131 void
3132 menu_open_filename(gchar *cf_name)
3133 {
3134     GtkWidget *submenu_recent_files;
3135     int       err;
3136     submenu_recent_files = gtk_item_factory_get_widget(main_menu_factory, MENU_RECENT_FILES_PATH_OLD);
3137     /* open and read the capture file (this will close an existing file) */
3138     if (cf_open(&cfile, cf_name, FALSE, &err) == CF_OK) {
3139         cf_read(&cfile, FALSE);
3140     } else {
3141         /* the capture file apparently no longer exists; remove menu item    */
3142         /* XXX: ask user to remove item, it's maybe only a temporary problem */
3143         remove_menu_recent_capture_filename(cf_name);
3144     }
3145
3146     update_menu_recent_capture_file(submenu_recent_files);
3147 }
3148
3149 /* callback, if the user pushed a recent file submenu item */
3150 void
3151 menu_open_recent_file_cmd(gpointer action)
3152 {
3153     GtkWidget   *submenu_recent_files;
3154     GtkWidget   *menu_item_child;
3155     const gchar *cf_name;
3156     int         err;
3157
3158
3159     submenu_recent_files = gtk_item_factory_get_widget(main_menu_factory, MENU_RECENT_FILES_PATH_OLD);
3160
3161     /* get capture filename from the menu item label */
3162     menu_item_child = gtk_bin_get_child(GTK_BIN(action));
3163     cf_name = gtk_label_get_text(GTK_LABEL(menu_item_child));
3164
3165     /* open and read the capture file (this will close an existing file) */
3166     if (cf_open(&cfile, cf_name, FALSE, &err) == CF_OK) {
3167         cf_read(&cfile, FALSE);
3168     } else {
3169         /* the capture file apparently no longer exists; remove menu item    */
3170         /* XXX: ask user to remove item, it's maybe only a temporary problem */
3171         remove_menu_recent_capture_file(action, NULL);
3172     }
3173
3174     update_menu_recent_capture_file(submenu_recent_files);
3175 }
3176
3177 static void menu_open_recent_file_answered_cb(gpointer dialog _U_, gint btn, gpointer data)
3178 {
3179     switch(btn) {
3180     case(ESD_BTN_YES):
3181         /* save file first */
3182         file_save_as_cmd(after_save_open_recent_file, data);
3183         break;
3184     case(ESD_BTN_NO):
3185         cf_close(&cfile);
3186         menu_open_recent_file_cmd(data);
3187         break;
3188     case(ESD_BTN_CANCEL):
3189         break;
3190     default:
3191         g_assert_not_reached();
3192     }
3193 }
3194 static void
3195 menu_open_recent_file_cmd_cb(GtkWidget *widget, gpointer data _U_) {
3196     gpointer  dialog;
3197
3198
3199     if((cfile.state != FILE_CLOSED) && !cfile.user_saved && prefs.gui_ask_unsaved) {
3200         /* user didn't saved his current file, ask him */
3201         dialog = simple_dialog(ESD_TYPE_CONFIRMATION, ESD_BTNS_YES_NO_CANCEL,
3202                                "%sSave capture file before opening a new one?%s\n\n"
3203                                "If you open a new capture file without saving, your current capture data will be discarded.",
3204                                simple_dialog_primary_start(), simple_dialog_primary_end());
3205         simple_dialog_set_cb(dialog, menu_open_recent_file_answered_cb, widget);
3206     } else {
3207         /* unchanged file */
3208         menu_open_recent_file_cmd(widget);
3209     }
3210 }
3211
3212
3213 /* add the capture filename (with an absolute path) to the "Recent Files" menu */
3214 static void
3215 add_menu_recent_capture_file_absolute(gchar *cf_name) {
3216     GtkWidget *submenu_recent_files;
3217     GList *menu_item_list_old;
3218     GList *li;
3219     gchar *widget_cf_name;
3220     gchar *normalized_cf_name;
3221     GtkWidget *menu_item;
3222     guint cnt;
3223
3224     normalized_cf_name = g_strdup(cf_name);
3225 #ifdef _WIN32
3226     /* replace all slashes by backslashes */
3227     g_strdelimit(normalized_cf_name, "/", '\\');
3228 #endif
3229     submenu_recent_files = gtk_item_factory_get_widget(main_menu_factory, MENU_RECENT_FILES_PATH_OLD);
3230     /* convert container to a GList */
3231     menu_item_list_old = gtk_container_get_children(GTK_CONTAINER(submenu_recent_files));
3232
3233     /* iterate through list items of menu_item_list,
3234      * removing special items, a maybe duplicate entry and every item above count_max */
3235     cnt = 1;
3236     for (li = g_list_first(menu_item_list_old); li; li = li->next, cnt++) {
3237         /* get capture filename */
3238         menu_item = GTK_WIDGET(li->data);
3239         widget_cf_name = g_object_get_data(G_OBJECT(menu_item), MENU_RECENT_FILES_KEY);
3240
3241         /* if this element string is one of our special items (seperator, ...) or
3242          * already in the list or
3243          * this element is above maximum count (too old), remove it
3244          */
3245         if (!widget_cf_name ||
3246 #ifdef _WIN32
3247             /* do a case insensitive compare on win32 */
3248             g_ascii_strncasecmp(widget_cf_name, normalized_cf_name, 1000) == 0 ||
3249 #else   /* _WIN32 */
3250             /* do a case sensitive compare on unix */
3251             strncmp(widget_cf_name, normalized_cf_name, 1000) == 0 ||
3252 #endif
3253             cnt >= prefs.gui_recent_files_count_max) {
3254             remove_menu_recent_capture_file(li->data, NULL);
3255             cnt--;
3256         }
3257     }
3258
3259     g_list_free(menu_item_list_old);
3260
3261     /* add new item at latest position */
3262     menu_item = gtk_menu_item_new_with_label(normalized_cf_name);
3263     g_object_set_data(G_OBJECT(menu_item), MENU_RECENT_FILES_KEY, normalized_cf_name);
3264     gtk_menu_shell_prepend (GTK_MENU_SHELL(submenu_recent_files), menu_item);
3265     g_signal_connect_swapped(G_OBJECT(menu_item), "activate",
3266                              G_CALLBACK(menu_open_recent_file_cmd_cb), (GObject *) menu_item);
3267     gtk_widget_show (menu_item);
3268
3269     /* add seperator at last position */
3270     menu_item = gtk_menu_item_new();
3271     gtk_menu_shell_append (GTK_MENU_SHELL(submenu_recent_files), menu_item);
3272     gtk_widget_show (menu_item);
3273
3274     /* add new "clear list" item at last position */
3275     menu_item = gtk_image_menu_item_new_from_stock(GTK_STOCK_CLEAR, NULL);
3276     gtk_menu_shell_append (GTK_MENU_SHELL(submenu_recent_files), menu_item);
3277     g_signal_connect_swapped(G_OBJECT(menu_item), "activate",
3278                              G_CALLBACK(clear_menu_recent_capture_file_cmd_cb), (GObject *) menu_item);
3279     gtk_widget_show (menu_item);
3280
3281     update_menu_recent_capture_file(submenu_recent_files);
3282 }
3283
3284 /* add the capture filename to the "Recent Files" menu */
3285 /* (will change nothing, if this filename is already in the menu) */
3286 /*
3287  * XXX - We might want to call SHAddToRecentDocs under Windows 7:
3288  * http://stackoverflow.com/questions/437212/how-do-you-register-a-most-recently-used-list-with-windows-in-preparation-for-win
3289  */
3290 void
3291 add_menu_recent_capture_file(gchar *cf_name) {
3292     gchar *curr;
3293     gchar *absolute;
3294
3295
3296     /* if this filename is an absolute path, we can use it directly */
3297     if (g_path_is_absolute(cf_name)) {
3298         add_menu_recent_capture_file_absolute(cf_name);
3299         return;
3300     }
3301
3302     /* this filename is not an absolute path, prepend the current dir */
3303     curr = g_get_current_dir();
3304     absolute = g_strdup_printf("%s%s%s", curr, G_DIR_SEPARATOR_S, cf_name);
3305     add_menu_recent_capture_file_absolute(absolute);
3306     g_free(curr);
3307     g_free(absolute);
3308 }
3309
3310
3311 /* write all capture filenames of the menu to the user's recent file */
3312 void
3313 menu_recent_file_write_all(FILE *rf) {
3314     GtkWidget   *submenu_recent_files;
3315     GList       *children;
3316     GList       *child;
3317     gchar       *cf_name;
3318     submenu_recent_files = gtk_item_factory_get_widget(main_menu_factory, MENU_RECENT_FILES_PATH_OLD);
3319     /* we have to iterate backwards through the children's list,
3320      * so we get the latest item last in the file.
3321      * (don't use gtk_container_foreach() here, it will return the wrong iteration order) */
3322     children = gtk_container_get_children(GTK_CONTAINER(submenu_recent_files));
3323     child = g_list_last(children);
3324     while(child != NULL) {
3325         /* get capture filename from the menu item label */
3326         cf_name = g_object_get_data(G_OBJECT(child->data), MENU_RECENT_FILES_KEY);
3327         if (cf_name) {
3328             if(u3_active())
3329                 fprintf (rf, RECENT_KEY_CAPTURE_FILE ": %s\n", u3_contract_device_path(cf_name));
3330             else
3331                 fprintf (rf, RECENT_KEY_CAPTURE_FILE ": %s\n", cf_name);
3332         }
3333
3334         child = g_list_previous(child);
3335     }
3336
3337     g_list_free(children);
3338 }
3339
3340
3341 static void
3342 show_hide_cb(GtkWidget *w, gpointer data _U_, gint action)
3343 {
3344
3345     /* save current setting in recent */
3346     switch(action) {
3347     case(SHOW_HIDE_MAIN_TOOLBAR):
3348         recent.main_toolbar_show = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(w));
3349         break;
3350     case(SHOW_HIDE_FILTER_TOOLBAR):
3351         recent.filter_toolbar_show = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(w));
3352         break;
3353 #ifdef HAVE_AIRPCAP
3354     case(SHOW_HIDE_AIRPCAP_TOOLBAR):
3355         recent.airpcap_toolbar_show = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(w));
3356         break;
3357 #endif
3358     case(SHOW_HIDE_STATUSBAR):
3359         recent.statusbar_show = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(w));
3360         break;
3361     case(SHOW_HIDE_PACKET_LIST):
3362         recent.packet_list_show = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(w));
3363         break;
3364     case(SHOW_HIDE_TREE_VIEW):
3365         recent.tree_view_show = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(w));
3366         break;
3367     case(SHOW_HIDE_BYTE_VIEW):
3368         recent.byte_view_show = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(w));
3369         break;
3370     default:
3371         g_assert_not_reached();
3372     }
3373
3374     main_widgets_show_or_hide();
3375 }
3376
3377 static void
3378 timestamp_format_cb(GtkWidget *w _U_, gpointer d _U_, gint action)
3379 {
3380     if (recent.gui_time_format != action) {
3381         timestamp_set_type(action);
3382         recent.gui_time_format = action;
3383         /* This call adjusts column width */
3384         cf_timestamp_auto_precision(&cfile);
3385         new_packet_list_queue_draw();
3386     }
3387 }
3388
3389
3390 static void
3391 timestamp_precision_cb(GtkWidget *w _U_, gpointer d _U_, gint action)
3392 {
3393     if (recent.gui_time_precision != action) {
3394         /* the actual precision will be set in new_packet_list_queue_draw() below */
3395         if (action == TS_PREC_AUTO) {
3396             timestamp_set_precision(TS_PREC_AUTO_SEC);
3397         } else {
3398             timestamp_set_precision(action);
3399         }
3400         recent.gui_time_precision  = action;
3401         /* This call adjusts column width */
3402         cf_timestamp_auto_precision(&cfile);
3403         new_packet_list_queue_draw();
3404     }
3405 }
3406
3407 static void
3408 timestamp_seconds_time_cb(GtkWidget *w, gpointer d _U_, gint action _U_)
3409 {
3410     if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(w))) {
3411         recent.gui_seconds_format = TS_SECONDS_HOUR_MIN_SEC;
3412     } else {
3413         recent.gui_seconds_format = TS_SECONDS_DEFAULT;
3414     }
3415     timestamp_set_seconds_type (recent.gui_seconds_format);
3416
3417     /* This call adjusts column width */
3418     cf_timestamp_auto_precision(&cfile);
3419     new_packet_list_queue_draw();
3420 }
3421
3422 void
3423 menu_name_resolution_changed(void)
3424 {
3425     GtkWidget *menu = NULL;
3426     menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Name Resolution/Enable for MAC Layer");
3427     gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), gbl_resolv_flags & RESOLV_MAC);
3428
3429     menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Name Resolution/Enable for Network Layer");
3430     gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), gbl_resolv_flags & RESOLV_NETWORK);
3431
3432     menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Name Resolution/Enable for Transport Layer");
3433     gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), gbl_resolv_flags & RESOLV_TRANSPORT);
3434 }
3435
3436 static void
3437 name_resolution_cb(GtkWidget *w, gpointer d _U_, gint action)
3438 {
3439     if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(w))) {
3440         gbl_resolv_flags |= action;
3441     } else {
3442         gbl_resolv_flags &= ~action;
3443     }
3444 }
3445
3446 #ifdef HAVE_LIBPCAP
3447 void
3448 menu_auto_scroll_live_changed(gboolean auto_scroll_live_in) {
3449     GtkWidget *menu;
3450
3451
3452     /* tell menu about it */
3453     menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Auto Scroll in Live Capture");
3454     if( ((gboolean) gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menu)) != auto_scroll_live_in) ) {
3455         gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), auto_scroll_live_in);
3456     }
3457
3458     /* tell toolbar about it */
3459     toolbar_auto_scroll_live_changed(auto_scroll_live_in);
3460
3461     /* change auto scroll */
3462     if(auto_scroll_live_in != auto_scroll_live) {
3463         auto_scroll_live  = auto_scroll_live_in;
3464     }
3465 }
3466
3467 static void
3468 auto_scroll_live_cb(GtkWidget *w _U_, gpointer d _U_)
3469 {
3470     menu_auto_scroll_live_changed(gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(w)));
3471 }
3472
3473 #endif /*HAVE_LIBPCAP */
3474
3475
3476 void
3477 menu_colorize_changed(gboolean packet_list_colorize) {
3478     GtkWidget *menu;
3479
3480
3481     /* tell menu about it */
3482     menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Colorize Packet List");
3483     if( (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menu)) != packet_list_colorize) ) {
3484         gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), packet_list_colorize);
3485     }
3486
3487     /* tell toolbar about it */
3488     toolbar_colorize_changed(packet_list_colorize);
3489
3490     /* change colorization */
3491     if(packet_list_colorize != recent.packet_list_colorize) {
3492         recent.packet_list_colorize = packet_list_colorize;
3493         color_filters_enable(packet_list_colorize);
3494         new_packet_list_colorize_packets();
3495     }
3496 }
3497
3498 static void
3499 colorize_cb(GtkWidget *w, gpointer d _U_)
3500 {
3501     menu_colorize_changed(gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(w)));
3502 }
3503
3504
3505 /* the recent file read has finished, update the menu corresponding */
3506 void
3507 menu_recent_read_finished(void) {
3508     GtkWidget *menu = NULL;
3509
3510     menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Main Toolbar");
3511     gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), recent.main_toolbar_show);
3512
3513     menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Filter Toolbar");
3514     gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), recent.filter_toolbar_show);
3515 #ifdef HAVE_AIRPCAP
3516     menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Wireless Toolbar");
3517     gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), recent.airpcap_toolbar_show);
3518 #endif /* HAVE_AIRPCAP */
3519
3520     menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Statusbar");
3521     gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), recent.statusbar_show);
3522
3523     menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Packet List");
3524     gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), recent.packet_list_show);
3525
3526     menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Packet Details");
3527     gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), recent.tree_view_show);
3528
3529     menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Packet Bytes");
3530     gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), recent.byte_view_show);
3531
3532     menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Colorize Packet List");
3533     gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), recent.packet_list_colorize);
3534
3535     menu_name_resolution_changed();
3536
3537 #ifdef HAVE_LIBPCAP
3538     menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Auto Scroll in Live Capture");
3539     gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), auto_scroll_live);
3540 #endif /* HAVE_LIBPCAP */
3541
3542     main_widgets_rearrange();
3543
3544     /* don't change the time format, if we had a command line value */
3545     if (timestamp_get_type() != TS_NOT_SET) {
3546         recent.gui_time_format = timestamp_get_type();
3547     }
3548
3549     switch(recent.gui_time_format) {
3550     case(TS_ABSOLUTE_WITH_DATE):
3551         menu = gtk_item_factory_get_widget(main_menu_factory,
3552             "/View/Time Display Format/Date and Time of Day:   1970-01-01 01:02:03.123456");
3553         break;
3554     case(TS_ABSOLUTE):
3555         menu = gtk_item_factory_get_widget(main_menu_factory,
3556             "/View/Time Display Format/Time of Day:   01:02:03.123456");
3557         break;
3558     case(TS_RELATIVE):
3559         menu = gtk_item_factory_get_widget(main_menu_factory,
3560             "/View/Time Display Format/Seconds Since Beginning of Capture:   123.123456");
3561         break;
3562     case(TS_DELTA):
3563         menu = gtk_item_factory_get_widget(main_menu_factory,
3564             "/View/Time Display Format/Seconds Since Previous Captured Packet:   1.123456");
3565         break;
3566     case(TS_DELTA_DIS):
3567         menu = gtk_item_factory_get_widget(main_menu_factory,
3568             "/View/Time Display Format/Seconds Since Previous Displayed Packet:   1.123456");
3569         break;
3570     case(TS_EPOCH):
3571         menu = gtk_item_factory_get_widget(main_menu_factory,
3572             "/View/Time Display Format/Seconds Since Epoch (1970-01-01):   1234567890.123456");
3573         break;
3574     case(TS_UTC_WITH_DATE):
3575         menu = gtk_item_factory_get_widget(main_menu_factory,
3576             "/View/Time Display Format/UTC Date and Time of Day:   1970-01-01 01:02:03.123456");
3577         break;
3578     case(TS_UTC):
3579         menu = gtk_item_factory_get_widget(main_menu_factory,
3580             "/View/Time Display Format/UTC Time of Day:   01:02:03.123456");
3581         break;
3582     default:
3583         g_assert_not_reached();
3584     }
3585     /* set_active will not trigger the callback when activating an active item! */
3586     recent.gui_time_format = -1;
3587     gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), FALSE);
3588     gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), TRUE);
3589     switch(recent.gui_time_precision) {
3590     case(TS_PREC_AUTO):
3591         menu = gtk_item_factory_get_widget(main_menu_factory,
3592             "/View/Time Display Format/Automatic (File Format Precision)");
3593         break;
3594     case(TS_PREC_FIXED_SEC):
3595         menu = gtk_item_factory_get_widget(main_menu_factory,
3596             "/View/Time Display Format/Seconds:   0");
3597         break;
3598     case(TS_PREC_FIXED_DSEC):
3599         menu = gtk_item_factory_get_widget(main_menu_factory,
3600             "/View/Time Display Format/Deciseconds:   0.1");
3601         break;
3602     case(TS_PREC_FIXED_CSEC):
3603         menu = gtk_item_factory_get_widget(main_menu_factory,
3604             "/View/Time Display Format/Centiseconds:   0.12");
3605         break;
3606     case(TS_PREC_FIXED_MSEC):
3607         menu = gtk_item_factory_get_widget(main_menu_factory,
3608             "/View/Time Display Format/Milliseconds:   0.123");
3609         break;
3610     case(TS_PREC_FIXED_USEC):
3611         menu = gtk_item_factory_get_widget(main_menu_factory,
3612             "/View/Time Display Format/Microseconds:   0.123456");
3613         break;
3614     case(TS_PREC_FIXED_NSEC):
3615         menu = gtk_item_factory_get_widget(main_menu_factory,
3616             "/View/Time Display Format/Nanoseconds:   0.123456789");
3617         break;
3618     default:
3619         g_assert_not_reached();
3620     }
3621
3622     /* set_active will not trigger the callback when activating an active item! */
3623     recent.gui_time_precision = -1;
3624     gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), FALSE);
3625     gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), TRUE);
3626
3627     /* don't change the seconds format, if we had a command line value */
3628     if (timestamp_get_seconds_type() != TS_SECONDS_NOT_SET) {
3629         recent.gui_seconds_format = timestamp_get_seconds_type();
3630     }
3631     menu = gtk_item_factory_get_widget(main_menu_factory,
3632             "/View/Time Display Format/Display Seconds with hours and minutes");
3633
3634     switch (recent.gui_seconds_format) {
3635     case TS_SECONDS_DEFAULT:
3636         recent.gui_seconds_format = -1;
3637         /* set_active will not trigger the callback when deactivating an inactive item! */
3638         gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), TRUE);
3639         gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), FALSE);
3640         break;
3641     case TS_SECONDS_HOUR_MIN_SEC:
3642         recent.gui_seconds_format = -1;
3643         /* set_active will not trigger the callback when activating an active item! */
3644         gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), FALSE);
3645         gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), TRUE);
3646         break;
3647     default:
3648         g_assert_not_reached();
3649     }
3650
3651     menu_colorize_changed(recent.packet_list_colorize);
3652 }
3653
3654
3655 gboolean
3656 popup_menu_handler(GtkWidget *widget, GdkEvent *event, gpointer data)
3657 {
3658     GtkWidget *menu = (GtkWidget *)data;
3659     GdkEventButton *event_button = NULL;
3660     gint row, column;
3661
3662     if(widget == NULL || event == NULL || data == NULL) {
3663         return FALSE;
3664     }
3665
3666     /*
3667      * If we ever want to make the menu differ based on what row
3668      * and/or column we're above, we'd use "eth_clist_get_selection_info()"
3669      * to find the row and column number for the coordinates; a CTree is,
3670      * I guess, like a CList with one column(?) and the expander widget
3671      * as a pixmap.
3672      */
3673     /* Check if we are on packet_list object */
3674     if (widget == g_object_get_data(G_OBJECT(popup_menu_object), E_MPACKET_LIST_KEY) &&
3675         ((GdkEventButton *)event)->button != 1) {
3676         gint physical_row;
3677         if (new_packet_list_get_event_row_column((GdkEventButton *)event, &physical_row, &row, &column)) {
3678             g_object_set_data(G_OBJECT(popup_menu_object), E_MPACKET_LIST_ROW_KEY,
3679                             GINT_TO_POINTER(row));
3680             g_object_set_data(G_OBJECT(popup_menu_object), E_MPACKET_LIST_COL_KEY,
3681                             GINT_TO_POINTER(column));
3682             new_packet_list_set_selected_row(row);
3683         }
3684     }
3685
3686     /* Check if we are on tree_view object */
3687     if (widget == tree_view_gbl) {
3688         tree_view_select(widget, (GdkEventButton *) event);
3689     }
3690
3691     /* context menu handler */
3692     if(event->type == GDK_BUTTON_PRESS) {
3693         event_button = (GdkEventButton *) event;
3694
3695         /* To quote the "Gdk Event Structures" doc:
3696          * "Normally button 1 is the left mouse button, 2 is the middle button, and 3 is the right button" */
3697         if(event_button->button == 3) {
3698             gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL,
3699                            event_button->button,
3700                            event_button->time);
3701             g_signal_stop_emission_by_name(widget, "button_press_event");
3702             return TRUE;
3703         }
3704     }
3705
3706     /* Check if we are on byte_view object */
3707     if(widget == get_notebook_bv_ptr(byte_nb_ptr_gbl)) {
3708         byte_view_select(widget, (GdkEventButton *) event);
3709     }
3710
3711     /* GDK_2BUTTON_PRESS is a doubleclick -> expand/collapse tree row */
3712     /* GTK version 1 seems to be doing this automatically */
3713     if (widget == tree_view_gbl && event->type == GDK_2BUTTON_PRESS) {
3714         GtkTreePath      *path;
3715
3716         if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(widget),
3717                                           (gint) (((GdkEventButton *)event)->x),
3718                                           (gint) (((GdkEventButton *)event)->y),
3719                                           &path, NULL, NULL, NULL))
3720         {
3721             if (gtk_tree_view_row_expanded(GTK_TREE_VIEW(widget), path))
3722                 gtk_tree_view_collapse_row(GTK_TREE_VIEW(widget), path);
3723             else
3724                 gtk_tree_view_expand_row(GTK_TREE_VIEW(widget), path,
3725                                          FALSE);
3726             gtk_tree_path_free(path);
3727         }
3728     }
3729     return FALSE;
3730 }
3731
3732 /* Enable or disable menu items based on whether you have a capture file
3733    you've finished reading and, if you have one, whether it's been saved
3734    and whether it could be saved except by copying the raw packet data. */
3735 void
3736 set_menus_for_capture_file(capture_file *cf)
3737 {
3738     if (cf == NULL) {
3739         /* We have no capture file */
3740         set_menu_sensitivity_old("/File/Merge...", FALSE);
3741         set_menu_sensitivity_old("/File/Close", FALSE);
3742         set_menu_sensitivity_old("/File/Save", FALSE);
3743         set_menu_sensitivity_old("/File/Save As...", FALSE);
3744         set_menu_sensitivity_old("/File/Export", FALSE);
3745         set_menu_sensitivity_old("/View/Reload", FALSE);
3746
3747         set_toolbar_for_capture_file(FALSE);
3748         set_toolbar_for_unsaved_capture_file(FALSE);
3749     } else {
3750         set_menu_sensitivity_old("/File/Merge...", TRUE);
3751         set_menu_sensitivity_old("/File/Close", TRUE);
3752         set_menu_sensitivity_old("/File/Save", !cf->user_saved);
3753         /*
3754          * "Save As..." works only if we can write the file out in at least
3755          * one format (so we can save the whole file or just a subset) or
3756          * if we have an unsaved capture (so writing the whole file out
3757          * with a raw data copy makes sense).
3758          */
3759         set_menu_sensitivity_old("/File/Save As...",
3760                              cf_can_save_as(cf) || !cf->user_saved);
3761         set_menu_sensitivity_old("/File/Export", TRUE);
3762         set_menu_sensitivity_old("/View/Reload", TRUE);
3763         set_toolbar_for_unsaved_capture_file(!cf->user_saved);
3764         set_toolbar_for_capture_file(TRUE);
3765     }
3766 }
3767
3768 /* Enable or disable menu items based on whether there's a capture in
3769    progress. */
3770 void
3771 set_menus_for_capture_in_progress(gboolean capture_in_progress)
3772 {
3773     set_menu_sensitivity_old("/File/Open...",
3774                          !capture_in_progress);
3775     set_menu_sensitivity_old("/File/Open Recent",
3776                          !capture_in_progress);
3777     set_menu_sensitivity_old("/File/Export",
3778                          capture_in_progress);
3779     set_menu_sensitivity_old("/File/File Set",
3780                          !capture_in_progress);
3781     set_menu_sensitivity(ui_manager_packet_list_heading, "/PacketListHeadingPopup/SortAscending",
3782                          !capture_in_progress);
3783     set_menu_sensitivity(ui_manager_packet_list_heading, "/PacketListHeadingPopup/SortDescending",
3784                          !capture_in_progress);
3785     set_menu_sensitivity(ui_manager_packet_list_heading, "/PacketListHeadingPopup/NoSorting",
3786                          !capture_in_progress);
3787
3788 #ifdef HAVE_LIBPCAP
3789     set_menu_sensitivity_old("/Capture/Options...",
3790                          !capture_in_progress);
3791     set_menu_sensitivity_old("/Capture/Start",
3792                          !capture_in_progress);
3793     set_menu_sensitivity_old("/Capture/Stop",
3794                          capture_in_progress);
3795     set_menu_sensitivity_old("/Capture/Restart",
3796                          capture_in_progress);
3797     set_toolbar_for_capture_in_progress(capture_in_progress);
3798
3799     set_capture_if_dialog_for_capture_in_progress(capture_in_progress);
3800 #endif /* HAVE_LIBPCAP */
3801 }
3802
3803 /* Enable or disable menu items based on whether you have some captured
3804    packets. */
3805 static gboolean
3806 walk_menu_tree_for_captured_packets(GList *node,
3807     gboolean have_captured_packets)
3808 {
3809     gboolean    is_enabled;
3810     GList       *child;
3811     menu_item_t *node_data = node->data;
3812
3813     /*
3814      * Is this a leaf node or an interior node?
3815      */
3816     if (node_data->children == NULL) {
3817         /*
3818          * It's a leaf node.
3819          *
3820          * If it has no "selected_packet_enabled()" or
3821          * "selected_tree_row_enabled()" routines, we enable
3822          * it.  This allows tap windows to be popped up even
3823          * if you have no capture file; this is done to let
3824          * the user pop up multiple tap windows before reading
3825          * in a capture file, so that they can be processed in
3826          * parallel while the capture file is being read rather
3827          * than one at at time as you pop up the windows, and to
3828          * let the user pop up tap windows before starting an
3829          * "Update list of packets in real time" capture, so that
3830          * the statistics can be displayed while the capture is
3831          * in progress.
3832          *
3833          * If it has either of those routines, we disable it for
3834          * now - as long as, when a capture is first available,
3835          * we don't get called after a packet or tree row is
3836          * selected, that's OK.
3837          * XXX - that should be done better.
3838          */
3839         if (node_data->selected_packet_enabled == NULL &&
3840             node_data->selected_tree_row_enabled == NULL)
3841             node_data->enabled = TRUE;
3842         else
3843             node_data->enabled = FALSE;
3844     } else {
3845         /*
3846          * It's an interior node; call
3847          * "walk_menu_tree_for_captured_packets()" on all its
3848          * children and, if any of them are enabled, enable
3849          * this node, otherwise disable it.
3850          *
3851          * XXX - should we just leave all interior nodes enabled?
3852          * Which is a better UI choice?
3853          */
3854         is_enabled = FALSE;
3855         for (child = node_data->children; child != NULL; child =
3856                  child->next) {
3857             if (walk_menu_tree_for_captured_packets(child,
3858                                                     have_captured_packets))
3859                 is_enabled = TRUE;
3860         }
3861         node_data->enabled = is_enabled;
3862     }
3863
3864     /*
3865      * The root node doesn't correspond to a menu tree item; it
3866      * has a null name pointer.
3867      */
3868     if (node_data->gui_path != NULL) {
3869         set_menu_sensitivity_old(node_data->gui_path,
3870                              node_data->enabled);
3871     }
3872     return node_data->enabled;
3873 }
3874
3875 void
3876 set_menus_for_captured_packets(gboolean have_captured_packets)
3877 {
3878     set_menu_sensitivity_old("/File/Print...",
3879                          have_captured_packets);
3880     set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/Print",
3881                          have_captured_packets);
3882
3883     set_menu_sensitivity_old("/Edit/Find Packet...",
3884                          have_captured_packets);
3885     set_menu_sensitivity_old("/Edit/Find Next",
3886                          have_captured_packets);
3887     set_menu_sensitivity_old("/Edit/Find Previous",
3888                          have_captured_packets);
3889     set_menu_sensitivity_old("/View/Zoom In",
3890                          have_captured_packets);
3891     set_menu_sensitivity_old("/View/Zoom Out",
3892                          have_captured_packets);
3893     set_menu_sensitivity_old("/View/Normal Size",
3894                          have_captured_packets);
3895     set_menu_sensitivity_old("/Go/Go to Packet...",
3896                          have_captured_packets);
3897     set_menu_sensitivity_old("/Go/Previous Packet",
3898                          have_captured_packets);
3899     set_menu_sensitivity_old("/Go/Next Packet",
3900                          have_captured_packets);
3901     set_menu_sensitivity_old("/Go/First Packet",
3902                          have_captured_packets);
3903     set_menu_sensitivity_old("/Go/Last Packet",
3904                          have_captured_packets);
3905     set_menu_sensitivity_old("/Go/Previous Packet In Conversation",
3906                          have_captured_packets);
3907     set_menu_sensitivity_old("/Go/Next Packet In Conversation",
3908                          have_captured_packets);
3909     set_menu_sensitivity_old("/Statistics/Summary",
3910                          have_captured_packets);
3911     set_menu_sensitivity_old("/Statistics/Protocol Hierarchy",
3912                          have_captured_packets);
3913     walk_menu_tree_for_captured_packets(tap_menu_tree_root,
3914                                         have_captured_packets);
3915     set_toolbar_for_captured_packets(have_captured_packets);
3916 }
3917
3918 /* Enable or disable menu items based on whether a packet is selected and,
3919    if so, on the properties of the packet. */
3920 static gboolean
3921 walk_menu_tree_for_selected_packet(GList *node, frame_data *fd,
3922     epan_dissect_t *edt)
3923 {
3924     gboolean is_enabled;
3925     GList *child;
3926     menu_item_t *node_data = node->data;
3927
3928     /*
3929      * Is this a leaf node or an interior node?
3930      */
3931     if (node_data->children == NULL) {
3932         /*
3933          * It's a leaf node.
3934          *
3935          * If it has no "selected_packet_enabled()" routine,
3936          * leave its enabled/disabled status alone - it
3937          * doesn't depend on whether we have a packet selected
3938          * or not or on the selected packet.
3939          *
3940          * If it has a "selected_packet_enabled()" routine,
3941          * call it and set the item's enabled/disabled status
3942          * based on its return value.
3943          */
3944         if (node_data->selected_packet_enabled != NULL)
3945             node_data->enabled = node_data->selected_packet_enabled(fd, edt, node_data->callback_data);
3946     } else {
3947         /*
3948          * It's an interior node; call
3949          * "walk_menu_tree_for_selected_packet()" on all its
3950          * children and, if any of them are enabled, enable
3951          * this node, otherwise disable it.
3952          *
3953          * XXX - should we just leave all interior nodes enabled?
3954          * Which is a better UI choice?
3955          */
3956         is_enabled = FALSE;
3957         for (child = node_data->children; child != NULL; child =
3958                  child->next) {
3959             if (walk_menu_tree_for_selected_packet(child, fd, edt))
3960                 is_enabled = TRUE;
3961         }
3962         node_data->enabled = is_enabled;
3963     }
3964
3965     /*
3966      * The root node doesn't correspond to a menu tree item; it
3967      * has a null name pointer.
3968      */
3969     if (node_data->gui_path != NULL) {
3970         set_menu_sensitivity_old(node_data->gui_path,
3971                              node_data->enabled);
3972     }
3973     return node_data->enabled;
3974 }
3975
3976 gboolean
3977 packet_is_ssl(epan_dissect_t* edt)
3978 {
3979     GPtrArray* array;
3980     int ssl_id;
3981     gboolean is_ssl;
3982
3983     if (!edt || !edt->tree)
3984         return FALSE;
3985     ssl_id = proto_get_id_by_filter_name("ssl");
3986     if (ssl_id < 0)
3987         return FALSE;
3988     array = proto_find_finfo(edt->tree, ssl_id);
3989     is_ssl = (array->len > 0) ? TRUE : FALSE;
3990     g_ptr_array_free(array, TRUE);
3991     return is_ssl;
3992 }
3993
3994 void
3995 set_menus_for_selected_packet(capture_file *cf)
3996 {
3997     /* Making the menu context-sensitive allows for easier selection of the
3998        desired item and has the added benefit, with large captures, of
3999        avoiding needless looping through huge lists for marked, ignored,
4000        or time-referenced packets. */
4001     gboolean is_ssl = packet_is_ssl(cf->edt);
4002     gboolean frame_selected = cf->current_frame != NULL;
4003         /* A frame is selected */
4004     gboolean have_marked = frame_selected && cf->marked_count > 0;
4005         /* We have marked frames.  (XXX - why check frame_selected?) */
4006     gboolean another_is_marked = have_marked &&
4007         !(cf->marked_count == 1 && cf->current_frame->flags.marked);
4008         /* We have a marked frame other than the current frame (i.e.,
4009            we have at least one marked frame, and either there's more
4010            than one marked frame or the current frame isn't marked). */
4011     gboolean have_time_ref = cf->ref_time_count > 0;
4012     gboolean another_is_time_ref = frame_selected && have_time_ref &&
4013         !(cf->ref_time_count == 1 && cf->current_frame->flags.ref_time);
4014         /* We have a time reference frame other than the current frame (i.e.,
4015            we have at least one time reference frame, and either there's more
4016            than one time reference frame or the current frame isn't a
4017            time reference frame). (XXX - why check frame_selected?) */
4018
4019     set_menu_sensitivity_old("/Edit/Mark Packet (toggle)",
4020                          frame_selected);
4021     set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/MarkPacket",
4022                          frame_selected);
4023     set_menu_sensitivity_old("/Edit/Mark All Displayed Packets (toggle)",
4024                          cf->displayed_count > 0);
4025     /* Unlike un-ignore, do not allow unmark of all frames when no frames are displayed  */
4026     set_menu_sensitivity_old("/Edit/Unmark All Packets",
4027                          have_marked);
4028     set_menu_sensitivity_old("/Edit/Find Next Mark",
4029                          another_is_marked);
4030     set_menu_sensitivity_old("/Edit/Find Previous Mark",
4031                          another_is_marked);
4032
4033     set_menu_sensitivity_old("/Edit/Ignore Packet (toggle)",
4034                          frame_selected);
4035     set_menu_sensitivity_old("/Edit/Edit packet",
4036                          frame_selected);
4037    set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/IgnorePacket",
4038                          frame_selected);
4039     set_menu_sensitivity_old("/Edit/Ignore All Displayed Packets (toggle)",
4040                          cf->displayed_count > 0 && cf->displayed_count != cf->count);
4041     /* Allow un-ignore of all frames even with no frames currently displayed */
4042     set_menu_sensitivity_old("/Edit/Un-Ignore All Packets",
4043                          cf->ignored_count > 0);
4044
4045     set_menu_sensitivity_old("/Edit/Set Time Reference (toggle)",
4046                          frame_selected);
4047     set_menu_sensitivity_old("/Edit/Un-Time Reference All Packets",
4048                          have_time_ref);
4049     set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/SetTimeReference",
4050                          frame_selected);
4051     set_menu_sensitivity_old("/Edit/Find Next Time Reference",
4052                          another_is_time_ref);
4053     set_menu_sensitivity_old("/Edit/Find Previous Time Reference",
4054                          another_is_time_ref);
4055
4056     set_menu_sensitivity_old("/View/Resize All Columns",
4057                          frame_selected);
4058     set_menu_sensitivity_old("/View/Collapse All",
4059                          frame_selected);
4060     set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/CollapseAll",
4061                          frame_selected);
4062      set_menu_sensitivity_old("/View/Expand All",
4063                           frame_selected);
4064     set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/ExpandAll",
4065                          frame_selected);
4066     set_menu_sensitivity_old("/View/Colorize Conversation",
4067                          frame_selected);
4068     set_menu_sensitivity_old("/View/Reset Coloring 1-10",
4069                          tmp_color_filters_used());
4070     set_menu_sensitivity_old("/View/Show Packet in New Window",
4071                          frame_selected);
4072     set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/ShowPacketinNewWindow",
4073                          frame_selected);
4074     set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/ManuallyResolveAddress",
4075                          frame_selected ? ((cf->edt->pi.ethertype == ETHERTYPE_IP)||(cf->edt->pi.ethertype == ETHERTYPE_IPv6)) : FALSE);
4076     set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/SCTP",
4077                          frame_selected ? (cf->edt->pi.ipproto == IP_PROTO_SCTP) : FALSE);
4078     set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/FollowTCPStream",
4079                          frame_selected ? (cf->edt->pi.ipproto == IP_PROTO_TCP) : FALSE);
4080     set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/FollowTCPStream",
4081                          frame_selected ? (cf->edt->pi.ipproto == IP_PROTO_TCP) : FALSE);
4082     set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/FollowUDPStream",
4083                          frame_selected ? (cf->edt->pi.ipproto == IP_PROTO_UDP) : FALSE);
4084     set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/FollowSSLStream",
4085                          frame_selected ? is_ssl : FALSE);
4086     set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/FollowSSLStream",
4087                          frame_selected ? is_ssl : FALSE);
4088     set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/ConversationFilter",
4089                          frame_selected);
4090     set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/ConversationFilter/Ethernet",
4091                          frame_selected ? (cf->edt->pi.dl_src.type == AT_ETHER) : FALSE);
4092     set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/ConversationFilter/IP",
4093                          frame_selected ? ((cf->edt->pi.ethertype == ETHERTYPE_IP)||(cf->edt->pi.ethertype == ETHERTYPE_IPv6)) : FALSE);
4094     set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/ConversationFilter/TCP",
4095                          frame_selected ? (cf->edt->pi.ipproto == IP_PROTO_TCP) : FALSE);
4096     set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/ConversationFilter/UDP",
4097                          frame_selected ? (cf->edt->pi.ipproto == IP_PROTO_UDP) : FALSE);
4098     set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/FollowUDPStream",
4099                          frame_selected ? (cf->edt->pi.ipproto == IP_PROTO_UDP) : FALSE);
4100     set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/ConversationFilter/PN-CBA",
4101                          frame_selected ? (cf->edt->pi.profinet_type != 0 && cf->edt->pi.profinet_type < 10) : FALSE);
4102     set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/ColorizeConversation",
4103                          frame_selected);
4104     set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/ColorizeConversation/Ethernet",
4105                          frame_selected ? (cf->edt->pi.dl_src.type == AT_ETHER) : FALSE);
4106     set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/ColorizeConversation/IP",
4107                          frame_selected ? ((cf->edt->pi.ethertype == ETHERTYPE_IP)||(cf->edt->pi.ethertype == ETHERTYPE_IPv6)) : FALSE);
4108     set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/ColorizeConversation/TCP",
4109                          frame_selected ? (cf->edt->pi.ipproto == IP_PROTO_TCP) : FALSE);
4110     set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/ColorizeConversation/UDP",
4111                          frame_selected ? (cf->edt->pi.ipproto == IP_PROTO_UDP) : FALSE);
4112     set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/ColorizeConversation/PN-CBA",
4113                          frame_selected ? (cf->edt->pi.profinet_type != 0 && cf->edt->pi.profinet_type < 10) : FALSE);
4114     set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/DecodeAs",
4115                          frame_selected && decode_as_ok());
4116     set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/DecodeAs",
4117                          frame_selected && decode_as_ok());
4118     set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/Copy",
4119                          frame_selected);
4120     set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/ApplyAsFilter",
4121                          frame_selected);
4122     set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/PrepareaFilter",
4123                          frame_selected);
4124     set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/ResolveName",
4125                          frame_selected && (gbl_resolv_flags & RESOLV_ALL_ADDRS) != RESOLV_ALL_ADDRS);
4126     set_menu_sensitivity_old("/Analyze/Follow TCP Stream",
4127                          frame_selected ? (cf->edt->pi.ipproto == IP_PROTO_TCP) : FALSE);
4128     set_menu_sensitivity_old("/Analyze/Follow UDP Stream",
4129                          frame_selected ? (cf->edt->pi.ipproto == IP_PROTO_UDP) : FALSE);
4130     set_menu_sensitivity_old("/Analyze/Follow SSL Stream",
4131                          frame_selected ? is_ssl : FALSE);
4132     set_menu_sensitivity_old("/Analyze/Decode As...",
4133                          frame_selected && decode_as_ok());
4134     set_menu_sensitivity_old("/View/Name Resolution/Resolve Name",
4135                          frame_selected && (gbl_resolv_flags & RESOLV_ALL_ADDRS) != RESOLV_ALL_ADDRS);
4136     set_menu_sensitivity_old("/Tools/Firewall ACL Rules",
4137                          frame_selected);
4138     walk_menu_tree_for_selected_packet(tap_menu_tree_root, cf->current_frame,
4139                                        cf->edt);
4140 }
4141
4142 /* Enable or disable menu items based on whether a tree row is selected
4143    and, if so, on the properties of the tree row. */
4144 static gboolean
4145 walk_menu_tree_for_selected_tree_row(GList *node, field_info *fi)
4146 {
4147     gboolean is_enabled;
4148     GList *child;
4149     menu_item_t *node_data = node->data;
4150
4151     /*
4152      * Is this a leaf node or an interior node?
4153      */
4154     if (node_data->children == NULL) {
4155         /*
4156          * It's a leaf node.
4157          *
4158          * If it has no "selected_tree_row_enabled()" routine,
4159          * leave its enabled/disabled status alone - it
4160          * doesn't depend on whether we have a tree row selected
4161          * or not or on the selected tree row.
4162          *
4163          * If it has a "selected_tree_row_enabled()" routine,
4164          * call it and set the item's enabled/disabled status
4165          * based on its return value.
4166          */
4167         if (node_data->selected_tree_row_enabled != NULL)
4168             node_data->enabled = node_data->selected_tree_row_enabled(fi, node_data->callback_data);
4169     } else {
4170         /*
4171          * It's an interior node; call
4172          * "walk_menu_tree_for_selected_tree_row()" on all its
4173          * children and, if any of them are enabled, enable
4174          * this node, otherwise disable it.
4175          *
4176          * XXX - should we just leave all interior nodes enabled?
4177          * Which is a better UI choice?
4178          */
4179         is_enabled = FALSE;
4180         for (child = node_data->children; child != NULL; child =
4181                  child->next) {
4182             if (walk_menu_tree_for_selected_tree_row(child, fi))
4183                 is_enabled = TRUE;
4184         }
4185         node_data->enabled = is_enabled;
4186     }
4187
4188     /*
4189      * The root node doesn't correspond to a menu tree item; it
4190      * has a null name pointer.
4191      */
4192     if (node_data->gui_path != NULL) {
4193         set_menu_sensitivity_old(node_data->gui_path,
4194                              node_data->enabled);
4195     }
4196     return node_data->enabled;
4197 }
4198
4199 static void
4200 menu_prefs_toggle_bool (GtkWidget *w, gpointer data)
4201 {
4202     gboolean *value = data;
4203     module_t *module = g_object_get_data (G_OBJECT(w), "module");
4204
4205     module->prefs_changed = TRUE;
4206     *value = !(*value);
4207
4208     prefs_apply (module);
4209     if (!prefs.gui_use_pref_save) {
4210         prefs_main_write();
4211     }
4212     redissect_packets();
4213 }
4214
4215 static void
4216 menu_prefs_change_enum (GtkWidget *w, gpointer data)
4217 {
4218     gint *value = data;
4219     module_t *module = g_object_get_data (G_OBJECT(w), "module");
4220     gint new_value = GPOINTER_TO_INT(g_object_get_data (G_OBJECT(w), "enumval"));
4221
4222     if (!gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM(w)))
4223         return;
4224
4225     if (*value != new_value) {
4226         module->prefs_changed = TRUE;
4227         *value = new_value;
4228
4229         prefs_apply (module);
4230         if (!prefs.gui_use_pref_save) {
4231             prefs_main_write();
4232         }
4233         redissect_packets();
4234     }
4235 }
4236
4237 void
4238 menu_prefs_reset(void)
4239 {
4240         g_free (g_object_get_data(G_OBJECT(ui_manager_tree_view_menu), "menu_abbrev"));
4241         g_object_set_data(G_OBJECT(ui_manager_tree_view_menu), "menu_abbrev", NULL);
4242 }
4243
4244 static void
4245 menu_prefs_change_ok (GtkWidget *w, gpointer parent_w)
4246 {
4247     GtkWidget *entry = g_object_get_data (G_OBJECT(w), "entry");
4248     module_t *module = g_object_get_data (G_OBJECT(w), "module");
4249     pref_t *pref = g_object_get_data (G_OBJECT(w), "pref");
4250     const gchar *new_value =  gtk_entry_get_text(GTK_ENTRY(entry));
4251     range_t *newrange;
4252     gchar *p;
4253     guint uval;
4254
4255     switch (pref->type) {
4256     case PREF_UINT:
4257         uval = strtoul(new_value, &p, pref->info.base);
4258         if (p == new_value || *p != '\0') {
4259             simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
4260                           "The value \"%s\" isn't a valid number.",
4261                           new_value);
4262             return;
4263         }
4264         if (*pref->varp.uint != uval) {
4265             module->prefs_changed = TRUE;
4266             *pref->varp.uint = uval;
4267         }
4268         break;
4269     case PREF_STRING:
4270         if (strcmp (*pref->varp.string, new_value) != 0) {
4271             module->prefs_changed = TRUE;
4272             g_free((void*)*pref->varp.string);
4273             *pref->varp.string = g_strdup(new_value);
4274         }
4275         break;
4276     case PREF_RANGE:
4277         if (range_convert_str(&newrange, new_value, pref->info.max_value) != CVT_NO_ERROR) {
4278             simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
4279                           "The value \"%s\" isn't a valid range.",
4280                           new_value);
4281             return;
4282         }
4283         if (!ranges_are_equal(*pref->varp.range, newrange)) {
4284             module->prefs_changed = TRUE;
4285             g_free(*pref->varp.range);
4286             *pref->varp.range = newrange;
4287         } else {
4288             g_free (newrange);
4289         }
4290         break;
4291     default:
4292         g_assert_not_reached();
4293         break;
4294     }
4295
4296     if (module->prefs_changed) {
4297         /* Ensure we reload the sub menu */
4298         menu_prefs_reset();
4299         prefs_apply (module);
4300         if (!prefs.gui_use_pref_save) {
4301             prefs_main_write();
4302         }
4303         redissect_packets();
4304     }
4305
4306     window_destroy(GTK_WIDGET(parent_w));
4307 }
4308
4309 static void
4310 menu_prefs_change_cancel (GtkWidget *w _U_, gpointer parent_w)
4311 {
4312     window_destroy(GTK_WIDGET(parent_w));
4313 }
4314
4315 static void
4316 menu_prefs_edit_dlg (GtkWidget *w, gpointer data)
4317 {
4318     pref_t *pref = data;
4319     module_t *module = g_object_get_data (G_OBJECT(w), "module");
4320     gchar *value = NULL;
4321
4322     GtkWidget *win, *main_tb, *main_vb, *bbox, *cancel_bt, *ok_bt;
4323     GtkWidget *entry, *label;
4324
4325     switch (pref->type) {
4326     case PREF_UINT:
4327         switch (pref->info.base) {
4328         case 8:
4329             value = g_strdup_printf("%o", *pref->varp.uint);
4330             break;
4331         case 10:
4332             value = g_strdup_printf("%u", *pref->varp.uint);
4333             break;
4334         case 16:
4335             value = g_strdup_printf("%x", *pref->varp.uint);
4336             break;
4337         default:
4338             g_assert_not_reached();
4339             break;
4340         }
4341         break;
4342     case PREF_STRING:
4343         value = g_strdup(*pref->varp.string);
4344         break;
4345     case PREF_RANGE:
4346         value = g_strdup(range_convert_range (*pref->varp.range));
4347         break;
4348     default:
4349         g_assert_not_reached();
4350         break;
4351     }
4352
4353     win = dlg_window_new(module->description);
4354
4355     gtk_window_set_resizable(GTK_WINDOW(win),FALSE);
4356     gtk_window_resize(GTK_WINDOW(win), 400, 100);
4357
4358     main_vb = gtk_vbox_new(FALSE, 5);
4359     gtk_container_add(GTK_CONTAINER(win), main_vb);
4360     gtk_container_set_border_width(GTK_CONTAINER(main_vb), 6);
4361
4362     main_tb = gtk_table_new(2, 2, FALSE);
4363     gtk_box_pack_start(GTK_BOX(main_vb), main_tb, FALSE, FALSE, 0);
4364     gtk_table_set_col_spacings(GTK_TABLE(main_tb), 10);
4365
4366     label = gtk_label_new(ep_strdup_printf("%s:", pref->title));
4367     gtk_table_attach_defaults(GTK_TABLE(main_tb), label, 0, 1, 1, 2);
4368     gtk_misc_set_alignment(GTK_MISC(label), 1.0f, 0.5f);
4369     if (pref->description)
4370         gtk_widget_set_tooltip_text(label, pref->description);
4371
4372     entry = gtk_entry_new();
4373     gtk_table_attach_defaults(GTK_TABLE(main_tb), entry, 1, 2, 1, 2);
4374     gtk_entry_set_text(GTK_ENTRY(entry), value);
4375     if (pref->description)
4376         gtk_widget_set_tooltip_text(entry, pref->description);
4377
4378     bbox = dlg_button_row_new(GTK_STOCK_CANCEL,GTK_STOCK_OK, NULL);
4379     gtk_box_pack_end(GTK_BOX(main_vb), bbox, FALSE, FALSE, 0);
4380
4381     ok_bt = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_OK);
4382     g_object_set_data (G_OBJECT(ok_bt), "module", module);
4383     g_object_set_data (G_OBJECT(ok_bt), "entry", entry);
4384     g_object_set_data (G_OBJECT(ok_bt), "pref", pref);
4385     g_signal_connect(ok_bt, "clicked", G_CALLBACK(menu_prefs_change_ok), win);
4386
4387     dlg_set_activate(entry, ok_bt);
4388
4389     cancel_bt = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CANCEL);
4390     g_signal_connect(cancel_bt, "clicked", G_CALLBACK(menu_prefs_change_cancel), win);
4391     window_set_cancel_button(win, cancel_bt, NULL);
4392
4393     gtk_widget_grab_default(ok_bt);
4394     gtk_widget_show_all(win);
4395     g_free(value);
4396 }
4397
4398 static guint
4399 add_protocol_prefs_menu (pref_t *pref, gpointer data)
4400 {
4401     GtkWidget *menu_preferences;
4402     GtkWidget *menu_item, *menu_sub_item, *sub_menu;
4403     GSList *group = NULL;
4404     module_t *module = data;
4405     const enum_val_t *enum_valp;
4406     gchar *label = NULL;
4407
4408     switch (pref->type) {
4409     case PREF_UINT:
4410         switch (pref->info.base) {
4411         case 8:
4412             label = g_strdup_printf ("%s: %o", pref->title, *pref->varp.uint);
4413             break;
4414         case 10:
4415             label = g_strdup_printf ("%s: %u", pref->title, *pref->varp.uint);
4416             break;
4417         case 16:
4418             label = g_strdup_printf ("%s: %x", pref->title, *pref->varp.uint);
4419             break;
4420         default:
4421             g_assert_not_reached();
4422             break;
4423         }
4424         menu_item = gtk_menu_item_new_with_label(label);
4425         g_object_set_data (G_OBJECT(menu_item), "module", module);
4426         g_signal_connect(menu_item, "activate", G_CALLBACK(menu_prefs_edit_dlg), pref);
4427         g_free (label);
4428         break;
4429     case PREF_BOOL:
4430         menu_item = gtk_check_menu_item_new_with_label(pref->title);
4431         gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM(menu_item), *pref->varp.boolp);
4432         g_object_set_data (G_OBJECT(menu_item), "module", module);
4433         g_signal_connect(menu_item, "activate", G_CALLBACK(menu_prefs_toggle_bool), pref->varp.boolp);
4434         break;
4435     case PREF_ENUM:
4436         menu_item = gtk_menu_item_new_with_label(pref->title);
4437         sub_menu = gtk_menu_new();
4438         gtk_menu_item_set_submenu (GTK_MENU_ITEM(menu_item), sub_menu);
4439         enum_valp = pref->info.enum_info.enumvals;
4440         while (enum_valp->name != NULL) {
4441             menu_sub_item = gtk_radio_menu_item_new_with_label(group, enum_valp->description);
4442             group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (menu_sub_item));
4443             if (enum_valp->value == *pref->varp.enump) {
4444                 gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM(menu_sub_item), TRUE);
4445             }
4446             g_object_set_data (G_OBJECT(menu_sub_item), "module", module);
4447             g_object_set_data (G_OBJECT(menu_sub_item), "enumval", GINT_TO_POINTER(enum_valp->value));
4448             g_signal_connect(menu_sub_item, "activate", G_CALLBACK(menu_prefs_change_enum), pref->varp.enump);
4449             gtk_menu_shell_append (GTK_MENU_SHELL(sub_menu), menu_sub_item);
4450             gtk_widget_show (menu_sub_item);
4451             enum_valp++;
4452         }
4453         break;
4454     case PREF_STRING:
4455         label = g_strdup_printf ("%s: %s", pref->title, *pref->varp.string);
4456         menu_item = gtk_menu_item_new_with_label(label);
4457         g_object_set_data (G_OBJECT(menu_item), "module", module);
4458         g_signal_connect(menu_item, "activate", G_CALLBACK(menu_prefs_edit_dlg), pref);
4459         g_free (label);
4460         break;
4461     case PREF_RANGE:
4462         label = g_strdup_printf ("%s: %s", pref->title, range_convert_range (*pref->varp.range));
4463         menu_item = gtk_menu_item_new_with_label(label);
4464         g_object_set_data (G_OBJECT(menu_item), "module", module);
4465         g_signal_connect(menu_item, "activate", G_CALLBACK(menu_prefs_edit_dlg), pref);
4466         g_free (label);
4467         break;
4468     case PREF_UAT:
4469         label = g_strdup_printf ("%s...", pref->title);
4470         menu_item = gtk_menu_item_new_with_label(label);
4471         g_signal_connect (menu_item, "activate", G_CALLBACK(uat_window_cb), pref->varp.uat);
4472         g_free (label);
4473         break;
4474     case PREF_STATIC_TEXT:
4475     case PREF_OBSOLETE:
4476     default:
4477         /* Nothing to add */
4478         return 0;
4479     }
4480
4481     menu_preferences = gtk_ui_manager_get_widget(ui_manager_tree_view_menu, "/TreeViewPopup/ProtocolPreferences");
4482     if(!menu_preferences)
4483         g_warning("menu_preferences Not found path:TreeViewPopup/ProtocolPreferences");
4484     sub_menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM(menu_preferences));
4485     gtk_menu_shell_append (GTK_MENU_SHELL(sub_menu), menu_item);
4486     gtk_widget_show (menu_item);
4487
4488     return 0;
4489 }
4490
4491 static void
4492 rebuild_protocol_prefs_menu (module_t *prefs_module_p, gboolean preferences)
4493 {
4494     GtkWidget *menu_preferences, *menu_item;
4495     GtkWidget *sub_menu;
4496     gchar *label;
4497
4498     menu_preferences = gtk_ui_manager_get_widget(ui_manager_tree_view_menu, "/TreeViewPopup/ProtocolPreferences");
4499     if (prefs_module_p && preferences) {
4500         sub_menu = gtk_menu_new();
4501         gtk_menu_item_set_submenu (GTK_MENU_ITEM(menu_preferences), sub_menu);
4502
4503         label = g_strdup_printf ("%s Preferences...", prefs_module_p->description);
4504         menu_item = gtk_image_menu_item_new_with_label (label);
4505         gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM(menu_item),
4506                                        gtk_image_new_from_stock(GTK_STOCK_PREFERENCES, GTK_ICON_SIZE_MENU));
4507         gtk_menu_shell_append (GTK_MENU_SHELL(sub_menu), menu_item);
4508         g_signal_connect_swapped(G_OBJECT(menu_item), "activate",
4509                                  G_CALLBACK(properties_cb), (GObject *) menu_item);
4510         gtk_widget_show (menu_item);
4511         g_free (label);
4512
4513         menu_item = gtk_menu_item_new();
4514         gtk_menu_shell_append (GTK_MENU_SHELL(sub_menu), menu_item);
4515         gtk_widget_show (menu_item);
4516
4517         prefs_pref_foreach(prefs_module_p, add_protocol_prefs_menu, prefs_module_p);
4518     } else {
4519         /* No preferences, remove sub menu */
4520         gtk_menu_item_set_submenu (GTK_MENU_ITEM(menu_preferences), NULL);
4521     }
4522
4523 }
4524
4525 static void
4526 menu_visible_column_toggle (GtkWidget *w _U_, gpointer data)
4527 {
4528     new_packet_list_toggle_visible_column (GPOINTER_TO_INT(data));
4529 }
4530
4531 void
4532 rebuild_visible_columns_menu (void)
4533 {
4534     GtkWidget *menu_columns[2], *menu_item;
4535     GtkWidget *sub_menu;
4536     GList     *clp;
4537     fmt_data  *cfmt;
4538     gchar     *title;
4539     gint       i, col_id, cur_fmt;
4540     menu_columns[0] = gtk_item_factory_get_widget(main_menu_factory, "/View/Displayed Columns");
4541     menu_columns[1] = gtk_ui_manager_get_widget(ui_manager_packet_list_heading, "/PacketListHeadingPopup/DisplayedColumns");
4542     /* Debug */
4543     if(! menu_columns[1]){
4544         fprintf (stderr, "Warning: couldn't find menu_columns[1] path=/PacketListHeadingPopup/DisplayedColumns");
4545     }
4546
4547     for (i = 0; i < 2; i++) {
4548         sub_menu = gtk_menu_new();
4549         gtk_menu_item_set_submenu (GTK_MENU_ITEM(menu_columns[i]), sub_menu);
4550
4551         clp = g_list_first (prefs.col_list);
4552         col_id = 0;
4553         while (clp) {
4554             cfmt = (fmt_data *) clp->data;
4555             cur_fmt = get_column_format_from_str(cfmt->fmt);
4556             if (cfmt->title[0]) {
4557                 if (cur_fmt == COL_CUSTOM) {
4558                     title = g_strdup_printf ("%s  (%s)", cfmt->title, cfmt->custom_field);
4559                 } else {
4560                     title = g_strdup_printf ("%s  (%s)", cfmt->title, col_format_desc (cur_fmt));
4561                 }
4562             } else {
4563                 if (cur_fmt == COL_CUSTOM) {
4564                     title = g_strdup_printf ("(%s)", cfmt->custom_field);
4565                 } else {
4566                     title = g_strdup_printf ("(%s)", col_format_desc (cur_fmt));
4567                 }
4568             }
4569             menu_item = gtk_check_menu_item_new_with_label(title);
4570             g_free (title);
4571             gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM(menu_item), cfmt->visible);
4572             g_signal_connect(menu_item, "activate", G_CALLBACK(menu_visible_column_toggle), GINT_TO_POINTER(col_id));
4573             gtk_menu_shell_append (GTK_MENU_SHELL(sub_menu), menu_item);
4574             gtk_widget_show (menu_item);
4575             clp = g_list_next (clp);
4576             col_id++;
4577         }
4578
4579         menu_item = gtk_menu_item_new();
4580         gtk_menu_shell_append (GTK_MENU_SHELL(sub_menu), menu_item);
4581         gtk_widget_show (menu_item);
4582
4583         menu_item = gtk_menu_item_new_with_label ("Display All");
4584         gtk_menu_shell_append (GTK_MENU_SHELL(sub_menu), menu_item);
4585         g_signal_connect(menu_item, "activate", G_CALLBACK(packet_list_heading_activate_all_columns_cb), NULL);
4586         gtk_widget_show (menu_item);
4587     }
4588 }
4589
4590 void
4591 menus_set_column_resolved (gboolean resolved, gboolean can_resolve)
4592 {
4593     GtkWidget *menu;
4594
4595     menu = gtk_ui_manager_get_widget(ui_manager_packet_list_heading, "/PacketListHeadingPopup/ShowResolved");
4596     if(!menu){
4597         fprintf (stderr, "Warning: couldn't find menu path=/PacketListHeadingPopup/ShowResolved");
4598     }
4599     g_object_set_data(G_OBJECT(menu), "skip-update", (void *)1);
4600     gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), resolved && can_resolve);
4601     set_menu_sensitivity(ui_manager_packet_list_heading, "/PacketListHeadingPopup/ShowResolved", can_resolve);
4602     g_object_set_data(G_OBJECT(menu), "skip-update", NULL);
4603 }
4604
4605 void
4606 menus_set_column_align_default (gboolean right_justify)
4607 {
4608     GtkWidget   *submenu, *menu_item_child;
4609     GList       *child_list, *child_list_item;
4610     const gchar *menu_item_name;
4611     size_t       menu_item_len;
4612
4613     /* get the submenu container item */
4614     submenu = gtk_ui_manager_get_widget (ui_manager_packet_list_heading, "/PacketListHeadingPopup");
4615     if(!submenu){
4616         fprintf (stderr, "Warning: couldn't find submenu path=/PacketListHeadingPopup");
4617     }
4618
4619     /* find the corresponding menu items to update */
4620     child_list = gtk_container_get_children(GTK_CONTAINER(submenu));
4621     child_list_item = child_list;
4622     while(child_list_item) {
4623         menu_item_child = gtk_bin_get_child(GTK_BIN(child_list_item->data));
4624         if (menu_item_child != NULL) {
4625             menu_item_name = gtk_label_get_text(GTK_LABEL(menu_item_child));
4626             menu_item_len = strlen (menu_item_name);
4627             if(strncmp(menu_item_name, "Align Left", 10) == 0) {
4628                 if (!right_justify && menu_item_len == 10) {
4629                     gtk_label_set_text(GTK_LABEL(menu_item_child), "Align Left\t(default)");
4630                 } else if (right_justify && menu_item_len > 10) {
4631                     gtk_label_set_text(GTK_LABEL(menu_item_child), "Align Left");
4632                 }
4633             } else if (strncmp (menu_item_name, "Align Right", 11) == 0) {
4634                 if (right_justify && menu_item_len == 11) {
4635                     gtk_label_set_text(GTK_LABEL(menu_item_child), "Align Right\t(default)");
4636                 } else if (!right_justify && menu_item_len > 11) {
4637                     gtk_label_set_text(GTK_LABEL(menu_item_child), "Align Right");
4638                 }
4639             }
4640         }
4641         child_list_item = g_list_next(child_list_item);
4642     }
4643     g_list_free(child_list);
4644 }
4645
4646 void
4647 set_menus_for_selected_tree_row(capture_file *cf)
4648 {
4649     gboolean properties;
4650     gint id;
4651
4652     if (cf->finfo_selected != NULL) {
4653         header_field_info *hfinfo = cf->finfo_selected->hfinfo;
4654         const char *abbrev;
4655         char *prev_abbrev;
4656
4657         if (hfinfo->parent == -1) {
4658             abbrev = hfinfo->abbrev;
4659             id = (hfinfo->type == FT_PROTOCOL) ? proto_get_id((protocol_t *)hfinfo->strings) : -1;
4660         } else {
4661             abbrev = proto_registrar_get_abbrev(hfinfo->parent);
4662             id = hfinfo->parent;
4663         }
4664         properties = prefs_is_registered_protocol(abbrev);
4665         set_menu_sensitivity(ui_manager_tree_view_menu,
4666                              "/TreeViewPopup/GotoCorrespondingPacket", hfinfo->type == FT_FRAMENUM);
4667         set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/Copy",
4668                              TRUE);
4669         set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/Copy/AsFilter",
4670                              proto_can_match_selected(cf->finfo_selected, cf->edt));
4671         set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/ApplyasColumn",
4672                              hfinfo->type != FT_NONE);
4673         set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/ApplyAsFilter",
4674                              proto_can_match_selected(cf->finfo_selected, cf->edt));
4675         set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/PrepareaFilter",
4676                              proto_can_match_selected(cf->finfo_selected, cf->edt));
4677         set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/ColorizewithFilter",
4678                              proto_can_match_selected(cf->finfo_selected, cf->edt));
4679         set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/ProtocolPreferences",
4680                              properties);
4681         set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/DisableProtocol",
4682                              (id == -1) ? FALSE : proto_can_toggle_protocol(id));
4683         set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/ExpandSubtrees",
4684                              cf->finfo_selected->tree_type != -1);
4685         set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/WikiProtocolPage",
4686                              (id == -1) ? FALSE : TRUE);
4687         set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/FilterFieldReference",
4688                              (id == -1) ? FALSE : TRUE);
4689         set_menu_sensitivity_old(
4690                              "/File/Export/Selected Packet Bytes...", TRUE);
4691         set_menu_sensitivity_old(
4692                              "/Go/Go to Corresponding Packet", hfinfo->type == FT_FRAMENUM);
4693         set_menu_sensitivity_old("/Edit/Copy/Description",
4694                              proto_can_match_selected(cf->finfo_selected, cf->edt));
4695         set_menu_sensitivity_old("/Edit/Copy/Fieldname",
4696                              proto_can_match_selected(cf->finfo_selected, cf->edt));
4697         set_menu_sensitivity_old("/Edit/Copy/Value",
4698                              proto_can_match_selected(cf->finfo_selected, cf->edt));
4699         set_menu_sensitivity_old("/Edit/Copy/As Filter",
4700                              proto_can_match_selected(cf->finfo_selected, cf->edt));
4701         set_menu_sensitivity_old("/Analyze/Apply as Column",
4702                              hfinfo->type != FT_NONE);
4703         set_menu_sensitivity_old("/Analyze/Apply as Filter",
4704                              proto_can_match_selected(cf->finfo_selected, cf->edt));
4705         set_menu_sensitivity_old("/Analyze/Prepare a Filter",
4706                              proto_can_match_selected(cf->finfo_selected, cf->edt));
4707         set_menu_sensitivity_old("/View/Expand Subtrees",
4708                              cf->finfo_selected->tree_type != -1);
4709         prev_abbrev = g_object_get_data(G_OBJECT(ui_manager_tree_view_menu), "menu_abbrev");
4710         if (!prev_abbrev || (strcmp (prev_abbrev, abbrev) != 0)) {
4711             /* No previous protocol or protocol changed - update Protocol Preferences menu */
4712             module_t *prefs_module_p = prefs_find_module(abbrev);
4713             rebuild_protocol_prefs_menu (prefs_module_p, properties);
4714
4715             g_object_set_data(G_OBJECT(ui_manager_tree_view_menu), "menu_abbrev", g_strdup(abbrev));
4716             g_free (prev_abbrev);
4717         }
4718     } else {
4719         set_menu_sensitivity(ui_manager_tree_view_menu,
4720                              "/TreeViewPopup/GotoCorrespondingPacket", FALSE);
4721         set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/Copy", FALSE);
4722         set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/ApplyasColumn", FALSE);
4723         set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/ApplyAsFilter", FALSE);
4724         set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/PrepareaFilter", FALSE);
4725         set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/ColorizewithFilter", FALSE);
4726         set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/ProtocolPreferences",
4727                              FALSE);
4728         set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/DisableProtocol", FALSE);
4729         set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/ExpandSubtrees", FALSE);
4730         set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/WikiProtocolPage",
4731                              FALSE);
4732         set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/FilterFieldReference",
4733                              FALSE);
4734         set_menu_sensitivity_old("/File/Export/Selected Packet Bytes...", FALSE);
4735         set_menu_sensitivity_old("/Go/Go to Corresponding Packet", FALSE);
4736         set_menu_sensitivity_old("/Edit/Copy/Description", FALSE);
4737         set_menu_sensitivity_old("/Edit/Copy/Fieldname", FALSE);
4738         set_menu_sensitivity_old("/Edit/Copy/Value", FALSE);
4739         set_menu_sensitivity_old("/Edit/Copy/As Filter", FALSE);
4740         set_menu_sensitivity_old("/Analyze/Apply as Column", FALSE);
4741         set_menu_sensitivity_old("/Analyze/Apply as Filter", FALSE);
4742         set_menu_sensitivity_old("/Analyze/Prepare a Filter", FALSE);
4743         set_menu_sensitivity_old("/View/Expand Subtrees", FALSE);
4744
4745         }
4746
4747     walk_menu_tree_for_selected_tree_row(tap_menu_tree_root, cf->finfo_selected);
4748 }
4749
4750 void set_menus_for_packet_history(gboolean back_history, gboolean forward_history) {
4751     set_menu_sensitivity_old("/Go/Back", back_history);
4752     set_menu_sensitivity_old("/Go/Forward", forward_history);
4753     set_toolbar_for_packet_history(back_history, forward_history);
4754 }
4755
4756
4757 void set_menus_for_file_set(gboolean file_set, gboolean previous_file, gboolean next_file) {
4758     set_menu_sensitivity_old("/File/File Set/List Files", file_set);
4759     set_menu_sensitivity_old("/File/File Set/Previous File", previous_file);
4760     set_menu_sensitivity_old("/File/File Set/Next File", next_file);
4761 }
4762
4763 GtkWidget *menus_get_profiles_edit_menu (void)
4764 {
4765     return gtk_ui_manager_get_widget(ui_manager_statusbar_profiles_menu, "/ProfilesMenuPopup/Edit");
4766 }
4767
4768 GtkWidget *menus_get_profiles_delete_menu (void)
4769 {
4770     return gtk_ui_manager_get_widget(ui_manager_statusbar_profiles_menu, "/ProfilesMenuPopup/Delete");
4771 }
4772
4773 GtkWidget *menus_get_profiles_change_menu (void)
4774 {
4775     return gtk_ui_manager_get_widget(ui_manager_statusbar_profiles_menu, "/ProfilesMenuPopup/Change");
4776 }
4777
4778 void set_menus_for_profiles(gboolean default_profile)
4779 {
4780     set_menu_sensitivity(ui_manager_statusbar_profiles_menu, "/ProfilesMenuPopup/Edit", !default_profile);
4781     set_menu_sensitivity(ui_manager_statusbar_profiles_menu, "/ProfilesMenuPopup/Delete", !default_profile);
4782 }
4783
4784 /*
4785  * Editor modelines
4786  *
4787  * Local Variables:
4788  * c-basic-offset: 4
4789  * tab-width: 8
4790  * indent-tabs-mode: nil
4791  * End:
4792  *
4793  * ex: set shiftwidth=4 tabstop=8 expandtab
4794  * :indentSize=4:tabSize=8:noTabs=true:
4795  */
4796 #endif /* MAIN_MENU_USE_UIMANAGER */