From 0dbf17b690f9f79960d67f5f8a58ad0b1e90965f Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Sat, 12 Nov 2005 11:05:02 +0000 Subject: [PATCH] Allow a progress dialog to have "Stop" or "Cancel" as the "terminate button"; "Stop" should be used for operations that can only be stopped (meaning that what it's already done isn't undone), not cancelled (meaning that whatever it's already done *is* undone), for which "Cancel" is used. Allow the merging process to be cancelled. Clean up indentation. Update some comments. svn path=/trunk/; revision=16489 --- file.c | 63 ++++++++----- gtk/packet_list.c | 2 +- gtk/progress_dlg.c | 230 +++++++++++++++++++++++---------------------- gtk/proto_draw.c | 1 + gtk/rtp_analysis.c | 3 +- progress_dlg.h | 11 ++- proto_hier_stats.c | 2 +- 7 files changed, 170 insertions(+), 142 deletions(-) diff --git a/file.c b/file.c index 57729564eb..e7e5d83a3d 100644 --- a/file.c +++ b/file.c @@ -411,7 +411,7 @@ cf_read(capture_file *cf) time in order to get to the next progress bar step). */ if (progbar == NULL) { progbar = delayed_create_progress_dlg("Loading", name_ptr, - &stop_flag, &start_time, progbar_val); + TRUE, &stop_flag, &start_time, progbar_val); } /* Update the progress bar, but do it only N_PROGBAR_UPDATES times; @@ -447,10 +447,11 @@ cf_read(capture_file *cf) if (stop_flag) { /* Well, the user decided to abort the read. He/She will be warned and - it might be enough for him/her to work with the already loaded packets. - This is especially true for very large capture files, where you don't - want to wait loading the whole file (which may last minutes or even - hours even on fast machines) just to see that it was the wrong file. */ + it might be enough for him/her to work with the already loaded + packets. + This is especially true for very large capture files, where you don't + want to wait loading the whole file (which may last minutes or even + hours even on fast machines) just to see that it was the wrong file. */ break; } read_packet(cf, data_offset); @@ -1063,7 +1064,7 @@ cf_merge_files(char **out_filenamep, int in_file_count, time in order to get to the next progress bar step). */ if (progbar == NULL) { progbar = delayed_create_progress_dlg("Merging", "files", - &stop_flag, &start_time, progbar_val); + FALSE, &stop_flag, &start_time, progbar_val); } /* Update the progress bar, but do it only N_PROGBAR_UPDATES times; @@ -1092,6 +1093,11 @@ cf_merge_files(char **out_filenamep, int in_file_count, progbar_nextstep += progbar_quantum; } + if (stop_flag) { + /* Well, the user decided to abort the merge. */ + break; + } + if (!wtap_dump(pdh, wtap_phdr(wth), wtap_pseudoheader(wth), wtap_buf_ptr(wth), &write_err)) { got_write_error = TRUE; @@ -1164,7 +1170,13 @@ cf_merge_files(char **out_filenamep, int in_file_count, cf_write_failure_alert_box(out_filename, write_err); } - return (!got_read_error && !got_write_error) ? CF_OK : CF_ERROR; + if (got_read_error || got_write_error || stop_flag) { + /* Callers aren't expected to treat an error or an explicit abort + differently - we put up error dialogs ourselves, so they don't + have to. */ + return CF_ERROR; + } else + return CF_READ_OK; } cf_status_t @@ -1357,8 +1369,9 @@ rescan_packets(capture_file *cf, const char *action, const char *action_item, large file, we might take considerably longer than that standard time in order to get to the next progress bar step). */ if (progbar == NULL) - progbar = delayed_create_progress_dlg(action, action_item, &stop_flag, - &start_time, progbar_val); + progbar = delayed_create_progress_dlg(action, action_item, TRUE, + &stop_flag, &start_time, + progbar_val); /* Update the progress bar, but do it only N_PROGBAR_UPDATES times; when we update it, we have to run the GTK+ main loop to get it @@ -1535,7 +1548,7 @@ typedef enum { static psp_return_t process_specified_packets(capture_file *cf, packet_range_t *range, - const char *string1, const char *string2, + const char *string1, const char *string2, gboolean terminate_is_stop, gboolean (*callback)(capture_file *, frame_data *, union wtap_pseudo_header *, const guint8 *, void *), void *callback_args) @@ -1582,6 +1595,7 @@ process_specified_packets(capture_file *cf, packet_range_t *range, time in order to get to the next progress bar step). */ if (progbar == NULL) progbar = delayed_create_progress_dlg(string1, string2, + terminate_is_stop, &progbar_stop_flag, &progbar_start_time, progbar_val); @@ -1609,8 +1623,8 @@ process_specified_packets(capture_file *cf, packet_range_t *range, if (progbar_stop_flag) { /* Well, the user decided to abort the operation. Just stop, - and arrange to return TRUE to our caller, so they know it - was stopped explicitly. */ + and arrange to return PSP_STOPPED to our caller, so they know + it was stopped explicitly. */ ret = PSP_STOPPED; break; } @@ -1685,7 +1699,7 @@ cf_retap_packets(capture_file *cf, gboolean do_columns) packet_range_init(&range); packet_range_process_init(&range); switch (process_specified_packets(cf, &range, "Refiltering statistics on", - "all packets", retap_packet, + "all packets", TRUE, retap_packet, do_columns ? &cf->cinfo : NULL)) { case PSP_FINISHED: /* Completed successfully. */ @@ -1948,7 +1962,7 @@ cf_print_packets(capture_file *cf, print_args_t *print_args) /* Iterate through the list of packets, printing the packets we were told to print. */ ret = process_specified_packets(cf, &print_args->range, "Printing", - "selected packets", print_packet, + "selected packets", TRUE, print_packet, &callback_args); if (callback_args.header_line_buf != NULL) @@ -2034,8 +2048,8 @@ cf_write_pdml_packets(capture_file *cf, print_args_t *print_args) /* Iterate through the list of packets, printing the packets we were told to print. */ ret = process_specified_packets(cf, &print_args->range, "Writing PDML", - "selected packets", write_pdml_packet, - fh); + "selected packets", TRUE, + write_pdml_packet, fh); switch (ret) { @@ -2105,8 +2119,8 @@ cf_write_psml_packets(capture_file *cf, print_args_t *print_args) /* Iterate through the list of packets, printing the packets we were told to print. */ ret = process_specified_packets(cf, &print_args->range, "Writing PSML", - "selected packets", write_psml_packet, - fh); + "selected packets", TRUE, + write_psml_packet, fh); switch (ret) { @@ -2176,8 +2190,8 @@ cf_write_csv_packets(capture_file *cf, print_args_t *print_args) /* Iterate through the list of packets, printing the packets we were told to print. */ ret = process_specified_packets(cf, &print_args->range, "Writing CSV", - "selected packets", write_csv_packet, - fh); + "selected packets", TRUE, + write_csv_packet, fh); switch (ret) { @@ -2296,7 +2310,7 @@ cf_change_time_formats(capture_file *cf) time in order to get to the next progress bar step). */ if (progbar == NULL) progbar = delayed_create_progress_dlg("Changing", "time display", - &stop_flag, &start_time, progbar_val); + TRUE, &stop_flag, &start_time, progbar_val); /* Update the progress bar, but do it only N_PROGBAR_UPDATES times; when we update it, we have to run the GTK+ main loop to get it @@ -2749,7 +2763,7 @@ find_packet(capture_file *cf, time in order to get to the next progress bar step). */ if (progbar == NULL) progbar = delayed_create_progress_dlg("Searching", cf->sfilter, - &stop_flag, &start_time, progbar_val); + FALSE, &stop_flag, &start_time, progbar_val); /* Update the progress bar, but do it only N_PROGBAR_UPDATES times; when we update it, we have to run the GTK+ main loop to get it @@ -3243,9 +3257,8 @@ cf_save(capture_file *cf, const char *fname, packet_range_t *range, guint save_f "range" since we initialized it. */ callback_args.pdh = pdh; callback_args.fname = fname; - switch (process_specified_packets(cf, range, "Saving", - "selected packets", save_packet, - &callback_args)) { + switch (process_specified_packets(cf, range, "Saving", "selected packets", + TRUE, save_packet, &callback_args)) { case PSP_FINISHED: /* Completed successfully. */ diff --git a/gtk/packet_list.c b/gtk/packet_list.c index 10e3cd4ec2..8b1e2bc789 100644 --- a/gtk/packet_list.c +++ b/gtk/packet_list.c @@ -642,7 +642,7 @@ packet_list_resize_columns(void) { time in order to get to the next progress bar step). */ if (progbar == NULL) progbar = delayed_create_progress_dlg("Resizing", "Resize Columns", - &progbar_stop_flag, &progbar_start_time, progbar_val); + TRUE, &progbar_stop_flag, &progbar_start_time, progbar_val); if (i >= progbar_nextstep) { /* let's not divide by zero. I should never be started diff --git a/gtk/progress_dlg.c b/gtk/progress_dlg.c index 1adb0a9743..135cd01767 100644 --- a/gtk/progress_dlg.c +++ b/gtk/progress_dlg.c @@ -63,7 +63,10 @@ struct progdlg { * * The first argument is the task to do, e.g. "Loading". * The second argument is the item to do, e.g. "capture.cap". - * The third argument is the string to put in the "stop this operation" button. + * The third argument is TRUE if the "terminate this operation" button should + * be a "Stop" button (meaning that the operation is stopped, but not undone), + * and FALSE if it should be a "Cancel" button (meaning that it's stopped + * and anything it's done would be undone) * The fourth argument is a pointer to a Boolean variable that will be * set to TRUE if the user hits that button. * @@ -79,16 +82,16 @@ struct progdlg { */ progdlg_t * create_progress_dlg(const gchar *task_title, const gchar *item_title, - gboolean *stop_flag) + gboolean terminate_is_stop, gboolean *stop_flag) { - progdlg_t *dlg; - GtkWidget *dlg_w, *main_vb, *title_lb, *status_lb, *elapsed_lb, *time_left_lb, *percentage_lb; - GtkWidget *prog_bar, *bbox, *cancel_bt; - GtkWidget *static_vb, *tmp_lb, *main_hb, *dynamic_vb, *percentage_hb; - gchar *task_title_dup; + progdlg_t *dlg; + GtkWidget *dlg_w, *main_vb, *title_lb, *status_lb, *elapsed_lb, *time_left_lb, *percentage_lb; + GtkWidget *prog_bar, *bbox, *cancel_bt; + GtkWidget *static_vb, *tmp_lb, *main_hb, *dynamic_vb, *percentage_hb; + gchar *task_title_dup; gchar *item_title_dup; - dlg = g_malloc(sizeof (progdlg_t)); + dlg = g_malloc(sizeof (progdlg_t)); /* limit the item_title to some reasonable length */ item_title_dup = g_strdup(item_title); @@ -98,138 +101,140 @@ create_progress_dlg(const gchar *task_title, const gchar *item_title, dlg->title = g_strdup_printf("%s: %s", task_title, item_title_dup); - dlg_w = dlg_window_new(dlg->title); - gtk_window_set_modal(GTK_WINDOW(dlg_w), TRUE); + dlg_w = dlg_window_new(dlg->title); + gtk_window_set_modal(GTK_WINDOW(dlg_w), TRUE); - /* - * Container for dialog widgets. - */ - main_vb = gtk_vbox_new(FALSE, 1); - gtk_container_border_width(GTK_CONTAINER(main_vb), 5); - gtk_container_add(GTK_CONTAINER(dlg_w), main_vb); + /* + * Container for dialog widgets. + */ + main_vb = gtk_vbox_new(FALSE, 1); + gtk_container_border_width(GTK_CONTAINER(main_vb), 5); + gtk_container_add(GTK_CONTAINER(dlg_w), main_vb); - /* - * Static labels (left dialog side, labels aligned to the right) - */ - static_vb = gtk_vbox_new(FALSE, 1); - task_title_dup = g_strdup_printf ("%s:", task_title); - tmp_lb = gtk_label_new(task_title_dup); - gtk_misc_set_alignment(GTK_MISC(tmp_lb), 1.0, 0.0); - gtk_box_pack_start(GTK_BOX(static_vb), tmp_lb, FALSE, TRUE, 3); - tmp_lb = gtk_label_new("Status:"); - gtk_misc_set_alignment(GTK_MISC(tmp_lb), 1.0, 0.0); - gtk_box_pack_start(GTK_BOX(static_vb), tmp_lb, FALSE, TRUE, 3); - tmp_lb = gtk_label_new("Elapsed Time:"); - gtk_misc_set_alignment(GTK_MISC(tmp_lb), 1.0, 0.0); - gtk_box_pack_start(GTK_BOX(static_vb), tmp_lb, FALSE, TRUE, 3); - tmp_lb = gtk_label_new("Time Left:"); - gtk_misc_set_alignment(GTK_MISC(tmp_lb), 1.0, 0.0); - gtk_box_pack_start(GTK_BOX(static_vb), tmp_lb, FALSE, TRUE, 3); - tmp_lb = gtk_label_new("Progress:"); - gtk_misc_set_alignment(GTK_MISC(tmp_lb), 1.0, 0.0); - gtk_box_pack_start(GTK_BOX(static_vb), tmp_lb, FALSE, TRUE, 3); + /* + * Static labels (left dialog side, labels aligned to the right) + */ + static_vb = gtk_vbox_new(FALSE, 1); + task_title_dup = g_strdup_printf ("%s:", task_title); + tmp_lb = gtk_label_new(task_title_dup); + gtk_misc_set_alignment(GTK_MISC(tmp_lb), 1.0, 0.0); + gtk_box_pack_start(GTK_BOX(static_vb), tmp_lb, FALSE, TRUE, 3); + tmp_lb = gtk_label_new("Status:"); + gtk_misc_set_alignment(GTK_MISC(tmp_lb), 1.0, 0.0); + gtk_box_pack_start(GTK_BOX(static_vb), tmp_lb, FALSE, TRUE, 3); + tmp_lb = gtk_label_new("Elapsed Time:"); + gtk_misc_set_alignment(GTK_MISC(tmp_lb), 1.0, 0.0); + gtk_box_pack_start(GTK_BOX(static_vb), tmp_lb, FALSE, TRUE, 3); + tmp_lb = gtk_label_new("Time Left:"); + gtk_misc_set_alignment(GTK_MISC(tmp_lb), 1.0, 0.0); + gtk_box_pack_start(GTK_BOX(static_vb), tmp_lb, FALSE, TRUE, 3); + tmp_lb = gtk_label_new("Progress:"); + gtk_misc_set_alignment(GTK_MISC(tmp_lb), 1.0, 0.0); + gtk_box_pack_start(GTK_BOX(static_vb), tmp_lb, FALSE, TRUE, 3); - /* - * Dynamic labels (right dialog side, labels aligned to the left) - */ - dynamic_vb = gtk_vbox_new(FALSE, 1); + /* + * Dynamic labels (right dialog side, labels aligned to the left) + */ + dynamic_vb = gtk_vbox_new(FALSE, 1); - /* - * Put the item_title here as a label indicating what we're - * doing; set its alignment and padding so it's aligned on the - * left. - */ - title_lb = gtk_label_new(item_title_dup); - gtk_box_pack_start(GTK_BOX(dynamic_vb), title_lb, FALSE, TRUE, 3); - gtk_misc_set_alignment(GTK_MISC(title_lb), 0.0, 0.0); - gtk_misc_set_padding(GTK_MISC(title_lb), 0, 0); + /* + * Put the item_title here as a label indicating what we're + * doing; set its alignment and padding so it's aligned on the + * left. + */ + title_lb = gtk_label_new(item_title_dup); + gtk_box_pack_start(GTK_BOX(dynamic_vb), title_lb, FALSE, TRUE, 3); + gtk_misc_set_alignment(GTK_MISC(title_lb), 0.0, 0.0); + gtk_misc_set_padding(GTK_MISC(title_lb), 0, 0); - /* same for "Status" */ - status_lb = gtk_label_new(""); - gtk_box_pack_start(GTK_BOX(dynamic_vb), status_lb, FALSE, TRUE, 3); - gtk_misc_set_alignment(GTK_MISC(status_lb), 0.0, 0.0); - gtk_misc_set_padding(GTK_MISC(status_lb), 0, 0); - dlg->status_lb = (GtkLabel *) status_lb; + /* same for "Status" */ + status_lb = gtk_label_new(""); + gtk_box_pack_start(GTK_BOX(dynamic_vb), status_lb, FALSE, TRUE, 3); + gtk_misc_set_alignment(GTK_MISC(status_lb), 0.0, 0.0); + gtk_misc_set_padding(GTK_MISC(status_lb), 0, 0); + dlg->status_lb = (GtkLabel *) status_lb; - /* same for "Elapsed Time" */ - elapsed_lb = gtk_label_new("00:00"); - gtk_box_pack_start(GTK_BOX(dynamic_vb), elapsed_lb, FALSE, TRUE, 3); - gtk_misc_set_alignment(GTK_MISC(elapsed_lb), 0.0, 0.0); - gtk_misc_set_padding(GTK_MISC(elapsed_lb), 0, 0); - dlg->elapsed_lb = (GtkLabel *) elapsed_lb; + /* same for "Elapsed Time" */ + elapsed_lb = gtk_label_new("00:00"); + gtk_box_pack_start(GTK_BOX(dynamic_vb), elapsed_lb, FALSE, TRUE, 3); + gtk_misc_set_alignment(GTK_MISC(elapsed_lb), 0.0, 0.0); + gtk_misc_set_padding(GTK_MISC(elapsed_lb), 0, 0); + dlg->elapsed_lb = (GtkLabel *) elapsed_lb; - /* same for "Time Left" */ - time_left_lb = gtk_label_new("--:--"); - gtk_box_pack_start(GTK_BOX(dynamic_vb), time_left_lb, FALSE, TRUE, 3); - gtk_misc_set_alignment(GTK_MISC(time_left_lb), 0.0, 0.0); - gtk_misc_set_padding(GTK_MISC(time_left_lb), 0, 0); - dlg->time_left_lb = (GtkLabel *) time_left_lb; + /* same for "Time Left" */ + time_left_lb = gtk_label_new("--:--"); + gtk_box_pack_start(GTK_BOX(dynamic_vb), time_left_lb, FALSE, TRUE, 3); + gtk_misc_set_alignment(GTK_MISC(time_left_lb), 0.0, 0.0); + gtk_misc_set_padding(GTK_MISC(time_left_lb), 0, 0); + dlg->time_left_lb = (GtkLabel *) time_left_lb; - /* - * The progress bar (in its own horizontal box, including - * percentage value) - */ - percentage_hb = gtk_hbox_new(FALSE, 1); - gtk_box_pack_start(GTK_BOX(dynamic_vb), percentage_hb, FALSE, TRUE, 3); + /* + * The progress bar (in its own horizontal box, including + * percentage value) + */ + percentage_hb = gtk_hbox_new(FALSE, 1); + gtk_box_pack_start(GTK_BOX(dynamic_vb), percentage_hb, FALSE, TRUE, 3); - prog_bar = gtk_progress_bar_new(); + prog_bar = gtk_progress_bar_new(); #if GTK_MAJOR_VERSION < 2 - gtk_progress_set_activity_mode(GTK_PROGRESS(prog_bar), FALSE); + gtk_progress_set_activity_mode(GTK_PROGRESS(prog_bar), FALSE); #endif - gtk_box_pack_start(GTK_BOX(percentage_hb), prog_bar, FALSE, TRUE, 3); + gtk_box_pack_start(GTK_BOX(percentage_hb), prog_bar, FALSE, TRUE, 3); - percentage_lb = gtk_label_new(" 0%"); - gtk_misc_set_alignment(GTK_MISC(percentage_lb), 0.0, 0.0); - gtk_box_pack_start(GTK_BOX(percentage_hb), percentage_lb, FALSE, TRUE, - 3); - dlg->percentage_lb = (GtkLabel *) percentage_lb; + percentage_lb = gtk_label_new(" 0%"); + gtk_misc_set_alignment(GTK_MISC(percentage_lb), 0.0, 0.0); + gtk_box_pack_start(GTK_BOX(percentage_hb), percentage_lb, FALSE, TRUE, 3); + dlg->percentage_lb = (GtkLabel *) percentage_lb; - /* - * Attach a pointer to the progress bar widget to the top-level widget. - */ - OBJECT_SET_DATA(dlg_w, PROG_BAR_KEY, prog_bar); + /* + * Attach a pointer to the progress bar widget to the top-level widget. + */ + OBJECT_SET_DATA(dlg_w, PROG_BAR_KEY, prog_bar); - /* - * Static and dynamic boxes are now complete - */ - main_hb = gtk_hbox_new(FALSE, 1); - gtk_box_pack_start(GTK_BOX(main_hb), static_vb, FALSE, TRUE, 3); - gtk_box_pack_start(GTK_BOX(main_hb), dynamic_vb, FALSE, TRUE, 3); - gtk_box_pack_start(GTK_BOX(main_vb), main_hb, FALSE, TRUE, 3); + /* + * Static and dynamic boxes are now complete + */ + main_hb = gtk_hbox_new(FALSE, 1); + gtk_box_pack_start(GTK_BOX(main_hb), static_vb, FALSE, TRUE, 3); + gtk_box_pack_start(GTK_BOX(main_hb), dynamic_vb, FALSE, TRUE, 3); + gtk_box_pack_start(GTK_BOX(main_vb), main_hb, FALSE, TRUE, 3); - /* Button row */ - bbox = dlg_button_row_new(GTK_STOCK_CANCEL, NULL); + /* Button row */ + bbox = dlg_button_row_new(terminate_is_stop ? GTK_STOCK_STOP : + GTK_STOCK_CANCEL, NULL); gtk_container_add(GTK_CONTAINER(main_vb), bbox); gtk_widget_show(bbox); - cancel_bt = OBJECT_GET_DATA(bbox, GTK_STOCK_CANCEL); + cancel_bt = OBJECT_GET_DATA(bbox, terminate_is_stop ? GTK_STOCK_STOP : + GTK_STOCK_CANCEL); gtk_widget_grab_default(cancel_bt); - /* - * Allow user to either click the "Cancel" button, or - * the close button on the window, to stop an operation in - * progress. - */ - SIGNAL_CONNECT(cancel_bt, "clicked", stop_cb, stop_flag); - SIGNAL_CONNECT(dlg_w, "delete_event", delete_event_cb, stop_flag); + /* + * Allow user to either click the "Cancel"/"Stop" button, or + * the close button on the window, to stop an operation in + * progress. + */ + SIGNAL_CONNECT(cancel_bt, "clicked", stop_cb, stop_flag); + SIGNAL_CONNECT(dlg_w, "delete_event", delete_event_cb, stop_flag); - gtk_widget_show_all(dlg_w); + gtk_widget_show_all(dlg_w); - dlg->dlg_w = dlg_w; + dlg->dlg_w = dlg_w; - g_get_current_time(&dlg->start_time); - memset(&dlg->last_time, 0, sizeof(dlg->last_time)); + g_get_current_time(&dlg->start_time); + memset(&dlg->last_time, 0, sizeof(dlg->last_time)); g_free(task_title_dup); g_free(item_title_dup); - return dlg; + return dlg; } progdlg_t * delayed_create_progress_dlg(const gchar *task_title, const gchar *item_title, - gboolean *stop_flag, const GTimeVal *start_time, gfloat progress) + gboolean terminate_is_stop, gboolean *stop_flag, + const GTimeVal *start_time, gfloat progress) { GTimeVal time_now; gdouble delta_time; @@ -285,7 +290,8 @@ delayed_create_progress_dlg(const gchar *task_title, const gchar *item_title, if (progress >= (delta_time / (delta_time + min_display))) return NULL; - dlg = create_progress_dlg(task_title, item_title, stop_flag); + dlg = create_progress_dlg(task_title, item_title, terminate_is_stop, + stop_flag); /* set dialog start_time to the start of processing, not box creation */ dlg->start_time = *start_time; @@ -399,9 +405,9 @@ update_progress_dlg(progdlg_t *dlg, gfloat percentage, const gchar *status) void destroy_progress_dlg(progdlg_t *dlg) { - GtkWidget *dlg_w = dlg->dlg_w; + GtkWidget *dlg_w = dlg->dlg_w; - window_destroy(GTK_WIDGET(dlg_w)); + window_destroy(GTK_WIDGET(dlg_w)); g_free(dlg->title); - g_free(dlg); + g_free(dlg); } diff --git a/gtk/proto_draw.c b/gtk/proto_draw.c index 0d0c8a47f9..5ef7d99fc5 100644 --- a/gtk/proto_draw.c +++ b/gtk/proto_draw.c @@ -1081,6 +1081,7 @@ packet_hex_print_common(GtkTextView *bv, const guint8 *pd, int len, int bstart, time in order to get to the next progress bar step). */ if (progbar == NULL) progbar = delayed_create_progress_dlg("Processing", "Packet Details", + TRUE, &progbar_stop_flag, &progbar_start_time, progbar_val); diff --git a/gtk/rtp_analysis.c b/gtk/rtp_analysis.c index 4489869b0f..966f50ef1b 100644 --- a/gtk/rtp_analysis.c +++ b/gtk/rtp_analysis.c @@ -2513,7 +2513,8 @@ static gboolean copy_file(gchar *dest, gint channels, gint format, user_data_t * return FALSE; } - progbar = create_progress_dlg("Saving voice in a file", dest, &stop_flag); + progbar = create_progress_dlg("Saving voice in a file", dest, TRUE, + &stop_flag); if (format == SAVE_AU_FORMAT) /* au format */ { diff --git a/progress_dlg.h b/progress_dlg.h index 158b491356..c4f1932c53 100644 --- a/progress_dlg.h +++ b/progress_dlg.h @@ -44,12 +44,15 @@ typedef struct progdlg progdlg_t; * * @param task_title the task to do, e.g. "Loading" * @param item_title the item to do, e.g. "capture.cap" + * @param terminate_is_stop TRUE if the operation can't be cancelled, just + * stopped (i.e., it has a "Stop" button and clicking it doesn't undo + * anything already done), FALSE if it can * @param stop_flag a pointer to a Boolean variable that will be * set to TRUE if the user hits that button * @return the newly created progress dialog */ progdlg_t *create_progress_dlg(const gchar *task_title, const gchar *item_title, - gboolean *stop_flag); + gboolean terminate_is_stop, gboolean *stop_flag); /** * Create a progress dialog, but only if it's not likely to disappear @@ -57,6 +60,9 @@ progdlg_t *create_progress_dlg(const gchar *task_title, const gchar *item_title, * * @param task_title the task to do, e.g. "Loading" * @param item_title the item to do, e.g. "capture.cap" + * @param terminate_is_stop TRUE if the operation can't be cancelled, just + * stopped (i.e., it has a "Stop" button and clicking it doesn't undo + * anything already done), FALSE if it can * @param stop_flag a pointer to a Boolean variable that will be * set to TRUE if the user hits that button * @param start_time a pointer to a GTimeVal structure which holds @@ -66,7 +72,8 @@ progdlg_t *create_progress_dlg(const gchar *task_title, const gchar *item_title, */ progdlg_t * delayed_create_progress_dlg(const gchar *task_title, const gchar *item_title, - gboolean *stop_flag, const GTimeVal *start_time, gfloat progress); + gboolean terminate_is_stop, gboolean *stop_flag, + const GTimeVal *start_time, gfloat progress); /** * Update the progress information of the progress dialog box. diff --git a/proto_hier_stats.c b/proto_hier_stats.c index 0e0d602988..beacf589b2 100644 --- a/proto_hier_stats.c +++ b/proto_hier_stats.c @@ -219,7 +219,7 @@ ph_stats_new(void) if (progbar == NULL) progbar = delayed_create_progress_dlg( "Computing", "protocol hierarchy statistics", - &stop_flag, &start_time, progbar_val); + TRUE, &stop_flag, &start_time, progbar_val); /* Update the progress bar, but do it only N_PROGBAR_UPDATES times; when we update it, we have to run the GTK+ main