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

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