aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUlf Lamping <ulf.lamping@web.de>2005-04-19 21:02:01 +0000
committerUlf Lamping <ulf.lamping@web.de>2005-04-19 21:02:01 +0000
commit9b5d52aab65358c11e5344e61e8c9a039a850e90 (patch)
tree7b05236b0d52029ec646e97ec527a0db9c123077
parent2078bfc8b4cbc3239df7629df6c393aaf3ee50a5 (diff)
ask for unsaved file when using the new start capture feature,
ask for unsaved file when really starting the capture, not already when showing the options dialog, use the start capture icon in the capture options dialog (instead of simply Ok) svn path=/trunk/; revision=14142
-rw-r--r--gtk/capture_dlg.c105
-rw-r--r--gtk/capture_dlg.h5
-rw-r--r--gtk/capture_if_dlg.c3
-rw-r--r--gtk/dlg_utils.c9
-rw-r--r--gtk/file_dlg.c2
5 files changed, 66 insertions, 58 deletions
diff --git a/gtk/capture_dlg.c b/gtk/capture_dlg.c
index 719708ef93..3e4f396675 100644
--- a/gtk/capture_dlg.c
+++ b/gtk/capture_dlg.c
@@ -122,44 +122,14 @@ static void
capture_prep_adjust_sensitivity(GtkWidget *tb, gpointer parent_w);
static void
-capture_prep_ok_cb(GtkWidget *ok_bt, gpointer parent_w);
-
-static void
capture_prep_destroy_cb(GtkWidget *win, gpointer user_data);
static void
capture_prep_interface_changed_cb(GtkWidget *entry, gpointer parent_w);
+static void
+capture_dlg_prep(gpointer parent_w);
-/* immediately start a new capture */
-/* XXX - we should ask to save old unsaved capture file */
-void
-capture_start_cb(GtkWidget *w _U_, gpointer d _U_)
-{
-
- /* do we have an open prepare window? */
- if(cap_open_w) {
- /* yes, just act like we'd pressed the Ok button */
- capture_prep_ok_cb(NULL, cap_open_w);
- return;
- }
-
- /* init iface, if never used before */
- /* XXX - would better be doing this in main.c */
- if(capture_opts->iface == NULL) {
- gchar *if_device;
- gchar *if_name;
-
- if_device = g_strdup(prefs.capture_device);
- if_name = get_if_name(if_device);
- capture_opts->iface = g_strdup(if_name);
-
- g_free(if_device);
- }
-
- /* XXX - we might need to init other pref data as well... */
- capture_start(capture_opts);
-}
/* stop the currently running capture */
void
@@ -531,7 +501,7 @@ guint32 value)
/* show capture prepare (options) dialog */
void
-capture_prep(void)
+capture_prep_cb(GtkWidget *w _U_, gpointer d _U_)
{
GtkWidget *main_vb,
*main_hb, *left_vb, *right_vb,
@@ -1117,12 +1087,12 @@ capture_prep(void)
"Perform transport layer name resolution while capturing.", NULL);
gtk_container_add(GTK_CONTAINER(resolv_vb), t_resolv_cb);
- /* Button row: OK and cancel buttons */
- bbox = dlg_button_row_new(GTK_STOCK_OK, GTK_STOCK_CANCEL, GTK_STOCK_HELP, NULL);
+ /* Button row: "Start" and "Cancel" buttons */
+ bbox = dlg_button_row_new(ETHEREAL_STOCK_CAPTURE_START, GTK_STOCK_CANCEL, GTK_STOCK_HELP, NULL);
gtk_box_pack_start(GTK_BOX(main_vb), bbox, FALSE, FALSE, 5);
- ok_bt = OBJECT_GET_DATA(bbox, GTK_STOCK_OK);
- SIGNAL_CONNECT(ok_bt, "clicked", capture_prep_ok_cb, cap_open_w);
+ ok_bt = OBJECT_GET_DATA(bbox, ETHEREAL_STOCK_CAPTURE_START);
+ SIGNAL_CONNECT(ok_bt, "clicked", capture_start_cb, cap_open_w);
gtk_tooltips_set_tip(tooltips, ok_bt,
"Start the capture process.", NULL);
@@ -1223,8 +1193,36 @@ capture_prep(void)
window_present(cap_open_w);
}
+/* everythings prepared, now it's really time to start the capture */
+void
+capture_start_confirmed(void) {
+
+
+ /* init iface, if never used before */
+ /* XXX - would better be doing this in main.c */
+ if(capture_opts->iface == NULL) {
+ gchar *if_device;
+ gchar *if_name;
+
+ if_device = g_strdup(prefs.capture_device);
+ if_name = get_if_name(if_device);
+ capture_opts->iface = g_strdup(if_name);
+
+ g_free(if_device);
+ }
+
+ /* XXX - we might need to init other pref data as well... */
+
+ if (capture_start(capture_opts)) {
+ /* The capture succeeded, which means the capture filter syntax is
+ valid; add this capture filter to the recent capture filter list. */
+ cfilter_combo_add_recent(capture_opts->cfilter);
+ }
+}
+
+/* user confirmed the "Save capture file..." dialog */
static void
-capture_prep_answered_cb(gpointer dialog _U_, gint btn, gpointer data)
+capture_start_answered_cb(gpointer dialog _U_, gint btn, gpointer data)
{
switch(btn) {
case(ESD_BTN_SAVE):
@@ -1233,7 +1231,8 @@ capture_prep_answered_cb(gpointer dialog _U_, gint btn, gpointer data)
break;
case(ESD_BTN_DONT_SAVE):
/* XXX - unlink old file? */
- capture_prep();
+ /* start the capture */
+ capture_start_confirmed();
break;
case(ESD_BTN_CANCEL):
break;
@@ -1242,20 +1241,28 @@ capture_prep_answered_cb(gpointer dialog _U_, gint btn, gpointer data)
}
}
+/* user pressed the "Start" button (in dialog or toolbar) */
void
-capture_prep_cb(GtkWidget *w _U_, gpointer d _U_)
+capture_start_cb(GtkWidget *w _U_, gpointer d _U_)
{
gpointer dialog;
+
+ /* get the values and close the options dialog */
+ if(cap_open_w) {
+ capture_dlg_prep(cap_open_w);
+ window_destroy(GTK_WIDGET(cap_open_w));
+ }
+
if((cfile.state != FILE_CLOSED) && !cfile.user_saved && prefs.gui_ask_unsaved) {
/* user didn't saved his current file, ask him */
dialog = simple_dialog(ESD_TYPE_CONFIRMATION, ESD_BTNS_SAVE_DONTSAVE_CANCEL,
PRIMARY_TEXT_START "Save capture file before starting a new capture?" PRIMARY_TEXT_END "\n\n"
"If you start a new capture without saving, your current capture data will\nbe discarded.");
- simple_dialog_set_cb(dialog, capture_prep_answered_cb, NULL);
+ simple_dialog_set_cb(dialog, capture_start_answered_cb, NULL);
} else {
/* unchanged file, just capture a new one */
- capture_prep();
+ capture_start_confirmed();
}
}
@@ -1279,9 +1286,9 @@ capture_prep_file_cb(GtkWidget *file_bt, GtkWidget *file_te)
}
-/* user pressed "Ok" button" */
+/* convert dialog settings into capture_opts values */
static void
-capture_prep_ok_cb(GtkWidget *ok_bt _U_, gpointer parent_w) {
+capture_dlg_prep(gpointer parent_w) {
GtkWidget *if_cb, *snap_cb, *snap_sb, *promisc_cb, *filter_te, *filter_cm,
*file_te, *multi_files_on_cb, *ringbuffer_nbf_sb, *ringbuffer_nbf_cb,
*linktype_om, *sync_cb, *auto_scroll_cb, *hide_info_cb,
@@ -1519,15 +1526,7 @@ capture_prep_ok_cb(GtkWidget *ok_bt _U_, gpointer parent_w) {
return;
}
}
- }
-
- window_destroy(GTK_WIDGET(parent_w));
-
- if (capture_start(capture_opts)) {
- /* The capture succeeded, which means the capture filter syntax is
- valid; add this capture filter to the recent capture filter list. */
- cfilter_combo_add_recent(capture_opts->cfilter);
- }
+ } /* multi_files_on */
}
/* user requested to destroy the dialog */
diff --git a/gtk/capture_dlg.h b/gtk/capture_dlg.h
index 2d76a848bd..d132061066 100644
--- a/gtk/capture_dlg.h
+++ b/gtk/capture_dlg.h
@@ -59,9 +59,8 @@ void capture_stop_cb(GtkWidget *widget, gpointer data);
*/
void capture_restart_cb(GtkWidget *widget, gpointer data);
-/** Create the "Capture Options" dialog box.
- */
-void capture_prep(void);
+/* capture start confirmed by "Save unsaved capture", so do it now */
+void capture_start_confirmed(void);
/** User requested the "Capture Interfaces" dialog box by menu or toolbar.
*
diff --git a/gtk/capture_if_dlg.c b/gtk/capture_if_dlg.c
index 8bba0d09ae..6aaa6b53d0 100644
--- a/gtk/capture_if_dlg.c
+++ b/gtk/capture_if_dlg.c
@@ -113,12 +113,13 @@ capture_do_cb(GtkWidget *capture_bt _U_, gpointer if_data)
capture_opts->iface = g_strdup(if_dlg_data->device);
+ /* XXX - remove this? */
if (capture_opts->save_file) {
g_free(capture_opts->save_file);
capture_opts->save_file = NULL;
}
- capture_start(capture_opts);
+ capture_start_cb(NULL, NULL);
}
diff --git a/gtk/dlg_utils.c b/gtk/dlg_utils.c
index dbf36f2ee7..444ba93176 100644
--- a/gtk/dlg_utils.c
+++ b/gtk/dlg_utils.c
@@ -104,6 +104,7 @@ dlg_button_row_new(gchar *stock_id_first, ...)
gchar *cancel = NULL;
gchar *close = NULL;
gchar *clear = NULL;
+ gchar *start = NULL;
gchar *stop = NULL;
gchar *create_stat = NULL;
gchar *help = NULL;
@@ -134,6 +135,8 @@ dlg_button_row_new(gchar *stock_id_first, ...)
close = stock_id;
} else if (strcmp(stock_id, GTK_STOCK_CLEAR) == 0) {
clear = stock_id;
+ } else if (strcmp(stock_id, ETHEREAL_STOCK_CAPTURE_START) == 0) {
+ start = stock_id;
} else if (strcmp(stock_id, GTK_STOCK_STOP) == 0) {
stop = stock_id;
} else if (strcmp(stock_id, GTK_STOCK_HELP) == 0) {
@@ -239,6 +242,11 @@ dlg_button_row_new(gchar *stock_id_first, ...)
dlg_button_new(hbox, button_hbox, create_stat);
return hbox;
}
+ if (start && cancel) {
+ dlg_button_new(hbox, button_hbox, cancel);
+ dlg_button_new(hbox, button_hbox, start);
+ return hbox;
+ }
}
if (buttons == 3) {
if (ok && save && close) {
@@ -301,6 +309,7 @@ dlg_button_row_new(gchar *stock_id_first, ...)
if (no != NULL) dlg_button_new(hbox, button_hbox, no);
if (save != NULL) dlg_button_new(hbox, button_hbox, save);
if (dont_save != NULL) dlg_button_new(hbox, button_hbox, dont_save);
+ if (start != NULL) dlg_button_new(hbox, button_hbox, start);
if (stop != NULL) dlg_button_new(hbox, button_hbox, stop);
if (close != NULL) dlg_button_new(hbox, button_hbox, close);
if (clear != NULL) dlg_button_new(hbox, button_hbox, clear);
diff --git a/gtk/file_dlg.c b/gtk/file_dlg.c
index 5f6f3ee2e6..a445850e3a 100644
--- a/gtk/file_dlg.c
+++ b/gtk/file_dlg.c
@@ -1456,7 +1456,7 @@ file_save_as_cb(GtkWidget *w _U_, gpointer fs) {
break;
#ifdef HAVE_LIBPCAP
case(after_save_capture_dialog):
- capture_prep();
+ capture_start_confirmed();
break;
#endif
case(after_save_close_file):