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

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