From b133654755c854346d9a8598c426cc44fd2048db Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Fri, 11 Oct 2024 11:21:56 +0100 Subject: [PATCH] Realign source file split-register-control.cpp for spaces --- .../ledger-core/split-register-control.cpp | 753 +++++++++--------- 1 file changed, 376 insertions(+), 377 deletions(-) diff --git a/gnucash/register/ledger-core/split-register-control.cpp b/gnucash/register/ledger-core/split-register-control.cpp index 9b821bb89eb..8afa75915d2 100644 --- a/gnucash/register/ledger-core/split-register-control.cpp +++ b/gnucash/register/ledger-core/split-register-control.cpp @@ -1,5 +1,5 @@ /********************************************************************\ - * split-register-control.c -- split register control object * + * split-register-control.cpp -- split register control object * * Copyright (C) 2017 Aaron Laws * * * * This program is free software; you can redistribute it and/or * @@ -50,20 +50,20 @@ static QofLogModule log_module = GNC_MOD_LEDGER; static inline bool -check_imbalance_fraction (const SplitRegister* reg, - const gnc_monetary* imbal_mon, - const Transaction* trans) +check_imbalance_fraction (const SplitRegister *reg, + const gnc_monetary *imbal_mon, + const Transaction *trans) { - auto commodity_fraction{gnc_commodity_get_fraction (imbal_mon->commodity)}; + auto commodity_fraction {gnc_commodity_get_fraction (imbal_mon->commodity)}; auto denom_diff = imbal_mon->value.denom > commodity_fraction; if (!denom_diff) { const auto imbal_comm = imbal_mon->commodity; - for (auto node = xaccTransGetSplitList(trans); node; - node = g_list_next(node)) + for (auto node = xaccTransGetSplitList (trans); node; + node = g_list_next (node)) { - auto acc = xaccSplitGetAccount(GNC_SPLIT (node->data)); - if (xaccAccountGetCommodity(acc) == imbal_comm && + auto acc = xaccSplitGetAccount (GNC_SPLIT(node->data)); + if (xaccAccountGetCommodity (acc) == imbal_comm && imbal_mon->value.denom > xaccAccountGetCommoditySCU (acc)) { denom_diff = true; @@ -73,8 +73,11 @@ check_imbalance_fraction (const SplitRegister* reg, } if (denom_diff) - gnc_error_dialog(gnc_ui_get_main_window(GTK_WIDGET(reg)), "%s", _("This transaction cannot be balanced: The imbalance is a fraction smaller than the commodity allows.")); - + { + gnc_error_dialog (gnc_ui_get_main_window (GTK_WIDGET(reg)), + "%s", + _("This transaction cannot be balanced: The imbalance is a fraction smaller than the commodity allows.")); + } return denom_diff; } @@ -86,7 +89,7 @@ gnc_split_register_balance_trans (SplitRegister *reg, Transaction *trans) Account *default_account; Account *other_account; Account *root; - GList *radio_list = NULL; + GList *radio_list = nullptr; const char *title = _("Rebalance Transaction"); const char *message = _("The current transaction is not balanced."); Split *split; @@ -94,9 +97,8 @@ gnc_split_register_balance_trans (SplitRegister *reg, Transaction *trans) gboolean two_accounts; gboolean multi_currency; - if (xaccTransIsBalanced (trans)) - return FALSE; + return false; if (xaccTransUseTradingAccounts (trans)) { @@ -109,46 +111,48 @@ gnc_split_register_balance_trans (SplitRegister *reg, Transaction *trans) /* Value imbalance, but not commodity imbalance. This shouldn't be something that scrubbing can cause to happen. Perhaps someone entered invalid splits. */ - multi_currency = TRUE; + multi_currency = true; else { imbal_mon = static_cast(imbal_list->data); if (!imbal_list->next && - gnc_commodity_equiv(gnc_monetary_commodity(*imbal_mon), - xaccTransGetCurrency(trans))) - multi_currency = FALSE; + gnc_commodity_equiv (gnc_monetary_commodity (*imbal_mon), + xaccTransGetCurrency (trans))) + multi_currency = false; else - multi_currency = TRUE; + multi_currency = true; if (multi_currency && check_imbalance_fraction (reg, imbal_mon, trans)) - return FALSE; + return false; } /* We're done with the imbalance list, the real work will be done by xaccTransScrubImbalance which will get it again. */ - gnc_monetary_list_free(imbal_list); + gnc_monetary_list_free (imbal_list); } else - multi_currency = FALSE; + multi_currency = false; split = xaccTransGetSplit (trans, 0); other_split = xaccSplitGetOtherSplit (split); - if (other_split == NULL) + if (other_split == nullptr) { /* Attempt to handle the inverted many-to-one mapping */ split = xaccTransGetSplit (trans, 1); - if (split) other_split = xaccSplitGetOtherSplit (split); - else split = xaccTransGetSplit (trans, 0); + if (split) + other_split = xaccSplitGetOtherSplit (split); + else + split = xaccTransGetSplit (trans, 0); } - if (other_split == NULL || multi_currency) + if (other_split == nullptr || multi_currency) { - two_accounts = FALSE; - other_account = NULL; + two_accounts = false; + other_account = nullptr; } else { - two_accounts = TRUE; + two_accounts = true; other_account = xaccSplitGetAccount (other_split); } @@ -166,7 +170,7 @@ gnc_split_register_balance_trans (SplitRegister *reg, Transaction *trans) * object. */ if (default_account == other_account) - two_accounts = FALSE; + two_accounts = false; radio_list = g_list_append (radio_list, _("Balance it _manually")); @@ -189,17 +193,16 @@ gnc_split_register_balance_trans (SplitRegister *reg, Transaction *trans) else default_value = 0; - choice = gnc_choose_radio_option_dialog - (gnc_split_register_get_parent (reg), - title, - message, - _("_Rebalance"), - default_value, - radio_list); + choice = gnc_choose_radio_option_dialog (gnc_split_register_get_parent (reg), + title, + message, + _("_Rebalance"), + default_value, + radio_list); g_list_free (radio_list); - root = default_account ? gnc_account_get_root(default_account) : NULL; + root = default_account ? gnc_account_get_root (default_account) : nullptr; switch (choice) { default: @@ -207,7 +210,7 @@ gnc_split_register_balance_trans (SplitRegister *reg, Transaction *trans) break; case 1: - xaccTransScrubImbalance (trans, root, NULL); + xaccTransScrubImbalance (trans, root, nullptr); break; case 2: @@ -219,7 +222,7 @@ gnc_split_register_balance_trans (SplitRegister *reg, Transaction *trans) break; } - return TRUE; + return true; } static gboolean @@ -230,19 +233,19 @@ gnc_split_register_old_split_empty_p (SplitRegister *reg, Split *split) const char *string; string = gnc_table_layout_get_cell_value (reg->table->layout, MEMO_CELL); - if ((string != NULL) && (*string != '\0')) - return FALSE; + if ((string != nullptr) && (*string != '\0')) + return false; string = gnc_table_layout_get_cell_value (reg->table->layout, XFRM_CELL); - if ((string != NULL) && (*string != '\0')) - return FALSE; + if ((string != nullptr) && (*string != '\0')) + return false; cell = gnc_table_layout_get_cell (reg->table->layout, CRED_CELL); if (cell) { amount = gnc_price_cell_get_value ((PriceCell *) cell); if (!gnc_numeric_zero_p (amount)) - return FALSE; + return false; } cell = gnc_table_layout_get_cell (reg->table->layout, DEBT_CELL); @@ -250,10 +253,10 @@ gnc_split_register_old_split_empty_p (SplitRegister *reg, Split *split) { amount = gnc_price_cell_get_value ((PriceCell *) cell); if (!gnc_numeric_zero_p (amount)) - return FALSE; + return false; } - return TRUE; + return true; } /* Checks a cell for a debit or credit change to see if a new exchange @@ -265,15 +268,15 @@ gnc_split_register_check_debcred (SplitRegister *reg, { if ((gnc_cell_name_equal (cell_name, DEBT_CELL) && gnc_table_layout_get_cell_changed (reg->table->layout, - DEBT_CELL, FALSE)) || + DEBT_CELL, false)) || (gnc_cell_name_equal (cell_name, CRED_CELL) && gnc_table_layout_get_cell_changed (reg->table->layout, - CRED_CELL, FALSE))) + CRED_CELL, false))) { SRInfo *info = gnc_split_register_get_info (reg); PriceCell *rate_cell = (PriceCell *) gnc_table_layout_get_cell (reg->table->layout, - RATE_CELL); - if (gnc_split_reg_has_rate_cell(reg->type) && info->rate_reset != RATE_RESET_DONE) + RATE_CELL); + if (gnc_split_reg_has_rate_cell (reg->type) && info->rate_reset != RATE_RESET_DONE) { /* Debit or credit amount changed, get a new exchange rate */ info->rate_reset = RATE_RESET_REQD; @@ -286,7 +289,7 @@ gnc_split_register_check_debcred (SplitRegister *reg, } } - return TRUE; + return true; } /* Checks a cell for an account change and takes any necessary action if @@ -296,31 +299,31 @@ gnc_split_register_check_account (SplitRegister *reg, const char *cell_name) { SRInfo *info; - ComboCell *cell = NULL; + ComboCell *cell = nullptr; Account* new_acct; Split *split; char *name; - g_return_val_if_fail(reg, TRUE); + g_return_val_if_fail (reg, true); /* See if we are leaving an account field */ if (gnc_cell_name_equal (cell_name, XFRM_CELL)) { if (gnc_table_layout_get_cell_changed (reg->table->layout, - XFRM_CELL, FALSE)) + XFRM_CELL, false)) cell = (ComboCell *) gnc_table_layout_get_cell (reg->table->layout, - XFRM_CELL); + XFRM_CELL); } else if (gnc_cell_name_equal (cell_name, MXFRM_CELL)) { if (gnc_table_layout_get_cell_changed (reg->table->layout, - MXFRM_CELL, FALSE)) + MXFRM_CELL, false)) cell = (ComboCell *) gnc_table_layout_get_cell (reg->table->layout, - MXFRM_CELL); + MXFRM_CELL); } if (!cell) - return TRUE; + return true; /* The account has been changed. */ name = cell->cell.value; @@ -328,40 +331,40 @@ gnc_split_register_check_account (SplitRegister *reg, if (!name || *name == '\0' || g_strcmp0 (name, SPLIT_TRANS_STR) == 0 || g_strcmp0 (name, STOCK_SPLIT_STR) == 0) - return TRUE; + return true; /* Create the account if necessary. Also checks for a placeholder. */ info = gnc_split_register_get_info (reg); new_acct = gnc_split_register_get_account_by_name (reg, - (BasicCell *) cell, - cell->cell.value); + (BasicCell *) cell, + cell->cell.value); if (!new_acct) - return FALSE; + return false; - split = gnc_split_register_get_current_split(reg); + split = gnc_split_register_get_current_split (reg); gnc_split_register_set_cell_fractions (reg, split); /* See if we need to reset the exchange rate. */ - if (gnc_split_reg_has_rate_cell(reg->type)) + if (gnc_split_reg_has_rate_cell (reg->type)) { - PriceCell *rate_cell = (PriceCell *) gnc_table_layout_get_cell (reg->table->layout, - RATE_CELL); - Account *orig_acct = xaccSplitGetAccount(split); - gnc_commodity *orig_com = xaccAccountGetCommodity(orig_acct); - gnc_commodity *last_com = xaccAccountGetCommodity(info->rate_account); - gnc_commodity *new_com = xaccAccountGetCommodity(new_acct); + PriceCell *rate_cell = (PriceCell *) gnc_table_layout_get_cell (reg->table->layout, + RATE_CELL); + Account *orig_acct = xaccSplitGetAccount (split); + gnc_commodity *orig_com = xaccAccountGetCommodity (orig_acct); + gnc_commodity *last_com = xaccAccountGetCommodity (info->rate_account); + gnc_commodity *new_com = xaccAccountGetCommodity (new_acct); - if (gnc_commodity_equal(last_com ? last_com : orig_com, new_com)) + if (gnc_commodity_equal (last_com ? last_com : orig_com, new_com)) { DEBUG("Commodity is still %s. Leaving rate unchanged.", - new_com ? gnc_commodity_get_mnemonic(new_com) : "NULL"); + new_com ? gnc_commodity_get_mnemonic (new_com) : "NULL"); } - else if (!gnc_commodity_equal(orig_com, new_com)) + else if (!gnc_commodity_equal (orig_com, new_com)) { /* The commodity has changed but is not the original. Reset the rate. */ DEBUG("Commodity now %s (originally %s). Clearing rate.", - new_com ? gnc_commodity_get_mnemonic(new_com) : "NULL", - orig_com ? gnc_commodity_get_mnemonic(orig_com) : "NULL"); + new_com ? gnc_commodity_get_mnemonic (new_com) : "NULL", + orig_com ? gnc_commodity_get_mnemonic (orig_com) : "NULL"); gnc_price_cell_set_value (rate_cell, gnc_numeric_zero()); info->rate_account = new_acct; @@ -370,15 +373,14 @@ gnc_split_register_check_account (SplitRegister *reg, else { /* Get the original rate from the split. */ - gnc_numeric amt = xaccSplitGetAmount(split); - gnc_numeric val = xaccSplitGetValue(split); - gnc_numeric orig_rate = gnc_numeric_div(amt, val, GNC_DENOM_AUTO, - GNC_HOW_DENOM_REDUCE); + gnc_numeric amt = xaccSplitGetAmount (split); + gnc_numeric val = xaccSplitGetValue (split); + gnc_numeric orig_rate = gnc_numeric_div (amt, val, GNC_DENOM_AUTO, + GNC_HOW_DENOM_REDUCE); - if (!gnc_numeric_check(orig_rate)) + if (!gnc_numeric_check (orig_rate)) { - DEBUG("Using original rate of %s.", - gnc_num_dbg_to_string(orig_rate)); + DEBUG("Using original rate of %s.", gnc_num_dbg_to_string (orig_rate)); gnc_price_cell_set_value (rate_cell, orig_rate); info->rate_account = new_acct; info->rate_reset = RATE_RESET_NOT_REQD; @@ -393,14 +395,14 @@ gnc_split_register_check_account (SplitRegister *reg, } } - return TRUE; + return true; } static inline bool -is_trading_split (Split* split) +is_trading_split (Split *split) { auto acct{xaccSplitGetAccount (split)}; - return GNC_IS_ACCOUNT (acct) && xaccAccountGetType (acct) == ACCT_TYPE_TRADING; + return GNC_IS_ACCOUNT(acct) && xaccAccountGetType (acct) == ACCT_TYPE_TRADING; } static void @@ -424,10 +426,9 @@ gnc_split_register_move_cursor (VirtualLocation *p_new_virt_loc, gboolean saved; SRInfo *info; - ENTER("reg=%p, p_new_virt_loc=%p (%d, %d)", - reg, p_new_virt_loc, - new_virt_loc.vcell_loc.virt_row, - new_virt_loc.vcell_loc.virt_col); + ENTER("reg=%p, p_new_virt_loc=%p (%d, %d)", reg, p_new_virt_loc, + new_virt_loc.vcell_loc.virt_row, + new_virt_loc.vcell_loc.virt_col); if (!reg) { @@ -442,7 +443,7 @@ gnc_split_register_move_cursor (VirtualLocation *p_new_virt_loc, old_split = s; old_trans = gnc_split_register_get_current_trans (reg); if (auto s{gnc_split_register_get_current_trans_split (reg, &old_trans_split_loc)}; - !is_trading_split(s)) + !is_trading_split (s)) old_trans_split = s; old_class = gnc_split_register_get_current_cursor_class (reg); @@ -454,10 +455,10 @@ gnc_split_register_move_cursor (VirtualLocation *p_new_virt_loc, if (old_class == CURSOR_CLASS_SPLIT) new_trans = old_trans; else - new_trans = NULL; + new_trans = nullptr; - new_split = NULL; - new_trans_split = NULL; + new_split = nullptr; + new_trans_split = nullptr; new_class = CURSOR_CLASS_NONE; } else if (!info->hint_set_by_traverse) @@ -469,11 +470,12 @@ gnc_split_register_move_cursor (VirtualLocation *p_new_virt_loc, new_split = gnc_split_register_get_split (reg, new_virt_loc.vcell_loc); /* The split at the transaction line we are moving to */ - new_trans_split = gnc_split_register_get_trans_split - (reg, new_virt_loc.vcell_loc, NULL); + new_trans_split = gnc_split_register_get_trans_split (reg, + new_virt_loc.vcell_loc, + nullptr); new_class = gnc_split_register_get_cursor_class (reg, - new_virt_loc.vcell_loc); + new_virt_loc.vcell_loc); } else { @@ -483,8 +485,8 @@ gnc_split_register_move_cursor (VirtualLocation *p_new_virt_loc, new_class = info->cursor_hint_cursor_class; } - info->hint_set_by_traverse = FALSE; - info->reg_loaded = FALSE; + info->hint_set_by_traverse = false; + info->reg_loaded = false; gnc_suspend_gui_refresh (); @@ -499,14 +501,14 @@ gnc_split_register_move_cursor (VirtualLocation *p_new_virt_loc, if ((old_class == CURSOR_CLASS_SPLIT) && old_split && (old_split != new_split) && - gnc_split_register_old_split_empty_p(reg, old_split)) + gnc_split_register_old_split_empty_p (reg, old_split)) { if (old_split != gnc_split_register_get_blank_split (reg)) { int current_row; - xaccSplitDestroy(old_split); - old_split = NULL; + xaccSplitDestroy (old_split); + old_split = nullptr; /* * If the user is moving down a row, we've just thrown off the @@ -517,7 +519,7 @@ gnc_split_register_move_cursor (VirtualLocation *p_new_virt_loc, new_virt_loc.vcell_loc.virt_row--; } } - else if ((pending_trans != NULL) && + else if ((pending_trans != nullptr) && (pending_trans == old_trans) && (pending_trans != blank_trans) && (old_trans != new_trans)) @@ -537,15 +539,15 @@ gnc_split_register_move_cursor (VirtualLocation *p_new_virt_loc, info->pending_trans_guid = *guid_null (); if (xaccTransIsOpen (pending_trans)) xaccTransCommitEdit (pending_trans); - else g_assert_not_reached(); + else g_assert_not_reached (); - pending_trans = NULL; - saved = TRUE; + pending_trans = nullptr; + saved = true; } } else if (old_trans && (old_trans != new_trans) && - !xaccTransHasReconciledSplits(old_trans) && + !xaccTransHasReconciledSplits (old_trans) && !info->first_pass && gnc_split_register_balance_trans (reg, old_trans)) { @@ -567,12 +569,12 @@ gnc_split_register_move_cursor (VirtualLocation *p_new_virt_loc, /* change from split row to trans row */ if (old_class != new_class) - info->change_confirmed = FALSE; + info->change_confirmed = false; if (old_split != new_split) { - info->change_confirmed = FALSE; - info->rate_account = NULL; + info->change_confirmed = false; + info->rate_account = nullptr; info->rate_reset = RATE_RESET_NOT_REQD; } @@ -599,10 +601,11 @@ gnc_split_register_move_cursor (VirtualLocation *p_new_virt_loc, new_trans = gnc_split_register_get_trans (reg, new_virt_loc.vcell_loc); new_split = gnc_split_register_get_split (reg, new_virt_loc.vcell_loc); - new_trans_split = gnc_split_register_get_trans_split( - reg, new_virt_loc.vcell_loc, NULL); + new_trans_split = gnc_split_register_get_trans_split (reg, + new_virt_loc.vcell_loc, + nullptr); new_class = gnc_split_register_get_cursor_class (reg, - new_virt_loc.vcell_loc); + new_virt_loc.vcell_loc); } else if (info->traverse_to_new) { @@ -616,9 +619,8 @@ gnc_split_register_move_cursor (VirtualLocation *p_new_virt_loc, *p_new_virt_loc = new_virt_loc; - PINFO ("after move %d %d\n", - new_virt_loc.vcell_loc.virt_row, - new_virt_loc.vcell_loc.virt_col); + PINFO("after move %d %d", new_virt_loc.vcell_loc.virt_row, + new_virt_loc.vcell_loc.virt_col); /* if the register was reloaded, then everything should be fine :) * otherwise, we may need to change some visibility settings. */ @@ -638,28 +640,28 @@ gnc_split_register_move_cursor (VirtualLocation *p_new_virt_loc, VirtualCellLocation vc_loc; vc_loc = old_trans_split_loc; - gnc_table_set_virt_cell_cursor( - reg->table, vc_loc, gnc_split_register_get_passive_cursor (reg)); - gnc_split_register_set_trans_visible (reg, vc_loc, FALSE, + gnc_table_set_virt_cell_cursor (reg->table, vc_loc, + gnc_split_register_get_passive_cursor (reg)); + gnc_split_register_set_trans_visible (reg, vc_loc, false, reg->style == REG_STYLE_JOURNAL); if ((REG_STYLE_AUTO_LEDGER == reg->style) || - (REG_STYLE_JOURNAL == reg->style)) + (REG_STYLE_JOURNAL == reg->style)) { gnc_split_register_get_trans_split (reg, new_virt_loc.vcell_loc, &vc_loc); - gnc_table_set_virt_cell_cursor - (reg->table, vc_loc, gnc_split_register_get_active_cursor (reg)); - gnc_split_register_set_trans_visible (reg, vc_loc, TRUE, + gnc_table_set_virt_cell_cursor (reg->table, vc_loc, + gnc_split_register_get_active_cursor (reg)); + gnc_split_register_set_trans_visible (reg, vc_loc, true, reg->style == REG_STYLE_JOURNAL); } - info->trans_expanded = FALSE; + info->trans_expanded = false; - do_refresh = TRUE; + do_refresh = true; } else - do_refresh = FALSE; + do_refresh = false; info->cursor_hint_trans = new_trans; info->cursor_hint_split = new_split; @@ -675,7 +677,7 @@ gnc_split_register_move_cursor (VirtualLocation *p_new_virt_loc, { VirtualCellLocation vc_loc; - gnc_table_refresh_gui (reg->table, FALSE); + gnc_table_refresh_gui (reg->table, false); gnc_table_leave_update (reg->table, reg->table->current_cursor_loc); gnc_split_register_get_trans_split (reg, p_new_virt_loc->vcell_loc, @@ -704,7 +706,7 @@ gnc_find_split_in_trans_by_memo (Transaction *trans, const char *memo, return split; } - return NULL; + return nullptr; } static Split * @@ -730,12 +732,12 @@ gnc_find_split_in_reg_by_memo (SplitRegister *reg, const char *memo, Transaction *last_trans; if (!reg || !reg->table) - return NULL; + return nullptr; num_rows = reg->table->num_virt_rows; num_cols = reg->table->num_virt_cols; - last_trans = NULL; + last_trans = nullptr; for (virt_row = num_rows - 1; virt_row >= 0; virt_row--) for (virt_col = num_cols - 1; virt_col >= 0; virt_col--) @@ -751,13 +753,13 @@ gnc_find_split_in_reg_by_memo (SplitRegister *reg, const char *memo, continue; split = gnc_find_split_in_trans_by_memo (trans, memo, unit_price); - if (split != NULL) + if (split != nullptr) return split; last_trans = trans; } - return NULL; + return nullptr; } static Transaction * @@ -768,12 +770,12 @@ gnc_find_trans_in_reg_by_desc (SplitRegister *reg, const char *description) Transaction *last_trans; if (!reg || !reg->table) - return NULL; + return nullptr; num_rows = reg->table->num_virt_rows; num_cols = reg->table->num_virt_cols; - last_trans = NULL; + last_trans = nullptr; for (virt_row = num_rows - 1; virt_row >= 0; virt_row--) for (virt_col = num_cols - 1; virt_col >= 0; virt_col--) @@ -783,7 +785,7 @@ gnc_find_trans_in_reg_by_desc (SplitRegister *reg, const char *description) VirtualCellLocation vcell_loc = { virt_row, virt_col }; split = gnc_split_register_get_split (reg, vcell_loc); - trans = xaccSplitGetParent(split); + trans = xaccSplitGetParent (split); if (trans == last_trans) continue; @@ -794,7 +796,7 @@ gnc_find_trans_in_reg_by_desc (SplitRegister *reg, const char *description) last_trans = trans; } - return NULL; + return nullptr; } /* This function determines if auto-completion is appropriate and, @@ -817,7 +819,7 @@ gnc_split_register_auto_completion (SplitRegister *reg, Split *split; if (!reg->do_auto_complete) - return FALSE; + return false; blank_split = xaccSplitLookup (&info->blank_split_guid, gnc_get_current_book ()); @@ -828,12 +830,12 @@ gnc_split_register_auto_completion (SplitRegister *reg, /* auto-completion is only triggered by a tab out */ if (dir != GNC_TABLE_TRAVERSE_RIGHT) - return FALSE; + return false; split = gnc_split_register_get_current_split (reg); trans = gnc_split_register_get_current_trans (reg); - if (trans == NULL) - return FALSE; + if (trans == nullptr) + return false; cursor_class = gnc_split_register_get_current_cursor_class (reg); cell_name = gnc_table_get_current_cell_name (reg->table); @@ -846,59 +848,59 @@ gnc_split_register_auto_completion (SplitRegister *reg, const char *desc; /* there must be a blank transaction * */ - if (blank_trans == NULL) - return FALSE; + if (blank_trans == nullptr) + return false; /* we must be on the blank split */ if (trans != blank_trans) - return FALSE; + return false; /* and leaving the description cell */ if (!gnc_cell_name_equal (cell_name, DESC_CELL)) - return FALSE; + return false; /* nothing but the date, num, and description should be changed */ /* FIXME, this should be refactored. */ if (gnc_table_layout_get_cell_changed (reg->table->layout, - XFRM_CELL, TRUE) || + XFRM_CELL, true) || gnc_table_layout_get_cell_changed (reg->table->layout, - MXFRM_CELL, TRUE) || + MXFRM_CELL, true) || gnc_table_layout_get_cell_changed (reg->table->layout, - PRIC_CELL, TRUE) || + PRIC_CELL, true) || gnc_table_layout_get_cell_changed (reg->table->layout, - SHRS_CELL, TRUE) || + SHRS_CELL, true) || gnc_table_layout_get_cell_changed (reg->table->layout, - DEBT_CELL, TRUE) || + DEBT_CELL, true) || gnc_table_layout_get_cell_changed (reg->table->layout, - CRED_CELL, TRUE) || + CRED_CELL, true) || gnc_table_layout_get_cell_changed (reg->table->layout, - NOTES_CELL, TRUE) || + NOTES_CELL, true) || gnc_table_layout_get_cell_changed (reg->table->layout, - RECN_CELL, TRUE)) - return FALSE; + RECN_CELL, true)) + return false; /* and the description should be changed */ if (!gnc_table_layout_get_cell_changed (reg->table->layout, - DESC_CELL, TRUE)) - return FALSE; + DESC_CELL, true)) + return false; /* to a non-empty value */ desc = gnc_table_layout_get_cell_value (reg->table->layout, DESC_CELL); - if ((desc == NULL) || (*desc == '\0')) - return FALSE; + if ((desc == nullptr) || (*desc == '\0')) + return false; /* find a transaction to auto-complete on */ - if (gnc_split_register_get_default_account (reg) != NULL) + if (gnc_split_register_get_default_account (reg) != nullptr) { Account *account = gnc_split_register_get_default_account (reg); - auto_trans = xaccAccountFindTransByDesc(account, desc); + auto_trans = xaccAccountFindTransByDesc (account, desc); } else - auto_trans = gnc_find_trans_in_reg_by_desc(reg, desc); + auto_trans = gnc_find_trans_in_reg_by_desc (reg, desc); - if (auto_trans == NULL) - return FALSE; + if (auto_trans == nullptr) + return false; gnc_suspend_gui_refresh (); @@ -908,64 +910,63 @@ gnc_split_register_auto_completion (SplitRegister *reg, /* now perform the completion */ if (pending_trans != trans) { - if (!xaccTransIsOpen(trans)) - xaccTransBeginEdit(trans); + if (!xaccTransIsOpen (trans)) + xaccTransBeginEdit (trans); /* This is now the pending transaction */ - info->pending_trans_guid = *xaccTransGetGUID(trans); - if (pending_trans != NULL) + info->pending_trans_guid = *xaccTransGetGUID (trans); + if (pending_trans != nullptr) { if (xaccTransIsOpen (pending_trans)) xaccTransCommitEdit (pending_trans); - else g_assert_not_reached(); + else g_assert_not_reached (); } } - g_assert(xaccTransIsOpen(trans)); - pending_trans = xaccTransLookup(&info->pending_trans_guid, - gnc_get_current_book ()); - g_assert(pending_trans == trans); - - gnc_copy_trans_onto_trans (auto_trans, trans, FALSE, FALSE); - /* if there is an doclink, let's clear it */ - if (xaccTransGetDocLink (auto_trans) != NULL) + g_assert(xaccTransIsOpen (trans)); + pending_trans = xaccTransLookup (&info->pending_trans_guid, + gnc_get_current_book ()); + g_assert (pending_trans == trans); + + gnc_copy_trans_onto_trans (auto_trans, trans, false, false); + /* if there is a doclink, let's clear it */ + if (xaccTransGetDocLink (auto_trans) != nullptr) xaccTransSetDocLink (trans, ""); - blank_split = NULL; + blank_split = nullptr; - if (gnc_split_register_get_default_account (reg) != NULL) + if (gnc_split_register_get_default_account (reg) != nullptr) { - Account *default_account = - gnc_split_register_get_default_account (reg); - gnc_commodity *trans_cmdty = xaccTransGetCurrency(trans); - gnc_commodity *acct_cmdty = xaccAccountGetCommodity(default_account); - if (gnc_commodity_is_currency(acct_cmdty) && - !gnc_commodity_equal(trans_cmdty, acct_cmdty)) - xaccTransSetCurrency(trans, acct_cmdty); + Account *default_account = gnc_split_register_get_default_account (reg); + gnc_commodity *trans_cmdty = xaccTransGetCurrency (trans); + gnc_commodity *acct_cmdty = xaccAccountGetCommodity (default_account); + if (gnc_commodity_is_currency (acct_cmdty) && + !gnc_commodity_equal (trans_cmdty, acct_cmdty)) + xaccTransSetCurrency (trans, acct_cmdty); for (GList *n = xaccTransGetSplitList (trans); n; n = n->next) { auto s = GNC_SPLIT(n->data); - if (default_account == xaccSplitGetAccount(s)) + if (default_account == xaccSplitGetAccount (s)) { blank_split = s; - info->blank_split_guid = *xaccSplitGetGUID(blank_split); + info->blank_split_guid = *xaccSplitGetGUID (blank_split); break; } } } - if (blank_split == NULL) + if (blank_split == nullptr) { - blank_split = xaccTransGetSplit(trans, 0); - info->blank_split_guid = *xaccSplitGetGUID(blank_split); + blank_split = xaccTransGetSplit (trans, 0); + info->blank_split_guid = *xaccSplitGetGUID (blank_split); } DEBUG("blank_split=%p", blank_split); - info->blank_split_edited = TRUE; + info->blank_split_edited = true; { SRSaveData *sd; - sd = gnc_split_register_save_data_new( - trans, blank_split, gnc_split_register_current_trans_expanded (reg)); + sd = gnc_split_register_save_data_new (trans, blank_split, + gnc_split_register_current_trans_expanded (reg)); gnc_table_save_cells (reg->table, sd); gnc_split_register_save_data_destroy (sd); } @@ -973,14 +974,13 @@ gnc_split_register_auto_completion (SplitRegister *reg, gnc_resume_gui_refresh (); /* now move to the non-empty amount column unless config setting says not */ - if ( !gnc_prefs_get_bool(GNC_PREFS_GROUP_GENERAL_REGISTER, - GNC_PREF_TAB_TRANS_MEMORISED) ) + if (!gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL_REGISTER, + GNC_PREF_TAB_TRANS_MEMORISED)) { amount = xaccSplitGetAmount (blank_split); cell_name = (gnc_numeric_negative_p (amount)) ? CRED_CELL : DEBT_CELL; - if (gnc_table_get_current_cell_location (reg->table, cell_name, - &new_virt_loc)) + if (gnc_table_get_current_cell_location (reg->table, cell_name, &new_virt_loc)) *p_new_virt_loc = new_virt_loc; } } @@ -995,81 +995,81 @@ gnc_split_register_auto_completion (SplitRegister *reg, Split *auto_split; /* we must be on a blank split of a transaction */ - if (split != NULL) - return FALSE; + if (split != nullptr) + return false; /* and leaving the memo cell */ if (!gnc_cell_name_equal (cell_name, MEMO_CELL)) - return FALSE; + return false; /* nothing but the action, memo, and amounts should be changed */ /* FIXME. This should be refactored. */ if (gnc_table_layout_get_cell_changed (reg->table->layout, - XFRM_CELL, TRUE) || + XFRM_CELL, true) || gnc_table_layout_get_cell_changed (reg->table->layout, - MXFRM_CELL, TRUE) || + MXFRM_CELL, true) || gnc_table_layout_get_cell_changed (reg->table->layout, - PRIC_CELL, TRUE) || + PRIC_CELL, true) || gnc_table_layout_get_cell_changed (reg->table->layout, - SHRS_CELL, TRUE) || + SHRS_CELL, true) || gnc_table_layout_get_cell_changed (reg->table->layout, - RECN_CELL, TRUE)) - return FALSE; + RECN_CELL, true)) + return false; /* and the memo should be changed */ if (!gnc_table_layout_get_cell_changed (reg->table->layout, - MEMO_CELL, TRUE)) - return FALSE; + MEMO_CELL, true)) + return false; /* to a non-empty value */ memo = gnc_table_layout_get_cell_value (reg->table->layout, MEMO_CELL); - if ((memo == NULL) || (*memo == '\0')) - return FALSE; + if ((memo == nullptr) || (*memo == '\0')) + return false; /* if there is no price field, only auto-complete from splits with * a unit share price. */ unit_price = !gnc_table_get_current_cell_location (reg->table, - PRIC_CELL, NULL); + PRIC_CELL, nullptr); /* find a split to auto-complete on */ - if (gnc_split_register_get_default_account (reg) != NULL) + if (gnc_split_register_get_default_account (reg) != nullptr) { Account *account = gnc_split_register_get_default_account (reg); auto_split = gnc_find_split_in_account_by_memo (account, memo, - unit_price); + unit_price); } else auto_split = gnc_find_split_in_reg_by_memo (reg, memo, unit_price); - if (auto_split == NULL) - return FALSE; + if (auto_split == nullptr) + return false; /* the auto-complete code below is taken from xaccSRGetEntryHandler */ /* auto-complete the action field if it wasn't changed */ if (!gnc_table_layout_get_cell_changed (reg->table->layout, - ACTN_CELL, TRUE)) + ACTN_CELL, true)) { cell = gnc_table_layout_get_cell (reg->table->layout, ACTN_CELL); gnc_combo_cell_set_value ((ComboCell *) cell, - gnc_get_num_action (NULL, auto_split)); + gnc_get_num_action (nullptr, auto_split)); } /* auto-complete the account name */ cell = gnc_table_layout_get_cell (reg->table->layout, XFRM_CELL); account_name = gnc_get_account_name_for_split_register (xaccSplitGetAccount (auto_split), - reg->show_leaf_accounts); + reg->show_leaf_accounts); gnc_combo_cell_set_value ((ComboCell *) cell, account_name); - g_free(account_name); + g_free (account_name); - gnc_basic_cell_set_changed (cell, TRUE); + gnc_basic_cell_set_changed (cell, true); if (!gnc_table_layout_get_cell_changed (reg->table->layout, - DEBT_CELL, TRUE) && + DEBT_CELL, true) && !gnc_table_layout_get_cell_changed (reg->table->layout, - CRED_CELL, TRUE)) + CRED_CELL, true)) { BasicCell *debit_cell; BasicCell *credit_cell; @@ -1079,25 +1079,25 @@ gnc_split_register_auto_completion (SplitRegister *reg, debit_cell = gnc_table_layout_get_cell (reg->table->layout, DEBT_CELL); credit_cell = gnc_table_layout_get_cell (reg->table->layout, - CRED_CELL); + CRED_CELL); gnc_price_cell_set_debt_credit_value ((PriceCell *) debit_cell, (PriceCell *) credit_cell, amount); - gnc_basic_cell_set_changed (debit_cell, TRUE); - gnc_basic_cell_set_changed (credit_cell, TRUE); + gnc_basic_cell_set_changed (debit_cell, true); + gnc_basic_cell_set_changed (credit_cell, true); } /* and refresh the gui */ - gnc_table_refresh_gui (reg->table, TRUE); + gnc_table_refresh_gui (reg->table, true); /* now move to the non-empty amount column */ amount = xaccSplitGetAmount (auto_split); cell_name = (gnc_numeric_negative_p (amount)) ? CRED_CELL : DEBT_CELL; if (gnc_table_get_current_cell_location (reg->table, cell_name, - &new_virt_loc)) + &new_virt_loc)) *p_new_virt_loc = new_virt_loc; } @@ -1107,7 +1107,7 @@ gnc_split_register_auto_completion (SplitRegister *reg, break; } - return TRUE; + return true; } static void @@ -1121,14 +1121,14 @@ gnc_split_register_check_stock_action (SplitRegister *reg, if (!gnc_cell_name_equal (cell_name, ACTN_CELL) || !gnc_table_layout_get_cell_changed (reg->table->layout, - ACTN_CELL, FALSE)) + ACTN_CELL, false)) return; cell = gnc_table_layout_get_cell (reg->table->layout, ACTN_CELL); if (!cell) return; name = ((ComboCell *)cell)->cell.value; - if ((name == NULL) || (*name == '\0')) + if ((name == nullptr) || (*name == '\0')) return; buy = g_strcmp0 (name, ACTION_BUY_STR) == 0; @@ -1141,11 +1141,11 @@ gnc_split_register_check_stock_action (SplitRegister *reg, return; shares = gnc_price_cell_get_value ((PriceCell *) cell); - if ((buy && !gnc_numeric_positive_p (shares)) || - (sell && gnc_numeric_positive_p (shares))) + if ((buy && !gnc_numeric_positive_p (shares)) || + (sell && gnc_numeric_positive_p (shares))) { gnc_price_cell_set_value ((PriceCell *)cell, gnc_numeric_neg (shares)); - gnc_basic_cell_set_changed (cell, TRUE); + gnc_basic_cell_set_changed (cell, true); } } @@ -1160,7 +1160,7 @@ gnc_split_register_check_stock_shares (SplitRegister *reg, if (!gnc_cell_name_equal (cell_name, SHRS_CELL) || !gnc_table_layout_get_cell_changed (reg->table->layout, - SHRS_CELL, FALSE)) + SHRS_CELL, false)) return; cell = gnc_table_layout_get_cell (reg->table->layout, SHRS_CELL); @@ -1176,12 +1176,12 @@ gnc_split_register_check_stock_shares (SplitRegister *reg, return; name = ((ComboCell *)cell)->cell.value; - if (!g_strcmp0(name, "") || - !g_strcmp0(name, buy ? ACTION_SELL_STR : ACTION_BUY_STR)) + if (!g_strcmp0 (name, "") || + !g_strcmp0 (name, buy ? ACTION_SELL_STR : ACTION_BUY_STR)) { - gnc_combo_cell_set_value((ComboCell *)cell, - buy ? ACTION_BUY_STR : ACTION_SELL_STR); - gnc_basic_cell_set_changed (cell, TRUE); + gnc_combo_cell_set_value ((ComboCell *)cell, + buy ? ACTION_BUY_STR : ACTION_SELL_STR); + gnc_basic_cell_set_changed (cell, true); } } @@ -1199,14 +1199,14 @@ gnc_split_register_check_cell (SplitRegister *reg, const char *cell_name) if (!gnc_split_register_check_account (reg, cell_name)) { LEAVE("account check failed"); - return FALSE; + return false; } /* See if we are leaving a debit or credit cell */ if (!gnc_split_register_check_debcred (reg, cell_name)) { LEAVE("debit/credit check failed"); - return FALSE; + return false; } /* See if we are leaving an action field */ @@ -1219,27 +1219,25 @@ gnc_split_register_check_cell (SplitRegister *reg, const char *cell_name) } LEAVE(" "); - return TRUE; + return true; } static Account * gnc_split_register_get_account_always (SplitRegister *reg, - const char * cell_name) + const char *cell_name) { BasicCell *cell; const char *name; cell = gnc_table_layout_get_cell (reg->table->layout, cell_name); if (!cell) - return NULL; + return nullptr; name = gnc_basic_cell_get_value (cell); /* If 'name' is "-- Split Transaction --" then return NULL or the register acct */ if (!g_strcmp0 (name, SPLIT_TRANS_STR)) - { - return NULL; - } + return nullptr; return gnc_split_register_get_account_by_name (reg, cell, name); } @@ -1248,68 +1246,69 @@ gnc_split_register_get_account_always (SplitRegister *reg, * available) or from the provided transaction and split. */ static XferDialog * -gnc_split_register_xfer_dialog(SplitRegister *reg, Transaction *txn, - Split *split) +gnc_split_register_xfer_dialog (SplitRegister *reg, Transaction *txn, + Split *split) { XferDialog *xfer; CellBlock *cur; BasicCell *cell; - g_return_val_if_fail(reg, NULL); - g_return_val_if_fail(reg->table, NULL); + g_return_val_if_fail (reg, nullptr); + g_return_val_if_fail (reg->table, nullptr); + cur = reg->table->current_cursor; /* Create the exchange rate dialog. */ - xfer = gnc_xfer_dialog(gnc_split_register_get_parent (reg), NULL); - g_return_val_if_fail(xfer, NULL); + xfer = gnc_xfer_dialog (gnc_split_register_get_parent (reg), nullptr); + g_return_val_if_fail (xfer, nullptr); /* Set the description. */ - cell = gnc_cellblock_get_cell_by_name(cur, DESC_CELL, NULL, NULL); + cell = gnc_cellblock_get_cell_by_name (cur, DESC_CELL, nullptr, nullptr); if (cell) - gnc_xfer_dialog_set_description(xfer, gnc_basic_cell_get_value(cell)); + gnc_xfer_dialog_set_description (xfer, gnc_basic_cell_get_value (cell)); else { - const char *str = xaccTransGetDescription(txn); - gnc_xfer_dialog_set_description(xfer, str ? str : ""); + const char *str = xaccTransGetDescription (txn); + gnc_xfer_dialog_set_description (xfer, str ? str : ""); } /* Set the memo. */ - cell = gnc_cellblock_get_cell_by_name(cur, MEMO_CELL, NULL, NULL); + cell = gnc_cellblock_get_cell_by_name (cur, MEMO_CELL, nullptr, nullptr); if (cell) - gnc_xfer_dialog_set_memo(xfer, gnc_basic_cell_get_value(cell)); + gnc_xfer_dialog_set_memo (xfer, gnc_basic_cell_get_value (cell)); else { - const char *str = xaccSplitGetMemo(split); - gnc_xfer_dialog_set_memo(xfer, str ? str : ""); + const char *str = xaccSplitGetMemo (split); + gnc_xfer_dialog_set_memo (xfer, str ? str : ""); } /* Set the num. */ - cell = gnc_cellblock_get_cell_by_name(cur, NUM_CELL, NULL, NULL); + cell = gnc_cellblock_get_cell_by_name (cur, NUM_CELL, nullptr, nullptr); if (cell) - gnc_xfer_dialog_set_num(xfer, gnc_basic_cell_get_value(cell)); + gnc_xfer_dialog_set_num (xfer, gnc_basic_cell_get_value (cell)); else { const char *str = gnc_get_num_action (txn, split); - gnc_xfer_dialog_set_num(xfer, str ? str : ""); + gnc_xfer_dialog_set_num (xfer, str ? str : ""); } /* Set the date. */ - cell = gnc_cellblock_get_cell_by_name(cur, DATE_CELL, NULL, NULL); + cell = gnc_cellblock_get_cell_by_name (cur, DATE_CELL, nullptr, nullptr); if (cell) { time64 time; - gnc_date_cell_get_date((DateCell*) cell, &time, TRUE); - gnc_xfer_dialog_set_date(xfer, time); + gnc_date_cell_get_date ((DateCell*) cell, &time, true); + gnc_xfer_dialog_set_date (xfer, time); } else - gnc_xfer_dialog_set_date(xfer, xaccTransGetDate(txn)); + gnc_xfer_dialog_set_date (xfer, xaccTransGetDate (txn)); return xfer; } /** If needed display the transfer dialog to get a price/exchange rate and * adjust the price cell accordingly. - * If the dialog does not complete successfully, then return TRUE. + * If the dialog does not complete successfully, then return true. * Return FALSE in all other cases (meaning "move on") * @param reg the register to operate on * @param force_dialog pop a dialog even if we don't think we need it. @@ -1325,7 +1324,7 @@ gnc_split_register_handle_exchange (SplitRegister *reg, gboolean force_dialog) gnc_commodity *txn_cur, *xfer_com, *reg_com; gnc_numeric amount, exch_rate; XferDialog *xfer; - gboolean expanded = FALSE; + gboolean expanded = false; PriceCell *rate_cell; const char *message; CursorClass cursor_class; @@ -1336,7 +1335,7 @@ gnc_split_register_handle_exchange (SplitRegister *reg, gboolean force_dialog) if (reg->is_template) { LEAVE("Template transaction, rate makes no sense."); - return FALSE; + return false; } /* Make sure we NEED this for this type of register */ @@ -1345,33 +1344,33 @@ gnc_split_register_handle_exchange (SplitRegister *reg, gboolean force_dialog) if (force_dialog) { message = _("This register does not support editing exchange rates."); - gnc_error_dialog (GTK_WINDOW (gnc_split_register_get_parent (reg)), "%s", message); + gnc_error_dialog (GTK_WINDOW(gnc_split_register_get_parent (reg)), "%s", message); } LEAVE("no rate cell"); - return FALSE; + return false; } - rate_cell = (PriceCell*) gnc_table_layout_get_cell( - reg->table->layout, RATE_CELL); + rate_cell = (PriceCell*) gnc_table_layout_get_cell (reg->table->layout, RATE_CELL); + if (!rate_cell) { if (force_dialog) { message = _("This register does not support editing exchange rates."); - gnc_error_dialog (GTK_WINDOW (gnc_split_register_get_parent (reg)), "%s", message); + gnc_error_dialog (GTK_WINDOW(gnc_split_register_get_parent (reg)), "%s", message); } LEAVE("null rate cell"); - return FALSE; + return false; } /* See if we already have an exchange rate... */ info = gnc_split_register_get_info (reg); exch_rate = gnc_price_cell_get_value (rate_cell); - if (!gnc_numeric_zero_p(exch_rate) && !force_dialog && + if (!gnc_numeric_zero_p (exch_rate) && !force_dialog && info->rate_reset != RATE_RESET_REQD) { LEAVE("rate already non-zero"); - return FALSE; + return false; } /* Are we expanded? */ @@ -1385,24 +1384,24 @@ gnc_split_register_handle_exchange (SplitRegister *reg, gboolean force_dialog) { message = _("You need to select a split in order to modify its exchange " "rate."); - gnc_error_dialog (GTK_WINDOW (gnc_split_register_get_parent (reg)), "%s", message); + gnc_error_dialog (GTK_WINDOW(gnc_split_register_get_parent (reg)), "%s", message); } LEAVE("expanded with transaction cursor; nothing to do"); - return FALSE; + return false; } /* Grab the xfer account */ - xfer_acc = gnc_split_register_get_account_always( - reg, expanded ? XFRM_CELL : MXFRM_CELL); + xfer_acc = gnc_split_register_get_account_always (reg, + expanded ? XFRM_CELL : MXFRM_CELL); /* If this is an un-expanded, multi-split transaction, then warn the user */ if (force_dialog && !expanded && !xfer_acc) { message = _("You need to expand the transaction in order to modify its " "exchange rates."); - gnc_error_dialog (GTK_WINDOW (gnc_split_register_get_parent (reg)), "%s", message); + gnc_error_dialog (GTK_WINDOW(gnc_split_register_get_parent (reg)), "%s", message); LEAVE("%s", message); - return TRUE; + return true; } /* No account -- don't run the dialog */ @@ -1411,10 +1410,10 @@ gnc_split_register_handle_exchange (SplitRegister *reg, gboolean force_dialog) if (force_dialog) { message = _("The entered account could not be found."); - gnc_error_dialog (GTK_WINDOW (gnc_split_register_get_parent (reg)), "%s", message); + gnc_error_dialog (GTK_WINDOW(gnc_split_register_get_parent (reg)), "%s", message); } LEAVE("no xfer account"); - return FALSE; + return false; } /* Grab the txn currency and xfer commodity */ @@ -1439,16 +1438,16 @@ gnc_split_register_handle_exchange (SplitRegister *reg, gboolean force_dialog) if (!force_dialog) { LEAVE("txn and account currencies match, and not forcing"); - return FALSE; + return false; } /* Only proceed with two-split, basic, non-expanded registers */ - if (expanded || osplit == NULL) + if (expanded || osplit == nullptr) { message = _("The two currencies involved equal each other."); - gnc_error_dialog (GTK_WINDOW (gnc_split_register_get_parent (reg)), "%s", message); + gnc_error_dialog (GTK_WINDOW(gnc_split_register_get_parent (reg)), "%s", message); LEAVE("register is expanded or osplit == NULL; not forcing dialog"); - return FALSE; + return false; } /* If we're forcing, then compare the current account @@ -1459,9 +1458,9 @@ gnc_split_register_handle_exchange (SplitRegister *reg, gboolean force_dialog) if (gnc_commodity_equal (txn_cur, xfer_com)) { message = _("The two currencies involved equal each other."); - gnc_error_dialog (GTK_WINDOW (gnc_split_register_get_parent (reg)), "%s", message); + gnc_error_dialog (GTK_WINDOW(gnc_split_register_get_parent (reg)), "%s", message); LEAVE("reg commodity == txn commodity; not forcing"); - return FALSE; + return false; } } @@ -1477,10 +1476,10 @@ gnc_split_register_handle_exchange (SplitRegister *reg, gboolean force_dialog) "exchange rates."); if (force_dialog) { - gnc_error_dialog (GTK_WINDOW (gnc_split_register_get_parent (reg)), "%s", message); + gnc_error_dialog (GTK_WINDOW(gnc_split_register_get_parent (reg)), "%s", message); } LEAVE("%s", message); - return TRUE; + return true; } /* Strangely, if we're in a two-split, non-expanded txn, we need @@ -1490,8 +1489,8 @@ gnc_split_register_handle_exchange (SplitRegister *reg, gboolean force_dialog) * XXX: perhaps I should pop up an error here? Or maybe require the * user to go into expanded-mode? */ - if (!expanded && osplit && !gnc_commodity_equal(reg_com, txn_cur) && - !gnc_commodity_equal(reg_com, xfer_com)) + if (!expanded && osplit && !gnc_commodity_equal (reg_com, txn_cur) && + !gnc_commodity_equal (reg_com, xfer_com)) { gnc_numeric amt = xaccSplitGetAmount (osplit); gnc_numeric val = xaccSplitGetValue (osplit); @@ -1510,51 +1509,51 @@ gnc_split_register_handle_exchange (SplitRegister *reg, gboolean force_dialog) if (force_dialog) { message = _("The split's amount is zero, so no exchange rate is needed."); - gnc_error_dialog (GTK_WINDOW (gnc_split_register_get_parent (reg)), "%s", message); + gnc_error_dialog (GTK_WINDOW(gnc_split_register_get_parent (reg)), "%s", message); } LEAVE("amount is zero; no exchange rate needed"); - return FALSE; + return false; } /* If the exch_rate is zero, we're not forcing the dialog, and this is * _not_ the blank split, then return FALSE -- this is a "special" * gain/loss stock transaction. */ - if (gnc_numeric_zero_p(exch_rate) && !force_dialog && split && + if (gnc_numeric_zero_p (exch_rate) && !force_dialog && split && info->rate_reset != RATE_RESET_REQD && split != gnc_split_register_get_blank_split (reg)) { LEAVE("gain/loss split; no exchange rate needed"); - return FALSE; + return false; } /* Show the exchange-rate dialog */ - xfer = gnc_split_register_xfer_dialog(reg, txn, split); - gnc_xfer_dialog_is_exchange_dialog(xfer, &exch_rate); - if (gnc_xfer_dialog_run_exchange_dialog( - xfer, &exch_rate, amount, reg_acc, txn, xfer_com, expanded)) + xfer = gnc_split_register_xfer_dialog (reg, txn, split); + gnc_xfer_dialog_is_exchange_dialog (xfer, &exch_rate); + if (gnc_xfer_dialog_run_exchange_dialog (xfer, &exch_rate, amount, + reg_acc, txn, xfer_com, expanded)) { /* FIXME: How should the dialog be destroyed? */ LEAVE("leaving rate unchanged"); - return TRUE; + return true; } /* FIXME: How should the dialog be destroyed? */ /* Set the RATE_CELL on this cursor and mark it changed */ gnc_price_cell_set_value (rate_cell, exch_rate); - gnc_basic_cell_set_changed (&rate_cell->cell, TRUE); + gnc_basic_cell_set_changed (&rate_cell->cell, true); info->rate_account = xfer_acc; info->rate_reset = RATE_RESET_DONE; - LEAVE("set rate=%s", gnc_num_dbg_to_string(exch_rate)); - return FALSE; + LEAVE("set rate=%s", gnc_num_dbg_to_string (exch_rate)); + return false; } /* Returns FALSE if dialog was canceled. */ static gboolean -transaction_changed_confirm(VirtualLocation *p_new_virt_loc, - VirtualLocation *virt_loc, - SplitRegister *reg, Transaction *new_trans, - gboolean exact_traversal) +transaction_changed_confirm (VirtualLocation *p_new_virt_loc, + VirtualLocation *virt_loc, + SplitRegister *reg, Transaction *new_trans, + gboolean exact_traversal) { GtkWidget *dialog, *window; gint response; @@ -1564,21 +1563,21 @@ transaction_changed_confirm(VirtualLocation *p_new_virt_loc, "record the changes before moving to a new transaction, discard the " "changes, or return to the changed transaction?"); - window = gnc_split_register_get_parent(reg); - dialog = gtk_message_dialog_new(GTK_WINDOW(window), - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_QUESTION, - GTK_BUTTONS_NONE, - "%s", title); - gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog), - "%s", message); - gtk_dialog_add_buttons(GTK_DIALOG(dialog), - _("_Discard Changes"), GTK_RESPONSE_REJECT, - _("_Cancel"), GTK_RESPONSE_CANCEL, - _("_Record Changes"), GTK_RESPONSE_ACCEPT, - NULL); - response = gnc_dialog_run(GTK_DIALOG(dialog), GNC_PREF_WARN_REG_TRANS_MOD); - gtk_widget_destroy(dialog); + window = gnc_split_register_get_parent (reg); + dialog = gtk_message_dialog_new (GTK_WINDOW(window), + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_QUESTION, + GTK_BUTTONS_NONE, + "%s", title); + gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG(dialog), + "%s", message); + gtk_dialog_add_buttons (GTK_DIALOG(dialog), + _("_Discard Changes"), GTK_RESPONSE_REJECT, + _("_Cancel"), GTK_RESPONSE_CANCEL, + _("_Record Changes"), GTK_RESPONSE_ACCEPT, + nullptr); + response = gnc_dialog_run (GTK_DIALOG(dialog), GNC_PREF_WARN_REG_TRANS_MOD); + gtk_widget_destroy (dialog); switch (response) { @@ -1593,18 +1592,18 @@ transaction_changed_confirm(VirtualLocation *p_new_virt_loc, CursorClass new_class; /* Clear unreconcile split list */ - if (reg->unrecn_splits != NULL) + if (reg->unrecn_splits != nullptr) { g_list_free (reg->unrecn_splits); - reg->unrecn_splits = NULL; + reg->unrecn_splits = nullptr; } new_split = gnc_split_register_get_split (reg, virt_loc->vcell_loc); trans_split = gnc_split_register_get_trans_split (reg, - virt_loc->vcell_loc, - NULL); + virt_loc->vcell_loc, + nullptr); new_class = gnc_split_register_get_cursor_class (reg, - virt_loc->vcell_loc); + virt_loc->vcell_loc); gnc_split_register_cancel_cursor_trans_changes (reg); @@ -1621,10 +1620,10 @@ transaction_changed_confirm(VirtualLocation *p_new_virt_loc, case GTK_RESPONSE_CANCEL: default: - return TRUE; + return true; } - return FALSE; + return false; } /** Examine a request to traverse to a new location in the register and @@ -1653,7 +1652,7 @@ gnc_split_register_traverse (VirtualLocation *p_new_virt_loc, Split *split; const char *cell_name; - g_return_val_if_fail(p_new_virt_loc, TRUE); + g_return_val_if_fail (p_new_virt_loc, true); ENTER("reg=%p, p_new_virt_loc=%p (%d,%d), dir=%d", reg, p_new_virt_loc, (*p_new_virt_loc).vcell_loc.virt_row, @@ -1662,7 +1661,7 @@ gnc_split_register_traverse (VirtualLocation *p_new_virt_loc, if (!reg) { LEAVE("no register"); - return FALSE; + return false; } info = gnc_split_register_get_info (reg); @@ -1670,7 +1669,7 @@ gnc_split_register_traverse (VirtualLocation *p_new_virt_loc, if (info->first_pass) { LEAVE("first pass"); - return FALSE; + return false; } pending_trans = xaccTransLookup (&info->pending_trans_guid, @@ -1681,14 +1680,14 @@ gnc_split_register_traverse (VirtualLocation *p_new_virt_loc, split = gnc_split_register_get_current_split (reg); trans = gnc_split_register_get_current_trans (reg); - if (trans == NULL) + if (trans == nullptr) { LEAVE("no transaction"); - return FALSE; + return false; } /* no changes, make sure we aren't going off the end */ - changed = gnc_table_current_cursor_changed (reg->table, FALSE); + changed = gnc_table_current_cursor_changed (reg->table, false); if (!changed && (pending_trans != trans)) { gnc_table_find_close_valid_cell (reg->table, &virt_loc, @@ -1697,7 +1696,7 @@ gnc_split_register_traverse (VirtualLocation *p_new_virt_loc, *p_new_virt_loc = virt_loc; LEAVE("no changes"); - return FALSE; + return false; } /* Get the current cell-name and check it for changes. */ @@ -1705,7 +1704,7 @@ gnc_split_register_traverse (VirtualLocation *p_new_virt_loc, if (!gnc_split_register_check_cell (reg, cell_name)) { LEAVE("check cell"); - return TRUE; + return true; } /* See if we are tabbing off the end of the very last line */ @@ -1724,14 +1723,14 @@ gnc_split_register_traverse (VirtualLocation *p_new_virt_loc, break; virt_loc = reg->table->current_cursor_loc; - if (gnc_table_move_tab (reg->table, &virt_loc, TRUE)) + if (gnc_table_move_tab (reg->table, &virt_loc, true)) break; /* Deal with the exchange-rate */ - if (gnc_split_register_handle_exchange (reg, FALSE)) + if (gnc_split_register_handle_exchange (reg, false)) { LEAVE("no exchange rate"); - return TRUE; + return true; } *p_new_virt_loc = reg->table->current_cursor_loc; @@ -1739,13 +1738,13 @@ gnc_split_register_traverse (VirtualLocation *p_new_virt_loc, p_new_virt_loc->phys_row_offset = 0; p_new_virt_loc->phys_col_offset = 0; - info->traverse_to_new = TRUE; + info->traverse_to_new = true; LEAVE("off end of last line"); - return FALSE; + return false; } - while (FALSE); + while (false); /* Now see if we are changing cursors. If not, we may be able to * auto-complete. */ @@ -1753,9 +1752,9 @@ gnc_split_register_traverse (VirtualLocation *p_new_virt_loc, { if (gnc_split_register_auto_completion (reg, dir, p_new_virt_loc)) { - info->auto_complete = TRUE; + info->auto_complete = true; LEAVE("auto-complete"); - return FALSE; + return false; } } @@ -1777,7 +1776,7 @@ gnc_split_register_traverse (VirtualLocation *p_new_virt_loc, virt_loc = reg->table->current_cursor_loc; old_virt_row = virt_loc.vcell_loc.virt_row; - if (gnc_table_move_tab (reg->table, &virt_loc, TRUE) && + if (gnc_table_move_tab (reg->table, &virt_loc, true) && old_virt_row == virt_loc.vcell_loc.virt_row) break; @@ -1789,24 +1788,24 @@ gnc_split_register_traverse (VirtualLocation *p_new_virt_loc, * transaction. */ /* Deal with the exchange-rate */ - if (gnc_split_register_handle_exchange (reg, FALSE)) + if (gnc_split_register_handle_exchange (reg, false)) { LEAVE("no exchange rate"); - return TRUE; + return true; } info->cursor_hint_trans = trans; info->cursor_hint_split = split; info->cursor_hint_trans_split = - gnc_split_register_get_current_trans_split (reg, NULL); + gnc_split_register_get_current_trans_split (reg, nullptr); info->cursor_hint_cursor_class = CURSOR_CLASS_SPLIT; - info->hint_set_by_traverse = TRUE; + info->hint_set_by_traverse = true; LEAVE("off end of blank split"); - return FALSE; + return false; } - while (FALSE); + while (false); { int old_virt_row = reg->table->current_cursor_loc.vcell_loc.virt_row; @@ -1819,10 +1818,10 @@ gnc_split_register_traverse (VirtualLocation *p_new_virt_loc, /* Did we change vertical position? */ if (virt_loc.vcell_loc.virt_row != old_virt_row) /* Deal with the exchange-rate */ - if (gnc_split_register_handle_exchange (reg, FALSE)) + if (gnc_split_register_handle_exchange (reg, false)) { LEAVE("no exchange rate"); - return TRUE; + return true; } } @@ -1834,21 +1833,21 @@ gnc_split_register_traverse (VirtualLocation *p_new_virt_loc, *p_new_virt_loc = virt_loc; { LEAVE("staying within txn"); - return FALSE; + return false; } } /* Ok, we are changing transactions and the current transaction has * changed. See what the user wants to do. */ LEAVE("txn change"); - return transaction_changed_confirm(p_new_virt_loc, &virt_loc, reg, - new_trans, info->exact_traversal); + return transaction_changed_confirm (p_new_virt_loc, &virt_loc, reg, + new_trans, info->exact_traversal); } TableControl * gnc_split_register_control_new (void) { - TableControl *control = gnc_table_control_new(); + TableControl *control = gnc_table_control_new (); control->move_cursor = gnc_split_register_move_cursor; control->traverse = gnc_split_register_traverse; @@ -1869,21 +1868,21 @@ gnc_split_register_recn_cell_confirm (char old_flag, gpointer data) "with this change?"); if (old_flag != YREC) - return TRUE; + return true; /* Does the user want to be warned? */ - window = gnc_split_register_get_parent(reg); - dialog = - gtk_message_dialog_new(GTK_WINDOW(window), - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_WARNING, - GTK_BUTTONS_CANCEL, - "%s", title); - gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog), - "%s", message); - gtk_dialog_add_button(GTK_DIALOG(dialog), _("_Unreconcile"), - GTK_RESPONSE_YES); - response = gnc_dialog_run(GTK_DIALOG(dialog), GNC_PREF_WARN_REG_RECD_SPLIT_UNREC); - gtk_widget_destroy(dialog); + window = gnc_split_register_get_parent (reg); + dialog = gtk_message_dialog_new (GTK_WINDOW(window), + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_WARNING, + GTK_BUTTONS_CANCEL, + "%s", title); + gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG(dialog), + "%s", message); + gtk_dialog_add_button (GTK_DIALOG(dialog), + _("_Unreconcile"), + GTK_RESPONSE_YES); + response = gnc_dialog_run (GTK_DIALOG(dialog), GNC_PREF_WARN_REG_RECD_SPLIT_UNREC); + gtk_widget_destroy (dialog); return (response == GTK_RESPONSE_YES); }