gnucash stable: Multiple changes pushed

Christopher Lam clam at code.gnucash.org
Mon Apr 15 10:49:21 EDT 2024


Updated	 via  https://github.com/Gnucash/gnucash/commit/cc10b9a0 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/f21f4f42 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/6eed5b66 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/508679e3 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/957b6e3a (commit)
	from  https://github.com/Gnucash/gnucash/commit/6d7e231e (commit)



commit cc10b9a0b71a6284ca035dbe6aeafdb892ae0ac2
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Mon Apr 15 22:09:54 2024 +0800

    [SX-book.c] tidy for loop
    
    because splits will need to be g_list_free in a future commit

diff --git a/libgnucash/engine/SX-book.c b/libgnucash/engine/SX-book.c
index d30e405db2..b784bab150 100644
--- a/libgnucash/engine/SX-book.c
+++ b/libgnucash/engine/SX-book.c
@@ -375,9 +375,9 @@ gnc_sx_get_sxes_referencing_account(QofBook *book, Account *acct)
     {
         SchedXaction *sx = (SchedXaction*)sx_list->data;
         GList *splits = xaccSchedXactionGetSplits(sx);
-        for (; splits != NULL; splits = splits->next)
+        for (GList *node = splits; node; node = node->next)
         {
-            Split *s = (Split*)splits->data;
+            Split *s = (Split*)node->data;
             GncGUID *guid = NULL;
             qof_instance_get (QOF_INSTANCE (s), "sx-account", &guid, NULL);
             if (guid_equal(acct_guid, guid))

commit f21f4f42640ebda5545201534502aa7f4de9b488
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Mon Apr 15 22:10:05 2024 +0800

    [gnc-autoclear.c] tidy xaccAccountGetSplitList
    
    because acc_splits will need to be g_list_free in a future commit

diff --git a/gnucash/gnome-utils/gnc-autoclear.c b/gnucash/gnome-utils/gnc-autoclear.c
index b2c249d744..0b4ff9249d 100644
--- a/gnucash/gnome-utils/gnc-autoclear.c
+++ b/gnucash/gnome-utils/gnc-autoclear.c
@@ -122,7 +122,8 @@ gnc_autoclear_get_splits (Account *account, gnc_numeric toclear_value,
     DUP_LIST = g_list_prepend (NULL, NULL);
 
     /* Extract which splits are not cleared and compute the amount we have to clear */
-    for (GList *node = xaccAccountGetSplitList (account); node; node = node->next)
+    GList *acc_splits = xaccAccountGetSplitList (account);
+    for (GList *node = acc_splits; node; node = node->next)
     {
         Split *split = (Split *)node->data;
         gnc_numeric amount = xaccSplitGetAmount (split);

commit 6eed5b6641aca68854b536347c2667210fb27082
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Mon Apr 15 22:02:01 2024 +0800

    [split-register-control.cpp] convert to c++

diff --git a/gnucash/register/ledger-core/CMakeLists.txt b/gnucash/register/ledger-core/CMakeLists.txt
index 19563f3a58..7155e3e901 100644
--- a/gnucash/register/ledger-core/CMakeLists.txt
+++ b/gnucash/register/ledger-core/CMakeLists.txt
@@ -4,7 +4,7 @@ add_subdirectory(test)
 set (ledger_core_SOURCES
   gnc-ledger-display.c
   split-register.c
-  split-register-control.c
+  split-register-control.cpp
   split-register-copy-ops.c
   split-register-layout.c
   split-register-load.c
diff --git a/gnucash/register/ledger-core/split-register-control.c b/gnucash/register/ledger-core/split-register-control.cpp
similarity index 99%
rename from gnucash/register/ledger-core/split-register-control.c
rename to gnucash/register/ledger-core/split-register-control.cpp
index 324764c8f0..a1578868cd 100644
--- a/gnucash/register/ledger-core/split-register-control.c
+++ b/gnucash/register/ledger-core/split-register-control.cpp
@@ -82,7 +82,7 @@ gnc_split_register_balance_trans (SplitRegister *reg, Transaction *trans)
             multi_currency = TRUE;
         else
         {
-            imbal_mon = imbal_list->data;
+            imbal_mon = static_cast<gnc_monetary*>(imbal_list->data);
             if (!imbal_list->next &&
                     gnc_commodity_equiv(gnc_monetary_commodity(*imbal_mon),
                                         xaccTransGetCurrency(trans)))
@@ -369,7 +369,7 @@ gnc_split_register_move_cursor (VirtualLocation *p_new_virt_loc,
 {
     VirtualLocation new_virt_loc = *p_new_virt_loc;
     VirtualCellLocation old_trans_split_loc;
-    SplitRegister *reg = user_data;
+    auto reg = static_cast<SplitRegister*>(user_data);
     Transaction *pending_trans;
     Transaction *new_trans;
     Transaction *old_trans;
@@ -649,7 +649,7 @@ gnc_find_split_in_trans_by_memo (Transaction *trans, const char *memo,
 {
     for (GList *n = xaccTransGetSplitList (trans); n; n = n->next)
     {
-        Split *split = n->data;
+        auto split = GNC_SPLIT(n->data);
         if (unit_price)
         {
             gnc_numeric price = xaccSplitGetSharePrice (split);
@@ -668,23 +668,22 @@ static Split *
 gnc_find_split_in_account_by_memo (Account *account, const char *memo,
                                    gboolean unit_price)
 {
-    GList *slp;
-
     if (account == NULL) return NULL;
 
-    for (slp = g_list_last (xaccAccountGetSplitList (account));
-            slp;
-            slp = slp->prev)
+    Split *rv = nullptr;
+    auto splits = xaccAccountGetSplitList (account);
+    for (auto slp = g_list_last (splits); !rv && slp; slp = slp->prev)
     {
-        Split *split = slp->data;
+        auto split = GNC_SPLIT(slp->data);
         Transaction *trans = xaccSplitGetParent (split);
 
         split = gnc_find_split_in_trans_by_memo (trans, memo, unit_price);
 
-        if (split) return split;
+        if (split)
+            rv = split;
     }
 
-    return NULL;
+    return rv;
 }
 
 static Split *
@@ -908,7 +907,7 @@ gnc_split_register_auto_completion (SplitRegister *reg,
 
             for (GList *n = xaccTransGetSplitList (trans); n; n = n->next)
             {
-                Split *s = n->data;
+                auto s = GNC_SPLIT(n->data);
                 if (default_account == xaccSplitGetAccount(s))
                 {
                     blank_split = s;
@@ -1610,7 +1609,7 @@ gnc_split_register_traverse (VirtualLocation *p_new_virt_loc,
                              gncTableTraversalDir dir,
                              gpointer user_data)
 {
-    SplitRegister *reg = user_data;
+    auto reg = static_cast<SplitRegister*>(user_data);
     Transaction *pending_trans;
     VirtualLocation virt_loc;
     Transaction *trans, *new_trans;
@@ -1825,7 +1824,7 @@ gnc_split_register_control_new (void)
 gboolean
 gnc_split_register_recn_cell_confirm (char old_flag, gpointer data)
 {
-    SplitRegister *reg = data;
+    auto reg = static_cast<SplitRegister*>(data);
     GtkWidget *dialog, *window;
     gint response;
     const gchar *title = _("Mark split as unreconciled?");
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 3f0bfe91fb..54843eb06d 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -392,7 +392,7 @@ gnucash/register/ledger-core/gncEntryLedgerLoad.c
 gnucash/register/ledger-core/gncEntryLedgerModel.c
 gnucash/register/ledger-core/gnc-ledger-display.c
 gnucash/register/ledger-core/split-register.c
-gnucash/register/ledger-core/split-register-control.c
+gnucash/register/ledger-core/split-register-control.cpp
 gnucash/register/ledger-core/split-register-copy-ops.c
 gnucash/register/ledger-core/split-register-layout.c
 gnucash/register/ledger-core/split-register-load.c

commit 508679e338256b453c39f72f3d15bdbd7576bf3f
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Mon Apr 15 21:49:47 2024 +0800

    [window-reconcile.cpp] convert to c++

diff --git a/gnucash/gnome/CMakeLists.txt b/gnucash/gnome/CMakeLists.txt
index 1594c25e4a..cd54743c9e 100644
--- a/gnucash/gnome/CMakeLists.txt
+++ b/gnucash/gnome/CMakeLists.txt
@@ -120,7 +120,7 @@ set (gnc_gnome_SOURCES
   reconcile-view.c
   search-owner.c
   top-level.c
-  window-reconcile.c
+  window-reconcile.cpp
   window-report.cpp
   window-autoclear.c
 )
diff --git a/gnucash/gnome/window-reconcile.c b/gnucash/gnome/window-reconcile.cpp
similarity index 97%
rename from gnucash/gnome/window-reconcile.c
rename to gnucash/gnome/window-reconcile.cpp
index fd17025778..1d352f05d8 100644
--- a/gnucash/gnome/window-reconcile.c
+++ b/gnucash/gnome/window-reconcile.cpp
@@ -139,8 +139,10 @@ static void   recnFinishCB (GSimpleAction *simple, GVariant *parameter, gpointer
 static void   recnPostponeCB (GSimpleAction *simple, GVariant *parameter, gpointer user_data);
 static void   recnCancelCB (GSimpleAction *simple, GVariant *parameter, gpointer user_data);
 
+extern "C" {
 void gnc_start_recn_children_changed (GtkWidget *widget, startRecnWindowData *data);
 void gnc_start_recn_interest_clicked_cb (GtkButton *button, startRecnWindowData *data);
+}
 
 static void   gnc_reconcile_window_set_sensitivity (RecnWindow *recnData);
 static char * gnc_recn_make_window_name (Account *account);
@@ -893,7 +895,7 @@ static void
 gnc_reconcile_window_toggled_cb(GNCReconcileView *view, Split *split,
                                 gpointer data)
 {
-    RecnWindow *recnData = data;
+    auto recnData = static_cast<RecnWindow*>(data);
     gnc_reconcile_window_set_sensitivity(recnData);
     recnRecalculateBalance(recnData);
 }
@@ -903,7 +905,7 @@ static void
 gnc_reconcile_window_row_cb(GNCReconcileView *view, gpointer item,
                             gpointer data)
 {
-    RecnWindow *recnData = data;
+    auto recnData = static_cast<RecnWindow*>(data);
     gnc_reconcile_window_set_sensitivity(recnData);
 }
 
@@ -1014,7 +1016,7 @@ static void
 gnc_reconcile_window_double_click_cb(GNCReconcileView *view, Split *split,
                                      gpointer data)
 {
-    RecnWindow *recnData = data;
+    auto recnData = static_cast<RecnWindow*>(data);
     GNCSplitReg *gsr;
 
     /* This should never be true, but be paranoid */
@@ -1037,7 +1039,7 @@ static void
 gnc_reconcile_window_focus_cb(GtkWidget *widget, GdkEventFocus *event,
                               gpointer data)
 {
-    RecnWindow *recnData = data;
+    auto recnData = static_cast<RecnWindow*>(data);
     GNCReconcileView *this_view, *other_view;
     GNCReconcileView *debit, *credit;
 
@@ -1057,7 +1059,7 @@ static gboolean
 gnc_reconcile_key_press_cb (GtkWidget *widget, GdkEventKey *event,
                             gpointer data)
 {
-    RecnWindow *recnData = data;
+    auto recnData = static_cast<RecnWindow*>(data);
     GtkWidget *this_view, *other_view;
     GtkWidget *debit, *credit;
 
@@ -1199,7 +1201,7 @@ gnc_ui_reconcile_window_help_cb (GSimpleAction *simple,
                                  GVariant      *parameter,
                                  gpointer       user_data)
 {
-    RecnWindow *recnData = user_data;
+    auto recnData = static_cast<RecnWindow*>(user_data);
     gnc_gnome_help (GTK_WINDOW(recnData->window), DF_MANUAL, DL_RECNWIN);
 }
 
@@ -1209,7 +1211,7 @@ gnc_ui_reconcile_window_change_cb (GSimpleAction *simple,
                                    GVariant      *parameter,
                                    gpointer       user_data)
 {
-    RecnWindow *recnData = user_data;
+    auto recnData = static_cast<RecnWindow*>(user_data);
     Account *account = recn_get_account (recnData);
     gnc_numeric new_ending = recnData->new_ending;
     time64 statement_date = recnData->statement_date;
@@ -1231,7 +1233,7 @@ gnc_ui_reconcile_window_balance_cb (GSimpleAction *simple,
                                     GVariant      *parameter,
                                     gpointer       user_data)
 {
-    RecnWindow *recnData = user_data;
+    auto recnData = static_cast<RecnWindow*>(user_data);
     GNCSplitReg *gsr;
     Account *account;
     gnc_numeric balancing_amount;
@@ -1263,7 +1265,7 @@ gnc_ui_reconcile_window_rec_cb (GSimpleAction *simple,
                                 GVariant      *parameter,
                                 gpointer       user_data)
 {
-    RecnWindow *recnData = user_data;
+    auto recnData = static_cast<RecnWindow*>(user_data);
     GNCReconcileView *debit, *credit;
 
     debit  = GNC_RECONCILE_VIEW(recnData->debit);
@@ -1279,7 +1281,7 @@ gnc_ui_reconcile_window_unrec_cb (GSimpleAction *simple,
                                   GVariant      *parameter,
                                   gpointer       user_data)
 {
-    RecnWindow *recnData = user_data;
+    auto recnData = static_cast<RecnWindow*>(user_data);
     GNCReconcileView *debit, *credit;
 
     debit  = GNC_RECONCILE_VIEW(recnData->debit);
@@ -1323,7 +1325,7 @@ gnc_reconcile_window_delete_set_next_selection (RecnWindow *recnData, Split *spl
     GtkTreeIter iter;
     GtkTreeSelection *selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (view));
     GList *path_list, *node;
-    GtkTreePath *path, *save_del_path;
+    GtkTreePath *save_del_path;
     Transaction* trans = xaccSplitGetParent (split); // parent transaction of the split to delete
 
     if (!view)
@@ -1334,7 +1336,7 @@ gnc_reconcile_window_delete_set_next_selection (RecnWindow *recnData, Split *spl
     node = g_list_first (path_list);
     if (!node)
         return;
-    path = node->data;
+    auto path = static_cast<GtkTreePath*>(node->data);
     save_del_path = gtk_tree_path_copy (path);
 
     gtk_tree_path_next (path);
@@ -1376,7 +1378,7 @@ gnc_ui_reconcile_window_delete_cb (GSimpleAction *simple,
                                    GVariant      *parameter,
                                    gpointer       user_data)
 {
-    RecnWindow *recnData = user_data;
+    auto recnData = static_cast<RecnWindow*>(user_data);
     Transaction *trans;
     Split *split;
 
@@ -1413,7 +1415,7 @@ gnc_ui_reconcile_window_edit_cb (GSimpleAction *simple,
                                  GVariant      *parameter,
                                  gpointer       user_data)
 {
-    RecnWindow *recnData = user_data;
+    auto recnData = static_cast<RecnWindow*>(user_data);
     GNCSplitReg *gsr;
     Split *split;
 
@@ -1467,7 +1469,7 @@ gnc_recn_edit_account_cb (GSimpleAction *simple,
                           GVariant      *parameter,
                           gpointer       user_data)
 {
-    RecnWindow *recnData = user_data;
+    auto recnData = static_cast<RecnWindow*>(user_data);
     Account *account = recn_get_account (recnData);
 
     if (account == NULL)
@@ -1482,7 +1484,7 @@ gnc_recn_xfer_cb (GSimpleAction *simple,
                   GVariant      *parameter,
                   gpointer       user_data)
 {
-    RecnWindow *recnData = user_data;
+    auto recnData = static_cast<RecnWindow*>(user_data);
     Account *account = recn_get_account (recnData);
 
     if (account == NULL)
@@ -1497,7 +1499,7 @@ gnc_recn_scrub_cb (GSimpleAction *simple,
                    GVariant      *parameter,
                    gpointer       user_data)
 {
-    RecnWindow *recnData = user_data;
+    auto recnData = static_cast<RecnWindow*>(user_data);
     Account *account = recn_get_account (recnData);
 
     if (account == NULL)
@@ -1521,7 +1523,7 @@ gnc_recn_open_cb (GSimpleAction *simple,
                   GVariant      *parameter,
                   gpointer       user_data)
 {
-    RecnWindow *recnData = user_data;
+    auto recnData = static_cast<RecnWindow*>(user_data);
 
     gnc_reconcile_window_open_register(recnData);
 }
@@ -1597,8 +1599,8 @@ gnc_get_reconcile_info (Account *account,
 static gboolean
 find_by_account (gpointer find_data, gpointer user_data)
 {
-    Account *account = find_data;
-    RecnWindow *recnData = user_data;
+    auto account = GNC_ACCOUNT(find_data);
+    auto recnData = static_cast<RecnWindow*>(user_data);
 
     if (!recnData)
         return FALSE;
@@ -1612,7 +1614,6 @@ recn_set_watches_one_account (gpointer data, gpointer user_data)
 {
     Account *account = (Account *)data;
     RecnWindow *recnData = (RecnWindow *)user_data;
-    GList *node;
 
     /* add a watch on the account */
     gnc_gui_component_watch_entity (recnData->component_id,
@@ -1620,9 +1621,10 @@ recn_set_watches_one_account (gpointer data, gpointer user_data)
                                     QOF_EVENT_MODIFY | QOF_EVENT_DESTROY);
 
     /* add a watch on each unreconciled or cleared split for the account */
-    for (node = xaccAccountGetSplitList (account); node; node = node->next)
+    GList *splits = xaccAccountGetSplitList (account);
+    for (GList *node = splits; node; node = node->next)
     {
-        Split *split = node->data;
+        auto split = GNC_SPLIT(node->data);
         Transaction *trans;
         char recn;
 
@@ -1674,7 +1676,7 @@ recn_set_watches (RecnWindow *recnData)
 static void
 refresh_handler (GHashTable *changes, gpointer user_data)
 {
-    RecnWindow *recnData = user_data;
+    auto recnData = static_cast<RecnWindow*>(user_data);
     const EventInfo *info;
     Account *account;
 
@@ -1705,7 +1707,7 @@ refresh_handler (GHashTable *changes, gpointer user_data)
 static void
 close_handler (gpointer user_data)
 {
-    RecnWindow *recnData = user_data;
+    auto recnData = static_cast<RecnWindow*>(user_data);
 
     gnc_save_window_size(GNC_PREFS_GROUP_RECONCILE, GTK_WINDOW(recnData->window));
     gtk_widget_destroy (recnData->window);
@@ -1812,8 +1814,8 @@ recnWindowWithBalance (GtkWidget *parent, Account *account, gnc_numeric new_endi
     if (account == NULL)
         return NULL;
 
-    recnData = gnc_find_first_gui_component (WINDOW_RECONCILE_CM_CLASS,
-               find_by_account, account);
+    recnData = static_cast<RecnWindow*>(gnc_find_first_gui_component (WINDOW_RECONCILE_CM_CLASS,
+                                                                      find_by_account, account));
     if (recnData)
         return recnData;
 
@@ -1878,7 +1880,7 @@ recnWindowWithBalance (GtkWidget *parent, Account *account, gnc_numeric new_endi
         menu_bar = gtk_menu_bar_new_from_model (menu_model);
         gtk_container_add (GTK_CONTAINER(vbox), menu_bar);
 #ifdef MAC_INTEGRATION
-        GtkosxApplication *theApp = g_object_new (GTKOSX_TYPE_APPLICATION, NULL);
+        auto theApp = static_cast<GtkosxApplication*>(g_object_new (GTKOSX_TYPE_APPLICATION, NULL));
         gtk_widget_hide (menu_bar);
         gtk_widget_set_no_show_all (menu_bar, TRUE);
         if (GTK_IS_MENU_ITEM (menu_bar))
@@ -1940,10 +1942,11 @@ recnWindowWithBalance (GtkWidget *parent, Account *account, gnc_numeric new_endi
         GtkWidget *box = gtk_statusbar_get_message_area (bar);
         GtkWidget *image = gtk_image_new_from_icon_name
             ("dialog-warning", GTK_ICON_SIZE_SMALL_TOOLBAR);
+        GList *splits = xaccAccountGetSplitList (account);
 
-        for (GList *n = xaccAccountGetSplitList (account); n; n = n->next)
+        for (GList *n = splits; n; n = n->next)
         {
-            Split* split = n->data;
+            auto split = GNC_SPLIT(n->data);
             time64 recn_date = xaccSplitGetDateReconciled (split);
             gchar *datestr, *recnstr;
             if ((xaccSplitGetReconcile (split) != YREC) ||
@@ -2177,7 +2180,7 @@ gnc_ui_reconcile_window_get_window (RecnWindow * recnData)
 static void
 recn_destroy_cb (GtkWidget *w, gpointer data)
 {
-    RecnWindow *recnData = data;
+    auto recnData = static_cast<RecnWindow*>(data);
     gchar **actions = g_action_group_list_actions (G_ACTION_GROUP(recnData->simple_action_group));
     gint num_actions = g_strv_length (actions);
 
@@ -2222,7 +2225,7 @@ recn_cancel(RecnWindow *recnData)
 static gboolean
 recn_delete_cb(GtkWidget *widget, GdkEvent *event, gpointer data)
 {
-    RecnWindow *recnData = data;
+    auto recnData = static_cast<RecnWindow*>(data);
 
     recn_cancel(recnData);
     return TRUE;
@@ -2232,7 +2235,7 @@ recn_delete_cb(GtkWidget *widget, GdkEvent *event, gpointer data)
 static gboolean
 recn_key_press_cb(GtkWidget *widget, GdkEventKey *event, gpointer data)
 {
-    RecnWindow *recnData = data;
+    auto recnData = static_cast<RecnWindow*>(data);
 
     if (event->keyval == GDK_KEY_Escape)
     {
@@ -2258,22 +2261,19 @@ recn_key_press_cb(GtkWidget *widget, GdkEventKey *event, gpointer data)
 static Account *
 find_payment_account(Account *account)
 {
-    GList *list;
-    GList *node;
-
     if (account == NULL)
         return NULL;
 
-    list = xaccAccountGetSplitList (account);
+    GList *list = xaccAccountGetSplitList (account);
+    Account *rv = nullptr;
 
     /* Search backwards to find the latest payment */
-    for (node = g_list_last (list); node; node = node->prev)
+    for (GList *node = g_list_last (list); !rv && node; node = node->prev)
     {
         Transaction *trans;
-        Split *split;
         GList *n;
 
-        split = node->data;
+        auto split = GNC_SPLIT(node->data);
         if (split == NULL)
             continue;
 
@@ -2289,9 +2289,8 @@ find_payment_account(Account *account)
         {
             GNCAccountType type;
             Account *a;
-            Split *s;
 
-            s = n->data;
+            auto s = GNC_SPLIT(n->data);
             if ((s == NULL) || (s == split))
                 continue;
 
@@ -2302,11 +2301,11 @@ find_payment_account(Account *account)
             type = xaccAccountGetType(a);
             if ((type == ACCT_TYPE_BANK) || (type == ACCT_TYPE_CASH) ||
                     (type == ACCT_TYPE_ASSET))
-                return a;
+                rv = a;
         }
     }
 
-    return NULL;
+    return rv;
 }
 
 typedef void (*AccountProc) (Account *a);
@@ -2320,7 +2319,7 @@ acct_traverse_descendants (Account *acct, AccountProc fn)
 {
     fn (acct);
     if (xaccAccountGetReconcileChildrenStatus (acct))
-        gnc_account_foreach_descendant (acct, (AccountCb)traverse_fn, fn);
+        gnc_account_foreach_descendant (acct, (AccountCb)traverse_fn, (gpointer)fn);
 }
 
 /********************************************************************\
@@ -2336,7 +2335,7 @@ recnFinishCB (GSimpleAction *simple,
               GVariant      *parameter,
               gpointer       user_data)
 {
-    RecnWindow *recnData = user_data;
+    auto recnData = static_cast<RecnWindow*>(user_data);
     gboolean auto_payment;
     Account *account;
     time64 date;
@@ -2399,7 +2398,7 @@ recnPostponeCB (GSimpleAction *simple,
                 GVariant      *parameter,
                 gpointer       user_data)
 {
-    RecnWindow *recnData = user_data;
+    auto recnData = static_cast<RecnWindow*>(user_data);
     Account *account;
 
     {
@@ -2431,6 +2430,6 @@ recnCancelCB (GSimpleAction *simple,
               GVariant      *parameter,
               gpointer       user_data)
 {
-    RecnWindow *recnData = user_data;
+    auto recnData = static_cast<RecnWindow*>(user_data);
     recn_cancel(recnData);
 }
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 05bf6aeb09..3f0bfe91fb 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -112,7 +112,7 @@ gnucash/gnome/report-menus.scm
 gnucash/gnome/search-owner.c
 gnucash/gnome/top-level.c
 gnucash/gnome/window-autoclear.c
-gnucash/gnome/window-reconcile.c
+gnucash/gnome/window-reconcile.cpp
 gnucash/gnome/window-report.cpp
 gnucash/gnome-search/dialog-search.c
 gnucash/gnome-search/gnc-general-search.c

commit 957b6e3afafbf1f37195e363c87dde7d27ace43d
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Mon Apr 15 22:01:31 2024 +0800

    [register/*.h] add extern "C" {} wrappers

diff --git a/gnucash/register/ledger-core/split-register-control.h b/gnucash/register/ledger-core/split-register-control.h
index fd23b27e83..dbfe43e1d6 100644
--- a/gnucash/register/ledger-core/split-register-control.h
+++ b/gnucash/register/ledger-core/split-register-control.h
@@ -23,6 +23,10 @@
 #ifndef SPLIT_REGISTER_CONTROL_H
 #define SPLIT_REGISTER_CONTROL_H
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #include "table-control.h"
 /** @addtogroup SplitRegister
  *  @{
@@ -32,5 +36,10 @@
 
 /** Create a new TableControl specialized for the SplitRegister. */
 TableControl * gnc_split_register_control_new (void);
+
+#ifdef __cplusplus
+}
+#endif
+
 /** @} */
 #endif
diff --git a/gnucash/register/ledger-core/split-register-model-save.h b/gnucash/register/ledger-core/split-register-model-save.h
index e0dd41134f..500391e873 100644
--- a/gnucash/register/ledger-core/split-register-model-save.h
+++ b/gnucash/register/ledger-core/split-register-model-save.h
@@ -23,6 +23,10 @@
 #ifndef SPLIT_REGISTER_MODEL_SAVE_H
 #define SPLIT_REGISTER_MODEL_SAVE_H
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #include "Transaction.h"
 #include "table-model.h"
 
@@ -44,5 +48,9 @@ SRSaveData * gnc_split_register_save_data_new (Transaction *trans,
 
 void gnc_split_register_save_data_destroy (SRSaveData *sd);
 
+#ifdef __cplusplus
+}
+#endif
+
 /** @} */
 #endif
diff --git a/gnucash/register/ledger-core/split-register-p.h b/gnucash/register/ledger-core/split-register-p.h
index 276f2a7c6e..13b18a15bc 100644
--- a/gnucash/register/ledger-core/split-register-p.h
+++ b/gnucash/register/ledger-core/split-register-p.h
@@ -23,6 +23,10 @@
 #ifndef SPLIT_REGISTER_P_H
 #define SPLIT_REGISTER_P_H
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #include "split-register.h"
 
 /** @addtogroup SplitRegister
@@ -209,5 +213,9 @@ gboolean gnc_split_register_split_needs_amount(
 gboolean gnc_split_register_needs_conv_rate(
     SplitRegister *reg, Transaction *txn, Account *acc);
 
+#ifdef __cplusplus
+}
+#endif
+
 /** @} */
 #endif
diff --git a/gnucash/register/register-core/basiccell.h b/gnucash/register/register-core/basiccell.h
index 3ffa72af8c..50884141f5 100644
--- a/gnucash/register/register-core/basiccell.h
+++ b/gnucash/register/register-core/basiccell.h
@@ -157,6 +157,10 @@
 #ifndef BASIC_CELL_H
 #define BASIC_CELL_H
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #include <gdk/gdk.h>
 #include <glib.h>
 #include <gtk/gtk.h>
@@ -285,5 +289,9 @@ char * gnc_basic_cell_validate (BasicCell *bcell,
                                 const char *toks,
                                 gint *cursor_position);
 
+#ifdef __cplusplus
+}
+#endif
+
 /** @} @} */
 #endif /* BASIC_CELL_H */
diff --git a/gnucash/register/register-core/combocell.h b/gnucash/register/register-core/combocell.h
index ceeb7b7dd0..90a108de61 100644
--- a/gnucash/register/register-core/combocell.h
+++ b/gnucash/register/register-core/combocell.h
@@ -40,6 +40,10 @@
 #ifndef COMBO_CELL_H
 #define COMBO_CELL_H
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #include <glib.h>
 
 #include "basiccell.h"
@@ -104,5 +108,9 @@ void gnc_combo_cell_use_quickfill_cache (ComboCell* cell,
                                          QuickFill* shared_qf);
 void gnc_combo_cell_use_list_store_cache (ComboCell* cell, gpointer data);
 
+#ifdef __cplusplus
+}
+#endif
+
 /** @} */
 #endif
diff --git a/gnucash/register/register-core/datecell.h b/gnucash/register/register-core/datecell.h
index 10ed419117..68f5de6864 100644
--- a/gnucash/register/register-core/datecell.h
+++ b/gnucash/register/register-core/datecell.h
@@ -78,6 +78,10 @@
 #ifndef DATE_CELL_H
 #define DATE_CELL_H
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #include <time.h>
 
 #include "basiccell.h"
@@ -127,5 +131,9 @@ void        gnc_date_cell_commit (DateCell *cell);
  */
 void        gnc_date_cell_get_date (DateCell *cell, time64 *time, gboolean warn);
 
+#ifdef __cplusplus
+}
+#endif
+
 /** @} */
 #endif
diff --git a/gnucash/register/register-core/pricecell.h b/gnucash/register/register-core/pricecell.h
index 47025ec79f..6897c5e635 100644
--- a/gnucash/register/register-core/pricecell.h
+++ b/gnucash/register/register-core/pricecell.h
@@ -43,6 +43,10 @@
 #ifndef PRICE_CELL_H
 #define PRICE_CELL_H
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #include "basiccell.h"
 #include "qof.h"
 #include "gnc-ui-util.h"
@@ -87,5 +91,10 @@ void         gnc_price_cell_set_print_info (PriceCell *cell,
 void         gnc_price_cell_set_debt_credit_value (PriceCell *debit,
         PriceCell *credit,
         gnc_numeric amount);
+
+#ifdef __cplusplus
+}
+#endif
+
 /** @} */
 #endif
diff --git a/gnucash/register/register-core/table-control.h b/gnucash/register/register-core/table-control.h
index 2600915107..1062394714 100644
--- a/gnucash/register/register-core/table-control.h
+++ b/gnucash/register/register-core/table-control.h
@@ -23,6 +23,10 @@
 #ifndef TABLE_CONTROL_H
 #define TABLE_CONTROL_H
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #include "register-common.h"
 
 /** @addtogroup Table Table
@@ -65,5 +69,9 @@ void gnc_table_control_destroy (TableControl *control);
 void gnc_table_control_allow_move (TableControl *control,
                                    gboolean allow_move);
 
+#ifdef __cplusplus
+}
+#endif
+
 /** @} */
 #endif



Summary of changes:
 gnucash/gnome-utils/gnc-autoclear.c                |  3 +-
 gnucash/gnome/CMakeLists.txt                       |  2 +-
 .../{window-reconcile.c => window-reconcile.cpp}   | 95 +++++++++++-----------
 gnucash/register/ledger-core/CMakeLists.txt        |  2 +-
 ...gister-control.c => split-register-control.cpp} | 27 +++---
 .../register/ledger-core/split-register-control.h  |  9 ++
 .../ledger-core/split-register-model-save.h        |  8 ++
 gnucash/register/ledger-core/split-register-p.h    |  8 ++
 gnucash/register/register-core/basiccell.h         |  8 ++
 gnucash/register/register-core/combocell.h         |  8 ++
 gnucash/register/register-core/datecell.h          |  8 ++
 gnucash/register/register-core/pricecell.h         |  9 ++
 gnucash/register/register-core/table-control.h     |  8 ++
 libgnucash/engine/SX-book.c                        |  4 +-
 po/POTFILES.in                                     |  4 +-
 15 files changed, 134 insertions(+), 69 deletions(-)
 rename gnucash/gnome/{window-reconcile.c => window-reconcile.cpp} (97%)
 rename gnucash/register/ledger-core/{split-register-control.c => split-register-control.cpp} (99%)



More information about the gnucash-changes mailing list