gnucash master: Multiple changes pushed

Robert Fewell bobit at code.gnucash.org
Thu May 14 07:14:51 EDT 2020


Updated	 via  https://github.com/Gnucash/gnucash/commit/86dc6dcb (commit)
	 via  https://github.com/Gnucash/gnucash/commit/9f59d2cb (commit)
	from  https://github.com/Gnucash/gnucash/commit/6fb50d22 (commit)



commit 86dc6dcb96c82d59c56584808dd488906eaa83ef
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Thu May 14 12:13:08 2020 +0100

    Remove some spaces and tabs from dialog-options.c

diff --git a/gnucash/gnome-utils/dialog-options.c b/gnucash/gnome-utils/dialog-options.c
index a60333049..4bb96f6d8 100644
--- a/gnucash/gnome-utils/dialog-options.c
+++ b/gnucash/gnome-utils/dialog-options.c
@@ -853,10 +853,10 @@ gnc_option_changed_gain_loss_account_widget_cb (GtkTreeSelection *selection,
         {
             const char *message = _("The account %s is a placeholder account " \
                 "and does not allow transactions. " \
-        	"Please choose a different account.");
+            "Please choose a different account.");
 
             gnc_error_dialog (gnc_ui_get_gtk_window (book_currency_data->default_gain_loss_account_widget),
-			      message, xaccAccountGetName (account));
+                  message, xaccAccountGetName (account));
             if (book_currency_data->prior_gain_loss_account)
             {
                 (gnc_tree_view_account_set_selected_account
@@ -2435,7 +2435,7 @@ 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)
 {
@@ -2727,7 +2727,7 @@ gnc_option_set_ui_widget_account_sel (GNCOption *option, GtkGrid *page_box,
 {
     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",

commit 9f59d2cbd77b1fb5016c097b46d926949523bef6
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Thu May 14 12:07:42 2020 +0100

    Enable the Options Checkbox label to be used to toggle
    
    With the new the options dialogue using a GtkGrid it is required that
    clicking on the label of the GtkCheckBox would also toggle the
    GtkCheckBox. To this end the label is added to an event box so it can
    be clicked on and a callback used to toggle the checkbox.

diff --git a/gnucash/gnome-utils/dialog-options.c b/gnucash/gnome-utils/dialog-options.c
index c52167572..a60333049 100644
--- a/gnucash/gnome-utils/dialog-options.c
+++ b/gnucash/gnome-utils/dialog-options.c
@@ -1695,6 +1695,7 @@ gnc_option_set_ui_widget(GNCOption *option, GtkGrid *page_box, gint grid_row)
     char *type;
     GNCOptionDef_t *option_def;
     GtkLabel *name_label;
+    GtkWidget *label_event_box;
 
     ENTER("option %p(%s), box %p",
           option, gnc_option_name(option), page_box);
@@ -1737,11 +1738,24 @@ gnc_option_set_ui_widget(GNCOption *option, GtkGrid *page_box, gint grid_row)
         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
+    /* attach the name label to the first column of the grid and align to the end
+     * if event_box present, pack the name label into that first so it can be
+     * clicked on */
+    label_event_box = g_object_get_data (G_OBJECT(name_label), "label_event_box");
+
+    if (label_event_box)
+    {
+        gtk_container_add (GTK_CONTAINER(label_event_box), GTK_WIDGET(name_label));
+
+        gtk_grid_attach (GTK_GRID(page_box), GTK_WIDGET(label_event_box),
+                         0, grid_row, // left, top
+                         1, 1);  // width, height
+    }
+    else
+        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))
@@ -2428,7 +2442,16 @@ 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); 
+    gtk_widget_set_margin_top (GTK_WIDGET(name_label), 6);
+}
+
+static gboolean
+label_event_toggle_cb (GtkButton *button, GdkEvent *event, gpointer user_data)
+{
+    GtkCheckButton *cb = user_data;
+    gboolean active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(cb));
+    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(cb), !active);
+    return FALSE;
 }
 
 static GtkWidget *
@@ -2438,6 +2461,7 @@ gnc_option_set_ui_widget_boolean (GNCOption *option, GtkGrid *page_box,
                                   GtkWidget **enclosing, gboolean *packed)
 {
     GtkWidget *value;
+    GtkWidget *label_event_box = gtk_event_box_new ();
 
     *enclosing = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
     gtk_box_set_homogeneous (GTK_BOX (*enclosing), FALSE);
@@ -2446,6 +2470,12 @@ gnc_option_set_ui_widget_boolean (GNCOption *option, GtkGrid *page_box,
     gnc_option_set_widget (option, value);
     gnc_option_set_ui_value(option, FALSE);
 
+    g_object_set_data (G_OBJECT(name_label), "label_event_box", label_event_box);
+
+    gtk_widget_set_events (label_event_box, GDK_BUTTON_PRESS_MASK);
+    g_signal_connect (G_OBJECT(label_event_box), "button-press-event",
+                      G_CALLBACK(label_event_toggle_cb), value);
+
     g_signal_connect(G_OBJECT(value), "toggled",
                      G_CALLBACK(gnc_option_changed_widget_cb), option);
 



Summary of changes:
 gnucash/gnome-utils/dialog-options.c | 50 ++++++++++++++++++++++++++++--------
 1 file changed, 40 insertions(+), 10 deletions(-)



More information about the gnucash-changes mailing list