Skip to content

Commit

Permalink
cleanup of "capture_in_progress" ugly hack from main_toolbar, call ca…
Browse files Browse the repository at this point in the history
…pture_if_dlg directly from within main.c

svn path=/trunk/; revision=24943
  • Loading branch information
ulflulfl committed Apr 12, 2008
1 parent 4073fa0 commit e08ae89
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 16 deletions.
5 changes: 4 additions & 1 deletion gtk/capture_if_dlg.c
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ update_all(gpointer data)
return TRUE;
}

gboolean g_capture_in_progress = FALSE;

/* a live capture has started or stopped */
void
Expand All @@ -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);

Expand Down Expand Up @@ -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);
Expand Down
10 changes: 9 additions & 1 deletion gtk/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down Expand Up @@ -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);
Expand All @@ -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*). */
Expand All @@ -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. */
Expand Down Expand Up @@ -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). */
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 */
Expand All @@ -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 */
}

Expand Down
12 changes: 0 additions & 12 deletions gtk/main_toolbar.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions gtk/main_toolbar.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,14 @@
#ifndef __TOOLBAR_H__
#define __TOOLBAR_H__

gboolean is_capture_in_progress(void);

/** @file
* The main toolbar.
* @ingroup main_window_group
*/

/** Create the main toolbar.
* @return the new (still hidden) toolbar
* @return the new toolbar
*/
GtkWidget *toolbar_new(void);

Expand Down

0 comments on commit e08ae89

Please sign in to comment.