Blame SOURCES/0051-gui-reload-destroyed-sensitive-data-warn-widgets-fro.patch

0c9110
From 3abbb4c7324fff37189b632f7522385a001e16a0 Mon Sep 17 00:00:00 2001
0c9110
From: Jakub Filak <jfilak@redhat.com>
0c9110
Date: Wed, 30 Jul 2014 13:48:59 +0200
0c9110
Subject: [LIBREPORT PATCH 51/93] gui: reload destroyed sensitive data warn
0c9110
 widgets from the galde
0c9110
0c9110
clear_warnings() destroys the warning widgets. The sensitive data
0c9110
widgets needs to be reloaded as GtkBuilder does not return clones of
0c9110
object but the instances from its cache.
0c9110
0c9110
Related to rhbz#1069917
0c9110
0c9110
Signed-off-by: Jakub Filak <jfilak@redhat.com>
0c9110
---
0c9110
 src/gui-wizard-gtk/wizard.c | 75 +++++++++++++++++++++++++++------------------
0c9110
 1 file changed, 46 insertions(+), 29 deletions(-)
0c9110
0c9110
diff --git a/src/gui-wizard-gtk/wizard.c b/src/gui-wizard-gtk/wizard.c
0c9110
index 492feed..d7d1a78 100644
0c9110
--- a/src/gui-wizard-gtk/wizard.c
0c9110
+++ b/src/gui-wizard-gtk/wizard.c
0c9110
@@ -229,6 +229,45 @@ static bool check_minimal_bt_rating(const char *event_name);
0c9110
 static char *get_next_processed_event(GList **events_list);
0c9110
 static void on_next_btn_cb(GtkWidget *btn, gpointer user_data);
0c9110
 
0c9110
+/* wizard.glade file as a string WIZARD_GLADE_CONTENTS: */
0c9110
+#include "wizard_glade.c"
0c9110
+
0c9110
+static GtkBuilder *make_builder()
0c9110
+{
0c9110
+    GError *error = NULL;
0c9110
+    GtkBuilder *builder = gtk_builder_new();
0c9110
+    if (!g_glade_file)
0c9110
+    {
0c9110
+        /* load additional widgets from glade */
0c9110
+        gtk_builder_add_objects_from_string(builder,
0c9110
+                WIZARD_GLADE_CONTENTS, sizeof(WIZARD_GLADE_CONTENTS) - 1,
0c9110
+                (gchar**)misc_widgets,
0c9110
+                &error);
0c9110
+        if (error != NULL)
0c9110
+            error_msg_and_die("Error loading glade data: %s", error->message);
0c9110
+        /* Load pages from internal string */
0c9110
+        gtk_builder_add_objects_from_string(builder,
0c9110
+                WIZARD_GLADE_CONTENTS, sizeof(WIZARD_GLADE_CONTENTS) - 1,
0c9110
+                (gchar**)page_names,
0c9110
+                &error);
0c9110
+        if (error != NULL)
0c9110
+            error_msg_and_die("Error loading glade data: %s", error->message);
0c9110
+    }
0c9110
+    else
0c9110
+    {
0c9110
+        /* -g FILE: load UI from it */
0c9110
+        /* load additional widgets from glade */
0c9110
+        gtk_builder_add_objects_from_file(builder, g_glade_file, (gchar**)misc_widgets, &error);
0c9110
+        if (error != NULL)
0c9110
+            error_msg_and_die("Can't load %s: %s", g_glade_file, error->message);
0c9110
+        gtk_builder_add_objects_from_file(builder, g_glade_file, (gchar**)page_names, &error);
0c9110
+        if (error != NULL)
0c9110
+            error_msg_and_die("Can't load %s: %s", g_glade_file, error->message);
0c9110
+    }
0c9110
+
0c9110
+    return builder;
0c9110
+}
0c9110
+
0c9110
 static void label_wrapper(GtkWidget *widget, gpointer data_unused)
0c9110
 {
0c9110
     if (GTK_IS_CONTAINER(widget))
0c9110
@@ -2062,11 +2101,15 @@ static void on_sensitive_ticket_clicked_cb(GtkWidget *button, gpointer user_data
0c9110
 
0c9110
 static void add_sensitive_data_warning(void)
0c9110
 {
0c9110
-    GtkWidget *sens_data_warn = GTK_WIDGET(gtk_builder_get_object(g_builder, SENSITIVE_DATA_WARN));
0c9110
-    GtkButton *sens_ticket_cb = GTK_BUTTON(gtk_builder_get_object(g_builder, PRIVATE_TICKET_CB));
0c9110
+    GtkBuilder *builder = make_builder();
0c9110
+
0c9110
+    GtkWidget *sens_data_warn = GTK_WIDGET(gtk_builder_get_object(builder, SENSITIVE_DATA_WARN));
0c9110
+    GtkButton *sens_ticket_cb = GTK_BUTTON(gtk_builder_get_object(builder, PRIVATE_TICKET_CB));
0c9110
 
0c9110
     g_signal_connect(sens_ticket_cb, "toggled", G_CALLBACK(on_sensitive_ticket_clicked_cb), NULL);
0c9110
     add_widget_to_warning_area(GTK_WIDGET(sens_data_warn));
0c9110
+
0c9110
+    g_object_unref(builder);
0c9110
 }
0c9110
 
0c9110
 static void show_warnings(void)
0c9110
@@ -3128,9 +3171,6 @@ static gint on_key_press_event_in_item_list(GtkTreeView *treeview, GdkEventKey *
0c9110
 
0c9110
 /* Initialization */
0c9110
 
0c9110
-/* wizard.glade file as a string WIZARD_GLADE_CONTENTS: */
0c9110
-#include "wizard_glade.c"
0c9110
-
0c9110
 static void on_next_btn_cb(GtkWidget *btn, gpointer user_data)
0c9110
 {
0c9110
     gint current_page_no = gtk_notebook_get_current_page(g_assistant);
0c9110
@@ -3145,30 +3185,7 @@ static void on_next_btn_cb(GtkWidget *btn, gpointer user_data)
0c9110
 
0c9110
 static void add_pages(void)
0c9110
 {
0c9110
-    GError *error = NULL;
0c9110
-    g_builder = gtk_builder_new();
0c9110
-    if (!g_glade_file)
0c9110
-    {
0c9110
-        /* load additional widgets from glade */
0c9110
-        gtk_builder_add_objects_from_string(g_builder,
0c9110
-                WIZARD_GLADE_CONTENTS, sizeof(WIZARD_GLADE_CONTENTS) - 1,
0c9110
-                (gchar**)misc_widgets,
0c9110
-                &error);
0c9110
-        /* Load pages from internal string */
0c9110
-        gtk_builder_add_objects_from_string(g_builder,
0c9110
-                WIZARD_GLADE_CONTENTS, sizeof(WIZARD_GLADE_CONTENTS) - 1,
0c9110
-                (gchar**)page_names,
0c9110
-                &error);
0c9110
-        if (error != NULL)
0c9110
-            error_msg_and_die("Error loading glade data: %s", error->message);
0c9110
-    }
0c9110
-    else
0c9110
-    {
0c9110
-        /* -g FILE: load IU from it */
0c9110
-        gtk_builder_add_objects_from_file(g_builder, g_glade_file, (gchar**)page_names, &error);
0c9110
-        if (error != NULL)
0c9110
-            error_msg_and_die("Can't load %s: %s", g_glade_file, error->message);
0c9110
-    }
0c9110
+    g_builder = make_builder();
0c9110
 
0c9110
     int i;
0c9110
     int page_no = 0;
0c9110
-- 
0c9110
1.8.3.1
0c9110