aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>2003-12-19 23:41:55 +0000
committerguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>2003-12-19 23:41:55 +0000
commit2b9c65696f9ab219a16222999b8f5466b7501477 (patch)
tree1e98a2488910ce5e2ef9e67ab11250ecedf6b3b6
parent4d7a0de6b1d33dbca67a39b2da819038c00a9ac6 (diff)
From Lars Roland:
use the common display filter dialog infrastructure in the MGCP service response time tap; add common infrastructure for updating the titles of tap dialogs when the capture file name changes. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@9366 f5534014-38df-0310-8fa8-9805f1628bb7
-rw-r--r--Makefile.am3
-rw-r--r--file.c4
-rw-r--r--gtk/h225_counter.c3
-rw-r--r--gtk/h225_ras_srt.c3
-rw-r--r--gtk/mgcp_stat.c138
-rw-r--r--gtk/tap_dfilter_dlg.c48
-rw-r--r--gtk/tap_dfilter_dlg.h39
-rw-r--r--tap_dfilter_dlg.h62
8 files changed, 115 insertions, 185 deletions
diff --git a/Makefile.am b/Makefile.am
index 4773e41b4e..3e24534d76 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,7 +1,7 @@
# Makefile.am
# Automake file for Ethereal
#
-# $Id: Makefile.am,v 1.673 2003/12/18 18:56:36 guy Exp $
+# $Id: Makefile.am,v 1.674 2003/12/19 23:39:53 guy Exp $
#
# Ethereal - Network traffic analyzer
# By Gerald Combs <gerald@ethereal.com>
@@ -850,6 +850,7 @@ ETHEREAL_COMMON_SRC = \
t35.h \
tap.c \
tap.h \
+ tap_dfilter_dlg.h \
timestats.c \
timestats.h \
util.c \
diff --git a/file.c b/file.c
index 9aadbe9ddd..18456d6fb2 100644
--- a/file.c
+++ b/file.c
@@ -1,7 +1,7 @@
/* file.c
* File I/O routines
*
- * $Id: file.c,v 1.330 2003/12/13 18:01:29 ulfl Exp $
+ * $Id: file.c,v 1.331 2003/12/19 23:39:53 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -79,6 +79,7 @@
#include "globals.h"
#include <epan/epan_dissect.h>
#include "tap.h"
+#include "tap_dfilter_dlg.h"
#include "packet-data.h"
#ifdef HAVE_LIBPCAP
@@ -347,6 +348,7 @@ cf_read(capture_file *cf, int *err)
cul_bytes=0;
reset_tap_listeners();
+ tap_dfilter_dlg_update();
name_ptr = get_basename(cf->filename);
msg_len = strlen(name_ptr) + strlen(load_fmt) + 2;
diff --git a/gtk/h225_counter.c b/gtk/h225_counter.c
index afc9fabcb1..d9bbd917ec 100644
--- a/gtk/h225_counter.c
+++ b/gtk/h225_counter.c
@@ -2,7 +2,7 @@
* h225 message counter for ethereal
* Copyright 2003 Lars Roland
*
- * $Id: h225_counter.c,v 1.5 2003/12/17 22:13:07 guy Exp $
+ * $Id: h225_counter.c,v 1.6 2003/12/19 23:41:55 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -48,6 +48,7 @@
#include "dlg_utils.h"
#include "../file.h"
#include "../globals.h"
+#include "../tap_dfilter_dlg.h"
#include "tap_dfilter_dlg.h"
extern GtkWidget *main_display_filter_widget;
diff --git a/gtk/h225_ras_srt.c b/gtk/h225_ras_srt.c
index e55157f2a4..e9e8ccfc24 100644
--- a/gtk/h225_ras_srt.c
+++ b/gtk/h225_ras_srt.c
@@ -2,7 +2,7 @@
* h225 RAS Service Response Time statistics for ethereal
* Copyright 2003 Lars Roland
*
- * $Id: h225_ras_srt.c,v 1.4 2003/12/17 22:13:07 guy Exp $
+ * $Id: h225_ras_srt.c,v 1.5 2003/12/19 23:41:55 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -49,6 +49,7 @@
#include "dlg_utils.h"
#include "../file.h"
#include "../globals.h"
+#include "../tap_dfilter_dlg.h"
#include "tap_dfilter_dlg.h"
extern GtkWidget *main_display_filter_widget;
diff --git a/gtk/mgcp_stat.c b/gtk/mgcp_stat.c
index c02828fc4b..9ffe254c83 100644
--- a/gtk/mgcp_stat.c
+++ b/gtk/mgcp_stat.c
@@ -2,7 +2,7 @@
* mgcp-statistics for ethereal
* Copyright 2003 Lars Roland
*
- * $Id: mgcp_stat.c,v 1.20 2003/12/17 22:13:07 guy Exp $
+ * $Id: mgcp_stat.c,v 1.21 2003/12/19 23:41:55 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -49,6 +49,8 @@
#include "dlg_utils.h"
#include "../file.h"
#include "../globals.h"
+#include "../tap_dfilter_dlg.h"
+#include "tap_dfilter_dlg.h"
extern GtkWidget *main_display_filter_widget;
@@ -81,16 +83,11 @@ static const value_string mgcp_mesage_type[] = {
{ 0, NULL}
};
-static GtkWidget *dlg=NULL;
-static GtkWidget *filter_entry;
-
-
static void
mgcpstat_reset(void *pms)
{
mgcpstat_t *ms=(mgcpstat_t *)pms;
int i;
- char *title;
for(i=0;i<NUM_TIMESTATS;i++) {
ms->rtd[i].num=0;
@@ -108,12 +105,6 @@ mgcpstat_reset(void *pms)
ms->disc_rsp_num=0;
ms->req_dup_num=0;
ms->rsp_dup_num=0;
-
- if (! dlg)
- dlg=gtk_window_new(GTK_WINDOW_TOPLEVEL);
- title = g_strdup_printf("MGCP SRT statistics: %s", cf_get_display_name(&cfile));
- gtk_window_set_title(GTK_WINDOW(dlg), title);
- g_free(title);
}
@@ -310,126 +301,7 @@ gtk_mgcpstat_init(char *optarg)
redissect_packets(&cfile);
}
-
-static void
-dlg_destroy_cb(void)
-{
- dlg=NULL;
-}
-
-static void
-dlg_cancel_cb(GtkWidget *cancel_bt _U_, gpointer parent_w)
-{
- gtk_widget_destroy(GTK_WIDGET(parent_w));
-}
-
-static void
-mgcpstat_start_button_clicked(GtkWidget *item _U_, gpointer data _U_)
-{
- char *filter;
- char str[256];
-
- filter=(char *)gtk_entry_get_text(GTK_ENTRY(filter_entry));
- if(filter[0]==0){
- gtk_mgcpstat_init("mgcp,srt");
- } else {
- sprintf(str,"mgcp,srt,%s", filter);
- gtk_mgcpstat_init(str);
- }
-}
-
-
-
-static void
-gtk_mgcpstat_cb(GtkWidget *w _U_, gpointer d _U_)
-{
- const char *filter;
- char *title;
- GtkWidget *dlg_box;
- GtkWidget *filter_box, *filter_label;
- GtkWidget *bbox, *start_button, *cancel_button;
-
- /* if the window is already open, bring it to front */
- if(dlg){
- gdk_window_raise(dlg->window);
- return;
- }
-
- title = g_strdup_printf("Ethereal: Compute MGCP SRT statistics: %s", cf_get_display_name(&cfile));
-
- dlg=dlg_window_new(title);
- g_free(title);
- SIGNAL_CONNECT(dlg, "destroy", dlg_destroy_cb, NULL);
-
- dlg_box=gtk_vbox_new(FALSE, 10);
- gtk_container_border_width(GTK_CONTAINER(dlg_box), 10);
- gtk_container_add(GTK_CONTAINER(dlg), dlg_box);
- gtk_widget_show(dlg_box);
-
- /* Filter box */
- filter_box=gtk_hbox_new(FALSE, 3);
-
- /* Filter label */
- filter_label=gtk_label_new("Filter:");
- gtk_box_pack_start(GTK_BOX(filter_box), filter_label, FALSE, FALSE, 0);
- gtk_widget_show(filter_label);
-
- /* Filter entry */
- filter_entry=gtk_entry_new();
- WIDGET_SET_SIZE(filter_entry, 300, -2);
- gtk_box_pack_start(GTK_BOX(filter_box), filter_entry, TRUE, TRUE, 0);
- filter=gtk_entry_get_text(GTK_ENTRY(main_display_filter_widget));
- if(filter){
- gtk_entry_set_text(GTK_ENTRY(filter_entry), filter);
- }
- gtk_widget_show(filter_entry);
-
- gtk_box_pack_start(GTK_BOX(dlg_box), filter_box, TRUE, TRUE, 0);
- gtk_widget_show(filter_box);
-
- /* button box */
- bbox = gtk_hbutton_box_new();
- gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_DEFAULT_STYLE);
- gtk_button_box_set_spacing(GTK_BUTTON_BOX(bbox), 5);
- gtk_box_pack_start(GTK_BOX(dlg_box), bbox, FALSE, FALSE, 0);
- gtk_widget_show(bbox);
-
- /* the start button */
- start_button=gtk_button_new_with_label("Create Stat");
- SIGNAL_CONNECT_OBJECT(start_button, "clicked",
- mgcpstat_start_button_clicked, NULL);
- gtk_box_pack_start(GTK_BOX(bbox), start_button, TRUE, TRUE, 0);
- GTK_WIDGET_SET_FLAGS(start_button, GTK_CAN_DEFAULT);
- gtk_widget_grab_default(start_button);
- gtk_widget_show(start_button);
-
-#if GTK_MAJOR_VERSION < 2
- cancel_button=gtk_button_new_with_label("Cancel");
-#else
- cancel_button=gtk_button_new_from_stock(GTK_STOCK_CANCEL);
-#endif
- SIGNAL_CONNECT(cancel_button, "clicked", dlg_cancel_cb, dlg);
- GTK_WIDGET_SET_FLAGS(cancel_button, GTK_CAN_DEFAULT);
- gtk_box_pack_start(GTK_BOX(bbox), cancel_button, TRUE, TRUE, 0);
- gtk_widget_show(cancel_button);
-
- /* Catch the "activate" signal on the filter text entry, so that
- if the user types Return there, we act as if the "Create Stat"
- button had been selected, as happens if Return is typed if
- some widget that *doesn't* handle the Return key has the input
- focus. */
- dlg_set_activate(filter_entry, start_button);
-
- /* Catch the "key_press_event" signal in the window, so that we can
- catch the ESC key being pressed and act as if the "Cancel" button
- had been selected. */
- dlg_set_cancel(dlg, cancel_button);
-
- /* Give the initial focus to the "Filter" entry box. */
- gtk_widget_grab_focus(filter_entry);
-
- gtk_widget_show_all(dlg);
-}
+tap_dfilter_dlg mgcp_srt_dlg = {"MGCP Service Response Time (SRT) Statistics", "mgcp,srt", gtk_mgcpstat_init, -1};
void
register_tap_listener_gtkmgcpstat(void)
@@ -442,6 +314,6 @@ register_tap_menu_gtkmgcpstat(void)
{
if (find_tap_id("mgcp"))
register_tap_menu_item("Statistics/Service Response Time/MGCP...",
- gtk_mgcpstat_cb, NULL, NULL, NULL);
+ gtk_tap_dfilter_dlg_cb, NULL, NULL, &(mgcp_srt_dlg));
}
diff --git a/gtk/tap_dfilter_dlg.c b/gtk/tap_dfilter_dlg.c
index 40489891bb..925dc39587 100644
--- a/gtk/tap_dfilter_dlg.c
+++ b/gtk/tap_dfilter_dlg.c
@@ -2,7 +2,7 @@
* Routines for display filter dialog used by gui taps
* Copyright 2003 Lars Roland
*
- * $Id: tap_dfilter_dlg.c,v 1.1 2003/12/17 22:13:08 guy Exp $
+ * $Id: tap_dfilter_dlg.c,v 1.2 2003/12/19 23:41:55 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -41,7 +41,8 @@
#include "dlg_utils.h"
#include "../file.h"
#include "../globals.h"
-
+#include "filter_prefs.h"
+#include "../tap_dfilter_dlg.h"
#include "tap_dfilter_dlg.h"
extern GtkWidget *main_display_filter_widget;
@@ -50,12 +51,28 @@ typedef struct _tap_dfilter_dlg_list_item {
GtkWidget *dlg;
GtkWidget *filter_entry;
tap_dfilter_dlg cont;
+ construct_args_t args;
struct _tap_dfilter_dlg_list_item *next;
} tap_dfilter_dlg_list_item;
-tap_dfilter_dlg_list_item *start_dlg_list=NULL;
-tap_dfilter_dlg_list_item *end_dlg_list=NULL;
-tap_dfilter_dlg_list_item *current_dlg = NULL;
+static tap_dfilter_dlg_list_item *start_dlg_list=NULL;
+static tap_dfilter_dlg_list_item *end_dlg_list=NULL;
+static tap_dfilter_dlg_list_item *current_dlg = NULL;
+
+void tap_dfilter_dlg_update (void)
+{
+ tap_dfilter_dlg_list_item *dialog = start_dlg_list;
+ char *title;
+
+ while(dialog != NULL) {
+ if(dialog->dlg) {
+ title = g_strdup_printf("Ethereal: %s: %s", dialog->cont.win_title , cf_get_display_name(&cfile));
+ gtk_window_set_title(GTK_WINDOW(dialog->dlg), title);
+ g_free(title);
+ }
+ dialog = dialog->next;
+ }
+}
static void
dlg_destroy_cb(GtkWidget *item _U_, gpointer dialog_data)
@@ -94,7 +111,7 @@ gtk_tap_dfilter_dlg_cb(GtkWidget *w _U_, gpointer data)
const char *filter;
char *title;
GtkWidget *dlg_box;
- GtkWidget *filter_box, *filter_label;
+ GtkWidget *filter_box, *filter_bt;
GtkWidget *bbox, *start_button, *cancel_button;
tap_dfilter_dlg *dlg_data = (tap_dfilter_dlg *) data;
@@ -118,6 +135,9 @@ gtk_tap_dfilter_dlg_cb(GtkWidget *w _U_, gpointer data)
end_dlg_list->cont.win_title = dlg_data->win_title;
end_dlg_list->cont.init_string = dlg_data->init_string;
end_dlg_list->cont.tap_init_cb = dlg_data->tap_init_cb;
+ end_dlg_list->args.title = g_strdup_printf("%s Filter", dlg_data->win_title);
+ end_dlg_list->args.wants_apply_button = TRUE;
+ end_dlg_list->args.activate_on_ok = FALSE;
end_dlg_list->next = NULL;
dlg_data->index = end_dlg_list->cont.index;
current_dlg = end_dlg_list;
@@ -154,14 +174,20 @@ gtk_tap_dfilter_dlg_cb(GtkWidget *w _U_, gpointer data)
/* Filter box */
filter_box=gtk_hbox_new(FALSE, 3);
- /* Filter label */
- filter_label=gtk_label_new("Filter:");
- gtk_box_pack_start(GTK_BOX(filter_box), filter_label, FALSE, FALSE, 0);
- gtk_widget_show(filter_label);
+ /* Filter button */
+ filter_bt = gtk_button_new_with_label("Filter:");
+ SIGNAL_CONNECT(filter_bt, "clicked", display_filter_construct_cb, &(current_dlg->args));
+ gtk_box_pack_start(GTK_BOX(filter_box), filter_bt, FALSE, TRUE, 0);
+ gtk_widget_show(filter_bt);
/* Filter entry */
current_dlg->filter_entry=gtk_entry_new();
- WIDGET_SET_SIZE(current_dlg->filter_entry, 300, -2);
+ WIDGET_SET_SIZE(current_dlg->filter_entry, 300, 25);
+
+ /* filter prefs dialog */
+ OBJECT_SET_DATA(filter_bt, E_FILT_TE_PTR_KEY, current_dlg->filter_entry);
+ /* filter prefs dialog */
+
gtk_box_pack_start(GTK_BOX(filter_box), current_dlg->filter_entry, TRUE, TRUE, 0);
filter=gtk_entry_get_text(GTK_ENTRY(main_display_filter_widget));
if(filter){
diff --git a/gtk/tap_dfilter_dlg.h b/gtk/tap_dfilter_dlg.h
index 23fcd6b61a..142f9d5917 100644
--- a/gtk/tap_dfilter_dlg.h
+++ b/gtk/tap_dfilter_dlg.h
@@ -1,8 +1,8 @@
/* tap_dfilter_dlg.h
- * Header file for display filter dialog used by gui taps
+ * Header file for display filter dialog used by GTK gui taps
* Copyright 2003 Lars Roland
*
- * $Id: tap_dfilter_dlg.h,v 1.1 2003/12/17 22:13:08 guy Exp $
+ * $Id: tap_dfilter_dlg.h,v 1.2 2003/12/19 23:41:55 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -23,39 +23,4 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-/*
- * You can easily add a display filter dialog for your gui tap by using
- * the following infrastructure:
- *
- * Define a global structure of tap_dfilter_dlg within your tap source file.
- * Initiate it with:
- * 1) a title string for the Dialog Window
- * 2) the init string, which is the same as the string after "-z" option without
- * the filter string and without the seperating comma.
- * 3) a pointer to the init function of the tap, which will be called when you click
- * on the start button in the display filter dialog.
- * 4) the index with "-1"
- *
- * Within register_tap_menu_yourtap(void), call register_tap_menu_item() with gtk_tap_dfilter_dlg_cb as callback and a pointer
- * to the global tap_dfilter_dlg structure .
- *
- * Usage:
- *
- * tap_dfilter_dlg my_tap_dfilter_dlg = {"My Title", "myproto,mytap", gtk_mytap_init, -1};
- *
- * register_tap_menu_mytap(void) {
- * register_tap_menu_item(char *menu_string, gtk_tap_dfilter_dlg_cb, NULL, NULL, &(my_tap_dfilter_dlg));
- * }
- *
- * See also: h225_ras_srt.c or h225_counter.c
- *
- */
-
-typedef struct _tap_dfilter_dlg {
- char *win_title; /* title */
- char *init_string; /* the string to call the tap without a filter via "-z" option */
- void (* tap_init_cb)(char *); /* callback to init function of the tap */
- gint index; /* initiate this value always with "-1" */
-} tap_dfilter_dlg;
-
void gtk_tap_dfilter_dlg_cb(GtkWidget *w, gpointer data);
diff --git a/tap_dfilter_dlg.h b/tap_dfilter_dlg.h
new file mode 100644
index 0000000000..1cc4b73f03
--- /dev/null
+++ b/tap_dfilter_dlg.h
@@ -0,0 +1,62 @@
+/* tap_dfilter_dlg.h
+ * Header file for display filter dialog used by gui taps
+ * Copyright 2003 Lars Roland
+ *
+ * $Id: tap_dfilter_dlg.h,v 1.1 2003/12/19 23:39:53 guy Exp $
+ *
+ * Ethereal - Network traffic analyzer
+ * By Gerald Combs <gerald@ethereal.com>
+ * 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.
+ */
+
+/*
+ * You can easily add a display filter dialog for your gui tap by using
+ * the following infrastructure:
+ *
+ * Define a global structure of tap_dfilter_dlg within your tap source file.
+ * Initiate it with:
+ * 1) a title string for the Dialog Window
+ * 2) the init string, which is the same as the string after "-z" option without
+ * the filter string and without the seperating comma.
+ * 3) a pointer to the init function of the tap, which will be called when you click
+ * on the start button in the display filter dialog.
+ * 4) the index with "-1"
+ *
+ * Within register_tap_menu_yourtap(void), call register_tap_menu_item() with gtk_tap_dfilter_dlg_cb as callback and a pointer
+ * to the global tap_dfilter_dlg structure .
+ *
+ * Usage:
+ *
+ * tap_dfilter_dlg my_tap_dfilter_dlg = {"My Title", "myproto,mytap", gtk_mytap_init, -1};
+ *
+ * register_tap_menu_mytap(void) {
+ * register_tap_menu_item(char *menu_string, gtk_tap_dfilter_dlg_cb, NULL, NULL, &(my_tap_dfilter_dlg));
+ * }
+ *
+ * See also: h225_ras_srt.c or h225_counter.c
+ *
+ */
+
+typedef struct _tap_dfilter_dlg {
+ char *win_title; /* title */
+ char *init_string; /* the string to call the tap without a filter via "-z" option */
+ void (* tap_init_cb)(char *); /* callback to init function of the tap */
+ gint index; /* initiate this value always with "-1" */
+} tap_dfilter_dlg;
+
+/* This will update the titles of the dialog windows when we load a new capture file. */
+void tap_dfilter_dlg_update (void);