forked from osmocom/wireshark
Jerry Talkington's changes to support, in the packet list and protocol
tree panes, menus popped up by the right mouse button. svn path=/trunk/; revision=1504
This commit is contained in:
parent
4aaff9af74
commit
4603877dc4
1
AUTHORS
1
AUTHORS
|
@ -195,6 +195,7 @@ Jerry Talkington <jerryt@netapp.com> {
|
||||||
updates to HTTP support
|
updates to HTTP support
|
||||||
Filter selection/editing GUI improvements
|
Filter selection/editing GUI improvements
|
||||||
WCCP 1.0 support
|
WCCP 1.0 support
|
||||||
|
Right-mouse-button menu support
|
||||||
}
|
}
|
||||||
|
|
||||||
Dave Chapeskie <dchapes@ddm.on.ca> {
|
Dave Chapeskie <dchapes@ddm.on.ca> {
|
||||||
|
|
|
@ -316,11 +316,13 @@ through and select. The packet number, packet timestamp, source and
|
||||||
destination addresses, protocol, and description are printed for each
|
destination addresses, protocol, and description are printed for each
|
||||||
packet. An effort is made to display information as high up the protocol
|
packet. An effort is made to display information as high up the protocol
|
||||||
stack as possible, e.g. IP addresses are displayed for IP packets, but the
|
stack as possible, e.g. IP addresses are displayed for IP packets, but the
|
||||||
MAC layer address is displayed for unknown packet types.
|
MAC layer address is displayed for unknown packet types. The right
|
||||||
|
mouse button can be used to pop up a menu of operations.
|
||||||
|
|
||||||
The middle pane contains a I<protocol tree> for the currently-selected
|
The middle pane contains a I<protocol tree> for the currently-selected
|
||||||
packet. The tree displays each field and its value in each protocol header
|
packet. The tree displays each field and its value in each protocol
|
||||||
in the stack.
|
header in the stack. The right mouse button can be used to pop up a
|
||||||
|
menu of operations.
|
||||||
|
|
||||||
The lowest pane contains a hex dump of the actual packet data.
|
The lowest pane contains a hex dump of the actual packet data.
|
||||||
Selecting a field in the I<protocol tree> highlights the corresponding
|
Selecting a field in the I<protocol tree> highlights the corresponding
|
||||||
|
|
7
file.c
7
file.c
|
@ -1,7 +1,7 @@
|
||||||
/* file.c
|
/* file.c
|
||||||
* File I/O routines
|
* File I/O routines
|
||||||
*
|
*
|
||||||
* $Id: file.c,v 1.153 2000/01/15 00:22:30 gram Exp $
|
* $Id: file.c,v 1.154 2000/01/18 08:37:55 guy Exp $
|
||||||
*
|
*
|
||||||
* Ethereal - Network traffic analyzer
|
* Ethereal - Network traffic analyzer
|
||||||
* By Gerald Combs <gerald@zing.org>
|
* By Gerald Combs <gerald@zing.org>
|
||||||
|
@ -310,8 +310,6 @@ read_cap_file(capture_file *cf)
|
||||||
cf->filed = open(cf->filename, O_RDONLY);
|
cf->filed = open(cf->filename, O_RDONLY);
|
||||||
cf->fh = filed_open(cf->filed, "r");
|
cf->fh = filed_open(cf->filed, "r");
|
||||||
cf->current_frame = cf->first_displayed;
|
cf->current_frame = cf->first_displayed;
|
||||||
/* Make the first row the selected row. */
|
|
||||||
gtk_clist_select_row(GTK_CLIST(packet_list), 0, -1);
|
|
||||||
thaw_clist(cf);
|
thaw_clist(cf);
|
||||||
|
|
||||||
gtk_progress_set_activity_mode(GTK_PROGRESS(prog_bar), FALSE);
|
gtk_progress_set_activity_mode(GTK_PROGRESS(prog_bar), FALSE);
|
||||||
|
@ -328,6 +326,9 @@ read_cap_file(capture_file *cf)
|
||||||
/* Enable menu items that make sense if you have some captured packets. */
|
/* Enable menu items that make sense if you have some captured packets. */
|
||||||
set_menus_for_captured_packets(TRUE);
|
set_menus_for_captured_packets(TRUE);
|
||||||
|
|
||||||
|
/* Make the first row the selected row. */
|
||||||
|
gtk_signal_emit_by_name(GTK_OBJECT(packet_list), "select_row", 0);
|
||||||
|
|
||||||
if (!success) {
|
if (!success) {
|
||||||
/* Put up a message box noting that the read failed somewhere along
|
/* Put up a message box noting that the read failed somewhere along
|
||||||
the line. Don't throw out the stuff we managed to read, though,
|
the line. Don't throw out the stuff we managed to read, though,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/* keys.h
|
/* keys.h
|
||||||
* Key definitions for various objects
|
* Key definitions for various objects
|
||||||
*
|
*
|
||||||
* $Id: keys.h,v 1.9 2000/01/06 07:33:33 guy Exp $
|
* $Id: keys.h,v 1.10 2000/01/18 08:38:16 guy Exp $
|
||||||
*
|
*
|
||||||
* Ethereal - Network traffic analyzer
|
* Ethereal - Network traffic analyzer
|
||||||
* By Gerald Combs <gerald@zing.org>
|
* By Gerald Combs <gerald@zing.org>
|
||||||
|
@ -40,4 +40,8 @@
|
||||||
|
|
||||||
#define PLUGINS_DFILTER_TE "plugins_dfilter_te"
|
#define PLUGINS_DFILTER_TE "plugins_dfilter_te"
|
||||||
|
|
||||||
|
#define PM_MENU_LIST_KEY "popup_menu_menu_list"
|
||||||
|
#define PM_PACKET_LIST_KEY "popup_menu_packet_list"
|
||||||
|
#define PM_TREE_VIEW_KEY "popup_menu_tree_view"
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* main.c
|
/* main.c
|
||||||
*
|
*
|
||||||
* $Id: main.c,v 1.91 2000/01/16 02:48:12 guy Exp $
|
* $Id: main.c,v 1.92 2000/01/18 08:38:16 guy Exp $
|
||||||
*
|
*
|
||||||
* Ethereal - Network traffic analyzer
|
* Ethereal - Network traffic analyzer
|
||||||
* By Gerald Combs <gerald@zing.org>
|
* By Gerald Combs <gerald@zing.org>
|
||||||
|
@ -1539,6 +1539,8 @@ create_main_window (gint pl_size, gint tv_size, gint bv_size, e_prefs *prefs)
|
||||||
get_column_longest_string(get_column_format(i)));
|
get_column_longest_string(get_column_format(i)));
|
||||||
}
|
}
|
||||||
gtk_widget_set_usize(packet_list, -1, pl_size);
|
gtk_widget_set_usize(packet_list, -1, pl_size);
|
||||||
|
gtk_signal_connect_object(GTK_OBJECT(packet_list), "button_press_event",
|
||||||
|
GTK_SIGNAL_FUNC(popup_menu_handler), gtk_object_get_data(GTK_OBJECT(popup_menu_object), PM_PACKET_LIST_KEY));
|
||||||
gtk_widget_show(packet_list);
|
gtk_widget_show(packet_list);
|
||||||
|
|
||||||
/* Tree view */
|
/* Tree view */
|
||||||
|
@ -1562,6 +1564,8 @@ create_main_window (gint pl_size, gint tv_size, gint bv_size, e_prefs *prefs)
|
||||||
GTK_SIGNAL_FUNC(tree_view_select_row_cb), NULL);
|
GTK_SIGNAL_FUNC(tree_view_select_row_cb), NULL);
|
||||||
gtk_signal_connect(GTK_OBJECT(tree_view), "tree-unselect-row",
|
gtk_signal_connect(GTK_OBJECT(tree_view), "tree-unselect-row",
|
||||||
GTK_SIGNAL_FUNC(tree_view_unselect_row_cb), NULL);
|
GTK_SIGNAL_FUNC(tree_view_unselect_row_cb), NULL);
|
||||||
|
gtk_signal_connect_object(GTK_OBJECT(tree_view), "button_press_event",
|
||||||
|
GTK_SIGNAL_FUNC(popup_menu_handler), gtk_object_get_data(GTK_OBJECT(popup_menu_object), PM_TREE_VIEW_KEY));
|
||||||
gtk_widget_show(tree_view);
|
gtk_widget_show(tree_view);
|
||||||
|
|
||||||
item_style = gtk_style_new();
|
item_style = gtk_style_new();
|
||||||
|
|
108
gtk/menu.c
108
gtk/menu.c
|
@ -1,7 +1,7 @@
|
||||||
/* menu.c
|
/* menu.c
|
||||||
* Menu routines
|
* Menu routines
|
||||||
*
|
*
|
||||||
* $Id: menu.c,v 1.17 2000/01/17 17:12:42 oabad Exp $
|
* $Id: menu.c,v 1.18 2000/01/18 08:38:18 guy Exp $
|
||||||
*
|
*
|
||||||
* Ethereal - Network traffic analyzer
|
* Ethereal - Network traffic analyzer
|
||||||
* By Gerald Combs <gerald@zing.org>
|
* By Gerald Combs <gerald@zing.org>
|
||||||
|
@ -28,6 +28,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
#include <glib.h>
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -50,6 +51,7 @@
|
||||||
#include "print.h"
|
#include "print.h"
|
||||||
#include "follow.h"
|
#include "follow.h"
|
||||||
#include "colors.h"
|
#include "colors.h"
|
||||||
|
#include "keys.h"
|
||||||
#include "plugins.h"
|
#include "plugins.h"
|
||||||
|
|
||||||
#define GTK_MENU_FUNC(a) ((GtkItemFactoryCallback)(a))
|
#define GTK_MENU_FUNC(a) ((GtkItemFactoryCallback)(a))
|
||||||
|
@ -80,6 +82,7 @@ static void set_menu_sensitivity (gchar *, gint);
|
||||||
"<LastBranch>" -> create a right justified branch
|
"<LastBranch>" -> create a right justified branch
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* main menu */
|
||||||
static GtkItemFactoryEntry menu_items[] =
|
static GtkItemFactoryEntry menu_items[] =
|
||||||
{
|
{
|
||||||
{"/_File", NULL, NULL, 0, "<Branch>" },
|
{"/_File", NULL, NULL, 0, "<Branch>" },
|
||||||
|
@ -128,8 +131,35 @@ static GtkItemFactoryEntry menu_items[] =
|
||||||
/* calculate the number of menu_items */
|
/* calculate the number of menu_items */
|
||||||
static int nmenu_items = sizeof(menu_items) / sizeof(menu_items[0]);
|
static int nmenu_items = sizeof(menu_items) / sizeof(menu_items[0]);
|
||||||
|
|
||||||
|
/* packet list popup */
|
||||||
|
static GtkItemFactoryEntry packet_list_menu_items[] =
|
||||||
|
{
|
||||||
|
{"/Match Selected", NULL, GTK_MENU_FUNC(match_selected_cb), 0, NULL},
|
||||||
|
{"/Follow TCP Stream", NULL, GTK_MENU_FUNC(follow_stream_cb), 0, NULL},
|
||||||
|
{"/Filters...", NULL, GTK_MENU_FUNC(filter_dialog_cb), 0, NULL},
|
||||||
|
{"/<separator>", NULL, NULL, 0, "<Separator>"},
|
||||||
|
{"/Colorize Display...", NULL, GTK_MENU_FUNC(color_display_cb), 0, NULL},
|
||||||
|
{"/Print...", NULL, GTK_MENU_FUNC(file_print_cmd_cb), 0, NULL},
|
||||||
|
{"/Print Packet", NULL, GTK_MENU_FUNC(file_print_packet_cmd_cb), 0, NULL},
|
||||||
|
};
|
||||||
|
|
||||||
|
static GtkItemFactoryEntry tree_view_menu_items[] =
|
||||||
|
{
|
||||||
|
{"/Match Selected", NULL, GTK_MENU_FUNC(match_selected_cb), 0, NULL},
|
||||||
|
{"/Follow TCP Stream", NULL, GTK_MENU_FUNC(follow_stream_cb), 0, NULL},
|
||||||
|
{"/Filters...", NULL, GTK_MENU_FUNC(filter_dialog_cb), 0, NULL},
|
||||||
|
{"/<separator>", NULL, NULL, 0, "<Separator>"},
|
||||||
|
{"/Collapse All", NULL, GTK_MENU_FUNC(collapse_all_cb), 0, NULL},
|
||||||
|
{"/Expand All", NULL, GTK_MENU_FUNC(expand_all_cb), 0, NULL}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
static int initialize = TRUE;
|
static int initialize = TRUE;
|
||||||
static GtkItemFactory *factory = NULL;
|
static GtkItemFactory *factory = NULL;
|
||||||
|
static GtkItemFactory *packet_list_menu_factory = NULL;
|
||||||
|
static GtkItemFactory *tree_view_menu_factory = NULL;
|
||||||
|
|
||||||
|
static GSList *popup_menu_list = NULL;
|
||||||
|
|
||||||
static GtkAccelGroup *grp;
|
static GtkAccelGroup *grp;
|
||||||
|
|
||||||
|
@ -138,8 +168,10 @@ get_main_menu(GtkWidget ** menubar, GtkAccelGroup ** table) {
|
||||||
|
|
||||||
grp = gtk_accel_group_new();
|
grp = gtk_accel_group_new();
|
||||||
|
|
||||||
if (initialize)
|
if (initialize) {
|
||||||
|
popup_menu_object = gtk_widget_new(GTK_TYPE_WIDGET, NULL);
|
||||||
menus_init();
|
menus_init();
|
||||||
|
}
|
||||||
|
|
||||||
if (menubar)
|
if (menubar)
|
||||||
*menubar = factory->widget;
|
*menubar = factory->widget;
|
||||||
|
@ -154,6 +186,18 @@ menus_init(void) {
|
||||||
if (initialize) {
|
if (initialize) {
|
||||||
initialize = FALSE;
|
initialize = FALSE;
|
||||||
|
|
||||||
|
/* popup */
|
||||||
|
|
||||||
|
packet_list_menu_factory = gtk_item_factory_new(GTK_TYPE_MENU, "<main>", NULL);
|
||||||
|
gtk_item_factory_create_items_ac(packet_list_menu_factory, sizeof(packet_list_menu_items)/sizeof(packet_list_menu_items[0]), packet_list_menu_items, NULL, 2);
|
||||||
|
gtk_object_set_data(GTK_OBJECT(popup_menu_object), PM_PACKET_LIST_KEY, packet_list_menu_factory->widget);
|
||||||
|
popup_menu_list = g_slist_append((GSList *)popup_menu_list, packet_list_menu_factory);
|
||||||
|
|
||||||
|
tree_view_menu_factory = gtk_item_factory_new(GTK_TYPE_MENU, "<main>", NULL);
|
||||||
|
gtk_item_factory_create_items_ac(tree_view_menu_factory, sizeof(tree_view_menu_items)/sizeof(tree_view_menu_items[0]), tree_view_menu_items, NULL, 2);
|
||||||
|
gtk_object_set_data(GTK_OBJECT(popup_menu_object), PM_TREE_VIEW_KEY, tree_view_menu_factory->widget);
|
||||||
|
popup_menu_list = g_slist_append((GSList *)popup_menu_list, tree_view_menu_factory);
|
||||||
|
|
||||||
factory = gtk_item_factory_new(GTK_TYPE_MENU_BAR, "<main>", grp);
|
factory = gtk_item_factory_new(GTK_TYPE_MENU_BAR, "<main>", grp);
|
||||||
gtk_item_factory_create_items_ac(factory, nmenu_items, menu_items, NULL,2);
|
gtk_item_factory_create_items_ac(factory, nmenu_items, menu_items, NULL,2);
|
||||||
set_menus_for_unsaved_capture_file(FALSE);
|
set_menus_for_unsaved_capture_file(FALSE);
|
||||||
|
@ -167,20 +211,68 @@ menus_init(void) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
set_menu_sensitivity_meat(GtkItemFactory *ifactory, gchar *path, gint val) {
|
||||||
|
GtkWidget *menu = NULL;
|
||||||
|
|
||||||
|
if((menu = gtk_item_factory_get_widget(ifactory, path)) != NULL) {
|
||||||
|
gtk_widget_set_sensitive(menu,val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
set_menu_sensitivity (gchar *path, gint val) {
|
set_menu_sensitivity (gchar *path, gint val) {
|
||||||
GtkWidget *menu;
|
GSList *menu_list = popup_menu_list;
|
||||||
|
gchar *shortpath = rindex(path, '/');
|
||||||
|
|
||||||
if ((menu = gtk_item_factory_get_widget(factory, path)) != NULL)
|
set_menu_sensitivity_meat(factory, path, val);
|
||||||
gtk_widget_set_sensitive(menu, val);
|
|
||||||
|
while (menu_list != NULL) {
|
||||||
|
set_menu_sensitivity_meat(menu_list->data, shortpath, val);
|
||||||
|
menu_list = g_slist_next(menu_list);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
set_menu_object_data_meat(GtkItemFactory *ifactory, gchar *path, gchar *key, gpointer data)
|
||||||
|
{
|
||||||
|
GtkWidget *menu = NULL;
|
||||||
|
|
||||||
|
if ((menu = gtk_item_factory_get_widget(ifactory, path)) != NULL)
|
||||||
|
gtk_object_set_data(GTK_OBJECT(menu), key, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
set_menu_object_data (gchar *path, gchar *key, gpointer data) {
|
set_menu_object_data (gchar *path, gchar *key, gpointer data) {
|
||||||
GtkWidget *menu;
|
GSList *menu_list = popup_menu_list;
|
||||||
|
gchar *shortpath = rindex(path, '/');
|
||||||
|
|
||||||
if ((menu = gtk_item_factory_get_widget(factory, path)) != NULL)
|
set_menu_object_data_meat(factory, path, key, data);
|
||||||
gtk_object_set_data(GTK_OBJECT(menu), key, data);
|
while (menu_list != NULL) {
|
||||||
|
set_menu_object_data_meat(menu_list->data, shortpath, key, data);
|
||||||
|
menu_list = g_slist_next(menu_list);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
popup_menu_handler(GtkWidget *widget, GdkEvent *event)
|
||||||
|
{
|
||||||
|
GtkWidget *menu = NULL;
|
||||||
|
GdkEventButton *event_button = NULL;
|
||||||
|
|
||||||
|
if(widget == NULL || event == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
menu = widget;
|
||||||
|
if(event->type == GDK_BUTTON_PRESS) {
|
||||||
|
event_button = (GdkEventButton *) event;
|
||||||
|
|
||||||
|
if(event_button->button == 3) {
|
||||||
|
gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, event_button->button, event_button->time);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Enable or disable menu items based on whether you have a capture file
|
/* Enable or disable menu items based on whether you have a capture file
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/* menu.h
|
/* menu.h
|
||||||
* Menu definitions
|
* Menu definitions
|
||||||
*
|
*
|
||||||
* $Id: menu.h,v 1.3 2000/01/03 04:06:09 guy Exp $
|
* $Id: menu.h,v 1.4 2000/01/18 08:38:18 guy Exp $
|
||||||
*
|
*
|
||||||
* Ethereal - Network traffic analyzer
|
* Ethereal - Network traffic analyzer
|
||||||
* By Gerald Combs <gerald@zing.org>
|
* By Gerald Combs <gerald@zing.org>
|
||||||
|
@ -32,6 +32,9 @@ extern "C" {
|
||||||
|
|
||||||
void get_main_menu (GtkWidget **, GtkAccelGroup **);
|
void get_main_menu (GtkWidget **, GtkAccelGroup **);
|
||||||
void set_menu_object_data (gchar *path, gchar *key, gpointer data);
|
void set_menu_object_data (gchar *path, gchar *key, gpointer data);
|
||||||
|
void popup_menu_handler(GtkWidget *widget, GdkEvent *event);
|
||||||
|
|
||||||
|
GtkWidget *popup_menu_object;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue