gnucash stable: Multiple changes pushed

Christopher Lam clam at code.gnucash.org
Fri Sep 8 05:35:12 EDT 2023


Updated	 via  https://github.com/Gnucash/gnucash/commit/76ac345e (commit)
	 via  https://github.com/Gnucash/gnucash/commit/492f8c92 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/c1bc9e17 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/58d5d4bc (commit)
	 via  https://github.com/Gnucash/gnucash/commit/af371af1 (commit)
	from  https://github.com/Gnucash/gnucash/commit/9d12874c (commit)



commit 76ac345edbe2d7fd9d67a7b83344003a18e2e23f
Merge: 9d12874cec 492f8c927c
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Fri Sep 8 17:24:44 2023 +0800

    Merge branch 'GNCAccountSel-default-commodity' into stable #1762


commit 492f8c927cc384fc1dc90da3ab6180d03dd2fdb2
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Thu Sep 7 23:41:09 2023 +0800

    [dialog-account] remove gnc_ui_new_accounts_from_name_window_with_types

diff --git a/gnucash/gnome-utils/dialog-account.c b/gnucash/gnome-utils/dialog-account.c
index e1a2f3dffe..0bd2e8566f 100644
--- a/gnucash/gnome-utils/dialog-account.c
+++ b/gnucash/gnome-utils/dialog-account.c
@@ -1985,15 +1985,6 @@ gnc_ui_new_accounts_from_name_window (GtkWindow *parent, const char *name)
                                                          NULL, NULL);
 }
 
-Account *
-gnc_ui_new_accounts_from_name_window_with_types (GtkWindow *parent,
-                                                 const char *name,
-                                                 GList *valid_types)
-{
-    return gnc_ui_new_accounts_from_name_with_defaults (parent, name,
-                                                        valid_types, NULL, NULL);
-}
-
 Account *
 gnc_ui_new_accounts_from_name_with_defaults (GtkWindow *parent,
                                              const char *name,
@@ -2169,14 +2160,6 @@ gnc_ui_new_account_window (GtkWindow *parent, QofBook *book,
                                         NULL, FALSE);
 }
 
-void
-gnc_ui_new_account_with_types (GtkWindow *parent, QofBook *book,
-                               GList *valid_types)
-{
-    gnc_ui_new_account_window_internal (parent, book, NULL, NULL,
-                                        valid_types, NULL, FALSE);
-}
-
 /************************************************************
  *             Callbacks for a non-Modal Dialog             *
  ************************************************************/
diff --git a/gnucash/gnome-utils/dialog-account.h b/gnucash/gnome-utils/dialog-account.h
index 84eb8e7b6f..2d51039a3f 100644
--- a/gnucash/gnome-utils/dialog-account.h
+++ b/gnucash/gnome-utils/dialog-account.h
@@ -143,26 +143,6 @@ void gnc_ui_new_account_with_types (GtkWindow *parent, QofBook *book,
 Account * gnc_ui_new_accounts_from_name_window (GtkWindow *parent,
                                                 const char *name);
 
-/** Display a modal window for creating a new account.  This function
- *  will restrict the available account type values to the list
- *  specified by the caller.
- *
- *  @param parent The widget on which to parent the dialog.
- *
- *  @param name The account name/path to be created.  This parameter
- *  is not used for determining the initially selected parent account.
- *
- *  @param valid_types A GList of GNCAccountType gints [as pointers]
- *  which are allowed to be created.  The calling function is
- *  responsible for freeing this list.
- *
- *  @return A pointer to the newly created account.
- */
-/* Note that the caller owns the valid_types list */
-Account * gnc_ui_new_accounts_from_name_window_with_types (GtkWindow *parent,
-                                                           const char *name,
-                                                           GList *valid_types);
-
 
 /** Display a modal window for creating a new account.  This function
  *  will restrict the available account type values to the list

commit c1bc9e17c661fe2236819077fe7e660a5a9b9bbd
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Thu Sep 7 23:40:24 2023 +0800

    [gncEntryLedger] don't use gnc_ui_new_accounts_from_name_window_with_types
    
    use gnc_ui_new_accounts_from_name_with_defaults instead

diff --git a/gnucash/register/ledger-core/gncEntryLedger.c b/gnucash/register/ledger-core/gncEntryLedger.c
index 11266c2e41..a799183fde 100644
--- a/gnucash/register/ledger-core/gncEntryLedger.c
+++ b/gnucash/register/ledger-core/gncEntryLedger.c
@@ -113,7 +113,8 @@ gnc_entry_ledger_get_account_by_name (GncEntryLedger *ledger, BasicCell * bcell,
         else
             account_types = g_list_prepend (account_types, (gpointer)ACCT_TYPE_EXPENSE);
 
-        account = gnc_ui_new_accounts_from_name_window_with_types (GTK_WINDOW (ledger->parent), name, account_types);
+        account = gnc_ui_new_accounts_from_name_with_defaults (GTK_WINDOW (ledger->parent), name, account_types,
+                                                               NULL, NULL);
         g_list_free ( account_types );
         if (!account)
             return NULL;

commit 58d5d4bc73269aefd1d025047a0b78e9f0e5f90e
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Thu Sep 7 23:39:40 2023 +0800

    [gnc-account-sel] can specify any new account's default commodity

diff --git a/gnucash/gnome-utils/gnc-account-sel.c b/gnucash/gnome-utils/gnc-account-sel.c
index c1cafa3fa2..bdd87e6a81 100644
--- a/gnucash/gnome-utils/gnc-account-sel.c
+++ b/gnucash/gnome-utils/gnc-account-sel.c
@@ -65,6 +65,7 @@ struct _GNCAccountSel
     GList *acctTypeFilters;
     GList *acctCommodityFilters;
     GList *acctExcludeList;
+    gnc_commodity *default_new_commodity;
 
     /* The state of this pointer also serves as a flag about what state
      * the widget is in WRT the new-account-button ability. */
@@ -671,6 +672,7 @@ gnc_account_sel_init (GNCAccountSel *gas)
 
     gtk_orientable_set_orientation (GTK_ORIENTABLE(gas), GTK_ORIENTATION_HORIZONTAL);
 
+    gas->default_new_commodity = NULL;
     gas->acctTypeFilters = NULL;
     gas->acctCommodityFilters = NULL;
     gas->acctExcludeList = NULL;
@@ -913,6 +915,14 @@ gnc_account_sel_set_acct_exclude_filter (GNCAccountSel *gas,
     update_entry_and_refilter (gas);
 }
 
+void
+gnc_account_sel_set_default_new_commodity (GNCAccountSel *gas, gnc_commodity *new_commodity)
+{
+    g_return_if_fail (gas);
+    g_return_if_fail (GNC_IS_COMMODITY (new_commodity));
+    gas->default_new_commodity = new_commodity;
+}
+
 static void
 gnc_account_sel_finalize (GObject *object)
 {
@@ -1015,14 +1025,14 @@ gas_new_account_click (GtkButton *b, gpointer user_data)
 
     if (gas->isModal)
     {
-        Account *account = gnc_ui_new_accounts_from_name_window_with_types (parent, NULL,
-                                                                            gas->acctTypeFilters);
+        Account *account = gnc_ui_new_accounts_from_name_with_defaults (parent, NULL, gas->acctTypeFilters,
+                                                                        gas->default_new_commodity, NULL);
         if (account)
             gnc_account_sel_set_account (gas, account, FALSE);
     }
     else
-        gnc_ui_new_account_with_types (parent, gnc_get_current_book(),
-                                       gas->acctTypeFilters);
+        gnc_ui_new_account_with_types_and_commodity (parent, gnc_get_current_book(),
+                                                     gas->acctTypeFilters, gas->default_new_commodity);
 }
 
 gint
diff --git a/gnucash/gnome-utils/gnc-account-sel.h b/gnucash/gnome-utils/gnc-account-sel.h
index c21973c2e0..8965deaec3 100644
--- a/gnucash/gnome-utils/gnc-account-sel.h
+++ b/gnucash/gnome-utils/gnc-account-sel.h
@@ -75,6 +75,14 @@ void gnc_account_sel_set_acct_filters (GNCAccountSel *gas,
 void gnc_account_sel_set_acct_exclude_filter (GNCAccountSel *gas,
                                               GList *excludeFilter);
 
+
+/**
+ * The GNCAccountSel can be setup to provide a New account facility whose commodity
+ * is defaulted to this commodity.
+ * @param gas The GNCAccountSel widget.
+ * @param gnc_commodity* A gnc_commodity*
+ **/
+void gnc_account_sel_set_default_new_commodity (GNCAccountSel*, gnc_commodity*);
 /**
  * Conditional inclusion of a new-account button to the right of the
  * combobox.

commit af371af17240c2a10fb607841a06c68f8e1b1f00
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Thu Sep 7 23:37:57 2023 +0800

    [dialog-account] new: gnc_ui_new_account_with_types_and_commodity
    
    same as gnc_ui_new_account_with_types but can specify new account's
    default commodity

diff --git a/gnucash/gnome-utils/dialog-account.c b/gnucash/gnome-utils/dialog-account.c
index c98e10fde5..e1a2f3dffe 100644
--- a/gnucash/gnome-utils/dialog-account.c
+++ b/gnucash/gnome-utils/dialog-account.c
@@ -2143,6 +2143,14 @@ gnc_ui_edit_account_window (GtkWindow *parent, Account *account)
     gtk_window_present (GTK_WINDOW(aw->dialog));
 }
 
+void
+gnc_ui_new_account_with_types_and_commodity (GtkWindow *parent, QofBook *book, GList *valid_types,
+                                             gnc_commodity *default_commodity)
+{
+    gnc_ui_new_account_window_internal (parent, book, NULL, NULL,
+                                        valid_types, default_commodity, FALSE);
+}
+
 /*
  * opens up a window to create a new account
  *
diff --git a/gnucash/gnome-utils/dialog-account.h b/gnucash/gnome-utils/dialog-account.h
index 9d59b9c9c0..84eb8e7b6f 100644
--- a/gnucash/gnome-utils/dialog-account.h
+++ b/gnucash/gnome-utils/dialog-account.h
@@ -74,6 +74,25 @@ account_type_has_auto_interest_payment(type) )
 void gnc_ui_edit_account_window (GtkWindow *parent, Account *account);
 
 
+/** Display a window for creating a new account.  This function will
+ *  restrict the available account type values to the list specified
+ *  by the caller.
+ *
+ *  @param parent The widget on which to parent the dialog.
+ *
+ *  @param book The book in which the new account should be created.
+ *  This is a required argument.
+ *
+ *  @param valid_types A GList of GNCAccountType gints [as pointers]
+ *  which are allowed to be created.  The calling function is
+ *  responsible for freeing this list.
+ *
+ *  @param default_commodity A gnc_commodity* to specify the default
+ *  commodity to create. May be NULL.
+ */
+void gnc_ui_new_account_with_types_and_commodity (GtkWindow *parent, QofBook *book,
+                                                  GList *valid_types, gnc_commodity*);
+
 /** Display a window for creating a new account.  This function will
  *  also initially set the parent account of the new account to what
  *  the caller specified.  The user is free, however, to choose any



Summary of changes:
 gnucash/gnome-utils/dialog-account.c          | 25 ++++++-----------
 gnucash/gnome-utils/dialog-account.h          | 39 +++++++++++++--------------
 gnucash/gnome-utils/gnc-account-sel.c         | 18 ++++++++++---
 gnucash/gnome-utils/gnc-account-sel.h         |  8 ++++++
 gnucash/register/ledger-core/gncEntryLedger.c |  3 ++-
 5 files changed, 51 insertions(+), 42 deletions(-)



More information about the gnucash-changes mailing list