gnucash master: Multiple changes pushed

John Ralls jralls at code.gnucash.org
Wed May 20 19:57:38 EDT 2020


Updated	 via  https://github.com/Gnucash/gnucash/commit/027d1f27 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/f4b0b36a (commit)
	 via  https://github.com/Gnucash/gnucash/commit/53e48ab6 (commit)
	from  https://github.com/Gnucash/gnucash/commit/700e2dc5 (commit)



commit 027d1f2751ae1973c9989cb2e7c6eb7eddf05896
Author: John Ralls <jralls at ceridwen.us>
Date:   Wed May 20 16:50:38 2020 -0700

    Recalculate type-ahead search when deleting.

diff --git a/gnucash/register/register-gnome/combocell-gnome.c b/gnucash/register/register-gnome/combocell-gnome.c
index 036440f18..bf8a6bb40 100644
--- a/gnucash/register/register-gnome/combocell-gnome.c
+++ b/gnucash/register/register-gnome/combocell-gnome.c
@@ -620,18 +620,19 @@ gnc_combo_cell_modify_verify (BasicCell* _cell,
         return;
     }
 
-    // If we were deleting or inserting in the middle, just accept.
-    if (change == NULL || *cursor_position < _cell->value_chars)
-    {
-        gnc_basic_cell_set_value_internal (_cell, newval);
-        return;
-    }
-
     /* If item_list is using temp then we're already partly matched by
      * type-ahead and a quickfill_match won't work.
      */
     if (!gnc_item_list_using_temp (box->item_list))
+    {
+        // If we were deleting or inserting in the middle, just accept.
+        if (change == NULL || *cursor_position < _cell->value_chars)
+        {
+            gnc_basic_cell_set_value_internal (_cell, newval);
+            return;
+        }
         match_str = quickfill_match (box->qf, newval);
+    }
 
     if (match_str != NULL)
     {

commit f4b0b36a3a12d8ba6962bc043dc72efb6a75adbd
Author: John Ralls <jralls at ceridwen.us>
Date:   Wed May 20 16:30:51 2020 -0700

    gnc_combo_cell: Remove the vertical scrollbar if the list store is small.
    
    A GtkScrolledWindow in automatic mode reserves at least enough space for
    its vertical scrollbar even if it's empty. This causes the combo to be
    at least two rows tall even when there's only one item, which is ugly.
    Worse, it caused check_popup_height_is_true to fail resulting in an
    infinite loop because it's predicated on there being a size error that
    can be fixed by calling gnc_item_edit_update, which will cause a redraw
    and call check_popup_height_is_true again.

diff --git a/gnucash/register/register-gnome/combocell-gnome.c b/gnucash/register/register-gnome/combocell-gnome.c
index 704da882c..036440f18 100644
--- a/gnucash/register/register-gnome/combocell-gnome.c
+++ b/gnucash/register/register-gnome/combocell-gnome.c
@@ -549,6 +549,7 @@ gnc_combo_cell_type_ahead_search (const gchar* newval,
     g_regex_unref (regex0);
 
     block_list_signals (cell); //Prevent recursion from gtk_tree_view signals.
+    gnc_item_edit_hide_popup (box->item_edit);
     gtk_list_store_clear (box->tmp_store);
     unblock_list_signals (cell);
 
@@ -896,10 +897,20 @@ popup_get_height (G_GNUC_UNUSED GtkWidget* widget,
                   gpointer user_data)
 {
     PopBox* box = user_data;
-    int count, pad = 4;
+    GtkScrolledWindow* scrollwin = GNC_ITEM_LIST(widget)->scrollwin;
+    int count, height;
 
     count = gnc_item_list_num_entries (box->item_list);
-    return MIN (space_available, (count * (row_height + pad)) + pad);
+    height = count * row_height;
+    if (height < space_available)
+    {
+        gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrollwin),
+                                        GTK_POLICY_AUTOMATIC, GTK_POLICY_NEVER);
+        return height;
+    }
+    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrollwin),
+                                    GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+    return space_available;
 }
 
 static int
diff --git a/gnucash/register/register-gnome/gnucash-item-list.c b/gnucash/register/register-gnome/gnucash-item-list.c
index cc51b0718..667e0103f 100644
--- a/gnucash/register/register-gnome/gnucash-item-list.c
+++ b/gnucash/register/register-gnome/gnucash-item-list.c
@@ -279,6 +279,7 @@ gnc_item_list_using_temp (GncItemList *item_list)
 static void
 gnc_item_list_init (GncItemList* item_list)
 {
+    item_list->scrollwin = NULL;
     item_list->tree_view = NULL;
     item_list->list_store = NULL;
     item_list->temp_store = NULL;
@@ -477,7 +478,6 @@ GtkWidget*
 gnc_item_list_new (GtkListStore* list_store)
 {
     GtkWidget* tree_view;
-    GtkWidget* scrollwin;
     GtkCellRenderer* renderer;
     GtkTreeViewColumn* column;
 
@@ -485,10 +485,12 @@ gnc_item_list_new (GtkListStore* list_store)
         GNC_ITEM_LIST (g_object_new (GNC_TYPE_ITEM_LIST,
                                      NULL));
 
-    scrollwin = gtk_scrolled_window_new(NULL, NULL);
-    gtk_container_add (GTK_CONTAINER (item_list), GTK_WIDGET (scrollwin));
+    item_list->scrollwin =
+        GTK_SCROLLED_WINDOW (gtk_scrolled_window_new(NULL, NULL));
+    gtk_container_add (GTK_CONTAINER (item_list),
+                       GTK_WIDGET (item_list->scrollwin));
 
-    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrollwin),
+    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (item_list->scrollwin),
                                     GTK_POLICY_AUTOMATIC,
                                     GTK_POLICY_AUTOMATIC);
 
@@ -513,7 +515,7 @@ gnc_item_list_new (GtkListStore* list_store)
                                                        NULL);
     gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), column);
 
-    gtk_container_add (GTK_CONTAINER (scrollwin), tree_view);
+    gtk_container_add (GTK_CONTAINER (item_list->scrollwin), tree_view);
 
     item_list->tree_view = GTK_TREE_VIEW (tree_view);
     item_list->list_store = list_store;
diff --git a/gnucash/register/register-gnome/gnucash-item-list.h b/gnucash/register/register-gnome/gnucash-item-list.h
index 74e7d7bd0..c5e75f859 100644
--- a/gnucash/register/register-gnome/gnucash-item-list.h
+++ b/gnucash/register/register-gnome/gnucash-item-list.h
@@ -42,6 +42,7 @@ typedef struct
     GtkEventBox ebox;
 
     GtkTreeView *tree_view;
+    GtkScrolledWindow* scrollwin;
     GtkListStore *list_store; /* Contains the list items */
     GtkListStore *temp_store; /* Temporary store for typeahead select */
 } GncItemList;

commit 53e48ab6fac7b934f8b692a71fa74b33c60f5e90
Author: John Ralls <jralls at ceridwen.us>
Date:   Wed May 20 16:29:07 2020 -0700

    Get rid of GncScrolledWindow.
    
    It's just a pointless rename, no added value at all.

diff --git a/gnucash/register/register-gnome/CMakeLists.txt b/gnucash/register/register-gnome/CMakeLists.txt
index 14ee2ce0e..51a288680 100644
--- a/gnucash/register/register-gnome/CMakeLists.txt
+++ b/gnucash/register/register-gnome/CMakeLists.txt
@@ -11,7 +11,6 @@ set (register_gnome_SOURCES
   gnucash-item-edit.c
   gnucash-item-list.c
   gnucash-register.c
-  gnucash-scrolled-window.c
   gnucash-sheet-private.c
   gnucash-sheet.c
   gnucash-style.c
@@ -29,7 +28,6 @@ set (register_gnome_noinst_HEADERS
   gnucash-item-edit.h
   gnucash-item-list.h
   gnucash-register.h
-  gnucash-scrolled-window.h
   gnucash-sheet.h
   gnucash-sheetP.h
   gnucash-style.h
diff --git a/gnucash/register/register-gnome/gnucash-item-list.c b/gnucash/register/register-gnome/gnucash-item-list.c
index 8cb2c7167..cc51b0718 100644
--- a/gnucash/register/register-gnome/gnucash-item-list.c
+++ b/gnucash/register/register-gnome/gnucash-item-list.c
@@ -34,7 +34,6 @@
 
 #include "gnc-engine.h"
 #include "gnucash-item-list.h"
-#include "gnucash-scrolled-window.h"
 
 /* Item list signals */
 enum
@@ -486,8 +485,8 @@ gnc_item_list_new (GtkListStore* list_store)
         GNC_ITEM_LIST (g_object_new (GNC_TYPE_ITEM_LIST,
                                      NULL));
 
-    scrollwin = gnc_scrolled_window_new();
-    gtk_container_add (GTK_CONTAINER (item_list), scrollwin);
+    scrollwin = gtk_scrolled_window_new(NULL, NULL);
+    gtk_container_add (GTK_CONTAINER (item_list), GTK_WIDGET (scrollwin));
 
     gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrollwin),
                                     GTK_POLICY_AUTOMATIC,
diff --git a/gnucash/register/register-gnome/gnucash-scrolled-window.c b/gnucash/register/register-gnome/gnucash-scrolled-window.c
deleted file mode 100644
index 2dc015dfd..000000000
--- a/gnucash/register/register-gnome/gnucash-scrolled-window.c
+++ /dev/null
@@ -1,92 +0,0 @@
-/********************************************************************\
- * gnucash-scrolled-window.c -- gnucash specific scrolled window    *
- * Copyright (C) 2001 Gnumatic, Inc.                                *
- * Author: Dave Peticolas <dave at krondo.com>                         *
- *                                                                  *
- * This program is free software; you can redistribute it and/or    *
- * modify it under the terms of the GNU General Public License as   *
- * published by the Free Software Foundation; either version 2 of   *
- * the License, or (at your option) any later version.              *
- *                                                                  *
- * This program is distributed in the hope that it will be useful,  *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
- * GNU General Public License for more details.                     *
- *                                                                  *
- * You should have received a copy of the GNU General Public License*
- * along with this program; if not, contact:                        *
- *                                                                  *
- * Free Software Foundation           Voice:  +1-617-542-5942       *
- * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
- * Boston, MA  02110-1301,  USA       gnu at gnu.org                   *
-\********************************************************************/
-
-#include <config.h>
-
-#include "gnucash-scrolled-window.h"
-
-
-/** Static Globals ****************************************************/
-static GtkScrolledWindowClass *parent_class = NULL;
-
-
-/** Declarations ******************************************************/
-static void gnc_scrolled_window_class_init (GncScrolledWindowClass *klass);
-static void gnc_scrolled_window_init (GncScrolledWindow *scrollwin);
-
-
-/** Implementations ***************************************************/
-
-GType
-gnc_scrolled_window_get_type (void)
-{
-    static GType gnc_scrolled_window_type = 0;
-
-    if (!gnc_scrolled_window_type)
-    {
-        static const GTypeInfo gnc_scrolled_window_info =
-        {
-            sizeof (GncScrolledWindowClass),
-            NULL,
-            NULL,
-            (GClassInitFunc) gnc_scrolled_window_class_init,
-            NULL,
-            NULL,
-            sizeof (GncScrolledWindow),
-            0,
-            (GInstanceInitFunc) gnc_scrolled_window_init
-        };
-
-        gnc_scrolled_window_type = g_type_register_static (GTK_TYPE_SCROLLED_WINDOW,
-                                   "GncScrolledWindow",
-                                   &gnc_scrolled_window_info, 0);
-    }
-
-    return gnc_scrolled_window_type;
-}
-
-
-GtkWidget *
-gnc_scrolled_window_new (void)
-{
-    return gtk_widget_new (GNC_TYPE_SCROLLED_WINDOW,
-                           "hadjustment", NULL,
-                           "vadjustment", NULL,
-                           NULL);
-}
-
-
-static void
-gnc_scrolled_window_class_init (GncScrolledWindowClass *klass)
-{
-    GtkScrolledWindowClass *scroll_class = GTK_SCROLLED_WINDOW_CLASS (klass);
-
-    parent_class = g_type_class_peek_parent (klass);
-
-    scroll_class->scrollbar_spacing = 0;
-}
-
-static void
-gnc_scrolled_window_init (GncScrolledWindow *scrollwin)
-{
-}
diff --git a/gnucash/register/register-gnome/gnucash-scrolled-window.h b/gnucash/register/register-gnome/gnucash-scrolled-window.h
deleted file mode 100644
index 6426f3594..000000000
--- a/gnucash/register/register-gnome/gnucash-scrolled-window.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/********************************************************************\
- * gnucash-scrolled-window.h -- gnucash specific scrolled window    *
- * Copyright (C) 2001 Gnumatic, Inc.                                *
- * Author: Dave Peticolas <dave at krondo.com>                         *
- *                                                                  *
- * This program is free software; you can redistribute it and/or    *
- * modify it under the terms of the GNU General Public License as   *
- * published by the Free Software Foundation; either version 2 of   *
- * the License, or (at your option) any later version.              *
- *                                                                  *
- * This program is distributed in the hope that it will be useful,  *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
- * GNU General Public License for more details.                     *
- *                                                                  *
- * You should have received a copy of the GNU General Public License*
- * along with this program; if not, contact:                        *
- *                                                                  *
- * Free Software Foundation           Voice:  +1-617-542-5942       *
- * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
- * Boston, MA  02110-1301,  USA       gnu at gnu.org                   *
-\********************************************************************/
-
-#ifndef GNC_SCROLLED_WINDOW_H
-#define GNC_SCROLLED_WINDOW_H
-
-#include <gtk/gtk.h>
-/** @ingroup Register
- * @addtogroup Gnome
- * @{
- * @brief Gtk+-2 widgets for displaying SplitRegister components.
- */
-/** @file gnucash-scrolled-window.h
- * @brief Public declarations for GncScrolledWindow class
- */
-G_BEGIN_DECLS
-
-#define GNC_TYPE_SCROLLED_WINDOW        (gnc_scrolled_window_get_type ())
-#define GNC_SCROLLED_WINDOW(o)          (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_SCROLLED_WINDOW, GNCScrolledWindow))
-#define GNC_SCROLLED_WINDOW_CLASS(k)    (G_TYPE_CHECK_CLASS_CAST ((k), GNC_TYPE_SCROLLED_WINDOW, GNCScrolledWindowClass))
-#define GNC_IS_SCROLLED_WINDOW(o)       (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_SCROLLED_WINDOW))
-#define GNC_IS_SCROLLED_WINDOW_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_SCROLLED_WINDOW))
-
-
-typedef struct
-{
-    GtkScrolledWindow scrollwin;
-} GncScrolledWindow;
-
-typedef struct
-{
-    GtkScrolledWindowClass parent_class;
-} GncScrolledWindowClass;
-
-
-GType      gnc_scrolled_window_get_type (void);
-GtkWidget *gnc_scrolled_window_new (void);
-
-G_END_DECLS
-/** @} */
-#endif /* GNC_SCROLLED_WINDOW_H */



Summary of changes:
 gnucash/register/register-gnome/CMakeLists.txt     |  2 -
 gnucash/register/register-gnome/combocell-gnome.c  | 30 ++++---
 .../register/register-gnome/gnucash-item-list.c    | 13 +--
 .../register/register-gnome/gnucash-item-list.h    |  1 +
 .../register-gnome/gnucash-scrolled-window.c       | 92 ----------------------
 .../register-gnome/gnucash-scrolled-window.h       | 61 --------------
 6 files changed, 29 insertions(+), 170 deletions(-)
 delete mode 100644 gnucash/register/register-gnome/gnucash-scrolled-window.c
 delete mode 100644 gnucash/register/register-gnome/gnucash-scrolled-window.h



More information about the gnucash-changes mailing list