On 04/17/2013 04:44 PM, Denys Vlasenko wrote:
No change in logic
Signed-off-by: Denys Vlasenko dvlasenk@redhat.com
src/gui-wizard-gtk/wizard.c | 48 ++++++++++++++++----------------------------- 1 file changed, 17 insertions(+), 31 deletions(-)
diff --git a/src/gui-wizard-gtk/wizard.c b/src/gui-wizard-gtk/wizard.c index 00f1f20..b4fff7e 100644 --- a/src/gui-wizard-gtk/wizard.c +++ b/src/gui-wizard-gtk/wizard.c @@ -1348,9 +1348,6 @@ struct analyze_event_data struct run_event_state *run_state; const char *event_name; GList *env_list;
- GtkWidget *page_widget;
- GtkLabel *status_label;
- GtkTextView *tv_log; const char *success_msg; const char *error_msg; GIOChannel *channel;
@@ -1530,9 +1527,9 @@ static void terminate_event_chain() hide_next_step_button(); }
-static void cancel_processing(GtkLabel *status_label, const char *message) +static void cancel_processing(const char *message)
- please don't remove the status_label parameter, so it's more clear which label it's going to set, using the global variables where it's not needed opens door for problems...
{
- gtk_label_set_text(status_label, message ? message : _("Processing was canceled"));
- gtk_label_set_text(g_lbl_event_log, message ? message : _("Processing was canceled")); terminate_event_chain(); }
@@ -1545,7 +1542,7 @@ static void update_command_run_log(const char* message, struct analyze_event_dat
/* Don't append new line behind single dot */ const char *log_msg = it_is_a_dot ? message : xasprintf("%s\n", message);
- append_to_textview(evd->tv_log, log_msg);
append_to_textview(g_tv_event_log, log_msg); save_to_event_log(evd, log_msg);
/* Because of single dot, see lines above */
@@ -1759,7 +1756,7 @@ static gboolean consume_cmd_output(GIOChannel *source, GIOCondition condition, g evd->event_log_state = LOGSTATE_ERRLINE; msg = xasprintf("(exited with %u)\n", retval); }
append_to_textview(evd->tv_log, msg);
append_to_textview(g_tv_event_log, msg); save_to_event_log(evd, msg); free(msg); }
@@ -1804,7 +1801,7 @@ static gboolean consume_cmd_output(GIOChannel *source, GIOCondition condition, g || spawn_next_command_in_evd(evd) < 0 ) { VERB1 log("done running event on '%s': %d", g_dump_dir_name, retval);
append_to_textview(evd->tv_log, "\n");
append_to_textview(g_tv_event_log, "\n"); /* Free child output buffer */ strbuf_free(cmd_output);
@@ -1829,23 +1826,23 @@ static gboolean consume_cmd_output(GIOChannel *source, GIOCondition condition, g { /* 256 means NOT_REPORTABLE */ if (retval == 256)
cancel_processing(evd->status_label, evd->success_msg);
cancel_processing(evd->success_msg); else { /* We use SIGTERM to stop event processing on user's request. * So SIGTERM is not a failure. */ if (retval == EXIT_CANCEL_BY_USER || WTERMSIG(run_state->process_status) == SIGTERM)
cancel_processing(evd->status_label, /* default message */ NULL);
cancel_processing(/* default message */ NULL); else {
cancel_processing(evd->status_label, evd->error_msg);
cancel_processing(evd->error_msg); on_failed_event(evd->event_name); } } } else
gtk_label_set_text(evd->status_label, evd->success_msg);
gtk_label_set_text(g_lbl_event_log, evd->success_msg); /*g_source_remove(evd->event_source_id);*/ close(evd->fd);
@@ -1880,10 +1877,6 @@ static gboolean consume_cmd_output(GIOChannel *source, GIOCondition condition, g }
static void start_event_run(const char *event_name,
GtkWidget *page,
GtkTextView *tv_log,
GtkLabel *status_label,
) {const char *start_msg, const char *error_msg, const char *success_msg
@@ -1907,11 +1900,11 @@ static void start_event_run(const char *event_name, //TODO: better msg? char *msg = xasprintf(_("No processing for event '%s' is defined"), event_name); if (g_expert_mode)
gtk_label_set_text(status_label, msg);
gtk_label_set_text(g_lbl_event_log, msg); else {
gtk_label_set_text(status_label, error_msg);
append_to_textview(tv_log, msg);
gtk_label_set_text(g_lbl_event_log, error_msg);
append_to_textview(g_tv_event_log, msg); terminate_event_chain(); } free(msg);
@@ -1926,7 +1919,7 @@ static void start_event_run(const char *event_name, if (!g_expert_mode) { char *msg = xasprintf(_("Processing interrupted: can't continue without writable directory."));
cancel_processing(status_label, msg);
cancel_processing(msg); free(msg); } return; /* user refused to steal, or write error, etc... */
@@ -1949,9 +1942,6 @@ static void start_event_run(const char *event_name, evd->run_state = state; evd->event_name = event_name; evd->env_list = env_list;
- evd->page_widget = page;
- evd->status_label = status_label;
- evd->tv_log = tv_log; evd->error_msg = error_msg; evd->success_msg = success_msg; evd->event_log = strbuf_new();
@@ -1969,10 +1959,10 @@ static void start_event_run(const char *event_name, evd );
- gtk_label_set_text(status_label, start_msg);
- gtk_label_set_text(g_lbl_event_log, _("Processing...")); VERB1 log("running event '%s' on '%s'", event_name, g_dump_dir_name); char *msg = xasprintf("--- Running %s ---\n", event_name);
- append_to_textview(evd->tv_log, msg);
append_to_textview(g_tv_event_log, msg); free(msg);
/* don't bother testing if they are visible, this is faster */
@@ -2291,10 +2281,6 @@ static gint select_next_page_no(gint current_page_no, gpointer data); static void setup_and_start_event_run(const char *event_name) { start_event_run(event_name,
pages[PAGENO_EVENT_PROGRESS].page_widget,
g_tv_event_log,
g_lbl_event_log,
_("Processing..."), g_expert_mode ? _("Processing failed. You can try another operation if available.") : _("Processing failed."), /* this event is the last event from the chain */
@@ -2620,7 +2606,7 @@ static gint select_next_page_no(gint current_page_no, gpointer data) { free(event);
cancel_processing(g_lbl_event_log, /* default message */ NULL);
cancel_processing(/* default message */ NULL); current_page_no = pages[PAGENO_EVENT_PROGRESS].page_no - 1; goto again; }
@@ -2633,7 +2619,7 @@ static gint select_next_page_no(gint current_page_no, gpointer data) "(it is likely a known problem). %s"), problem_data_get_content_or_NULL(g_cd, FILENAME_NOT_REPORTABLE) );
cancel_processing(g_lbl_event_log, msg);
cancel_processing(msg); free(msg); current_page_no = pages[PAGENO_EVENT_PROGRESS].page_no - 1; goto again;