You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

131 lines
4.9 KiB

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