From e08ae89241e89400777797ce29a6b21ac425a962 Mon Sep 17 00:00:00 2001 From: Ulf Lamping Date: Sat, 12 Apr 2008 17:04:21 +0000 Subject: [PATCH] cleanup of "capture_in_progress" ugly hack from main_toolbar, call capture_if_dlg directly from within main.c svn path=/trunk/; revision=24943 --- gtk/capture_if_dlg.c | 5 ++++- gtk/main.c | 10 +++++++++- gtk/main_toolbar.c | 12 ------------ gtk/main_toolbar.h | 3 +-- 4 files changed, 14 insertions(+), 16 deletions(-) diff --git a/gtk/capture_if_dlg.c b/gtk/capture_if_dlg.c index 46951ef8ec4..60ff2b818c9 100644 --- a/gtk/capture_if_dlg.c +++ b/gtk/capture_if_dlg.c @@ -246,6 +246,7 @@ update_all(gpointer data) return TRUE; } +gboolean g_capture_in_progress = FALSE; /* a live capture has started or stopped */ void @@ -254,6 +255,8 @@ set_capture_if_dialog_for_capture_in_progress(gboolean capture_in_progress) GList *curr; int ifs; + g_capture_in_progress = capture_in_progress; + if(cap_if_w) { gtk_widget_set_sensitive(stop_bt, capture_in_progress); @@ -658,7 +661,7 @@ capture_if_cb(GtkWidget *w _U_, gpointer d _U_) gtk_widget_show_all(cap_if_w); window_present(cap_if_w); - set_capture_if_dialog_for_capture_in_progress(is_capture_in_progress()); + set_capture_if_dialog_for_capture_in_progress(g_capture_in_progress); /* update the interface list every 1000ms */ timer_id = gtk_timeout_add(1000, update_all, sc); diff --git a/gtk/main.c b/gtk/main.c index 0d2de4341cf..33e2df929ae 100644 --- a/gtk/main.c +++ b/gtk/main.c @@ -1345,6 +1345,7 @@ main_cf_cb_file_closing(capture_file *cf) set_menus_for_captured_packets(FALSE); set_menus_for_selected_packet(cf); set_menus_for_capture_in_progress(FALSE); + set_capture_if_dialog_for_capture_in_progress(FALSE); set_menus_for_selected_tree_row(cf); /* Set up main window for no capture file. */ @@ -1448,6 +1449,7 @@ main_cf_cb_live_capture_prepared(capture_options *capture_opts) /* Disable menu items that make no sense if you're currently running a capture. */ set_menus_for_capture_in_progress(TRUE); + set_capture_if_dialog_for_capture_in_progress(TRUE); /* Don't set up main window for a capture file. */ main_set_for_capture_file(FALSE); @@ -1470,6 +1472,7 @@ main_cf_cb_live_capture_update_started(capture_options *capture_opts) g_free(title); set_menus_for_capture_in_progress(TRUE); + set_capture_if_dialog_for_capture_in_progress(TRUE); /* Enable menu items that make sense if you have some captured packets (yes, I know, we don't have any *yet*). */ @@ -1489,6 +1492,7 @@ main_cf_cb_live_capture_update_finished(capture_file *cf) /* Enable menu items that make sense if you're not currently running a capture. */ set_menus_for_capture_in_progress(FALSE); + set_capture_if_dialog_for_capture_in_progress(FALSE); /* Enable menu items that make sense if you have a capture file you've finished reading. */ @@ -1526,6 +1530,7 @@ main_cf_cb_live_capture_fixed_finished(capture_file *cf _U_) /* Enable menu items that make sense if you're not currently running a capture. */ set_menus_for_capture_in_progress(FALSE); + set_capture_if_dialog_for_capture_in_progress(FALSE); /* Restore the standard title bar message */ /* (just in case we have trouble opening the capture file). */ @@ -2650,7 +2655,8 @@ main(int argc, char *argv[]) dfilter_free(rfcode); cfile.rfcode = NULL; show_main_window(FALSE); - set_menus_for_capture_in_progress(FALSE); + set_menus_for_capture_in_progress(FALSE); + set_capture_if_dialog_for_capture_in_progress(FALSE); } } } else { @@ -2678,6 +2684,7 @@ main(int argc, char *argv[]) else { show_main_window(FALSE); set_menus_for_capture_in_progress(FALSE); + set_capture_if_dialog_for_capture_in_progress(FALSE); } /* if the user didn't supplied a capture filter, use the one to filter out remote connections like SSH */ @@ -2688,6 +2695,7 @@ main(int argc, char *argv[]) #else /* HAVE_LIBPCAP */ show_main_window(FALSE); set_menus_for_capture_in_progress(FALSE); + set_capture_if_dialog_for_capture_in_progress(FALSE); #endif /* HAVE_LIBPCAP */ } diff --git a/gtk/main_toolbar.c b/gtk/main_toolbar.c index 3298dd0d400..5efb7ccd9f8 100644 --- a/gtk/main_toolbar.c +++ b/gtk/main_toolbar.c @@ -177,21 +177,9 @@ void set_toolbar_for_packet_history(gboolean back_history, gboolean forward_hist } -/* XXX - this is a quick and dirty hack to get the current state of capturing. - * this has to be improved, and should be reside somewhere in the capture engine. */ -gboolean g_is_capture_in_progress = FALSE; - -gboolean -is_capture_in_progress(void) -{ - return g_is_capture_in_progress; -} - /* set toolbar state "have a capture in progress" */ void set_toolbar_for_capture_in_progress(gboolean capture_in_progress) { - g_is_capture_in_progress = capture_in_progress; - if (toolbar_init) { #ifdef HAVE_LIBPCAP gtk_widget_set_sensitive(GTK_WIDGET(capture_options_button), !capture_in_progress); diff --git a/gtk/main_toolbar.h b/gtk/main_toolbar.h index 39c8c6798f7..42c32bd6e1d 100644 --- a/gtk/main_toolbar.h +++ b/gtk/main_toolbar.h @@ -26,7 +26,6 @@ #ifndef __TOOLBAR_H__ #define __TOOLBAR_H__ -gboolean is_capture_in_progress(void); /** @file * The main toolbar. @@ -34,7 +33,7 @@ gboolean is_capture_in_progress(void); */ /** Create the main toolbar. - * @return the new (still hidden) toolbar + * @return the new toolbar */ GtkWidget *toolbar_new(void);