gnucash maint: Multiple changes pushed

Robert Fewell bobit at code.gnucash.org
Mon Dec 16 11:04:09 EST 2019


Updated	 via  https://github.com/Gnucash/gnucash/commit/3d2e2c23 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/b7f67bb3 (commit)
	from  https://github.com/Gnucash/gnucash/commit/75dba612 (commit)



commit 3d2e2c2348fe9777164b2ef508f96dd0a418f7d1
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Mon Dec 16 14:51:08 2019 +0000

    Allow room for the border on the item_edit button

diff --git a/gnucash/register/register-gnome/gnucash-item-edit.c b/gnucash/register/register-gnome/gnucash-item-edit.c
index c603fdfbe..170c8583d 100644
--- a/gnucash/register/register-gnome/gnucash-item-edit.c
+++ b/gnucash/register/register-gnome/gnucash-item-edit.c
@@ -565,7 +565,8 @@ draw_arrow_cb (GtkWidget *widget, cairo_t *cr, gpointer data)
     gint height = gtk_widget_get_allocated_height (widget);
     gint size;
 
-    gtk_render_background (context, cr, 0, 0, width, height);
+    // allow room for a border
+    gtk_render_background (context, cr, 2, 2, width - 4, height - 4);
 
     gtk_style_context_add_class (context, GTK_STYLE_CLASS_ARROW);
 

commit b7f67bb387ebace7e2f043e1ec60d5e637cbb1d8
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Mon Dec 16 12:36:37 2019 +0000

    Bug 796736 - Register cell pop up columns width to narrow
    
    On first start up, cells with a pop up were initialised with the sample
    text plus the cell height. This worked most of the time but with small
    fonts the height could be smaller than the minimum button width so the
    cell was too small. Add a function to retrieve the button width which
    can not be less than the minimum button width and add this to be the
    sample text width.
    
    Also when you double clicked on the header of a pop up cell column to
    auto size the cell width it did not take into account the button width
    and so was too narrow, this is also fixed by getting the button width.

diff --git a/gnucash/register/register-gnome/gnucash-item-edit.c b/gnucash/register/register-gnome/gnucash-item-edit.c
index 4f27171f9..c603fdfbe 100644
--- a/gnucash/register/register-gnome/gnucash-item-edit.c
+++ b/gnucash/register/register-gnome/gnucash-item-edit.c
@@ -56,6 +56,8 @@ enum
     TARGET_COMPOUND_TEXT
 };
 
+#define MIN_BUTT_WIDTH 22 // minimum size for a button
+
 static GtkBoxClass *gnc_item_edit_parent_class;
 
 static GtkToggleButtonClass *gnc_item_edit_tb_parent_class;
@@ -114,9 +116,10 @@ gnc_item_edit_tb_get_preferred_width (GtkWidget *widget,
     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 < 22) // minimum size for a button
-        width = 22;
+    if (width < MIN_BUTT_WIDTH)
+        width = MIN_BUTT_WIDTH;
     *minimal_width = *natural_width = width;
+    item_edit->button_width = width;
 }
 
 static void
@@ -319,6 +322,7 @@ gnc_item_edit_init (GncItemEdit *item_edit)
     item_edit->popup_user_data = NULL;
 
     item_edit->style = NULL;
+    item_edit->button_width = MIN_BUTT_WIDTH;
 
     gnc_virtual_location_init(&item_edit->virt_loc);
 }
@@ -797,6 +801,15 @@ gnc_item_edit_get_padding_border (GncItemEdit *item_edit, Sides side)
     }
 }
 
+gint
+gnc_item_edit_get_button_width (GncItemEdit *item_edit)
+{
+    if (item_edit)
+        return item_edit->button_width;
+    else
+        return MIN_BUTT_WIDTH;
+}
+
 static gboolean
 button_press_cb (GtkWidget *widget, GdkEventButton *event, gpointer *pointer)
 {
diff --git a/gnucash/register/register-gnome/gnucash-item-edit.h b/gnucash/register/register-gnome/gnucash-item-edit.h
index 2be4d249e..09ffc9143 100644
--- a/gnucash/register/register-gnome/gnucash-item-edit.h
+++ b/gnucash/register/register-gnome/gnucash-item-edit.h
@@ -94,6 +94,7 @@ typedef struct
     GtkBorder        padding;
     GtkBorder        margin;
     GtkBorder        border;
+    gint             button_width;
 
     /* Where are we */
     VirtualLocation virt_loc;
@@ -161,6 +162,8 @@ void gnc_item_edit_focus_out (GncItemEdit *item_edit);
 
 gint gnc_item_edit_get_margin (GncItemEdit *item_edit, Sides side);
 gint gnc_item_edit_get_padding_border (GncItemEdit *item_edit, Sides side);
+gint gnc_item_edit_get_button_width (GncItemEdit *item_edit);
+
 
 GType gnc_item_edit_tb_get_type (void);
 GtkWidget *gnc_item_edit_tb_new (GnucashSheet *sheet);
diff --git a/gnucash/register/register-gnome/gnucash-sheet.c b/gnucash/register/register-gnome/gnucash-sheet.c
index fd5b8f6c5..e4ab6f398 100644
--- a/gnucash/register/register-gnome/gnucash-sheet.c
+++ b/gnucash/register/register-gnome/gnucash-sheet.c
@@ -2268,6 +2268,7 @@ gnucash_sheet_col_max_width (GnucashSheet *sheet, gint virt_col, gint cell_col)
     SheetBlockStyle *style;
     PangoLayout *layout = gtk_widget_create_pango_layout (GTK_WIDGET (sheet), "");
     GncItemEdit *item_edit = GNC_ITEM_EDIT(sheet->item_editor);
+    const gchar *type_name;
 
     g_return_val_if_fail (virt_col >= 0, 0);
     g_return_val_if_fail (virt_col < sheet->num_virt_cols, 0);
@@ -2313,6 +2314,14 @@ gnucash_sheet_col_max_width (GnucashSheet *sheet, gint virt_col, gint cell_col)
                 width += (gnc_item_edit_get_margin (item_edit, left_right) +
                           gnc_item_edit_get_padding_border (item_edit, left_right));
 
+                // get the cell type so we can add the button width to the
+                // text width if required.
+                type_name = gnc_table_get_cell_type_name (sheet->table, virt_loc);
+                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);
+                }
                 max = MAX (max, width);
             }
     }
diff --git a/gnucash/register/register-gnome/gnucash-style.c b/gnucash/register/register-gnome/gnucash-style.c
index 13d801e4b..181a24767 100644
--- a/gnucash/register/register-gnome/gnucash-style.c
+++ b/gnucash/register/register-gnome/gnucash-style.c
@@ -207,8 +207,7 @@ 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);
-
+                         gnc_item_edit_get_padding_border (item_edit, left_right) + 2;
                 cd->pixel_height += gnc_item_edit_get_margin (item_edit, top_bottom) +
                                     gnc_item_edit_get_padding_border (item_edit, top_bottom);
             }
@@ -227,7 +226,7 @@ set_dimensions_pass_one (GnucashSheet *sheet, CellBlock *cursor,
             // This is used on new account popup cells to get the default
             // width of text plus toggle button.
             if (cell && cell->is_popup)
-                width += cd->pixel_height; // toggle button is square, use cell height
+                width += gnc_item_edit_get_button_width (item_edit);
 
             cd->pixel_width = MAX (cd->pixel_width, width);
         }



Summary of changes:
 gnucash/register/register-gnome/gnucash-item-edit.c | 20 +++++++++++++++++---
 gnucash/register/register-gnome/gnucash-item-edit.h |  3 +++
 gnucash/register/register-gnome/gnucash-sheet.c     |  9 +++++++++
 gnucash/register/register-gnome/gnucash-style.c     |  5 ++---
 4 files changed, 31 insertions(+), 6 deletions(-)



More information about the gnucash-changes mailing list