diff options
author | Guy Harris <guy@alum.mit.edu> | 2000-04-01 12:03:42 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2000-04-01 12:03:42 +0000 |
commit | c6e50f9bc98d10c007bbe11e49dd8c3211ce2479 (patch) | |
tree | 54f55938c6c723b5f6bd37cce61a4e73587f0b5e /gtk/file_dlg.c | |
parent | 5549f62efd72450189dad088a7206ed4b6a1bfb6 (diff) |
Split "filter_dialog_cb()" into "filter_dialog_cb()", which pops up a
"global" dialog box when "Edit:Filters" is selected, so that the list of
filters can be edited, and "filter_browse_cb()", which pops up a dialog
box associated with a "Filter:" button and a text entry widget attached
to that button, so that a filter can be selected or saved (although it
also supports the same editing that the "global" dialog box does).
Have "filter_dialog_cb()" connect the window in which the "Filter:"
button lives and the filter dialog box, so that:
if the window in which the "Filter:" button lives goes away, so
does the filter dialog box (as it no longer has a text widget
into which it can stuff the selected filter);
if the "Filter:" button is clicked when there's already a filter
dialog box open, we just reactivate that existing dialog box
rather than popping up a new one.
Also keep a pointer to the "global" filter dialog box, so that we also
arrange that there's only one of them (by reactivating the existing on
if "Edit:Filters" is selected when there's already a "global" filter
dialog box open).
Keep around pointers to the dialog boxes that contain the "Filter:"
buttons, so that we can arrange that there be only one of them (that was
a side-effect of an earlier attempt at fixing the problems described
above, but it's still useful for keeping multiple competing dialog boxes
from being open - there's more of that to be done).
Make the pointer to the "Open Capture File" dialog box widget static to
"file_dlg.c" - nobody outside of "file_dlg.c cares about it.
svn path=/trunk/; revision=1774
Diffstat (limited to 'gtk/file_dlg.c')
-rw-r--r-- | gtk/file_dlg.c | 40 |
1 files changed, 38 insertions, 2 deletions
diff --git a/gtk/file_dlg.c b/gtk/file_dlg.c index 32de6d755b..407c65ad5e 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.20 2000/02/12 06:58:41 guy Exp $ + * $Id: file_dlg.c,v 1.21 2000/04/01 12:03:38 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -49,6 +49,7 @@ #endif #include "filter_prefs.h" +#include "ui_util.h" #ifndef __DIALOG_H__ #include "simple_dialog.h" @@ -65,14 +66,29 @@ #endif static void file_open_ok_cb(GtkWidget *w, GtkFileSelection *fs); +static void file_open_destroy_cb(GtkWidget *win, gpointer user_data); static void select_file_type_cb(GtkWidget *w, gpointer data); static void file_save_as_ok_cb(GtkWidget *w, GtkFileSelection *fs); +/* + * Keep a static pointer to the current "Open Capture File" window, if + * any, so that if somebody tries to do "File:Open" while there's already + * an "Open Capture File" window up, we just pop up the existing one, + * rather than creating a new one. + */ +static GtkWidget *file_sel; + /* Open a file */ void file_open_cmd_cb(GtkWidget *w, gpointer data) { GtkWidget *filter_hbox, *filter_bt, *filter_te; + if (file_sel != NULL) { + /* There's already an "Open Capture File" dialog box; reactivate it. */ + reactivate_window(file_sel); + return; + } + /* XXX - GTK+'s file selection dialog box doesn't let you set the initial directory it should show; it always uses the current directory. We want to start out by showing the user the files @@ -89,6 +105,8 @@ file_open_cmd_cb(GtkWidget *w, gpointer data) { chdir(last_open_dir); file_sel = gtk_file_selection_new ("Ethereal: Open Capture File"); + gtk_signal_connect(GTK_OBJECT(file_sel), "destroy", + GTK_SIGNAL_FUNC(file_open_destroy_cb), NULL); /* Connect the ok_button to file_open_ok_cb function and pass along a pointer to the file selection box widget */ @@ -106,7 +124,7 @@ file_open_cmd_cb(GtkWidget *w, gpointer data) { filter_bt = gtk_button_new_with_label("Filter:"); gtk_signal_connect(GTK_OBJECT(filter_bt), "clicked", - GTK_SIGNAL_FUNC(filter_dialog_cb), NULL); + GTK_SIGNAL_FUNC(filter_browse_cb), NULL); gtk_box_pack_start(GTK_BOX(filter_hbox), filter_bt, FALSE, TRUE, 0); gtk_widget_show(filter_bt); @@ -205,6 +223,24 @@ file_open_ok_cb(GtkWidget *w, GtkFileSelection *fs) { g_free(cf_name); } +static void +file_open_destroy_cb(GtkWidget *win, gpointer user_data) +{ + GtkWidget *file_open_filter_w; + + /* Is there a filter edit/selection dialog associated with this + Open Capture File dialog? */ + file_open_filter_w = gtk_object_get_data(GTK_OBJECT(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_sel = NULL; +} + /* Close a file */ void file_close_cmd_cb(GtkWidget *widget, gpointer data) { |