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

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