gnucash master: Change dialog-options to use a two column GtkGrid

Robert Fewell bobit at code.gnucash.org
Tue Dec 3 14:59:25 EST 2019


Updated	 via  https://github.com/Gnucash/gnucash/commit/65948137 (commit)
	from  https://github.com/Gnucash/gnucash/commit/ce32117f (commit)



commit 65948137b2f1d446926ed8cdd475844fe89fce69
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Sat Nov 30 17:49:51 2019 +0000

    Change dialog-options to use a two column GtkGrid
    
    Change the dialog options to use a two column grid and setup to be the
    same as other dialogs. In the first column there is the 'name' of the
    option and the right column the 'option widget'. Also add the radio
    button option to the examples report for testing.

diff --git a/gnucash/gnome-utils/dialog-options.c b/gnucash/gnome-utils/dialog-options.c
index 9227e9056..03a990ce2 100644
--- a/gnucash/gnome-utils/dialog-options.c
+++ b/gnucash/gnome-utils/dialog-options.c
@@ -1160,7 +1160,7 @@ gnc_option_create_radiobutton_widget(char *name, GNCOption *option)
     frame = gtk_frame_new (name);
 
     /* Create the button box */
-    box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
+    box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
     gtk_box_set_homogeneous (GTK_BOX (box), FALSE);
     gtk_container_add (GTK_CONTAINER (frame), box);
 
@@ -1528,6 +1528,9 @@ gnc_option_create_account_widget(GNCOption *option, char *name)
     g_signal_connect(G_OBJECT(button), "clicked",
                      G_CALLBACK(gnc_option_default_cb), option);
 
+    gtk_widget_set_margin_start (GTK_WIDGET(bbox), 6);
+    gtk_widget_set_margin_end (GTK_WIDGET(bbox), 6);
+
     if (multiple_selection)
     {
         /* Put the "Show hidden" checkbox on a separate line since the 4 buttons make
@@ -1640,7 +1643,7 @@ gnc_option_create_list_widget(GNCOption *option, char *name)
 
     bbox = gtk_button_box_new (GTK_ORIENTATION_VERTICAL);
     gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_SPREAD);
-    gtk_box_pack_start(GTK_BOX(hbox), bbox, FALSE, FALSE, 10);
+    gtk_box_pack_end(GTK_BOX(hbox), bbox, FALSE, FALSE, 0);
 
     button = gtk_button_new_with_label(_("Select All"));
     gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
@@ -1663,6 +1666,8 @@ gnc_option_create_list_widget(GNCOption *option, char *name)
     g_signal_connect(G_OBJECT(button), "clicked",
                      G_CALLBACK(gnc_option_default_cb), option);
 
+    g_object_set (G_OBJECT(hbox), "margin", 3, NULL);
+
     gnc_option_set_widget (option, GTK_WIDGET(view));
 
     return frame;
@@ -1681,8 +1686,7 @@ gnc_option_font_changed_cb(GtkFontButton *font_button, GNCOption *option)
 }
 
 static void
-gnc_option_set_ui_widget(GNCOption *option,
-                         GtkBox *page_box)
+gnc_option_set_ui_widget(GNCOption *option, GtkGrid *page_box, gint grid_row)
 {
     GtkWidget *enclosing = NULL;
     GtkWidget *value = NULL;
@@ -1691,6 +1695,7 @@ gnc_option_set_ui_widget(GNCOption *option,
     char *name, *documentation;
     char *type;
     GNCOptionDef_t *option_def;
+    GtkLabel *name_label;
 
     ENTER("option %p(%s), box %p",
           option, gnc_option_name(option), page_box);
@@ -1718,11 +1723,13 @@ gnc_option_set_ui_widget(GNCOption *option,
     else
         documentation = NULL;
 
+    name_label = GTK_LABEL(gtk_label_new (name));
+
     option_def = gnc_options_ui_get_option (type);
     if (option_def && option_def->set_widget)
     {
         value = option_def->set_widget (option, page_box,
-                                        name, documentation,
+                                        name_label, documentation,
                                         /* Return values */
                                         &enclosing, &packed);
     }
@@ -1731,6 +1738,13 @@ gnc_option_set_ui_widget(GNCOption *option,
         PERR("Unknown option type. Ignoring option \"%s\".\n", name);
     }
 
+    /* attach the name label to the first column of the grid and
+       align to the end */
+    gtk_grid_attach (GTK_GRID(page_box), GTK_WIDGET(name_label),
+                     0, grid_row, // left, top
+                     1, 1);  // width, height
+    gtk_widget_set_halign (GTK_WIDGET(name_label), GTK_ALIGN_END);
+
     if (!packed && (enclosing != NULL))
     {
         /* Pack option widget into an extra eventbox because otherwise the
@@ -1739,11 +1753,10 @@ gnc_option_set_ui_widget(GNCOption *option,
 
         gtk_container_add (GTK_CONTAINER (eventbox), enclosing);
 
-        /* Allow the text widget to expand and fill remaining space */
-        if (g_strcmp0 (type, "text") == 0)
-            gtk_box_pack_start (page_box, eventbox, TRUE, TRUE, 0);
-        else
-            gtk_box_pack_start (page_box, eventbox, FALSE, FALSE, 0);
+        /* attach the option widget to the second column of the grid */
+        gtk_grid_attach (GTK_GRID(page_box), eventbox,
+                         1, grid_row, // left, top
+                         1, 1);  // width, height
 
         gtk_widget_set_tooltip_text (eventbox, documentation);
     }
@@ -1761,9 +1774,10 @@ gnc_option_set_ui_widget(GNCOption *option,
 
 static void
 gnc_options_dialog_add_option(GtkWidget *page,
-                              GNCOption *option)
+                              GNCOption *option, gint row)
 {
-    gnc_option_set_ui_widget(option, GTK_BOX(page));
+    g_object_set_data (G_OBJECT(page), "options-grid-row", GINT_TO_POINTER(row));
+    gnc_option_set_ui_widget(option, GTK_GRID(page), row);
 }
 
 static gint
@@ -1801,6 +1815,7 @@ gnc_options_dialog_append_page(GNCOptionWin * propertybox,
 
     /* Build this options page */
     page_content_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
+    gtk_widget_set_name (page_content_box, "page-content-box");
     gtk_box_set_homogeneous (GTK_BOX (page_content_box), FALSE);
 
     gtk_container_set_border_width(GTK_CONTAINER(page_content_box), 12);
@@ -1809,8 +1824,12 @@ gnc_options_dialog_append_page(GNCOptionWin * propertybox,
     gtk_box_pack_start(GTK_BOX(page_content_box), options_scrolled_win, TRUE, TRUE, 0);
 
     /* Build space for the content - the options box */
-    options_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
-    gtk_box_set_homogeneous (GTK_BOX (options_box), FALSE);
+    options_box = gtk_grid_new(); // this will have two columns
+    gtk_widget_set_name (options_box, "options-box");
+    gtk_grid_set_row_homogeneous (GTK_GRID(options_box), FALSE);
+    gtk_grid_set_column_homogeneous (GTK_GRID(options_box), FALSE);
+    gtk_grid_set_row_spacing (GTK_GRID(options_box), 6);
+    gtk_grid_set_column_spacing (GTK_GRID(options_box), 6);
 
     gtk_container_set_border_width(GTK_CONTAINER(options_box), 0);
     gtk_container_add (GTK_CONTAINER(options_scrolled_win), GTK_WIDGET(options_box));
@@ -1821,7 +1840,7 @@ gnc_options_dialog_append_page(GNCOptionWin * propertybox,
     for (i = 0; i < num_options; i++)
     {
         option = gnc_get_option_section_option(section, i);
-        gnc_options_dialog_add_option(options_box, option);
+        gnc_options_dialog_add_option(options_box, option, i);
     }
 
     /* Add a button box at the bottom of the page */
@@ -2403,9 +2422,19 @@ gnc_options_dialog_destroy(GNCOptionWin * win)
  * The widget you return from this function should be the widget in
  * which you're storing the option value.
  */
+ 
+static void
+gnc_option_set_ui_label_alignment (GtkLabel *name_label)
+{
+    /* some option widgets have a large vertical foot print so align
+       the label name to the top and add a small top margin */
+    gtk_widget_set_valign (GTK_WIDGET(name_label), GTK_ALIGN_START);
+    gtk_widget_set_margin_top (GTK_WIDGET(name_label), 6); 
+}
+
 static GtkWidget *
-gnc_option_set_ui_widget_boolean (GNCOption *option, GtkBox *page_box,
-                                  char *name, char *documentation,
+gnc_option_set_ui_widget_boolean (GNCOption *option, GtkGrid *page_box,
+                                  GtkLabel *name_label, char *documentation,
                                   /* Return values */
                                   GtkWidget **enclosing, gboolean *packed)
 {
@@ -2413,7 +2442,7 @@ gnc_option_set_ui_widget_boolean (GNCOption *option, GtkBox *page_box,
 
     *enclosing = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
     gtk_box_set_homogeneous (GTK_BOX (*enclosing), FALSE);
-    value = gtk_check_button_new_with_label(name);
+    value = gtk_check_button_new ();
 
     gnc_option_set_widget (option, value);
     gnc_option_set_ui_value(option, FALSE);
@@ -2428,36 +2457,35 @@ gnc_option_set_ui_widget_boolean (GNCOption *option, GtkBox *page_box,
 }
 
 static GtkWidget *
-gnc_option_set_ui_widget_string (GNCOption *option, GtkBox *page_box,
-                                 char *name, char *documentation,
+gnc_option_set_ui_widget_string (GNCOption *option, GtkGrid *page_box,
+                                 GtkLabel *name_label, char *documentation,
                                  /* Return values */
                                  GtkWidget **enclosing, gboolean *packed)
 {
     GtkWidget *value;
-    GtkWidget *label;
-
-    label = gtk_label_new(name);
-    gnc_label_set_alignment(label, 1.0, 0.5);
 
     *enclosing = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
+    gtk_widget_set_hexpand (GTK_WIDGET(*enclosing), TRUE);
     gtk_box_set_homogeneous (GTK_BOX (*enclosing), FALSE);
     value = gtk_entry_new();
 
     gnc_option_set_widget (option, value);
     gnc_option_set_ui_value(option, FALSE);
 
+    if (gtk_widget_get_direction (GTK_WIDGET(value)) == GTK_TEXT_DIR_RTL)
+        gtk_entry_set_alignment (GTK_ENTRY(value), 1.0);
+
     g_signal_connect(G_OBJECT(value), "changed",
                      G_CALLBACK(gnc_option_changed_widget_cb), option);
 
-    gtk_box_pack_start(GTK_BOX(*enclosing), label, FALSE, FALSE, 0);
     gtk_box_pack_start(GTK_BOX(*enclosing), value, TRUE, TRUE, 0);
     gtk_widget_show_all(*enclosing);
     return value;
 }
 
 static GtkWidget *
-gnc_option_set_ui_widget_text (GNCOption *option, GtkBox *page_box,
-                               char *name, char *documentation,
+gnc_option_set_ui_widget_text (GNCOption *option, GtkGrid *page_box,
+                               GtkLabel *name_label, char *documentation,
                                /* Return values */
                                GtkWidget **enclosing, gboolean *packed)
 {
@@ -2466,7 +2494,9 @@ gnc_option_set_ui_widget_text (GNCOption *option, GtkBox *page_box,
     GtkWidget *scroll;
     GtkTextBuffer* text_buffer;
 
-    frame = gtk_frame_new(name);
+    frame = gtk_frame_new(NULL);
+
+    gnc_option_set_ui_label_alignment (name_label);
 
     scroll = gtk_scrolled_window_new(NULL, NULL);
     gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll),
@@ -2477,6 +2507,8 @@ gnc_option_set_ui_widget_text (GNCOption *option, GtkBox *page_box,
     gtk_container_add(GTK_CONTAINER(frame), scroll);
 
     *enclosing = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
+    gtk_widget_set_vexpand (GTK_WIDGET(*enclosing), TRUE);
+    gtk_widget_set_hexpand (GTK_WIDGET(*enclosing), TRUE);
     gtk_box_set_homogeneous (GTK_BOX (*enclosing), FALSE);
     value = gtk_text_view_new();
     gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(value), GTK_WRAP_WORD);
@@ -2497,16 +2529,12 @@ gnc_option_set_ui_widget_text (GNCOption *option, GtkBox *page_box,
 }
 
 static GtkWidget *
-gnc_option_set_ui_widget_currency (GNCOption *option, GtkBox *page_box,
-                                   char *name, char *documentation,
+gnc_option_set_ui_widget_currency (GNCOption *option, GtkGrid *page_box,
+                                   GtkLabel *name_label, char *documentation,
                                    /* Return values */
                                    GtkWidget **enclosing, gboolean *packed)
 {
     GtkWidget *value;
-    GtkWidget *label;
-
-    label = gtk_label_new(name);
-    gnc_label_set_alignment(label, 1.0, 0.5);
 
     *enclosing = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
     gtk_box_set_homogeneous (GTK_BOX (*enclosing), FALSE);
@@ -2518,23 +2546,18 @@ gnc_option_set_ui_widget_currency (GNCOption *option, GtkBox *page_box,
     g_signal_connect(G_OBJECT(value), "changed",
                      G_CALLBACK(gnc_option_changed_widget_cb), option);
 
-    gtk_box_pack_start(GTK_BOX(*enclosing), label, FALSE, FALSE, 0);
     gtk_box_pack_start(GTK_BOX(*enclosing), value, FALSE, FALSE, 0);
     gtk_widget_show_all(*enclosing);
     return value;
 }
 
 static GtkWidget *
-gnc_option_set_ui_widget_commodity (GNCOption *option, GtkBox *page_box,
-                                    char *name, char *documentation,
+gnc_option_set_ui_widget_commodity (GNCOption *option, GtkGrid *page_box,
+                                    GtkLabel *name_label, char *documentation,
                                     /* Return values */
                                     GtkWidget **enclosing, gboolean *packed)
 {
     GtkWidget *value;
-    GtkWidget *label;
-
-    label = gtk_label_new(name);
-    gnc_label_set_alignment(label, 1.0, 0.5);
 
     *enclosing = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
     gtk_box_set_homogeneous (GTK_BOX (*enclosing), FALSE);
@@ -2553,23 +2576,18 @@ gnc_option_set_ui_widget_commodity (GNCOption *option, GtkBox *page_box,
     g_signal_connect(G_OBJECT(GNC_GENERAL_SELECT(value)->entry), "changed",
                      G_CALLBACK(gnc_option_changed_widget_cb), option);
 
-    gtk_box_pack_start(GTK_BOX(*enclosing), label, FALSE, FALSE, 0);
     gtk_box_pack_start(GTK_BOX(*enclosing), value, FALSE, FALSE, 0);
     gtk_widget_show_all(*enclosing);
     return value;
 }
 
 static GtkWidget *
-gnc_option_set_ui_widget_multichoice (GNCOption *option, GtkBox *page_box,
-                                      char *name, char *documentation,
+gnc_option_set_ui_widget_multichoice (GNCOption *option, GtkGrid *page_box,
+                                      GtkLabel *name_label, char *documentation,
                                       /* Return values */
                                       GtkWidget **enclosing, gboolean *packed)
 {
     GtkWidget *value;
-    GtkWidget *label;
-
-    label = gtk_label_new(name);
-    gnc_label_set_alignment(label, 1.0, 0.5);
 
     *enclosing = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
     gtk_box_set_homogeneous (GTK_BOX (*enclosing), FALSE);
@@ -2578,41 +2596,54 @@ gnc_option_set_ui_widget_multichoice (GNCOption *option, GtkBox *page_box,
     gnc_option_set_widget (option, value);
 
     gnc_option_set_ui_value(option, FALSE);
-    gtk_box_pack_start(GTK_BOX(*enclosing), label, FALSE, FALSE, 0);
     gtk_box_pack_start(GTK_BOX(*enclosing), value, FALSE, FALSE, 0);
     gtk_widget_show_all(*enclosing);
     return value;
 }
 
 static GtkWidget *
-gnc_option_set_ui_widget_date (GNCOption *option, GtkBox *page_box,
-                               char *name, char *documentation,
+gnc_option_set_ui_widget_date (GNCOption *option, GtkGrid *page_box,
+                               GtkLabel *name_label, char *documentation,
                                /* Return values */
                                GtkWidget **enclosing, gboolean *packed)
 {
     GtkWidget *value;
-    GtkWidget *label;
     gchar *colon_name;
     GtkWidget *eventbox;
+    gchar *type = gnc_option_date_option_get_subtype (option);
 
-    label = gtk_label_new(name);
-    gnc_label_set_alignment(label, 1.0, 0.5);
 
-    *enclosing = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
-    gtk_box_set_homogeneous (GTK_BOX (*enclosing), FALSE);
+    gint  grid_row = GPOINTER_TO_INT(g_object_get_data
+                                    (G_OBJECT(page_box), "options-grid-row"));
 
     value = gnc_option_create_date_widget(option);
 
     gnc_option_set_widget (option, value);
 
-    gtk_box_pack_start(GTK_BOX(*enclosing), label, FALSE, FALSE, 0);
-    gtk_box_pack_start(GTK_BOX(*enclosing), value, FALSE, FALSE, 0);
+    if (g_strcmp0(type, "relative") == 0)
+    {
+        *enclosing = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
+        gtk_box_set_homogeneous (GTK_BOX (*enclosing), FALSE);
+
+        gtk_box_pack_start(GTK_BOX(*enclosing), value, FALSE, FALSE, 0);
+    }
+    else
+    {
+        *enclosing = gtk_frame_new (NULL);
+        g_object_set (G_OBJECT(value), "margin", 3, NULL);
+
+        gtk_container_add (GTK_CONTAINER(*enclosing), value);
+    }
+    g_free (type);
+
+    gtk_widget_set_halign (GTK_WIDGET(*enclosing), GTK_ALIGN_START);
 
     /* Pack option widget into an extra eventbox because otherwise the
        "documentation" tooltip is not displayed. */
     eventbox = gtk_event_box_new();
     gtk_container_add (GTK_CONTAINER (eventbox), *enclosing);
-    gtk_box_pack_start(page_box, eventbox, FALSE, FALSE, 5);
+
+    gtk_grid_attach (GTK_GRID(page_box), eventbox, 1, grid_row, 1, 1);
     *packed = TRUE;
 
     gtk_widget_set_tooltip_text (eventbox, documentation);
@@ -2623,20 +2654,26 @@ gnc_option_set_ui_widget_date (GNCOption *option, GtkBox *page_box,
 }
 
 static GtkWidget *
-gnc_option_set_ui_widget_account_list (GNCOption *option, GtkBox *page_box,
-                                       char *name, char *documentation,
+gnc_option_set_ui_widget_account_list (GNCOption *option, GtkGrid *page_box,
+                                       GtkLabel *name_label, char *documentation,
                                        /* Return values */
                                        GtkWidget **enclosing, gboolean *packed)
 {
     GtkWidget *value;
     GtkTreeSelection *selection;
+    gint  grid_row = GPOINTER_TO_INT(g_object_get_data
+                                    (G_OBJECT(page_box), "options-grid-row"));
+
+    gnc_option_set_ui_label_alignment (name_label);
 
-    *enclosing = gnc_option_create_account_widget(option, name);
+    *enclosing = gnc_option_create_account_widget(option, NULL);
+    gtk_widget_set_vexpand (GTK_WIDGET(*enclosing), TRUE);
+    gtk_widget_set_hexpand (GTK_WIDGET(*enclosing), TRUE);
     value = gnc_option_get_gtk_widget (option);
 
     gtk_widget_set_tooltip_text(*enclosing, documentation);
 
-    gtk_box_pack_start(page_box, *enclosing, TRUE, TRUE, 5);
+    gtk_grid_attach (GTK_GRID(page_box), *enclosing, 1, grid_row, 1, 1);
     *packed = TRUE;
 
     //gtk_widget_realize(value);
@@ -2654,20 +2691,14 @@ gnc_option_set_ui_widget_account_list (GNCOption *option, GtkBox *page_box,
 }
 
 static GtkWidget *
-gnc_option_set_ui_widget_account_sel (GNCOption *option, GtkBox *page_box,
-                                      char *name, char *documentation,
+gnc_option_set_ui_widget_account_sel (GNCOption *option, GtkGrid *page_box,
+                                      GtkLabel *name_label, char *documentation,
                                       /* Return values */
                                       GtkWidget **enclosing, gboolean *packed)
 {
-    GtkWidget *value;
-    GtkWidget *label;
-    GList *acct_type_list;
-
-    label = gtk_label_new(name);
-    gnc_label_set_alignment(label, 1.0, 0.5);
-
-    acct_type_list = gnc_option_get_account_type_list(option);
-    value = gnc_account_sel_new();
+    GtkWidget *value = gnc_account_sel_new ();
+    GList *acct_type_list = gnc_option_get_account_type_list (option);
+    
     gnc_account_sel_set_acct_filters(GNC_ACCOUNT_SEL(value), acct_type_list, NULL);
 
     g_signal_connect(value, "account_sel_changed",
@@ -2679,29 +2710,33 @@ gnc_option_set_ui_widget_account_sel (GNCOption *option, GtkBox *page_box,
 
     *enclosing = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
     gtk_box_set_homogeneous (GTK_BOX (*enclosing), FALSE);
-    gtk_box_pack_start(GTK_BOX(*enclosing), label, FALSE, FALSE, 0);
     gtk_box_pack_start(GTK_BOX(*enclosing), value, FALSE, FALSE, 0);
     gtk_widget_show_all(*enclosing);
     return value;
 }
 
 static GtkWidget *
-gnc_option_set_ui_widget_list (GNCOption *option, GtkBox *page_box,
-                               char *name, char *documentation,
+gnc_option_set_ui_widget_list (GNCOption *option, GtkGrid *page_box,
+                               GtkLabel *name_label, char *documentation,
                                /* Return values */
                                GtkWidget **enclosing, gboolean *packed)
 {
     GtkWidget *value;
     GtkWidget *eventbox;
+    gint       grid_row = GPOINTER_TO_INT(g_object_get_data
+                                         (G_OBJECT(page_box), "options-grid-row"));
 
-    *enclosing = gnc_option_create_list_widget(option, name);
+    *enclosing = gnc_option_create_list_widget(option, NULL);
     value = gnc_option_get_gtk_widget (option);
 
+    gnc_option_set_ui_label_alignment (name_label);
+
     /* Pack option widget into an extra eventbox because otherwise the
        "documentation" tooltip is not displayed. */
     eventbox = gtk_event_box_new();
     gtk_container_add (GTK_CONTAINER (eventbox), *enclosing);
-    gtk_box_pack_start(page_box, eventbox, FALSE, FALSE, 5);
+
+    gtk_grid_attach (GTK_GRID(page_box), eventbox, 1, grid_row, 1, 1);
     *packed = TRUE;
 
     gtk_widget_set_tooltip_text(eventbox, documentation);
@@ -2712,22 +2747,18 @@ gnc_option_set_ui_widget_list (GNCOption *option, GtkBox *page_box,
 }
 
 static GtkWidget *
-gnc_option_set_ui_widget_number_range (GNCOption *option, GtkBox *page_box,
-                                       char *name, char *documentation,
+gnc_option_set_ui_widget_number_range (GNCOption *option, GtkGrid *page_box,
+                                       GtkLabel *name_label, char *documentation,
                                        /* Return values */
                                        GtkWidget **enclosing, gboolean *packed)
 {
     GtkWidget *value;
-    GtkWidget *label;
     GtkAdjustment *adj;
     gdouble lower_bound = G_MINDOUBLE;
     gdouble upper_bound = G_MAXDOUBLE;
     gdouble step_size = 1.0;
     int num_decimals = 0;
 
-    label = gtk_label_new(name);
-    gnc_label_set_alignment(label, 1.0, 0.5);
-
     *enclosing = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
     gtk_box_set_homogeneous (GTK_BOX (*enclosing), FALSE);
 
@@ -2768,32 +2799,26 @@ gnc_option_set_ui_widget_number_range (GNCOption *option, GtkBox *page_box,
     g_signal_connect(G_OBJECT(value), "changed",
                      G_CALLBACK(gnc_option_changed_widget_cb), option);
 
-    gtk_box_pack_start(GTK_BOX(*enclosing), label, FALSE, FALSE, 0);
     gtk_box_pack_start(GTK_BOX(*enclosing), value, FALSE, FALSE, 0);
     gtk_widget_show_all(*enclosing);
     return value;
 }
 
 static GtkWidget *
-gnc_option_set_ui_widget_color (GNCOption *option, GtkBox *page_box,
-                                char *name, char *documentation,
+gnc_option_set_ui_widget_color (GNCOption *option, GtkGrid *page_box,
+                                GtkLabel *name_label, char *documentation,
                                 /* Return values */
                                 GtkWidget **enclosing, gboolean *packed)
 {
     GtkWidget *value;
-    GtkWidget *label;
     gboolean use_alpha;
 
-    label = gtk_label_new(name);
-    gnc_label_set_alignment(label, 1.0, 0.5);
-
     *enclosing = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
     gtk_box_set_homogeneous (GTK_BOX (*enclosing), FALSE);
 
     use_alpha = gnc_option_use_alpha(option);
 
     value = gtk_color_button_new();
-    gtk_color_button_set_title(GTK_COLOR_BUTTON(value), name);
     gtk_color_chooser_set_use_alpha(GTK_COLOR_CHOOSER(value), use_alpha);
 
     gnc_option_set_widget (option, value);
@@ -2802,23 +2827,18 @@ gnc_option_set_ui_widget_color (GNCOption *option, GtkBox *page_box,
     g_signal_connect(G_OBJECT(value), "color-set",
                      G_CALLBACK(gnc_option_color_changed_cb), option);
 
-    gtk_box_pack_start(GTK_BOX(*enclosing), label, FALSE, FALSE, 0);
     gtk_box_pack_start(GTK_BOX(*enclosing), value, FALSE, FALSE, 0);
     gtk_widget_show_all(*enclosing);
     return value;
 }
 
 static GtkWidget *
-gnc_option_set_ui_widget_font (GNCOption *option, GtkBox *page_box,
-                               char *name, char *documentation,
+gnc_option_set_ui_widget_font (GNCOption *option, GtkGrid *page_box,
+                               GtkLabel *name_label, char *documentation,
                                /* Return values */
                                GtkWidget **enclosing, gboolean *packed)
 {
     GtkWidget *value;
-    GtkWidget *label;
-
-    label = gtk_label_new(name);
-    gnc_label_set_alignment(label, 1.0, 0.5);
 
     *enclosing = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
     gtk_box_set_homogeneous (GTK_BOX (*enclosing), FALSE);
@@ -2836,26 +2856,20 @@ gnc_option_set_ui_widget_font (GNCOption *option, GtkBox *page_box,
     g_signal_connect(G_OBJECT(value), "font-set",
                      G_CALLBACK(gnc_option_font_changed_cb), option);
 
-    gtk_box_pack_start(GTK_BOX(*enclosing), label, FALSE, FALSE, 0);
     gtk_box_pack_start(GTK_BOX(*enclosing), value, FALSE, FALSE, 0);
     gtk_widget_show_all(*enclosing);
     return value;
 }
 
 static GtkWidget *
-gnc_option_set_ui_widget_pixmap (GNCOption *option, GtkBox *page_box,
-                                 char *name, char *documentation,
+gnc_option_set_ui_widget_pixmap (GNCOption *option, GtkGrid *page_box,
+                                 GtkLabel *name_label, char *documentation,
                                  /* Return values */
                                  GtkWidget **enclosing, gboolean *packed)
 {
     GtkWidget *value;
-    GtkWidget *label;
     GtkWidget *button;
 
-    ENTER("option %p(%s), name %s", option, gnc_option_name(option), name);
-    label = gtk_label_new(name);
-    gnc_label_set_alignment(label, 1.0, 0.5);
-
     *enclosing = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
     gtk_box_set_homogeneous (GTK_BOX (*enclosing), FALSE);
 
@@ -2881,20 +2895,18 @@ gnc_option_set_ui_widget_pixmap (GNCOption *option, GtkBox *page_box,
     gnc_option_set_widget (option, value);
     gnc_option_set_ui_value(option, FALSE);
 
-    gtk_box_pack_start(GTK_BOX(*enclosing), label, FALSE, FALSE, 0);
-    gtk_box_pack_end(GTK_BOX(*enclosing), button, FALSE, FALSE, 0);
-    gtk_box_pack_end(GTK_BOX(*enclosing), value, FALSE, FALSE, 0);
+    gtk_box_pack_start(GTK_BOX(*enclosing), value, FALSE, FALSE, 0);
+    gtk_box_pack_start(GTK_BOX(*enclosing), button, FALSE, FALSE, 0);
 
     gtk_widget_show(value);
-    gtk_widget_show(label);
     gtk_widget_show(*enclosing);
-    LEAVE("new widget = %p", value);
+
     return value;
 }
 
 static GtkWidget *
-gnc_option_set_ui_widget_radiobutton (GNCOption *option, GtkBox *page_box,
-                                      char *name, char *documentation,
+gnc_option_set_ui_widget_radiobutton (GNCOption *option, GtkGrid *page_box,
+                                      GtkLabel *name_label, char *documentation,
                                       /* Return values */
                                       GtkWidget **enclosing, gboolean *packed)
 {
@@ -2903,7 +2915,9 @@ gnc_option_set_ui_widget_radiobutton (GNCOption *option, GtkBox *page_box,
     *enclosing = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
     gtk_box_set_homogeneous (GTK_BOX (*enclosing), FALSE);
 
-    value = gnc_option_create_radiobutton_widget(name, option);
+    gnc_option_set_ui_label_alignment (name_label);
+
+    value = gnc_option_create_radiobutton_widget(NULL, option);
     gnc_option_set_widget (option, value);
 
     gnc_option_set_ui_value(option, FALSE);
@@ -2913,14 +2927,16 @@ gnc_option_set_ui_widget_radiobutton (GNCOption *option, GtkBox *page_box,
 }
 
 static GtkWidget *
-gnc_option_set_ui_widget_dateformat (GNCOption *option, GtkBox *page_box,
-                                     char *name, char *documentation,
+gnc_option_set_ui_widget_dateformat (GNCOption *option, GtkGrid *page_box,
+                                     GtkLabel *name_label, char *documentation,
                                      /* Return values */
                                      GtkWidget **enclosing, gboolean *packed)
 {
-    *enclosing = gnc_date_format_new_with_label(name);
+    *enclosing = gnc_date_format_new_without_label ();
     gnc_option_set_widget (option, *enclosing);
 
+    gnc_option_set_ui_label_alignment (name_label);
+
     gnc_option_set_ui_value(option, FALSE);
     g_signal_connect(G_OBJECT(*enclosing), "format_changed",
                      G_CALLBACK(gnc_option_changed_option_cb), option);
@@ -2975,13 +2991,12 @@ gnc_rd_option_p_set_cb(GtkWidget *widget, gpointer *raw_option)
 
 
 static GtkWidget *
-gnc_option_set_ui_widget_plot_size (GNCOption *option, GtkBox *page_box,
-                                     char *name, char *documentation,
+gnc_option_set_ui_widget_plot_size (GNCOption *option, GtkGrid *page_box,
+                                     GtkLabel *name_label, char *documentation,
                                      /* Return values */
                                      GtkWidget **enclosing, gboolean *packed)
 {
     GtkWidget *value_px, *value_percent;
-    GtkWidget *label;
     GtkWidget *px_butt, *p_butt;
     GtkWidget *hbox;
     GtkAdjustment *adj_px, *adj_percent;
@@ -2990,17 +3005,14 @@ gnc_option_set_ui_widget_plot_size (GNCOption *option, GtkBox *page_box,
     gdouble step_size = 1.0;
     int num_decimals = 0;
 
-    label = gtk_label_new(name);
-    gnc_label_set_alignment(label, 1.0, 0.5);
+    *enclosing = gtk_frame_new(NULL);
+    gtk_widget_set_halign (GTK_WIDGET(*enclosing), GTK_ALIGN_START);
 
     hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
     gtk_box_set_homogeneous (GTK_BOX (hbox), FALSE);
+    g_object_set (G_OBJECT(hbox), "margin", 3, NULL);
 
-    *enclosing = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
-    gtk_box_set_homogeneous (GTK_BOX (*enclosing), FALSE);
-
-    gtk_box_pack_start(GTK_BOX(*enclosing), label, FALSE, FALSE, 0);
-    gtk_box_pack_start(GTK_BOX(*enclosing), hbox, FALSE, FALSE, 0);
+    gtk_container_add(GTK_CONTAINER(*enclosing), hbox);
 
     gnc_option_get_range_info(option, &lower_bound, &upper_bound,
                               &num_decimals, &step_size);
@@ -3070,16 +3082,13 @@ gnc_option_set_ui_widget_plot_size (GNCOption *option, GtkBox *page_box,
 }
 
 static GtkWidget *
-gnc_option_set_ui_widget_budget (GNCOption *option, GtkBox *page_box,
-                                 char *name, char *documentation,
+gnc_option_set_ui_widget_budget (GNCOption *option, GtkGrid *page_box,
+                                 GtkLabel *name_label, char *documentation,
                                  /* Return values */
                                  GtkWidget **enclosing, gboolean *packed)
 {
     GtkWidget *value;
-    GtkWidget *label;
 
-    label = gtk_label_new(name);
-    gnc_label_set_alignment(label, 1.0, 0.5);
 
     *enclosing = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
     gtk_box_set_homogeneous (GTK_BOX (*enclosing), FALSE);
@@ -3093,7 +3102,6 @@ gnc_option_set_ui_widget_budget (GNCOption *option, GtkBox *page_box,
     g_signal_connect(G_OBJECT(value), "changed",
                      G_CALLBACK(gnc_option_changed_widget_cb), option);
 
-    gtk_box_pack_start(GTK_BOX(*enclosing), label, FALSE, FALSE, 0);
     gtk_box_pack_start(GTK_BOX(*enclosing), value, FALSE, FALSE, 0);
     gtk_widget_show_all(*enclosing);
     return value;
@@ -3101,8 +3109,8 @@ gnc_option_set_ui_widget_budget (GNCOption *option, GtkBox *page_box,
 
 static GtkWidget *
 gnc_option_set_ui_widget_currency_accounting (GNCOption *option,
-                                              GtkBox *page_box,
-                                              char *name, char *documentation,
+                                              GtkGrid *page_box,
+                                              GtkLabel *name_label, char *documentation,
                                               /* Return values */
                                               GtkWidget **enclosing,
                                               gboolean *packed)
@@ -3112,7 +3120,7 @@ gnc_option_set_ui_widget_currency_accounting (GNCOption *option,
     *enclosing = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
     gtk_box_set_homogeneous (GTK_BOX (*enclosing), FALSE);
 
-    value = gnc_option_create_currency_accounting_widget(name, option);
+    value = gnc_option_create_currency_accounting_widget(NULL, option);
     gnc_option_set_widget (option, value);
 
     gnc_option_set_ui_value(option, FALSE);
diff --git a/gnucash/gnome-utils/dialog-options.h b/gnucash/gnome-utils/dialog-options.h
index 1ed60c15b..e59c1c89e 100644
--- a/gnucash/gnome-utils/dialog-options.h
+++ b/gnucash/gnome-utils/dialog-options.h
@@ -84,8 +84,8 @@ void gnc_options_dialog_set_scm_callbacks (GNCOptionWin *win,
 
 /* Function to set the UI widget based upon the option */
 typedef GtkWidget *
-(*GNCOptionUISetWidget) (GNCOption *option, GtkBox *page_box,
-                         char *name, char *documentation,
+(*GNCOptionUISetWidget) (GNCOption *option, GtkGrid *page_box,
+                         GtkLabel *name_label, char *documentation,
                          /* Return values */
                          GtkWidget **enclosing, gboolean *packed);
 
diff --git a/gnucash/gnome/business-options-gnome.c b/gnucash/gnome/business-options-gnome.c
index 7841f8ecb..afee518ca 100644
--- a/gnucash/gnome/business-options-gnome.c
+++ b/gnucash/gnome/business-options-gnome.c
@@ -102,20 +102,16 @@ get_owner_type_from_option (GNCOption *option)
 
 /* Function to set the UI widget based upon the option */
 static GtkWidget *
-owner_set_widget (GNCOption *option, GtkBox *page_box,
-                  char *name, char *documentation,
+owner_set_widget (GNCOption *option, GtkGrid *page_box,
+                  GtkLabel *name_label, char *documentation,
                   /* Return values */
                   GtkWidget **enclosing, gboolean *packed)
 {
     GtkWidget *value;
-    GtkWidget *label;
 
     *enclosing = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
     gtk_box_set_homogeneous (GTK_BOX (*enclosing), FALSE);
 
-    label = make_name_label (name);
-    gtk_box_pack_start (GTK_BOX (*enclosing), label, FALSE, FALSE, 0);
-
     value = create_owner_widget (option, get_owner_type_from_option (option),
                                  *enclosing);
 
@@ -173,20 +169,16 @@ owner_get_value (GNCOption *option, GtkWidget *widget)
 
 /* Function to set the UI widget based upon the option */
 static GtkWidget *
-customer_set_widget (GNCOption *option, GtkBox *page_box,
-                     char *name, char *documentation,
+customer_set_widget (GNCOption *option, GtkGrid *page_box,
+                     GtkLabel *name_label, char *documentation,
                      /* Return values */
                      GtkWidget **enclosing, gboolean *packed)
 {
     GtkWidget *value;
-    GtkWidget *label;
 
     *enclosing = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
     gtk_box_set_homogeneous (GTK_BOX (*enclosing), FALSE);
 
-    label = make_name_label (name);
-    gtk_box_pack_start (GTK_BOX (*enclosing), label, FALSE, FALSE, 0);
-
     value = create_owner_widget (option, GNC_OWNER_CUSTOMER, *enclosing);
 
     gnc_option_set_ui_value (option, FALSE);
@@ -233,20 +225,16 @@ customer_get_value (GNCOption *option, GtkWidget *widget)
 
 /* Function to set the UI widget based upon the option */
 static GtkWidget *
-vendor_set_widget (GNCOption *option, GtkBox *page_box,
-                   char *name, char *documentation,
+vendor_set_widget (GNCOption *option, GtkGrid *page_box,
+                   GtkLabel *name_label, char *documentation,
                    /* Return values */
                    GtkWidget **enclosing, gboolean *packed)
 {
     GtkWidget *value;
-    GtkWidget *label;
 
     *enclosing = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
     gtk_box_set_homogeneous (GTK_BOX (*enclosing), FALSE);
 
-    label = make_name_label (name);
-    gtk_box_pack_start (GTK_BOX (*enclosing), label, FALSE, FALSE, 0);
-
     value = create_owner_widget (option, GNC_OWNER_VENDOR, *enclosing);
 
     gnc_option_set_ui_value (option, FALSE);
@@ -292,20 +280,16 @@ vendor_get_value (GNCOption *option, GtkWidget *widget)
 
 /* Function to set the UI widget based upon the option */
 static GtkWidget *
-employee_set_widget (GNCOption *option, GtkBox *page_box,
-                     char *name, char *documentation,
+employee_set_widget (GNCOption *option, GtkGrid *page_box,
+                     GtkLabel *name_label, char *documentation,
                      /* Return values */
                      GtkWidget **enclosing, gboolean *packed)
 {
     GtkWidget *value;
-    GtkWidget *label;
 
     *enclosing = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
     gtk_box_set_homogeneous (GTK_BOX (*enclosing), FALSE);
 
-    label = make_name_label (name);
-    gtk_box_pack_start (GTK_BOX (*enclosing), label, FALSE, FALSE, 0);
-
     value = create_owner_widget (option, GNC_OWNER_EMPLOYEE, *enclosing);
 
     gnc_option_set_ui_value (option, FALSE);
@@ -368,20 +352,16 @@ create_invoice_widget (GNCOption *option, GtkWidget *hbox)
 
 /* Function to set the UI widget based upon the option */
 static GtkWidget *
-invoice_set_widget (GNCOption *option, GtkBox *page_box,
-                    char *name, char *documentation,
+invoice_set_widget (GNCOption *option, GtkGrid *page_box,
+                    GtkLabel *name_label, char *documentation,
                     /* Return values */
                     GtkWidget **enclosing, gboolean *packed)
 {
     GtkWidget *value;
-    GtkWidget *label;
 
     *enclosing = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
     gtk_box_set_homogeneous (GTK_BOX (*enclosing), FALSE);
 
-    label = make_name_label (name);
-    gtk_box_pack_start (GTK_BOX (*enclosing), label, FALSE, FALSE, 0);
-
     value = create_invoice_widget (option, *enclosing);
 
     gnc_option_set_ui_value (option, FALSE);
@@ -448,20 +428,16 @@ create_taxtable_widget (GNCOption *option, GtkWidget *hbox)
 
 /* Function to set the UI widget based upon the option */
 static GtkWidget *
-taxtable_set_widget (GNCOption *option, GtkBox *page_box,
-                     char *name, char *documentation,
+taxtable_set_widget (GNCOption *option, GtkGrid *page_box,
+                     GtkLabel *name_label, char *documentation,
                      /* Return values */
                      GtkWidget **enclosing, gboolean *packed)
 {
     GtkWidget *value;
-    GtkWidget *label;
 
     *enclosing = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
     gtk_box_set_homogeneous (GTK_BOX (*enclosing), FALSE);
 
-    label = make_name_label (name);
-    gtk_box_pack_start (GTK_BOX (*enclosing), label, FALSE, FALSE, 0);
-
     value = create_taxtable_widget (option, *enclosing);
 
     gnc_option_set_ui_value (option, FALSE);
diff --git a/gnucash/report/reports/example/hello-world.scm b/gnucash/report/reports/example/hello-world.scm
index 2643f5b12..673e24b33 100644
--- a/gnucash/report/reports/example/hello-world.scm
+++ b/gnucash/report/reports/example/hello-world.scm
@@ -206,7 +206,22 @@
 Your reports probably shouldn't have an \
 option like this.") 
       #f))
-    
+
+    ;; This is a Radio Button option. The user can only select one 
+    ;; value from the list of buttons.
+    (add-option
+     (gnc:make-radiobutton-option
+      (N_ "Hello Again") "A Radio Button option" "z" (N_ "This is a Radio Button option.") 'good
+      (list (vector 'good
+                    (N_ "The Good")
+                    (N_ "Good option."))
+            (vector 'bad
+                    (N_ "The Bad")
+                    (N_ "Bad option."))
+            (vector 'ugly
+                    (N_ "The Ugly")
+                    (N_ "Ugly option.")))))
+
     (gnc:options-set-default-section options "Hello, World!")      
     options))
 
@@ -242,6 +257,7 @@ option like this.")
         (bg-color-op  (get-op   "Hello, World!" "Background Color"))
         (accounts     (op-value "Hello Again"   "An account list option"))
         (list-val     (op-value "Hello Again"   "A list option"))
+        (radio-val    (op-value "Hello Again"   "A Radio Button option"))
         (crash-val    (op-value "Testing"       "Crash the report"))
         
         ;; document will be the HTML document that we return.
@@ -346,6 +362,11 @@ new, totally cool report, consult the mailing list ~a.")
           (_ "The boolean option is ~a.")
           (gnc:html-markup-b (if bool-val (_ "true") (_ "false")))))
 
+        (gnc:html-markup-p
+         (gnc:html-markup/format
+          (_ "The radio button option is ~a.")
+          (gnc:html-markup-b radio-val)))
+
         (gnc:html-markup-p
          (gnc:html-markup/format
           (_ "The multi-choice option is ~a.")
@@ -407,6 +428,8 @@ new, totally cool report, consult the mailing list ~a.")
           (let ((table (gnc:make-html-table)))
             (gnc:html-table-append-column! 
              table (map symbol->string list-val))
+            (gnc:html-table-set-style! table "table"
+             'attribute (list "style" "width:200px"))
             (gnc:html-table-set-caption! table 
                                          (_ "List items selected"))
             (gnc:html-document-add-object! document table))
@@ -439,11 +462,11 @@ new, totally cool report, consult the mailing list ~a.")
              (map 
               (lambda (acct)
                 (gnc:html-markup-anchor 
-		 (gnc-build-url URL-TYPE-REGISTER
-				     (string-append "account=" 
-						    (gnc-account-get-full-name
-						     acct))
-				     "")
+                 (gnc-build-url URL-TYPE-REGISTER
+                   (string-append "account=" 
+                     (gnc-account-get-full-name
+                        acct))
+                     "")
                  (xaccAccountGetName acct)))
               accounts))))
           (gnc:html-document-add-object!



Summary of changes:
 gnucash/gnome-utils/dialog-options.c           | 284 +++++++++++++------------
 gnucash/gnome-utils/dialog-options.h           |   4 +-
 gnucash/gnome/business-options-gnome.c         |  48 ++---
 gnucash/report/reports/example/hello-world.scm |  35 ++-
 4 files changed, 189 insertions(+), 182 deletions(-)



More information about the gnucash-changes mailing list