1998-09-16 02:39:15 +00:00
|
|
|
/* menu.c
|
|
|
|
* Menu routines
|
|
|
|
*
|
2004-01-29 23:11:38 +00:00
|
|
|
* $Id: menu.c,v 1.152 2004/01/29 23:11:37 ulfl Exp $
|
1998-09-16 03:22:19 +00:00
|
|
|
*
|
1998-09-16 02:39:15 +00:00
|
|
|
* Ethereal - Network traffic analyzer
|
Enable "Match Selected" only if there's a field selected *and* we can do
a "Match Selected" on it - we can't do a "Match Selected" if the field
has no value (e.g., FT_NULL) and has a length of 0.
If we unselect the current packet, we don't have a protocol tree, so we
don't have a currently selected field - clear the "Match Selected" menu
item and the display in the status line of information about the
currently selected field.
Move the low-level statusbar manipulation into "gtk/main.c", in routines
whose API doesn't expose anything GTK+-ish.
"close_cap_file()" calls one of those routines to clear out the status
bar, so it doesn't need to take a pointer to the statusbar widget as an
argument.
"clear_tree_and_hex_views()" is purely a display-manipulating routine;
move it to "gtk/proto_draw.c".
Extract from "tree_view_unselect_row_cb()" an "unselect_field()" routine
to do all the work that needs to be done if the currently selected
protocol tree row is unselected, and call it if the currently selected
packet list row is unselected (if it's unselected, there *is* no
protocol tree, so no row can be selected), as well as from
"tree_view_unselect_row_cb()".
Before pushing a new field-description message onto the statusbar, pop
the old one off.
Get rid of an unused variable (set, but not used).
svn path=/trunk/; revision=3513
2001-06-05 07:39:31 +00:00
|
|
|
* By Gerald Combs <gerald@ethereal.com>
|
1998-09-16 02:39:15 +00:00
|
|
|
* Copyright 1998 Gerald Combs
|
2002-08-28 21:04:11 +00:00
|
|
|
*
|
1998-09-16 02:39:15 +00:00
|
|
|
* 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.
|
2002-08-28 21:04:11 +00:00
|
|
|
*
|
1998-09-16 02:39:15 +00:00
|
|
|
* 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.
|
2002-08-28 21:04:11 +00:00
|
|
|
*
|
1998-09-16 02:39:15 +00:00
|
|
|
* 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>
|
2003-12-13 18:01:30 +00:00
|
|
|
#include <stdio.h>
|
1999-07-09 04:18:36 +00:00
|
|
|
|
1999-09-09 02:42:40 +00:00
|
|
|
#include "main.h"
|
1998-12-17 05:42:33 +00:00
|
|
|
#include "menu.h"
|
2002-01-21 07:37:49 +00:00
|
|
|
#include <epan/packet.h>
|
|
|
|
#include <epan/resolv.h>
|
2002-01-11 07:40:32 +00:00
|
|
|
#include "prefs.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:46:54 +00:00
|
|
|
#include "filter_prefs.h"
|
2003-11-30 04:21:55 +00:00
|
|
|
#include "file_dlg.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-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"
|
2001-02-01 07:34:33 +00:00
|
|
|
#include "decode_as_dlg.h"
|
2000-08-08 12:28:50 +00:00
|
|
|
#include "help_dlg.h"
|
2003-11-19 00:04:15 +00:00
|
|
|
#include "supported_protos_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"
|
2001-03-22 23:54:47 +00:00
|
|
|
#include "proto_hier_stats_dlg.h"
|
2000-01-18 08:38:18 +00:00
|
|
|
#include "keys.h"
|
2002-01-21 07:37:49 +00:00
|
|
|
#include <epan/plugins.h>
|
2001-12-08 09:27:51 +00:00
|
|
|
#include "tcp_graph.h"
|
2002-01-21 07:37:49 +00:00
|
|
|
#include <epan/epan_dissect.h>
|
2002-11-11 15:39:06 +00:00
|
|
|
#include "compat_macros.h"
|
2003-10-15 19:40:42 +00:00
|
|
|
#include "toolbar.h"
|
2002-11-11 18:46:16 +00:00
|
|
|
#include "gtkglobals.h"
|
2003-10-20 22:28:22 +00:00
|
|
|
#include "register.h"
|
2003-04-16 07:25:12 +00:00
|
|
|
#include "../tap.h"
|
2003-09-24 02:36:35 +00:00
|
|
|
#include "../menu.h"
|
|
|
|
#include "../ipproto.h"
|
2004-01-09 08:36:23 +00:00
|
|
|
#include "packet_list.h"
|
|
|
|
#include "ethclist.h"
|
2004-01-19 00:42:12 +00:00
|
|
|
#include "recent.h"
|
2004-01-27 19:46:52 +00:00
|
|
|
#include "../ui_util.h"
|
|
|
|
#include "proto_draw.h"
|
2004-01-29 23:11:38 +00:00
|
|
|
#include "simple_dialog.h"
|
1998-09-16 02:39:15 +00:00
|
|
|
|
2000-04-06 06:52:10 +00:00
|
|
|
GtkWidget *popup_menu_object;
|
|
|
|
|
2003-11-30 04:37:50 +00:00
|
|
|
extern void savehex_cb(GtkWidget * w, gpointer data _U_);
|
|
|
|
|
2004-01-02 17:27:00 +00:00
|
|
|
static void
|
|
|
|
clear_menu_recent_capture_file_cmd_cb(GtkWidget *w, gpointer unused _U_);
|
|
|
|
|
2000-01-03 04:06:09 +00:00
|
|
|
#define GTK_MENU_FUNC(a) ((GtkItemFactoryCallback)(a))
|
|
|
|
|
|
|
|
static void menus_init(void);
|
2003-04-22 00:16:58 +00:00
|
|
|
static void set_menu_sensitivity (GtkItemFactory *, gchar *, gint);
|
2004-01-19 00:42:12 +00:00
|
|
|
static void main_toolbar_show_cb(GtkWidget *w _U_, gpointer d _U_);
|
|
|
|
static void filter_toolbar_show_cb(GtkWidget *w _U_, gpointer d _U_);
|
|
|
|
static void packet_list_show_cb(GtkWidget *w _U_, gpointer d _U_);
|
|
|
|
static void tree_view_show_cb(GtkWidget *w _U_, gpointer d _U_);
|
|
|
|
static void byte_view_show_cb(GtkWidget *w _U_, gpointer d _U_);
|
|
|
|
static void statusbar_show_cb(GtkWidget *w _U_, gpointer d _U_);
|
2004-01-19 03:46:43 +00:00
|
|
|
static void timestamp_absolute_cb(GtkWidget *w _U_, gpointer d _U_);
|
|
|
|
static void timestamp_absolute_date_cb(GtkWidget *w _U_, gpointer d _U_);
|
|
|
|
static void timestamp_relative_cb(GtkWidget *w _U_, gpointer d _U_);
|
|
|
|
static void timestamp_delta_cb(GtkWidget *w _U_, gpointer d _U_);
|
2004-01-21 06:41:03 +00:00
|
|
|
static void name_resolution_mac_cb(GtkWidget *w _U_, gpointer d _U_);
|
|
|
|
static void name_resolution_network_cb(GtkWidget *w _U_, gpointer d _U_);
|
|
|
|
static void name_resolution_transport_cb(GtkWidget *w _U_, gpointer d _U_);
|
|
|
|
static void auto_scroll_live_cb(GtkWidget *w _U_, gpointer d _U_);
|
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
|
2002-11-15 23:50:06 +00:00
|
|
|
"<ImageItem>" -> create an item holding an image (gtk2)
|
|
|
|
"<StockItem>" -> create an item holding a stock image (gtk2)
|
1999-06-12 06:22:47 +00:00
|
|
|
"<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
|
2002-11-15 23:50:06 +00:00
|
|
|
"<Tearoff>" -> create a tearoff separator (gtk2)
|
1999-06-12 06:22:47 +00:00
|
|
|
"<Branch>" -> create an item to hold sub items (optional)
|
2002-08-28 21:04:11 +00:00
|
|
|
"<LastBranch>" -> create a right justified branch
|
2002-11-15 23:50:06 +00:00
|
|
|
Item 6: extra data needed for ImageItem and StockItem (gtk2)
|
1999-06-12 06:22:47 +00:00
|
|
|
*/
|
|
|
|
|
2000-01-18 08:38:18 +00:00
|
|
|
/* main menu */
|
1998-12-17 05:42:33 +00:00
|
|
|
static GtkItemFactoryEntry menu_items[] =
|
|
|
|
{
|
2002-11-15 23:50:06 +00:00
|
|
|
ITEM_FACTORY_ENTRY("/_File", NULL, NULL, 0, "<Branch>", NULL),
|
|
|
|
ITEM_FACTORY_STOCK_ENTRY("/File/_Open...", "<control>O", file_open_cmd_cb,
|
|
|
|
0, GTK_STOCK_OPEN),
|
2003-12-13 18:01:30 +00:00
|
|
|
ITEM_FACTORY_ENTRY("/File/Open _Recent", NULL, NULL, 0, "<Branch>", NULL),
|
2002-11-15 23:50:06 +00:00
|
|
|
ITEM_FACTORY_STOCK_ENTRY("/File/_Close", "<control>W", file_close_cmd_cb,
|
|
|
|
0, GTK_STOCK_CLOSE),
|
2003-11-27 20:34:01 +00:00
|
|
|
ITEM_FACTORY_ENTRY("/File/<separator>", NULL, NULL, 0, "<Separator>", NULL),
|
2002-11-15 23:50:06 +00:00
|
|
|
ITEM_FACTORY_STOCK_ENTRY("/File/_Save", "<control>S", file_save_cmd_cb,
|
|
|
|
0, GTK_STOCK_SAVE),
|
2003-11-06 23:02:06 +00:00
|
|
|
ITEM_FACTORY_STOCK_ENTRY("/File/Save _As...", "<shift><control>S", file_save_as_cmd_cb,
|
2002-11-15 23:50:06 +00:00
|
|
|
0, GTK_STOCK_SAVE_AS),
|
2003-12-08 19:25:01 +00:00
|
|
|
ITEM_FACTORY_ENTRY("/File/<separator>", NULL, NULL, 0, "<Separator>", NULL),
|
|
|
|
ITEM_FACTORY_ENTRY("/File/_Export", NULL, NULL, 0, "<Branch>", NULL),
|
2004-01-27 20:58:19 +00:00
|
|
|
ITEM_FACTORY_ENTRY("/File/_Export/_Selected Packet Bytes...", "<control>H", savehex_cb,
|
2003-12-03 19:59:28 +00:00
|
|
|
0, NULL, NULL),
|
2002-11-15 23:50:06 +00:00
|
|
|
ITEM_FACTORY_ENTRY("/File/<separator>", NULL, NULL, 0, "<Separator>", NULL),
|
2003-11-27 20:34:01 +00:00
|
|
|
ITEM_FACTORY_STOCK_ENTRY("/File/_Print...", "<control>P", file_print_cmd_cb,
|
2002-11-15 23:50:06 +00:00
|
|
|
0, GTK_STOCK_PRINT),
|
|
|
|
ITEM_FACTORY_ENTRY("/File/<separator>", NULL, NULL, 0, "<Separator>", NULL),
|
|
|
|
ITEM_FACTORY_STOCK_ENTRY("/File/_Quit", "<control>Q", file_quit_cmd_cb,
|
|
|
|
0, GTK_STOCK_QUIT),
|
|
|
|
ITEM_FACTORY_ENTRY("/_Edit", NULL, NULL, 0, "<Branch>", NULL),
|
2000-09-09 08:17:51 +00:00
|
|
|
#if 0
|
2002-11-15 23:50:06 +00:00
|
|
|
/* Un-#if this when we actually implement Cut/Copy/Paste. */
|
|
|
|
ITEM_FACTORY_STOCK_ENTRY("/Edit/Cut", "<control>X", NULL,
|
|
|
|
0, GTK_STOCK_CUT),
|
|
|
|
ITEM_FACTORY_STOCK_ENTRY("/Edit/Copy", "<control>C", NULL,
|
|
|
|
0, GTK_STOCK_COPY),
|
|
|
|
ITEM_FACTORY_STOCK_ENTRY("/Edit/Paste", "<control>V", NULL,
|
|
|
|
0, GTK_STOCK_PASTE),
|
|
|
|
ITEM_FACTORY_ENTRY("/Edit/<separator>", NULL, NULL, 0, "<Separator>"),
|
2000-09-09 08:17:51 +00:00
|
|
|
#endif
|
2003-11-28 19:13:25 +00:00
|
|
|
ITEM_FACTORY_STOCK_ENTRY("/Edit/_Find Packet...", "<control>F",
|
2002-11-15 23:50:06 +00:00
|
|
|
find_frame_cb, 0, GTK_STOCK_FIND),
|
2003-11-27 20:34:01 +00:00
|
|
|
ITEM_FACTORY_STOCK_ENTRY("/Edit/Find Ne_xt", "<control>N", find_next_cb,
|
2002-11-15 23:50:06 +00:00
|
|
|
0, GTK_STOCK_GO_FORWARD),
|
2003-11-27 20:34:01 +00:00
|
|
|
ITEM_FACTORY_STOCK_ENTRY("/Edit/Find Pre_vious", "<control>B",
|
2002-11-15 23:50:06 +00:00
|
|
|
find_previous_cb, 0, GTK_STOCK_GO_BACK),
|
2003-11-27 20:34:01 +00:00
|
|
|
ITEM_FACTORY_ENTRY("/Edit/<separator>", NULL, NULL, 0, "<Separator>", NULL),
|
2004-01-20 21:20:29 +00:00
|
|
|
ITEM_FACTORY_STOCK_ENTRY("/Edit/Go To Firs_t Packet", NULL,
|
2004-01-20 18:47:25 +00:00
|
|
|
goto_top_frame_cb, 0, GTK_STOCK_GOTO_TOP),
|
2004-01-20 21:20:29 +00:00
|
|
|
ITEM_FACTORY_STOCK_ENTRY("/Edit/Go To _Last Packet", NULL,
|
2004-01-20 18:47:25 +00:00
|
|
|
goto_bottom_frame_cb, 0, GTK_STOCK_GOTO_BOTTOM),
|
2003-11-28 19:13:25 +00:00
|
|
|
ITEM_FACTORY_STOCK_ENTRY("/Edit/_Go To Packet...", "<control>G",
|
2002-11-15 23:50:06 +00:00
|
|
|
goto_frame_cb, 0, GTK_STOCK_JUMP_TO),
|
2003-11-28 19:13:25 +00:00
|
|
|
ITEM_FACTORY_ENTRY("/Edit/Go To _Corresponding Packet", NULL, goto_framenum_cb,
|
2003-11-27 20:34:01 +00:00
|
|
|
0, NULL, NULL),
|
2002-11-15 23:50:06 +00:00
|
|
|
ITEM_FACTORY_ENTRY("/Edit/<separator>", NULL, NULL, 0, "<Separator>", NULL),
|
2003-11-27 20:34:01 +00:00
|
|
|
ITEM_FACTORY_ENTRY("/Edit/Time _Reference", NULL, NULL, 0, "<Branch>", NULL),
|
2003-10-10 08:39:24 +00:00
|
|
|
ITEM_FACTORY_ENTRY("/Edit/Time Reference/Set Time Reference (toggle)", "<control>T", reftime_frame_cb, 0, NULL, NULL),
|
|
|
|
ITEM_FACTORY_ENTRY("/Edit/Time Reference/Find Next", NULL, reftime_frame_cb, 1, NULL, NULL),
|
|
|
|
ITEM_FACTORY_ENTRY("/Edit/Time Reference/Find Previous", NULL, reftime_frame_cb, 2, NULL, NULL),
|
2003-11-28 19:13:25 +00:00
|
|
|
ITEM_FACTORY_ENTRY("/Edit/_Mark Packet", "<control>M", mark_frame_cb,
|
2002-11-15 23:50:06 +00:00
|
|
|
0, NULL, NULL),
|
2003-11-28 19:13:25 +00:00
|
|
|
ITEM_FACTORY_ENTRY("/Edit/Mark _All Packets", NULL, mark_all_frames_cb,
|
2002-11-15 23:50:06 +00:00
|
|
|
0, NULL, NULL),
|
2003-11-28 19:13:25 +00:00
|
|
|
ITEM_FACTORY_ENTRY("/Edit/_Unmark All Packets", NULL, unmark_all_frames_cb,
|
2002-11-15 23:50:06 +00:00
|
|
|
0, NULL, NULL),
|
|
|
|
ITEM_FACTORY_ENTRY("/Edit/<separator>", NULL, NULL, 0, "<Separator>", NULL),
|
2003-11-15 23:48:52 +00:00
|
|
|
ITEM_FACTORY_STOCK_ENTRY("/Edit/_Preferences...", "<shift><control>P", prefs_cb,
|
2002-11-15 23:50:06 +00:00
|
|
|
0, GTK_STOCK_PREFERENCES),
|
2003-11-27 20:34:01 +00:00
|
|
|
ITEM_FACTORY_ENTRY("/_View", NULL, NULL, 0, "<Branch>", NULL),
|
2003-11-28 19:13:25 +00:00
|
|
|
ITEM_FACTORY_ENTRY("/View/_Show", NULL, NULL, 0, "<Branch>", NULL),
|
2004-01-19 00:42:12 +00:00
|
|
|
ITEM_FACTORY_ENTRY("/View/Show/Main Toolbar", NULL, main_toolbar_show_cb, 0, "<CheckItem>", NULL),
|
|
|
|
ITEM_FACTORY_ENTRY("/View/Show/Filter Toolbar", NULL, filter_toolbar_show_cb, 0, "<CheckItem>", NULL),
|
|
|
|
ITEM_FACTORY_ENTRY("/View/Show/<separator>", NULL, NULL, 0, "<Separator>", NULL),
|
|
|
|
ITEM_FACTORY_ENTRY("/View/Show/Packet List", NULL, packet_list_show_cb, 0, "<CheckItem>", NULL),
|
2004-01-26 18:35:56 +00:00
|
|
|
ITEM_FACTORY_ENTRY("/View/Show/Packet Details", NULL, tree_view_show_cb, 0, "<CheckItem>", NULL),
|
|
|
|
ITEM_FACTORY_ENTRY("/View/Show/Packet Bytes", NULL, byte_view_show_cb, 0, "<CheckItem>", NULL),
|
2004-01-19 00:42:12 +00:00
|
|
|
ITEM_FACTORY_ENTRY("/View/Show/<separator>", NULL, NULL, 0, "<Separator>", NULL),
|
|
|
|
ITEM_FACTORY_ENTRY("/View/Show/Status Bar", NULL, statusbar_show_cb, 0, "<CheckItem>", NULL),
|
2003-11-28 19:13:25 +00:00
|
|
|
ITEM_FACTORY_ENTRY("/View/_Time Display Format", NULL, NULL, 0, "<Branch>", NULL),
|
2004-01-23 16:10:09 +00:00
|
|
|
ITEM_FACTORY_ENTRY("/View/Time Display Format/Time of Day", NULL, timestamp_absolute_cb,
|
2004-01-19 03:46:43 +00:00
|
|
|
0, "<RadioItem>", NULL),
|
2004-01-23 16:10:09 +00:00
|
|
|
ITEM_FACTORY_ENTRY("/View/Time Display Format/Date and Time of Day", NULL, timestamp_absolute_date_cb,
|
|
|
|
0, "/View/Time Display Format/Time of Day", NULL),
|
|
|
|
ITEM_FACTORY_ENTRY("/View/Time Display Format/Seconds Since Beginning of Capture", NULL, timestamp_relative_cb,
|
|
|
|
0, "/View/Time Display Format/Time of Day", NULL),
|
|
|
|
ITEM_FACTORY_ENTRY("/View/Time Display Format/Seconds Since Previous Packet", NULL, timestamp_delta_cb,
|
|
|
|
0, "/View/Time Display Format/Time of Day", NULL),
|
2003-11-28 19:13:25 +00:00
|
|
|
ITEM_FACTORY_ENTRY("/View/_Name Resolution", NULL, NULL, 0, "<Branch>", NULL),
|
2004-01-23 16:10:09 +00:00
|
|
|
ITEM_FACTORY_ENTRY("/View/Name Resolution/Enable for _MAC Layer", NULL, name_resolution_mac_cb, 0, "<CheckItem>", NULL),
|
|
|
|
ITEM_FACTORY_ENTRY("/View/Name Resolution/Enable for _Network Layer", NULL, name_resolution_mac_cb, 0, "<CheckItem>", NULL),
|
|
|
|
ITEM_FACTORY_ENTRY("/View/Name Resolution/Enable for _Transport Layer", NULL, name_resolution_transport_cb, 0, "<CheckItem>", NULL),
|
|
|
|
ITEM_FACTORY_ENTRY("/View/Auto Scroll in Live Capture", NULL, auto_scroll_live_cb, 0, "<CheckItem>", NULL),
|
2003-11-27 20:34:01 +00:00
|
|
|
ITEM_FACTORY_ENTRY("/View/<separator>", NULL, NULL, 0, "<Separator>", NULL),
|
2004-01-20 18:47:25 +00:00
|
|
|
ITEM_FACTORY_STOCK_ENTRY("/View/Zoom In", "<control>plus", view_zoom_in_cb,
|
|
|
|
0, GTK_STOCK_ZOOM_IN),
|
|
|
|
ITEM_FACTORY_STOCK_ENTRY("/View/Zoom Out", "<control>minus", view_zoom_out_cb,
|
|
|
|
0, GTK_STOCK_ZOOM_OUT),
|
|
|
|
ITEM_FACTORY_STOCK_ENTRY("/View/Normal Size", "<control>equal", view_zoom_100_cb,
|
|
|
|
0, GTK_STOCK_ZOOM_100),
|
|
|
|
ITEM_FACTORY_ENTRY("/View/<separator>", NULL, NULL, 0, "<Separator>", NULL),
|
2003-11-27 20:34:01 +00:00
|
|
|
ITEM_FACTORY_ENTRY("/View/Collapse _All", NULL, collapse_all_cb,
|
|
|
|
0, NULL, NULL),
|
|
|
|
ITEM_FACTORY_ENTRY("/View/_Expand All", NULL, expand_all_cb,
|
|
|
|
0, NULL, NULL),
|
|
|
|
ITEM_FACTORY_ENTRY("/View/<separator>", NULL, NULL, 0, "<Separator>", NULL),
|
|
|
|
ITEM_FACTORY_STOCK_ENTRY("/View/_Coloring Rules...", NULL, color_display_cb,
|
|
|
|
0, GTK_STOCK_SELECT_COLOR),
|
|
|
|
ITEM_FACTORY_ENTRY("/View/<separator>", NULL, NULL, 0, "<Separator>", NULL),
|
|
|
|
ITEM_FACTORY_ENTRY("/View/_Show Packet In New Window", NULL,
|
|
|
|
new_window_cb, 0, NULL, NULL),
|
|
|
|
ITEM_FACTORY_STOCK_ENTRY("/View/_Reload", "<control>R", file_reload_cmd_cb,
|
|
|
|
0, GTK_STOCK_REFRESH),
|
1999-07-09 04:18:36 +00:00
|
|
|
#ifdef HAVE_LIBPCAP
|
2002-11-15 23:50:06 +00:00
|
|
|
ITEM_FACTORY_ENTRY("/_Capture", NULL, NULL, 0, "<Branch>", NULL),
|
|
|
|
ITEM_FACTORY_STOCK_ENTRY("/Capture/_Start...", "<control>K",
|
2003-11-15 11:46:09 +00:00
|
|
|
capture_prep_cb, 0, ETHEREAL_STOCK_CAPTURE_START),
|
2002-11-15 23:50:06 +00:00
|
|
|
ITEM_FACTORY_STOCK_ENTRY("/Capture/S_top", "<control>E", capture_stop_cb,
|
|
|
|
0, GTK_STOCK_STOP),
|
2003-11-27 20:34:01 +00:00
|
|
|
ITEM_FACTORY_STOCK_ENTRY("/Capture/_Capture Filters...", NULL, cfilter_dialog_cb,
|
|
|
|
0, ETHEREAL_STOCK_CAPTURE_FILTER),
|
2000-10-11 06:01:16 +00:00
|
|
|
#endif /* HAVE_LIBPCAP */
|
2003-11-27 20:34:01 +00:00
|
|
|
ITEM_FACTORY_ENTRY("/_Analyze", NULL, NULL, 0, "<Branch>", NULL),
|
|
|
|
ITEM_FACTORY_STOCK_ENTRY("/Analyze/_Display Filters...", NULL, dfilter_dialog_cb,
|
|
|
|
0, ETHEREAL_STOCK_DISPLAY_FILTER),
|
|
|
|
ITEM_FACTORY_ENTRY("/Analyze/_Match", NULL, NULL, 0, "<Branch>", NULL),
|
|
|
|
ITEM_FACTORY_ENTRY("/Analyze/Match/_Selected", NULL,
|
2002-11-15 23:50:06 +00:00
|
|
|
match_selected_cb_replace_ptree, 0, NULL, NULL),
|
2003-11-27 20:34:01 +00:00
|
|
|
ITEM_FACTORY_ENTRY("/Analyze/Match/_Not Selected", NULL,
|
2002-11-15 23:50:06 +00:00
|
|
|
match_selected_cb_not_ptree, 0, NULL, NULL),
|
2003-11-27 20:34:01 +00:00
|
|
|
ITEM_FACTORY_ENTRY("/Analyze/Match/_And Selected", NULL,
|
2002-11-15 23:50:06 +00:00
|
|
|
match_selected_cb_and_ptree, 0, NULL, NULL),
|
2003-11-27 20:34:01 +00:00
|
|
|
ITEM_FACTORY_ENTRY("/Analyze/Match/_Or Selected", NULL,
|
2002-11-15 23:50:06 +00:00
|
|
|
match_selected_cb_or_ptree, 0, NULL, NULL),
|
2003-11-27 20:34:01 +00:00
|
|
|
ITEM_FACTORY_ENTRY("/Analyze/Match/A_nd Not Selected", NULL,
|
2002-11-15 23:50:06 +00:00
|
|
|
match_selected_cb_and_ptree_not, 0, NULL, NULL),
|
2003-11-27 20:34:01 +00:00
|
|
|
ITEM_FACTORY_ENTRY("/Analyze/Match/O_r Not Selected", NULL,
|
2002-11-15 23:50:06 +00:00
|
|
|
match_selected_cb_or_ptree_not, 0, NULL, NULL),
|
2003-11-27 20:34:01 +00:00
|
|
|
ITEM_FACTORY_ENTRY("/Analyze/_Prepare", NULL, NULL, 0, "<Branch>", NULL),
|
|
|
|
ITEM_FACTORY_ENTRY("/Analyze/Prepare/_Selected", NULL,
|
2002-11-15 23:50:06 +00:00
|
|
|
prepare_selected_cb_replace_ptree, 0, NULL, NULL),
|
2003-11-27 20:34:01 +00:00
|
|
|
ITEM_FACTORY_ENTRY("/Analyze/Prepare/_Not Selected", NULL,
|
2002-11-15 23:50:06 +00:00
|
|
|
prepare_selected_cb_not_ptree, 0, NULL, NULL),
|
2003-11-27 20:34:01 +00:00
|
|
|
ITEM_FACTORY_ENTRY("/Analyze/Prepare/_And Selected", NULL,
|
2002-11-15 23:50:06 +00:00
|
|
|
prepare_selected_cb_and_ptree, 0, NULL, NULL),
|
2003-11-27 20:34:01 +00:00
|
|
|
ITEM_FACTORY_ENTRY("/Analyze/Prepare/_Or Selected", NULL,
|
2002-11-15 23:50:06 +00:00
|
|
|
prepare_selected_cb_or_ptree, 0, NULL, NULL),
|
2003-11-27 20:34:01 +00:00
|
|
|
ITEM_FACTORY_ENTRY("/Analyze/Prepare/A_nd Not Selected", NULL,
|
2002-11-15 23:50:06 +00:00
|
|
|
prepare_selected_cb_and_ptree_not, 0, NULL, NULL),
|
2003-11-27 20:34:01 +00:00
|
|
|
ITEM_FACTORY_ENTRY("/Analyze/Prepare/O_r Not Selected", NULL,
|
2002-11-15 23:50:06 +00:00
|
|
|
prepare_selected_cb_or_ptree_not, 0, NULL, NULL),
|
2003-11-27 20:34:01 +00:00
|
|
|
ITEM_FACTORY_ENTRY("/Analyze/<separator>", NULL, NULL, 0, "<Separator>", NULL),
|
2003-11-28 19:13:25 +00:00
|
|
|
ITEM_FACTORY_ENTRY("/Analyze/_Enabled Protocols...", "<shift><control>R", proto_cb, 0, NULL, NULL),
|
|
|
|
ITEM_FACTORY_ENTRY("/Analyze/Decode _As...", NULL, decode_as_cb,
|
|
|
|
0, NULL, NULL),
|
2004-01-04 06:16:57 +00:00
|
|
|
ITEM_FACTORY_ENTRY("/Analyze/_User Specified Decodes...", NULL,
|
2003-11-28 19:13:25 +00:00
|
|
|
decode_show_cb, 0, NULL, NULL),
|
|
|
|
ITEM_FACTORY_ENTRY("/Analyze/<separator>", NULL, NULL, 0, "<Separator>", NULL),
|
2003-11-27 20:34:01 +00:00
|
|
|
ITEM_FACTORY_ENTRY("/Analyze/_Follow TCP Stream", NULL, follow_stream_cb,
|
2002-11-15 23:50:06 +00:00
|
|
|
0, NULL, NULL),
|
2003-11-27 20:34:01 +00:00
|
|
|
/* {"/Analyze/Graph", NULL, NULL, 0, NULL}, future use */
|
|
|
|
ITEM_FACTORY_ENTRY("/Analyze/_TCP Stream Analysis", NULL, NULL,
|
2002-11-15 23:50:06 +00:00
|
|
|
0, "<Branch>", NULL),
|
2003-11-27 20:34:01 +00:00
|
|
|
ITEM_FACTORY_ENTRY("/Analyze/TCP Stream Analysis/Time-Sequence Graph (Stevens)",
|
2002-11-15 23:50:06 +00:00
|
|
|
NULL, tcp_graph_cb, 0, NULL, NULL),
|
2003-11-27 20:34:01 +00:00
|
|
|
ITEM_FACTORY_ENTRY("/Analyze/TCP Stream Analysis/Time-Sequence Graph (tcptrace)",
|
2002-11-15 23:50:06 +00:00
|
|
|
NULL, tcp_graph_cb, 1, NULL, NULL),
|
2003-11-27 20:34:01 +00:00
|
|
|
ITEM_FACTORY_ENTRY("/Analyze/TCP Stream Analysis/Throughput Graph", NULL,
|
2002-11-15 23:50:06 +00:00
|
|
|
tcp_graph_cb, 2, NULL, NULL),
|
2003-11-27 20:34:01 +00:00
|
|
|
ITEM_FACTORY_ENTRY("/Analyze/TCP Stream Analysis/RTT Graph", NULL,
|
2002-11-15 23:50:06 +00:00
|
|
|
tcp_graph_cb, 3, NULL, NULL),
|
2003-11-28 19:13:25 +00:00
|
|
|
ITEM_FACTORY_ENTRY("/Analyze/<separator>", NULL, NULL, 0, "<Separator>", NULL),
|
2004-01-03 18:05:57 +00:00
|
|
|
ITEM_FACTORY_ENTRY("/Analyze/Summar_y", NULL, summary_open_cb, 0, NULL, NULL),
|
2003-11-27 20:34:01 +00:00
|
|
|
ITEM_FACTORY_ENTRY("/Analyze/Protocol _Hierarchy Statistics", NULL,
|
2002-11-15 23:50:06 +00:00
|
|
|
proto_hier_stats_cb, 0, NULL, NULL),
|
2003-08-25 21:42:33 +00:00
|
|
|
ITEM_FACTORY_ENTRY("/_Help", NULL, NULL, 0, "<Branch>", NULL),
|
2003-11-27 20:34:01 +00:00
|
|
|
ITEM_FACTORY_STOCK_ENTRY("/Help/_Contents", "F1", help_cb, 0, GTK_STOCK_HELP),
|
2003-11-19 00:04:15 +00:00
|
|
|
ITEM_FACTORY_ENTRY("/Help/_Supported Protocols", NULL, supported_cb, 0, NULL, NULL),
|
2002-11-15 23:50:06 +00:00
|
|
|
ITEM_FACTORY_ENTRY("/Help/<separator>", NULL, NULL, 0, "<Separator>", NULL),
|
2003-11-27 20:34:01 +00:00
|
|
|
#ifdef HAVE_PLUGINS
|
|
|
|
ITEM_FACTORY_ENTRY("/Help/About _Plugins", NULL, tools_plugins_cmd_cb,
|
|
|
|
0, NULL, NULL),
|
|
|
|
#endif /* HAVE_PLUGINS */
|
|
|
|
ITEM_FACTORY_ENTRY("/Help/_About Ethereal", NULL, about_ethereal,
|
2002-11-15 23:50:06 +00:00
|
|
|
0, NULL, NULL)
|
1998-12-17 05:42:33 +00:00
|
|
|
};
|
2002-11-15 23:50:06 +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 */
|
2002-11-03 17:38:45 +00:00
|
|
|
static GtkItemFactoryEntry packet_list_menu_items[] =
|
|
|
|
{
|
2002-11-15 23:50:06 +00:00
|
|
|
ITEM_FACTORY_ENTRY("/Follow TCP Stream", NULL, follow_stream_cb,
|
|
|
|
0, NULL, NULL),
|
|
|
|
ITEM_FACTORY_ENTRY("/Decode As...", NULL, decode_as_cb, 0, NULL, NULL),
|
|
|
|
ITEM_FACTORY_ENTRY("/Display Filters...", NULL, dfilter_dialog_cb,
|
|
|
|
0, NULL, NULL),
|
|
|
|
ITEM_FACTORY_ENTRY("/<separator>", NULL, NULL, 0, "<Separator>", NULL),
|
2003-11-28 19:13:25 +00:00
|
|
|
ITEM_FACTORY_ENTRY("/Mark Packet", NULL, mark_frame_cb, 0, NULL, NULL),
|
2003-10-10 08:39:24 +00:00
|
|
|
ITEM_FACTORY_ENTRY("/Time Reference", NULL, NULL, 0, "<Branch>", NULL),
|
|
|
|
ITEM_FACTORY_ENTRY("/Time Reference/Set Time Reference (toggle)", NULL, reftime_frame_cb, 0, NULL, NULL),
|
|
|
|
ITEM_FACTORY_ENTRY("/Time Reference/Find Next", NULL, reftime_frame_cb, 1, NULL, NULL),
|
|
|
|
ITEM_FACTORY_ENTRY("/Time Reference/Find Previous", NULL, reftime_frame_cb, 2, NULL, NULL),
|
2002-11-15 23:50:06 +00:00
|
|
|
ITEM_FACTORY_ENTRY("/Match", NULL, NULL, 0, "<Branch>", NULL),
|
|
|
|
ITEM_FACTORY_ENTRY("/Match/_Selected", NULL,
|
|
|
|
match_selected_cb_replace_plist, 0, NULL, NULL),
|
|
|
|
ITEM_FACTORY_ENTRY("/Match/_Not Selected", NULL,
|
|
|
|
match_selected_cb_not_plist, 0, NULL, NULL),
|
|
|
|
ITEM_FACTORY_ENTRY("/Match/_And Selected", NULL,
|
|
|
|
match_selected_cb_and_plist, 0, NULL, NULL),
|
|
|
|
ITEM_FACTORY_ENTRY("/Match/_Or Selected", NULL, match_selected_cb_or_plist,
|
|
|
|
0, NULL, NULL),
|
|
|
|
ITEM_FACTORY_ENTRY("/Match/A_nd Not Selected", NULL,
|
|
|
|
match_selected_cb_and_plist_not, 0, NULL, NULL),
|
|
|
|
ITEM_FACTORY_ENTRY("/Match/O_r Not Selected", NULL,
|
|
|
|
match_selected_cb_or_plist_not, 0, NULL, NULL),
|
|
|
|
ITEM_FACTORY_ENTRY("/Prepare", NULL, NULL, 0, "<Branch>", NULL),
|
|
|
|
ITEM_FACTORY_ENTRY("/Prepare/_Selected", NULL,
|
|
|
|
prepare_selected_cb_replace_plist, 0, NULL, NULL),
|
|
|
|
ITEM_FACTORY_ENTRY("/Prepare/_Not Selected", NULL,
|
|
|
|
prepare_selected_cb_not_plist, 0, NULL, NULL),
|
|
|
|
ITEM_FACTORY_ENTRY("/Prepare/_And Selected", NULL,
|
|
|
|
prepare_selected_cb_and_plist, 0, NULL, NULL),
|
|
|
|
ITEM_FACTORY_ENTRY("/Prepare/_Or Selected", NULL,
|
|
|
|
prepare_selected_cb_or_plist, 0, NULL, NULL),
|
|
|
|
ITEM_FACTORY_ENTRY("/Prepare/A_nd Not Selected", NULL,
|
|
|
|
prepare_selected_cb_and_plist_not, 0, NULL, NULL),
|
|
|
|
ITEM_FACTORY_ENTRY("/Prepare/O_r Not Selected", NULL,
|
|
|
|
prepare_selected_cb_or_plist_not, 0, NULL, NULL),
|
|
|
|
ITEM_FACTORY_ENTRY("/<separator>", NULL, NULL, 0, "<Separator>", NULL),
|
2003-11-27 20:34:01 +00:00
|
|
|
ITEM_FACTORY_ENTRY("/Coloring Rules...", NULL, color_display_cb,
|
2002-11-15 23:50:06 +00:00
|
|
|
0, NULL, NULL),
|
|
|
|
ITEM_FACTORY_ENTRY("/Print...", NULL, file_print_cmd_cb, 0, NULL, NULL),
|
|
|
|
ITEM_FACTORY_ENTRY("/Show Packet In New Window", NULL, new_window_cb,
|
|
|
|
0, NULL, NULL),
|
2002-11-03 17:38:45 +00:00
|
|
|
};
|
2000-01-18 08:38:18 +00:00
|
|
|
|
|
|
|
static GtkItemFactoryEntry tree_view_menu_items[] =
|
|
|
|
{
|
2002-11-15 23:50:06 +00:00
|
|
|
ITEM_FACTORY_ENTRY("/Follow TCP Stream", NULL, follow_stream_cb,
|
|
|
|
0, NULL, NULL),
|
|
|
|
ITEM_FACTORY_ENTRY("/Decode As...", NULL, decode_as_cb, 0, NULL, NULL),
|
|
|
|
ITEM_FACTORY_ENTRY("/Display Filters...", NULL, dfilter_dialog_cb,
|
|
|
|
0, NULL, NULL),
|
|
|
|
ITEM_FACTORY_ENTRY("/<separator>", NULL, NULL, 0, "<Separator>", NULL),
|
2002-12-19 02:58:53 +00:00
|
|
|
ITEM_FACTORY_ENTRY("/_Resolve Name", NULL, resolve_name_cb, 0, NULL, NULL),
|
2003-11-28 19:13:25 +00:00
|
|
|
ITEM_FACTORY_ENTRY("/_Go To Corresponding Packet", NULL, goto_framenum_cb, 0, NULL, NULL),
|
2004-01-27 20:58:19 +00:00
|
|
|
ITEM_FACTORY_ENTRY("/_Export Selected Packet Bytes...", NULL, savehex_cb,
|
2004-01-27 05:05:58 +00:00
|
|
|
0, NULL, NULL),
|
2002-11-15 23:50:06 +00:00
|
|
|
ITEM_FACTORY_ENTRY("/Protocol Properties...", NULL, properties_cb,
|
|
|
|
0, NULL, NULL),
|
|
|
|
ITEM_FACTORY_ENTRY("/Match", NULL, NULL, 0, "<Branch>", NULL),
|
|
|
|
ITEM_FACTORY_ENTRY("/Match/_Selected", NULL,
|
|
|
|
match_selected_cb_replace_ptree, 0, NULL, NULL),
|
|
|
|
ITEM_FACTORY_ENTRY("/Match/_Not Selected", NULL,
|
|
|
|
match_selected_cb_not_ptree, 0, NULL, NULL),
|
|
|
|
ITEM_FACTORY_ENTRY("/Match/_And Selected", NULL,
|
|
|
|
match_selected_cb_and_ptree, 0, NULL, NULL),
|
|
|
|
ITEM_FACTORY_ENTRY("/Match/_Or Selected", NULL, match_selected_cb_or_ptree,
|
|
|
|
0, NULL, NULL),
|
|
|
|
ITEM_FACTORY_ENTRY("/Match/A_nd Not Selected", NULL,
|
|
|
|
match_selected_cb_and_ptree_not, 0, NULL, NULL),
|
|
|
|
ITEM_FACTORY_ENTRY("/Match/O_r Not Selected", NULL,
|
|
|
|
match_selected_cb_or_ptree_not, 0, NULL, NULL),
|
|
|
|
ITEM_FACTORY_ENTRY("/Prepare", NULL, NULL, 0, "<Branch>", NULL),
|
|
|
|
ITEM_FACTORY_ENTRY("/Prepare/_Selected", NULL,
|
|
|
|
prepare_selected_cb_replace_ptree, 0, NULL, NULL),
|
|
|
|
ITEM_FACTORY_ENTRY("/Prepare/_Not Selected", NULL,
|
|
|
|
prepare_selected_cb_not_ptree, 0, NULL, NULL),
|
|
|
|
ITEM_FACTORY_ENTRY("/Prepare/_And Selected", NULL,
|
|
|
|
prepare_selected_cb_and_ptree, 0, NULL, NULL),
|
|
|
|
ITEM_FACTORY_ENTRY("/Prepare/_Or Selected", NULL,
|
|
|
|
prepare_selected_cb_or_ptree, 0, NULL, NULL),
|
|
|
|
ITEM_FACTORY_ENTRY("/Prepare/A_nd Not Selected", NULL,
|
|
|
|
prepare_selected_cb_and_ptree_not, 0, NULL, NULL),
|
|
|
|
ITEM_FACTORY_ENTRY("/Prepare/O_r Not Selected", NULL,
|
|
|
|
prepare_selected_cb_or_ptree_not, 0, NULL, NULL),
|
|
|
|
ITEM_FACTORY_ENTRY("/<separator>", NULL, NULL, 0, "<Separator>", NULL),
|
|
|
|
ITEM_FACTORY_ENTRY("/Collapse All", NULL, collapse_all_cb, 0, NULL, NULL),
|
|
|
|
ITEM_FACTORY_ENTRY("/Expand All", NULL, expand_all_cb, 0, NULL, NULL)
|
2000-01-18 08:38:18 +00:00
|
|
|
};
|
|
|
|
|
2000-08-20 21:55:58 +00:00
|
|
|
static GtkItemFactoryEntry hexdump_menu_items[] =
|
|
|
|
{
|
2002-11-15 23:50:06 +00:00
|
|
|
ITEM_FACTORY_ENTRY("/Follow TCP Stream", NULL, follow_stream_cb,
|
|
|
|
0, NULL, NULL),
|
|
|
|
ITEM_FACTORY_ENTRY("/Decode As...", NULL, decode_as_cb, 0, NULL, NULL),
|
|
|
|
ITEM_FACTORY_ENTRY("/Display Filters...", NULL, dfilter_dialog_cb,
|
2003-11-29 06:09:54 +00:00
|
|
|
0, NULL, NULL),
|
2004-01-27 20:58:19 +00:00
|
|
|
ITEM_FACTORY_ENTRY("/Export Selected Packet Bytes...", NULL, savehex_cb,
|
2002-11-15 23:50:06 +00:00
|
|
|
0, NULL, 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;
|
2003-04-22 00:16:58 +00:00
|
|
|
static GtkItemFactory *main_menu_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;
|
|
|
|
|
2004-01-19 00:42:12 +00:00
|
|
|
GtkWidget *
|
|
|
|
main_menu_new(GtkAccelGroup ** table) {
|
|
|
|
GtkWidget *menubar;
|
1998-12-17 05:42:33 +00:00
|
|
|
|
|
|
|
grp = gtk_accel_group_new();
|
|
|
|
|
2003-10-20 22:28:22 +00:00
|
|
|
if (initialize)
|
1998-09-16 02:39:15 +00:00
|
|
|
menus_init();
|
|
|
|
|
2004-01-19 00:42:12 +00:00
|
|
|
menubar = main_menu_factory->widget;
|
1998-12-17 05:42:33 +00:00
|
|
|
|
1998-09-16 02:39:15 +00:00
|
|
|
if (table)
|
1998-12-17 05:42:33 +00:00
|
|
|
*table = grp;
|
2004-01-19 00:42:12 +00:00
|
|
|
|
|
|
|
return menubar;
|
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);
|
2003-10-20 22:28:22 +00:00
|
|
|
popup_menu_object = gtk_menu_new();
|
2002-01-11 08:21:02 +00:00
|
|
|
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, popup_menu_object, 2);
|
2002-11-11 15:39:06 +00:00
|
|
|
OBJECT_SET_DATA(popup_menu_object, PM_PACKET_LIST_KEY,
|
|
|
|
packet_list_menu_factory->widget);
|
2000-01-18 08:38:18 +00:00
|
|
|
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);
|
2002-01-11 08:21:02 +00:00
|
|
|
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, popup_menu_object, 2);
|
2002-11-11 15:39:06 +00:00
|
|
|
OBJECT_SET_DATA(popup_menu_object, PM_TREE_VIEW_KEY,
|
|
|
|
tree_view_menu_factory->widget);
|
2000-01-18 08:38:18 +00:00
|
|
|
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);
|
2002-01-11 08:21:02 +00:00
|
|
|
gtk_item_factory_create_items_ac(hexdump_menu_factory, sizeof(hexdump_menu_items)/sizeof(hexdump_menu_items[0]), hexdump_menu_items, popup_menu_object, 2);
|
2002-11-11 15:39:06 +00:00
|
|
|
OBJECT_SET_DATA(popup_menu_object, PM_HEXDUMP_KEY,
|
|
|
|
hexdump_menu_factory->widget);
|
2000-08-20 21:55:58 +00:00
|
|
|
popup_menu_list = g_slist_append((GSList *)popup_menu_list, hexdump_menu_factory);
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2003-10-20 22:28:22 +00:00
|
|
|
/* main */
|
2003-04-22 00:16:58 +00:00
|
|
|
main_menu_factory = gtk_item_factory_new(GTK_TYPE_MENU_BAR, "<main>", grp);
|
2003-12-03 19:59:28 +00:00
|
|
|
gtk_item_factory_create_items_ac(main_menu_factory, nmenu_items, menu_items, NULL, 2);
|
2003-10-20 22:28:22 +00:00
|
|
|
register_all_tap_menus(); /* must be done after creating the main menu */
|
|
|
|
|
|
|
|
/* Initialize enabled/disabled state of menu items */
|
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. */
|
2003-04-22 00:16:58 +00:00
|
|
|
set_menu_sensitivity(main_menu_factory, "/Edit/Cut", FALSE);
|
|
|
|
set_menu_sensitivity(main_menu_factory, "/Edit/Copy", FALSE);
|
|
|
|
set_menu_sensitivity(main_menu_factory, "/Edit/Paste", FALSE);
|
2000-09-09 08:17:51 +00:00
|
|
|
#endif
|
2003-04-16 07:25:12 +00:00
|
|
|
|
2000-01-03 03:57:04 +00:00
|
|
|
set_menus_for_captured_packets(FALSE);
|
2003-09-24 02:36:35 +00:00
|
|
|
set_menus_for_selected_packet(&cfile);
|
|
|
|
set_menus_for_selected_tree_row(&cfile);
|
2004-01-02 17:27:00 +00:00
|
|
|
|
2004-01-19 00:42:12 +00:00
|
|
|
/* init with an empty recent files list */
|
2004-01-02 17:27:00 +00:00
|
|
|
clear_menu_recent_capture_file_cmd_cb(NULL, NULL);
|
1998-09-16 02:39:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-09-19 07:24:39 +00:00
|
|
|
typedef struct _menu_item {
|
|
|
|
char *name;
|
|
|
|
gboolean enabled;
|
2003-09-24 02:36:35 +00:00
|
|
|
gboolean (*selected_packet_enabled)(frame_data *, epan_dissect_t *);
|
|
|
|
gboolean (*selected_tree_row_enabled)(field_info *);
|
2003-09-19 07:24:39 +00:00
|
|
|
struct _menu_item *parent;
|
|
|
|
struct _menu_item *children;
|
|
|
|
struct _menu_item *next;
|
|
|
|
} menu_item_t;
|
|
|
|
|
|
|
|
static menu_item_t tap_menu_tree_root;
|
|
|
|
|
2003-04-23 03:13:16 +00:00
|
|
|
/*
|
2003-09-19 07:24:39 +00:00
|
|
|
* Add a new menu item for a tap.
|
2003-04-23 03:13:16 +00:00
|
|
|
* This must be called after we've created the main menu, so it can't
|
|
|
|
* be called from the routine that registers taps - we have to introduce
|
|
|
|
* another per-tap registration routine.
|
2003-09-19 07:24:39 +00:00
|
|
|
*
|
|
|
|
* "callback" gets called when the menu item is selected; it should do
|
|
|
|
* the work of creating the tap window.
|
|
|
|
*
|
|
|
|
* "selected_packet_enabled" gets called by "set_menus_for_selected_packet()";
|
|
|
|
* it's passed a Boolean that's TRUE if a packet is selected and FALSE
|
|
|
|
* otherwise, and should return TRUE if the tap will work now (which
|
|
|
|
* might depend on whether a packet is selected and, if one is, on the
|
|
|
|
* packet) and FALSE if not.
|
|
|
|
*
|
|
|
|
* "selected_tree_row_enabled" gets called by
|
|
|
|
* "set_menus_for_selected_tree_row()"; it's passed a Boolean that's TRUE if
|
|
|
|
* a protocol tree row is selected and FALSE otherwise, and should return
|
|
|
|
* TRUE if the tap will work now (which might depend on whether a tree row
|
|
|
|
* is selected and, if one is, on the tree row) and FALSE if not.
|
2003-04-23 03:13:16 +00:00
|
|
|
*/
|
|
|
|
void
|
2003-09-19 07:24:39 +00:00
|
|
|
register_tap_menu_item(char *name, GtkItemFactoryCallback callback,
|
2003-09-24 02:36:35 +00:00
|
|
|
gboolean (*selected_packet_enabled)(frame_data *, epan_dissect_t *),
|
2003-12-17 22:13:08 +00:00
|
|
|
gboolean (*selected_tree_row_enabled)(field_info *),
|
|
|
|
gpointer callback_data)
|
2003-04-23 03:13:16 +00:00
|
|
|
{
|
2003-11-27 20:34:01 +00:00
|
|
|
static const char toolspath[] = "/Analyze/";
|
2003-04-23 05:37:23 +00:00
|
|
|
char *p;
|
2003-04-23 03:13:16 +00:00
|
|
|
char *menupath;
|
|
|
|
size_t menupathlen;
|
|
|
|
GtkItemFactoryEntry *entry;
|
2003-09-19 07:24:39 +00:00
|
|
|
menu_item_t *curnode, *child;
|
2003-04-23 03:13:16 +00:00
|
|
|
|
2003-04-23 05:37:23 +00:00
|
|
|
/*
|
|
|
|
* The menu path must be relative.
|
|
|
|
*/
|
|
|
|
g_assert(*name != '/');
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Create any submenus required.
|
|
|
|
*/
|
2003-09-19 07:24:39 +00:00
|
|
|
curnode = &tap_menu_tree_root;
|
2003-04-23 05:37:23 +00:00
|
|
|
p = name;
|
|
|
|
while ((p = strchr(p, '/')) != NULL) {
|
|
|
|
/*
|
|
|
|
* OK, everything between "name" and "p" is
|
|
|
|
* a menu relative subtree into which the menu item
|
|
|
|
* will be placed.
|
|
|
|
*
|
|
|
|
* Construct the absolute path name of that subtree.
|
|
|
|
*/
|
2003-09-17 19:39:34 +00:00
|
|
|
menupathlen = sizeof toolspath + (p - name);
|
2003-04-23 05:37:23 +00:00
|
|
|
menupath = g_malloc(menupathlen);
|
2003-09-17 19:39:34 +00:00
|
|
|
strcpy(menupath, toolspath);
|
2003-04-23 05:37:23 +00:00
|
|
|
strncat(menupath, name, p - name);
|
|
|
|
|
|
|
|
/*
|
2003-09-19 07:24:39 +00:00
|
|
|
* Does there exist an entry with that path at this
|
2004-01-03 18:05:57 +00:00
|
|
|
* level of the Analyze menu tree?
|
2003-04-23 05:37:23 +00:00
|
|
|
*/
|
2003-09-19 07:24:39 +00:00
|
|
|
for (child = curnode->children; child != NULL;
|
|
|
|
child = child->next) {
|
|
|
|
if (strcmp(child->name, menupath) == 0)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (child == NULL) {
|
2003-04-23 05:37:23 +00:00
|
|
|
/*
|
2003-09-19 07:24:39 +00:00
|
|
|
* No. Create such an item as a subtree, and
|
|
|
|
* add it to the Tools menu tree.
|
2003-04-23 05:37:23 +00:00
|
|
|
*/
|
|
|
|
entry = g_malloc0(sizeof (GtkItemFactoryEntry));
|
|
|
|
entry->path = menupath;
|
|
|
|
entry->item_type = "<Branch>";
|
|
|
|
gtk_item_factory_create_item(main_menu_factory, entry,
|
|
|
|
NULL, 2);
|
2003-09-19 07:24:39 +00:00
|
|
|
set_menu_sensitivity(main_menu_factory, menupath,
|
|
|
|
FALSE); /* no children yet */
|
|
|
|
child = g_malloc(sizeof (menu_item_t));
|
|
|
|
child->name = menupath;
|
|
|
|
child->selected_packet_enabled = NULL;
|
|
|
|
child->selected_tree_row_enabled = NULL;
|
|
|
|
child->enabled = FALSE; /* no children yet */
|
|
|
|
child->parent = curnode;
|
|
|
|
child->children = NULL;
|
|
|
|
child->next = curnode->children;
|
|
|
|
curnode->children = child;
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* Yes. We don't need "menupath" any more.
|
|
|
|
*/
|
|
|
|
g_free(menupath);
|
2003-04-23 05:37:23 +00:00
|
|
|
}
|
2003-09-19 07:24:39 +00:00
|
|
|
curnode = child;
|
2003-04-23 05:37:23 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Skip over the '/' we found.
|
|
|
|
*/
|
|
|
|
p++;
|
|
|
|
}
|
|
|
|
|
2003-04-23 03:13:16 +00:00
|
|
|
/*
|
|
|
|
* Construct the main menu path for the menu item.
|
|
|
|
*
|
2003-09-17 19:39:34 +00:00
|
|
|
* "sizeof toolspath" includes the trailing '\0', so the sum
|
2003-04-23 03:13:16 +00:00
|
|
|
* of that and the length of "name" is enough to hold a string
|
|
|
|
* containing their concatenation.
|
|
|
|
*/
|
2003-09-17 19:39:34 +00:00
|
|
|
menupathlen = sizeof toolspath + strlen(name);
|
2003-04-23 03:13:16 +00:00
|
|
|
menupath = g_malloc(menupathlen);
|
2003-09-17 19:39:34 +00:00
|
|
|
strcpy(menupath, toolspath);
|
2003-04-23 03:13:16 +00:00
|
|
|
strcat(menupath, name);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Construct an item factory entry for the item, and add it to
|
|
|
|
* the main menu.
|
|
|
|
*/
|
|
|
|
entry = g_malloc0(sizeof (GtkItemFactoryEntry));
|
|
|
|
entry->path = menupath;
|
|
|
|
entry->callback = callback;
|
2003-12-17 22:13:08 +00:00
|
|
|
gtk_item_factory_create_item(main_menu_factory, entry, callback_data, 2);
|
2003-09-19 07:24:39 +00:00
|
|
|
set_menu_sensitivity(main_menu_factory, menupath, FALSE); /* no capture file yet */
|
|
|
|
child = g_malloc(sizeof (menu_item_t));
|
|
|
|
child->name = menupath;
|
|
|
|
child->enabled = FALSE; /* no capture file yet, hence no taps yet */
|
|
|
|
child->selected_packet_enabled = selected_packet_enabled;
|
|
|
|
child->selected_tree_row_enabled = selected_tree_row_enabled;
|
|
|
|
child->parent = curnode;
|
|
|
|
child->children = NULL;
|
|
|
|
child->next = curnode->children;
|
|
|
|
curnode->children = child;
|
2003-04-23 03:13:16 +00:00
|
|
|
}
|
|
|
|
|
2003-04-22 00:16:58 +00:00
|
|
|
/*
|
|
|
|
* Enable/disable menu sensitivity.
|
|
|
|
*/
|
2000-01-03 04:06:09 +00:00
|
|
|
static void
|
2003-04-22 00:16:58 +00:00
|
|
|
set_menu_sensitivity(GtkItemFactory *ifactory, gchar *path, gint val)
|
|
|
|
{
|
|
|
|
GSList *menu_list;
|
2003-04-22 04:02:49 +00:00
|
|
|
GtkWidget *menu_item;
|
2002-01-11 08:21:02 +00:00
|
|
|
|
2003-04-22 00:16:58 +00:00
|
|
|
if (ifactory == NULL) {
|
|
|
|
/*
|
|
|
|
* Do it for all pop-up menus.
|
|
|
|
*/
|
|
|
|
for (menu_list = popup_menu_list; menu_list != NULL;
|
|
|
|
menu_list = g_slist_next(menu_list))
|
|
|
|
set_menu_sensitivity(menu_list->data, path, val);
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* Do it for that particular menu.
|
|
|
|
*/
|
2003-04-22 04:02:49 +00:00
|
|
|
if ((menu_item = gtk_item_factory_get_widget(ifactory, path)) != NULL) {
|
|
|
|
if (GTK_IS_MENU(menu_item)) {
|
|
|
|
/*
|
|
|
|
* "path" refers to a submenu; "gtk_item_factory_get_widget()"
|
|
|
|
* gets the menu, not the item that, when selected, pops up
|
|
|
|
* the submenu.
|
|
|
|
*
|
|
|
|
* We have to change the latter item's sensitivity, so that
|
|
|
|
* it shows up normally if sensitive and grayed-out if
|
|
|
|
* insensitive.
|
|
|
|
*/
|
|
|
|
menu_item = gtk_menu_get_attach_widget(GTK_MENU(menu_item));
|
|
|
|
}
|
|
|
|
gtk_widget_set_sensitive(menu_item, val);
|
|
|
|
}
|
2000-01-18 08:38:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
set_menu_object_data_meat(GtkItemFactory *ifactory, gchar *path, gchar *key, gpointer data)
|
|
|
|
{
|
|
|
|
GtkWidget *menu = NULL;
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2000-01-18 08:38:18 +00:00
|
|
|
if ((menu = gtk_item_factory_get_widget(ifactory, path)) != NULL)
|
2002-11-11 15:39:06 +00:00
|
|
|
OBJECT_SET_DATA(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, '/');
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2003-04-22 00:16:58 +00:00
|
|
|
set_menu_object_data_meat(main_menu_factory, path, key, data);
|
2000-01-18 08:38:18 +00:00
|
|
|
while (menu_list != NULL) {
|
|
|
|
set_menu_object_data_meat(menu_list->data, shortpath, key, data);
|
|
|
|
menu_list = g_slist_next(menu_list);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-12-13 18:01:30 +00:00
|
|
|
|
|
|
|
/* Recently used capture files submenu:
|
|
|
|
* Submenu containing the recently used capture files.
|
|
|
|
* The capture filenames are always kept with the absolute path, to be independant
|
|
|
|
* of the current path.
|
|
|
|
* They are only stored inside the labels of the submenu (no separate list). */
|
|
|
|
|
|
|
|
#define MENU_RECENT_FILES_PATH "/File/Open Recent"
|
2004-01-02 17:27:00 +00:00
|
|
|
#define MENU_RECENT_FILES_KEY "Recent File Name"
|
|
|
|
|
|
|
|
void
|
|
|
|
update_menu_recent_capture_file1(GtkWidget *widget, gpointer cnt) {
|
2004-01-06 22:38:07 +00:00
|
|
|
gchar *widget_cf_name;
|
2004-01-02 17:27:00 +00:00
|
|
|
|
|
|
|
widget_cf_name = OBJECT_GET_DATA(widget, MENU_RECENT_FILES_KEY);
|
|
|
|
|
2004-01-06 22:38:07 +00:00
|
|
|
/* if this menu item is a file, count it */
|
|
|
|
if (widget_cf_name) {
|
2004-01-02 17:27:00 +00:00
|
|
|
(*(guint *)cnt)++;
|
2004-01-06 22:38:07 +00:00
|
|
|
}
|
2004-01-02 17:27:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* update the menu */
|
|
|
|
void
|
|
|
|
update_menu_recent_capture_file(GtkWidget *submenu_recent_files) {
|
2004-01-06 22:38:07 +00:00
|
|
|
guint cnt = 0;
|
2004-01-02 17:27:00 +00:00
|
|
|
|
|
|
|
gtk_container_foreach(GTK_CONTAINER(submenu_recent_files),
|
|
|
|
update_menu_recent_capture_file1, &cnt);
|
|
|
|
|
|
|
|
/* make parent menu item sensitive only, if we have any valid files in the list */
|
|
|
|
set_menu_sensitivity(main_menu_factory, MENU_RECENT_FILES_PATH, cnt);
|
|
|
|
}
|
|
|
|
|
2003-12-13 18:01:30 +00:00
|
|
|
|
2003-12-15 06:38:48 +00:00
|
|
|
/* remove the capture filename from the "Recent Files" menu */
|
|
|
|
void
|
2004-01-03 05:13:12 +00:00
|
|
|
remove_menu_recent_capture_file(GtkWidget *widget, gpointer unused _U_) {
|
2003-12-15 06:38:48 +00:00
|
|
|
GtkWidget *submenu_recent_files;
|
2004-01-02 17:27:00 +00:00
|
|
|
gchar *widget_cf_name;
|
2003-12-15 06:38:48 +00:00
|
|
|
|
|
|
|
|
2004-01-02 17:27:00 +00:00
|
|
|
widget_cf_name = OBJECT_GET_DATA(widget, MENU_RECENT_FILES_KEY);
|
|
|
|
g_free(widget_cf_name);
|
|
|
|
|
2004-01-03 05:13:12 +00:00
|
|
|
/* get the submenu container item */
|
|
|
|
submenu_recent_files = gtk_item_factory_get_widget(main_menu_factory, MENU_RECENT_FILES_PATH);
|
2003-12-15 06:38:48 +00:00
|
|
|
|
2004-01-06 22:38:07 +00:00
|
|
|
/* XXX: is this all we need to do, to free the menu item and its label?
|
|
|
|
The reference count of widget will go to 0, so it'll be freed;
|
|
|
|
will that free the label? */
|
2004-01-03 05:13:12 +00:00
|
|
|
gtk_container_remove(GTK_CONTAINER(submenu_recent_files), widget);
|
2004-01-02 17:27:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* callback, if the user pushed the <clear file list> item */
|
|
|
|
static void
|
2004-01-03 05:13:12 +00:00
|
|
|
clear_menu_recent_capture_file_cmd_cb(GtkWidget *w _U_, gpointer unused _U_) {
|
|
|
|
GtkWidget *submenu_recent_files;
|
2004-01-02 17:27:00 +00:00
|
|
|
|
|
|
|
|
2004-01-03 05:13:12 +00:00
|
|
|
submenu_recent_files = gtk_item_factory_get_widget(main_menu_factory, MENU_RECENT_FILES_PATH);
|
2004-01-02 17:27:00 +00:00
|
|
|
|
2004-01-03 05:13:12 +00:00
|
|
|
gtk_container_foreach(GTK_CONTAINER(submenu_recent_files),
|
2004-01-02 17:27:00 +00:00
|
|
|
remove_menu_recent_capture_file, NULL);
|
|
|
|
|
|
|
|
update_menu_recent_capture_file(submenu_recent_files);
|
2003-12-15 06:38:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-12-13 18:01:30 +00:00
|
|
|
/* callback, if the user pushed a recent file submenu item */
|
|
|
|
void
|
2004-01-29 23:11:38 +00:00
|
|
|
menu_open_recent_file_cmd(GtkWidget *w)
|
2003-12-13 18:01:30 +00:00
|
|
|
{
|
2004-01-02 17:27:00 +00:00
|
|
|
GtkWidget *submenu_recent_files;
|
2003-12-13 18:01:30 +00:00
|
|
|
GtkWidget *menu_item_child;
|
|
|
|
gchar *cf_name;
|
Have the Wiretap open, read, and seek-and-read routines return, in
addition to an error code, an error info string, for
WTAP_ERR_UNSUPPORTED, WTAP_ERR_UNSUPPORTED_ENCAP, and
WTAP_ERR_BAD_RECORD errors. Replace the error messages logged with
"g_message()" for those errors with g_strdup()ed or g_strdup_printf()ed
strings returned as the error info string, and change the callers of
those routines to, for those errors, put the info string into the
printed message or alert box for the error.
Add messages for cases where those errors were returned without printing
an additional message.
Nobody uses the error code from "cf_read()" - "cf_read()" puts up the
alert box itself for failures; get rid of the error code, so it just
returns a success/failure indication.
Rename "file_read_error_message()" to "cf_read_error_message()", as it
handles read errors from Wiretap, and have it take an error info string
as an argument. (That handles a lot of the work of putting the info
string into the error message.)
Make some variables in "ascend-grammar.y" static.
Check the return value of "erf_read_header()" in "erf_seek_read()".
Get rid of an unused #define in "i4btrace.c".
svn path=/trunk/; revision=9852
2004-01-25 21:55:17 +00:00
|
|
|
int err;
|
2003-12-13 18:01:30 +00:00
|
|
|
|
2004-01-02 17:27:00 +00:00
|
|
|
submenu_recent_files = gtk_item_factory_get_widget(main_menu_factory, MENU_RECENT_FILES_PATH);
|
|
|
|
|
Have the Wiretap open, read, and seek-and-read routines return, in
addition to an error code, an error info string, for
WTAP_ERR_UNSUPPORTED, WTAP_ERR_UNSUPPORTED_ENCAP, and
WTAP_ERR_BAD_RECORD errors. Replace the error messages logged with
"g_message()" for those errors with g_strdup()ed or g_strdup_printf()ed
strings returned as the error info string, and change the callers of
those routines to, for those errors, put the info string into the
printed message or alert box for the error.
Add messages for cases where those errors were returned without printing
an additional message.
Nobody uses the error code from "cf_read()" - "cf_read()" puts up the
alert box itself for failures; get rid of the error code, so it just
returns a success/failure indication.
Rename "file_read_error_message()" to "cf_read_error_message()", as it
handles read errors from Wiretap, and have it take an error info string
as an argument. (That handles a lot of the work of putting the info
string into the error message.)
Make some variables in "ascend-grammar.y" static.
Check the return value of "erf_read_header()" in "erf_seek_read()".
Get rid of an unused #define in "i4btrace.c".
svn path=/trunk/; revision=9852
2004-01-25 21:55:17 +00:00
|
|
|
/* get capture filename from the menu item label */
|
2003-12-13 18:01:30 +00:00
|
|
|
menu_item_child = (GTK_BIN(w))->child;
|
|
|
|
gtk_label_get(GTK_LABEL(menu_item_child), &cf_name);
|
|
|
|
|
|
|
|
/* open and read the capture file (this will close an existing file) */
|
2003-12-29 19:59:05 +00:00
|
|
|
if ((err = cf_open(cf_name, FALSE, &cfile)) == 0) {
|
Have the Wiretap open, read, and seek-and-read routines return, in
addition to an error code, an error info string, for
WTAP_ERR_UNSUPPORTED, WTAP_ERR_UNSUPPORTED_ENCAP, and
WTAP_ERR_BAD_RECORD errors. Replace the error messages logged with
"g_message()" for those errors with g_strdup()ed or g_strdup_printf()ed
strings returned as the error info string, and change the callers of
those routines to, for those errors, put the info string into the
printed message or alert box for the error.
Add messages for cases where those errors were returned without printing
an additional message.
Nobody uses the error code from "cf_read()" - "cf_read()" puts up the
alert box itself for failures; get rid of the error code, so it just
returns a success/failure indication.
Rename "file_read_error_message()" to "cf_read_error_message()", as it
handles read errors from Wiretap, and have it take an error info string
as an argument. (That handles a lot of the work of putting the info
string into the error message.)
Make some variables in "ascend-grammar.y" static.
Check the return value of "erf_read_header()" in "erf_seek_read()".
Get rid of an unused #define in "i4btrace.c".
svn path=/trunk/; revision=9852
2004-01-25 21:55:17 +00:00
|
|
|
cf_read(&cfile);
|
2003-12-29 19:59:05 +00:00
|
|
|
} else {
|
|
|
|
/* the capture file isn't existing any longer, remove menu item */
|
|
|
|
/* XXX: ask user to remove item, it's maybe only a temporary problem */
|
2004-01-02 17:27:00 +00:00
|
|
|
remove_menu_recent_capture_file(w, NULL);
|
2003-12-13 18:01:30 +00:00
|
|
|
}
|
2004-01-02 17:27:00 +00:00
|
|
|
|
2004-01-06 22:38:07 +00:00
|
|
|
update_menu_recent_capture_file(submenu_recent_files);
|
2003-12-13 18:01:30 +00:00
|
|
|
}
|
|
|
|
|
2004-01-29 23:11:38 +00:00
|
|
|
static void menu_open_recent_file_answered_cb(gpointer dialog _U_, gint btn, gpointer data _U_)
|
|
|
|
{
|
|
|
|
switch(btn) {
|
|
|
|
case(ESD_BTN_YES):
|
|
|
|
/* save file first */
|
|
|
|
file_save_as_cmd(after_save_open_recent_file, data);
|
|
|
|
break;
|
|
|
|
case(ESD_BTN_NO):
|
|
|
|
menu_open_recent_file_cmd(data);
|
|
|
|
break;
|
|
|
|
case(ESD_BTN_CANCEL):
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_assert_not_reached();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
menu_open_recent_file_cmd_cb(GtkWidget *widget, gpointer data _U_) {
|
|
|
|
gpointer dialog;
|
|
|
|
|
|
|
|
|
|
|
|
if((cfile.state != FILE_CLOSED) && !cfile.user_saved) {
|
|
|
|
/* user didn't saved his current file, ask him */
|
|
|
|
dialog = simple_dialog(ESD_TYPE_QUEST | ESD_TYPE_MODAL,
|
|
|
|
ESD_BTN_YES | ESD_BTN_NO | ESD_BTN_CANCEL,
|
|
|
|
"Save packets to \"%s\" before opening a new capture file?",
|
|
|
|
cf_get_display_name(&cfile));
|
|
|
|
simple_dialog_set_cb(dialog, menu_open_recent_file_answered_cb, widget);
|
|
|
|
} else {
|
|
|
|
/* unchanged file */
|
|
|
|
menu_open_recent_file_cmd(widget);
|
|
|
|
}
|
|
|
|
}
|
2003-12-13 18:01:30 +00:00
|
|
|
|
|
|
|
/* add the capture filename (with an absolute path) to the "Recent Files" menu */
|
|
|
|
void
|
|
|
|
add_menu_recent_capture_file_absolute(gchar *cf_name) {
|
|
|
|
GtkWidget *submenu_recent_files;
|
|
|
|
GList *menu_item_list;
|
|
|
|
GList *li;
|
|
|
|
gchar *widget_cf_name;
|
|
|
|
GtkWidget *menu_item;
|
|
|
|
guint cnt;
|
|
|
|
|
|
|
|
|
|
|
|
/* get the submenu container item */
|
|
|
|
submenu_recent_files = gtk_item_factory_get_widget(main_menu_factory, MENU_RECENT_FILES_PATH);
|
|
|
|
|
|
|
|
/* convert container to a GList */
|
|
|
|
menu_item_list = gtk_container_children(GTK_CONTAINER(submenu_recent_files));
|
|
|
|
|
|
|
|
/* iterate through list items of menu_item_list,
|
2004-01-02 17:27:00 +00:00
|
|
|
* removing special items, a maybe duplicate entry and every item above count_max */
|
2004-01-06 22:38:07 +00:00
|
|
|
cnt = 1;
|
2004-01-02 17:27:00 +00:00
|
|
|
for (li = g_list_first(menu_item_list); li; li = li->next, cnt++) {
|
|
|
|
/* get capture filename */
|
2004-01-06 22:38:07 +00:00
|
|
|
menu_item = GTK_WIDGET(li->data);
|
|
|
|
widget_cf_name = OBJECT_GET_DATA(menu_item, MENU_RECENT_FILES_KEY);
|
2003-12-13 18:01:30 +00:00
|
|
|
|
2004-01-02 17:27:00 +00:00
|
|
|
/* if this element string is one of our special items or
|
2004-01-06 22:38:07 +00:00
|
|
|
* already in the list or
|
2003-12-13 18:01:30 +00:00
|
|
|
* this element is above maximum count (too old), remove it */
|
2004-01-02 17:27:00 +00:00
|
|
|
if (!widget_cf_name ||
|
2004-01-06 22:38:07 +00:00
|
|
|
strncmp(widget_cf_name, cf_name, 1000) == 0 ||
|
|
|
|
cnt >= prefs.gui_recent_files_count_max) {
|
2004-01-02 17:27:00 +00:00
|
|
|
remove_menu_recent_capture_file(li->data, NULL);
|
2003-12-13 18:01:30 +00:00
|
|
|
cnt--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
g_list_free(menu_item_list);
|
|
|
|
|
|
|
|
/* add new item at latest position */
|
|
|
|
menu_item = gtk_menu_item_new_with_label(cf_name);
|
2004-01-06 22:38:07 +00:00
|
|
|
widget_cf_name = g_strdup(cf_name);
|
|
|
|
OBJECT_SET_DATA(menu_item, MENU_RECENT_FILES_KEY, widget_cf_name);
|
2003-12-13 18:01:30 +00:00
|
|
|
gtk_menu_prepend (GTK_MENU(submenu_recent_files), menu_item);
|
2003-12-16 18:43:35 +00:00
|
|
|
SIGNAL_CONNECT_OBJECT(GTK_OBJECT(menu_item), "activate",
|
2003-12-13 18:01:30 +00:00
|
|
|
menu_open_recent_file_cmd_cb, (GtkObject *) menu_item);
|
|
|
|
gtk_widget_show (menu_item);
|
2004-01-02 17:27:00 +00:00
|
|
|
|
|
|
|
/* add seperator at last position */
|
|
|
|
menu_item = gtk_menu_item_new();
|
|
|
|
gtk_menu_append (GTK_MENU(submenu_recent_files), menu_item);
|
|
|
|
gtk_widget_show (menu_item);
|
|
|
|
|
2004-01-06 22:38:07 +00:00
|
|
|
/* add new "clear list" item at last position */
|
2004-01-02 17:27:00 +00:00
|
|
|
menu_item = gtk_menu_item_new_with_label("<clear file list>");
|
|
|
|
gtk_menu_append (GTK_MENU(submenu_recent_files), menu_item);
|
|
|
|
SIGNAL_CONNECT_OBJECT(GTK_OBJECT(menu_item), "activate",
|
|
|
|
clear_menu_recent_capture_file_cmd_cb, (GtkObject *) menu_item);
|
|
|
|
gtk_widget_show (menu_item);
|
|
|
|
|
2004-01-06 22:38:07 +00:00
|
|
|
update_menu_recent_capture_file(submenu_recent_files);
|
2003-12-13 18:01:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* add the capture filename to the "Recent Files" menu */
|
|
|
|
/* (will change nothing, if this filename is already in the menu) */
|
|
|
|
void
|
|
|
|
add_menu_recent_capture_file(gchar *cf_name) {
|
|
|
|
gchar *curr;
|
|
|
|
gchar *absolute;
|
|
|
|
|
|
|
|
|
|
|
|
/* if this filename is an absolute path, we can use it directly */
|
|
|
|
if (g_path_is_absolute(cf_name)) {
|
|
|
|
add_menu_recent_capture_file_absolute(cf_name);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* this filename is not an absolute path, prepend the current dir */
|
|
|
|
curr = g_get_current_dir();
|
|
|
|
absolute = g_strdup_printf("%s%s%s", curr, G_DIR_SEPARATOR_S, cf_name);
|
|
|
|
add_menu_recent_capture_file_absolute(absolute);
|
|
|
|
g_free(curr);
|
|
|
|
g_free(absolute);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* write a single menu item widget label to the user's recent file */
|
|
|
|
/* helper, for menu_recent_file_write_all() */
|
|
|
|
void menu_recent_file_write(GtkWidget *widget, gpointer data) {
|
|
|
|
gchar *cf_name;
|
|
|
|
FILE *rf = (FILE *) data;
|
|
|
|
|
|
|
|
|
|
|
|
/* get capture filename from the menu item label */
|
2004-01-06 22:38:07 +00:00
|
|
|
cf_name = OBJECT_GET_DATA(widget, MENU_RECENT_FILES_KEY);
|
2003-12-13 18:01:30 +00:00
|
|
|
|
2004-01-06 22:38:07 +00:00
|
|
|
if (cf_name) {
|
2004-01-02 17:27:00 +00:00
|
|
|
fprintf (rf, RECENT_KEY_CAPTURE_FILE ": %s\n", cf_name);
|
2004-01-06 22:38:07 +00:00
|
|
|
}
|
2003-12-13 18:01:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* write all capture filenames of the menu to the user's recent file */
|
|
|
|
void
|
|
|
|
menu_recent_file_write_all(FILE *rf) {
|
|
|
|
GtkWidget *submenu_recent_files;
|
|
|
|
|
|
|
|
|
|
|
|
submenu_recent_files = gtk_item_factory_get_widget(main_menu_factory, MENU_RECENT_FILES_PATH);
|
|
|
|
|
|
|
|
gtk_container_foreach(GTK_CONTAINER(submenu_recent_files),
|
|
|
|
menu_recent_file_write, rf);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-01-19 00:42:12 +00:00
|
|
|
static void
|
|
|
|
main_toolbar_show_cb(GtkWidget *w _U_, gpointer d _U_)
|
|
|
|
{
|
|
|
|
|
|
|
|
/* save current setting in recent */
|
|
|
|
recent.main_toolbar_show = GTK_CHECK_MENU_ITEM(w)->active;
|
|
|
|
|
|
|
|
main_widgets_rearrange();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
filter_toolbar_show_cb(GtkWidget *w _U_, gpointer d _U_)
|
|
|
|
{
|
|
|
|
|
|
|
|
/* save current setting in recent */
|
|
|
|
recent.filter_toolbar_show = GTK_CHECK_MENU_ITEM(w)->active;
|
|
|
|
|
|
|
|
main_widgets_rearrange();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
packet_list_show_cb(GtkWidget *w _U_, gpointer d _U_)
|
|
|
|
{
|
|
|
|
|
|
|
|
/* save current setting in recent */
|
|
|
|
recent.packet_list_show = GTK_CHECK_MENU_ITEM(w)->active;
|
|
|
|
|
|
|
|
main_widgets_rearrange();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
tree_view_show_cb(GtkWidget *w _U_, gpointer d _U_)
|
|
|
|
{
|
|
|
|
|
|
|
|
/* save current setting in recent */
|
|
|
|
recent.tree_view_show = GTK_CHECK_MENU_ITEM(w)->active;
|
|
|
|
|
|
|
|
main_widgets_rearrange();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
byte_view_show_cb(GtkWidget *w _U_, gpointer d _U_)
|
|
|
|
{
|
|
|
|
|
|
|
|
/* save current setting in recent */
|
|
|
|
recent.byte_view_show = GTK_CHECK_MENU_ITEM(w)->active;
|
|
|
|
|
|
|
|
main_widgets_rearrange();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
statusbar_show_cb(GtkWidget *w _U_, gpointer d _U_)
|
|
|
|
{
|
|
|
|
|
|
|
|
/* save current setting in recent */
|
|
|
|
recent.statusbar_show = GTK_CHECK_MENU_ITEM(w)->active;
|
|
|
|
|
|
|
|
main_widgets_rearrange();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-01-19 03:46:43 +00:00
|
|
|
static void
|
|
|
|
timestamp_absolute_cb(GtkWidget *w _U_, gpointer d _U_)
|
|
|
|
{
|
|
|
|
if (recent.gui_time_format != TS_ABSOLUTE) {
|
|
|
|
timestamp_type = TS_ABSOLUTE;
|
|
|
|
recent.gui_time_format = timestamp_type;
|
|
|
|
change_time_formats(&cfile);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
timestamp_absolute_date_cb(GtkWidget *w _U_, gpointer d _U_)
|
|
|
|
{
|
|
|
|
if (recent.gui_time_format != TS_ABSOLUTE_WITH_DATE) {
|
|
|
|
timestamp_type = TS_ABSOLUTE_WITH_DATE;
|
|
|
|
recent.gui_time_format = timestamp_type;
|
|
|
|
change_time_formats(&cfile);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
timestamp_relative_cb(GtkWidget *w _U_, gpointer d _U_)
|
|
|
|
{
|
|
|
|
if (recent.gui_time_format != TS_RELATIVE) {
|
|
|
|
timestamp_type = TS_RELATIVE;
|
|
|
|
recent.gui_time_format = timestamp_type;
|
|
|
|
change_time_formats(&cfile);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
timestamp_delta_cb(GtkWidget *w _U_, gpointer d _U_)
|
|
|
|
{
|
|
|
|
if (recent.gui_time_format != TS_DELTA) {
|
|
|
|
timestamp_type = TS_DELTA;
|
|
|
|
recent.gui_time_format = timestamp_type;
|
|
|
|
change_time_formats(&cfile);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-01-21 06:41:03 +00:00
|
|
|
static void
|
|
|
|
name_resolution_mac_cb(GtkWidget *w _U_, gpointer d _U_)
|
|
|
|
{
|
|
|
|
if (GTK_CHECK_MENU_ITEM(w)->active) {
|
|
|
|
g_resolv_flags |= RESOLV_MAC;
|
|
|
|
} else {
|
|
|
|
g_resolv_flags &= ~RESOLV_MAC;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
name_resolution_network_cb(GtkWidget *w _U_, gpointer d _U_)
|
|
|
|
{
|
|
|
|
if (GTK_CHECK_MENU_ITEM(w)->active) {
|
|
|
|
g_resolv_flags |= RESOLV_NETWORK;
|
|
|
|
} else {
|
|
|
|
g_resolv_flags &= ~RESOLV_NETWORK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
name_resolution_transport_cb(GtkWidget *w _U_, gpointer d _U_)
|
|
|
|
{
|
|
|
|
if (GTK_CHECK_MENU_ITEM(w)->active) {
|
|
|
|
g_resolv_flags |= RESOLV_TRANSPORT;
|
|
|
|
} else {
|
|
|
|
g_resolv_flags &= ~RESOLV_TRANSPORT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
auto_scroll_live_cb(GtkWidget *w _U_, gpointer d _U_)
|
|
|
|
{
|
|
|
|
auto_scroll_live = GTK_CHECK_MENU_ITEM(w)->active;
|
|
|
|
}
|
|
|
|
|
2004-01-19 03:46:43 +00:00
|
|
|
|
2004-01-19 00:42:12 +00:00
|
|
|
/* the recent file read has finished, update the menu corresponding */
|
|
|
|
void
|
|
|
|
menu_recent_read_finished(void) {
|
2004-01-19 23:03:20 +00:00
|
|
|
GtkWidget *menu = NULL;
|
2004-01-19 00:42:12 +00:00
|
|
|
|
2004-01-19 23:03:20 +00:00
|
|
|
menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Show/Main Toolbar");
|
2004-01-19 00:42:12 +00:00
|
|
|
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), recent.main_toolbar_show);
|
|
|
|
|
2004-01-19 23:03:20 +00:00
|
|
|
menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Show/Filter Toolbar");
|
2004-01-19 00:42:12 +00:00
|
|
|
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), recent.filter_toolbar_show);
|
|
|
|
|
2004-01-19 23:03:20 +00:00
|
|
|
menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Show/Packet List");
|
2004-01-19 00:42:12 +00:00
|
|
|
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), recent.packet_list_show);
|
|
|
|
|
2004-01-26 18:35:56 +00:00
|
|
|
menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Show/Packet Details");
|
2004-01-19 00:42:12 +00:00
|
|
|
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), recent.tree_view_show);
|
|
|
|
|
2004-01-26 18:35:56 +00:00
|
|
|
menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Show/Packet Bytes");
|
2004-01-19 00:42:12 +00:00
|
|
|
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), recent.byte_view_show);
|
|
|
|
|
|
|
|
menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Show/Status Bar");
|
|
|
|
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), recent.statusbar_show);
|
|
|
|
|
2004-01-23 16:10:09 +00:00
|
|
|
menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Name Resolution/Enable for MAC Layer");
|
2004-01-21 06:41:03 +00:00
|
|
|
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), g_resolv_flags & RESOLV_MAC);
|
|
|
|
|
2004-01-23 16:10:09 +00:00
|
|
|
menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Name Resolution/Enable for Network Layer");
|
2004-01-21 06:41:03 +00:00
|
|
|
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), g_resolv_flags & RESOLV_NETWORK);
|
|
|
|
|
2004-01-23 16:10:09 +00:00
|
|
|
menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Name Resolution/Enable for Transport Layer");
|
2004-01-21 06:41:03 +00:00
|
|
|
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), g_resolv_flags & RESOLV_TRANSPORT);
|
|
|
|
|
2004-01-23 16:10:09 +00:00
|
|
|
menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Auto Scroll in Live Capture");
|
2004-01-21 06:41:03 +00:00
|
|
|
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), auto_scroll_live);
|
|
|
|
|
2004-01-19 00:42:12 +00:00
|
|
|
main_widgets_rearrange();
|
2004-01-19 03:46:43 +00:00
|
|
|
|
|
|
|
/* don't change the time format, if we had a command line value */
|
2004-01-19 23:03:20 +00:00
|
|
|
if (timestamp_type != TS_NOT_SET) {
|
2004-01-19 03:46:43 +00:00
|
|
|
recent.gui_time_format = timestamp_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch(recent.gui_time_format) {
|
|
|
|
case(TS_ABSOLUTE):
|
|
|
|
menu = gtk_item_factory_get_widget(main_menu_factory,
|
2004-01-23 16:10:09 +00:00
|
|
|
"/View/Time Display Format/Time of Day");
|
2004-01-19 03:46:43 +00:00
|
|
|
/* set_active will not trigger the callback when activating an active item! */
|
|
|
|
recent.gui_time_format = -1;
|
|
|
|
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), FALSE);
|
|
|
|
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), TRUE);
|
|
|
|
break;
|
|
|
|
case(TS_ABSOLUTE_WITH_DATE):
|
|
|
|
menu = gtk_item_factory_get_widget(main_menu_factory,
|
2004-01-23 16:10:09 +00:00
|
|
|
"/View/Time Display Format/Date and Time of Day");
|
2004-01-19 03:46:43 +00:00
|
|
|
recent.gui_time_format = -1;
|
|
|
|
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), TRUE);
|
|
|
|
break;
|
|
|
|
case(TS_RELATIVE):
|
|
|
|
menu = gtk_item_factory_get_widget(main_menu_factory,
|
2004-01-23 16:10:09 +00:00
|
|
|
"/View/Time Display Format/Seconds Since Beginning of Capture");
|
2004-01-19 03:46:43 +00:00
|
|
|
recent.gui_time_format = -1;
|
|
|
|
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), TRUE);
|
|
|
|
break;
|
|
|
|
case(TS_DELTA):
|
|
|
|
menu = gtk_item_factory_get_widget(main_menu_factory,
|
2004-01-23 16:10:09 +00:00
|
|
|
"/View/Time Display Format/Seconds Since Previous Packet");
|
2004-01-19 03:46:43 +00:00
|
|
|
recent.gui_time_format = -1;
|
|
|
|
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), TRUE);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_assert_not_reached();
|
|
|
|
}
|
2004-01-19 00:42:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
{
|
2004-01-27 19:46:52 +00:00
|
|
|
GtkWidget *menu = (GtkWidget *)data;
|
2002-11-11 18:46:16 +00:00
|
|
|
GdkEventButton *event_button = NULL;
|
|
|
|
gint row, column;
|
2000-01-18 08:38:18 +00:00
|
|
|
|
2002-11-11 18:46:16 +00:00
|
|
|
if(widget == NULL || event == NULL || data == NULL) {
|
|
|
|
return FALSE;
|
|
|
|
}
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2002-11-11 18:46:16 +00:00
|
|
|
/*
|
|
|
|
* If we ever want to make the menu differ based on what row
|
2004-01-09 08:36:23 +00:00
|
|
|
* and/or column we're above, we'd use "eth_clist_get_selection_info()"
|
2002-11-11 18:46:16 +00:00
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
/* Check if we are on packet_list object */
|
|
|
|
if (widget == OBJECT_GET_DATA(popup_menu_object, E_MPACKET_LIST_KEY)) {
|
2004-01-09 08:36:23 +00:00
|
|
|
if (packet_list_get_event_row_column(widget, (GdkEventButton *)event,
|
|
|
|
&row, &column)) {
|
2002-11-11 18:46:16 +00:00
|
|
|
OBJECT_SET_DATA(popup_menu_object, E_MPACKET_LIST_ROW_KEY,
|
2002-11-11 15:39:06 +00:00
|
|
|
GINT_TO_POINTER(row));
|
2002-11-11 18:46:16 +00:00
|
|
|
OBJECT_SET_DATA(popup_menu_object, E_MPACKET_LIST_COL_KEY,
|
2002-11-11 15:39:06 +00:00
|
|
|
GINT_TO_POINTER(column));
|
2004-01-27 19:46:52 +00:00
|
|
|
packet_list_set_selected_row(row);
|
2002-11-11 18:46:16 +00:00
|
|
|
}
|
|
|
|
}
|
2004-01-27 19:46:52 +00:00
|
|
|
|
|
|
|
/* Check if we are on tree_view object */
|
|
|
|
if (widget == tree_view) {
|
|
|
|
tree_view_select(widget, (GdkEventButton *) event);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check if we are on byte_view object */
|
|
|
|
if(widget == get_notebook_bv_ptr(byte_nb_ptr)) {
|
|
|
|
byte_view_select(widget, (GdkEventButton *) event);
|
|
|
|
}
|
|
|
|
|
2002-11-11 18:46:16 +00:00
|
|
|
if(event->type == GDK_BUTTON_PRESS) {
|
|
|
|
event_button = (GdkEventButton *) event;
|
|
|
|
|
2004-01-27 19:46:52 +00:00
|
|
|
/* To qoute the "Gdk Event Structures" doc:
|
|
|
|
* "Normally button 1 is the left mouse button, 2 is the middle button, and 3 is the right button" */
|
2002-11-11 18:46:16 +00:00
|
|
|
if(event_button->button == 3) {
|
|
|
|
gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL,
|
|
|
|
event_button->button,
|
|
|
|
event_button->time);
|
|
|
|
SIGNAL_EMIT_STOP_BY_NAME(widget, "button_press_event");
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#if GTK_MAJOR_VERSION >= 2
|
2004-01-27 19:46:52 +00:00
|
|
|
/* GDK_2BUTTON_PRESS is a doubleclick -> expand/collapse tree row */
|
|
|
|
/* GTK version 1 seems to be doing this automatically */
|
2002-11-11 18:46:16 +00:00
|
|
|
if (widget == tree_view && event->type == GDK_2BUTTON_PRESS) {
|
|
|
|
GtkTreePath *path;
|
|
|
|
|
|
|
|
if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(widget),
|
2003-12-17 20:28:49 +00:00
|
|
|
(gint) (((GdkEventButton *)event)->x),
|
|
|
|
(gint) (((GdkEventButton *)event)->y),
|
2002-11-11 18:46:16 +00:00
|
|
|
&path, NULL, NULL, NULL))
|
|
|
|
{
|
|
|
|
if (gtk_tree_view_row_expanded(GTK_TREE_VIEW(widget), path))
|
|
|
|
gtk_tree_view_collapse_row(GTK_TREE_VIEW(widget), path);
|
|
|
|
else
|
|
|
|
gtk_tree_view_expand_row(GTK_TREE_VIEW(widget), path,
|
|
|
|
FALSE);
|
|
|
|
gtk_tree_path_free(path);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
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)
|
|
|
|
{
|
2003-11-27 20:34:01 +00:00
|
|
|
set_menu_sensitivity(main_menu_factory, "/File/Open...", have_capture_file);
|
2004-01-22 18:13:57 +00:00
|
|
|
set_menu_sensitivity(main_menu_factory, "/File/Open Recent", have_capture_file);
|
2004-01-23 00:43:29 +00:00
|
|
|
set_menu_sensitivity(main_menu_factory, "/File/Close", have_capture_file);
|
2003-04-22 00:16:58 +00:00
|
|
|
set_menu_sensitivity(main_menu_factory, "/File/Save As...",
|
|
|
|
have_capture_file);
|
2004-01-23 00:43:29 +00:00
|
|
|
set_menu_sensitivity(main_menu_factory, "/File/Export", have_capture_file);
|
2003-11-27 20:34:01 +00:00
|
|
|
set_menu_sensitivity(main_menu_factory, "/View/Reload", have_capture_file);
|
2003-10-15 19:40:42 +00:00
|
|
|
set_toolbar_for_capture_file(have_capture_file);
|
2000-01-03 03:57:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* 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)
|
|
|
|
{
|
2003-04-22 00:16:58 +00:00
|
|
|
set_menu_sensitivity(main_menu_factory, "/File/Save",
|
|
|
|
have_unsaved_capture_file);
|
2003-11-07 01:29:05 +00:00
|
|
|
set_toolbar_for_unsaved_capture_file(have_unsaved_capture_file);
|
2000-01-03 03:57:04 +00:00
|
|
|
}
|
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)
|
|
|
|
{
|
2003-04-22 00:16:58 +00:00
|
|
|
set_menu_sensitivity(main_menu_factory, "/File/Open...",
|
|
|
|
!capture_in_progress);
|
2004-01-22 18:13:57 +00:00
|
|
|
set_menu_sensitivity(main_menu_factory, "/File/Open Recent",
|
|
|
|
!capture_in_progress);
|
2003-10-17 17:28:38 +00:00
|
|
|
#ifdef HAVE_LIBPCAP
|
2003-04-22 00:16:58 +00:00
|
|
|
set_menu_sensitivity(main_menu_factory, "/Capture/Start...",
|
|
|
|
!capture_in_progress);
|
|
|
|
set_menu_sensitivity(main_menu_factory, "/Capture/Stop",
|
|
|
|
capture_in_progress);
|
2003-10-17 17:28:38 +00:00
|
|
|
#endif /* HAVE_LIBPCAP */
|
2003-11-07 01:29:05 +00:00
|
|
|
set_toolbar_for_capture_in_progress(capture_in_progress);
|
2000-01-03 03:57:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Enable or disable menu items based on whether you have some captured
|
|
|
|
packets. */
|
2003-09-19 07:24:39 +00:00
|
|
|
static gboolean
|
|
|
|
walk_menu_tree_for_captured_packets(menu_item_t *node,
|
|
|
|
gboolean have_captured_packets)
|
|
|
|
{
|
|
|
|
gboolean is_enabled;
|
|
|
|
menu_item_t *child;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Is this a leaf node or an interior node?
|
|
|
|
*/
|
|
|
|
if (node->children == NULL) {
|
|
|
|
/*
|
|
|
|
* It's a leaf node.
|
|
|
|
*
|
|
|
|
* If it has no "selected_packet_enabled()" or
|
|
|
|
* "selected_tree_row_enabled()" routines, we enable
|
2003-10-20 22:28:22 +00:00
|
|
|
* it. This allows tap windows to be popped up even
|
|
|
|
* if you have no capture file; this is done to let
|
|
|
|
* the user pop up multiple tap windows before reading
|
|
|
|
* in a capture file, so that they can be processed in
|
|
|
|
* parallel while the capture file is being read rather
|
|
|
|
* than one at at time as you pop up the windows, and to
|
|
|
|
* let the user pop up tap windows before starting an
|
|
|
|
* "Update list of packets in real time" capture, so that
|
|
|
|
* the statistics can be displayed while the capture is
|
|
|
|
* in progress.
|
2003-09-19 07:24:39 +00:00
|
|
|
*
|
|
|
|
* If it has either of those routines, we disable it for
|
|
|
|
* now - as long as, when a capture is first available,
|
|
|
|
* we don't get called after a packet or tree row is
|
|
|
|
* selected, that's OK.
|
|
|
|
* XXX - that should be done better.
|
|
|
|
*/
|
2003-10-20 22:28:22 +00:00
|
|
|
if (node->selected_packet_enabled == NULL &&
|
|
|
|
node->selected_tree_row_enabled == NULL)
|
|
|
|
node->enabled = TRUE;
|
2003-09-19 07:24:39 +00:00
|
|
|
else
|
|
|
|
node->enabled = FALSE;
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* It's an interior node; call
|
|
|
|
* "walk_menu_tree_for_captured_packets()" on all its
|
|
|
|
* children and, if any of them are enabled, enable
|
|
|
|
* this node, otherwise disable it.
|
|
|
|
*
|
|
|
|
* XXX - should we just leave all interior nodes enabled?
|
|
|
|
* Which is a better UI choice?
|
|
|
|
*/
|
|
|
|
is_enabled = FALSE;
|
|
|
|
for (child = node->children; child != NULL; child =
|
|
|
|
child->next) {
|
|
|
|
if (walk_menu_tree_for_captured_packets(child,
|
|
|
|
have_captured_packets))
|
|
|
|
is_enabled = TRUE;
|
|
|
|
}
|
|
|
|
node->enabled = is_enabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The root node doesn't correspond to a menu tree item; it
|
|
|
|
* has a null name pointer.
|
|
|
|
*/
|
|
|
|
if (node->name != NULL) {
|
|
|
|
set_menu_sensitivity(main_menu_factory, node->name,
|
|
|
|
node->enabled);
|
|
|
|
}
|
|
|
|
return node->enabled;
|
|
|
|
}
|
|
|
|
|
2000-01-03 03:57:04 +00:00
|
|
|
void
|
|
|
|
set_menus_for_captured_packets(gboolean have_captured_packets)
|
|
|
|
{
|
2003-04-22 00:16:58 +00:00
|
|
|
set_menu_sensitivity(main_menu_factory, "/File/Print...",
|
|
|
|
have_captured_packets);
|
|
|
|
set_menu_sensitivity(packet_list_menu_factory, "/Print...",
|
|
|
|
have_captured_packets);
|
2003-11-28 19:13:25 +00:00
|
|
|
set_menu_sensitivity(main_menu_factory, "/Edit/Find Packet...",
|
2003-04-22 00:16:58 +00:00
|
|
|
have_captured_packets);
|
|
|
|
set_menu_sensitivity(main_menu_factory, "/Edit/Find Next",
|
|
|
|
have_captured_packets);
|
|
|
|
set_menu_sensitivity(main_menu_factory, "/Edit/Find Previous",
|
|
|
|
have_captured_packets);
|
2004-01-23 00:43:29 +00:00
|
|
|
set_menu_sensitivity(main_menu_factory, "/Edit/Go To First Packet",
|
|
|
|
have_captured_packets);
|
|
|
|
set_menu_sensitivity(main_menu_factory, "/Edit/Go To Last Packet",
|
|
|
|
have_captured_packets);
|
2003-11-28 19:13:25 +00:00
|
|
|
set_menu_sensitivity(main_menu_factory, "/Edit/Go To Packet...",
|
2003-04-22 00:16:58 +00:00
|
|
|
have_captured_packets);
|
2004-01-23 00:43:29 +00:00
|
|
|
set_menu_sensitivity(main_menu_factory, "/View/Zoom In",
|
|
|
|
have_captured_packets);
|
|
|
|
set_menu_sensitivity(main_menu_factory, "/View/Zoom Out",
|
|
|
|
have_captured_packets);
|
|
|
|
set_menu_sensitivity(main_menu_factory, "/View/Normal Size",
|
|
|
|
have_captured_packets);
|
2003-11-27 20:34:01 +00:00
|
|
|
set_menu_sensitivity(main_menu_factory, "/View/Coloring Rules...",
|
2003-04-22 00:16:58 +00:00
|
|
|
have_captured_packets);
|
2003-11-27 20:34:01 +00:00
|
|
|
set_menu_sensitivity(packet_list_menu_factory, "/Coloring Rules...",
|
2003-04-22 00:16:58 +00:00
|
|
|
have_captured_packets);
|
2003-11-27 20:34:01 +00:00
|
|
|
set_menu_sensitivity(main_menu_factory, "/Analyze/Summary",
|
2003-04-22 00:16:58 +00:00
|
|
|
have_captured_packets);
|
|
|
|
set_menu_sensitivity(main_menu_factory,
|
2003-11-27 20:34:01 +00:00
|
|
|
"/Analyze/Protocol Hierarchy Statistics", have_captured_packets);
|
2003-04-22 00:16:58 +00:00
|
|
|
set_menu_sensitivity(packet_list_menu_factory, "/Match",
|
|
|
|
have_captured_packets);
|
|
|
|
set_menu_sensitivity(packet_list_menu_factory, "/Prepare",
|
|
|
|
have_captured_packets);
|
2003-09-19 07:24:39 +00:00
|
|
|
walk_menu_tree_for_captured_packets(&tap_menu_tree_root,
|
2003-04-22 00:16:58 +00:00
|
|
|
have_captured_packets);
|
2003-10-15 19:40:42 +00:00
|
|
|
set_toolbar_for_captured_packets(have_captured_packets);
|
2000-01-03 03:57:04 +00:00
|
|
|
}
|
|
|
|
|
2003-09-24 02:36:35 +00:00
|
|
|
/* Enable or disable menu items based on whether a packet is selected and,
|
|
|
|
if so, on the properties of the packet. */
|
2003-09-19 07:24:39 +00:00
|
|
|
static gboolean
|
2003-09-24 02:36:35 +00:00
|
|
|
walk_menu_tree_for_selected_packet(menu_item_t *node, frame_data *fd,
|
|
|
|
epan_dissect_t *edt)
|
2003-09-19 07:24:39 +00:00
|
|
|
{
|
|
|
|
gboolean is_enabled;
|
|
|
|
menu_item_t *child;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Is this a leaf node or an interior node?
|
|
|
|
*/
|
|
|
|
if (node->children == NULL) {
|
|
|
|
/*
|
|
|
|
* It's a leaf node.
|
|
|
|
*
|
|
|
|
* If it has no "selected_packet_enabled()" routine,
|
|
|
|
* leave its enabled/disabled status alone - it
|
|
|
|
* doesn't depend on whether we have a packet selected
|
|
|
|
* or not or on the selected packet.
|
|
|
|
*
|
|
|
|
* If it has a "selected_packet_enabled()" routine,
|
|
|
|
* call it and set the item's enabled/disabled status
|
|
|
|
* based on its return value.
|
|
|
|
*/
|
2003-09-24 02:36:35 +00:00
|
|
|
if (node->selected_packet_enabled != NULL)
|
|
|
|
node->enabled = node->selected_packet_enabled(fd, edt);
|
2003-09-19 07:24:39 +00:00
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* It's an interior node; call
|
|
|
|
* "walk_menu_tree_for_selected_packet()" on all its
|
|
|
|
* children and, if any of them are enabled, enable
|
|
|
|
* this node, otherwise disable it.
|
|
|
|
*
|
|
|
|
* XXX - should we just leave all interior nodes enabled?
|
|
|
|
* Which is a better UI choice?
|
|
|
|
*/
|
|
|
|
is_enabled = FALSE;
|
|
|
|
for (child = node->children; child != NULL; child =
|
|
|
|
child->next) {
|
2003-09-24 02:36:35 +00:00
|
|
|
if (walk_menu_tree_for_selected_packet(child, fd, edt))
|
2003-09-19 07:24:39 +00:00
|
|
|
is_enabled = TRUE;
|
|
|
|
}
|
|
|
|
node->enabled = is_enabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The root node doesn't correspond to a menu tree item; it
|
|
|
|
* has a null name pointer.
|
|
|
|
*/
|
|
|
|
if (node->name != NULL) {
|
|
|
|
set_menu_sensitivity(main_menu_factory, node->name,
|
|
|
|
node->enabled);
|
|
|
|
}
|
|
|
|
return node->enabled;
|
|
|
|
}
|
|
|
|
|
2000-01-03 03:57:04 +00:00
|
|
|
void
|
2003-09-24 02:36:35 +00:00
|
|
|
set_menus_for_selected_packet(capture_file *cf)
|
2000-01-03 03:57:04 +00:00
|
|
|
{
|
2003-04-22 00:16:58 +00:00
|
|
|
set_menu_sensitivity(main_menu_factory, "/File/Print Packet",
|
2003-09-24 02:36:35 +00:00
|
|
|
cf->current_frame != NULL);
|
2003-04-22 00:16:58 +00:00
|
|
|
set_menu_sensitivity(packet_list_menu_factory, "/Print Packet",
|
2003-09-24 02:36:35 +00:00
|
|
|
cf->current_frame != NULL);
|
2003-11-28 19:13:25 +00:00
|
|
|
set_menu_sensitivity(main_menu_factory, "/Edit/Mark Packet",
|
2003-09-24 02:36:35 +00:00
|
|
|
cf->current_frame != NULL);
|
2003-11-27 20:34:01 +00:00
|
|
|
set_menu_sensitivity(main_menu_factory, "/Edit/Time Reference",
|
|
|
|
cf->current_frame != NULL);
|
2003-11-28 19:13:25 +00:00
|
|
|
set_menu_sensitivity(packet_list_menu_factory, "/Mark Packet",
|
2003-09-24 02:36:35 +00:00
|
|
|
cf->current_frame != NULL);
|
2003-11-28 19:13:25 +00:00
|
|
|
set_menu_sensitivity(main_menu_factory, "/Edit/Mark All Packets",
|
2003-09-24 02:36:35 +00:00
|
|
|
cf->current_frame != NULL);
|
2003-11-28 19:13:25 +00:00
|
|
|
set_menu_sensitivity(main_menu_factory, "/Edit/Unmark All Packets",
|
2003-09-24 02:36:35 +00:00
|
|
|
cf->current_frame != NULL);
|
2003-11-27 20:34:01 +00:00
|
|
|
set_menu_sensitivity(main_menu_factory, "/View/Collapse All",
|
2003-09-24 02:36:35 +00:00
|
|
|
cf->current_frame != NULL);
|
2003-04-22 00:16:58 +00:00
|
|
|
set_menu_sensitivity(tree_view_menu_factory, "/Collapse All",
|
2003-09-24 02:36:35 +00:00
|
|
|
cf->current_frame != NULL);
|
2003-11-27 20:34:01 +00:00
|
|
|
set_menu_sensitivity(main_menu_factory, "/View/Expand All",
|
2003-09-24 02:36:35 +00:00
|
|
|
cf->current_frame != NULL);
|
2003-04-22 00:16:58 +00:00
|
|
|
set_menu_sensitivity(tree_view_menu_factory, "/Expand All",
|
2003-09-24 02:36:35 +00:00
|
|
|
cf->current_frame != NULL);
|
2003-11-27 20:34:01 +00:00
|
|
|
set_menu_sensitivity(main_menu_factory, "/View/Show Packet In New Window",
|
2003-09-24 02:36:35 +00:00
|
|
|
cf->current_frame != NULL);
|
2003-04-22 04:49:17 +00:00
|
|
|
set_menu_sensitivity(packet_list_menu_factory, "/Show Packet In New Window",
|
2003-09-24 02:36:35 +00:00
|
|
|
cf->current_frame != NULL);
|
2003-11-27 20:34:01 +00:00
|
|
|
set_menu_sensitivity(main_menu_factory, "/Analyze/Follow TCP Stream",
|
2003-09-24 02:36:35 +00:00
|
|
|
cf->current_frame != NULL ? (cf->edt->pi.ipproto == IP_PROTO_TCP) : FALSE);
|
2003-04-22 00:16:58 +00:00
|
|
|
set_menu_sensitivity(NULL, "/Follow TCP Stream",
|
2003-09-24 02:36:35 +00:00
|
|
|
cf->current_frame != NULL ? (cf->edt->pi.ipproto == IP_PROTO_TCP) : FALSE);
|
2003-11-28 19:13:25 +00:00
|
|
|
set_menu_sensitivity(main_menu_factory, "/Analyze/Decode As...",
|
2003-09-24 02:36:35 +00:00
|
|
|
cf->current_frame != NULL && decode_as_ok());
|
2003-04-22 00:16:58 +00:00
|
|
|
set_menu_sensitivity(NULL, "/Decode As...",
|
2003-09-24 02:36:35 +00:00
|
|
|
cf->current_frame != NULL && decode_as_ok());
|
2003-04-22 00:16:58 +00:00
|
|
|
set_menu_sensitivity(tree_view_menu_factory, "/Resolve Name",
|
2003-09-24 02:36:35 +00:00
|
|
|
cf->current_frame != NULL && g_resolv_flags == 0);
|
2003-11-27 20:34:01 +00:00
|
|
|
set_menu_sensitivity(main_menu_factory, "/Analyze/TCP Stream Analysis",
|
2003-09-24 02:36:35 +00:00
|
|
|
cf->current_frame != NULL ? (cf->edt->pi.ipproto == IP_PROTO_TCP) : FALSE);
|
|
|
|
walk_menu_tree_for_selected_packet(&tap_menu_tree_root, cf->current_frame,
|
|
|
|
cf->edt);
|
2000-08-15 20:46:17 +00:00
|
|
|
}
|
|
|
|
|
Enable "Match Selected" only if there's a field selected *and* we can do
a "Match Selected" on it - we can't do a "Match Selected" if the field
has no value (e.g., FT_NULL) and has a length of 0.
If we unselect the current packet, we don't have a protocol tree, so we
don't have a currently selected field - clear the "Match Selected" menu
item and the display in the status line of information about the
currently selected field.
Move the low-level statusbar manipulation into "gtk/main.c", in routines
whose API doesn't expose anything GTK+-ish.
"close_cap_file()" calls one of those routines to clear out the status
bar, so it doesn't need to take a pointer to the statusbar widget as an
argument.
"clear_tree_and_hex_views()" is purely a display-manipulating routine;
move it to "gtk/proto_draw.c".
Extract from "tree_view_unselect_row_cb()" an "unselect_field()" routine
to do all the work that needs to be done if the currently selected
protocol tree row is unselected, and call it if the currently selected
packet list row is unselected (if it's unselected, there *is* no
protocol tree, so no row can be selected), as well as from
"tree_view_unselect_row_cb()".
Before pushing a new field-description message onto the statusbar, pop
the old one off.
Get rid of an unused variable (set, but not used).
svn path=/trunk/; revision=3513
2001-06-05 07:39:31 +00:00
|
|
|
/* Enable or disable menu items based on whether a tree row is selected
|
2003-09-24 02:36:35 +00:00
|
|
|
and, if so, on the properties of the tree row. */
|
2003-09-19 07:24:39 +00:00
|
|
|
static gboolean
|
2003-09-24 02:36:35 +00:00
|
|
|
walk_menu_tree_for_selected_tree_row(menu_item_t *node, field_info *fi)
|
2003-09-19 07:24:39 +00:00
|
|
|
{
|
|
|
|
gboolean is_enabled;
|
|
|
|
menu_item_t *child;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Is this a leaf node or an interior node?
|
|
|
|
*/
|
|
|
|
if (node->children == NULL) {
|
|
|
|
/*
|
|
|
|
* It's a leaf node.
|
|
|
|
*
|
|
|
|
* If it has no "selected_tree_row_enabled()" routine,
|
|
|
|
* leave its enabled/disabled status alone - it
|
|
|
|
* doesn't depend on whether we have a tree row selected
|
|
|
|
* or not or on the selected tree row.
|
|
|
|
*
|
|
|
|
* If it has a "selected_tree_row_enabled()" routine,
|
|
|
|
* call it and set the item's enabled/disabled status
|
|
|
|
* based on its return value.
|
|
|
|
*/
|
2003-09-24 02:36:35 +00:00
|
|
|
if (node->selected_tree_row_enabled != NULL)
|
|
|
|
node->enabled = node->selected_tree_row_enabled(fi);
|
2003-09-19 07:24:39 +00:00
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* It's an interior node; call
|
|
|
|
* "walk_menu_tree_for_selected_tree_row()" on all its
|
|
|
|
* children and, if any of them are enabled, enable
|
|
|
|
* this node, otherwise disable it.
|
|
|
|
*
|
|
|
|
* XXX - should we just leave all interior nodes enabled?
|
|
|
|
* Which is a better UI choice?
|
|
|
|
*/
|
|
|
|
is_enabled = FALSE;
|
|
|
|
for (child = node->children; child != NULL; child =
|
|
|
|
child->next) {
|
2003-09-24 02:36:35 +00:00
|
|
|
if (walk_menu_tree_for_selected_tree_row(child, fi))
|
2003-09-19 07:24:39 +00:00
|
|
|
is_enabled = TRUE;
|
|
|
|
}
|
|
|
|
node->enabled = is_enabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The root node doesn't correspond to a menu tree item; it
|
|
|
|
* has a null name pointer.
|
|
|
|
*/
|
|
|
|
if (node->name != NULL) {
|
|
|
|
set_menu_sensitivity(main_menu_factory, node->name,
|
|
|
|
node->enabled);
|
|
|
|
}
|
|
|
|
return node->enabled;
|
|
|
|
}
|
|
|
|
|
2000-08-15 20:46:17 +00:00
|
|
|
void
|
2003-09-24 02:36:35 +00:00
|
|
|
set_menus_for_selected_tree_row(capture_file *cf)
|
2000-08-15 20:46:17 +00:00
|
|
|
{
|
2003-09-24 02:36:35 +00:00
|
|
|
gboolean properties;
|
Enable "Match Selected" only if there's a field selected *and* we can do
a "Match Selected" on it - we can't do a "Match Selected" if the field
has no value (e.g., FT_NULL) and has a length of 0.
If we unselect the current packet, we don't have a protocol tree, so we
don't have a currently selected field - clear the "Match Selected" menu
item and the display in the status line of information about the
currently selected field.
Move the low-level statusbar manipulation into "gtk/main.c", in routines
whose API doesn't expose anything GTK+-ish.
"close_cap_file()" calls one of those routines to clear out the status
bar, so it doesn't need to take a pointer to the statusbar widget as an
argument.
"clear_tree_and_hex_views()" is purely a display-manipulating routine;
move it to "gtk/proto_draw.c".
Extract from "tree_view_unselect_row_cb()" an "unselect_field()" routine
to do all the work that needs to be done if the currently selected
protocol tree row is unselected, and call it if the currently selected
packet list row is unselected (if it's unselected, there *is* no
protocol tree, so no row can be selected), as well as from
"tree_view_unselect_row_cb()".
Before pushing a new field-description message onto the statusbar, pop
the old one off.
Get rid of an unused variable (set, but not used).
svn path=/trunk/; revision=3513
2001-06-05 07:39:31 +00:00
|
|
|
|
2003-09-24 02:36:35 +00:00
|
|
|
if (cf->finfo_selected != NULL) {
|
2003-12-03 09:28:26 +00:00
|
|
|
header_field_info *hfinfo = cf->finfo_selected->hfinfo;
|
2000-08-15 20:46:17 +00:00
|
|
|
if (hfinfo->parent == -1) {
|
|
|
|
properties = prefs_is_registered_protocol(hfinfo->abbrev);
|
|
|
|
} else {
|
|
|
|
properties = prefs_is_registered_protocol(proto_registrar_get_abbrev(hfinfo->parent));
|
|
|
|
}
|
2003-09-24 02:36:35 +00:00
|
|
|
set_menu_sensitivity(main_menu_factory,
|
2003-11-28 19:13:25 +00:00
|
|
|
"/Edit/Go To Corresponding Packet", hfinfo->type == FT_FRAMENUM);
|
2003-09-24 02:36:35 +00:00
|
|
|
set_menu_sensitivity(tree_view_menu_factory,
|
2003-11-28 19:13:25 +00:00
|
|
|
"/Go To Corresponding Packet", hfinfo->type == FT_FRAMENUM);
|
2003-11-27 20:34:01 +00:00
|
|
|
set_menu_sensitivity(main_menu_factory, "/Analyze/Match",
|
2003-09-24 02:36:35 +00:00
|
|
|
proto_can_match_selected(cf->finfo_selected, cf->edt));
|
2003-04-22 00:16:58 +00:00
|
|
|
set_menu_sensitivity(tree_view_menu_factory, "/Match",
|
2003-09-24 02:36:35 +00:00
|
|
|
proto_can_match_selected(cf->finfo_selected, cf->edt));
|
2003-11-27 20:34:01 +00:00
|
|
|
set_menu_sensitivity(main_menu_factory, "/Analyze/Prepare",
|
2003-09-24 02:36:35 +00:00
|
|
|
proto_can_match_selected(cf->finfo_selected, cf->edt));
|
2003-04-22 00:16:58 +00:00
|
|
|
set_menu_sensitivity(tree_view_menu_factory, "/Prepare",
|
2003-09-24 02:36:35 +00:00
|
|
|
proto_can_match_selected(cf->finfo_selected, cf->edt));
|
|
|
|
set_menu_sensitivity(tree_view_menu_factory, "/Protocol Properties...",
|
|
|
|
properties);
|
2002-01-11 08:21:02 +00:00
|
|
|
} else {
|
2003-11-27 20:34:01 +00:00
|
|
|
set_menu_sensitivity(main_menu_factory,
|
2003-11-28 19:13:25 +00:00
|
|
|
"/Edit/Go To Corresponding Packet", FALSE);
|
2003-09-24 02:36:35 +00:00
|
|
|
set_menu_sensitivity(tree_view_menu_factory,
|
2003-11-28 19:13:25 +00:00
|
|
|
"/Go To Corresponding Packet", FALSE);
|
2003-11-27 20:34:01 +00:00
|
|
|
set_menu_sensitivity(main_menu_factory, "/Analyze/Match", FALSE);
|
2003-04-22 00:16:58 +00:00
|
|
|
set_menu_sensitivity(tree_view_menu_factory, "/Match", FALSE);
|
2003-11-27 20:34:01 +00:00
|
|
|
set_menu_sensitivity(main_menu_factory, "/Analyze/Prepare", FALSE);
|
2003-04-22 00:16:58 +00:00
|
|
|
set_menu_sensitivity(tree_view_menu_factory, "/Prepare", FALSE);
|
2003-09-24 02:36:35 +00:00
|
|
|
set_menu_sensitivity(tree_view_menu_factory, "/Protocol Properties...",
|
|
|
|
FALSE);
|
2002-01-11 08:21:02 +00:00
|
|
|
}
|
Enable "Match Selected" only if there's a field selected *and* we can do
a "Match Selected" on it - we can't do a "Match Selected" if the field
has no value (e.g., FT_NULL) and has a length of 0.
If we unselect the current packet, we don't have a protocol tree, so we
don't have a currently selected field - clear the "Match Selected" menu
item and the display in the status line of information about the
currently selected field.
Move the low-level statusbar manipulation into "gtk/main.c", in routines
whose API doesn't expose anything GTK+-ish.
"close_cap_file()" calls one of those routines to clear out the status
bar, so it doesn't need to take a pointer to the statusbar widget as an
argument.
"clear_tree_and_hex_views()" is purely a display-manipulating routine;
move it to "gtk/proto_draw.c".
Extract from "tree_view_unselect_row_cb()" an "unselect_field()" routine
to do all the work that needs to be done if the currently selected
protocol tree row is unselected, and call it if the currently selected
packet list row is unselected (if it's unselected, there *is* no
protocol tree, so no row can be selected), as well as from
"tree_view_unselect_row_cb()".
Before pushing a new field-description message onto the statusbar, pop
the old one off.
Get rid of an unused variable (set, but not used).
svn path=/trunk/; revision=3513
2001-06-05 07:39:31 +00:00
|
|
|
|
2003-09-24 02:36:35 +00:00
|
|
|
walk_menu_tree_for_selected_tree_row(&tap_menu_tree_root, cf->finfo_selected);
|
2000-01-03 03:57:04 +00:00
|
|
|
}
|