gnucash maint: Multiple changes pushed

Robert Fewell bobit at code.gnucash.org
Fri Dec 27 11:15:05 EST 2019


Updated	 via  https://github.com/Gnucash/gnucash/commit/9291ad23 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/28718689 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/ff10aa24 (commit)
	from  https://github.com/Gnucash/gnucash/commit/b7b81699 (commit)



commit 9291ad23d66bccab3fe7963502d0e23fd4112bb1
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Fri Dec 27 16:08:42 2019 +0000

    Take account of some columns in the register having 'Tot' added.
    
    In the journal register and when using auto split some register columns
    have 'Tot added to them like 'Tot Debit' depending on where the cursor
    is so if you tried to size that column with a double click on the
    header it would be based on the short name. This changes fixes that.

diff --git a/gnucash/register/register-gnome/gnucash-sheet.c b/gnucash/register/register-gnome/gnucash-sheet.c
index 6098d9485..049411737 100644
--- a/gnucash/register/register-gnome/gnucash-sheet.c
+++ b/gnucash/register/register-gnome/gnucash-sheet.c
@@ -2294,7 +2294,11 @@ gnucash_sheet_col_max_width (GnucashSheet *sheet, gint virt_col, gint cell_col)
                 VirtualLocation virt_loc;
                 const char *text;
 
-                virt_loc.vcell_loc = vcell_loc;
+                if (virt_row == 0)
+                    virt_loc.vcell_loc = sheet->table->current_cursor_loc.vcell_loc;
+                else
+                    virt_loc.vcell_loc = vcell_loc;
+
                 virt_loc.phys_row_offset = cell_row;
                 virt_loc.phys_col_offset = cell_col;
 

commit 28718689dc147fa6f0a31d2a22f266beaef3c36f
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Fri Dec 27 16:07:46 2019 +0000

    Take account for the pop up button border in the register.
    
    If the pop up button border is specified in CSS, the default size of
    the button needs to change so retrieve the border and add it to the
    default button size. Also only add the button margin when cells have
    the button.

diff --git a/gnucash/register/register-gnome/gnucash-item-edit.c b/gnucash/register/register-gnome/gnucash-item-edit.c
index 170c8583d..d9b79e54d 100644
--- a/gnucash/register/register-gnome/gnucash-item-edit.c
+++ b/gnucash/register/register-gnome/gnucash-item-edit.c
@@ -56,7 +56,7 @@ enum
     TARGET_COMPOUND_TEXT
 };
 
-#define MIN_BUTT_WIDTH 22 // minimum size for a button
+#define MIN_BUTT_WIDTH 20 // minimum size for a button excluding border
 
 static GtkBoxClass *gnc_item_edit_parent_class;
 
@@ -113,11 +113,17 @@ gnc_item_edit_tb_get_preferred_width (GtkWidget *widget,
 {
     GncItemEditTb *tb = GNC_ITEM_EDIT_TB (widget);
     GncItemEdit *item_edit = GNC_ITEM_EDIT(tb->sheet->item_editor);
+    GtkStyleContext *context = gtk_widget_get_style_context (GTK_WIDGET(tb));
+    GtkBorder border;
     gint x, y, w, h = 2, width = 0;
     gnc_item_edit_get_pixel_coords (GNC_ITEM_EDIT (item_edit), &x, &y, &w, &h);
     width = ((h - 2)*2)/3;
-    if (width < MIN_BUTT_WIDTH)
-        width = MIN_BUTT_WIDTH;
+
+    gtk_style_context_get_border (context, GTK_STATE_FLAG_NORMAL, &border);
+
+    if (width < MIN_BUTT_WIDTH + border.left + border.right)
+        width = MIN_BUTT_WIDTH + border.left + border.right;
+
     *minimal_width = *natural_width = width;
     item_edit->button_width = width;
 }
@@ -806,9 +812,19 @@ gint
 gnc_item_edit_get_button_width (GncItemEdit *item_edit)
 {
     if (item_edit)
-        return item_edit->button_width;
-    else
-        return MIN_BUTT_WIDTH;
+    {
+        if (gtk_widget_is_visible (GTK_WIDGET(item_edit->popup_toggle.tbutton)))
+            return item_edit->button_width;
+        else
+        {
+            GtkStyleContext *context = gtk_widget_get_style_context (GTK_WIDGET(item_edit->popup_toggle.tbutton));
+            GtkBorder border;
+
+            gtk_style_context_get_border (context, GTK_STATE_FLAG_NORMAL, &border);
+            return MIN_BUTT_WIDTH + border.left + border.right;
+        }
+    }
+    return MIN_BUTT_WIDTH + 2; // add the default border
 }
 
 static gboolean
diff --git a/gnucash/register/register-gnome/gnucash-sheet.c b/gnucash/register/register-gnome/gnucash-sheet.c
index e4ab6f398..6098d9485 100644
--- a/gnucash/register/register-gnome/gnucash-sheet.c
+++ b/gnucash/register/register-gnome/gnucash-sheet.c
@@ -2288,6 +2288,7 @@ gnucash_sheet_col_max_width (GnucashSheet *sheet, gint virt_col, gint cell_col)
             continue;
 
         if (cell_col < style->ncols)
+        {
             for (cell_row = 0; cell_row < style->nrows; cell_row++)
             {
                 VirtualLocation virt_loc;
@@ -2320,15 +2321,16 @@ gnucash_sheet_col_max_width (GnucashSheet *sheet, gint virt_col, gint cell_col)
                 if ((g_strcmp0 (type_name, DATE_CELL_TYPE_NAME) == 0)
                     || (g_strcmp0 (type_name, COMBO_CELL_TYPE_NAME) == 0))
                 {
-                    width += gnc_item_edit_get_button_width (item_edit);
+                    width += gnc_item_edit_get_button_width (item_edit) + 2; // add 2 for the button margin
                 }
                 max = MAX (max, width);
             }
+        }
     }
 
     g_object_unref (layout);
 
-    return max + 1; // add 1 for the border
+    return max;
 }
 
 void
diff --git a/gnucash/register/register-gnome/gnucash-style.c b/gnucash/register/register-gnome/gnucash-style.c
index 181a24767..09dd59e49 100644
--- a/gnucash/register/register-gnome/gnucash-style.c
+++ b/gnucash/register/register-gnome/gnucash-style.c
@@ -207,7 +207,13 @@ set_dimensions_pass_one (GnucashSheet *sheet, CellBlock *cursor,
                 pango_layout_get_pixel_size (layout, &width, &cd->pixel_height);
                 g_object_unref (layout);
                 width += gnc_item_edit_get_margin (item_edit, left_right) +
-                         gnc_item_edit_get_padding_border (item_edit, left_right) + 2;
+                         gnc_item_edit_get_padding_border (item_edit, left_right);
+
+                // This is used on new popup cells to get the default
+                // width of text plus toggle button.
+                if (cell && cell->is_popup)
+                    width += gnc_item_edit_get_button_width (item_edit) + 2;  // + 2 for the button margin
+
                 cd->pixel_height += gnc_item_edit_get_margin (item_edit, top_bottom) +
                                     gnc_item_edit_get_padding_border (item_edit, top_bottom);
             }
@@ -223,11 +229,6 @@ set_dimensions_pass_one (GnucashSheet *sheet, CellBlock *cursor,
             if (cd->pixel_width > 0)
                 continue;
 
-            // This is used on new account popup cells to get the default
-            // width of text plus toggle button.
-            if (cell && cell->is_popup)
-                width += gnc_item_edit_get_button_width (item_edit);
-
             cd->pixel_width = MAX (cd->pixel_width, width);
         }
 

commit ff10aa24f1300147e70e8084fcff37328c68d1e9
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Fri Dec 27 16:06:43 2019 +0000

    Change the date sample so it has the maximum text width possible

diff --git a/gnucash/register/ledger-core/split-register-layout.c b/gnucash/register/ledger-core/split-register-layout.c
index bce4d73f0..d960cc7f8 100644
--- a/gnucash/register/ledger-core/split-register-layout.c
+++ b/gnucash/register/ledger-core/split-register-layout.c
@@ -637,7 +637,7 @@ gnc_split_register_layout_add_cells (SplitRegister *reg,
                            /* Translators: The 'sample:' items are
                               strings which are not displayed, but only
                               used to estimate widths. */
-                           C_("sample", "12/12/2000"),
+                           C_("sample", "22/02/2000"),
                            CELL_ALIGN_RIGHT,
                            FALSE,
                            FALSE);
@@ -645,7 +645,7 @@ gnc_split_register_layout_add_cells (SplitRegister *reg,
     gnc_register_add_cell (layout,
                            DDUE_CELL,
                            DATE_CELL_TYPE_NAME,
-                           C_("sample", "12/12/2000"),
+                           C_("sample", "22/02/2000"),
                            CELL_ALIGN_RIGHT,
                            FALSE,
                            FALSE);



Summary of changes:
 .../register/ledger-core/split-register-layout.c   |  4 ++--
 .../register/register-gnome/gnucash-item-edit.c    | 28 +++++++++++++++++-----
 gnucash/register/register-gnome/gnucash-sheet.c    | 12 +++++++---
 gnucash/register/register-gnome/gnucash-style.c    | 13 +++++-----
 4 files changed, 40 insertions(+), 17 deletions(-)



More information about the gnucash-changes mailing list