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      &nb