1998-09-16 02:39:15 +00:00
|
|
|
/* menu.c
|
|
|
|
* Menu routines
|
|
|
|
*
|
Have separate capture and display filter lists; some filter dialog boxes
use the capture filter lists, and others use the display filter list, as
appropriate.
Have separate menu items for editing the capture and display filter
lists.
Have separate "~/.ethereal/cfilters" and "~/.ethereal/dfilters" files
for the two lists; if either of those files isn't found, we try
"~/.ethereal/filters", which means that you will start out with two
identical lists holding all your filters - if certain filters belong
only in one list, you'll have to delete them by hand from the other
list.
Do I/O error checking when reading and writing filter lists; when
writing a filter list, write it to a new file, and then rename the new
file on top of the old file, so that you don't lose your old filter list
if, for example, you run out of disk space or disk quota.
svn path=/trunk/; revision=2948
2001-01-28 09:13:10 +00:00
|
|
|
* $Id: menu.c,v 1.47 2001/01/28 09:13:10 guy Exp $
|
1998-09-16 03:22:19 +00:00
|
|
|
*
|
1998-09-16 02:39:15 +00:00
|
|
|
* Ethereal - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@zing.org>
|
|
|
|
* Copyright 1998 Gerald Combs
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <gtk/gtk.h>
|
2000-01-18 08:38:18 +00:00
|
|
|
#include <glib.h>
|
1998-09-16 02:39:15 +00:00
|
|
|
|
1999-04-05 22:51:44 +00:00
|
|
|
#include <string.h>
|
1999-07-09 04:18:36 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#ifdef HAVE_SYS_TYPES_H
|
|
|
|
# include <sys/types.h>
|
|
|
|
#endif
|
1998-09-16 02:39:15 +00:00
|
|
|
|
2000-01-03 03:57:04 +00:00
|
|
|
#include "../menu.h"
|
|
|
|
|
1999-09-09 02:42:40 +00:00
|
|
|
#include "main.h"
|
1998-12-17 05:42:33 +00:00
|
|
|
#include "menu.h"
|
1998-09-16 02:39:15 +00:00
|
|
|
#include "packet.h"
|
2000-10-19 22:59:24 +00:00
|
|
|
#include "resolv.h"
|
1999-09-09 03:32:03 +00:00
|
|
|
#include "capture_dlg.h"
|
2000-02-12 08:31:49 +00:00
|
|
|
#include "color_dlg.h"
|
2000-02-12 06:58:42 +00:00
|
|
|
#include "file_dlg.h"
|
2000-02-12 06:46:54 +00:00
|
|
|
#include "filter_prefs.h"
|
1999-11-06 06:28:07 +00:00
|
|
|
#include "find_dlg.h"
|
1999-11-10 07:01:53 +00:00
|
|
|
#include "goto_dlg.h"
|
1999-12-10 04:21:04 +00:00
|
|
|
#include "summary_dlg.h"
|
1999-10-18 12:48:14 +00:00
|
|
|
#include "display_opts.h"
|
1999-09-09 03:32:03 +00:00
|
|
|
#include "prefs_dlg.h"
|
2000-02-29 06:24:41 +00:00
|
|
|
#include "packet_win.h"
|
1998-09-16 02:39:15 +00:00
|
|
|
#include "print.h"
|
2000-08-03 12:44:40 +00:00
|
|
|
#include "follow_dlg.h"
|
2000-08-08 12:28:50 +00:00
|
|
|
#include "help_dlg.h"
|
Add the "Edit:Protocols..." feature which currently only implements
the following:
It is now possible to enable/disable a particular protocol decoding
(i.e. the protocol dissector is void or not). When a protocol
is disabled, it is displayed as Data and of course, all linked
sub-protocols are disabled as well.
Disabling a protocol could be interesting:
- in case of buggy dissectors
- in case of wrong heuristics
- for performance reasons
- to decode the data as another protocol (TODO)
Currently (if I am not wrong), all dissectors but NFS can be disabled
(and dissectors that do not register protocols :-)
I do not like the way the RPC sub-dissectors are disabled (in the
sub-dissectors) since this could be done in the RPC dissector itself,
knowing the sub-protocol hfinfo entry (this is why, I've not modified
the NFS one yet).
Two functions are added in proto.c :
gboolean proto_is_protocol_enabled(int n);
void proto_set_decoding(int n, gboolean enabled);
and two MACROs which can be used in dissectors:
OLD_CHECK_DISPLAY_AS_DATA(index, pd, offset, fd, tree)
CHECK_DISPLAY_AS_DATA(index, tvb, pinfo, tree)
See also the XXX in proto_dlg.c and proto.c around the new functions.
svn path=/trunk/; revision=2267
2000-08-13 14:09:15 +00:00
|
|
|
#include "proto_dlg.h"
|
2000-01-18 08:38:18 +00:00
|
|
|
#include "keys.h"
|
2000-01-17 17:12:43 +00:00
|
|
|
#include "plugins.h"
|
1998-09-16 02:39:15 +00:00
|
|
|
|
2000-04-06 06:52:10 +00:00
|
|
|
GtkWidget *popup_menu_object;
|
|
|
|
|
2000-01-03 04:06:09 +00:00
|
|
|
#define GTK_MENU_FUNC(a) ((GtkItemFactoryCallback)(a))
|
|
|
|
|
|
|
|
static void menus_init(void);
|
|
|
|
static void set_menu_sensitivity (gchar *, gint);
|
1998-09-16 02:39:15 +00:00
|
|
|
|
1999-06-12 06:22:47 +00:00
|
|
|
/* This is the GtkItemFactoryEntry structure used to generate new menus.
|
|
|
|
Item 1: The menu path. The letter after the underscore indicates an
|
|
|
|
accelerator key once the menu is open.
|
|
|
|
Item 2: The accelerator key for the entry
|
|
|
|
Item 3: The callback function.
|
|
|
|
Item 4: The callback action. This changes the parameters with
|
|
|
|
which the function is called. The default is 0.
|
|
|
|
Item 5: The item type, used to define what kind of an item it is.
|
|
|
|
Here are the possible values:
|
|
|
|
|
|
|
|
NULL -> "<Item>"
|
|
|
|
"" -> "<Item>"
|
|
|
|
"<Title>" -> create a title item
|
|
|
|
"<Item>" -> create a simple item
|
|
|
|
"<CheckItem>" -> create a check item
|
|
|
|
"<ToggleItem>" -> create a toggle item
|
|
|
|
"<RadioItem>" -> create a radio item
|
|
|
|
<path> -> path of a radio item to link against
|
|
|
|
"<Separator>" -> create a separator
|
|
|
|
"<Branch>" -> create an item to hold sub items (optional)
|
|
|
|
"<LastBranch>" -> create a right justified branch
|
|
|
|
*/
|
|
|
|
|
2000-01-18 08:38:18 +00:00
|
|
|
/* main menu */
|
1998-12-17 05:42:33 +00:00
|
|
|
static GtkItemFactoryEntry menu_items[] =
|
|
|
|
{
|
|
|
|
{"/_File", NULL, NULL, 0, "<Branch>" },
|
1999-06-15 04:48:57 +00:00
|
|
|
{"/File/_Open...", "<control>O", GTK_MENU_FUNC(file_open_cmd_cb), 0, NULL},
|
1998-12-17 05:42:33 +00:00
|
|
|
{"/File/_Close", "<control>W", GTK_MENU_FUNC(file_close_cmd_cb), 0, NULL},
|
1999-04-06 16:24:50 +00:00
|
|
|
{"/File/_Save", "<control>S", GTK_MENU_FUNC(file_save_cmd_cb), 0, NULL},
|
1999-06-15 04:48:57 +00:00
|
|
|
{"/File/Save _As...", NULL, GTK_MENU_FUNC(file_save_as_cmd_cb), 0, NULL},
|
1999-07-27 02:04:38 +00:00
|
|
|
{"/File/_Reload", "<control>R", GTK_MENU_FUNC(file_reload_cmd_cb), 0, NULL},
|
1998-12-17 05:42:33 +00:00
|
|
|
{"/File/<separator>", NULL, NULL, 0, "<Separator>"},
|
2000-05-02 03:21:41 +00:00
|
|
|
{"/File/_Print...", NULL, GTK_MENU_FUNC(file_print_cmd_cb), 0, NULL},
|
1999-07-23 08:29:24 +00:00
|
|
|
{"/File/Print Pac_ket", "<control>P", GTK_MENU_FUNC(file_print_packet_cmd_cb), 0, NULL},
|
1998-12-17 05:42:33 +00:00
|
|
|
{"/File/<separator>", NULL, NULL, 0, "<Separator>"},
|
|
|
|
{"/File/_Quit", "<control>Q", GTK_MENU_FUNC(file_quit_cmd_cb), 0, NULL},
|
|
|
|
{"/_Edit", NULL, NULL, 0, "<Branch>" },
|
2000-09-09 08:17:51 +00:00
|
|
|
#if 0
|
|
|
|
/* Un-#if this when we actually implement Cut/Copy/Paste. */
|
1998-12-17 05:42:33 +00:00
|
|
|
{"/Edit/Cut", "<control>X", NULL, 0, NULL},
|
|
|
|
{"/Edit/Copy", "<control>C", NULL, 0, NULL},
|
|
|
|
{"/Edit/Paste", "<control>V", NULL, 0, NULL},
|
|
|
|
{"/Edit/<separator>", NULL, NULL, 0, "<Separator>"},
|
2000-09-09 08:17:51 +00:00
|
|
|
#endif
|
2000-01-18 09:05:30 +00:00
|
|
|
{"/Edit/_Find Frame...", "<control>F", GTK_MENU_FUNC(find_frame_cb), 0, NULL},
|
|
|
|
{"/Edit/_Go To Frame...", "<control>G", GTK_MENU_FUNC(goto_frame_cb), 0, NULL},
|
1998-12-17 05:42:33 +00:00
|
|
|
{"/Edit/<separator>", NULL, NULL, 0, "<Separator>"},
|
2000-08-22 14:21:27 +00:00
|
|
|
{"/Edit/_Mark Frame", "<control>M", GTK_MENU_FUNC(mark_frame_cb), 0, NULL},
|
2000-08-21 19:36:19 +00:00
|
|
|
{"/Edit/Mark _All Frames", NULL, GTK_MENU_FUNC(mark_all_frames_cb), 0, NULL},
|
|
|
|
{"/Edit/_Unmark All Frames", NULL, GTK_MENU_FUNC(unmark_all_frames_cb), 0, NULL},
|
|
|
|
{"/Edit/<separator>", NULL, NULL, 0, "<Separator>"},
|
2000-07-05 06:33:02 +00:00
|
|
|
{"/Edit/_Preferences...", NULL, GTK_MENU_FUNC(prefs_cb), 0, NULL},
|
Have separate capture and display filter lists; some filter dialog boxes
use the capture filter lists, and others use the display filter list, as
appropriate.
Have separate menu items for editing the capture and display filter
lists.
Have separate "~/.ethereal/cfilters" and "~/.ethereal/dfilters" files
for the two lists; if either of those files isn't found, we try
"~/.ethereal/filters", which means that you will start out with two
identical lists holding all your filters - if certain filters belong
only in one list, you'll have to delete them by hand from the other
list.
Do I/O error checking when reading and writing filter lists; when
writing a filter list, write it to a new file, and then rename the new
file on top of the old file, so that you don't lose your old filter list
if, for example, you run out of disk space or disk quota.
svn path=/trunk/; revision=2948
2001-01-28 09:13:10 +00:00
|
|
|
{"/Edit/_Capture Filters...", NULL, GTK_MENU_FUNC(cfilter_dialog_cb), 0, NULL},
|
|
|
|
{"/Edit/_Display Filters...", NULL, GTK_MENU_FUNC(dfilter_dialog_cb), 0, NULL},
|
Add the "Edit:Protocols..." feature which currently only implements
the following:
It is now possible to enable/disable a particular protocol decoding
(i.e. the protocol dissector is void or not). When a protocol
is disabled, it is displayed as Data and of course, all linked
sub-protocols are disabled as well.
Disabling a protocol could be interesting:
- in case of buggy dissectors
- in case of wrong heuristics
- for performance reasons
- to decode the data as another protocol (TODO)
Currently (if I am not wrong), all dissectors but NFS can be disabled
(and dissectors that do not register protocols :-)
I do not like the way the RPC sub-dissectors are disabled (in the
sub-dissectors) since this could be done in the RPC dissector itself,
knowing the sub-protocol hfinfo entry (this is why, I've not modified
the NFS one yet).
Two functions are added in proto.c :
gboolean proto_is_protocol_enabled(int n);
void proto_set_decoding(int n, gboolean enabled);
and two MACROs which can be used in dissectors:
OLD_CHECK_DISPLAY_AS_DATA(index, pd, offset, fd, tree)
CHECK_DISPLAY_AS_DATA(index, tvb, pinfo, tree)
See also the XXX in proto_dlg.c and proto.c around the new functions.
svn path=/trunk/; revision=2267
2000-08-13 14:09:15 +00:00
|
|
|
{"/Edit/P_rotocols...", NULL, GTK_MENU_FUNC(proto_cb), 0, NULL},
|
1999-07-09 04:18:36 +00:00
|
|
|
#ifdef HAVE_LIBPCAP
|
1999-06-19 01:14:51 +00:00
|
|
|
{"/_Capture", NULL, NULL, 0, "<Branch>" },
|
|
|
|
{"/Capture/_Start...", "<control>K", GTK_MENU_FUNC(capture_prep_cb), 0, NULL},
|
2000-10-11 06:01:16 +00:00
|
|
|
/*
|
|
|
|
* XXX - this doesn't yet work in Win32.
|
|
|
|
*/
|
|
|
|
#ifndef _WIN32
|
|
|
|
{"/Capture/S_top", "<control>E", GTK_MENU_FUNC(capture_stop_cb), 0, NULL},
|
|
|
|
#endif /* _WIN32 */
|
|
|
|
#endif /* HAVE_LIBPCAP */
|
1999-06-19 01:14:51 +00:00
|
|
|
{"/_Display", NULL, NULL, 0, "<Branch>" },
|
|
|
|
{"/Display/_Options...", NULL, GTK_MENU_FUNC(display_opt_cb), 0, NULL},
|
1999-06-24 16:25:59 +00:00
|
|
|
{"/Display/_Match Selected", NULL, GTK_MENU_FUNC(match_selected_cb), 0, NULL},
|
1999-08-24 16:27:23 +00:00
|
|
|
{"/Display/_Colorize Display...", NULL, GTK_MENU_FUNC(color_display_cb), 0, NULL},
|
1999-09-11 12:38:18 +00:00
|
|
|
{"/Display/Collapse _All", NULL, GTK_MENU_FUNC(collapse_all_cb), 0, NULL},
|
|
|
|
{"/Display/_Expand All", NULL, GTK_MENU_FUNC(expand_all_cb), 0, NULL},
|
2000-02-29 06:24:41 +00:00
|
|
|
{"/Display/_Show Packet In New Window", NULL, GTK_MENU_FUNC(new_window_cb), 0, NULL},
|
1998-12-17 05:42:33 +00:00
|
|
|
{"/_Tools", NULL, NULL, 0, "<Branch>" },
|
2000-01-15 00:23:13 +00:00
|
|
|
#ifdef HAVE_PLUGINS
|
1999-12-09 20:43:38 +00:00
|
|
|
{"/Tools/_Plugins...", NULL, GTK_MENU_FUNC(tools_plugins_cmd_cb), 0, NULL},
|
|
|
|
#endif
|
1998-12-17 05:42:33 +00:00
|
|
|
{"/Tools/_Follow TCP Stream", NULL, GTK_MENU_FUNC(follow_stream_cb), 0, NULL},
|
1999-06-24 16:25:59 +00:00
|
|
|
/* {"/Tools/Graph", NULL, NULL, 0, NULL}, future use */
|
1999-12-10 04:21:04 +00:00
|
|
|
{"/Tools/_Summary", NULL, GTK_MENU_FUNC(summary_open_cb), 0, NULL},
|
1998-12-27 20:46:45 +00:00
|
|
|
{"/_Help", NULL, NULL, 0, "<LastBranch>" },
|
2000-08-09 06:43:22 +00:00
|
|
|
{"/Help/_Help", NULL, GTK_MENU_FUNC(help_cb), 0, NULL},
|
|
|
|
{"/Help/<separator>", NULL, NULL, 0, "<Separator>"},
|
|
|
|
{"/Help/_About Ethereal...", NULL, GTK_MENU_FUNC(about_ethereal), 0, NULL}
|
1998-12-17 05:42:33 +00:00
|
|
|
};
|
1998-09-16 02:39:15 +00:00
|
|
|
|
|
|
|
/* calculate the number of menu_items */
|
|
|
|
static int nmenu_items = sizeof(menu_items) / sizeof(menu_items[0]);
|
|
|
|
|
2000-01-18 08:38:18 +00:00
|
|
|
/* packet list popup */
|
|
|
|
static GtkItemFactoryEntry packet_list_menu_items[] =
|
|
|
|
{
|
|
|
|
{"/Follow TCP Stream", NULL, GTK_MENU_FUNC(follow_stream_cb), 0, NULL},
|
Have separate capture and display filter lists; some filter dialog boxes
use the capture filter lists, and others use the display filter list, as
appropriate.
Have separate menu items for editing the capture and display filter
lists.
Have separate "~/.ethereal/cfilters" and "~/.ethereal/dfilters" files
for the two lists; if either of those files isn't found, we try
"~/.ethereal/filters", which means that you will start out with two
identical lists holding all your filters - if certain filters belong
only in one list, you'll have to delete them by hand from the other
list.
Do I/O error checking when reading and writing filter lists; when
writing a filter list, write it to a new file, and then rename the new
file on top of the old file, so that you don't lose your old filter list
if, for example, you run out of disk space or disk quota.
svn path=/trunk/; revision=2948
2001-01-28 09:13:10 +00:00
|
|
|
{"/Display Filters...", NULL, GTK_MENU_FUNC(dfilter_dialog_cb), 0, NULL},
|
2000-01-18 08:38:18 +00:00
|
|
|
{"/<separator>", NULL, NULL, 0, "<Separator>"},
|
|
|
|
{"/Colorize Display...", NULL, GTK_MENU_FUNC(color_display_cb), 0, NULL},
|
|
|
|
{"/Print...", NULL, GTK_MENU_FUNC(file_print_cmd_cb), 0, NULL},
|
|
|
|
{"/Print Packet", NULL, GTK_MENU_FUNC(file_print_packet_cmd_cb), 0, NULL},
|
2000-02-29 06:24:41 +00:00
|
|
|
{"/Show Packet In New Window", NULL, GTK_MENU_FUNC(new_window_cb), 0, NULL},
|
2000-01-18 08:38:18 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static GtkItemFactoryEntry tree_view_menu_items[] =
|
|
|
|
{
|
|
|
|
{"/Follow TCP Stream", NULL, GTK_MENU_FUNC(follow_stream_cb), 0, NULL},
|
Have separate capture and display filter lists; some filter dialog boxes
use the capture filter lists, and others use the display filter list, as
appropriate.
Have separate menu items for editing the capture and display filter
lists.
Have separate "~/.ethereal/cfilters" and "~/.ethereal/dfilters" files
for the two lists; if either of those files isn't found, we try
"~/.ethereal/filters", which means that you will start out with two
identical lists holding all your filters - if certain filters belong
only in one list, you'll have to delete them by hand from the other
list.
Do I/O error checking when reading and writing filter lists; when
writing a filter list, write it to a new file, and then rename the new
file on top of the old file, so that you don't lose your old filter list
if, for example, you run out of disk space or disk quota.
svn path=/trunk/; revision=2948
2001-01-28 09:13:10 +00:00
|
|
|
{"/Display Filters...", NULL, GTK_MENU_FUNC(dfilter_dialog_cb), 0, NULL},
|
2000-01-18 08:38:18 +00:00
|
|
|
{"/<separator>", NULL, NULL, 0, "<Separator>"},
|
2000-08-16 19:15:11 +00:00
|
|
|
{"/Resolve Name", NULL, GTK_MENU_FUNC(resolve_name_cb), 0, NULL},
|
|
|
|
{"/Protocol Properties...", NULL, GTK_MENU_FUNC(properties_cb), 0, NULL},
|
|
|
|
{"/Match Selected", NULL, GTK_MENU_FUNC(match_selected_cb), 0, NULL},
|
|
|
|
{"/<separator>", NULL, NULL, 0, "<Separator>"},
|
2000-01-18 08:38:18 +00:00
|
|
|
{"/Collapse All", NULL, GTK_MENU_FUNC(collapse_all_cb), 0, NULL},
|
|
|
|
{"/Expand All", NULL, GTK_MENU_FUNC(expand_all_cb), 0, NULL}
|
|
|
|
};
|
|
|
|
|
2000-08-20 21:55:58 +00:00
|
|
|
static GtkItemFactoryEntry hexdump_menu_items[] =
|
|
|
|
{
|
|
|
|
{"/Follow TCP Stream", NULL, GTK_MENU_FUNC(follow_stream_cb), 0, NULL},
|
Have separate capture and display filter lists; some filter dialog boxes
use the capture filter lists, and others use the display filter list, as
appropriate.
Have separate menu items for editing the capture and display filter
lists.
Have separate "~/.ethereal/cfilters" and "~/.ethereal/dfilters" files
for the two lists; if either of those files isn't found, we try
"~/.ethereal/filters", which means that you will start out with two
identical lists holding all your filters - if certain filters belong
only in one list, you'll have to delete them by hand from the other
list.
Do I/O error checking when reading and writing filter lists; when
writing a filter list, write it to a new file, and then rename the new
file on top of the old file, so that you don't lose your old filter list
if, for example, you run out of disk space or disk quota.
svn path=/trunk/; revision=2948
2001-01-28 09:13:10 +00:00
|
|
|
{"/Display Filters...", NULL, GTK_MENU_FUNC(dfilter_dialog_cb), 0, NULL}
|
2000-08-20 21:55:58 +00:00
|
|
|
};
|
2000-01-18 08:38:18 +00:00
|
|
|
|
1998-09-16 02:39:15 +00:00
|
|
|
static int initialize = TRUE;
|
1998-12-17 05:42:33 +00:00
|
|
|
static GtkItemFactory *factory = NULL;
|
2000-01-18 08:38:18 +00:00
|
|
|
static GtkItemFactory *packet_list_menu_factory = NULL;
|
|
|
|
static GtkItemFactory *tree_view_menu_factory = NULL;
|
2000-08-20 21:55:58 +00:00
|
|
|
static GtkItemFactory *hexdump_menu_factory = NULL;
|
2000-01-18 08:38:18 +00:00
|
|
|
|
|
|
|
static GSList *popup_menu_list = NULL;
|
1998-09-16 02:39:15 +00:00
|
|
|
|
2000-01-03 04:06:09 +00:00
|
|
|
static GtkAccelGroup *grp;
|
|
|
|
|
1998-09-16 02:39:15 +00:00
|
|
|
void
|
1998-12-17 05:42:33 +00:00
|
|
|
get_main_menu(GtkWidget ** menubar, GtkAccelGroup ** table) {
|
|
|
|
|
|
|
|
grp = gtk_accel_group_new();
|
|
|
|
|
2000-01-18 08:38:18 +00:00
|
|
|
if (initialize) {
|
|
|
|
popup_menu_object = gtk_widget_new(GTK_TYPE_WIDGET, NULL);
|
1998-09-16 02:39:15 +00:00
|
|
|
menus_init();
|
2000-01-18 08:38:18 +00:00
|
|
|
}
|
1998-09-16 02:39:15 +00:00
|
|
|
|
1998-12-17 05:42:33 +00:00
|
|
|
if (menubar)
|
|
|
|
*menubar = factory->widget;
|
|
|
|
|
1998-09-16 02:39:15 +00:00
|
|
|
if (table)
|
1998-12-17 05:42:33 +00:00
|
|
|
*table = grp;
|
1998-09-16 02:39:15 +00:00
|
|
|
}
|
|
|
|
|
2000-01-03 04:06:09 +00:00
|
|
|
static void
|
1998-09-16 02:39:15 +00:00
|
|
|
menus_init(void) {
|
|
|
|
|
|
|
|
if (initialize) {
|
|
|
|
initialize = FALSE;
|
|
|
|
|
2000-01-18 08:38:18 +00:00
|
|
|
/* popup */
|
|
|
|
|
|
|
|
packet_list_menu_factory = gtk_item_factory_new(GTK_TYPE_MENU, "<main>", NULL);
|
|
|
|
gtk_item_factory_create_items_ac(packet_list_menu_factory, sizeof(packet_list_menu_items)/sizeof(packet_list_menu_items[0]), packet_list_menu_items, NULL, 2);
|
|
|
|
gtk_object_set_data(GTK_OBJECT(popup_menu_object), PM_PACKET_LIST_KEY, packet_list_menu_factory->widget);
|
|
|
|
popup_menu_list = g_slist_append((GSList *)popup_menu_list, packet_list_menu_factory);
|
|
|
|
|
|
|
|
tree_view_menu_factory = gtk_item_factory_new(GTK_TYPE_MENU, "<main>", NULL);
|
|
|
|
gtk_item_factory_create_items_ac(tree_view_menu_factory, sizeof(tree_view_menu_items)/sizeof(tree_view_menu_items[0]), tree_view_menu_items, NULL, 2);
|
|
|
|
gtk_object_set_data(GTK_OBJECT(popup_menu_object), PM_TREE_VIEW_KEY, tree_view_menu_factory->widget);
|
|
|
|
popup_menu_list = g_slist_append((GSList *)popup_menu_list, tree_view_menu_factory);
|
2000-08-20 21:55:58 +00:00
|
|
|
|
|
|
|
hexdump_menu_factory = gtk_item_factory_new(GTK_TYPE_MENU, "<main>", NULL);
|
|
|
|
gtk_item_factory_create_items_ac(hexdump_menu_factory, sizeof(hexdump_menu_items)/sizeof(hexdump_menu_items[0]), hexdump_menu_items, NULL, 2);
|
|
|
|
gtk_object_set_data(GTK_OBJECT(popup_menu_object), PM_HEXDUMP_KEY, hexdump_menu_factory->widget);
|
|
|
|
popup_menu_list = g_slist_append((GSList *)popup_menu_list, hexdump_menu_factory);
|
2000-01-18 08:38:18 +00:00
|
|
|
|
1998-12-17 05:42:33 +00:00
|
|
|
factory = gtk_item_factory_new(GTK_TYPE_MENU_BAR, "<main>", grp);
|
1999-03-01 18:57:07 +00:00
|
|
|
gtk_item_factory_create_items_ac(factory, nmenu_items, menu_items, NULL,2);
|
2000-01-03 03:57:04 +00:00
|
|
|
set_menus_for_unsaved_capture_file(FALSE);
|
|
|
|
set_menus_for_capture_file(FALSE);
|
2000-09-09 08:17:51 +00:00
|
|
|
#if 0
|
|
|
|
/* Un-#if this when we actually implement Cut/Copy/Paste.
|
|
|
|
Then make sure you enable them when they can be done. */
|
1998-12-17 05:42:33 +00:00
|
|
|
set_menu_sensitivity("/Edit/Cut", FALSE);
|
|
|
|
set_menu_sensitivity("/Edit/Copy", FALSE);
|
|
|
|
set_menu_sensitivity("/Edit/Paste", FALSE);
|
2000-09-09 08:17:51 +00:00
|
|
|
#endif
|
2000-01-03 03:57:04 +00:00
|
|
|
set_menus_for_captured_packets(FALSE);
|
|
|
|
set_menus_for_selected_packet(FALSE);
|
2000-08-15 21:03:55 +00:00
|
|
|
set_menus_for_selected_tree_row(FALSE);
|
1998-09-16 02:39:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-01-18 08:38:18 +00:00
|
|
|
void
|
|
|
|
set_menu_sensitivity_meat(GtkItemFactory *ifactory, gchar *path, gint val) {
|
|
|
|
GtkWidget *menu = NULL;
|
|
|
|
|
|
|
|
if((menu = gtk_item_factory_get_widget(ifactory, path)) != NULL) {
|
|
|
|
gtk_widget_set_sensitive(menu,val);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-01-03 04:06:09 +00:00
|
|
|
static void
|
1998-09-16 02:39:15 +00:00
|
|
|
set_menu_sensitivity (gchar *path, gint val) {
|
2000-01-18 08:38:18 +00:00
|
|
|
GSList *menu_list = popup_menu_list;
|
2000-01-18 19:01:35 +00:00
|
|
|
gchar *shortpath = strrchr(path, '/');
|
2000-01-18 08:38:18 +00:00
|
|
|
|
|
|
|
set_menu_sensitivity_meat(factory, path, val);
|
1998-12-17 05:42:33 +00:00
|
|
|
|
2000-01-18 08:38:18 +00:00
|
|
|
while (menu_list != NULL) {
|
|
|
|
set_menu_sensitivity_meat(menu_list->data, shortpath, val);
|
|
|
|
menu_list = g_slist_next(menu_list);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
set_menu_object_data_meat(GtkItemFactory *ifactory, gchar *path, gchar *key, gpointer data)
|
|
|
|
{
|
|
|
|
GtkWidget *menu = NULL;
|
|
|
|
|
|
|
|
if ((menu = gtk_item_factory_get_widget(ifactory, path)) != NULL)
|
|
|
|
gtk_object_set_data(GTK_OBJECT(menu), key, data);
|
1998-10-12 01:40:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
set_menu_object_data (gchar *path, gchar *key, gpointer data) {
|
2000-01-18 08:38:18 +00:00
|
|
|
GSList *menu_list = popup_menu_list;
|
2000-01-18 19:01:35 +00:00
|
|
|
gchar *shortpath = strrchr(path, '/');
|
1998-10-12 01:40:57 +00:00
|
|
|
|
2000-01-18 08:38:18 +00:00
|
|
|
set_menu_object_data_meat(factory, path, key, data);
|
|
|
|
while (menu_list != NULL) {
|
|
|
|
set_menu_object_data_meat(menu_list->data, shortpath, key, data);
|
|
|
|
menu_list = g_slist_next(menu_list);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-08-21 12:33:22 +00:00
|
|
|
gint
|
|
|
|
popup_menu_handler(GtkWidget *widget, GdkEvent *event, gpointer data)
|
2000-01-18 08:38:18 +00:00
|
|
|
{
|
|
|
|
GtkWidget *menu = NULL;
|
|
|
|
GdkEventButton *event_button = NULL;
|
|
|
|
|
2000-08-21 12:33:22 +00:00
|
|
|
if(widget == NULL || event == NULL || data == NULL) {
|
|
|
|
return FALSE;
|
2000-01-18 08:38:18 +00:00
|
|
|
}
|
|
|
|
|
2000-05-02 07:44:37 +00:00
|
|
|
/*
|
|
|
|
* If we ever want to make the menu differ based on what row
|
|
|
|
* and/or column we're above, we'd use "gtk_clist_get_selection_info()"
|
|
|
|
* to find the row and column number for the coordinates; a CTree is,
|
|
|
|
* I guess, like a CList with one column(?) and the expander widget
|
|
|
|
* as a pixmap.
|
|
|
|
*/
|
2000-08-21 12:33:22 +00:00
|
|
|
menu = (GtkWidget *)data;
|
2000-01-18 08:38:18 +00:00
|
|
|
if(event->type == GDK_BUTTON_PRESS) {
|
|
|
|
event_button = (GdkEventButton *) event;
|
|
|
|
|
|
|
|
if(event_button->button == 3) {
|
|
|
|
gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, event_button->button, event_button->time);
|
2000-08-21 12:33:22 +00:00
|
|
|
gtk_signal_emit_stop_by_name(GTK_OBJECT(widget), "button_press_event");
|
|
|
|
return TRUE;
|
2000-01-18 08:38:18 +00:00
|
|
|
}
|
|
|
|
}
|
2000-08-21 12:33:22 +00:00
|
|
|
return FALSE;
|
1998-09-16 02:39:15 +00:00
|
|
|
}
|
|
|
|
|
2000-01-03 03:57:04 +00:00
|
|
|
/* Enable or disable menu items based on whether you have a capture file
|
|
|
|
you've finished reading. */
|
|
|
|
void
|
|
|
|
set_menus_for_capture_file(gboolean have_capture_file)
|
|
|
|
{
|
2000-01-25 03:48:16 +00:00
|
|
|
set_menu_sensitivity("/File/Open...", have_capture_file);
|
2000-01-03 03:57:04 +00:00
|
|
|
set_menu_sensitivity("/File/Save As...", have_capture_file);
|
|
|
|
set_menu_sensitivity("/File/Close", have_capture_file);
|
|
|
|
set_menu_sensitivity("/File/Reload", have_capture_file);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Enable or disable menu items based on whether you have an unsaved
|
|
|
|
capture file you've finished reading. */
|
|
|
|
void
|
|
|
|
set_menus_for_unsaved_capture_file(gboolean have_unsaved_capture_file)
|
|
|
|
{
|
|
|
|
set_menu_sensitivity("/File/Save", have_unsaved_capture_file);
|
|
|
|
}
|
1998-09-16 02:39:15 +00:00
|
|
|
|
2000-01-03 03:57:04 +00:00
|
|
|
/* Enable or disable menu items based on whether there's a capture in
|
|
|
|
progress. */
|
|
|
|
void
|
|
|
|
set_menus_for_capture_in_progress(gboolean capture_in_progress)
|
|
|
|
{
|
|
|
|
set_menu_sensitivity("/File/Open...", !capture_in_progress);
|
|
|
|
set_menu_sensitivity("/Capture/Start...", !capture_in_progress);
|
2000-10-11 06:01:16 +00:00
|
|
|
/*
|
|
|
|
* XXX - this doesn't yet work in Win32.
|
|
|
|
*/
|
|
|
|
#ifndef _WIN32
|
|
|
|
set_menu_sensitivity("/Capture/Stop", capture_in_progress);
|
|
|
|
#endif
|
2000-01-03 03:57:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Enable or disable menu items based on whether you have some captured
|
|
|
|
packets. */
|
|
|
|
void
|
|
|
|
set_menus_for_captured_packets(gboolean have_captured_packets)
|
|
|
|
{
|
2000-01-08 23:34:50 +00:00
|
|
|
set_menu_sensitivity("/File/Print...", have_captured_packets);
|
2000-01-18 19:01:35 +00:00
|
|
|
set_menu_sensitivity("/Edit/Find Frame...", have_captured_packets);
|
|
|
|
set_menu_sensitivity("/Edit/Go To Frame...", have_captured_packets);
|
2000-01-03 03:57:04 +00:00
|
|
|
set_menu_sensitivity("/Display/Match Selected", have_captured_packets);
|
|
|
|
set_menu_sensitivity("/Display/Colorize Display...", have_captured_packets);
|
|
|
|
set_menu_sensitivity("/Tools/Summary", have_captured_packets);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Enable or disable menu items based on whether a packet is selected. */
|
|
|
|
void
|
|
|
|
set_menus_for_selected_packet(gboolean have_selected_packet)
|
|
|
|
{
|
|
|
|
set_menu_sensitivity("/File/Print Packet", have_selected_packet);
|
2000-08-21 19:36:19 +00:00
|
|
|
set_menu_sensitivity("/Edit/Mark Frame", have_selected_packet);
|
|
|
|
set_menu_sensitivity("/Edit/Mark All Frames", have_selected_packet);
|
|
|
|
set_menu_sensitivity("/Edit/Unmark All Frames", have_selected_packet);
|
2000-01-03 03:57:04 +00:00
|
|
|
set_menu_sensitivity("/Display/Collapse All", have_selected_packet);
|
|
|
|
set_menu_sensitivity("/Display/Expand All", have_selected_packet);
|
2000-02-29 06:24:41 +00:00
|
|
|
set_menu_sensitivity("/Display/Show Packet In New Window", have_selected_packet);
|
2000-01-03 03:57:04 +00:00
|
|
|
set_menu_sensitivity("/Tools/Follow TCP Stream",
|
|
|
|
have_selected_packet ? (pi.ipproto == 6) : FALSE);
|
2000-02-20 14:52:28 +00:00
|
|
|
set_menu_sensitivity("/Resolve Name",
|
2000-08-15 20:46:17 +00:00
|
|
|
have_selected_packet && !g_resolving_actif);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Enable or disable menu items based on whether a tree row is selected. */
|
|
|
|
void
|
|
|
|
set_menus_for_selected_tree_row(gboolean have_selected_tree)
|
|
|
|
{
|
|
|
|
gboolean properties = FALSE;
|
|
|
|
if (finfo_selected) {
|
|
|
|
header_field_info *hfinfo = finfo_selected->hfinfo;
|
|
|
|
if (hfinfo->parent == -1) {
|
|
|
|
properties = prefs_is_registered_protocol(hfinfo->abbrev);
|
|
|
|
} else {
|
|
|
|
properties = prefs_is_registered_protocol(proto_registrar_get_abbrev(hfinfo->parent));
|
|
|
|
}
|
|
|
|
}
|
2000-08-15 21:35:34 +00:00
|
|
|
set_menu_sensitivity("/Protocol Properties...", have_selected_tree && properties);
|
2000-01-03 03:57:04 +00:00
|
|
|
}
|