aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2003-01-15 05:20:19 +0000
committerGuy Harris <guy@alum.mit.edu>2003-01-15 05:20:19 +0000
commita2f01014c141592a9d0c662fea616a0fe7c981df (patch)
treeb06c7bbfd2d29e74953f94af9465aa9172a038be
parentcdbf86b42accb6116a70818f3c6cea1ace040852 (diff)
Add a new routine "filter_button_destroy_cb()", and make it the
"destroy" signal handler for any button that pops up a filter; if the button has a filter dialog box associated with it, it destroys that dialog box. Have the routines that create filter dialog boxes asociate the dialog box with the button that created it, so that if the button is destroyed the filter dialog box can be destroyed as well, and associate the button with the dialog box. This means that if a dialog box has a button to create a filter, we no longer have to have the destroy handler for the dialog box destroy any filters - that'll happen when the button in the dialog box is destroyed as part of the process of destroying the dialog box. Don't make the "Filter" buttons in the io_stat dialog box insensitive if there's already a filter dialog box open - we can have more than one open per dialog box. svn path=/trunk/; revision=6930
-rw-r--r--gtk/capture_dlg.c15
-rw-r--r--gtk/file_dlg.c16
-rw-r--r--gtk/filter_prefs.c79
-rw-r--r--gtk/filter_prefs.h5
-rw-r--r--gtk/find_dlg.c16
-rw-r--r--gtk/io_stat.c24
6 files changed, 60 insertions, 95 deletions
diff --git a/gtk/capture_dlg.c b/gtk/capture_dlg.c
index 2b573f9f8a..893c1b3b35 100644
--- a/gtk/capture_dlg.c
+++ b/gtk/capture_dlg.c
@@ -1,7 +1,7 @@
/* capture_dlg.c
* Routines for packet capture windows
*
- * $Id: capture_dlg.c,v 1.76 2002/11/09 20:00:35 oabad Exp $
+ * $Id: capture_dlg.c,v 1.77 2003/01/15 05:20:18 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -284,6 +284,7 @@ capture_prep_cb(GtkWidget *w _U_, gpointer d _U_)
filter_bt = gtk_button_new_with_label("Filter:");
SIGNAL_CONNECT(filter_bt, "clicked", capture_filter_construct_cb, NULL);
+ SIGNAL_CONNECT(filter_bt, "destroy", filter_button_destroy_cb, NULL);
gtk_box_pack_start(GTK_BOX(filter_hb), filter_bt, FALSE, FALSE, 3);
gtk_widget_show(filter_bt);
@@ -883,20 +884,10 @@ capture_prep_close_cb(GtkWidget *close_bt _U_, gpointer parent_w)
static void
capture_prep_destroy_cb(GtkWidget *win, gpointer user_data _U_)
{
- GtkWidget *capture_prep_filter_w;
GtkWidget *fs;
- /* Is there a filter edit/selection dialog associated with this
- Capture Options dialog? */
- capture_prep_filter_w = OBJECT_GET_DATA(win, E_FILT_DIALOG_PTR_KEY);
-
- if (capture_prep_filter_w != NULL) {
- /* Yes. Destroy it. */
- gtk_widget_destroy(capture_prep_filter_w);
- }
-
/* Is there a file selection dialog associated with this
- Print File dialog? */
+ Capture Options dialog? */
fs = OBJECT_GET_DATA(win, E_FILE_SEL_DIALOG_PTR_KEY);
if (fs != NULL) {
diff --git a/gtk/file_dlg.c b/gtk/file_dlg.c
index 7212bc8f35..b5bdce05a8 100644
--- a/gtk/file_dlg.c
+++ b/gtk/file_dlg.c
@@ -1,7 +1,7 @@
/* file_dlg.c
* Dialog boxes for handling files
*
- * $Id: file_dlg.c,v 1.54 2002/11/10 11:00:29 oabad Exp $
+ * $Id: file_dlg.c,v 1.55 2003/01/15 05:20:18 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -114,6 +114,7 @@ file_open_cmd_cb(GtkWidget *w, gpointer data _U_)
filter_bt = gtk_button_new_with_label("Filter:");
SIGNAL_CONNECT(filter_bt, "clicked", display_filter_construct_cb, &args);
+ SIGNAL_CONNECT(filter_bt, "destroy", filter_button_destroy_cb, NULL);
gtk_box_pack_start(GTK_BOX(filter_hbox), filter_bt, FALSE, TRUE, 0);
gtk_widget_show(filter_bt);
@@ -273,19 +274,8 @@ file_open_ok_cb(GtkWidget *w, GtkFileSelection *fs) {
}
static void
-file_open_destroy_cb(GtkWidget *win, gpointer user_data _U_)
+file_open_destroy_cb(GtkWidget *win _U_, gpointer user_data _U_)
{
- GtkWidget *file_open_filter_w;
-
- /* Is there a filter edit/selection dialog associated with this
- Open Capture File dialog? */
- file_open_filter_w = OBJECT_GET_DATA(win, E_FILT_DIALOG_PTR_KEY);
-
- if (file_open_filter_w != NULL) {
- /* Yes. Destroy it. */
- gtk_widget_destroy(file_open_filter_w);
- }
-
/* Note that we no longer have a "Open Capture File" dialog box. */
file_open_w = NULL;
}
diff --git a/gtk/filter_prefs.c b/gtk/filter_prefs.c
index 62d835823f..22e9a7682b 100644
--- a/gtk/filter_prefs.c
+++ b/gtk/filter_prefs.c
@@ -3,7 +3,7 @@
* (This used to be a notebook page under "Preferences", hence the
* "prefs" in the file name.)
*
- * $Id: filter_prefs.c,v 1.41 2003/01/11 11:10:33 sahlberg Exp $
+ * $Id: filter_prefs.c,v 1.42 2003/01/15 05:20:18 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -43,6 +43,8 @@
#include "dfilter_expr_dlg.h"
#include "compat_macros.h"
+#define E_FILT_DIALOG_PTR_KEY "filter_dialog_ptr"
+#define E_FILT_BUTTON_PTR_KEY "filter_button_ptr"
#define E_FILT_PARENT_FILTER_TE_KEY "filter_parent_filter_te"
#define E_FILT_CONSTRUCT_ARGS_KEY "filter_construct_args"
#define E_FILT_LIST_ITEM_MODEL_KEY "filter_list_item_model"
@@ -62,7 +64,7 @@ typedef struct _filter_cb_data {
GtkWidget *win;
} filter_cb_data;
-static GtkWidget *filter_dialog_new(GtkWidget *caller, GtkWidget *filter_te,
+static GtkWidget *filter_dialog_new(GtkWidget *button, GtkWidget *filter_te,
filter_list_type_t list,
construct_args_t *construct_args);
static void filter_dlg_dclick(GtkWidget *dummy, gpointer main_w_arg,
@@ -106,7 +108,6 @@ static void filter_filter_te_destroy_cb(GtkWidget *, gpointer);
void
capture_filter_construct_cb(GtkWidget *w, gpointer user_data _U_)
{
- GtkWidget *caller = gtk_widget_get_toplevel(w);
GtkWidget *filter_browse_w;
GtkWidget *parent_filter_te;
/* No Apply button, and "OK" just sets our text widget, it doesn't
@@ -117,9 +118,8 @@ capture_filter_construct_cb(GtkWidget *w, gpointer user_data _U_)
FALSE
};
- /* Has a filter dialog box already been opened for that top-level
- widget? */
- filter_browse_w = OBJECT_GET_DATA(caller, E_FILT_DIALOG_PTR_KEY);
+ /* Has a filter dialog box already been opened for that button? */
+ filter_browse_w = OBJECT_GET_DATA(w, E_FILT_DIALOG_PTR_KEY);
if (filter_browse_w != NULL) {
/* Yes. Just re-activate that dialog box. */
@@ -131,15 +131,15 @@ capture_filter_construct_cb(GtkWidget *w, gpointer user_data _U_)
parent_filter_te = OBJECT_GET_DATA(w, E_FILT_TE_PTR_KEY);
/* Now create a new dialog, without an "Add Expression..." button. */
- filter_browse_w = filter_dialog_new(caller, parent_filter_te,
+ filter_browse_w = filter_dialog_new(w, parent_filter_te,
CFILTER_LIST, &args);
- /* Set the E_FILT_CALLER_PTR_KEY for the new dialog to point to
- our caller. */
- OBJECT_SET_DATA(filter_browse_w, E_FILT_CALLER_PTR_KEY, caller);
+ /* Set the E_FILT_BUTTON_PTR_KEY for the new dialog to point to
+ the button. */
+ OBJECT_SET_DATA(filter_browse_w, E_FILT_BUTTON_PTR_KEY, w);
- /* Set the E_FILT_DIALOG_PTR_KEY for the caller to point to us */
- OBJECT_SET_DATA(caller, E_FILT_DIALOG_PTR_KEY, filter_browse_w);
+ /* Set the E_FILT_DIALOG_PTR_KEY for the button to point to us */
+ OBJECT_SET_DATA(w, E_FILT_DIALOG_PTR_KEY, filter_browse_w);
}
#endif
@@ -159,13 +159,11 @@ GtkWidget *
display_filter_construct_cb(GtkWidget *w, gpointer construct_args_ptr)
{
construct_args_t *construct_args = construct_args_ptr;
- GtkWidget *caller = gtk_widget_get_toplevel(w);
GtkWidget *filter_browse_w;
GtkWidget *parent_filter_te;
- /* Has a filter dialog box already been opened for that top-level
- widget? */
- filter_browse_w = OBJECT_GET_DATA(caller, E_FILT_DIALOG_PTR_KEY);
+ /* Has a filter dialog box already been opened for the button? */
+ filter_browse_w = OBJECT_GET_DATA(w, E_FILT_DIALOG_PTR_KEY);
if (filter_browse_w != NULL) {
/* Yes. Just re-activate that dialog box. */
@@ -178,19 +176,36 @@ display_filter_construct_cb(GtkWidget *w, gpointer construct_args_ptr)
/* Now create a new dialog, possibly with an "Apply" button, and
definitely with an "Add Expression..." button. */
- filter_browse_w = filter_dialog_new(caller, parent_filter_te,
+ filter_browse_w = filter_dialog_new(w, parent_filter_te,
DFILTER_LIST, construct_args);
- /* Set the E_FILT_CALLER_PTR_KEY for the new dialog to point to
- our caller. */
- OBJECT_SET_DATA(filter_browse_w, E_FILT_CALLER_PTR_KEY, caller);
+ /* Set the E_FILT_BUTTON_PTR_KEY for the new dialog to point to
+ the button. */
+ OBJECT_SET_DATA(filter_browse_w, E_FILT_BUTTON_PTR_KEY, w);
- /* Set the E_FILT_DIALOG_PTR_KEY for the caller to point to us */
- OBJECT_SET_DATA(caller, E_FILT_DIALOG_PTR_KEY, filter_browse_w);
+ /* Set the E_FILT_DIALOG_PTR_KEY for the button to point to us */
+ OBJECT_SET_DATA(w, E_FILT_DIALOG_PTR_KEY, filter_browse_w);
return filter_browse_w;
}
+/* Should be called when a button that creates filters is destroyed; it
+ destroys any filter created by that button. */
+void
+filter_button_destroy_cb(GtkWidget *button, gpointer user_data _U_)
+{
+ GtkWidget *filter_w;
+
+ /* Is there a filter edit/selection dialog associated with this
+ button? */
+ filter_w = OBJECT_GET_DATA(button, E_FILT_DIALOG_PTR_KEY);
+
+ if (filter_w != NULL) {
+ /* Yes. Destroy it. */
+ gtk_widget_destroy(filter_w);
+ }
+}
+
#ifdef HAVE_LIBPCAP
static GtkWidget *global_cfilter_w;
@@ -218,7 +233,7 @@ cfilter_dialog_cb(GtkWidget *w _U_)
/*
* No. Create one; we didn't pop this up as a result of pressing
* a button next to some text entry field, so don't associate it
- * with a text entry field.
+ * with a text entry field or button.
*/
global_cfilter_w = filter_dialog_new(NULL, NULL, CFILTER_LIST, &args);
}
@@ -250,7 +265,7 @@ dfilter_dialog_cb(GtkWidget *w _U_)
/*
* No. Create one; we didn't pop this up as a result of pressing
* a button next to some text entry field, so don't associate it
- * with a text entry field.
+ * with a text entry field or button.
*/
global_dfilter_w = filter_dialog_new(NULL, NULL, DFILTER_LIST, &args);
}
@@ -310,7 +325,7 @@ get_filter_dialog_list(filter_list_type_t list)
}
static GtkWidget *
-filter_dialog_new(GtkWidget *caller _U_, GtkWidget *parent_filter_te,
+filter_dialog_new(GtkWidget *button _U_, GtkWidget *parent_filter_te,
filter_list_type_t list, construct_args_t *construct_args)
{
GtkWidget *main_w, /* main window */
@@ -382,8 +397,8 @@ filter_dialog_new(GtkWidget *caller _U_, GtkWidget *parent_filter_te,
main_w = dlg_window_new(construct_args->title);
OBJECT_SET_DATA(main_w, E_FILT_CONSTRUCT_ARGS_KEY, construct_args);
- /* Call a handler when we're destroyed, so we can inform
- our caller, if any, that we've been destroyed. */
+ /* Call a handler when we're destroyed, so we can detach ourselves
+ from the button. */
SIGNAL_CONNECT(main_w, "destroy", filter_dlg_destroy, filter_list_p);
main_vb = gtk_vbox_new(FALSE, 5);
@@ -863,16 +878,16 @@ static void
filter_dlg_destroy(GtkWidget *win, gpointer data)
{
filter_list_type_t list = *(filter_list_type_t *)data;
- GtkWidget *caller;
+ GtkWidget *button;
- /* Get the widget that requested that we be popped up, if any.
+ /* Get the button that requested that we be popped up, if any.
(It should arrange to destroy us if it's destroyed, so
that we don't get a pointer to a non-existent window here.) */
- caller = OBJECT_GET_DATA(win, E_FILT_CALLER_PTR_KEY);
+ button = OBJECT_GET_DATA(win, E_FILT_BUTTON_PTR_KEY);
- if (caller != NULL) {
+ if (button != NULL) {
/* Tell it we no longer exist. */
- OBJECT_SET_DATA(caller, E_FILT_DIALOG_PTR_KEY, NULL);
+ OBJECT_SET_DATA(button, E_FILT_DIALOG_PTR_KEY, NULL);
} else {
/* This is an editing dialog popped up from, for example,
a menu item; note that we no longer have one. */
diff --git a/gtk/filter_prefs.h b/gtk/filter_prefs.h
index b14b0c2618..ef92174947 100644
--- a/gtk/filter_prefs.h
+++ b/gtk/filter_prefs.h
@@ -3,7 +3,7 @@
* (This used to be a notebook page under "Preferences", hence the
* "prefs" in the file name.)
*
- * $Id: filter_prefs.h,v 1.13 2003/01/11 11:10:33 sahlberg Exp $
+ * $Id: filter_prefs.h,v 1.14 2003/01/15 05:20:19 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -41,11 +41,10 @@ typedef struct {
void capture_filter_construct_cb(GtkWidget *w, gpointer user_data);
GtkWidget *display_filter_construct_cb(GtkWidget *w, gpointer construct_args_ptr);
+void filter_button_destroy_cb(GtkWidget *button, gpointer user_data);
void cfilter_dialog_cb(GtkWidget *w);
void dfilter_dialog_cb(GtkWidget *w);
#define E_FILT_TE_PTR_KEY "filter_te_ptr"
-#define E_FILT_CALLER_PTR_KEY "filter_caller_ptr"
-#define E_FILT_DIALOG_PTR_KEY "filter_dialog_ptr"
#endif /* filter.h */
diff --git a/gtk/find_dlg.c b/gtk/find_dlg.c
index 7228e361e6..5e27031215 100644
--- a/gtk/find_dlg.c
+++ b/gtk/find_dlg.c
@@ -1,7 +1,7 @@
/* find_dlg.c
* Routines for "find frame" window
*
- * $Id: find_dlg.c,v 1.26 2002/11/11 15:39:05 oabad Exp $
+ * $Id: find_dlg.c,v 1.27 2003/01/15 05:20:19 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -108,6 +108,7 @@ find_frame_cb(GtkWidget *w _U_, gpointer d _U_)
filter_bt = gtk_button_new_with_label("Filter:");
SIGNAL_CONNECT(filter_bt, "clicked", display_filter_construct_cb, &args);
+ SIGNAL_CONNECT(filter_bt, "destroy", filter_button_destroy_cb, NULL);
gtk_box_pack_start(GTK_BOX(filter_hb), filter_bt, FALSE, TRUE, 0);
gtk_widget_show(filter_bt);
@@ -248,19 +249,8 @@ find_frame_close_cb(GtkWidget *close_bt _U_, gpointer parent_w)
}
static void
-find_frame_destroy_cb(GtkWidget *win, gpointer user_data _U_)
+find_frame_destroy_cb(GtkWidget *win _U_, gpointer user_data _U_)
{
- GtkWidget *find_frame_filter_w;
-
- /* Is there a filter edit/selection dialog associated with this
- Find Frame dialog? */
- find_frame_filter_w = OBJECT_GET_DATA(win, E_FILT_DIALOG_PTR_KEY);
-
- if (find_frame_filter_w != NULL) {
- /* Yes. Destroy it. */
- gtk_widget_destroy(find_frame_filter_w);
- }
-
/* Note that we no longer have a "Find Frame" dialog box. */
find_frame_w = NULL;
}
diff --git a/gtk/io_stat.c b/gtk/io_stat.c
index b5019f7649..86ddd67826 100644
--- a/gtk/io_stat.c
+++ b/gtk/io_stat.c
@@ -1,7 +1,7 @@
/* io_stat.c
* io_stat 2002 Ronnie Sahlberg
*
- * $Id: io_stat.c,v 1.14 2003/01/11 11:10:33 sahlberg Exp $
+ * $Id: io_stat.c,v 1.15 2003/01/15 05:20:19 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -1491,34 +1491,13 @@ create_advanced_box(io_stat_graph_t *gio, GtkWidget *box)
}
-gint delete_filter_event(GtkWidget *widget _U_, io_stat_graph_t *gio)
-{
- int i;
-
- for(i=0;i<MAX_GRAPHS;i++){
- if (GTK_WIDGET_STATE (gio->io->graphs[i].filter_bt)
- == GTK_STATE_INSENSITIVE) {
- gtk_widget_set_sensitive (gio->io->graphs[i].filter_bt,1);
- }
- }
- return(FALSE);
-}
-
-
static void
filter_button_clicked(GtkWidget *w, gpointer uio)
{
int i;
io_stat_graph_t *gio=(io_stat_graph_t *)uio;
- for(i=0;i<MAX_GRAPHS;i++){
- if( gio->io->graphs[i].filter_bt != w ){
- gtk_widget_set_sensitive(gio->io->graphs[i].filter_bt,0);
- }
- }
gio->filter_main_win=display_filter_construct_cb(w, gio->args);
- SIGNAL_CONNECT(gio->filter_main_win, "delete_event", delete_filter_event, gio);
- SIGNAL_CONNECT(gio->filter_main_win, "destroy", delete_filter_event, gio);
return;
}
@@ -1596,6 +1575,7 @@ create_filter_box(io_stat_graph_t *gio, GtkWidget *box, int num)
gio->args->title=strdup(str);
SIGNAL_CONNECT(gio->filter_bt, "clicked", filter_button_clicked, gio);
+ SIGNAL_CONNECT(gio->filter_bt, "destroy", filter_button_destroy_cb, NULL);
gtk_box_pack_start(GTK_BOX(hbox), gio->filter_bt, FALSE, TRUE, 0);
gtk_widget_show(gio->filter_bt);