1998-09-16 02:39:15 +00:00
|
|
|
/* menu.c
|
|
|
|
* Menu routines
|
|
|
|
*
|
Check in Olivier Abad's patch to add dissectors for LAP-B and X.25, and
wiretap support for RADCOM Ltd.'s WAN/LAN analyzers (see
http://www.radcom-inc.com/
). Note: as I remember, IEEE 802.2/ISO 8022 LLC has somewhat of an SDLC
flavor to it, just as I think LAP, LAPB, LAPD, and so on do, so we may
be able to combine some of the LLC dissection and the LAPB dissection
into common code that could, conceivably be used for other SDLC-flavored
protocols.
Make "S" a mnemonic for "Summary" in the "Tools" menu.
Move the routine, used for the "Tools/Summary" display, that turns a
wiretap file type into a descriptive string for it into the wiretap
library itself, expand on some of its descriptions, and add an entry for
files from a RADCOM analyzer.
Have "Tools/Summary" display the snapshot length for the capture.
svn path=/trunk/; revision=416
1999-08-02 02:04:38 +00:00
|
|
|
* $Id: menu.c,v 1.32 1999/08/02 02:04:26 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>
|
|
|
|
|
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
|
|
|
|
|
|
|
#include "ethereal.h"
|
1998-12-17 05:42:33 +00:00
|
|
|
#include "menu.h"
|
1998-09-16 02:39:15 +00:00
|
|
|
#include "packet.h"
|
1999-02-09 00:35:38 +00:00
|
|
|
#include "capture.h"
|
1999-06-22 22:02:39 +00:00
|
|
|
#include "summary.h"
|
1999-06-19 01:14:51 +00:00
|
|
|
#include "display.h"
|
1998-10-28 21:38:11 +00:00
|
|
|
#include "prefs.h"
|
1998-09-16 02:39:15 +00:00
|
|
|
#include "print.h"
|
1998-09-17 03:12:28 +00:00
|
|
|
#include "follow.h"
|
1998-09-16 02:39:15 +00:00
|
|
|
|
|
|
|
|
1998-12-17 05:42:33 +00:00
|
|
|
GtkAccelGroup *grp;
|
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
|
|
|
|
*/
|
|
|
|
|
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>"},
|
1999-07-23 08:29:24 +00:00
|
|
|
{"/File/Print...", NULL, GTK_MENU_FUNC(file_print_cmd_cb), 0, NULL},
|
|
|
|
{"/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>" },
|
|
|
|
{"/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>"},
|
|
|
|
{"/Edit/Find", "<control>F", NULL, 0, NULL},
|
|
|
|
{"/Edit/<separator>", NULL, NULL, 0, "<Separator>"},
|
1999-06-15 04:48:57 +00:00
|
|
|
{"/Edit/_Preferences...", NULL, GTK_MENU_FUNC(prefs_cb), E_PR_PG_NONE, 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},
|
1999-07-09 04:18:36 +00:00
|
|
|
#endif
|
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},
|
1998-12-17 05:42:33 +00:00
|
|
|
{"/_Tools", NULL, NULL, 0, "<Branch>" },
|
|
|
|
{"/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 */
|
Check in Olivier Abad's patch to add dissectors for LAP-B and X.25, and
wiretap support for RADCOM Ltd.'s WAN/LAN analyzers (see
http://www.radcom-inc.com/
). Note: as I remember, IEEE 802.2/ISO 8022 LLC has somewhat of an SDLC
flavor to it, just as I think LAP, LAPB, LAPD, and so on do, so we may
be able to combine some of the LLC dissection and the LAPB dissection
into common code that could, conceivably be used for other SDLC-flavored
protocols.
Make "S" a mnemonic for "Summary" in the "Tools" menu.
Move the routine, used for the "Tools/Summary" display, that turns a
wiretap file type into a descriptive string for it into the wiretap
library itself, expand on some of its descriptions, and add an entry for
files from a RADCOM analyzer.
Have "Tools/Summary" display the snapshot length for the capture.
svn path=/trunk/; revision=416
1999-08-02 02:04:38 +00:00
|
|
|
{"/Tools/_Summary", NULL, GTK_MENU_FUNC(summary_prep_cb), 0, NULL},
|
1998-12-27 20:46:45 +00:00
|
|
|
{"/_Help", NULL, NULL, 0, "<LastBranch>" },
|
1999-06-15 04:48:57 +00:00
|
|
|
{"/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]);
|
|
|
|
|
|
|
|
static int initialize = TRUE;
|
1998-12-17 05:42:33 +00:00
|
|
|
static GtkItemFactory *factory = NULL;
|
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();
|
|
|
|
|
1998-09-16 02:39:15 +00:00
|
|
|
if (initialize)
|
|
|
|
menus_init();
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
menus_init(void) {
|
|
|
|
|
|
|
|
if (initialize) {
|
|
|
|
initialize = FALSE;
|
|
|
|
|
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);
|
1998-12-17 05:42:33 +00:00
|
|
|
set_menu_sensitivity("/File/Close", FALSE);
|
|
|
|
set_menu_sensitivity("/File/Save", FALSE);
|
1999-06-15 04:48:57 +00:00
|
|
|
set_menu_sensitivity("/File/Save As...", FALSE);
|
1999-07-27 02:04:38 +00:00
|
|
|
set_menu_sensitivity("/File/Reload", FALSE);
|
1999-07-23 08:29:24 +00:00
|
|
|
set_menu_sensitivity("/File/Print...", FALSE);
|
Have "close_cap_file()" disable all menu items that make sense only if
you have a capture.
Leave the job of enabling and disabling menu items that make sense only
if you have a capture (except for "File/Save" and "File/Save As...", for
now) up to "load_cap_file()", "close_cap_file()", and the like - don't
scatter that stuff throughout the code.
Disable "File/Print Packet" if no packet is selected; enable it only if
a packet is selected.
If there's a selected packet, and a display filter is run:
if the selected packet passed the filter, re-select it;
if the selected packet didn't pass the filter, un-select it.
If we've opened a live "pcap" capture, but can't do the capture because
we can't get the netmask info, or can't parse the capture filter string,
or can't install the filter, close the live capture and the dump and
delete the dump file.
If we failed to open a live "pcap" capture, don't try to read the
capture file - it doesn't exist.
svn path=/trunk/; revision=384
1999-07-24 02:42:52 +00:00
|
|
|
set_menu_sensitivity("/File/Print Packet", FALSE);
|
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);
|
|
|
|
set_menu_sensitivity("/Edit/Find", FALSE);
|
|
|
|
set_menu_sensitivity("/Tools/Graph", FALSE);
|
1999-06-22 22:02:39 +00:00
|
|
|
set_menu_sensitivity("/Tools/Summary", FALSE);
|
1999-07-07 22:52:57 +00:00
|
|
|
|
1999-07-17 04:19:15 +00:00
|
|
|
/*set_menu_sensitivity("/Tools/Follow TCP Stream", FALSE);*/
|
1999-06-24 16:25:59 +00:00
|
|
|
set_menu_sensitivity("/Display/Match Selected", FALSE);
|
1998-09-16 02:39:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
set_menu_sensitivity (gchar *path, gint val) {
|
1998-12-17 05:42:33 +00:00
|
|
|
GtkWidget *menu;
|
|
|
|
|
|
|
|
if ((menu = gtk_item_factory_get_widget(factory, path)) != NULL)
|
|
|
|
gtk_widget_set_sensitive(menu, val);
|
1998-10-12 01:40:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
set_menu_object_data (gchar *path, gchar *key, gpointer data) {
|
1998-12-17 05:42:33 +00:00
|
|
|
GtkWidget *menu;
|
1998-10-12 01:40:57 +00:00
|
|
|
|
1998-12-17 05:42:33 +00:00
|
|
|
if ((menu = gtk_item_factory_get_widget(factory, path)) != NULL)
|
|
|
|
gtk_object_set_data(GTK_OBJECT(menu), key, data);
|
1998-09-16 02:39:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|