aboutsummaryrefslogtreecommitdiffstats
path: root/gtk
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>1999-11-06 06:28:07 +0000
committerGuy Harris <guy@alum.mit.edu>1999-11-06 06:28:07 +0000
commitf0889e55c1913a8ca89e2f0c2f1ad9b701fa8779 (patch)
treeacf447680007e0258ef70dea3e295601b5ca8195 /gtk
parentbba1ad82d1179e0fe43d2aab42f418613d8a3062 (diff)
Add a "Find Frame" menu item under "Display"; it lets you use a display
filter to search forward or backward in the list of displayed frames for a matching frame. When filtering the display, readjust the display to show the "current" frame if it passed the display filter. When a file is read in, the first frame becomes the "current" frame; when a frame is selected, it becomes the "current" frame, and remains so *even if you unselect it*, until another frame is selected. Select the first frame when a file is read in. Disable most of the "Display" and "Tools" menu items if there's no current capture file, and enable the relevant ones if there is. svn path=/trunk/; revision=982
Diffstat (limited to 'gtk')
-rw-r--r--gtk/Makefile.am4
-rw-r--r--gtk/find_dlg.c199
-rw-r--r--gtk/find_dlg.h31
-rw-r--r--gtk/main.c4
-rw-r--r--gtk/menu.c8
-rw-r--r--gtk/print_dlg.c4
6 files changed, 244 insertions, 6 deletions
diff --git a/gtk/Makefile.am b/gtk/Makefile.am
index c3f7c87d29..5744404934 100644
--- a/gtk/Makefile.am
+++ b/gtk/Makefile.am
@@ -1,7 +1,7 @@
# Makefile.am
# Automake file for the GTK interface routines for Ethereal
#
-# $Id: Makefile.am,v 1.8 1999/10/20 22:53:43 gram Exp $
+# $Id: Makefile.am,v 1.9 1999/11/06 06:28:07 guy Exp $
#
# Ethereal - Network traffic analyzer
# By Gerald Combs <gerald@zing.org>
@@ -36,6 +36,8 @@ libui_a_SOURCES = \
file_dlg.c \
filter_prefs.c \
filter_prefs.h \
+ find_dlg.c \
+ find_dlg.h \
gtkbindings.h \
gtkclist.c \
gtkclist.h \
diff --git a/gtk/find_dlg.c b/gtk/find_dlg.c
new file mode 100644
index 0000000000..4bd77fa433
--- /dev/null
+++ b/gtk/find_dlg.c
@@ -0,0 +1,199 @@
+/* find_dlg.c
+ * Routines for "find frame" window
+ *
+ * $Id: find_dlg.c,v 1.1 1999/11/06 06:27:09 guy Exp $
+ *
+ * Ethereal - Network traffic analyzer
+ * By Gerald Combs <gerald@zing.org>
+ * Copyright 1998 Gerald Combs
+ *
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#if 0
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#endif
+#include <gtk/gtk.h>
+
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#ifndef __G_LIB_H__
+#include <glib.h>
+#endif
+
+#include "proto.h"
+#include "dfilter.h"
+#include "globals.h"
+
+#if 0
+#include <time.h>
+
+#include <signal.h>
+#include <errno.h>
+
+#include <wiretap/wtap.h>
+#include "main.h"
+#endif
+#include "find_dlg.h"
+#include "prefs_dlg.h"
+#include "util.h"
+
+/* Capture callback data keys */
+#define E_FIND_FILT_KEY "find_filter_te"
+#define E_FIND_BACKWARD_KEY "find_backward"
+
+static void
+find_frame_ok_cb(GtkWidget *ok_bt, gpointer parent_w);
+
+static void
+find_frame_close_cb(GtkWidget *close_bt, gpointer parent_w);
+
+void
+find_frame_cb(GtkWidget *w, gpointer d)
+{
+ GtkWidget *find_frame_w, *main_vb, *filter_hb, *filter_bt, *filter_te,
+ *direction_hb, *forward_rb, *backward_rb,
+ *bbox, *ok_bt, *cancel_bt;
+
+ find_frame_w = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+ gtk_window_set_title(GTK_WINDOW(find_frame_w), "Ethereal: Find Frame");
+
+ /* Container for each row of widgets */
+ main_vb = gtk_vbox_new(FALSE, 3);
+ gtk_container_border_width(GTK_CONTAINER(main_vb), 5);
+ gtk_container_add(GTK_CONTAINER(find_frame_w), main_vb);
+ gtk_widget_show(main_vb);
+
+ /* Filter row */
+ filter_hb = gtk_hbox_new(FALSE, 3);
+ gtk_container_add(GTK_CONTAINER(main_vb), filter_hb);
+ gtk_widget_show(filter_hb);
+
+ filter_bt = gtk_button_new_with_label("Filter:");
+ gtk_signal_connect(GTK_OBJECT(filter_bt), "clicked",
+ GTK_SIGNAL_FUNC(prefs_cb), (gpointer) E_PR_PG_FILTER);
+ gtk_box_pack_start(GTK_BOX(filter_hb), filter_bt, FALSE, TRUE, 0);
+ gtk_widget_show(filter_bt);
+
+ filter_te = gtk_entry_new();
+ if (cf.sfilter) gtk_entry_set_text(GTK_ENTRY(filter_te), cf.sfilter);
+ gtk_object_set_data(GTK_OBJECT(filter_bt), E_FILT_TE_PTR_KEY, filter_te);
+ gtk_box_pack_start(GTK_BOX(filter_hb), filter_te, TRUE, TRUE, 0);
+ gtk_widget_show(filter_te);
+
+ /* Misc row: Forward and reverse radio buttons */
+ direction_hb = gtk_hbox_new(FALSE, 3);
+ gtk_container_add(GTK_CONTAINER(main_vb), direction_hb);
+ gtk_widget_show(direction_hb);
+
+ forward_rb = gtk_radio_button_new_with_label(NULL, "Forward");
+ gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(forward_rb), !cf.sbackward);
+ gtk_box_pack_start(GTK_BOX(direction_hb), forward_rb, TRUE, TRUE, 0);
+ gtk_widget_show(forward_rb);
+
+ backward_rb = gtk_radio_button_new_with_label(
+ gtk_radio_button_group(GTK_RADIO_BUTTON(forward_rb)),
+ "Backward");
+ gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(backward_rb), cf.sbackward);
+ gtk_box_pack_start(GTK_BOX(direction_hb), backward_rb, TRUE, TRUE, 0);
+ gtk_widget_show(backward_rb);
+
+ /* Button row: OK and cancel buttons */
+ bbox = gtk_hbutton_box_new();
+ gtk_button_box_set_layout (GTK_BUTTON_BOX (bbox), GTK_BUTTONBOX_END);
+ gtk_button_box_set_spacing(GTK_BUTTON_BOX(bbox), 5);
+ gtk_container_add(GTK_CONTAINER(main_vb), bbox);
+ gtk_widget_show(bbox);
+
+ ok_bt = gtk_button_new_with_label ("OK");
+ gtk_signal_connect(GTK_OBJECT(ok_bt), "clicked",
+ GTK_SIGNAL_FUNC(find_frame_ok_cb), GTK_OBJECT(find_frame_w));
+ GTK_WIDGET_SET_FLAGS(ok_bt, GTK_CAN_DEFAULT);
+ gtk_box_pack_start (GTK_BOX (bbox), ok_bt, TRUE, TRUE, 0);
+ gtk_widget_grab_default(ok_bt);
+ gtk_widget_show(ok_bt);
+
+ cancel_bt = gtk_button_new_with_label ("Cancel");
+ gtk_signal_connect(GTK_OBJECT(cancel_bt), "clicked",
+ GTK_SIGNAL_FUNC(find_frame_close_cb), GTK_OBJECT(find_frame_w));
+ GTK_WIDGET_SET_FLAGS(cancel_bt, GTK_CAN_DEFAULT);
+ gtk_box_pack_start (GTK_BOX (bbox), cancel_bt, TRUE, TRUE, 0);
+ gtk_widget_show(cancel_bt);
+
+ /* Attach pointers to needed widgets to the capture prefs window/object */
+ gtk_object_set_data(GTK_OBJECT(find_frame_w), E_FIND_FILT_KEY, filter_te);
+ gtk_object_set_data(GTK_OBJECT(find_frame_w), E_FIND_BACKWARD_KEY, backward_rb);
+
+ gtk_widget_show(find_frame_w);
+}
+
+static void
+find_frame_ok_cb(GtkWidget *ok_bt, gpointer parent_w)
+{
+ GtkWidget *filter_te, *backward_rb;
+ gchar *filter_text;
+ dfilter *sfcode;
+
+ filter_te = (GtkWidget *) gtk_object_get_data(GTK_OBJECT(parent_w), E_FIND_FILT_KEY);
+ backward_rb = (GtkWidget *) gtk_object_get_data(GTK_OBJECT(parent_w), E_FIND_BACKWARD_KEY);
+
+ filter_text = gtk_entry_get_text(GTK_ENTRY(filter_te));
+
+ /*
+ * Try to compile the filter.
+ */
+ if (dfilter_compile(filter_text, &sfcode) != 0) {
+ /* The attempt failed; report an error. */
+ simple_dialog(ESD_TYPE_WARN, NULL, dfilter_error_msg);
+ return;
+ }
+
+ /* Was it empty? */
+ if (sfcode == NULL) {
+ /* Yes - complain. */
+ simple_dialog(ESD_TYPE_WARN, NULL, "Blah blah blah");
+ return;
+ }
+
+ /*
+ * Remember the filter.
+ */
+ if (cf.sfilter)
+ g_free(cf.sfilter);
+ cf.sfilter = g_strdup(filter_text);
+
+ cf.sbackward = GTK_TOGGLE_BUTTON (backward_rb)->active;
+
+ gtk_widget_destroy(GTK_WIDGET(parent_w));
+
+ find_packet(&cf, sfcode);
+}
+
+static void
+find_frame_close_cb(GtkWidget *close_bt, gpointer parent_w)
+{
+ gtk_grab_remove(GTK_WIDGET(parent_w));
+ gtk_widget_destroy(GTK_WIDGET(parent_w));
+}
diff --git a/gtk/find_dlg.h b/gtk/find_dlg.h
new file mode 100644
index 0000000000..dd7518b018
--- /dev/null
+++ b/gtk/find_dlg.h
@@ -0,0 +1,31 @@
+/* find_dlg.h
+ * Definitions for "find frame" window
+ *
+ * $Id: find_dlg.h,v 1.1 1999/11/06 06:27:09 guy Exp $
+ *
+ * Ethereal - Network traffic analyzer
+ * By Gerald Combs <gerald@zing.org>
+ * Copyright 1998 Gerald Combs
+ *
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __FIND_DLG_H__
+#define __FIND_DLG_H__
+
+void find_frame_cb(GtkWidget *, gpointer);
+
+#endif /* find_dlg.h */
diff --git a/gtk/main.c b/gtk/main.c
index 655c89e5df..c940e80933 100644
--- a/gtk/main.c
+++ b/gtk/main.c
@@ -1,6 +1,6 @@
/* main.c
*
- * $Id: main.c,v 1.31 1999/11/04 21:04:35 guy Exp $
+ * $Id: main.c,v 1.32 1999/11/06 06:27:07 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -564,7 +564,7 @@ tree_view_cb(GtkWidget *w, gpointer data) {
gtk_text_set_point(GTK_TEXT(byte_view), 0);
gtk_text_forward_delete(GTK_TEXT(byte_view),
gtk_text_get_length(GTK_TEXT(byte_view)));
- packet_hex_print(GTK_TEXT(byte_view), cf.pd, cf.fd->cap_len,
+ packet_hex_print(GTK_TEXT(byte_view), cf.pd, cf.current_frame->cap_len,
tree_selected_start,
tree_selected_len);
diff --git a/gtk/menu.c b/gtk/menu.c
index e3302ff7c7..a1a54145b0 100644
--- a/gtk/menu.c
+++ b/gtk/menu.c
@@ -1,7 +1,7 @@
/* menu.c
* Menu routines
*
- * $Id: menu.c,v 1.5 1999/10/18 12:48:14 gram Exp $
+ * $Id: menu.c,v 1.6 1999/11/06 06:27:08 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -40,6 +40,7 @@
#include "menu.h"
#include "packet.h"
#include "capture_dlg.h"
+#include "find_dlg.h"
#include "summary.h"
#include "display_opts.h"
#include "prefs_dlg.h"
@@ -101,6 +102,7 @@ static GtkItemFactoryEntry menu_items[] =
{"/Display/_Options...", NULL, GTK_MENU_FUNC(display_opt_cb), 0, NULL},
{"/Display/_Match Selected", NULL, GTK_MENU_FUNC(match_selected_cb), 0, NULL},
{"/Display/_Colorize Display...", NULL, GTK_MENU_FUNC(color_display_cb), 0, NULL},
+ {"/Display/_Find Frame...", "<control>F", GTK_MENU_FUNC(find_frame_cb), 0, NULL},
{"/Display/Collapse _All", NULL, GTK_MENU_FUNC(collapse_all_cb), 0, NULL},
{"/Display/_Expand All", NULL, GTK_MENU_FUNC(expand_all_cb), 0, NULL},
{"/_Tools", NULL, NULL, 0, "<Branch>" },
@@ -150,8 +152,12 @@ menus_init(void) {
set_menu_sensitivity("/Edit/Copy", FALSE);
set_menu_sensitivity("/Edit/Paste", FALSE);
set_menu_sensitivity("/Edit/Find", FALSE);
+ set_menu_sensitivity("/Display/Match Selected", FALSE);
+ set_menu_sensitivity("/Display/Colorize Display...", FALSE);
+ set_menu_sensitivity("/Display/Find Frame...", FALSE);
set_menu_sensitivity("/Display/Collapse All", FALSE);
set_menu_sensitivity("/Display/Expand All", FALSE);
+ set_menu_sensitivity("/Tools/Follow TCP Stream", FALSE);
set_menu_sensitivity("/Tools/Graph", FALSE);
set_menu_sensitivity("/Tools/Summary", FALSE);
}
diff --git a/gtk/print_dlg.c b/gtk/print_dlg.c
index 618f2c5079..079792573c 100644
--- a/gtk/print_dlg.c
+++ b/gtk/print_dlg.c
@@ -1,7 +1,7 @@
/* print_dlg.c
* Dialog boxes for printing
*
- * $Id: print_dlg.c,v 1.8 1999/09/29 22:25:41 guy Exp $
+ * $Id: print_dlg.c,v 1.9 1999/11/06 06:27:07 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -480,7 +480,7 @@ file_print_packet_cmd_cb(GtkWidget *widget, gpointer data) {
print_args.print_hex = FALSE;
print_args.expand_all = TRUE;
proto_tree_print(TRUE, &print_args, (GNode*) cf.protocol_tree, cf.pd,
- cf.fd, fh);
+ cf.current_frame, fh);
print_finale(fh);
close_print_dest(print_args.to_file, fh);
}