aboutsummaryrefslogtreecommitdiffstats
path: root/gtk/progress_dlg.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2000-07-07 23:09:15 +0000
committerGuy Harris <guy@alum.mit.edu>2000-07-07 23:09:15 +0000
commitae1df375130ca48b3ccd07160e6c47b353253e55 (patch)
tree5619e9209e3f0ccd11c34b8830789f2828db9baa /gtk/progress_dlg.c
parent839193f0e7da2a7c6eb79e3fd66f111dd7f75ad6 (diff)
If the progress dialog gets a "delete" event, have the handler return
TRUE, meaning "don't delete this", and if its "stop this operation" button gets clicked, don't have its handler delete the progress dialog; instead, leave the deletion of the window up to the code using the dialog, as it'll do so when it stops the operation. Make the "read file" operation destroy the dialog; all the other operations already did so (as they just broke out of the loop doing the operation, rather than returning). Don't catch the "destroy" operation on the dialog box - its handler appeared never to get called; we can just free the "progdlg_t" for the dialog in "destroy_progress_dlg()", right after destroying the dialog box widget. svn path=/trunk/; revision=2122
Diffstat (limited to 'gtk/progress_dlg.c')
-rw-r--r--gtk/progress_dlg.c57
1 files changed, 19 insertions, 38 deletions
diff --git a/gtk/progress_dlg.c b/gtk/progress_dlg.c
index 93e629fd08..33d092c701 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.6 2000/07/07 07:01:58 guy Exp $
+ * $Id: progress_dlg.c,v 1.7 2000/07/07 23:09:15 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -35,7 +35,6 @@
static gint delete_event_cb(GtkWidget *w, GdkEvent *event, gpointer data);
static void stop_cb(GtkWidget *w, gpointer data);
-static void destroy_cb(GtkWidget *w, gpointer data);
/*
* Define the structure describing a progress dialog.
@@ -70,7 +69,7 @@ create_progress_dlg(const gchar *title, const gchar *stop_title,
gboolean *stop_flag)
{
progdlg_t *dlg;
- GtkWidget *dlg_w, *main_vb, *title_lb, *prog_bar, *bbox, *cancel_bt;
+ GtkWidget *dlg_w, *main_vb, *title_lb, *prog_bar, *bbox, *stop_bt;
dlg = g_malloc(sizeof (progdlg_t));
@@ -79,13 +78,6 @@ create_progress_dlg(const gchar *title, const gchar *stop_title,
gtk_window_set_modal(GTK_WINDOW(dlg_w), TRUE);
/*
- * Call a handler when the progress dialog box is destroyed, so
- * we can free the "progdlg_t" to which it refers.
- */
- gtk_signal_connect(GTK_OBJECT(dlg_w), "destroy",
- GTK_SIGNAL_FUNC(destroy_cb), dlg);
-
- /*
* Container for dialog widgets.
*/
main_vb = gtk_vbox_new(FALSE, 1);
@@ -129,16 +121,16 @@ create_progress_dlg(const gchar *title, const gchar *stop_title,
* the close button on the window, to stop an operation in
* progress.
*/
- cancel_bt = gtk_button_new_with_label(stop_title);
- gtk_box_pack_start(GTK_BOX (bbox), cancel_bt, TRUE, TRUE, 0);
- gtk_signal_connect(GTK_OBJECT(cancel_bt), "clicked",
+ stop_bt = gtk_button_new_with_label(stop_title);
+ gtk_box_pack_start(GTK_BOX (bbox), stop_bt, TRUE, TRUE, 0);
+ gtk_signal_connect(GTK_OBJECT(stop_bt), "clicked",
GTK_SIGNAL_FUNC(stop_cb), (gpointer) stop_flag);
gtk_signal_connect(GTK_OBJECT(dlg_w), "delete_event",
GTK_SIGNAL_FUNC(delete_event_cb), (gpointer) stop_flag);
- GTK_WIDGET_SET_FLAGS(cancel_bt, GTK_CAN_DEFAULT);
- gtk_widget_grab_default(cancel_bt);
- GTK_WIDGET_SET_FLAGS(cancel_bt, GTK_CAN_DEFAULT);
- gtk_widget_grab_default(cancel_bt);
+ GTK_WIDGET_SET_FLAGS(stop_bt, GTK_CAN_DEFAULT);
+ gtk_widget_grab_default(stop_bt);
+ GTK_WIDGET_SET_FLAGS(stop_bt, GTK_CAN_DEFAULT);
+ gtk_widget_grab_default(stop_bt);
gtk_widget_show_all(dlg_w);
@@ -149,18 +141,24 @@ create_progress_dlg(const gchar *title, const gchar *stop_title,
/*
* Called when the dialog box is to be deleted.
- * We just treat this the same way we treat clicking the "Cancel" button.
+ * Set the "stop" flag to TRUE, and return TRUE - we don't want the dialog
+ * box deleted now, our caller will do so when they see that the
+ * "stop" flag is TRUE and abort the operation.
*/
static gint
delete_event_cb(GtkWidget *w, GdkEvent *event, gpointer data)
{
- stop_cb(NULL, data);
- return FALSE; /* go ahead and delete it */
+ gboolean *stop_flag = (gboolean *) data;
+
+ *stop_flag = TRUE;
+ return TRUE;
}
/*
* Called when the "stop this operation" button is clicked.
- * Set the Boolean to TRUE.
+ * Set the "stop" flag to TRUE; we don't have to destroy the dialog
+ * box, as our caller will do so when they see that the "stop" flag is
+ * true and abort the operation.
*/
static void
stop_cb(GtkWidget *w, gpointer data)
@@ -168,13 +166,6 @@ stop_cb(GtkWidget *w, gpointer data)
gboolean *stop_flag = (gboolean *) data;
*stop_flag = TRUE;
- if (w != NULL) {
- /*
- * The cancel button was clicked, so we have to destroy
- * the dialog box ourselves.
- */
- gtk_widget_destroy(GTK_WIDGET(gtk_widget_get_toplevel(w)));
- }
}
/*
@@ -205,15 +196,5 @@ destroy_progress_dlg(progdlg_t *dlg)
GtkWidget *dlg_w = dlg->dlg_w;
gtk_widget_destroy(GTK_WIDGET(dlg_w));
-}
-
-/*
- * Called when the top-level window is destroyed.
- */
-static void
-destroy_cb(GtkWidget *w, gpointer data)
-{
- progdlg_t *dlg = data;
-
g_free(dlg);
}