Blame SOURCES/0052-gui-add-Repeat-button.patch

562801
From b801cc0c8b951534990ed884360d13a6f27154e0 Mon Sep 17 00:00:00 2001
562801
From: Jakub Filak <jfilak@redhat.com>
562801
Date: Wed, 30 Jul 2014 13:53:02 +0200
562801
Subject: [LIBREPORT PATCH 52/93] gui: add "Repeat" button
562801
562801
If an event run fails, the button allows users to modify the
562801
configuration and re-run the event.
562801
562801
v2:
562801
- add a help text explaining what to do before clicking "Repeat" button
562801
562801
Related to rhbz#1069917
562801
562801
Signed-off-by: Jakub Filak <jfilak@redhat.com>
562801
562801
Conflicts:
562801
	src/gui-wizard-gtk/wizard.c
562801
---
562801
 src/gui-wizard-gtk/wizard.c | 80 +++++++++++++++++++++++++++++++++++----------
562801
 1 file changed, 62 insertions(+), 18 deletions(-)
562801
562801
diff --git a/src/gui-wizard-gtk/wizard.c b/src/gui-wizard-gtk/wizard.c
562801
index d7d1a78..d62ac04 100644
562801
--- a/src/gui-wizard-gtk/wizard.c
562801
+++ b/src/gui-wizard-gtk/wizard.c
562801
@@ -68,6 +68,7 @@ static GtkWidget *g_btn_stop;
562801
 static GtkWidget *g_btn_close;
562801
 static GtkWidget *g_btn_next;
562801
 static GtkWidget *g_btn_onfail;
562801
+static GtkWidget *g_btn_repeat;
562801
 
562801
 static GtkBox *g_box_events;
562801
 static GtkBox *g_box_workflows;
562801
@@ -1602,7 +1603,7 @@ static void hide_next_step_button()
562801
     /* 1. hide next button */
562801
     gtk_widget_hide(g_btn_next);
562801
     /* 2. move close button to the last position */
562801
-    gtk_box_reorder_child(g_box_buttons, g_btn_close, 3);
562801
+    gtk_box_reorder_child(g_box_buttons, g_btn_close, 4);
562801
 }
562801
 
562801
 static void show_next_step_button()
562801
@@ -1611,24 +1612,31 @@ static void show_next_step_button()
562801
     gtk_widget_show(g_btn_next);
562801
 }
562801
 
562801
-static void terminate_event_chain()
562801
+enum {
562801
+ TERMINATE_NOFLAGS    = 0,
562801
+ TERMINATE_WITH_RERUN = 1 << 0,
562801
+};
562801
+
562801
+static void terminate_event_chain(int flags)
562801
 {
562801
     if (g_expert_mode)
562801
         return;
562801
 
562801
+    hide_next_step_button();
562801
+    if ((flags & TERMINATE_WITH_RERUN))
562801
+        return;
562801
+
562801
     free(g_event_selected);
562801
     g_event_selected = NULL;
562801
 
562801
     g_list_free_full(g_auto_event_list, free);
562801
     g_auto_event_list = NULL;
562801
-
562801
-    hide_next_step_button();
562801
 }
562801
 
562801
-static void cancel_processing(GtkLabel *status_label, const char *message)
562801
+static void cancel_processing(GtkLabel *status_label, const char *message, int terminate_flags)
562801
 {
562801
     gtk_label_set_text(status_label, message ? message : _("Processing was canceled"));
562801
-    terminate_event_chain();
562801
+    terminate_event_chain(terminate_flags);
562801
 }
562801
 
562801
 static void update_command_run_log(const char* message, struct analyze_event_data *evd)
562801
@@ -1793,6 +1801,25 @@ static void on_btn_failed_cb(GtkButton *button)
562801
     gtk_widget_hide(GTK_WIDGET(button));
562801
 }
562801
 
562801
+static gint select_next_page_no(gint current_page_no, gpointer data);
562801
+static void on_page_prepare(GtkNotebook *assistant, GtkWidget *page, gpointer user_data);
562801
+
562801
+static void on_btn_repeat_cb(GtkButton *button)
562801
+{
562801
+    g_auto_event_list = g_list_prepend(g_auto_event_list, g_event_selected);
562801
+    g_event_selected = NULL;
562801
+
562801
+    show_next_step_button();
562801
+    clear_warnings();
562801
+
562801
+    const gint current_page_no = gtk_notebook_get_current_page(g_assistant);
562801
+    const int next_page_no = select_next_page_no(pages[PAGENO_SUMMARY].page_no, NULL);
562801
+    if (current_page_no == next_page_no)
562801
+        on_page_prepare(g_assistant, gtk_notebook_get_nth_page(g_assistant, next_page_no), NULL);
562801
+    else
562801
+        gtk_notebook_set_current_page(g_assistant, next_page_no);
562801
+}
562801
+
562801
 static void on_failed_event(const char *event_name)
562801
 {
562801
     /* Don't show the 'on failure' button if the processed event
562801
@@ -1802,9 +1829,20 @@ static void on_failed_event(const char *event_name)
562801
         return;
562801
 
562801
    add_warning(
562801
-_("Processing of the problem failed. This can have many reasons but there are two most common:\n"\
562801
+_("Processing of the problem failed. This can have many reasons but there are three most common:\n"\
562801
 "\tâ–« network connection problems\n"\
562801
-"\tâ–« corrupted problem data\n"));
562801
+"\tâ–« corrupted problem data\n"\
562801
+"\tâ–« invalid configuration"
562801
+));
562801
+
562801
+    if (!g_expert_mode)
562801
+    {
562801
+        add_warning(
562801
+_("If you want to update the configuration and try to report again, please open Preferences item\n"
562801
+"in the application menu and after applying the configuration changes click Repeat button."));
562801
+
562801
+        gtk_widget_show(g_btn_repeat);
562801
+    }
562801
 
562801
     show_warnings();
562801
 }
562801
@@ -1829,7 +1867,7 @@ static gboolean consume_cmd_output(GIOChannel *source, GIOCondition condition, g
562801
         retval = 0;
562801
         run_state->process_status = 0;
562801
         stop_requested = true;
562801
-        terminate_event_chain();
562801
+        terminate_event_chain(TERMINATE_NOFLAGS);
562801
     }
562801
 
562801
     unexport_event_config(evd->env_list);
562801
@@ -1918,17 +1956,17 @@ static gboolean consume_cmd_output(GIOChannel *source, GIOCondition condition, g
562801
             gtk_widget_show(GTK_WIDGET(g_img_process_fail));
562801
             /* 256 means NOT_REPORTABLE */
562801
             if (retval == 256)
562801
-                cancel_processing(g_lbl_event_log, _("Processing was interrupted because the problem is not reportable."));
562801
+                cancel_processing(g_lbl_event_log, _("Processing was interrupted because the problem is not reportable."), TERMINATE_NOFLAGS);
562801
             else
562801
             {
562801
                 /* We use SIGTERM to stop event processing on user's request.
562801
                  * So SIGTERM is not a failure.
562801
                  */
562801
                 if (retval == EXIT_CANCEL_BY_USER || WTERMSIG(run_state->process_status) == SIGTERM)
562801
-                    cancel_processing(g_lbl_event_log, /* default message */ NULL);
562801
+                    cancel_processing(g_lbl_event_log, /* default message */ NULL, TERMINATE_NOFLAGS);
562801
                 else
562801
                 {
562801
-                    cancel_processing(g_lbl_event_log, _("Processing failed."));
562801
+                    cancel_processing(g_lbl_event_log, _("Processing failed."), TERMINATE_WITH_RERUN);
562801
                     on_failed_event(evd->event_name);
562801
                 }
562801
             }
562801
@@ -1995,7 +2033,7 @@ static void start_event_run(const char *event_name)
562801
         char *msg = xasprintf(_("No processing for event '%s' is defined"), event_name);
562801
         append_to_textview(g_tv_event_log, msg);
562801
         free(msg);
562801
-        cancel_processing(g_lbl_event_log, _("Processing failed."));
562801
+        cancel_processing(g_lbl_event_log, _("Processing failed."), TERMINATE_NOFLAGS);
562801
         return;
562801
     }
562801
 
562801
@@ -2006,7 +2044,7 @@ static void start_event_run(const char *event_name)
562801
         free_run_event_state(state);
562801
         if (!g_expert_mode)
562801
         {
562801
-            cancel_processing(g_lbl_event_log, _("Processing interrupted: can't continue without writable directory."));
562801
+            cancel_processing(g_lbl_event_log, _("Processing interrupted: can't continue without writable directory."), TERMINATE_NOFLAGS);
562801
         }
562801
         return; /* user refused to steal, or write error, etc... */
562801
     }
562801
@@ -2484,8 +2522,6 @@ static gboolean highlight_forbidden(void)
562801
     return result;
562801
 }
562801
 
562801
-static gint select_next_page_no(gint current_page_no, gpointer data);
562801
-
562801
 static char *get_next_processed_event(GList **events_list)
562801
 {
562801
     if (!events_list || !*events_list)
562801
@@ -2597,6 +2633,8 @@ static void on_page_prepare(GtkNotebook *assistant, GtkWidget *page, gpointer us
562801
     }
562801
 
562801
     gtk_widget_hide(g_btn_onfail);
562801
+    if (!g_expert_mode)
562801
+        gtk_widget_hide(g_btn_repeat);
562801
     /* Save text fields if changed */
562801
     /* Must be called before any GUI operation because the following two
562801
      * functions causes recreating of the text items tabs, thus all updates to
562801
@@ -2815,7 +2853,7 @@ static gint select_next_page_no(gint current_page_no, gpointer data)
562801
             {
562801
                 free(event);
562801
 
562801
-                cancel_processing(g_lbl_event_log, /* default message */ NULL);
562801
+                cancel_processing(g_lbl_event_log, /* default message */ NULL, TERMINATE_NOFLAGS);
562801
                 current_page_no = pages[PAGENO_EVENT_PROGRESS].page_no - 1;
562801
                 goto again;
562801
             }
562801
@@ -2828,7 +2866,7 @@ static gint select_next_page_no(gint current_page_no, gpointer data)
562801
                                 "(it is likely a known problem). %s"),
562801
                                 problem_data_get_content_or_NULL(g_cd, FILENAME_NOT_REPORTABLE)
562801
                 );
562801
-                cancel_processing(g_lbl_event_log, msg);
562801
+                cancel_processing(g_lbl_event_log, msg, TERMINATE_NOFLAGS);
562801
                 free(msg);
562801
                 current_page_no = pages[PAGENO_EVENT_PROGRESS].page_no - 1;
562801
                 goto again;
562801
@@ -3408,6 +3446,9 @@ void create_assistant(GtkApplication *app, bool expert_mode)
562801
     g_btn_onfail = gtk_button_new_with_label(_("Upload for analysis"));
562801
     gtk_button_set_image(GTK_BUTTON(g_btn_onfail), gtk_image_new_from_icon_name("go-up", GTK_ICON_SIZE_BUTTON));
562801
     gtk_widget_set_no_show_all(g_btn_onfail, true); /* else gtk_widget_hide won't work */
562801
+    g_btn_repeat = gtk_button_new_with_label(_("Repeat"));
562801
+    gtk_button_set_image(GTK_BUTTON(g_btn_repeat), gtk_image_new_from_icon_name("view-refresh", GTK_ICON_SIZE_BUTTON));
562801
+    gtk_widget_set_no_show_all(g_btn_repeat, true); /* else gtk_widget_hide won't work */
562801
     g_btn_next = gtk_button_new_with_mnemonic(_("_Forward"));
562801
     gtk_button_set_image(GTK_BUTTON(g_btn_next), gtk_image_new_from_icon_name("go-next", GTK_ICON_SIZE_BUTTON));
562801
     gtk_widget_set_no_show_all(g_btn_next, true); /* else gtk_widget_hide won't work */
562801
@@ -3416,6 +3457,7 @@ void create_assistant(GtkApplication *app, bool expert_mode)
562801
     gtk_box_pack_start(g_box_buttons, g_btn_close, false, false, 5);
562801
     gtk_box_pack_start(g_box_buttons, g_btn_stop, false, false, 5);
562801
     gtk_box_pack_start(g_box_buttons, g_btn_onfail, false, false, 5);
562801
+    gtk_box_pack_start(g_box_buttons, g_btn_repeat, false, false, 5);
562801
     /* Btns above are to the left, the rest are to the right: */
562801
     GtkWidget *w = gtk_alignment_new(0.0, 0.0, 1.0, 1.0);
562801
     gtk_box_pack_start(g_box_buttons, w, true, true, 5);
562801
@@ -3456,6 +3498,7 @@ void create_assistant(GtkApplication *app, bool expert_mode)
562801
     gtk_widget_show_all(GTK_WIDGET(g_box_buttons));
562801
     gtk_widget_hide(g_btn_stop);
562801
     gtk_widget_hide(g_btn_onfail);
562801
+    gtk_widget_hide(g_btn_repeat);
562801
     gtk_widget_show(g_btn_next);
562801
 
562801
     g_wnd_assistant = GTK_WINDOW(gtk_application_window_new(app));
562801
@@ -3476,6 +3519,7 @@ void create_assistant(GtkApplication *app, bool expert_mode)
562801
     g_signal_connect(g_btn_close, "clicked", G_CALLBACK(assistant_quit_cb), g_wnd_assistant);
562801
     g_signal_connect(g_btn_stop, "clicked", G_CALLBACK(on_btn_cancel_event), NULL);
562801
     g_signal_connect(g_btn_onfail, "clicked", G_CALLBACK(on_btn_failed_cb), NULL);
562801
+    g_signal_connect(g_btn_repeat, "clicked", G_CALLBACK(on_btn_repeat_cb), NULL);
562801
     g_signal_connect(g_btn_next, "clicked", G_CALLBACK(on_next_btn_cb), NULL);
562801
 
562801
     g_signal_connect(g_wnd_assistant, "destroy", G_CALLBACK(assistant_quit_cb), g_wnd_assistant);
562801
-- 
562801
1.8.3.1
562801