Blame SOURCES/0045-wizard-use-a-tab-for-Advanced-opts-instead-of-an-exp.patch

562801
From 6cf4c34ea589698c3c4b9a2a6b708ca66f446844 Mon Sep 17 00:00:00 2001
562801
From: Jakub Filak <jfilak@redhat.com>
562801
Date: Tue, 24 Jun 2014 16:25:30 +0200
562801
Subject: [LIBREPORT PATCH 45/93] wizard: use a tab for Advanced opts instead
562801
 of an expander
562801
562801
GtkExpander containing wrapped labels  breaks GTK3's algorithm computing
562801
the window size when expanding/folding.
562801
562801
A tab page seems to be more modern approach which does not causes any
562801
problems.
562801
562801
The tab pages are filled with GtkScrolledWindow in order to prevent
562801
enlarging the configuration window behind screen limits.
562801
562801
The worfklow window also uses tab pages but on the left side because
562801
two vertical tab page lines are strange.
562801
562801
Resolves rhbz#965963
562801
562801
Signed-off-by: Jakub Filak <jfilak@redhat.com>
562801
---
562801
 src/gtk-helpers/event_config_dialog.c    | 59 ++++++++++++++++++++------------
562801
 src/gtk-helpers/workflow_config_dialog.c | 25 +++++++++-----
562801
 2 files changed, 55 insertions(+), 29 deletions(-)
562801
562801
diff --git a/src/gtk-helpers/event_config_dialog.c b/src/gtk-helpers/event_config_dialog.c
562801
index 1ed5196..9d442d6 100644
562801
--- a/src/gtk-helpers/event_config_dialog.c
562801
+++ b/src/gtk-helpers/event_config_dialog.c
562801
@@ -189,19 +189,18 @@ static void add_option_to_table(gpointer data, gpointer user_data)
562801
     free(option_label);
562801
 }
562801
 
562801
-config_dialog_t *create_event_config_dialog_content(event_config_t *event, GtkWidget *content)
562801
+static GtkWidget *create_event_config_grid()
562801
 {
562801
-    INITIALIZE_LIBREPORT();
562801
-
562801
-    if (content == NULL)
562801
-        content = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
562801
+    GtkWidget *option_table = gtk_grid_new();
562801
 
562801
-    //event_config_t *event = get_event_config(event_name);
562801
+    gtk_widget_set_margin_left(option_table, 5);
562801
+    gtk_widget_set_margin_top(option_table, 5);
562801
+    gtk_widget_set_margin_right(option_table, 5);
562801
+    gtk_widget_set_margin_bottom(option_table, 5);
562801
 
562801
-    GtkWidget *option_table = gtk_grid_new();
562801
     gtk_grid_set_row_homogeneous(GTK_GRID(option_table), FALSE);
562801
     gtk_grid_set_column_homogeneous(GTK_GRID(option_table), FALSE);
562801
-    gtk_grid_set_row_spacing(GTK_GRID(option_table), 2);
562801
+    gtk_grid_set_row_spacing(GTK_GRID(option_table), 10);
562801
     g_object_set_data(G_OBJECT(option_table), "n-rows", (gpointer)-1);
562801
 
562801
     gtk_widget_set_hexpand(option_table, TRUE);
562801
@@ -209,21 +208,28 @@ config_dialog_t *create_event_config_dialog_content(event_config_t *event, GtkWi
562801
     gtk_widget_set_halign(option_table, GTK_ALIGN_FILL);
562801
     gtk_widget_set_valign(option_table, GTK_ALIGN_FILL);
562801
 
562801
+    return option_table;
562801
+}
562801
+
562801
+config_dialog_t *create_event_config_dialog_content(event_config_t *event, GtkWidget *content)
562801
+{
562801
+    INITIALIZE_LIBREPORT();
562801
+
562801
+    if (content == NULL)
562801
+        content = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
562801
+
562801
+    //event_config_t *event = get_event_config(event_name);
562801
+    GtkWidget *notebook_layout = gtk_notebook_new();
562801
+    gtk_box_pack_start(GTK_BOX(content), notebook_layout, TRUE, TRUE, 0);
562801
+
562801
+    GtkWidget *option_table = create_event_config_grid();
562801
+
562801
     /* table to hold advanced options
562801
      * hidden in expander which is visible only if there's at least
562801
      * one advanced option
562801
     */
562801
+    GtkWidget *adv_option_table = create_event_config_grid();
562801
 
562801
-    GtkWidget *adv_option_table = gtk_grid_new();
562801
-    gtk_grid_set_row_homogeneous(GTK_GRID(adv_option_table), FALSE);
562801
-    gtk_grid_set_column_homogeneous(GTK_GRID(adv_option_table), FALSE);
562801
-    gtk_grid_set_row_spacing(GTK_GRID(adv_option_table), 2);
562801
-    g_object_set_data(G_OBJECT(adv_option_table), "n-rows", (gpointer)-1);
562801
-
562801
-    GtkWidget *adv_expander = gtk_expander_new(_("Advanced"));
562801
-    /* resize the toplevel widget containing the expander upon resizing and collapsing. */
562801
-    gtk_expander_set_resize_toplevel(GTK_EXPANDER(adv_expander), TRUE);
562801
-    gtk_container_add(GTK_CONTAINER(adv_expander), adv_option_table);
562801
     g_object_set_data(G_OBJECT(option_table), "advanced-options", adv_option_table);
562801
 
562801
     has_password_option = false;
562801
@@ -250,11 +256,22 @@ config_dialog_t *create_event_config_dialog_content(event_config_t *event, GtkWi
562801
         g_signal_connect(pass_store_cb, "toggled", G_CALLBACK(on_show_pass_store_cb), NULL);
562801
     }
562801
 
562801
-    gtk_box_pack_start(GTK_BOX(content), option_table, false, false, 20);
562801
+    GtkWidget *option_table_lbl = gtk_label_new_with_mnemonic(_("Basic"));
562801
+    GtkWidget *option_table_scrl = gtk_scrolled_window_new(NULL, NULL);
562801
+    gtk_container_add(GTK_CONTAINER(option_table_scrl), option_table);
562801
+    gtk_notebook_append_page(GTK_NOTEBOOK(notebook_layout), option_table_scrl, option_table_lbl);
562801
 
562801
     /* add the adv_option_table to the dialog only if there is some adv option */
562801
     if (g_list_length(gtk_container_get_children(GTK_CONTAINER(adv_option_table))) > 0)
562801
-        gtk_box_pack_start(GTK_BOX(content), adv_expander, false, false, 0);
562801
+    {
562801
+        GtkWidget *adv_option_table_lbl = gtk_label_new_with_mnemonic(_("Advanced"));
562801
+        GtkWidget *adv_option_table_scrl = gtk_scrolled_window_new(NULL, NULL);
562801
+        gtk_container_add(GTK_CONTAINER(adv_option_table_scrl), adv_option_table);
562801
+        gtk_notebook_append_page(GTK_NOTEBOOK(notebook_layout), adv_option_table_scrl, adv_option_table_lbl);
562801
+    }
562801
+    else
562801
+        /* Do not show single tab 'Basic' */
562801
+        gtk_notebook_set_show_tabs(GTK_NOTEBOOK(notebook_layout), FALSE);
562801
 
562801
     /* add warning if secrets service is not available showing the nagging dialog
562801
      * is considered "too heavy UI" be designers
562801
@@ -311,7 +328,7 @@ config_dialog_t *create_event_config_dialog(const char *event_name, GtkWindow *p
562801
      * line wrapped.
562801
      */
562801
     gtk_window_set_resizable(GTK_WINDOW(dialog), true);
562801
-    gtk_window_set_default_size(GTK_WINDOW(dialog), 450, -1);
562801
+    gtk_window_set_default_size(GTK_WINDOW(dialog), 450, 310);
562801
 
562801
     if (parent_window != NULL)
562801
     {
562801
diff --git a/src/gtk-helpers/workflow_config_dialog.c b/src/gtk-helpers/workflow_config_dialog.c
562801
index 7c399e4..45d7fb6 100644
562801
--- a/src/gtk-helpers/workflow_config_dialog.c
562801
+++ b/src/gtk-helpers/workflow_config_dialog.c
562801
@@ -29,15 +29,23 @@ enum
562801
 static GtkWindow *g_parent_window;
562801
 static GHashTable *g_events_options = NULL;
562801
 
562801
-static void create_event_config_dialog_content_cb(event_config_t *ec, gpointer content)
562801
+static void create_event_config_dialog_content_cb(event_config_t *ec, gpointer notebook)
562801
 {
562801
-    if (ec->options)
562801
-    {
562801
-        GtkWidget *ev_lbl = gtk_label_new(ec_get_screen_name(ec));
562801
-        gtk_box_pack_start(GTK_BOX(content), ev_lbl, false, false, 0);
562801
-    }
562801
+    if (!ec->options)
562801
+        return;
562801
+
562801
+    GtkWidget *ev_lbl = gtk_label_new(ec_get_screen_name(ec));
562801
+
562801
+    GtkWidget *content = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
562801
+    gtk_widget_set_margin_left(content, 10);
562801
+    gtk_widget_set_margin_top(content, 5);
562801
+    gtk_widget_set_margin_right(content, 10);
562801
+    gtk_widget_set_margin_bottom(content, 10);
562801
 
562801
     config_dialog_t *cdialog = create_event_config_dialog_content(ec, (GtkWidget *)content);
562801
+
562801
+    gtk_notebook_append_page(GTK_NOTEBOOK(notebook), content, ev_lbl);
562801
+
562801
     if (g_events_options == NULL)
562801
     {
562801
         g_events_options = g_hash_table_new_full(
562801
@@ -46,8 +54,8 @@ static void create_event_config_dialog_content_cb(event_config_t *ec, gpointer c
562801
                     /*key_destroy_func:*/ g_free,
562801
                     /*value_destroy_func:*/ NULL);
562801
     }
562801
-    g_hash_table_insert(g_events_options, ec, cdialog);
562801
 
562801
+    g_hash_table_insert(g_events_options, ec, cdialog);
562801
 }
562801
 
562801
 static void save_event_config_data_foreach(event_config_t *ec,
562801
@@ -91,7 +99,8 @@ config_dialog_t *create_workflow_config_dialog(const char *workflow_name, GtkWin
562801
     }
562801
 
562801
     GtkWidget *scrolled = gtk_scrolled_window_new(NULL, NULL);
562801
-    GtkWidget *content = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
562801
+    GtkWidget *content = gtk_notebook_new();
562801
+    gtk_notebook_set_tab_pos(GTK_NOTEBOOK(content), GTK_POS_LEFT);
562801
 
562801
 #if ((GTK_MAJOR_VERSION == 3 && GTK_MINOR_VERSION < 7) || (GTK_MAJOR_VERSION == 3 && GTK_MINOR_VERSION == 7 && GTK_MICRO_VERSION < 8))
562801
     /* http://developer.gnome.org/gtk3/unstable/GtkScrolledWindow.html#gtk-scrolled-window-add-with-viewport */
562801
-- 
562801
1.8.3.1
562801