aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--gtk/capture_dlg.c151
-rw-r--r--gtk/capture_info_dlg.c24
-rw-r--r--gtk/capture_prefs.c33
-rw-r--r--gtk/color_dlg.c58
-rw-r--r--gtk/column_prefs.c4
-rw-r--r--gtk/decode_as_dlg.c59
-rw-r--r--gtk/dfilter_expr_dlg.c48
-rw-r--r--gtk/dlg_utils.c168
-rw-r--r--gtk/dlg_utils.h20
-rw-r--r--gtk/file_dlg.c221
-rw-r--r--gtk/file_dlg.h8
-rw-r--r--gtk/filter_prefs.c43
-rw-r--r--gtk/find_dlg.c22
-rw-r--r--gtk/follow_dlg.c52
-rw-r--r--gtk/goto_dlg.c31
-rw-r--r--gtk/menu.c3
-rw-r--r--gtk/packet_win.c4
-rw-r--r--gtk/plugins_dlg.c29
-rw-r--r--gtk/prefs_dlg.c19
-rw-r--r--gtk/print_dlg.c38
-rw-r--r--gtk/print_prefs.c104
-rw-r--r--gtk/progress_dlg.c5
-rw-r--r--gtk/proto_dlg.c22
-rw-r--r--gtk/proto_draw.c19
-rw-r--r--gtk/rtp_analysis.c58
-rw-r--r--gtk/rtp_stream_dlg.c151
-rw-r--r--gtk/simple_dialog.c18
-rw-r--r--gtk/tcp_graph.c10
-rw-r--r--gtk/ui_util.c49
29 files changed, 552 insertions, 919 deletions
diff --git a/gtk/capture_dlg.c b/gtk/capture_dlg.c
index d5bff68ff5..5cb7183685 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.130 2004/04/28 20:47:43 guy Exp $
+ * $Id: capture_dlg.c,v 1.131 2004/05/26 03:49:21 ulfl Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -98,9 +98,6 @@
#define E_CAP_OM_LT_VALUE_KEY "cap_om_lt_value"
-#define E_FS_CALLER_PTR_KEY "fs_caller_ptr"
-#define E_FILE_SEL_DIALOG_PTR_KEY "file_sel_dialog_ptr"
-
static void
capture_prep_file_cb(GtkWidget *w, gpointer te);
@@ -110,9 +107,6 @@ select_link_type_cb(GtkWidget *w, gpointer data);
#if (GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION < 4) || GTK_MAJOR_VERSION < 2
static void
cap_prep_fs_ok_cb(GtkWidget *w, gpointer data);
-
-static void
-cap_prep_fs_cancel_cb(GtkWidget *w, gpointer data);
#endif
static void
@@ -125,9 +119,6 @@ static void
capture_prep_ok_cb(GtkWidget *ok_bt, gpointer parent_w);
static void
-capture_prep_close_cb(GtkWidget *close_bt, gpointer parent_w);
-
-static void
capture_prep_destroy_cb(GtkWidget *win, gpointer user_data);
static void
@@ -537,7 +528,6 @@ capture_prep(void)
}
cap_open_w = dlg_window_new("Ethereal: Capture Options");
- SIGNAL_CONNECT(cap_open_w, "destroy", capture_prep_destroy_cb, NULL);
tooltips = gtk_tooltips_new();
@@ -994,18 +984,19 @@ capture_prep(void)
SIGNAL_CONNECT(ok_bt, "clicked", capture_prep_ok_cb, cap_open_w);
gtk_tooltips_set_tip(tooltips, ok_bt,
"Start the capture process.", NULL);
- gtk_widget_grab_default(ok_bt);
cancel_bt = OBJECT_GET_DATA(bbox, GTK_STOCK_CANCEL);
gtk_tooltips_set_tip(tooltips, cancel_bt,
"Cancel and exit dialog.", NULL);
- SIGNAL_CONNECT(cancel_bt, "clicked", capture_prep_close_cb, cap_open_w);
+ window_set_cancel_button(cap_open_w, cancel_bt, window_cancel_button_cb);
help_bt = OBJECT_GET_DATA(bbox, GTK_STOCK_HELP);
gtk_tooltips_set_tip(tooltips, help_bt,
"Show help about capturing.", NULL);
SIGNAL_CONNECT(help_bt, "clicked", help_topic_cb, "Capturing");
+ gtk_widget_grab_default(ok_bt);
+
/* Attach pointers to needed widgets to the capture prefs window/object */
OBJECT_SET_DATA(cap_open_w, E_CAP_IFACE_KEY, if_cb);
OBJECT_SET_DATA(cap_open_w, E_CAP_SNAP_CB_KEY, snap_cb);
@@ -1057,11 +1048,6 @@ capture_prep(void)
dlg_set_activate(filter_te, ok_bt);
dlg_set_activate(file_te, ok_bt);
- /* 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(cap_open_w, cancel_bt);
-
/* XXX - why does not
gtk_widget_grab_focus(if_cb);
@@ -1085,7 +1071,11 @@ capture_prep(void)
in it; and it now appears that you simply *can't* make a combo box
get the initial focus, at least not in the obvious fashion. Sigh.... */
+ SIGNAL_CONNECT(cap_open_w, "delete_event", window_delete_event_cb, NULL);
+ SIGNAL_CONNECT(cap_open_w, "destroy", capture_prep_destroy_cb, NULL);
+
gtk_widget_show_all(cap_open_w);
+ window_present(cap_open_w);
}
static void
@@ -1135,121 +1125,11 @@ select_link_type_cb(GtkWidget *w, gpointer data)
}
static void
-capture_prep_file_cb(GtkWidget *w, gpointer file_te)
+capture_prep_file_cb(GtkWidget *file_bt, GtkWidget *file_te)
{
- GtkWidget *caller = gtk_widget_get_toplevel(w);
- GtkWidget *fs;
-#if (GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION >= 4) || GTK_MAJOR_VERSION > 2
- gchar *cf_name;
-#endif
-
- /* Has a file selection dialog box already been opened for that top-level
- widget? */
- fs = OBJECT_GET_DATA(caller, E_FILE_SEL_DIALOG_PTR_KEY);
-
- if (fs != NULL) {
- /* Yes. Just re-activate that dialog box. */
- reactivate_window(fs);
- return;
- }
-
- fs = file_selection_new("Ethereal: Capture File", FILE_SELECTION_SAVE);
-
- /* If we've opened a file, start out by showing the files in the directory
- in which that file resided. */
- if (last_open_dir)
- file_selection_set_current_folder(fs, last_open_dir);
-
- OBJECT_SET_DATA(fs, E_CAP_FILE_TE_KEY, file_te);
-
- /* Set the E_FS_CALLER_PTR_KEY for the new dialog to point to our caller. */
- OBJECT_SET_DATA(fs, E_FS_CALLER_PTR_KEY, caller);
-
- /* Set the E_FILE_SEL_DIALOG_PTR_KEY for the caller to point to us */
- OBJECT_SET_DATA(caller, E_FILE_SEL_DIALOG_PTR_KEY, fs);
-
- /* Call a handler when the file selection box is destroyed, so we can inform
- our caller, if any, that it's been destroyed. */
- SIGNAL_CONNECT(fs, "destroy", cap_prep_fs_destroy_cb, file_te);
-
-#if (GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION >= 4) || GTK_MAJOR_VERSION > 2
- if (gtk_dialog_run(GTK_DIALOG(fs)) == GTK_RESPONSE_ACCEPT)
- {
- cf_name = g_strdup(gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(fs)));
- gtk_entry_set_text(GTK_ENTRY(file_te), cf_name);
- g_free(cf_name);
- }
- gtk_widget_destroy(fs);
-#else
- SIGNAL_CONNECT(GTK_FILE_SELECTION(fs)->ok_button, "clicked", cap_prep_fs_ok_cb, fs);
-
- /* Connect the cancel_button to destroy the widget */
- SIGNAL_CONNECT(GTK_FILE_SELECTION(fs)->cancel_button, "clicked", cap_prep_fs_cancel_cb,
- fs);
-
- /* 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(fs, GTK_FILE_SELECTION(fs)->cancel_button);
-
- gtk_widget_show_all(fs);
-#endif
-}
-
-#if (GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION < 4) || GTK_MAJOR_VERSION < 2
-static void
-cap_prep_fs_ok_cb(GtkWidget *w _U_, gpointer data)
-{
- gchar *cf_name;
-
- cf_name = g_strdup(gtk_file_selection_get_filename(
- GTK_FILE_SELECTION (data)));
-
- /* Perhaps the user specified a directory instead of a file.
- Check whether they did. */
- if (test_for_directory(cf_name) == EISDIR) {
- /* It's a directory - set the file selection box to display it. */
- set_last_open_dir(cf_name);
- g_free(cf_name);
- gtk_file_selection_set_filename(GTK_FILE_SELECTION(data),
- last_open_dir);
- return;
- }
-
- gtk_entry_set_text(GTK_ENTRY(OBJECT_GET_DATA(data, E_CAP_FILE_TE_KEY)), cf_name);
-
- gtk_widget_destroy(GTK_WIDGET(data));
- g_free(cf_name);
-}
-
-static void
-cap_prep_fs_cancel_cb(GtkWidget *w _U_, gpointer data)
-{
- gtk_widget_destroy(GTK_WIDGET(data));
+ file_selection_browse(file_bt, file_te, "Ethereal: Specify a Capture File", FILE_SELECTION_OPEN);
}
-#endif
-
-static void
-cap_prep_fs_destroy_cb(GtkWidget *win, GtkWidget* file_te)
-{
- GtkWidget *caller;
-
- /* Get the widget that requested that we be popped up.
- (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_FS_CALLER_PTR_KEY);
- /* Tell it we no longer exist. */
- OBJECT_SET_DATA(caller, E_FILE_SEL_DIALOG_PTR_KEY, NULL);
-
- /* Now nuke this window. */
- gtk_grab_remove(GTK_WIDGET(win));
- gtk_widget_destroy(GTK_WIDGET(win));
-
- /* Give the focus to the file text entry widget so the user can just press
- Return to start the capture. */
- gtk_widget_grab_focus(file_te);
-}
static void
capture_prep_ok_cb(GtkWidget *ok_bt _U_, gpointer parent_w) {
@@ -1485,7 +1365,7 @@ capture_prep_ok_cb(GtkWidget *ok_bt _U_, gpointer parent_w) {
capture_opts.autostop_files =
gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(stop_files_sb));
- gtk_widget_destroy(GTK_WIDGET(parent_w));
+ window_destroy(GTK_WIDGET(parent_w));
do_capture(save_file);
if (save_file != NULL)
@@ -1493,13 +1373,6 @@ capture_prep_ok_cb(GtkWidget *ok_bt _U_, gpointer parent_w) {
}
static void
-capture_prep_close_cb(GtkWidget *close_bt _U_, gpointer parent_w)
-{
- gtk_grab_remove(GTK_WIDGET(parent_w));
- gtk_widget_destroy(GTK_WIDGET(parent_w));
-}
-
-static void
capture_prep_destroy_cb(GtkWidget *win, gpointer user_data _U_)
{
GtkWidget *fs;
@@ -1510,7 +1383,7 @@ capture_prep_destroy_cb(GtkWidget *win, gpointer user_data _U_)
if (fs != NULL) {
/* Yes. Destroy it. */
- gtk_widget_destroy(fs);
+ window_destroy(fs);
}
/* Note that we no longer have a "Capture Options" dialog box. */
diff --git a/gtk/capture_info_dlg.c b/gtk/capture_info_dlg.c
index 2a7753fd1b..5acb771418 100644
--- a/gtk/capture_info_dlg.c
+++ b/gtk/capture_info_dlg.c
@@ -1,7 +1,7 @@
/* capture_info_dlg.c
* Routines for packet capture info dialog
*
- * $Id: capture_info_dlg.c,v 1.15 2004/04/14 05:46:34 ulfl Exp $
+ * $Id: capture_info_dlg.c,v 1.16 2004/05/26 03:49:21 ulfl Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -39,6 +39,7 @@
#include "globals.h"
#include "capture_combo_utils.h"
#include "dlg_utils.h"
+#include "ui_util.h"
/* a single capture counter value (with title, pointer to value and GtkWidgets) */
/* as the packet_counts is a struct, not an array, keep a pointer to the */
@@ -68,13 +69,6 @@ pct(gint num, gint denom) {
}
}
-/* stop button (or ESC key) was pressed */
-static void
-capture_info_stop_cb(GtkWidget *w _U_, gpointer data _U_) {
- capture_stop();
-}
-
-
static void
capture_info_delete_cb(GtkWidget *w _U_, GdkEvent *event _U_, gpointer data _U_) {
capture_stop();
@@ -212,18 +206,14 @@ gchar *iface)
gtk_widget_show(bbox);
stop_bt = OBJECT_GET_DATA(bbox, GTK_STOCK_STOP);
- gtk_widget_grab_default(stop_bt);
- SIGNAL_CONNECT(stop_bt, "clicked", capture_info_stop_cb,
- NULL);
+ window_set_cancel_button(info->cap_w, stop_bt, NULL);
+ SIGNAL_CONNECT(stop_bt, "clicked", capture_info_delete_cb, NULL);
+
SIGNAL_CONNECT(info->cap_w, "delete_event", capture_info_delete_cb,
NULL);
- /* Catch the "key_press_event" signal in the window, so that we can catch
- the ESC key being pressed and act as if the "Stop" button had
- been selected. */
- dlg_set_cancel(info->cap_w, stop_bt);
-
gtk_widget_show(info->cap_w);
+ window_present(info->cap_w);
cinfo->ui = info;
}
@@ -275,7 +265,7 @@ capture_info *cinfo)
capture_info_ui_t *info = cinfo->ui;
gtk_grab_remove(GTK_WIDGET(info->cap_w));
- gtk_widget_destroy(GTK_WIDGET(info->cap_w));
+ window_destroy(GTK_WIDGET(info->cap_w));
g_free(info);
}
diff --git a/gtk/capture_prefs.c b/gtk/capture_prefs.c
index 0a79b794eb..d8b622d345 100644
--- a/gtk/capture_prefs.c
+++ b/gtk/capture_prefs.c
@@ -1,7 +1,7 @@
/* capture_prefs.c
* Dialog box for capture preferences
*
- * $Id: capture_prefs.c,v 1.32 2004/04/17 01:10:09 guy Exp $
+ * $Id: capture_prefs.c,v 1.33 2004/05/26 03:49:21 ulfl Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -65,7 +65,6 @@ static gint ifrow; /* current interface row selected */
static void ifopts_edit_cb(GtkWidget *w, gpointer data);
static void ifopts_edit_ok_cb(GtkWidget *w, gpointer parent_w);
-static void ifopts_edit_close_cb(GtkWidget *close_bt, gpointer parent_w);
static void ifopts_edit_destroy_cb(GtkWidget *win, gpointer data);
static void ifopts_edit_ifsel_cb(GtkWidget *clist, gint row, gint column,
GdkEventButton *event, gpointer data);
@@ -207,7 +206,7 @@ capture_prefs_destroy(GtkWidget *w)
if (dlg != NULL) {
/* Yes. Destroy it. */
- gtk_widget_destroy(dlg);
+ window_destroy(dlg);
}
}
@@ -238,8 +237,8 @@ ifopts_edit_cb(GtkWidget *w, gpointer data _U_)
/* create a new dialog */
ifopts_edit_dlg = dlg_window_new("Ethereal: Preferences: Interface Options");
- SIGNAL_CONNECT(ifopts_edit_dlg, "destroy", ifopts_edit_destroy_cb, NULL);
- main_vb = gtk_vbox_new(FALSE, 1);
+
+ main_vb = gtk_vbox_new(FALSE, 1);
gtk_container_border_width(GTK_CONTAINER(main_vb), 5);
gtk_container_add(GTK_CONTAINER(ifopts_edit_dlg), main_vb);
gtk_widget_show(main_vb);
@@ -339,12 +338,15 @@ ifopts_edit_cb(GtkWidget *w, gpointer data _U_)
gtk_widget_show(bbox);
ok_bt = OBJECT_GET_DATA(bbox, GTK_STOCK_OK);
- gtk_widget_grab_default(ok_bt);
SIGNAL_CONNECT(ok_bt, "clicked", ifopts_edit_ok_cb, ifopts_edit_dlg);
cancel_bt = OBJECT_GET_DATA(bbox, GTK_STOCK_CANCEL);
- SIGNAL_CONNECT(cancel_bt, "clicked", ifopts_edit_close_cb, ifopts_edit_dlg);
+ window_set_cancel_button(ifopts_edit_dlg, cancel_bt, window_cancel_button_cb);
+ gtk_widget_grab_default(ok_bt);
+
+ SIGNAL_CONNECT(ifopts_edit_dlg, "delete_event", window_delete_event_cb,
+ NULL);
/* Call a handler when we're destroyed, so we can inform
our caller, if any, that we've been destroyed. */
SIGNAL_CONNECT(ifopts_edit_dlg, "destroy", ifopts_edit_destroy_cb, NULL);
@@ -354,12 +356,8 @@ ifopts_edit_cb(GtkWidget *w, gpointer data _U_)
/* Set the key for the caller to point to us */
OBJECT_SET_DATA(caller, IFOPTS_DIALOG_PTR_KEY, ifopts_edit_dlg);
- /* 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(ifopts_edit_dlg, cancel_bt);
-
gtk_widget_show(ifopts_edit_dlg);
+ window_present(ifopts_edit_dlg);
}
/*
@@ -378,14 +376,7 @@ ifopts_edit_ok_cb(GtkWidget *w _U_, gpointer parent_w)
/* Now nuke this window. */
gtk_grab_remove(GTK_WIDGET(parent_w));
- gtk_widget_destroy(GTK_WIDGET(parent_w));
-}
-
-static void
-ifopts_edit_close_cb(GtkWidget *close_bt _U_, gpointer parent_w)
-{
- gtk_grab_remove(GTK_WIDGET(parent_w));
- gtk_widget_destroy(GTK_WIDGET(parent_w));
+ window_destroy(GTK_WIDGET(parent_w));
}
static void
@@ -405,7 +396,7 @@ ifopts_edit_destroy_cb(GtkWidget *win, gpointer data _U_)
/* Now nuke this window. */
gtk_grab_remove(GTK_WIDGET(win));
- gtk_widget_destroy(GTK_WIDGET(win));
+ window_destroy(GTK_WIDGET(win));
}
/*
diff --git a/gtk/color_dlg.c b/gtk/color_dlg.c
index 0b7ac8711e..2c9c5a0966 100644
--- a/gtk/color_dlg.c
+++ b/gtk/color_dlg.c
@@ -1,7 +1,7 @@
/* color_dlg.c
* Definitions for dialog boxes for color filters
*
- * $Id: color_dlg.c,v 1.48 2004/05/22 19:56:18 ulfl Exp $
+ * $Id: color_dlg.c,v 1.49 2004/05/26 03:49:22 ulfl Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -84,7 +84,6 @@ static void edit_color_filter_destroy_cb(GObject *object, gpointer user_data);
static void edit_color_filter_fg_cb(GtkButton *button, gpointer user_data);
static void edit_color_filter_bg_cb(GtkButton *button, gpointer user_data);
static void edit_color_filter_ok_cb(GtkButton *button, gpointer user_data);
-static void edit_color_filter_cancel_cb(GtkObject *object, gpointer user_data);
static GtkWidget* color_sel_win_new(color_filter_t *colorf, gboolean);
static void color_sel_ok_cb(GtkButton *button, gpointer user_data);
@@ -423,7 +422,6 @@ colorize_dialog_new (char *filter)
gtk_box_pack_start (GTK_BOX (dlg_vbox), button_ok_hbox, FALSE, FALSE, 5);
color_ok = OBJECT_GET_DATA(button_ok_hbox, GTK_STOCK_OK);
- gtk_widget_grab_default(color_ok);
gtk_tooltips_set_tip (tooltips, color_ok, ("Apply the color filters to the display and close this dialog"), NULL);
color_apply = OBJECT_GET_DATA(button_ok_hbox, GTK_STOCK_APPLY);
@@ -432,10 +430,12 @@ colorize_dialog_new (char *filter)
color_save = OBJECT_GET_DATA(button_ok_hbox, GTK_STOCK_SAVE);
gtk_tooltips_set_tip (tooltips, color_save, ("Save the color filters permanently and keep this dialog open"), NULL);
-/* color_cancel = OBJECT_GET_DATA(button_ok_hbox, GTK_STOCK_CANCEL);*/
color_cancel = OBJECT_GET_DATA(button_ok_hbox, GTK_STOCK_CLOSE);
+ window_set_cancel_button(color_win, color_cancel, color_cancel_cb);
gtk_tooltips_set_tip (tooltips, color_cancel, ("Close this dialog but don't apply the color filter changes to the display"), NULL);
+ gtk_widget_grab_default(color_ok);
+
/* signals and such */
SIGNAL_CONNECT(color_win, "destroy", color_destroy_cb, NULL);
OBJECT_SET_DATA(color_filter_up, COLOR_FILTERS_CL, color_filters);
@@ -467,13 +467,13 @@ colorize_dialog_new (char *filter)
SIGNAL_CONNECT(color_clear, "clicked", color_clear_cb, NULL);
SIGNAL_CONNECT(color_ok, "clicked", color_ok_cb, NULL);
SIGNAL_CONNECT(color_apply, "clicked", color_apply_cb, NULL);
- SIGNAL_CONNECT(color_cancel, "clicked", color_cancel_cb, NULL);
+
+ SIGNAL_CONNECT(color_win, "delete_event", window_delete_event_cb, NULL);
gtk_widget_grab_focus(color_filters);
- OBJECT_SET_DATA(color_win, "tooltips", tooltips);
- gtk_widget_show_all(color_win);
- dlg_set_cancel(color_win, color_cancel);
+ gtk_widget_show_all(color_win);
+ window_present(color_win);
if(filter){
/* if we specified a preset filter string, open the new dialog and
@@ -853,7 +853,7 @@ destroy_edit_dialog_cb(gpointer filter_arg, gpointer dummy _U_)
color_filter_t *colorf = (color_filter_t *)filter_arg;
if (colorf->edit_dialog != NULL)
- gtk_widget_destroy(colorf->edit_dialog);
+ window_destroy(colorf->edit_dialog);
}
/* XXX - we don't forbid having more than one "Edit color filter" dialog
@@ -1001,7 +1001,7 @@ color_delete(gint row, GtkWidget *color_filters)
/* Destroy any "Edit color filter" dialog boxes editing it. */
if (colorf->edit_dialog != NULL)
- gtk_widget_destroy(colorf->edit_dialog);
+ window_destroy(colorf->edit_dialog);
/* Remove the color filter from the list of color filters. */
remove_color_filter(colorf);
@@ -1019,7 +1019,7 @@ color_delete(gint row, GtkWidget *color_filters)
/* Destroy any "Edit color filter" dialog boxes editing it. */
if (colorf->edit_dialog != NULL)
- gtk_widget_destroy(colorf->edit_dialog);
+ window_destroy(colorf->edit_dialog);
/* Remove the color filter from the list of color filters. */
remove_color_filter(colorf);
@@ -1095,7 +1095,7 @@ color_clear_cmd(GtkWidget *widget)
/* Destroy the dialog box. */
/* XXX: is this useful? user might want to continue with editing new colors */
- gtk_widget_destroy(colorize_win);
+ window_destroy(colorize_win);
}
/* clear button: user responded to question */
@@ -1134,7 +1134,7 @@ color_ok_cb(GtkButton *button _U_, gpointer user_data _U_)
colorize_packets(&cfile);
/* Destroy the dialog box. */
- gtk_widget_destroy(colorize_win);
+ window_destroy(colorize_win);
}
/* Exit dialog without colorizing packets with the new list.
@@ -1143,7 +1143,7 @@ static void
color_cancel_cb(GtkWidget *widget _U_, gpointer user_data _U_)
{
/* Destroy the dialog box. */
- gtk_widget_destroy(colorize_win);
+ window_destroy(colorize_win);
}
/* Apply new list of color filters to the capture. */
@@ -1328,12 +1328,13 @@ edit_color_filter_dialog_new(GtkWidget *color_filters,
gtk_container_set_border_width (GTK_CONTAINER (bbox), 0);
edit_color_filter_ok = OBJECT_GET_DATA(bbox, GTK_STOCK_OK);
- gtk_widget_grab_default(edit_color_filter_ok);
gtk_tooltips_set_tip (tooltips, edit_color_filter_ok, ("Accept filter color change"), NULL);
edit_color_filter_cancel = OBJECT_GET_DATA(bbox, GTK_STOCK_CANCEL);
+ window_set_cancel_button(edit_dialog, edit_color_filter_cancel, window_cancel_button_cb);
gtk_tooltips_set_tip (tooltips, edit_color_filter_cancel, ("Reject filter color change"), NULL);
+ gtk_widget_grab_default(edit_color_filter_ok);
/* signals and such */
OBJECT_SET_DATA(edit_dialog, COLOR_FILTER, colorf);
@@ -1345,14 +1346,11 @@ edit_color_filter_dialog_new(GtkWidget *color_filters,
OBJECT_SET_DATA(edit_color_filter_ok, COLOR_FILTERS_CL, color_filters);
OBJECT_SET_DATA(edit_color_filter_ok, COLOR_FILTER, colorf);
SIGNAL_CONNECT(edit_color_filter_ok, "clicked", edit_color_filter_ok_cb, edit_dialog);
- SIGNAL_CONNECT(edit_color_filter_cancel, "clicked", edit_color_filter_cancel_cb,
- edit_dialog);
- OBJECT_SET_DATA(edit_dialog, "tooltips", tooltips);
-
- dlg_set_cancel(edit_dialog, edit_color_filter_cancel);
+ SIGNAL_CONNECT(edit_dialog, "delete_event", window_delete_event_cb, NULL);
gtk_widget_show_all(edit_dialog);
+ window_present(edit_dialog);
}
/* Called when the dialog box is being destroyed; destroy any color
@@ -1375,10 +1373,10 @@ edit_color_filter_destroy_cb(GObject *object, gpointer user_data _U_)
/* Destroy any color selection dialogs this dialog had open. */
color_sel = (GtkWidget *)OBJECT_GET_DATA(object, COLOR_SELECTION_FG);
if (color_sel != NULL)
- gtk_widget_destroy(color_sel);
+ window_destroy(color_sel);
color_sel = (GtkWidget *)OBJECT_GET_DATA(object, COLOR_SELECTION_BG);
if (color_sel != NULL)
- gtk_widget_destroy(color_sel);
+ window_destroy(color_sel);
}
/* Pop up a color selection box to choose the foreground color. */
@@ -1512,22 +1510,10 @@ edit_color_filter_ok_cb (GtkButton *button,
#endif
/* Destroy the dialog box. */
- gtk_widget_destroy(dialog);
+ window_destroy(dialog);
}
}
-/* Exit dialog and do not process list */
-static void
-edit_color_filter_cancel_cb(GtkObject *object _U_, gpointer user_data)
-{
- GtkWidget *dialog;
-
- dialog = (GtkWidget *)user_data;
-
- /* Destroy the dialog box. */
- gtk_widget_destroy(dialog);
-}
-
static GtkWidget*
color_sel_win_new(color_filter_t *colorf, gboolean is_bg)
{
@@ -1621,7 +1607,7 @@ color_sel_win_destroy(GtkWidget *sel_win)
}
/* Now destroy it. */
- gtk_widget_destroy(sel_win);
+ window_destroy(sel_win);
}
/* Retrieve selected color */
diff --git a/gtk/column_prefs.c b/gtk/column_prefs.c
index c1b0b95874..aa46192d4c 100644
--- a/gtk/column_prefs.c
+++ b/gtk/column_prefs.c
@@ -1,7 +1,7 @@
/* column_prefs.c
* Dialog box for column preferences
*
- * $Id: column_prefs.c,v 1.22 2004/02/06 19:19:09 ulfl Exp $
+ * $Id: column_prefs.c,v 1.23 2004/05/26 03:49:22 ulfl Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -681,5 +681,5 @@ column_prefs_destroy(GtkWidget *w) {
/* Let the list cb know we're about to destroy the widget tree, so it */
/* doesn't operate on widgets that don't exist. */
OBJECT_SET_DATA(w, E_COL_CM_KEY, (gpointer)TRUE);
- gtk_widget_destroy(GTK_WIDGET(w));
+ window_destroy(GTK_WIDGET(w));
}
diff --git a/gtk/decode_as_dlg.c b/gtk/decode_as_dlg.c
index 82a8677abd..dae3e02669 100644
--- a/gtk/decode_as_dlg.c
+++ b/gtk/decode_as_dlg.c
@@ -1,6 +1,6 @@
/* decode_as_dlg.c
*
- * $Id: decode_as_dlg.c,v 1.39 2004/03/13 15:15:23 ulfl Exp $
+ * $Id: decode_as_dlg.c,v 1.40 2004/05/26 03:49:22 ulfl Exp $
*
* Routines to modify dissector tables on the fly.
*
@@ -71,7 +71,7 @@ enum srcdst_type {
E_DECODE_BPORT
};
-#define E_DECODE_MIN_HEIGHT 100
+#define E_DECODE_MIN_HEIGHT 300
#define E_NOTEBOOK "notebook"
#define E_MENU_SRCDST "menu_src_dst"
@@ -360,22 +360,22 @@ decode_build_show_list (gchar *table_name, ftenum_t selector_type,
static void
decode_show_ok_cb (GtkWidget *ok_bt _U_, gpointer parent_w)
{
- gtk_widget_destroy(GTK_WIDGET(parent_w));
+ window_destroy(GTK_WIDGET(parent_w));
}
/*
- * This routine is called when the user clicks the "Reset" button in
+ * This routine is called when the user clicks the "Clear" button in
* the "Decode As:Show..." dialog window. This routine resets all the
* dissector values and then destroys the dialog box and performs
* other housekeeping functions.
*
- * @param GtkWidget * A pointer to the "Reset" button.
+ * @param GtkWidget * A pointer to the "Clear" button.
*
* @param gpointer A pointer to the dialog window.
*/
static void
-decode_show_reset_cb (GtkWidget *reset_bt _U_, gpointer parent_w)
+decode_show_clear_cb (GtkWidget *clear_bt _U_, gpointer parent_w)
{
dissector_delete_item_t *item;
GSList *tmp;
@@ -409,7 +409,7 @@ decode_show_reset_cb (GtkWidget *reset_bt _U_, gpointer parent_w)
redissect_packets(&cfile);
- gtk_widget_destroy(GTK_WIDGET(parent_w));
+ window_destroy(GTK_WIDGET(parent_w));
}
@@ -481,8 +481,8 @@ decode_show_cb (GtkWidget * w _U_, gpointer data _U_)
}
decode_show_w = dlg_window_new("Ethereal: Decode As: Show");
- SIGNAL_CONNECT(decode_show_w, "delete_event", decode_show_delete_cb, NULL);
- SIGNAL_CONNECT(decode_show_w, "destroy", decode_show_destroy_cb, NULL);
+ /* Provide a minimum of a couple of rows worth of data */
+ gtk_window_set_default_size(GTK_WINDOW(decode_show_w), -1, E_DECODE_MIN_HEIGHT);
/* Container for each row of widgets */
main_vb = gtk_vbox_new(FALSE, 2);
@@ -537,21 +537,24 @@ decode_show_cb (GtkWidget * w _U_, gpointer data _U_)
gtk_container_add(GTK_CONTAINER(scrolled_window),
GTK_WIDGET(list));
gtk_box_pack_start(GTK_BOX(main_vb), scrolled_window, TRUE, TRUE, 0);
- /* Provide a minimum of a couple of rows worth of data */
- WIDGET_SET_SIZE(scrolled_window, -1, E_DECODE_MIN_HEIGHT);
}
/* Button row */
bbox = dlg_button_row_new(GTK_STOCK_OK, GTK_STOCK_CLEAR, NULL);
- gtk_container_add(GTK_CONTAINER(main_vb), bbox);
+ gtk_box_pack_start(GTK_BOX(main_vb), bbox, FALSE, FALSE, 0);
gtk_widget_show(bbox);
ok_bt = OBJECT_GET_DATA(bbox, GTK_STOCK_OK);
SIGNAL_CONNECT(ok_bt, "clicked", decode_show_ok_cb, decode_show_w);
- gtk_widget_grab_default(ok_bt);
clear_bt = OBJECT_GET_DATA(bbox, GTK_STOCK_CLEAR);
- SIGNAL_CONNECT(clear_bt, "clicked", decode_show_reset_cb, decode_show_w);
+ SIGNAL_CONNECT(clear_bt, "clicked", decode_show_clear_cb, decode_show_w);
+
+ /* set ok as default, this button won't change anything */
+ window_set_cancel_button(decode_show_w, ok_bt, NULL);
+
+ SIGNAL_CONNECT(decode_show_w, "delete_event", decode_show_delete_cb, NULL);
+ SIGNAL_CONNECT(decode_show_w, "destroy", decode_show_destroy_cb, NULL);
#if GTK_MAJOR_VERSION < 2
gtk_widget_set_sensitive(clear_bt, (list->rows != 0));
@@ -560,9 +563,8 @@ decode_show_cb (GtkWidget * w _U_, gpointer data _U_)
gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &iter));
#endif
- dlg_set_cancel(decode_show_w, ok_bt);
-
gtk_widget_show_all(decode_show_w);
+ window_present(decode_show_w);
}
@@ -795,7 +797,7 @@ decode_ok_cb (GtkWidget *ok_bt _U_, gpointer parent_w)
func(notebook_pg);
/* Now destroy the "Decode As" dialog. */
- gtk_widget_destroy(GTK_WIDGET(parent_w));
+ window_destroy(GTK_WIDGET(parent_w));
g_slist_free(decode_dimmable);
decode_dimmable = NULL;
@@ -843,7 +845,7 @@ decode_apply_cb (GtkWidget *apply_bt _U_, gpointer parent_w)
static void
decode_cancel_cb (GtkWidget *cancel_bt _U_, gpointer parent_w)
{
- gtk_widget_destroy(GTK_WIDGET(parent_w));
+ window_destroy(GTK_WIDGET(parent_w));
g_slist_free(decode_dimmable);
decode_dimmable = NULL;
}
@@ -1178,8 +1180,6 @@ decode_list_menu_start(GtkWidget *page, GtkWidget **list_p,
gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(*scrolled_win_p),
GTK_SHADOW_IN);
#endif
- /* Provide a minimum of a couple of rows worth of data */
- WIDGET_SET_SIZE(*scrolled_win_p, -1, E_DECODE_MIN_HEIGHT);
#if GTK_MAJOR_VERSION < 2
gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(*scrolled_win_p),
GTK_WIDGET(list));
@@ -1467,8 +1467,8 @@ decode_as_cb (GtkWidget * w _U_, gpointer data _U_)
requested_action = E_DECODE_YES;
decode_w = dlg_window_new("Ethereal: Decode As");
- SIGNAL_CONNECT(decode_w, "delete_event", decode_delete_cb, NULL);
- SIGNAL_CONNECT(decode_w, "destroy", decode_destroy_cb, NULL);
+ /* Provide a minimum of a couple of rows worth of data */
+ gtk_window_set_default_size(GTK_WINDOW(decode_w), -1, E_DECODE_MIN_HEIGHT);
/* Container for each row of widgets */
main_vb = gtk_vbox_new(FALSE, 2);
@@ -1493,27 +1493,26 @@ decode_as_cb (GtkWidget * w _U_, gpointer data _U_)
/* Button row */
bbox = dlg_button_row_new(GTK_STOCK_OK, GTK_STOCK_APPLY, GTK_STOCK_CANCEL, NULL);
- gtk_container_add(GTK_CONTAINER(main_vb), bbox);
+ gtk_box_pack_start(GTK_BOX(main_vb), bbox, FALSE, FALSE, 0);
gtk_widget_show(bbox);
ok_bt = OBJECT_GET_DATA(bbox, GTK_STOCK_OK);
SIGNAL_CONNECT(ok_bt, "clicked", decode_ok_cb, decode_w);
- gtk_widget_grab_default(ok_bt);
apply_bt = OBJECT_GET_DATA(bbox, GTK_STOCK_APPLY);
SIGNAL_CONNECT(apply_bt, "clicked", decode_apply_cb, decode_w);
cancel_bt = OBJECT_GET_DATA(bbox, GTK_STOCK_CANCEL);
+ window_set_cancel_button(decode_w, cancel_bt, NULL);
SIGNAL_CONNECT(cancel_bt, "clicked", decode_cancel_cb, decode_w);
- /*
- * 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(decode_w, cancel_bt);
+ gtk_widget_grab_default(ok_bt);
+
+ SIGNAL_CONNECT(decode_w, "delete_event", decode_delete_cb, NULL);
+ SIGNAL_CONNECT(decode_w, "destroy", decode_destroy_cb, NULL);
gtk_widget_show_all(decode_w);
+ window_present(decode_w);
}
diff --git a/gtk/dfilter_expr_dlg.c b/gtk/dfilter_expr_dlg.c
index aa72105952..cfdd1d0311 100644
--- a/gtk/dfilter_expr_dlg.c
+++ b/gtk/dfilter_expr_dlg.c
@@ -7,7 +7,7 @@
* Copyright 2000, Jeffrey C. Foster <jfoste@woodward.com> and
* Guy Harris <guy@alum.mit.edu>
*
- * $Id: dfilter_expr_dlg.c,v 1.55 2004/03/13 11:47:08 ulfl Exp $
+ * $Id: dfilter_expr_dlg.c,v 1.56 2004/05/26 03:49:22 ulfl Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -67,7 +67,7 @@
#define E_DFILTER_EXPR_VALUE_LIST_LABEL_KEY "dfilter_expr_value_list_label"
#define E_DFILTER_EXPR_VALUE_LIST_KEY "dfilter_expr_value_list"
#define E_DFILTER_EXPR_VALUE_LIST_SW_KEY "dfilter_expr_value_list_sw"
-#define E_DFILTER_EXPR_ACCEPT_BT_KEY "dfilter_expr_accept_bt"
+#define E_DFILTER_EXPR_OK_BT_KEY "dfilter_expr_accept_bt"
#define E_DFILTER_EXPR_VALUE_KEY "dfilter_expr_value"
typedef struct protocol_data {
@@ -124,8 +124,8 @@ field_select_row_cb(GtkTreeSelection *sel, gpointer tree)
E_DFILTER_EXPR_VALUE_LIST_KEY);
GtkWidget *value_list_scrolled_win = OBJECT_GET_DATA(window,
E_DFILTER_EXPR_VALUE_LIST_SW_KEY);
- GtkWidget *accept_bt = OBJECT_GET_DATA(window,
- E_DFILTER_EXPR_ACCEPT_BT_KEY);
+ GtkWidget *ok_bt = OBJECT_GET_DATA(window,
+ E_DFILTER_EXPR_OK_BT_KEY);
header_field_info *hfinfo, *cur_hfinfo;
const char *value_type;
char value_label_string[1024+1]; /* XXX - should be large enough */
@@ -238,7 +238,7 @@ field_select_row_cb(GtkTreeSelection *sel, gpointer tree)
* XXX - in browse mode, there always has to be something
* selected, so this should always be sensitive.
*/
- gtk_widget_set_sensitive(accept_bt, TRUE);
+ gtk_widget_set_sensitive(ok_bt, TRUE);
}
static void
@@ -1013,7 +1013,7 @@ dfilter_expr_dlg_accept_cb(GtkWidget *w, gpointer filter_te_arg)
* We're done; destroy the dialog box (which is the top-level
* widget for the "Accept" button).
*/
- gtk_widget_destroy(window);
+ window_destroy(window);
#if GTK_MAJOR_VERSION >= 2
g_free(item_str);
#endif
@@ -1025,7 +1025,7 @@ dfilter_expr_dlg_cancel_cb(GtkWidget *w _U_, gpointer parent_w)
/*
* User pressed the cancel button; close the dialog box.
*/
- gtk_widget_destroy(GTK_WIDGET(parent_w));
+ window_destroy(GTK_WIDGET(parent_w));
}
static void
@@ -1062,7 +1062,7 @@ dfilter_expr_dlg_new(GtkWidget *filter_te)
GtkWidget *value_list_label, *value_list_scrolled_win, *value_list;
GtkWidget *range_label, *range_entry;
- GtkWidget *list_bb, *accept_bt, *close_bt;
+ GtkWidget *list_bb, *ok_bt, *cancel_bt;
header_field_info *hfinfo;
int i;
protocol_t *protocol;
@@ -1293,7 +1293,7 @@ dfilter_expr_dlg_new(GtkWidget *filter_te)
* we've constructed the value list and set the tree's
* E_DFILTER_EXPR_VALUE_LIST_KEY data to point to it, and
* constructed the "Accept" button and set the tree's
- * E_DFILTER_EXPR_ACCEPT_BT_KEY data to point to it, so that
+ * E_DFILTER_EXPR_OK_BT_KEY data to point to it, so that
* when the list item is "helpfully" automatically selected for us
* we're ready to cope with the selection signal.
*/
@@ -1425,27 +1425,22 @@ dfilter_expr_dlg_new(GtkWidget *filter_te)
gtk_box_pack_start(GTK_BOX(main_vb), list_bb, FALSE, FALSE, 0);
gtk_container_set_border_width (GTK_CONTAINER (list_bb), 0);
- accept_bt = OBJECT_GET_DATA(list_bb, GTK_STOCK_OK);
- gtk_widget_set_sensitive(accept_bt, FALSE);
- SIGNAL_CONNECT(accept_bt, "clicked", dfilter_expr_dlg_accept_cb, filter_te);
- gtk_widget_grab_default(accept_bt);
+ ok_bt = OBJECT_GET_DATA(list_bb, GTK_STOCK_OK);
+ gtk_widget_set_sensitive(ok_bt, FALSE);
+ SIGNAL_CONNECT(ok_bt, "clicked", dfilter_expr_dlg_accept_cb, filter_te);
- close_bt = OBJECT_GET_DATA(list_bb, GTK_STOCK_CANCEL);
- SIGNAL_CONNECT(close_bt, "clicked", dfilter_expr_dlg_cancel_cb, window);
+ cancel_bt = OBJECT_GET_DATA(list_bb, GTK_STOCK_CANCEL);
+ window_set_cancel_button(window, cancel_bt, NULL);
+ SIGNAL_CONNECT(cancel_bt, "clicked", dfilter_expr_dlg_cancel_cb, window);
+
+ gtk_widget_grab_default(ok_bt);
/* Catch the "activate" signal on the range and value text entries,
so that if the user types Return there, we act as if the "Accept"
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(range_entry, accept_bt);
- dlg_set_activate(value_entry, accept_bt);
-
- /*
- * Catch the "key_press_event" signal in the window, so that we can
- * catch the ESC key being pressed and act as if the "Close" button
- * had been selected.
- */
- dlg_set_cancel(window, close_bt);
+ dlg_set_activate(range_entry, ok_bt);
+ dlg_set_activate(value_entry, ok_bt);
OBJECT_SET_DATA(window, E_DFILTER_EXPR_RELATION_LIST_KEY, relation_list);
OBJECT_SET_DATA(window, E_DFILTER_EXPR_RANGE_LABEL_KEY, range_label);
@@ -1456,7 +1451,7 @@ dfilter_expr_dlg_new(GtkWidget *filter_te)
OBJECT_SET_DATA(window, E_DFILTER_EXPR_VALUE_LIST_LABEL_KEY, value_list_label);
OBJECT_SET_DATA(window, E_DFILTER_EXPR_VALUE_LIST_SW_KEY,
value_list_scrolled_win);
- OBJECT_SET_DATA(window, E_DFILTER_EXPR_ACCEPT_BT_KEY, accept_bt);
+ OBJECT_SET_DATA(window, E_DFILTER_EXPR_OK_BT_KEY, ok_bt);
#if GTK_MAJOR_VERSION < 2
/*
@@ -1468,6 +1463,8 @@ dfilter_expr_dlg_new(GtkWidget *filter_te)
GTK_SELECTION_BROWSE);
#endif
+ SIGNAL_CONNECT(window, "delete_event", dfilter_expr_dlg_cancel_cb, window);
+
/*
* Catch the "destroy" signal on our top-level window, and,
* when it's destroyed, disconnect the signal we'll be
@@ -1483,4 +1480,5 @@ dfilter_expr_dlg_new(GtkWidget *filter_te)
SIGNAL_CONNECT(filter_te, "destroy", dfilter_expr_dlg_cancel_cb, window);
gtk_widget_show_all(window);
+ window_present(window);
}
diff --git a/gtk/dlg_utils.c b/gtk/dlg_utils.c
index e2963413c2..6d15b11ad2 100644
--- a/gtk/dlg_utils.c
+++ b/gtk/dlg_utils.c
@@ -1,7 +1,7 @@
/* dlg_utils.c
* Utilities to use when constructing dialogs
*
- * $Id: dlg_utils.c,v 1.35 2004/05/24 17:41:26 ulfl Exp $
+ * $Id: dlg_utils.c,v 1.36 2004/05/26 03:49:22 ulfl Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -29,21 +29,33 @@
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
+#include <epan/filesystem.h>
+
+#include "globals.h"
+
#include "gtkglobals.h"
#include "ui_util.h"
#include "dlg_utils.h"
+#include "keys.h"
#include "compat_macros.h"
+#include "main.h"
#include <string.h>
#include <stdio.h>
#include <stdarg.h>
+
+/* Keys ... */
+#define E_FS_CALLER_PTR_KEY "fs_caller_ptr"
+
+
static void
dlg_activate (GtkWidget *widget, gpointer ok_button);
-static gint
-dlg_key_press (GtkWidget *widget, GdkEventKey *event, gpointer cancel_button);
-
+#if (GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION < 4) || GTK_MAJOR_VERSION < 2
+static void file_selection_browse_ok_cb(GtkWidget *w, gpointer data);
+#endif
+static void file_selection_browse_destroy_cb(GtkWidget *win, GtkWidget* file_te);
/* create a button for the button row (helper for dlg_button_row_new) */
@@ -409,6 +421,123 @@ file_selection_set_extra_widget(GtkWidget *fs, GtkWidget *extra)
#endif
}
+
+/*
+ * A generic select_file routine that is intended to be connected to
+ * a Browse button on other dialog boxes. This allows the user to browse
+ * for a file and select it. We fill in the text_entry that is given to us.
+ *
+ * We display the window label specified in our args.
+ */
+void
+file_selection_browse(GtkWidget *file_bt, GtkWidget *file_te, const char *label, file_selection_action_t action)
+{
+ GtkWidget *caller = gtk_widget_get_toplevel(file_bt);
+ GtkWidget *fs;
+#if (GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION >= 4) || GTK_MAJOR_VERSION > 2
+ gchar *f_name;
+#endif
+
+ /* Has a file selection dialog box already been opened for that top-level
+ widget? */
+ fs = OBJECT_GET_DATA(caller, E_FILE_SEL_DIALOG_PTR_KEY);
+ if (fs != NULL) {
+ /* Yes. Just re-activate that dialog box. */
+ reactivate_window(fs);
+ return;
+ }
+
+ fs = file_selection_new(label, action);
+
+ /* If we've opened a file, start out by showing the files in the directory
+ in which that file resided. */
+ if (last_open_dir)
+ file_selection_set_current_folder(fs, last_open_dir);
+
+ OBJECT_SET_DATA(fs, PRINT_FILE_TE_KEY, file_te);
+
+ /* Set the E_FS_CALLER_PTR_KEY for the new dialog to point to our caller. */
+ OBJECT_SET_DATA(fs, E_FS_CALLER_PTR_KEY, caller);
+
+ /* Set the E_FILE_SEL_DIALOG_PTR_KEY for the caller to point to us */
+ OBJECT_SET_DATA(caller, E_FILE_SEL_DIALOG_PTR_KEY, fs);
+
+ /* Call a handler when the file selection box is destroyed, so we can inform
+ our caller, if any, that it's been destroyed. */
+ SIGNAL_CONNECT(fs, "destroy", GTK_SIGNAL_FUNC(file_selection_browse_destroy_cb),
+ file_te);
+
+#if (GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION >= 4) || GTK_MAJOR_VERSION > 2
+ if (gtk_dialog_run(GTK_DIALOG(fs)) == GTK_RESPONSE_ACCEPT)
+ {
+ f_name = g_strdup(gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(fs)));
+ gtk_entry_set_text(GTK_ENTRY(file_te), f_name);
+ g_free(f_name);
+ }
+ window_destroy(fs);
+#else
+ SIGNAL_CONNECT(GTK_FILE_SELECTION(fs)->ok_button, "clicked",
+ file_selection_browse_ok_cb, fs);
+
+ window_set_cancel_button(fs, GTK_FILE_SELECTION(fs)->cancel_button, NULL);
+
+ SIGNAL_CONNECT(fs, "delete_event", window_delete_event_cb, fs);
+
+ gtk_widget_show(fs);
+ window_present(fs);
+#endif
+}
+
+
+#if (GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION < 4) || GTK_MAJOR_VERSION < 2
+static void
+file_selection_browse_ok_cb(GtkWidget *w _U_, gpointer data)
+{
+ gchar *f_name;
+ GtkWidget *win = data;
+
+ f_name = g_strdup(gtk_file_selection_get_filename(GTK_FILE_SELECTION (data)));
+
+ /* Perhaps the user specified a directory instead of a file.
+ Check whether they did. */
+ if (test_for_directory(f_name) == EISDIR) {
+ /* It's a directory - set the file selection box to display it. */
+ set_last_open_dir(f_name);
+ g_free(f_name);
+ gtk_file_selection_set_filename(GTK_FILE_SELECTION(data),
+ last_open_dir);
+ return;
+ }
+
+ gtk_entry_set_text(GTK_ENTRY(OBJECT_GET_DATA(win, PRINT_FILE_TE_KEY)),
+ f_name);
+ window_destroy(GTK_WIDGET(win));
+
+ g_free(f_name);
+}
+#endif
+
+static void
+file_selection_browse_destroy_cb(GtkWidget *win, GtkWidget* parent_te)
+{
+ GtkWidget *caller;
+
+ /* Get the widget that requested that we be popped up.
+ (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_FS_CALLER_PTR_KEY);
+
+ /* Tell it we no longer exist. */
+ OBJECT_SET_DATA(caller, E_FILE_SEL_DIALOG_PTR_KEY, NULL);
+
+ /* Give the focus to the file text entry widget so the user can just press
+ Return to print to the file. */
+ gtk_widget_grab_focus(parent_te);
+}
+
+
+
+
/* Set the "activate" signal for a widget to call a routine to
activate the "OK" button for a dialog box.
@@ -430,37 +559,6 @@ dlg_activate (GtkWidget *widget _U_, gpointer ok_button)
gtk_widget_activate(GTK_WIDGET(ok_button));
}
-/* Set the "key_press_event" signal for a top-level dialog window to
- call a routine to activate the "Cancel" button for a dialog box if
- the key being pressed is the <Esc> key.
-
- XXX - there should be a GTK+ widget that'll do that for you, and
- let you specify a "Cancel" button. It should also not impose
- a requirement that there be a separator in the dialog box, as
- the GtkDialog widget does; the visual convention that there's
- such a separator between the rest of the dialog boxes and buttons
- such as "OK" and "Cancel" is, for better or worse, not universal
- (not even in GTK+ - look at the GtkFileSelection dialog!). */
-void
-dlg_set_cancel(GtkWidget *widget, GtkWidget *cancel_button)
-{
- SIGNAL_CONNECT(widget, "key_press_event", dlg_key_press, cancel_button);
-}
-
-static gint
-dlg_key_press (GtkWidget *widget, GdkEventKey *event, gpointer cancel_button)
-{
- g_return_val_if_fail (widget != NULL, FALSE);
- g_return_val_if_fail (event != NULL, FALSE);
-
- if (event->keyval == GDK_Escape) {
- gtk_widget_activate(GTK_WIDGET(cancel_button));
- return TRUE;
- }
-
- return FALSE;
-}
-
#if GTK_MAJOR_VERSION < 2
/* Sigh. GTK+ appears not to acknowledge that it should be possible
to attach mnemonics to anything other than menu items; provide
diff --git a/gtk/dlg_utils.h b/gtk/dlg_utils.h
index 4b6d4b9979..75380ee677 100644
--- a/gtk/dlg_utils.h
+++ b/gtk/dlg_utils.h
@@ -1,7 +1,7 @@
/* dlg_utils.h
* Declarations of utilities to use when constructing dialogs
*
- * $Id: dlg_utils.h,v 1.14 2004/05/23 17:37:36 ulfl Exp $
+ * $Id: dlg_utils.h,v 1.15 2004/05/26 03:49:22 ulfl Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -27,7 +27,7 @@
/* Create a dialog box window that belongs to Ethereal's main window,
* see wíndow_new() for usage */
-extern GtkWidget *dlg_window_new(const gchar *);
+extern GtkWidget *dlg_window_new(const gchar *title);
/* Create a file selection dialog box window that belongs to Ethereal's
main window. */
@@ -35,14 +35,19 @@ typedef enum {
FILE_SELECTION_OPEN,
FILE_SELECTION_SAVE
} file_selection_action_t;
-extern GtkWidget *file_selection_new(const gchar *, file_selection_action_t);
+extern GtkWidget *file_selection_new(const gchar *title, file_selection_action_t action);
/* Set the current folder for a file selection dialog. */
-extern gboolean file_selection_set_current_folder(GtkWidget *, const gchar *);
+extern gboolean file_selection_set_current_folder(GtkWidget *fs, const gchar *filename);
/* Set the "extra" widget for a file selection dialog, with user-supplied
options. */
-extern void file_selection_set_extra_widget(GtkWidget *, GtkWidget *);
+extern void file_selection_set_extra_widget(GtkWidget *fs, GtkWidget *extra);
+
+#define E_FILE_SEL_DIALOG_PTR_KEY "file_sel_dialog_ptr"
+
+extern void
+file_selection_browse(GtkWidget *file_bt, GtkWidget *file_te, const char *label, file_selection_action_t action);
/* Create a button row for a dialog */
/* the button widgets will be available by OBJECT_GET_DATA(stock_id) */
@@ -52,11 +57,6 @@ extern GtkWidget *dlg_button_row_new(gchar *stock_id_first, ...);
activate the "OK" button for a dialog box. */
extern void dlg_set_activate(GtkWidget *widget, GtkWidget *ok_button);
-/* Set the "key_press_event" signal for a top-level dialog window to
- call a routine to activate the "Cancel" button for a dialog box if
- the key being pressed is the <Esc> key. */
-extern void dlg_set_cancel(GtkWidget *widget, GtkWidget *cancel_button);
-
/* used by compat_macros.h only */
extern GtkWidget *dlg_radio_button_new_with_label_with_mnemonic(GSList *group,
diff --git a/gtk/file_dlg.c b/gtk/file_dlg.c
index 088754fe39..ef6bb3b37b 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.105 2004/04/23 03:22:10 guy Exp $
+ * $Id: file_dlg.c,v 1.106 2004/05/26 03:49:22 ulfl Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -40,8 +40,8 @@
#include "alert_box.h"
#include "simple_dialog.h"
#include "menu.h"
-#include "file_dlg.h"
#include "dlg_utils.h"
+#include "file_dlg.h"
#include "main.h"
#include "compat_macros.h"
#include "prefs.h"
@@ -65,11 +65,6 @@ static void file_color_import_ok_cb(GtkWidget *w, gpointer fs);
static void file_color_import_destroy_cb(GtkWidget *win, gpointer user_data);
static void file_color_export_ok_cb(GtkWidget *w, gpointer fs);
static void file_color_export_destroy_cb(GtkWidget *win, gpointer user_data);
-#if (GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION < 4) || GTK_MAJOR_VERSION < 2
-static void file_select_ok_cb(GtkWidget *w, gpointer data);
-static void file_select_cancel_cb(GtkWidget *w, gpointer data);
-#endif
-static void file_select_destroy_cb(GtkWidget *win, GtkWidget* file_te);
#define E_FILE_M_RESOLVE_KEY "file_dlg_mac_resolve_key"
#define E_FILE_N_RESOLVE_KEY "file_dlg_network_resolve_key"
@@ -85,132 +80,7 @@ static void file_select_destroy_cb(GtkWidget *win, GtkWidget* file_te);
*/
static GtkWidget *file_save_as_w;
-/*
- * A generic select_file_cb routine that is intended to be connected to
- * a Browse button on other dialog boxes. This allows the user to browse
- * for a file and select it. We fill in the text_entry that is asssociated
- * with the button that invoked us.
- *
- * We display the window label specified in our args.
- */
-void
-select_file_cb(GtkWidget *file_bt, const char *label)
-{
- GtkWidget *caller = gtk_widget_get_toplevel(file_bt);
- GtkWidget *fs, *file_te;
-#if (GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION >= 4) || GTK_MAJOR_VERSION > 2
- gchar *f_name;
-#endif
-
- /* Has a file selection dialog box already been opened for that top-level
- widget? */
- fs = OBJECT_GET_DATA(caller, E_FILE_SEL_DIALOG_PTR_KEY);
- file_te = OBJECT_GET_DATA(file_bt, E_FILE_TE_PTR_KEY);
- if (fs != NULL) {
- /* Yes. Just re-activate that dialog box. */
- reactivate_window(fs);
- return;
- }
-
- fs = file_selection_new(label, FILE_SELECTION_SAVE);
-
- /* If we've opened a file, start out by showing the files in the directory
- in which that file resided. */
- if (last_open_dir)
- file_selection_set_current_folder(fs, last_open_dir);
-
- OBJECT_SET_DATA(fs, PRINT_FILE_TE_KEY, file_te);
-
- /* Set the E_FS_CALLER_PTR_KEY for the new dialog to point to our caller. */
- OBJECT_SET_DATA(fs, E_FS_CALLER_PTR_KEY, caller);
-
- /* Set the E_FILE_SEL_DIALOG_PTR_KEY for the caller to point to us */
- OBJECT_SET_DATA(caller, E_FILE_SEL_DIALOG_PTR_KEY, fs);
-
- /* Call a handler when the file selection box is destroyed, so we can inform
- our caller, if any, that it's been destroyed. */
- SIGNAL_CONNECT(fs, "destroy", GTK_SIGNAL_FUNC(file_select_destroy_cb),
- file_te);
-
-#if (GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION >= 4) || GTK_MAJOR_VERSION > 2
- if (gtk_dialog_run(GTK_DIALOG(fs)) == GTK_RESPONSE_ACCEPT)
- {
- f_name = g_strdup(gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(fs)));
- gtk_entry_set_text(GTK_ENTRY(file_te), f_name);
- g_free(f_name);
- }
- gtk_widget_destroy(fs);
-#else
- SIGNAL_CONNECT(GTK_FILE_SELECTION(fs)->ok_button, "clicked",
- file_select_ok_cb, fs);
-
- /* Connect the cancel_button to destroy the widget */
- SIGNAL_CONNECT(GTK_FILE_SELECTION(fs)->cancel_button, "clicked",
- file_select_cancel_cb, fs);
-
- /* 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(fs, GTK_FILE_SELECTION(fs)->cancel_button);
-
- gtk_widget_show(fs);
-#endif
-}
-
-#if (GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION < 4) || GTK_MAJOR_VERSION < 2
-static void
-file_select_ok_cb(GtkWidget *w _U_, gpointer data)
-{
- gchar *f_name;
-
- f_name = g_strdup(gtk_file_selection_get_filename(GTK_FILE_SELECTION (data)));
-
- /* Perhaps the user specified a directory instead of a file.
- Check whether they did. */
- if (test_for_directory(f_name) == EISDIR) {
- /* It's a directory - set the file selection box to display it. */
- set_last_open_dir(f_name);
- g_free(f_name);
- gtk_file_selection_set_filename(GTK_FILE_SELECTION(data),
- last_open_dir);
- return;
- }
-
- gtk_entry_set_text(GTK_ENTRY(OBJECT_GET_DATA(data, PRINT_FILE_TE_KEY)),
- f_name);
- gtk_widget_destroy(GTK_WIDGET(data));
-
- g_free(f_name);
-}
-
-static void
-file_select_cancel_cb(GtkWidget *w _U_, gpointer data)
-{
- gtk_widget_destroy(GTK_WIDGET(data));
-}
-#endif
-
-static void
-file_select_destroy_cb(GtkWidget *win, GtkWidget* file_te)
-{
- GtkWidget *caller;
-
- /* Get the widget that requested that we be popped up.
- (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_FS_CALLER_PTR_KEY);
-
- /* Tell it we no longer exist. */
- OBJECT_SET_DATA(caller, E_FILE_SEL_DIALOG_PTR_KEY, NULL);
- /* Now nuke this window. */
- gtk_grab_remove(GTK_WIDGET(win));
- gtk_widget_destroy(GTK_WIDGET(win));
-
- /* Give the focus to the file text entry widget so the user can just press
- Return to print to the file. */
- gtk_widget_grab_focus(file_te);
-}
/*
* Keep a static pointer to the current "Open Capture File" window, if
@@ -245,7 +115,6 @@ file_open_cmd(GtkWidget *w)
file_open_w = file_selection_new("Ethereal: Open Capture File",
FILE_SELECTION_OPEN);
- SIGNAL_CONNECT(file_open_w, "destroy", file_open_destroy_cb, NULL);
#if GTK_MAJOR_VERSION < 2
/* Accelerator group for the accelerators (or, as they're called in
@@ -343,6 +212,9 @@ file_open_cmd(GtkWidget *w)
E_FILE_T_RESOLVE_KEY, t_resolv_cb);
#endif
+
+ SIGNAL_CONNECT(file_open_w, "destroy", file_open_destroy_cb, NULL);
+
#if (GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION >= 4) || GTK_MAJOR_VERSION > 2
OBJECT_SET_DATA(file_open_w, E_DFILTER_TE_KEY,
OBJECT_GET_DATA(w, E_DFILTER_TE_KEY));
@@ -350,7 +222,7 @@ file_open_cmd(GtkWidget *w)
{
file_open_ok_cb(file_open_w, file_open_w);
}
- else gtk_widget_destroy(file_open_w);
+ else window_destroy(file_open_w);
#else
/* Connect the ok_button to file_open_ok_cb function and pass along a
pointer to the file selection box widget */
@@ -361,16 +233,13 @@ file_open_cmd(GtkWidget *w)
E_DFILTER_TE_KEY, OBJECT_GET_DATA(w, E_DFILTER_TE_KEY));
/* Connect the cancel_button to destroy the widget */
- SIGNAL_CONNECT_OBJECT(GTK_FILE_SELECTION(file_open_w)->cancel_button,
- "clicked", (GtkSignalFunc)gtk_widget_destroy,
- file_open_w);
+ window_set_cancel_button(file_open_w,
+ GTK_FILE_SELECTION(file_open_w)->cancel_button, window_cancel_button_cb);
- /* 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(file_open_w, GTK_FILE_SELECTION(file_open_w)->cancel_button);
+ SIGNAL_CONNECT(file_open_w, "delete_event", window_delete_event_cb, NULL);
gtk_widget_show(file_open_w);
+ window_present(file_open_w);
#endif
}
@@ -466,8 +335,7 @@ file_open_ok_cb(GtkWidget *w, gpointer fs) {
g_resolv_flags |= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (t_resolv_cb)) ? RESOLV_TRANSPORT : RESOLV_NONE;
/* We've crossed the Rubicon; get rid of the file selection box. */
- gtk_widget_hide(GTK_WIDGET (fs));
- gtk_widget_destroy(GTK_WIDGET (fs));
+ window_destroy(GTK_WIDGET (fs));
switch (cf_read(&cfile)) {
@@ -699,7 +567,6 @@ file_save_as_cmd(action_after_save_e action_after_save, gpointer action_after_sa
/* build the file selection */
file_save_as_w = file_selection_new ("Ethereal: Save Capture File As",
FILE_SELECTION_SAVE);
- SIGNAL_CONNECT(file_save_as_w, "destroy", file_save_as_destroy_cb, NULL);
/* as the dialog might already be gone, when using this values, we cannot
* set data to the dialog object, but keep global values */
@@ -765,31 +632,29 @@ file_save_as_cmd(action_after_save_e action_after_save, gpointer action_after_sa
/* dynamic values in the range frame */
range_update_dynamics(range_tb);
+ SIGNAL_CONNECT(file_save_as_w, "destroy", file_save_as_destroy_cb, NULL);
+
#if (GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION >= 4) || GTK_MAJOR_VERSION > 2
- if (gtk_dialog_run(GTK_DIALOG(file_save_as_w)) == GTK_RESPONSE_ACCEPT)
- {
+ if (gtk_dialog_run(GTK_DIALOG(file_save_as_w)) == GTK_RESPONSE_ACCEPT) {
file_save_as_ok_cb(file_save_as_w, file_save_as_w);
+ } else {
+ window_destroy(file_save_as_w);
}
- else gtk_widget_destroy(file_save_as_w);
#else
/* Connect the ok_button to file_save_as_ok_cb function and pass along a
pointer to the file selection box widget */
SIGNAL_CONNECT(GTK_FILE_SELECTION (file_save_as_w)->ok_button, "clicked",
file_save_as_ok_cb, file_save_as_w);
- /* Connect the cancel_button to destroy the widget */
- SIGNAL_CONNECT_OBJECT(GTK_FILE_SELECTION(file_save_as_w)->cancel_button,
- "clicked", (GtkSignalFunc)gtk_widget_destroy,
- file_save_as_w);
+ window_set_cancel_button(file_save_as_w,
+ GTK_FILE_SELECTION(file_save_as_w)->cancel_button, window_cancel_button_cb);
- /* 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(file_save_as_w, GTK_FILE_SELECTION(file_save_as_w)->cancel_button);
+ SIGNAL_CONNECT(file_save_as_w, "delete_event", window_delete_event_cb, NULL);
gtk_file_selection_set_filename(GTK_FILE_SELECTION(file_save_as_w), "");
gtk_widget_show(file_save_as_w);
+ window_present(file_save_as_w);
#endif
}
@@ -838,7 +703,7 @@ file_save_as_ok_cb(GtkWidget *w _U_, gpointer fs) {
/* The write succeeded; get rid of the file selection box. */
/* cf_save might already closed our dialog! */
if (file_save_as_w)
- gtk_widget_destroy(GTK_WIDGET (fs));
+ window_destroy(GTK_WIDGET (fs));
/* Save the directory name for future file dialogs. */
dirname = get_dirname(cf_name); /* Overwrites cf_name */
@@ -880,7 +745,7 @@ void
file_save_as_destroy(void)
{
if (file_save_as_w)
- gtk_widget_destroy(file_save_as_w);
+ window_destroy(file_save_as_w);
}
static void
@@ -989,7 +854,6 @@ file_color_import_cmd_cb(GtkWidget *w _U_, gpointer data)
file_color_import_w = file_selection_new("Ethereal: Import Color Filters",
FILE_SELECTION_OPEN);
- SIGNAL_CONNECT(file_color_import_w, "destroy", file_color_import_destroy_cb, NULL);
#if GTK_MAJOR_VERSION < 2
/* Accelerator group for the accelerators (or, as they're called in
@@ -1016,6 +880,8 @@ file_color_import_cmd_cb(GtkWidget *w _U_, gpointer data)
SIGNAL_CONNECT(cfglobal_but, "clicked", color_global_cb, file_color_import_w);
gtk_widget_show(cfglobal_but);
+ SIGNAL_CONNECT(file_color_import_w, "destroy", file_color_import_destroy_cb, NULL);
+
#if (GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION >= 4) || GTK_MAJOR_VERSION > 2
OBJECT_SET_DATA(file_color_import_w, ARGUMENT_CL, data);
@@ -1023,7 +889,7 @@ file_color_import_cmd_cb(GtkWidget *w _U_, gpointer data)
{
file_color_import_ok_cb(file_color_import_w, file_color_import_w);
}
- else gtk_widget_destroy(file_color_import_w);
+ else window_destroy(file_color_import_w);
#else
/* Connect the ok_button to file_open_ok_cb function and pass along a
pointer to the file selection box widget */
@@ -1033,17 +899,14 @@ file_color_import_cmd_cb(GtkWidget *w _U_, gpointer data)
OBJECT_SET_DATA(GTK_FILE_SELECTION(file_color_import_w)->ok_button,
ARGUMENT_CL, data);
- /* Connect the cancel_button to destroy the widget */
- SIGNAL_CONNECT_OBJECT(GTK_FILE_SELECTION(file_color_import_w)->cancel_button,
- "clicked", (GtkSignalFunc)gtk_widget_destroy,
- file_color_import_w);
+ window_set_cancel_button(file_color_import_w,
+ GTK_FILE_SELECTION(file_color_import_w)->cancel_button, window_cancel_button_cb);
+
+ SIGNAL_CONNECT(file_color_import_w, "delete_event", window_delete_event_cb, NULL);
- /* 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(file_color_import_w, GTK_FILE_SELECTION(file_color_import_w)->cancel_button);
gtk_widget_show(file_color_import_w);
+ window_present(file_color_import_w);
#endif
}
@@ -1082,8 +945,7 @@ file_color_import_ok_cb(GtkWidget *w, gpointer fs) {
}
/* We've crossed the Rubicon; get rid of the file selection box. */
- gtk_widget_hide(GTK_WIDGET (fs));
- gtk_widget_destroy(GTK_WIDGET (fs));
+ window_destroy(GTK_WIDGET (fs));
/* Save the name of the containing directory specified in the path name,
if any; we can write over cf_name, which is a good thing, given that
@@ -1154,7 +1016,6 @@ file_color_export_cmd_cb(GtkWidget *w _U_, gpointer data _U_)
file_color_export_w = file_selection_new("Ethereal: Export Color Filters",
FILE_SELECTION_SAVE);
- SIGNAL_CONNECT(file_color_export_w, "destroy", file_color_export_destroy_cb, NULL);
/* If we've opened a file, start out by showing the files in the directory
in which that file resided. */
@@ -1179,31 +1040,30 @@ file_color_export_cmd_cb(GtkWidget *w _U_, gpointer data _U_)
SIGNAL_CONNECT(cfglobal_but, "clicked", color_global_cb, file_color_export_w);
gtk_widget_show(cfglobal_but);
+ SIGNAL_CONNECT(file_color_export_w, "destroy", file_color_export_destroy_cb, NULL);
+
#if (GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION >= 4) || GTK_MAJOR_VERSION > 2
if (gtk_dialog_run(GTK_DIALOG(file_color_export_w)) == GTK_RESPONSE_ACCEPT)
{
file_color_export_ok_cb(file_color_export_w, file_color_export_w);
}
- else gtk_widget_destroy(file_color_export_w);
+ else window_destroy(file_color_export_w);
#else
/* Connect the ok_button to file_export_ok_cb function and pass along a
pointer to the file selection box widget */
SIGNAL_CONNECT(GTK_FILE_SELECTION (file_color_export_w)->ok_button, "clicked",
file_color_export_ok_cb, file_color_export_w);
- /* Connect the cancel_button to destroy the widget */
- SIGNAL_CONNECT_OBJECT(GTK_FILE_SELECTION(file_color_export_w)->cancel_button,
- "clicked", (GtkSignalFunc)gtk_widget_destroy,
- file_color_export_w);
+ window_set_cancel_button(file_color_export_w,
+ GTK_FILE_SELECTION(file_color_export_w)->cancel_button, window_cancel_button_cb);
+
+ SIGNAL_CONNECT(file_color_export_w, "delete_event", window_delete_event_cb, NULL);
- /* 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(file_color_export_w, GTK_FILE_SELECTION(file_color_export_w)->cancel_button);
gtk_file_selection_set_filename(GTK_FILE_SELECTION(file_color_export_w), "");
gtk_widget_show(file_color_export_w);
+ window_present(file_color_export_w);
#endif
}
@@ -1243,8 +1103,7 @@ file_color_export_ok_cb(GtkWidget *w _U_, gpointer fs) {
}
/* The write succeeded; get rid of the file selection box. */
- gtk_widget_hide(GTK_WIDGET (fs));
- gtk_widget_destroy(GTK_WIDGET (fs));
+ window_destroy(GTK_WIDGET (fs));
/* Save the directory name for future file dialogs. */
dirname = get_dirname(cf_name); /* Overwrites cf_name */
diff --git a/gtk/file_dlg.h b/gtk/file_dlg.h
index e14c8d24c9..fc57038d50 100644
--- a/gtk/file_dlg.h
+++ b/gtk/file_dlg.h
@@ -1,7 +1,7 @@
/* file_dlg.h
* Definitions for dialog boxes for handling files
*
- * $Id: file_dlg.h,v 1.9 2004/01/31 18:32:36 ulfl Exp $
+ * $Id: file_dlg.h,v 1.10 2004/05/26 03:49:22 ulfl Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -43,16 +43,10 @@ void file_save_cmd_cb(GtkWidget *, gpointer);
void file_save_as_cmd_cb(GtkWidget *, gpointer);
void file_close_cmd_cb(GtkWidget *, gpointer);
void file_reload_cmd_cb(GtkWidget *, gpointer);
-void select_file_cb(GtkWidget *file_bt, const char *label);
void file_color_import_cmd_cb(GtkWidget *w, gpointer data);
void file_color_export_cmd_cb(GtkWidget *, gpointer);
-/* Keys ... */
-#define E_FILE_TE_PTR_KEY "file_te_ptr"
-#define E_FILE_SEL_DIALOG_PTR_KEY "file_sel_dialog_ptr"
-#define E_FS_CALLER_PTR_KEY "fs_caller_ptr"
-
/*
* Set the "Save only marked packets" toggle button as appropriate for
* the current output file type and count of marked packets.
diff --git a/gtk/filter_prefs.c b/gtk/filter_prefs.c
index a0a46b1ac9..3c33339a46 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.62 2004/02/28 04:21:49 guy Exp $
+ * $Id: filter_prefs.c,v 1.63 2004/05/26 03:49:22 ulfl Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -74,7 +74,6 @@ static void filter_dlg_ok_cb(GtkWidget *ok_bt, gpointer dummy);
static void filter_dlg_apply_cb(GtkWidget *apply_bt, gpointer dummy);
static void filter_apply(GtkWidget *main_w, gboolean destroy);
static void filter_dlg_save_cb(GtkWidget *save_bt, gpointer parent_w);
-static void filter_dlg_close_cb(GtkWidget *close_bt, gpointer parent_w);
static void filter_dlg_destroy_cb(GtkWidget *win, gpointer data);
static gint filter_sel_list_button_cb(GtkWidget *, GdkEventButton *,
@@ -180,7 +179,7 @@ filter_button_destroy_cb(GtkWidget *button, gpointer user_data _U_)
if (filter_w != NULL) {
/* Yes. Break the association, and destroy the dialog. */
OBJECT_SET_DATA(button, E_FILT_DIALOG_PTR_KEY, NULL);
- gtk_widget_destroy(filter_w);
+ window_destroy(filter_w);
}
}
@@ -364,10 +363,6 @@ filter_dialog_new(GtkWidget *button, 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 detach ourselves
- from the button. */
- SIGNAL_CONNECT(main_w, "destroy", filter_dlg_destroy_cb, filter_list_type_p);
-
main_vb = gtk_vbox_new(FALSE, 0);
gtk_container_border_width(GTK_CONTAINER(main_vb), 5);
gtk_container_add(GTK_CONTAINER(main_w), main_vb);
@@ -586,6 +581,7 @@ filter_dialog_new(GtkWidget *button, GtkWidget *parent_filter_te,
gtk_box_pack_start(GTK_BOX(main_vb), bbox, FALSE, FALSE, 5);
gtk_widget_show(bbox);
+ ok_bt = NULL;
if (parent_filter_te != NULL) {
/*
* We have a filter text entry that we can fill in if
@@ -593,7 +589,6 @@ filter_dialog_new(GtkWidget *button, GtkWidget *parent_filter_te,
*/
ok_bt = OBJECT_GET_DATA(bbox, GTK_STOCK_OK);
SIGNAL_CONNECT(ok_bt, "clicked", filter_dlg_ok_cb, NULL);
- gtk_widget_grab_default(ok_bt);
gtk_tooltips_set_tip (tooltips, ok_bt, ("Apply the filters and close this dialog"), NULL);
/* Catch the "activate" signal on the filter name and filter
@@ -616,7 +611,6 @@ filter_dialog_new(GtkWidget *button, GtkWidget *parent_filter_te,
gtk_tooltips_set_tip (tooltips, save_bt, ("Save the filters permanently and keep this dialog open"), NULL);
close_bt = OBJECT_GET_DATA(bbox, GTK_STOCK_CLOSE);
- SIGNAL_CONNECT(close_bt, "clicked", filter_dlg_close_cb, main_w);
gtk_tooltips_set_tip (tooltips, close_bt, ("Close this dialog but don't apply the filter changes"), NULL);
if (parent_filter_te == NULL)
gtk_widget_grab_default(close_bt);
@@ -629,16 +623,18 @@ filter_dialog_new(GtkWidget *button, GtkWidget *parent_filter_te,
}
gtk_tooltips_set_tip (tooltips, help_bt, ("Show topic specific help"), NULL);
- /*
- * Catch the "key_press_event" signal in the window, so that we can
- * catch the ESC key being pressed and act as if the "Close" button
- * had been selected.
- */
- dlg_set_cancel(main_w, close_bt);
+ window_set_cancel_button(main_w, close_bt, window_cancel_button_cb);
+
+ if(ok_bt) {
+ gtk_widget_grab_default(ok_bt);
+ }
remember_filter_dialog(main_w, filter_dialogs);
- gtk_widget_show(main_w);
+ SIGNAL_CONNECT(main_w, "delete_event", window_delete_event_cb, NULL);
+ /* Call a handler when we're destroyed, so we can detach ourselves
+ from the button. */
+ SIGNAL_CONNECT(main_w, "destroy", filter_dlg_destroy_cb, filter_list_type_p);
if (button != NULL) {
/* This dialog box was created by a "Filter" button.
@@ -668,6 +664,9 @@ filter_dialog_new(GtkWidget *button, GtkWidget *parent_filter_te,
}
#endif
+ gtk_widget_show(main_w);
+ window_present(main_w);
+
return main_w;
}
@@ -733,7 +732,7 @@ filter_dlg_dclick(GtkWidget *filter_l, gpointer main_w_arg, gpointer activate)
}
}
- gtk_widget_destroy(main_w);
+ window_destroy(main_w);
}
static void
@@ -781,7 +780,7 @@ filter_apply(GtkWidget *main_w, gboolean destroy)
/*
* Destroy the filter dialog box.
*/
- gtk_widget_destroy(main_w);
+ window_destroy(main_w);
}
if (parent_filter_te != NULL) {
@@ -855,12 +854,6 @@ filter_dlg_save_cb(GtkWidget *save_bt _U_, gpointer data)
}
static void
-filter_dlg_close_cb(GtkWidget *close_bt _U_, gpointer parent_w)
-{
- gtk_widget_destroy(GTK_WIDGET(parent_w));
-}
-
-static void
filter_dlg_destroy_cb(GtkWidget *win, gpointer data)
{
filter_list_type_t list = *(filter_list_type_t *)data;
@@ -896,7 +889,7 @@ filter_dlg_destroy_cb(GtkWidget *win, gpointer data)
/* Now nuke this window. */
gtk_grab_remove(GTK_WIDGET(win));
- gtk_widget_destroy(GTK_WIDGET(win));
+ window_destroy(GTK_WIDGET(win));
}
#if GTK_MAJOR_VERSION < 2
diff --git a/gtk/find_dlg.c b/gtk/find_dlg.c
index 0a81406cc7..4bbde48a77 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.52 2004/05/26 02:33:37 guy Exp $
+ * $Id: find_dlg.c,v 1.53 2004/05/26 03:49:23 ulfl Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -136,7 +136,6 @@ find_frame_cb(GtkWidget *w _U_, gpointer d _U_)
}
find_frame_w = dlg_window_new("Ethereal: Find Packet");
- SIGNAL_CONNECT(find_frame_w, "destroy", find_frame_destroy_cb, NULL);
tooltips = gtk_tooltips_new ();
@@ -334,7 +333,6 @@ find_frame_cb(GtkWidget *w _U_, gpointer d _U_)
ok_bt = OBJECT_GET_DATA(bbox, GTK_STOCK_FIND);
SIGNAL_CONNECT(ok_bt, "clicked", find_frame_ok_cb, find_frame_w);
- gtk_widget_grab_default(ok_bt);
cancel_bt = OBJECT_GET_DATA(bbox, GTK_STOCK_CANCEL);
SIGNAL_CONNECT(cancel_bt, "clicked", find_frame_close_cb, find_frame_w);
@@ -365,21 +363,25 @@ find_frame_cb(GtkWidget *w _U_, gpointer d _U_)
string_selected_cb(NULL, find_frame_w);
filter_selected_cb(NULL, find_frame_w);
+
+ window_set_cancel_button(find_frame_w, cancel_bt, window_cancel_button_cb);
+
+ gtk_widget_grab_default(ok_bt);
+
/* Catch the "activate" signal on the filter text entry, so that
if the user types Return there, we act as if the "OK" 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_text_box, ok_bt);
- /* 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(find_frame_w, cancel_bt);
-
/* Give the initial focus to the "Filter" entry box. */
gtk_widget_grab_focus(filter_text_box);
+ SIGNAL_CONNECT(find_frame_w, "delete_event", window_delete_event_cb, NULL);
+ SIGNAL_CONNECT(find_frame_w, "destroy", find_frame_destroy_cb, NULL);
+
gtk_widget_show(find_frame_w);
+ window_present(find_frame_w);
}
/* this function opens the find frame dialogue and sets the filter string */
@@ -790,14 +792,14 @@ find_frame_ok_cb(GtkWidget *ok_bt _U_, gpointer parent_w)
return;
}
}
- gtk_widget_destroy(GTK_WIDGET(parent_w));
+ window_destroy(GTK_WIDGET(parent_w));
}
static void
find_frame_close_cb(GtkWidget *close_bt _U_, gpointer parent_w)
{
gtk_grab_remove(GTK_WIDGET(parent_w));
- gtk_widget_destroy(GTK_WIDGET(parent_w));
+ window_destroy(GTK_WIDGET(parent_w));
}
static void
diff --git a/gtk/follow_dlg.c b/gtk/follow_dlg.c
index 3d81b64bd8..2d5131b6f6 100644
--- a/gtk/follow_dlg.c
+++ b/gtk/follow_dlg.c
@@ -1,6 +1,6 @@
/* follow_dlg.c
*
- * $Id: follow_dlg.c,v 1.59 2004/05/22 19:56:18 ulfl Exp $
+ * $Id: follow_dlg.c,v 1.60 2004/05/26 03:49:23 ulfl Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -253,9 +253,7 @@ follow_stream_cb(GtkWidget * w, gpointer data _U_)
follow_info->streamwindow = streamwindow;
gtk_widget_set_name(streamwindow, "TCP stream window");
-
- SIGNAL_CONNECT(streamwindow, "destroy", follow_destroy_cb, NULL);
- WIDGET_SET_SIZE(streamwindow, DEF_WIDTH, DEF_HEIGHT);
+ gtk_window_set_default_size(GTK_WINDOW(streamwindow), DEF_WIDTH, DEF_HEIGHT);
gtk_container_border_width(GTK_CONTAINER(streamwindow), 2);
/* setup the container */
@@ -430,17 +428,12 @@ follow_stream_cb(GtkWidget * w, gpointer data _U_)
/* Create Close Button */
button = BUTTON_NEW_FROM_STOCK(GTK_STOCK_CLOSE);
- SIGNAL_CONNECT_OBJECT(button, "clicked", gtk_widget_destroy,
- streamwindow);
gtk_tooltips_set_tip (tooltips, button,
"Close the dialog and keep the current display filter", NULL);
gtk_box_pack_start(GTK_BOX(button_hbox), button, FALSE, FALSE, 0);
+ GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT);
- /* 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(streamwindow, button);
-
+ window_set_cancel_button(streamwindow, button, window_cancel_button_cb);
/* Tuck away the follow_info object into the window */
OBJECT_SET_DATA(streamwindow, E_FOLLOW_INFO_KEY, follow_info);
@@ -450,11 +443,16 @@ follow_stream_cb(GtkWidget * w, gpointer data _U_)
data_out_file = NULL;
+ SIGNAL_CONNECT(streamwindow, "delete_event", window_delete_event_cb, NULL);
+ SIGNAL_CONNECT(streamwindow, "destroy", follow_destroy_cb, NULL);
+
/* Make sure this widget gets destroyed if we quit the main loop,
so that if we exit, we clean up any temporary files we have
for "Follow TCP Stream" windows. */
gtk_quit_add_destroy(gtk_main_level(), GTK_OBJECT(streamwindow));
+
gtk_widget_show_all(streamwindow);
+ window_present(streamwindow);
}
/* The destroy call back has the responsibility of
@@ -468,7 +466,7 @@ follow_destroy_cb(GtkWidget *w, gpointer data _U_)
follow_info = OBJECT_GET_DATA(w, E_FOLLOW_INFO_KEY);
unlink(follow_info->data_out_filename);
g_free(follow_info->filter_out_filter);
- gtk_widget_destroy(w);
+ window_destroy(w);
forget_follow_info(follow_info);
g_free(follow_info);
}
@@ -759,7 +757,7 @@ follow_filter_out_stream(GtkWidget * w _U_, gpointer data)
main_filter_packets(&cfile, follow_info->filter_out_filter, FALSE);
/* we force a subsequent close */
- gtk_widget_destroy(follow_info->streamwindow);
+ window_destroy(follow_info->streamwindow);
return;
}
@@ -934,9 +932,6 @@ follow_load_text(follow_info_t *follow_info)
static void
follow_save_as_cmd_cb(GtkWidget *w _U_, gpointer data)
{
-#if GTK_MAJOR_VERSION < 2 || (GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION < 4)
- GtkWidget *ok_bt;
-#endif
GtkWidget *new_win;
follow_info_t *follow_info = data;
@@ -949,7 +944,6 @@ follow_save_as_cmd_cb(GtkWidget *w _U_, gpointer data)
new_win = file_selection_new("Ethereal: Save TCP Follow Stream As",
FILE_SELECTION_SAVE);
follow_info->follow_save_as_w = new_win;
- SIGNAL_CONNECT(new_win, "destroy", follow_save_as_destroy_cb, follow_info);
/* Tuck away the follow_info object into the window */
OBJECT_SET_DATA(new_win, E_FOLLOW_INFO_KEY, follow_info);
@@ -964,25 +958,23 @@ follow_save_as_cmd_cb(GtkWidget *w _U_, gpointer data)
{
follow_save_as_ok_cb(new_win, new_win);
}
- else gtk_widget_destroy(new_win);
+ else window_destroy(new_win);
#else
/* Connect the ok_button to file_save_as_ok_cb function and pass along a
pointer to the file selection box widget */
- ok_bt = GTK_FILE_SELECTION(new_win)->ok_button;
- SIGNAL_CONNECT(ok_bt, "clicked", follow_save_as_ok_cb, new_win);
-
- /* Connect the cancel_button to destroy the widget */
- SIGNAL_CONNECT_OBJECT(GTK_FILE_SELECTION(new_win)->cancel_button, "clicked",
- gtk_widget_destroy, new_win);
+ SIGNAL_CONNECT(GTK_FILE_SELECTION(new_win)->ok_button,
+ "clicked", follow_save_as_ok_cb, new_win);
- /* 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(new_win,
- GTK_FILE_SELECTION(new_win)->cancel_button);
+ window_set_cancel_button(new_win,
+ GTK_FILE_SELECTION(new_win)->cancel_button, window_cancel_button_cb);
gtk_file_selection_set_filename(GTK_FILE_SELECTION(new_win), "");
+
+ SIGNAL_CONNECT(new_win, "delete_event", window_delete_event_cb, NULL);
+ SIGNAL_CONNECT(new_win, "destroy", follow_save_as_destroy_cb, follow_info);
+
gtk_widget_show_all(new_win);
+ window_present(new_win);
#endif
}
@@ -1021,7 +1013,7 @@ follow_save_as_ok_cb(GtkWidget * w _U_, gpointer fs)
gtk_widget_hide(GTK_WIDGET(fs));
follow_info = OBJECT_GET_DATA(fs, E_FOLLOW_INFO_KEY);
- gtk_widget_destroy(GTK_WIDGET(fs));
+ window_destroy(GTK_WIDGET(fs));
switch (follow_read_stream(follow_info, follow_print_text, fh)) {
diff --git a/gtk/goto_dlg.c b/gtk/goto_dlg.c
index bd6ccadc07..c156ce6270 100644
--- a/gtk/goto_dlg.c
+++ b/gtk/goto_dlg.c
@@ -1,7 +1,7 @@
/* goto_dlg.c
* Routines for "go to packet" window
*
- * $Id: goto_dlg.c,v 1.25 2004/01/31 03:22:40 guy Exp $
+ * $Id: goto_dlg.c,v 1.26 2004/05/26 03:49:23 ulfl Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -36,6 +36,7 @@
#include "simple_dialog.h"
#include "dlg_utils.h"
#include "compat_macros.h"
+#include "ui_util.h"
/* Capture callback data keys */
#define E_GOTO_FNUMBER_KEY "goto_fnumber_te"
@@ -43,9 +44,6 @@
static void
goto_frame_ok_cb(GtkWidget *ok_bt, gpointer parent_w);
-static void
-goto_frame_close_cb(GtkWidget *close_bt, gpointer parent_w);
-
void
goto_frame_cb(GtkWidget *w _U_, gpointer d _U_)
{
@@ -80,13 +78,11 @@ goto_frame_cb(GtkWidget *w _U_, gpointer d _U_)
ok_bt = OBJECT_GET_DATA(bbox, GTK_STOCK_JUMP_TO);
SIGNAL_CONNECT(ok_bt, "clicked", goto_frame_ok_cb, goto_frame_w);
- gtk_widget_grab_default(ok_bt);
cancel_bt = OBJECT_GET_DATA(bbox, GTK_STOCK_CANCEL);
- SIGNAL_CONNECT(cancel_bt, "clicked", goto_frame_close_cb, goto_frame_w);
+ window_set_cancel_button(goto_frame_w, cancel_bt, window_cancel_button_cb);
- /* Attach pointers to needed widgets to the capture prefs window/object */
- OBJECT_SET_DATA(goto_frame_w, E_GOTO_FNUMBER_KEY, fnumber_te);
+ gtk_widget_grab_default(ok_bt);
/* Catch the "activate" signal on the frame number text entry, so that
if the user types Return there, we act as if the "OK" button
@@ -94,15 +90,16 @@ goto_frame_cb(GtkWidget *w _U_, gpointer d _U_)
that *doesn't* handle the Return key has the input focus. */
dlg_set_activate(fnumber_te, ok_bt);
- /* 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(goto_frame_w, cancel_bt);
-
/* Give the initial focus to the "Packet number" entry box. */
gtk_widget_grab_focus(fnumber_te);
+ /* Attach pointers to needed widgets to the capture prefs window/object */
+ OBJECT_SET_DATA(goto_frame_w, E_GOTO_FNUMBER_KEY, fnumber_te);
+
+ SIGNAL_CONNECT(goto_frame_w, "delete_event", window_delete_event_cb, NULL);
+
gtk_widget_show(goto_frame_w);
+ window_present(goto_frame_w);
}
static void
@@ -129,13 +126,7 @@ goto_frame_ok_cb(GtkWidget *ok_bt _U_, gpointer parent_w)
if (goto_frame(&cfile, fnumber)) {
/* We succeeded in going to that frame; we're done. */
- gtk_widget_destroy(GTK_WIDGET(parent_w));
+ window_destroy(GTK_WIDGET(parent_w));
}
}
-static void
-goto_frame_close_cb(GtkWidget *close_bt _U_, gpointer parent_w)
-{
- gtk_grab_remove(GTK_WIDGET(parent_w));
- gtk_widget_destroy(GTK_WIDGET(parent_w));
-}
diff --git a/gtk/menu.c b/gtk/menu.c
index bcf0371bf7..60bf3969ca 100644
--- a/gtk/menu.c
+++ b/gtk/menu.c
@@ -1,7 +1,7 @@
/* menu.c
* Menu routines
*
- * $Id: menu.c,v 1.197 2004/05/21 08:44:45 guy Exp $
+ * $Id: menu.c,v 1.198 2004/05/26 03:49:23 ulfl Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -40,6 +40,7 @@
#include "capture_dlg.h"
#include "color_dlg.h"
#include "filter_prefs.h"
+#include "dlg_utils.h"
#include "file_dlg.h"
#include "find_dlg.h"
#include "goto_dlg.h"
diff --git a/gtk/packet_win.c b/gtk/packet_win.c
index dbefa6c909..34b9b1865e 100644
--- a/gtk/packet_win.c
+++ b/gtk/packet_win.c
@@ -3,7 +3,7 @@
*
* Copyright 2000, Jeffrey C. Foster <jfoste@woodward.com>
*
- * $Id: packet_win.c,v 1.44 2004/02/13 00:53:35 guy Exp $
+ * $Id: packet_win.c,v 1.45 2004/05/26 03:49:23 ulfl Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -313,7 +313,7 @@ destroy_packet_wins(void)
we destroy the first window on the list. */
while (detail_windows != NULL) {
DataPtr = (struct PacketWinData *)(detail_windows->data);
- gtk_widget_destroy(DataPtr->main);
+ window_destroy(DataPtr->main);
}
}
diff --git a/gtk/plugins_dlg.c b/gtk/plugins_dlg.c
index 42431bdf66..3be4629d86 100644
--- a/gtk/plugins_dlg.c
+++ b/gtk/plugins_dlg.c
@@ -1,7 +1,7 @@
/* plugins_dlg.c
* Dialog boxes for plugins
*
- * $Id: plugins_dlg.c,v 1.36 2004/05/20 18:23:38 ulfl Exp $
+ * $Id: plugins_dlg.c,v 1.37 2004/05/26 03:49:23 ulfl Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -36,7 +36,6 @@
#ifdef HAVE_PLUGINS
-static void plugins_close_cb(GtkWidget *, gpointer);
static void plugins_destroy_cb(GtkWidget *, gpointer);
/*
@@ -105,7 +104,7 @@ tools_plugins_cmd_cb(GtkWidget *widget _U_, gpointer data _U_)
}
plugins_window = dlg_window_new("Ethereal: Plugins");
- SIGNAL_CONNECT(plugins_window, "destroy", plugins_destroy_cb, NULL);
+ gtk_window_set_default_size(GTK_WINDOW(plugins_window), 250, 200);
main_vbox = gtk_vbox_new(FALSE, 0);
gtk_container_add(GTK_CONTAINER(plugins_window), main_vbox);
@@ -119,30 +118,20 @@ tools_plugins_cmd_cb(GtkWidget *widget _U_, gpointer data _U_)
gtk_container_set_border_width(GTK_CONTAINER(frame_hbox), 5);
page = about_plugins_page_new();
- WIDGET_SET_SIZE(page, 250, 200);
gtk_box_pack_start(GTK_BOX(frame_hbox), page, TRUE, TRUE, 0);
+ /* button row */
bbox = dlg_button_row_new(GTK_STOCK_OK, NULL);
gtk_box_pack_end(GTK_BOX(main_vbox), bbox, FALSE, FALSE, 3);
ok_bt = OBJECT_GET_DATA(bbox, GTK_STOCK_OK);
- SIGNAL_CONNECT(ok_bt, "clicked", plugins_close_cb, plugins_window);
- gtk_widget_grab_default(ok_bt);
+ window_set_cancel_button(plugins_window, ok_bt, window_cancel_button_cb);
- /* Catch the "key_press_event" signal in the window, so that we can catch
- the ESC key being pressed and act as if the "OK" button had
- been selected. */
- dlg_set_cancel(plugins_window, ok_bt);
+ SIGNAL_CONNECT(plugins_window, "delete_event", window_delete_event_cb, NULL);
+ SIGNAL_CONNECT(plugins_window, "destroy", plugins_destroy_cb, NULL);
gtk_widget_show_all(plugins_window);
-
-}
-
-static void
-plugins_close_cb(GtkWidget *close_bt _U_, gpointer parent_w)
-{
- gtk_grab_remove(GTK_WIDGET(parent_w));
- gtk_widget_destroy(GTK_WIDGET(parent_w));
+ window_present(plugins_window);
}
static void
@@ -151,4 +140,6 @@ plugins_destroy_cb(GtkWidget *w _U_, gpointer data _U_)
/* Note that we no longer have a Plugins window. */
plugins_window = NULL;
}
-#endif
+
+
+#endif /* HAVE_PLUGINS */
diff --git a/gtk/prefs_dlg.c b/gtk/prefs_dlg.c
index 9b0705510b..9adae4b128 100644
--- a/gtk/prefs_dlg.c
+++ b/gtk/prefs_dlg.c
@@ -1,7 +1,7 @@
/* prefs_dlg.c
* Routines for handling preferences
*
- * $Id: prefs_dlg.c,v 1.82 2004/05/24 02:25:21 guy Exp $
+ * $Id: prefs_dlg.c,v 1.83 2004/05/26 03:49:23 ulfl Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -375,8 +375,6 @@ prefs_cb(GtkWidget *w _U_, gpointer dummy _U_)
copy_prefs(&saved_prefs, &prefs);
prefs_w = dlg_window_new("Ethereal: Preferences");
- SIGNAL_CONNECT(prefs_w, "delete_event", prefs_main_delete_cb, NULL);
- SIGNAL_CONNECT(prefs_w, "destroy", prefs_main_destroy_cb, NULL);
/*
* Unfortunately, we can't arrange that a GtkTable widget wrap an event box
@@ -651,7 +649,6 @@ prefs_cb(GtkWidget *w _U_, gpointer dummy _U_)
ok_bt = OBJECT_GET_DATA(bbox, GTK_STOCK_OK);
SIGNAL_CONNECT(ok_bt, "clicked", prefs_main_ok_cb, prefs_w);
- gtk_widget_grab_default(ok_bt);
apply_bt = OBJECT_GET_DATA(bbox, GTK_STOCK_APPLY);
SIGNAL_CONNECT(apply_bt, "clicked", prefs_main_apply_cb, prefs_w);
@@ -661,13 +658,15 @@ prefs_cb(GtkWidget *w _U_, gpointer dummy _U_)
cancel_bt = OBJECT_GET_DATA(bbox, GTK_STOCK_CANCEL);
SIGNAL_CONNECT(cancel_bt, "clicked", prefs_main_cancel_cb, prefs_w);
+ window_set_cancel_button(prefs_w, cancel_bt, NULL);
- /* 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(prefs_w, cancel_bt);
+ gtk_widget_grab_default(ok_bt);
+
+ SIGNAL_CONNECT(prefs_w, "delete_event", prefs_main_delete_cb, NULL);
+ SIGNAL_CONNECT(prefs_w, "destroy", prefs_main_destroy_cb, NULL);
gtk_widget_show(prefs_w);
+ window_present(prefs_w);
#if GTK_MAJOR_VERSION >= 2
g_object_unref(G_OBJECT(store));
@@ -1070,7 +1069,7 @@ prefs_main_ok_cb(GtkWidget *ok_bt _U_, gpointer parent_w)
prefs_apply_all();
/* Now destroy the "Preferences" dialog. */
- gtk_widget_destroy(GTK_WIDGET(parent_w));
+ window_destroy(GTK_WIDGET(parent_w));
if (must_redissect) {
/* Redissect all the packets, and re-evaluate the display filter. */
@@ -1298,7 +1297,7 @@ prefs_main_cancel_cb(GtkWidget *cancel_bt _U_, gpointer parent_w)
nameres_prefs_apply(OBJECT_GET_DATA(parent_w, E_NAMERES_PAGE_KEY));
prefs_apply_all();
- gtk_widget_destroy(GTK_WIDGET(parent_w));
+ window_destroy(GTK_WIDGET(parent_w));
if (must_redissect) {
/* Redissect all the packets, and re-evaluate the display filter. */
diff --git a/gtk/print_dlg.c b/gtk/print_dlg.c
index d7a99cd583..0eeb8d0edf 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.76 2004/04/25 22:34:06 ulfl Exp $
+ * $Id: print_dlg.c,v 1.77 2004/05/26 03:49:23 ulfl Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -74,7 +74,6 @@ open_print_dialog(char *title, output_action_e action, print_args_t *args);
static void print_cmd_toggle_dest(GtkWidget *widget, gpointer data);
static void print_cmd_toggle_detail(GtkWidget *widget, gpointer data);
static void print_ok_cb(GtkWidget *ok_bt, gpointer parent_w);
-static void print_close_cb(GtkWidget *close_bt, gpointer parent_w);
static void print_destroy_cb(GtkWidget *win, gpointer user_data);
@@ -96,6 +95,7 @@ static void print_destroy_cb(GtkWidget *win, gpointer user_data);
#define PRINT_BT_KEY "printer_button"
+#define PRINT_TE_PTR_KEY "printer_file_te_ptr"
/*
@@ -318,6 +318,13 @@ export_pdml_cmd_cb(GtkWidget *widget _U_, gpointer data _U_)
}
+static void
+print_browse_file_cb(GtkWidget *file_bt, GtkWidget *file_te)
+{
+ file_selection_browse(file_bt, file_te, "Ethereal: Print to File", FILE_SELECTION_SAVE);
+}
+
+
/* Open the print dialog */
static GtkWidget *
@@ -459,7 +466,7 @@ open_print_dialog(char *title, output_action_e action, print_args_t *args)
/* "Browse" button */
file_bt = BUTTON_NEW_FROM_STOCK(ETHEREAL_STOCK_BROWSE);
OBJECT_SET_DATA(dest_cb, PRINT_FILE_BT_KEY, file_bt);
- OBJECT_SET_DATA(file_bt, E_FILE_TE_PTR_KEY, file_te);
+ OBJECT_SET_DATA(file_bt, PRINT_TE_PTR_KEY, file_te);
gtk_tooltips_set_tip (tooltips, file_bt, "Browse output filename in filesystem", NULL);
gtk_table_attach_defaults(GTK_TABLE(printer_tb), file_bt, 2, 3, 0, 1);
gtk_widget_set_sensitive(file_bt, args->to_file);
@@ -486,7 +493,7 @@ open_print_dialog(char *title, output_action_e action, print_args_t *args)
#endif
SIGNAL_CONNECT(dest_cb, "toggled", print_cmd_toggle_dest, NULL);
- SIGNAL_CONNECT(file_bt, "clicked", select_file_cb, "Ethereal: Print to File");
+ SIGNAL_CONNECT(file_bt, "clicked", print_browse_file_cb, file_te);
if(action == output_action_export_ps) {
export_format_lb = gtk_label_new("(PostScript files can be easily converted to PDF files using ghostscript's ps2pdf)");
@@ -641,29 +648,27 @@ open_print_dialog(char *title, output_action_e action, print_args_t *args)
OBJECT_SET_DATA(ok_bt, PRINT_FORMFEED_CB_KEY, formfeed_cb);
SIGNAL_CONNECT(ok_bt, "clicked", print_ok_cb, main_win);
gtk_tooltips_set_tip (tooltips, ok_bt, "Start output", NULL);
- gtk_widget_grab_default(ok_bt);
cancel_bt = OBJECT_GET_DATA(bbox, GTK_STOCK_CANCEL);
- SIGNAL_CONNECT(cancel_bt, "clicked", print_close_cb, main_win);
+ window_set_cancel_button(main_win, cancel_bt, window_cancel_button_cb);
gtk_tooltips_set_tip (tooltips, cancel_bt, "Cancel and exit dialog", NULL);
+ gtk_widget_grab_default(ok_bt);
+
/* Catch the "activate" signal on the "Command" and "File" text entries,
so that if the user types Return there, we act as if the "OK" button
had been selected, as happens if Return is typed if some widget
that *doesn't* handle the Return key has the input focus. */
-
#ifndef _WIN32
dlg_set_activate(cmd_te, ok_bt);
#endif
if(action != output_action_print)
dlg_set_activate(file_te, ok_bt);
- /* 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(main_win, cancel_bt);
+ SIGNAL_CONNECT(main_win, "delete_event", window_delete_event_cb, NULL);
gtk_widget_show(main_win);
+ window_present(main_win);
return main_win;
}
@@ -812,7 +817,7 @@ print_ok_cb(GtkWidget *ok_bt, gpointer parent_w)
args->print_formfeed = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (button));
- gtk_widget_destroy(GTK_WIDGET(parent_w));
+ window_destroy(GTK_WIDGET(parent_w));
/* Now print the packets */
switch (print_packets(&cfile, args)) {
@@ -848,13 +853,6 @@ print_ok_cb(GtkWidget *ok_bt, gpointer parent_w)
}
static void
-print_close_cb(GtkWidget *close_bt _U_, gpointer parent_w)
-{
- gtk_grab_remove(GTK_WIDGET(parent_w));
- gtk_widget_destroy(GTK_WIDGET(parent_w));
-}
-
-static void
print_destroy_cb(GtkWidget *win, gpointer user_data)
{
GtkWidget *fs;
@@ -865,7 +863,7 @@ print_destroy_cb(GtkWidget *win, gpointer user_data)
if (fs != NULL) {
/* Yes. Destroy it. */
- gtk_widget_destroy(fs);
+ window_destroy(fs);
}
/* Note that we no longer have a "Print" dialog box. */
diff --git a/gtk/print_prefs.c b/gtk/print_prefs.c
index 6ac093f971..3bac0ead05 100644
--- a/gtk/print_prefs.c
+++ b/gtk/print_prefs.c
@@ -1,7 +1,7 @@
/* print_prefs.c
* Dialog boxes for preferences for printing
*
- * $Id: print_prefs.c,v 1.20 2004/05/24 02:25:21 guy Exp $
+ * $Id: print_prefs.c,v 1.21 2004/05/26 03:49:23 ulfl Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -38,18 +38,12 @@
#include "util.h"
#include "ui_util.h"
#include "dlg_utils.h"
+#include "file_dlg.h"
#include "compat_macros.h"
#include "gtkglobals.h"
-static void printer_opts_file_cb(GtkWidget *w, gpointer te);
-#if (GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION < 4) || GTK_MAJOR_VERSION < 2
-static void printer_opts_fs_ok_cb(GtkWidget *w, gpointer data);
-static void printer_opts_fs_cancel_cb(GtkWidget *w, gpointer data);
-#endif
-static void printer_opts_fs_destroy_cb(GtkWidget *win, gpointer data);
+static void printer_browse_file_cb(GtkWidget *w, gpointer te);
-#define E_FS_CALLER_PTR_KEY "fs_caller_ptr"
-#define E_FILE_SEL_DIALOG_PTR_KEY "file_sel_dialog_ptr"
#define E_PRINT_FORMAT_KEY "print_format"
#define E_PRINT_DESTINATION_KEY "print_destination"
@@ -130,7 +124,7 @@ GtkWidget * printer_prefs_show(void)
gtk_box_pack_start(GTK_BOX(file_bt_hb), file_te, TRUE, TRUE, 0);
gtk_widget_show(file_te);
- SIGNAL_CONNECT(file_bt, "clicked", printer_opts_file_cb, file_te);
+ SIGNAL_CONNECT(file_bt, "clicked", printer_browse_file_cb, file_te);
gtk_widget_show(main_vb);
return(main_vb);
@@ -138,94 +132,12 @@ GtkWidget * printer_prefs_show(void)
static void
-printer_opts_file_cb(GtkWidget *file_bt, gpointer file_te) {
- GtkWidget *caller = gtk_widget_get_toplevel(file_bt);
- GtkWidget *fs;
-
- /* Has a file selection dialog box already been opened for that top-level
- widget? */
- fs = OBJECT_GET_DATA(caller, E_FILE_SEL_DIALOG_PTR_KEY);
-
- if (fs != NULL) {
- /* Yes. Just re-activate that dialog box. */
- reactivate_window(fs);
- return;
- }
-
- fs = file_selection_new("Ethereal: Print to a File",
- FILE_SELECTION_SAVE);
-#if GTK_MAJOR_VERSION < 2 || (GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION < 4)
- OBJECT_SET_DATA(fs, PRINT_FILE_TE_KEY, file_te);
-#endif
-
- /* Set the E_FS_CALLER_PTR_KEY for the new dialog to point to our caller. */
- OBJECT_SET_DATA(fs, E_FS_CALLER_PTR_KEY, caller);
-
- /* Set the E_FILE_SEL_DIALOG_PTR_KEY for the caller to point to us */
- OBJECT_SET_DATA(caller, E_FILE_SEL_DIALOG_PTR_KEY, fs);
-
- /* Call a handler when the file selection box is destroyed, so we can inform
- our caller, if any, that it's been destroyed. */
- SIGNAL_CONNECT(fs, "destroy", printer_opts_fs_destroy_cb, NULL);
-
-#if (GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION >= 4) || GTK_MAJOR_VERSION > 2
- if (gtk_dialog_run(GTK_DIALOG(fs)) == GTK_RESPONSE_ACCEPT)
- {
- gtk_entry_set_text(GTK_ENTRY(file_te),
- gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(fs)));
- }
- gtk_widget_destroy(fs);
-#else
- SIGNAL_CONNECT(GTK_FILE_SELECTION(fs)->ok_button, "clicked",
- printer_opts_fs_ok_cb, fs);
-
- /* Connect the cancel_button to destroy the widget */
- SIGNAL_CONNECT(GTK_FILE_SELECTION(fs)->cancel_button, "clicked",
- printer_opts_fs_cancel_cb, fs);
-
- /* 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(fs, GTK_FILE_SELECTION(fs)->cancel_button);
-
- gtk_widget_show(fs);
-#endif
-}
-
-#if (GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION < 4) || GTK_MAJOR_VERSION < 2
-static void
-printer_opts_fs_ok_cb(GtkWidget *w, gpointer data) {
-
- gtk_entry_set_text(GTK_ENTRY(OBJECT_GET_DATA(data, PRINT_FILE_TE_KEY)),
- gtk_file_selection_get_filename(GTK_FILE_SELECTION(data)));
- printer_opts_fs_cancel_cb(w, data);
-}
-
-static void
-printer_opts_fs_cancel_cb(GtkWidget *w _U_, gpointer data) {
-
- gtk_widget_destroy(GTK_WIDGET(data));
-}
-#endif
-
-static void
-printer_opts_fs_destroy_cb(GtkWidget *win, gpointer data _U_)
+printer_browse_file_cb(GtkWidget *file_bt, GtkWidget *file_te)
{
- GtkWidget *caller;
-
- /* Get the widget that requested that we be popped up.
- (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_FS_CALLER_PTR_KEY);
-
- /* Tell it we no longer exist. */
- OBJECT_SET_DATA(caller, E_FILE_SEL_DIALOG_PTR_KEY, NULL);
-
- /* Now nuke this window. */
- gtk_grab_remove(GTK_WIDGET(win));
- gtk_widget_destroy(GTK_WIDGET(win));
+ file_selection_browse(file_bt, file_te, "Ethereal: Print to a File", FILE_SELECTION_SAVE);
}
+
void
printer_prefs_fetch(GtkWidget *w)
{
@@ -265,6 +177,6 @@ printer_prefs_destroy(GtkWidget *w)
if (fs != NULL) {
/* Yes. Destroy it. */
- gtk_widget_destroy(fs);
+ window_destroy(fs);
}
}
diff --git a/gtk/progress_dlg.c b/gtk/progress_dlg.c
index 6897d0ae22..786078cf67 100644
--- a/gtk/progress_dlg.c
+++ b/gtk/progress_dlg.c
@@ -1,7 +1,7 @@
/* progress_dlg.c
* Routines for progress-bar (modal) dialog
*
- * $Id: progress_dlg.c,v 1.22 2004/02/01 13:12:10 ulfl Exp $
+ * $Id: progress_dlg.c,v 1.23 2004/05/26 03:49:24 ulfl Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -31,6 +31,7 @@
#include <gtk/gtk.h>
#include "gtkglobals.h"
#include "dlg_utils.h"
+#include "ui_util.h"
#include "progress_dlg.h"
#include "compat_macros.h"
@@ -400,7 +401,7 @@ destroy_progress_dlg(progdlg_t *dlg)
{
GtkWidget *dlg_w = dlg->dlg_w;
- gtk_widget_destroy(GTK_WIDGET(dlg_w));
+ window_destroy(GTK_WIDGET(dlg_w));
g_free(dlg->title);
g_free(dlg);
}
diff --git a/gtk/proto_dlg.c b/gtk/proto_dlg.c
index 1ff6c6d2d6..5845196195 100644
--- a/gtk/proto_dlg.c
+++ b/gtk/proto_dlg.c
@@ -1,6 +1,6 @@
/* proto_dlg.c
*
- * $Id: proto_dlg.c,v 1.32 2004/02/06 19:19:10 ulfl Exp $
+ * $Id: proto_dlg.c,v 1.33 2004/05/26 03:49:24 ulfl Exp $
*
* Laurent Deniel <laurent.deniel@free.fr>
*
@@ -113,9 +113,7 @@ proto_cb(GtkWidget *w _U_, gpointer data _U_)
}
proto_w = dlg_window_new("Ethereal: Enabled Protocols");
- SIGNAL_CONNECT(proto_w, "delete_event", proto_delete_cb, NULL);
- SIGNAL_CONNECT(proto_w, "destroy", proto_destroy_cb, NULL);
- WIDGET_SET_SIZE(proto_w, DEF_WIDTH * 2/3, DEF_HEIGHT * 2/3);
+ gtk_window_set_default_size(GTK_WINDOW(proto_w), DEF_WIDTH * 2/3, DEF_HEIGHT * 2/3);
/* Container for each row of widgets */
@@ -222,7 +220,7 @@ proto_cb(GtkWidget *w _U_, gpointer data _U_)
gtk_widget_show(button);
- /* Ok, Apply, Cancel Buttons */
+ /* Button row */
bbox = dlg_button_row_new(GTK_STOCK_OK, GTK_STOCK_APPLY, GTK_STOCK_SAVE, GTK_STOCK_CANCEL, NULL);
gtk_box_pack_start(GTK_BOX(main_vb), bbox, FALSE, FALSE, 0);
gtk_widget_show(bbox);
@@ -238,13 +236,15 @@ proto_cb(GtkWidget *w _U_, gpointer data _U_)
SIGNAL_CONNECT(button, "clicked", proto_save_cb, proto_w);
button = OBJECT_GET_DATA(bbox, GTK_STOCK_CANCEL);
- SIGNAL_CONNECT(button, "clicked", proto_cancel_cb, proto_w);
+ window_set_cancel_button(proto_w, button, proto_cancel_cb);
- dlg_set_cancel(proto_w, button);
+ SIGNAL_CONNECT(proto_w, "delete_event", proto_delete_cb, NULL);
+ SIGNAL_CONNECT(proto_w, "destroy", proto_destroy_cb, NULL);
gtk_quit_add_destroy(gtk_main_level(), GTK_OBJECT(proto_w));
- gtk_widget_show(proto_w);
+ gtk_widget_show(proto_w);
+ window_present(proto_w);
} /* proto_cb */
#if GTK_MAJOR_VERSION < 2
@@ -377,7 +377,7 @@ proto_destroy_cb(GtkWidget *w _U_, gpointer data _U_)
GSList *entry;
if (proto_w)
- gtk_widget_destroy(proto_w);
+ window_destroy(proto_w);
proto_w = NULL;
/* remove protocol list */
@@ -407,7 +407,7 @@ proto_ok_cb(GtkWidget *ok_bt _U_, gpointer parent_w)
gboolean redissect;
redissect = set_proto_selection(GTK_WIDGET(parent_w));
- gtk_widget_destroy(GTK_WIDGET(parent_w));
+ window_destroy(GTK_WIDGET(parent_w));
if (redissect)
redissect_packets(&cfile);
}
@@ -461,7 +461,7 @@ proto_cancel_cb(GtkWidget *cancel_bt _U_, gpointer parent_w)
gboolean redissect;
redissect = revert_proto_selection();
- gtk_widget_destroy(GTK_WIDGET(parent_w));
+ window_destroy(GTK_WIDGET(parent_w));
if (redissect)
redissect_packets(&cfile);
}
diff --git a/gtk/proto_draw.c b/gtk/proto_draw.c
index 6d190fd058..2bd1d019a6 100644
--- a/gtk/proto_draw.c
+++ b/gtk/proto_draw.c
@@ -1,7 +1,7 @@
/* proto_draw.c
* Routines for GTK+ packet display
*
- * $Id: proto_draw.c,v 1.100 2004/05/23 23:24:06 ulfl Exp $
+ * $Id: proto_draw.c,v 1.101 2004/05/26 03:49:24 ulfl Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -792,6 +792,14 @@ savehex_dlg_destroy_cb(void)
savehex_dlg = NULL;
}
+static void
+savehex_browse_file_cb(GtkWidget *file_bt, GtkWidget *file_te)
+{
+ file_selection_browse(file_bt, file_te,
+ "Ethereal: Export Selected Packet Bytes", FILE_SELECTION_SAVE);
+}
+
+
/* Forward declaration */
static void
savehex_save_clicked_cb(GtkWidget * w, gpointer data);
@@ -865,12 +873,7 @@ void savehex_cb(GtkWidget * w _U_, gpointer data _U_)
/* File Browse button */
file_bt=BUTTON_NEW_FROM_STOCK(ETHEREAL_STOCK_BROWSE);
- SIGNAL_CONNECT(file_bt, "clicked", select_file_cb,
- "Ethereal: Export Selected Packet Bytes");
-
- /* file entry for print dialog */
- OBJECT_SET_DATA(file_bt, E_FILE_TE_PTR_KEY, file_entry);
- /* file entry for print dialog */
+ SIGNAL_CONNECT(file_bt, "clicked", savehex_browse_file_cb, file_entry);
gtk_tooltips_set_tip (tooltips, file_bt, ("Browse output filename in filesystem"), NULL);
gtk_box_pack_start(GTK_BOX(file_box), file_bt, FALSE, TRUE, 0);
@@ -966,7 +969,7 @@ savehex_save_clicked_cb(GtkWidget * w _U_, gpointer data _U_)
}
/* Get rid of the dialog box */
- gtk_widget_destroy(GTK_WIDGET(savehex_dlg));
+ window_destroy(GTK_WIDGET(savehex_dlg));
}
/* Update the progress bar this many times when reading a file. */
diff --git a/gtk/rtp_analysis.c b/gtk/rtp_analysis.c
index 317393ec18..9d213af81d 100644
--- a/gtk/rtp_analysis.c
+++ b/gtk/rtp_analysis.c
@@ -1,7 +1,7 @@
/* rtp_analysis.c
* RTP analysis addition for ethereal
*
- * $Id: rtp_analysis.c,v 1.42 2004/05/23 23:24:06 ulfl Exp $
+ * $Id: rtp_analysis.c,v 1.43 2004/05/26 03:49:24 ulfl Exp $
*
* Copyright 2003, Alcatel Business Systems
* By Lars Ruoff <lars.ruoff@gmx.net>
@@ -274,7 +274,7 @@ rtp_reset(void *user_data_arg)
#ifdef USE_CONVERSATION_GRAPH
if (user_data->dlg.graph_window != NULL)
- gtk_widget_destroy(user_data->dlg.graph_window);
+ window_destroy(user_data->dlg.graph_window);
g_array_free(user_data->series_fwd.value_pairs, TRUE);
user_data->series_fwd.value_pairs = g_array_new(FALSE, FALSE, sizeof(value_pair_t));
@@ -726,12 +726,12 @@ static void on_destroy(GtkWidget *win _U_, user_data_t *user_data _U_)
/* destroy save_voice_as window if open */
if (user_data->dlg.save_voice_as_w != NULL)
- gtk_widget_destroy(user_data->dlg.save_voice_as_w);
+ window_destroy(user_data->dlg.save_voice_as_w);
#ifdef USE_CONVERSATION_GRAPH
/* destroy graph window if open */
if (user_data->dlg.graph_window != NULL)
- gtk_widget_destroy(user_data->dlg.graph_window);
+ window_destroy(user_data->dlg.graph_window);
#endif
g_free(user_data->dlg.col_arrows_fwd);
@@ -1086,7 +1086,7 @@ static void save_csv_as_ok_cb(GtkWidget *bt _U_, gpointer fs /*user_data_t *user
}
}
- gtk_widget_destroy(GTK_WIDGET(user_data->dlg.save_csv_as_w));
+ window_destroy(GTK_WIDGET(user_data->dlg.save_csv_as_w));
}
static void save_csv_as_destroy_cb(GtkWidget *win _U_, user_data_t *user_data _U_)
@@ -1114,8 +1114,6 @@ static void save_csv_as_cb(GtkWidget *bt _U_, user_data_t *user_data _U_)
}
user_data->dlg.save_csv_as_w = gtk_file_selection_new("Ethereal: Save Data As CSV");
- SIGNAL_CONNECT(user_data->dlg.save_csv_as_w, "destroy",
- save_csv_as_destroy_cb, user_data);
/* Container for each row of widgets */
vertb = gtk_vbox_new(FALSE, 0);
@@ -1172,21 +1170,18 @@ static void save_csv_as_cb(GtkWidget *bt _U_, user_data_t *user_data _U_)
OBJECT_SET_DATA(ok_bt, "reversed_rb", reversed_rb);
OBJECT_SET_DATA(ok_bt, "both_rb", both_rb);
OBJECT_SET_DATA(ok_bt, "user_data", user_data);
-
- /* Connect the cancel_button to destroy the widget */
- SIGNAL_CONNECT_OBJECT(GTK_FILE_SELECTION(user_data->dlg.save_csv_as_w)->cancel_button,
- "clicked", (GtkSignalFunc)gtk_widget_destroy,
- user_data->dlg.save_csv_as_w);
-
- /* 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(user_data->dlg.save_csv_as_w, GTK_FILE_SELECTION(user_data->dlg.save_csv_as_w)->cancel_button);
-
SIGNAL_CONNECT(ok_bt, "clicked", save_csv_as_ok_cb,
user_data->dlg.save_csv_as_w);
+
+ window_set_cancel_button(user_data->dlg.save_csv_as_w,
+ GTK_FILE_SELECTION(user_data->dlg.save_csv_as_w)->cancel_button, NULL);
+ SIGNAL_CONNECT(user_data->dlg.save_csv_as_w, "delete_event", window_delete_event_cb, NULL);
+ SIGNAL_CONNECT(user_data->dlg.save_csv_as_w, "destroy",
+ save_csv_as_destroy_cb, user_data);
+
gtk_widget_show(user_data->dlg.save_csv_as_w);
+ window_present(user_data->dlg.save_csv_as_w);
}
@@ -1505,7 +1500,7 @@ static void save_voice_as_ok_cb(GtkWidget *ok_bt _U_, gpointer fs _U_)
return;
}
- gtk_widget_destroy(GTK_WIDGET(user_data->dlg.save_voice_as_w));
+ window_destroy(GTK_WIDGET(user_data->dlg.save_voice_as_w));
}
/****************************************************************************/
@@ -1535,9 +1530,8 @@ static void on_save_bt_clicked(GtkWidget *bt _U_, user_data_t *user_data _U_)
return;
}
+ /* XXX - use file_selection from dlg_utils instead! */
user_data->dlg.save_voice_as_w = gtk_file_selection_new("Ethereal: Save Payload As ...");
- SIGNAL_CONNECT(user_data->dlg.save_voice_as_w, "destroy",
- save_voice_as_destroy_cb, user_data);
/* Container for each row of widgets */
vertb = gtk_vbox_new(FALSE, 0);
@@ -1633,21 +1627,19 @@ static void on_save_bt_clicked(GtkWidget *bt _U_, user_data_t *user_data _U_)
OBJECT_SET_DATA(ok_bt, "reversed_rb", reversed_rb);
OBJECT_SET_DATA(ok_bt, "both_rb", both_rb);
OBJECT_SET_DATA(ok_bt, "user_data", user_data);
-
- /* Connect the cancel_button to destroy the widget */
- SIGNAL_CONNECT_OBJECT(GTK_FILE_SELECTION(user_data->dlg.save_voice_as_w)->cancel_button,
- "clicked", (GtkSignalFunc)gtk_widget_destroy,
- user_data->dlg.save_voice_as_w);
-
- /* 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(user_data->dlg.save_voice_as_w, GTK_FILE_SELECTION(user_data->dlg.save_voice_as_w)->cancel_button);
-
SIGNAL_CONNECT(ok_bt, "clicked", save_voice_as_ok_cb,
user_data->dlg.save_voice_as_w);
-
+
+ window_set_cancel_button(user_data->dlg.save_voice_as_w,
+ GTK_FILE_SELECTION(user_data->dlg.save_voice_as_w)->cancel_button, window_cancel_button_cb);
+
+ SIGNAL_CONNECT(user_data->dlg.save_voice_as_w, "delete_event",
+ window_delete_event_cb, NULL);
+ SIGNAL_CONNECT(user_data->dlg.save_voice_as_w, "destroy",
+ save_voice_as_destroy_cb, user_data);
+
gtk_widget_show(user_data->dlg.save_voice_as_w);
+ window_present(user_data->dlg.save_voice_as_w);
}
diff --git a/gtk/rtp_stream_dlg.c b/gtk/rtp_stream_dlg.c
index 82815b844b..495ff2828e 100644
--- a/gtk/rtp_stream_dlg.c
+++ b/gtk/rtp_stream_dlg.c
@@ -1,7 +1,7 @@
/* rtp_stream_dlg.c
* RTP streams summary addition for ethereal
*
- * $Id: rtp_stream_dlg.c,v 1.20 2004/04/12 18:01:27 ulfl Exp $
+ * $Id: rtp_stream_dlg.c,v 1.21 2004/05/26 03:49:24 ulfl Exp $
*
* Copyright 2003, Alcatel Business Systems
* By Lars Ruoff <lars.ruoff@gmx.net>
@@ -171,7 +171,7 @@ static void save_stream_ok_cb(GtkWidget *ok_bt _U_, gpointer user_data _U_)
if (!rtpstream_save(selected_stream_fwd, g_dest))
return;
- gtk_widget_destroy(GTK_WIDGET(rtpstream_save_dlg));
+ window_destroy(GTK_WIDGET(rtpstream_save_dlg));
}
@@ -187,7 +187,7 @@ rtpstream_on_destroy (GtkObject *object _U_,
/* Is there a save voice window open? */
if (rtpstream_save_dlg != NULL)
- gtk_widget_destroy(rtpstream_save_dlg);
+ window_destroy(rtpstream_save_dlg);
/* Clean up memory used by stream tap */
rtpstream_reset((rtpstream_tapinfo_t*) rtpstream_get_info());
@@ -310,9 +310,8 @@ rtpstream_on_save (GtkButton *button _U_,
return;
}
+ /* XXX - use file_selection from dlg_utils instead! */
rtpstream_save_dlg = gtk_file_selection_new("Ethereal: Save selected stream in rtpdump ('-F dump') format");
- SIGNAL_CONNECT(rtpstream_save_dlg, "destroy", save_stream_destroy_cb,
- NULL);
/* Container for each row of widgets */
vertb = gtk_vbox_new(FALSE, 0);
@@ -322,20 +321,17 @@ rtpstream_on_save (GtkButton *button _U_,
gtk_widget_show (vertb);
ok_bt = GTK_FILE_SELECTION(rtpstream_save_dlg)->ok_button;
+ SIGNAL_CONNECT(ok_bt, "clicked", save_stream_ok_cb, tapinfo);
- /* Connect the cancel_button to destroy the widget */
- SIGNAL_CONNECT_OBJECT(GTK_FILE_SELECTION(rtpstream_save_dlg)->cancel_button,
- "clicked", (GtkSignalFunc)gtk_widget_destroy,
- rtpstream_save_dlg);
-
- /* 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(rtpstream_save_dlg, GTK_FILE_SELECTION(rtpstream_save_dlg)->cancel_button);
+ window_set_cancel_button(rtpstream_save_dlg,
+ GTK_FILE_SELECTION(rtpstream_save_dlg)->cancel_button, window_cancel_button_cb);
- SIGNAL_CONNECT(ok_bt, "clicked", save_stream_ok_cb, tapinfo);
+ SIGNAL_CONNECT(rtpstream_save_dlg, "delete_event", window_delete_event_cb, NULL);
+ SIGNAL_CONNECT(rtpstream_save_dlg, "destroy", save_stream_destroy_cb,
+ NULL);
gtk_widget_show(rtpstream_save_dlg);
+ window_present(rtpstream_save_dlg);
}
@@ -405,16 +401,6 @@ rtpstream_on_filter (GtkButton *button _U_,
/****************************************************************************/
static void
-rtpstream_on_close (GtkButton *button _U_,
- gpointer user_data _U_)
-{
- gtk_grab_remove(rtp_stream_dlg);
- gtk_widget_destroy(rtp_stream_dlg);
-}
-
-
-/****************************************************************************/
-static void
rtpstream_on_analyse (GtkButton *button _U_,
gpointer user_data _U_)
{
@@ -588,12 +574,10 @@ rtpstream_sort_column(GtkCList *clist, gconstpointer ptr1, gconstpointer ptr2)
static void rtpstream_dlg_create (void)
{
GtkWidget *rtpstream_dlg_w;
- GtkWidget *dialog_vbox1;
- GtkWidget *vbox1;
- GtkWidget *label10;
- GtkWidget *scrolledwindow1;
- GtkWidget *dialog_action_area1;
- GtkWidget *hbuttonbox2;
+ GtkWidget *main_vb;
+ GtkWidget *label;
+ GtkWidget *scrolledwindow;
+ GtkWidget *hbuttonbox;
/* GtkWidget *bt_goto;*/
GtkWidget *bt_unselect;
GtkWidget *bt_findrev;
@@ -605,35 +589,24 @@ static void rtpstream_dlg_create (void)
gchar *titles[8] = {"Src IP addr", "Src port", "Dest IP addr", "Dest port", "SSRC", "Payload", "Packets", "Comment"};
column_arrows *col_arrows;
- GdkBitmap *ascend_bm, *descend_bm;
- GdkPixmap *ascend_pm, *descend_pm;
- GtkStyle *win_style;
GtkWidget *column_lb;
int i;
- rtpstream_dlg_w = gtk_dialog_new();
- gtk_window_set_title (GTK_WINDOW (rtpstream_dlg_w), "Ethereal: RTP Streams");
-
- dialog_vbox1 = GTK_DIALOG (rtpstream_dlg_w)->vbox;
- gtk_widget_show (dialog_vbox1);
+ rtpstream_dlg_w = dlg_window_new("Ethereal: RTP Streams");
+ gtk_window_set_default_size(GTK_WINDOW(rtpstream_dlg_w), 620, 200);
- vbox1 = gtk_vbox_new (FALSE, 0);
- gtk_widget_show (vbox1);
- gtk_box_pack_start (GTK_BOX (dialog_vbox1), vbox1, TRUE, TRUE, 0);
- gtk_container_set_border_width (GTK_CONTAINER (vbox1), 8);
+ main_vb = gtk_vbox_new (FALSE, 0);
+ gtk_container_add(GTK_CONTAINER(rtpstream_dlg_w), main_vb);
+ gtk_container_set_border_width (GTK_CONTAINER (main_vb), 12);
- label10 = gtk_label_new ("Detected RTP streams. Choose one for forward and reverse direction for analysis");
- gtk_widget_show (label10);
- gtk_box_pack_start (GTK_BOX (vbox1), label10, FALSE, FALSE, 8);
+ label = gtk_label_new ("Detected RTP streams. Choose one for forward and reverse direction for analysis");
+ gtk_box_pack_start (GTK_BOX (main_vb), label, FALSE, FALSE, 8);
- scrolledwindow1 = scrolled_window_new (NULL, NULL);
- gtk_widget_show (scrolledwindow1);
- gtk_box_pack_start (GTK_BOX (vbox1), scrolledwindow1, TRUE, TRUE, 0);
+ scrolledwindow = scrolled_window_new (NULL, NULL);
+ gtk_box_pack_start (GTK_BOX (main_vb), scrolledwindow, TRUE, TRUE, 0);
clist = gtk_clist_new (NUM_COLS);
- gtk_widget_show (clist);
- gtk_container_add (GTK_CONTAINER (scrolledwindow1), clist);
- WIDGET_SET_SIZE(clist, 620, 200);
+ gtk_container_add (GTK_CONTAINER (scrolledwindow), clist);
gtk_clist_set_column_width (GTK_CLIST (clist), 0, 100);
gtk_clist_set_column_width (GTK_CLIST (clist), 1, 50);
@@ -663,15 +636,6 @@ static void rtpstream_dlg_create (void)
/* sort by column feature */
col_arrows = (column_arrows *) g_malloc(sizeof(column_arrows) * NUM_COLS);
- win_style = gtk_widget_get_style(scrolledwindow1);
- ascend_pm = gdk_pixmap_create_from_xpm_d(scrolledwindow1->window,
- &ascend_bm,
- &win_style->bg[GTK_STATE_NORMAL],
- (gchar **)clist_ascend_xpm);
- descend_pm = gdk_pixmap_create_from_xpm_d(scrolledwindow1->window,
- &descend_bm,
- &win_style->bg[GTK_STATE_NORMAL],
- (gchar **)clist_descend_xpm);
for (i=0; i<NUM_COLS; i++) {
col_arrows[i].table = gtk_table_new(2, 2, FALSE);
@@ -680,9 +644,9 @@ static void rtpstream_dlg_create (void)
gtk_table_attach(GTK_TABLE(col_arrows[i].table), column_lb, 0, 1, 0, 2, GTK_SHRINK, GTK_SHRINK, 0, 0);
gtk_widget_show(column_lb);
- col_arrows[i].ascend_pm = gtk_pixmap_new(ascend_pm, ascend_bm);
+ col_arrows[i].ascend_pm = xpm_to_widget(clist_ascend_xpm);
gtk_table_attach(GTK_TABLE(col_arrows[i].table), col_arrows[i].ascend_pm, 1, 2, 1, 2, GTK_SHRINK, GTK_SHRINK, 0, 0);
- col_arrows[i].descend_pm = gtk_pixmap_new(descend_pm, descend_bm);
+ col_arrows[i].descend_pm = xpm_to_widget(clist_descend_xpm);
gtk_table_attach(GTK_TABLE(col_arrows[i].table), col_arrows[i].descend_pm, 1, 2, 0, 1, GTK_SHRINK, GTK_SHRINK, 0, 0);
/* make src-ip be the default sort order */
if (i == 0) {
@@ -695,61 +659,41 @@ static void rtpstream_dlg_create (void)
SIGNAL_CONNECT(clist, "click-column", rtpstream_click_column_cb, col_arrows);
label_fwd = gtk_label_new (FWD_LABEL_TEXT);
- gtk_widget_show (label_fwd);
- gtk_box_pack_start (GTK_BOX (vbox1), label_fwd, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (main_vb), label_fwd, FALSE, FALSE, 0);
label_rev = gtk_label_new (REV_LABEL_TEXT);
- gtk_widget_show (label_rev);
- gtk_box_pack_start (GTK_BOX (vbox1), label_rev, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (main_vb), label_rev, FALSE, FALSE, 0);
- dialog_action_area1 = GTK_DIALOG (rtpstream_dlg_w)->action_area;
- gtk_widget_show (dialog_action_area1);
- gtk_container_set_border_width (GTK_CONTAINER (dialog_action_area1), 10);
-
- hbuttonbox2 = gtk_hbutton_box_new ();
- gtk_widget_show (hbuttonbox2);
- gtk_box_pack_start (GTK_BOX (dialog_action_area1), hbuttonbox2, FALSE, FALSE, 0);
- gtk_button_box_set_layout (GTK_BUTTON_BOX (hbuttonbox2), GTK_BUTTONBOX_END);
- gtk_button_box_set_spacing (GTK_BUTTON_BOX (hbuttonbox2), 0);
+ /* button row */
+ hbuttonbox = gtk_hbutton_box_new ();
+ gtk_box_pack_start (GTK_BOX (main_vb), hbuttonbox, FALSE, FALSE, 0);
+ gtk_button_box_set_layout (GTK_BUTTON_BOX (hbuttonbox), GTK_BUTTONBOX_END);
+ gtk_button_box_set_spacing (GTK_BUTTON_BOX (hbuttonbox), 0);
bt_unselect = gtk_button_new_with_label ("Unselect");
- gtk_widget_show (bt_unselect);
- gtk_container_add (GTK_CONTAINER (hbuttonbox2), bt_unselect);
+ gtk_container_add (GTK_CONTAINER (hbuttonbox), bt_unselect);
bt_findrev = gtk_button_new_with_label ("Find Reverse");
- gtk_widget_show (bt_findrev);
- gtk_container_add (GTK_CONTAINER (hbuttonbox2), bt_findrev);
+ gtk_container_add (GTK_CONTAINER (hbuttonbox), bt_findrev);
/*
bt_goto = BUTTON_NEW_FROM_STOCK(GTK_STOCK_JUMP_TO);
- gtk_widget_show (bt_goto);
- gtk_container_add (GTK_CONTAINER (hbuttonbox2), bt_goto);
+ gtk_container_add (GTK_CONTAINER (hbuttonbox), bt_goto);
*/
bt_save = BUTTON_NEW_FROM_STOCK(GTK_STOCK_SAVE_AS);
- gtk_widget_show (bt_save);
- gtk_container_add (GTK_CONTAINER (hbuttonbox2), bt_save);
+ gtk_container_add (GTK_CONTAINER (hbuttonbox), bt_save);
bt_frames = gtk_button_new_with_label ("Mark frames");
- gtk_widget_show (bt_frames);
- gtk_container_add (GTK_CONTAINER (hbuttonbox2), bt_frames);
+ gtk_container_add (GTK_CONTAINER (hbuttonbox), bt_frames);
bt_filter = gtk_button_new_with_label ("Set filter");
- gtk_widget_show (bt_filter);
- gtk_container_add (GTK_CONTAINER (hbuttonbox2), bt_filter);
+ gtk_container_add (GTK_CONTAINER (hbuttonbox), bt_filter);
bt_analyse = gtk_button_new_with_label ("Analyse");
- gtk_widget_show (bt_analyse);
- gtk_container_add (GTK_CONTAINER (hbuttonbox2), bt_analyse);
+ gtk_container_add (GTK_CONTAINER (hbuttonbox), bt_analyse);
bt_close = BUTTON_NEW_FROM_STOCK(GTK_STOCK_CLOSE);
- gtk_widget_show (bt_close);
- gtk_container_add (GTK_CONTAINER (hbuttonbox2), bt_close);
+ gtk_container_add (GTK_CONTAINER (hbuttonbox), bt_close);
- /* Catch the "key_press_event" signal in the window, so that we can
- catch the ESC key being pressed and act as if the "Close" button had
- been selected. */
- dlg_set_cancel(rtpstream_dlg_w, bt_close);
-
- SIGNAL_CONNECT(rtpstream_dlg_w, "destroy", rtpstream_on_destroy, NULL);
SIGNAL_CONNECT(clist, "select_row", rtpstream_on_select_row, NULL);
SIGNAL_CONNECT(bt_unselect, "clicked", rtpstream_on_unselect, NULL);
SIGNAL_CONNECT(bt_findrev, "clicked", rtpstream_on_findrev, NULL);
@@ -760,8 +704,15 @@ static void rtpstream_dlg_create (void)
SIGNAL_CONNECT(bt_frames, "clicked", rtpstream_on_mark, NULL);
SIGNAL_CONNECT(bt_filter, "clicked", rtpstream_on_filter, NULL);
SIGNAL_CONNECT(bt_analyse, "clicked", rtpstream_on_analyse, NULL);
- SIGNAL_CONNECT(bt_close, "clicked", rtpstream_on_close, NULL);
-
+
+ window_set_cancel_button(rtpstream_dlg_w, bt_close, window_cancel_button_cb);
+
+ SIGNAL_CONNECT(rtpstream_dlg_w, "delete_event", window_delete_event_cb, NULL);
+ SIGNAL_CONNECT(rtpstream_dlg_w, "destroy", rtpstream_on_destroy, NULL);
+
+ gtk_widget_show_all(rtpstream_dlg_w);
+ window_present(rtpstream_dlg_w);
+
rtpstream_on_unselect(NULL, NULL);
rtp_stream_dlg = rtpstream_dlg_w;
diff --git a/gtk/simple_dialog.c b/gtk/simple_dialog.c
index 3d467843a8..b69396ce51 100644
--- a/gtk/simple_dialog.c
+++ b/gtk/simple_dialog.c
@@ -1,7 +1,7 @@
/* simple_dialog.c
* Simple message dialog box routines.
*
- * $Id: simple_dialog.c,v 1.34 2004/05/17 21:15:28 ulfl Exp $
+ * $Id: simple_dialog.c,v 1.35 2004/05/26 03:49:24 ulfl Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -33,6 +33,7 @@
#include "gtkglobals.h"
#include "simple_dialog.h"
#include "dlg_utils.h"
+#include "ui_util.h"
#include "compat_macros.h"
#include <epan/strutil.h>
@@ -207,20 +208,11 @@ display_simple_dialog(gint type, gint btn_mask, char *message)
bt = OBJECT_GET_DATA(bbox, GTK_STOCK_CANCEL);
if(bt) {
OBJECT_SET_DATA(bt, CALLBACK_BTN_KEY, GINT_TO_POINTER(ESD_BTN_CANCEL));
- SIGNAL_CONNECT(bt, "clicked", simple_dialog_cancel_cb, win);
- /* Catch the "key_press_event" signal in the window, so that we can catch
- the ESC key being pressed and act as if the "OK" button had
- been selected. */
- dlg_set_cancel(win, bt);
- gtk_widget_grab_default(bt);
+ window_set_cancel_button(win, bt, simple_dialog_cancel_cb);
}
if(!bt) {
- /* Catch the "key_press_event" signal in the window, so that we can catch
- the ESC key being pressed and act as if the "OK" button had
- been selected. */
- dlg_set_cancel(win, ok_bt);
- gtk_widget_grab_default(ok_bt);
+ window_set_cancel_button(win, ok_bt, simple_dialog_cancel_cb);
}
gtk_widget_show(win);
@@ -321,7 +313,7 @@ simple_dialog_cancel_cb(GtkWidget *w, gpointer win) {
simple_dialog_cb_t callback_fct = OBJECT_GET_DATA(win, CALLBACK_FCT_KEY);
gpointer data = OBJECT_GET_DATA(win, CALLBACK_DATA_KEY);
- gtk_widget_destroy(GTK_WIDGET(win));
+ window_destroy(GTK_WIDGET(win));
if (callback_fct)
(callback_fct) (win, button, data);
diff --git a/gtk/tcp_graph.c b/gtk/tcp_graph.c
index 4a15020691..b54275808f 100644
--- a/gtk/tcp_graph.c
+++ b/gtk/tcp_graph.c
@@ -3,7 +3,7 @@
* By Pavel Mores <pvl@uh.cz>
* Win32 port: rwh@unifiedtech.com
*
- * $Id: tcp_graph.c,v 1.61 2004/05/23 23:24:06 ulfl Exp $
+ * $Id: tcp_graph.c,v 1.62 2004/05/26 03:49:24 ulfl Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -900,14 +900,10 @@ static void control_panel_create (struct graph *g)
SIGNAL_CONNECT(help_bt, "clicked", callback_create_help, g);
close_bt = OBJECT_GET_DATA(bbox, GTK_STOCK_CLOSE);
- gtk_widget_grab_default(close_bt);
+ window_set_cancel_button(toplevel, close_bt, NULL);
SIGNAL_CONNECT(close_bt, "clicked", callback_close, g);
- /* Catch the "key_press_event" signal in the window, so that we can
- catch the ESC key being pressed and act as if the "Close" button had
- been selected. */
- dlg_set_cancel(toplevel, close_bt);
-
+ SIGNAL_CONNECT(toplevel, "delete_event", callback_close, g);
SIGNAL_CONNECT(toplevel, "destroy", callback_toplevel_destroy, g);
/* gtk_widget_show_all (table); */
diff --git a/gtk/ui_util.c b/gtk/ui_util.c
index df23a41c3c..7bef7bba95 100644
--- a/gtk/ui_util.c
+++ b/gtk/ui_util.c
@@ -1,7 +1,7 @@
/* ui_util.c
* UI utility routines
*
- * $Id: ui_util.c,v 1.25 2004/05/24 09:00:52 guy Exp $
+ * $Id: ui_util.c,v 1.26 2004/05/26 03:49:24 ulfl Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -37,6 +37,7 @@
#endif
#include <gtk/gtk.h>
+#include <gdk/gdkkeysyms.h>
#include "gtkglobals.h"
#include "ui_util.h"
@@ -147,7 +148,7 @@ window_new(GtkWindowType type, const gchar *title)
return win;
}
-/* Present the created window. */
+/* Present the created window on the screen. */
void
window_present(GtkWidget *win)
{
@@ -169,18 +170,48 @@ window_present(GtkWidget *win)
}
-/* set the actions needed for the cancel "Close"/"Ok"/"Cancel button that closes the window */
+static gint
+window_key_press_cb (GtkWidget *widget, GdkEventKey *event, gpointer cancel_button)
+{
+ g_return_val_if_fail (widget != NULL, FALSE);
+ g_return_val_if_fail (event != NULL, FALSE);
+
+ if (event->keyval == GDK_Escape) {
+ gtk_widget_activate(GTK_WIDGET(cancel_button));
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+
+/* Set the "key_press_event" signal for a top-level dialog window to
+ call a routine to activate the "Cancel" button for a dialog box if
+ the key being pressed is the <Esc> key.
+
+ XXX - there should be a GTK+ widget that'll do that for you, and
+ let you specify a "Cancel" button. It should also not impose
+ a requirement that there be a separator in the dialog box, as
+ the GtkDialog widget does; the visual convention that there's
+ such a separator between the rest of the dialog boxes and buttons
+ such as "OK" and "Cancel" is, for better or worse, not universal
+ (not even in GTK+ - look at the GtkFileSelection dialog!). */
+static void
+window_set_cancel(GtkWidget *widget, GtkWidget *cancel_button)
+{
+ SIGNAL_CONNECT(widget, "key_press_event", window_key_press_cb, cancel_button);
+}
+
+
+/* set the actions needed for the cancel "Close"/"Ok"/"Cancel" button that closes the window */
void window_set_cancel_button(GtkWidget *win, GtkWidget *bt, window_cancel_button_fct cb)
{
-/* SIGNAL_CONNECT_OBJECT(bt, "clicked", cb, win);*/
- SIGNAL_CONNECT(bt, "clicked", cb, win);
+ if(cb)
+ SIGNAL_CONNECT(bt, "clicked", cb, win);
gtk_widget_grab_default(bt);
- /* 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(win, bt);
+ window_set_cancel(win, bt);
}