aboutsummaryrefslogtreecommitdiffstats
path: root/gtk
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2002-01-08 09:32:15 +0000
committerGuy Harris <guy@alum.mit.edu>2002-01-08 09:32:15 +0000
commit12d566c0acad92a519b0bfef73a955a648f555fe (patch)
tree2b2117f07519ea791bd6a6fef23dcce9b3ac2270 /gtk
parent86a251065d768c8e88a6f5c62dc0e53d93cabb8e (diff)
Add a routine to kill a capture child if it exists, so that if we exit
(by deleting the main window or selecting File->Quit or typing ^Q) while an "Update list of packets in real time" capture is in progress, we can abort the capture. Arrange that "fork_child" is -1 when there is no capture child, so said routine knows when it can kill the child. When we exit, kill off any capture child, using that routine, and, if we're exiting due to a request to delete the main window and, if a read is in progress (from an "Update list of packets in real time" capture), don't delete the main window - just set the "Read aborted" flag, so that the code doing the read will see that flag (it will be called because the pipe to the capture child is closed due to the child exiting) will see that and clean up and exit itself. svn path=/trunk/; revision=4498
Diffstat (limited to 'gtk')
-rw-r--r--gtk/main.c77
1 files changed, 48 insertions, 29 deletions
diff --git a/gtk/main.c b/gtk/main.c
index b8ab021e86..7be6344f3e 100644
--- a/gtk/main.c
+++ b/gtk/main.c
@@ -1,6 +1,6 @@
/* main.c
*
- * $Id: main.c,v 1.222 2001/12/31 04:41:50 gerald Exp $
+ * $Id: main.c,v 1.223 2002/01/08 09:32:15 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -734,31 +734,7 @@ statusbar_pop_field_msg(void)
}
static gboolean
-main_window_delete_event_cb(GtkWidget *widget, GdkEvent *event, gpointer data)
-{
- gint desk_x, desk_y;
-
- /* Try to grab our geometry */
- gdk_window_get_root_origin(top_level->window, &root_x, &root_y);
- if (gdk_window_get_deskrelative_origin(top_level->window,
- &desk_x, &desk_y)) {
- if (desk_x <= root_x && desk_y <= root_y) {
- root_x = desk_x;
- root_y = desk_y;
- }
- }
-
- /* XXX - Is this the "approved" method? */
- gdk_window_get_size(top_level->window, &top_width, &top_height);
-
- file_quit_cmd_cb(widget, data);
-
- /* Say that the window should be deleted. */
- return FALSE;
-}
-
-void
-file_quit_cmd_cb (GtkWidget *widget, gpointer data)
+do_quit(void)
{
/* XXX - should we check whether the capture file is an
unsaved temporary file for a live capture and, if so,
@@ -767,9 +743,17 @@ file_quit_cmd_cb (GtkWidget *widget, gpointer data)
box to forcibly quit if the user clicks "OK"?
If so, note that this should be done in a subroutine that
- returns TRUE if we do so, and FALSE otherwise, and that
- "main_window_delete_event_cb()" should return its
- return value. */
+ returns TRUE if we do so, and FALSE otherwise, and if it
+ returns TRUE we should return TRUE without nuking anything.
+
+ Note that, if we do that, we might also want to check if
+ an "Update list of packets in real time" capture is in
+ progress and, if so, ask whether they want to terminate
+ the capture and discard it, and return TRUE, before nuking
+ any child capture, if they say they don't want to do so. */
+
+ /* Nuke any child capture in progress. */
+ kill_capture_child();
/* Are we in the middle of reading a capture? */
if (cfile.state == FILE_READ_IN_PROGRESS) {
@@ -780,6 +764,10 @@ file_quit_cmd_cb (GtkWidget *widget, gpointer data)
will check for that and, if it sees that, will clean
up and quit. */
cfile.state = FILE_READ_ABORTED;
+
+ /* Say that the window should *not* be deleted;
+ that'll be done by the code that cleans up. */
+ return TRUE;
} else {
/* Close any capture file we have open; on some OSes, you
can't unlink a temporary capture file if you have it
@@ -806,9 +794,40 @@ file_quit_cmd_cb (GtkWidget *widget, gpointer data)
/* Exit by leaving the main loop, so that any quit functions
we registered get called. */
gtk_main_quit();
+
+ /* Say that the window should be deleted. */
+ return FALSE;
}
}
+static gboolean
+main_window_delete_event_cb(GtkWidget *widget, GdkEvent *event, gpointer data)
+{
+ gint desk_x, desk_y;
+
+ /* Try to grab our geometry */
+ gdk_window_get_root_origin(top_level->window, &root_x, &root_y);
+ if (gdk_window_get_deskrelative_origin(top_level->window,
+ &desk_x, &desk_y)) {
+ if (desk_x <= root_x && desk_y <= root_y) {
+ root_x = desk_x;
+ root_y = desk_y;
+ }
+ }
+
+ /* XXX - Is this the "approved" method? */
+ gdk_window_get_size(top_level->window, &top_width, &top_height);
+
+ /* "do_quit()" indicates whether the main window should be deleted. */
+ return do_quit();
+}
+
+void
+file_quit_cmd_cb (GtkWidget *widget, gpointer data)
+{
+ do_quit();
+}
+
static void
print_usage(void) {