GnuCash  4.12-68-g5dc52459a1+
Files | Data Structures | Macros | Typedefs | Enumerations | Functions
Utility functions for the GnuCash GUI

Files

file  gnc-ui-util.h
 utility functions for the GnuCash UI
 

Data Structures

struct  GNCPrintAmountInfo
 

Macros

#define GNC_PREFS_GROUP_OPEN_SAVE   "dialogs.open-save"
 
#define GNC_PREFS_GROUP_EXPORT   "dialogs.export-accounts"
 
#define GNC_PREFS_GROUP_REPORT   "dialogs.report"
 
#define GNC_PREF_AUTO_DECIMAL_POINT   "auto-decimal-point"
 
#define GNC_PREF_AUTO_DECIMAL_PLACES   "auto-decimal-places"
 
#define WLINK   'w'
 
#define FLINK   'f'
 

Typedefs

typedef QofSession *(* QofSessionCB) (void)
 

Enumerations

enum  GNCEquityType { EQUITY_OPENING_BALANCE, EQUITY_RETAINED_EARNINGS, NUM_EQUITY_TYPES }
 

Functions

gchar * gnc_normalize_account_separator (const gchar *separator)
 
gboolean gnc_reverse_balance (const Account *account)
 
gboolean gnc_using_unreversed_budgets (QofBook *book)
 
gboolean gnc_reverse_budget_balance (const Account *account, gboolean unreversed)
 
void gnc_set_use_equity_type_opening_balance_account (QofBook *book)
 
gboolean gnc_using_equity_type_opening_balance_account (QofBook *book)
 
gchar * gnc_get_default_directory (const gchar *section)
 
void gnc_set_default_directory (const gchar *section, const gchar *directory)
 
QofBook * gnc_get_current_book (void)
 
gboolean gnc_is_new_book (void)
 
void gnc_set_current_book_tax_name_type (gboolean name_changed, const gchar *tax_name, gboolean type_changed, const gchar *tax_type)
 
const gchar * gnc_get_current_book_tax_name (void)
 
const gchar * gnc_get_current_book_tax_type (void)
 
void gnc_book_option_num_field_source_change_cb (gboolean num_action)
 Calls gnc_book_option_num_field_source_change to initiate registered callbacks when num_field_source book option changes so that registers/reports can update themselves; sets feature flag.
 
void gnc_book_option_book_currency_selected_cb (gboolean use_book_currency)
 Calls gnc_book_option_book_currency_selected to initiate registered callbacks when currency accounting book option changes to book-currency so that registers/reports can update themselves; sets feature flag.
 
gboolean gnc_book_use_book_currency (QofBook *book)
 Returns TRUE if both book-currency and default gain/loss policy KVPs exist and are valid and trading accounts are not used. More...
 
const gchar * gnc_book_get_book_currency_name (QofBook *book)
 Returns pointer to Book Currency name for book or NULL; determines that both book-currency and default gain/loss policy KVPs exist and that both are valid, a requirement for the 'book-currency' currency accounting method to apply. More...
 
gnc_commodity * gnc_book_get_book_currency (QofBook *book)
 Returns pointer to Book Currency for book or NULL; determines that both book-currency and default gain/loss policy KVPs exist and that both are valid, a requirement for the 'book-currency' currency accounting method to apply. More...
 
const gchar * gnc_book_get_default_gains_policy (QofBook *book)
 Returns pointer to default gain/loss policy for book or NULL; determines that both book-currency and default gain/loss policy KVPs exist and that both are valid, a requirement for the 'book-currency' currency accounting method to apply. More...
 
Accountgnc_book_get_default_gain_loss_acct (QofBook *book)
 Returns pointer to default gain/loss account for book or NULL; determines that both book-currency and default gain/loss policy KVPs exist and that both are valid, a requirement for the 'book-currency' currency accounting method to apply. More...
 
Accountgnc_get_current_root_account (void)
 
gnc_commodity_table * gnc_get_current_commodities (void)
 
gchar * gnc_get_account_name_for_register (const Account *account)
 Get either the full name of the account or the simple name, depending on the configuration parameter general/register/show_leaf_account_names. More...
 
Accountgnc_account_lookup_for_register (const Account *base_account, const gchar *name)
 Retrieve the account matching the given name starting from the descendants of base_account. More...
 
gchar * gnc_get_account_name_for_split_register (const Account *account, gboolean show_leaf_accounts)
 Get either the full name of the account or the simple name, depending on the show_leaf_accounts. More...
 
char * gnc_ui_account_get_tax_info_string (const Account *account)
 
char * gnc_ui_account_get_tax_info_sub_acct_string (const Account *account)
 
const char * gnc_get_reconcile_str (char reconciled_flag)
 
const char * gnc_get_reconcile_valid_flags (void)
 
const char * gnc_get_reconcile_flag_order (void)
 
const char * gnc_get_doclink_valid_flags (void)
 Get a string containing documentation link valid flags. More...
 
const char * gnc_get_doclink_flag_order (void)
 Get a string containing document link flag order. More...
 
const char * gnc_get_doclink_str (char link_flag)
 Get a string representing the document link type. More...
 
Accountgnc_find_or_create_equity_account (Account *root, GNCEquityType equity_type, gnc_commodity *currency)
 
gboolean gnc_account_create_opening_balance (Account *account, gnc_numeric balance, time64 date, QofBook *book)
 
gnc_commodity * gnc_locale_default_currency_nodefault (void)
 Returns the default currency of the current locale, or NULL if no sensible currency could be identified from the locale. More...
 
gnc_commodity * gnc_locale_default_currency (void)
 Returns the default currency of the current locale. More...
 
gnc_commodity * gnc_default_currency (void)
 Return the default currency set by the user. More...
 
gnc_commodity * gnc_account_or_default_currency (const Account *account, gboolean *currency_from_account_found)
 Returns a gnc_commodity that is a currency, suitable for being a Transaction's currency. More...
 
gnc_commodity * gnc_default_report_currency (void)
 Return the default currency for use in reports, as set by the user. More...
 
GNCPrintAmountInfo gnc_default_print_info (gboolean use_symbol)
 
GNCPrintAmountInfo gnc_commodity_print_info (const gnc_commodity *commodity, gboolean use_symbol)
 
GNCPrintAmountInfo gnc_account_print_info (const Account *account, gboolean use_symbol)
 
GNCPrintAmountInfo gnc_split_amount_print_info (Split *split, gboolean use_symbol)
 
GNCPrintAmountInfo gnc_price_print_info (const gnc_commodity *curr, gboolean use_symbol)
 
GNCPrintAmountInfo gnc_share_print_info_places (int decplaces)
 
GNCPrintAmountInfo gnc_default_share_print_info (void)
 
GNCPrintAmountInfo gnc_default_price_print_info (const gnc_commodity *curr)
 
GNCPrintAmountInfo gnc_integral_print_info (void)
 
const char * xaccPrintAmount (gnc_numeric val, GNCPrintAmountInfo info)
 Make a string representation of a gnc_numeric. More...
 
int xaccSPrintAmount (char *buf, gnc_numeric val, GNCPrintAmountInfo info)
 Make a string representation of a gnc_numeric. More...
 
const gchar * printable_value (gdouble val, gint denom)
 
gchar * number_to_words (gdouble val, gint64 denom)
 
gchar * numeric_to_words (gnc_numeric val)
 
gboolean xaccParseAmount (const char *in_str, gboolean monetary, gnc_numeric *result, char **endstr)
 Parses in_str to obtain a numeric result. More...
 
gboolean xaccParseAmountPosSign (const char *in_str, gboolean monetary, gnc_numeric *result, char **endstr, gboolean skip)
 Parses in_str to a gnc_numeric, with a flag to indicate whether the locale's positive sign (or in absence the '+') character is ignored. More...
 
gboolean xaccParseAmountExtended (const char *in_str, gboolean monetary, gunichar negative_sign, gunichar decimal_point, gunichar group_separator, const char *ignore_list, gnc_numeric *result, char **endstr)
 Converts a string to a gnc_numeric. More...
 
const char * gnc_print_amount_with_bidi_ltr_isolate (gnc_numeric val, GNCPrintAmountInfo info)
 Make a string representation of a gnc_numeric. More...
 
gchar * gnc_wrap_text_with_bidi_ltr_isolate (const char *text)
 This function helps with GTK's use of 'Unicode Bidirectional Text Algorithm'. More...
 
void gnc_ui_util_init (void)
 
void gnc_ui_util_remove_registered_prefs (void)
 
gchar * gnc_filter_text_for_control_chars (const gchar *incoming_text)
 Returns the incoming text removed of control characters. More...
 
void gnc_filter_text_set_cursor_position (const gchar *incoming_text, const gchar *symbol, gint *cursor_position)
 Updates cursor_position after removal of currency symbols. More...
 
gchar * gnc_filter_text_for_currency_symbol (const gchar *incoming_text, const gchar *symbol)
 Returns the incoming text removed of a currency symbol. More...
 
gchar * gnc_filter_text_for_currency_commodity (const gnc_commodity *comm, const gchar *incoming_text, const gchar **symbol)
 Returns the incoming text removed of currency symbol. More...
 

Detailed Description

Function Documentation

◆ gnc_account_lookup_for_register()

Account* gnc_account_lookup_for_register ( const Account base_account,
const gchar *  name 
)

Retrieve the account matching the given name starting from the descendants of base_account.

name is either considered to be the name of the leaf in the account tree or to be the full account path, depending on the configuration parameter general.register/show_leaf_account_names.

Parameters
base_accountThe account to start the search at.
nameThe name to search for.
Returns
A pointer to the account, or NULL if the account was not found.

◆ gnc_account_or_default_currency()

gnc_commodity* gnc_account_or_default_currency ( const Account account,
gboolean *  currency_from_account_found 
)

Returns a gnc_commodity that is a currency, suitable for being a Transaction's currency.

The gnc_commodity is taken either from the current account, or from the next parent account that has a gnc_commodity that is a currency, or from gnc_default_currency().

If the given account or any of its parent account have a commodity that is a currency, it is returned and the gboolean currency_from_account_found is set to TRUE (if non-NULL). If neither this account nor any of its parent accounts have such a commodity, gnc_default_currency() is returned and the gboolean currency_from_account_found is set to FALSE (if non-NULL). This can be used to show an appropriate warning message.

If account is NULL, gnc_default_currency() is returned and currency_from_account_found is set to FALSE.

Parameters
accountThe account where the currency should be looked up. May be NULL.
currency_from_account_foundA gboolean pointer that takes the output argument of whether the returned currency was found in the account. May be NULL.
Returns
A currency pointer (and never NULL).

Definition at line 1202 of file gnc-ui-util.c.

1203 {
1204  gnc_commodity *currency;
1205  if (!account)
1206  {
1207  if (currency_from_account_found)
1208  *currency_from_account_found = FALSE;
1209  return gnc_default_currency();
1210  }
1211 
1212  currency = gnc_account_get_currency_or_parent(account);
1213  if (currency)
1214  {
1215  if (currency_from_account_found)
1216  *currency_from_account_found = TRUE;
1217  }
1218  else
1219  {
1220  if (currency_from_account_found)
1221  *currency_from_account_found = FALSE;
1222  currency = gnc_default_currency();
1223  }
1224  return currency;
1225 }
gnc_commodity * gnc_default_currency(void)
Return the default currency set by the user.
Definition: gnc-ui-util.c:1197
gnc_commodity * gnc_account_get_currency_or_parent(const Account *account)
Returns a gnc_commodity that is a currency, suitable for being a Transaction's currency.
Definition: Account.cpp:3455

◆ gnc_book_get_book_currency()

gnc_commodity* gnc_book_get_book_currency ( QofBook *  book)

Returns pointer to Book Currency for book or NULL; determines that both book-currency and default gain/loss policy KVPs exist and that both are valid, a requirement for the 'book-currency' currency accounting method to apply.

Definition at line 496 of file gnc-ui-util.c.

497 {
498  if (!book) return NULL;
499 
500  if (gnc_book_use_book_currency (book))
501  return gnc_commodity_table_lookup
503  GNC_COMMODITY_NS_CURRENCY,
505 
506  return NULL;
507 }
gnc_commodity_table * gnc_commodity_table_get_table(QofBook *book)
Returns the commodity table associated with a book.
gboolean gnc_book_use_book_currency(QofBook *book)
Returns TRUE if both book-currency and default gain/loss policy KVPs exist and are valid and trading ...
Definition: gnc-ui-util.c:446
const gchar * qof_book_get_book_currency_name(QofBook *book)
Returns pointer to book-currency name for book, if one exists in the KVP, or NULL; does not validate ...
Definition: qofbook.cpp:993

◆ gnc_book_get_book_currency_name()

const gchar* gnc_book_get_book_currency_name ( QofBook *  book)

Returns pointer to Book Currency name for book or NULL; determines that both book-currency and default gain/loss policy KVPs exist and that both are valid, a requirement for the 'book-currency' currency accounting method to apply.

Definition at line 481 of file gnc-ui-util.c.

482 {
483  if (!book) return NULL;
484 
485  if (gnc_book_use_book_currency (book))
486  return qof_book_get_book_currency_name (book);
487 
488  return NULL;
489 }
gboolean gnc_book_use_book_currency(QofBook *book)
Returns TRUE if both book-currency and default gain/loss policy KVPs exist and are valid and trading ...
Definition: gnc-ui-util.c:446
const gchar * qof_book_get_book_currency_name(QofBook *book)
Returns pointer to book-currency name for book, if one exists in the KVP, or NULL; does not validate ...
Definition: qofbook.cpp:993

◆ gnc_book_get_default_gain_loss_acct()

Account* gnc_book_get_default_gain_loss_acct ( QofBook *  book)

Returns pointer to default gain/loss account for book or NULL; determines that both book-currency and default gain/loss policy KVPs exist and that both are valid, a requirement for the 'book-currency' currency accounting method to apply.

Also, account must not be hidden or a placeholder, and must be of same currency as book-currency and income or expense type

Definition at line 530 of file gnc-ui-util.c.

531 {
532  Account *gains_account = NULL;
533 
534  if (!book) return NULL;
535 
536  if (gnc_book_use_book_currency (book))
537  {
539  gains_account = xaccAccountLookup (guid, book);
540  guid_free (guid);
541  }
542 
543  if (gains_account &&
544  !xaccAccountGetPlaceholder(gains_account) &&
545  !xaccAccountGetHidden(gains_account) &&
547  gnc_book_get_book_currency(book))) &&
548  ((xaccAccountGetType(gains_account) == ACCT_TYPE_INCOME) ||
549  (xaccAccountGetType(gains_account) == ACCT_TYPE_EXPENSE)))
550  {
551  return gains_account;
552  }
553  else
554  {
555  return NULL;
556  }
557 }
gboolean gnc_book_use_book_currency(QofBook *book)
Returns TRUE if both book-currency and default gain/loss policy KVPs exist and are valid and trading ...
Definition: gnc-ui-util.c:446
Expense accounts are used to denote expenses.
Definition: Account.h:146
GNCAccountType xaccAccountGetType(const Account *acc)
Returns the account's account type.
Definition: Account.cpp:3279
gboolean gnc_commodity_equal(const gnc_commodity *a, const gnc_commodity *b)
This routine returns TRUE if the two commodities are equal.
Income accounts are used to denote income.
Definition: Account.h:143
gnc_commodity * gnc_book_get_book_currency(QofBook *book)
Returns pointer to Book Currency for book or NULL; determines that both book-currency and default gai...
Definition: gnc-ui-util.c:496
gboolean xaccAccountGetHidden(const Account *acc)
Get the "hidden" flag for an account.
Definition: Account.cpp:4351
gnc_commodity * xaccAccountGetCommodity(const Account *acc)
Get the account's commodity.
Definition: Account.cpp:3448
GncGUID * qof_book_get_default_gain_loss_acct_guid(QofBook *book)
Returns pointer to default gain/loss account GUID for book, if one exists in the KVP, or NULL; does not validate contents nor determine if there is a valid book-currency, both of which are required, for the 'book-currency' currency accounting method to apply.
Definition: qofbook.cpp:1023
gboolean xaccAccountGetPlaceholder(const Account *acc)
Get the "placeholder" flag for an account.
Definition: Account.cpp:4262
The type used to store guids in C.
Definition: guid.h:75
Account * xaccAccountLookup(const GncGUID *guid, QofBook *book)
The xaccAccountLookup() subroutine will return the account associated with the given id...
Definition: Account.cpp:2050

◆ gnc_book_get_default_gains_policy()

const gchar* gnc_book_get_default_gains_policy ( QofBook *  book)

Returns pointer to default gain/loss policy for book or NULL; determines that both book-currency and default gain/loss policy KVPs exist and that both are valid, a requirement for the 'book-currency' currency accounting method to apply.

Definition at line 514 of file gnc-ui-util.c.

515 {
516  if (!book) return NULL;
517 
518  if (gnc_book_use_book_currency (book))
519  return qof_book_get_default_gains_policy (book);
520 
521  return NULL;
522 }
gboolean gnc_book_use_book_currency(QofBook *book)
Returns TRUE if both book-currency and default gain/loss policy KVPs exist and are valid and trading ...
Definition: gnc-ui-util.c:446
const gchar * qof_book_get_default_gains_policy(QofBook *book)
Returns pointer to default gain/loss policy for book, if one exists in the KVP, or NULL; does not val...
Definition: qofbook.cpp:1008

◆ gnc_book_use_book_currency()

gboolean gnc_book_use_book_currency ( QofBook *  book)

Returns TRUE if both book-currency and default gain/loss policy KVPs exist and are valid and trading accounts are not used.

Definition at line 446 of file gnc-ui-util.c.

447 {
448  const gchar *policy;
449  const gchar *currency;
450 
451  if (!book) return FALSE;
452 
453  policy = qof_book_get_default_gains_policy (book);
454  currency = qof_book_get_book_currency_name (book);
455 
456  /* If either a default gain/loss policy or a book-currency does not exist,
457  book-currency accounting method not valid */
458  if (!policy || !currency)
459  return FALSE;
460 
461  /* If both exist, both must be valid */
462  if (!gnc_valid_policy_name (policy) || !gnc_commodity_table_lookup
464  (gnc_get_current_book()),
465  GNC_COMMODITY_NS_CURRENCY,
466  currency))
467  return FALSE;
468 
469  /* If both exist and are valid, there must be no trading accounts flag */
471  return FALSE;
472 
473  return TRUE;
474 }
gnc_commodity_table * gnc_commodity_table_get_table(QofBook *book)
Returns the commodity table associated with a book.
const gchar * qof_book_get_default_gains_policy(QofBook *book)
Returns pointer to default gain/loss policy for book, if one exists in the KVP, or NULL; does not val...
Definition: qofbook.cpp:1008
const gchar * qof_book_get_book_currency_name(QofBook *book)
Returns pointer to book-currency name for book, if one exists in the KVP, or NULL; does not validate ...
Definition: qofbook.cpp:993
gboolean gnc_valid_policy_name(const gchar *policy_name)
Valid Policy Name Uses the Valid Policy List to determine if a policy name is valid.
Definition: policy.c:80
gboolean qof_book_use_trading_accounts(const QofBook *book)
Returns flag indicating whether this book uses trading accounts.
Definition: qofbook.cpp:1035

◆ gnc_default_currency()

gnc_commodity* gnc_default_currency ( void  )

Return the default currency set by the user.

If the user's preference is invalid, then this routine will return the default currency for the user's locale.

Returns
A pointer to a currency.

Definition at line 1197 of file gnc-ui-util.c.

1198 {
1199  return gnc_default_currency_common (user_default_currency, GNC_PREFS_GROUP_GENERAL);
1200 }

◆ gnc_default_report_currency()

gnc_commodity* gnc_default_report_currency ( void  )

Return the default currency for use in reports, as set by the user.

If the user's preference is invalid, then this routine will return the default currency for the user's locale.

Returns
A pointer to a currency.

Definition at line 1230 of file gnc-ui-util.c.

1231 {
1232  return gnc_default_currency_common (user_report_currency, GNC_PREFS_GROUP_GENERAL_REPORT);
1233 }

◆ gnc_filter_text_for_control_chars()

gchar* gnc_filter_text_for_control_chars ( const gchar *  incoming_text)

Returns the incoming text removed of control characters.

Parameters
incoming_textThe text to filter
Returns
The incoming text filtered of control characters to be freed by the caller.

Definition at line 2596 of file gnc-ui-util.c.

2597 {
2598  gchar *normal_text, *nt;
2599  GString *filtered;
2600  gboolean cntrl = FALSE;
2601  gboolean text_found = FALSE;
2602 
2603  if (!text)
2604  return NULL;
2605 
2606  if (!g_utf8_validate (text, -1, NULL))
2607  return NULL;
2608 
2609  normal_text = g_utf8_normalize (text, -1, G_NORMALIZE_ALL_COMPOSE);
2610 
2611  filtered = g_string_sized_new (strlen (normal_text) + 1);
2612 
2613  nt = normal_text;
2614 
2615  while (*nt)
2616  {
2617  gunichar uc = g_utf8_get_char (nt);
2618 
2619  // check for starting with control characters
2620  if (unichar_is_cntrl (uc) && !text_found)
2621  {
2622  nt = g_utf8_next_char (nt);
2623  continue;
2624  }
2625  // check for alpha, num and punctuation
2626  if (!unichar_is_cntrl (uc))
2627  {
2628  filtered = g_string_append_unichar (filtered, uc);
2629  text_found = TRUE;
2630  }
2631  // check for control characters after text
2632  if (unichar_is_cntrl (uc))
2633  cntrl = TRUE;
2634 
2635  nt = g_utf8_next_char (nt);
2636 
2637  if (cntrl) // if control characters in text replace with space
2638  {
2639  gunichar uc2 = g_utf8_get_char (nt);
2640 
2641  if (!unichar_is_cntrl (uc2))
2642  filtered = g_string_append_unichar (filtered, ' ');
2643  }
2644  cntrl = FALSE;
2645  }
2646  g_free (normal_text);
2647  return g_string_free (filtered, FALSE);
2648 }

◆ gnc_filter_text_for_currency_commodity()

gchar* gnc_filter_text_for_currency_commodity ( const gnc_commodity *  comm,
const gchar *  incoming_text,
const gchar **  symbol 
)

Returns the incoming text removed of currency symbol.

Parameters
commcommodity of entry if known
incoming_textThe text to filter
symbolreturn the symbol used
Returns
The incoming text with symbol removed to be freed by the caller

Definition at line 2707 of file gnc-ui-util.c.

2710 {
2711  if (!incoming_text)
2712  {
2713  *symbol = NULL;
2714  return NULL;
2715  }
2716 
2717  if (!gnc_commodity_is_currency (comm))
2718  {
2719  *symbol = NULL;
2720  return g_strdup (incoming_text);
2721  }
2722 
2723  if (comm)
2724  *symbol = gnc_commodity_get_nice_symbol (comm);
2725  else
2727 
2728  return gnc_filter_text_for_currency_symbol (incoming_text, *symbol);
2729 }
gboolean gnc_commodity_is_currency(const gnc_commodity *cm)
Checks to see if the specified commodity is an ISO 4217 recognized currency or a legacy currency...
gnc_commodity * gnc_default_currency(void)
Return the default currency set by the user.
Definition: gnc-ui-util.c:1197
const char * gnc_commodity_get_nice_symbol(const gnc_commodity *cm)
Retrieve a symbol for the specified commodity, suitable for display to the user.
gchar * gnc_filter_text_for_currency_symbol(const gchar *incoming_text, const gchar *symbol)
Returns the incoming text removed of a currency symbol.
Definition: gnc-ui-util.c:2683

◆ gnc_filter_text_for_currency_symbol()

gchar* gnc_filter_text_for_currency_symbol ( const gchar *  incoming_text,
const gchar *  symbol 
)

Returns the incoming text removed of a currency symbol.

Parameters
incoming_textThe text to filter
symbolto remove
cursor_positionthe position of cursor in the incoming text
Returns
The incoming text with symbol removed to be freed by the caller

Definition at line 2683 of file gnc-ui-util.c.

2685 {
2686  gchar *ret_text = NULL;
2687  gchar **split;
2688 
2689  if (!incoming_text)
2690  return NULL;
2691 
2692  if (!symbol)
2693  return g_strdup (incoming_text);
2694 
2695  if (g_strrstr (incoming_text, symbol) == NULL)
2696  return g_strdup (incoming_text);
2697 
2698  split = g_strsplit (incoming_text, symbol, -1);
2699 
2700  ret_text = g_strjoinv (NULL, split);
2701 
2702  g_strfreev (split);
2703  return ret_text;
2704 }

◆ gnc_filter_text_set_cursor_position()

void gnc_filter_text_set_cursor_position ( const gchar *  incoming_text,
const gchar *  symbol,
gint *  cursor_position 
)

Updates cursor_position after removal of currency symbols.

Parameters
incoming_textThe text to filter
symbolto remove
cursor_positionthe position of cursor in the incoming text
Returns
nothing

Definition at line 2651 of file gnc-ui-util.c.

2654 {
2655  gint text_len;
2656  gint num = 0;
2657 
2658  if (*cursor_position == 0)
2659  return;
2660 
2661  if (!incoming_text || !symbol)
2662  return;
2663 
2664  if (g_strrstr (incoming_text, symbol) == NULL)
2665  return;
2666 
2667  text_len = g_utf8_strlen (incoming_text, -1);
2668 
2669  for (gint x = 0; x < text_len; x++)
2670  {
2671  gchar *temp = g_utf8_offset_to_pointer (incoming_text, x);
2672 
2673  if (g_str_has_prefix (temp, symbol))
2674  num++;
2675 
2676  if (g_strrstr (temp, symbol) == NULL)
2677  break;
2678  }
2679  *cursor_position = *cursor_position - (num * g_utf8_strlen (symbol, -1));
2680 }

◆ gnc_get_account_name_for_register()

gchar* gnc_get_account_name_for_register ( const Account account)

Get either the full name of the account or the simple name, depending on the configuration parameter general/register/show_leaf_account_names.

Parameters
accountThe account to retrieve the name for.
Returns
A newly allocated string.

Definition at line 581 of file gnc-ui-util.c.

582 {
583  gboolean show_leaf_accounts;
584  show_leaf_accounts = gnc_prefs_get_bool(GNC_PREFS_GROUP_GENERAL_REGISTER,
585  GNC_PREF_SHOW_LEAF_ACCT_NAMES);
586 
587  return gnc_get_account_name_for_split_register(account, show_leaf_accounts);
588 }
gchar * gnc_get_account_name_for_split_register(const Account *account, gboolean show_leaf_accounts)
Get either the full name of the account or the simple name, depending on the show_leaf_accounts.
Definition: gnc-ui-util.c:572
gboolean gnc_prefs_get_bool(const gchar *group, const gchar *pref_name)
Get a boolean value from the preferences backend.

◆ gnc_get_account_name_for_split_register()

gchar* gnc_get_account_name_for_split_register ( const Account account,
gboolean  show_leaf_accounts 
)

Get either the full name of the account or the simple name, depending on the show_leaf_accounts.

Parameters
accountThe account to retrieve the name for.
show_leaf_accountsWhether the full name will be returned.
Returns
A newly allocated string.

Definition at line 572 of file gnc-ui-util.c.

573 {
574  if (show_leaf_accounts)
575  return g_strdup (xaccAccountGetName (account));
576  else
577  return gnc_account_get_full_name (account);
578 }
gchar * gnc_account_get_full_name(const Account *account)
The gnc_account_get_full_name routine returns the fully qualified name of the account using the given...
Definition: Account.cpp:3308
const char * xaccAccountGetName(const Account *acc)
Get the account&#39;s name.
Definition: Account.cpp:3301

◆ gnc_get_doclink_flag_order()

const char* gnc_get_doclink_flag_order ( void  )

Get a string containing document link flag order.

Returns
a string containing the document link flag change order

Definition at line 940 of file gnc-ui-util.c.

941 {
942  static const char flags[] = { FLINK, WLINK, ' ', 0 };
943  return flags;
944 }

◆ gnc_get_doclink_str()

const char* gnc_get_doclink_str ( char  link_flag)

Get a string representing the document link type.

Parameters
link_flagThe flag to convert into a string
Returns
the i18n'd doclink string

Definition at line 916 of file gnc-ui-util.c.

917 {
918  switch (link_flag)
919  {
920  case WLINK:
921  return C_("Document Link flag for 'web'", "w");
922  case FLINK:
923  return C_("Document Link flag for 'file'", "f");
924  case ' ':
925  return " ";
926  default:
927  PERR("Bad link flag");
928  return NULL;
929  }
930 }
#define PERR(format, args...)
Log a serious error.
Definition: qoflog.h:244

◆ gnc_get_doclink_valid_flags()

const char* gnc_get_doclink_valid_flags ( void  )

Get a string containing documentation link valid flags.

Returns
a string containing the list of valid link_flags

Definition at line 933 of file gnc-ui-util.c.

934 {
935  static const char flags[] = { FLINK, WLINK, ' ', 0 };
936  return flags;
937 }

◆ gnc_locale_default_currency()

gnc_commodity* gnc_locale_default_currency ( void  )

Returns the default currency of the current locale.

WATCH OUT: If no currency could be identified from the locale, this one returns "USD", but this will have nothing to do with the actual locale.

Definition at line 1151 of file gnc-ui-util.c.

1152 {
1153  gnc_commodity * currency = gnc_locale_default_currency_nodefault ();
1154 
1155  return (currency ? currency :
1156  gnc_commodity_table_lookup (gnc_get_current_commodities (),
1157  GNC_COMMODITY_NS_CURRENCY, "USD"));
1158 }
gnc_commodity * gnc_locale_default_currency_nodefault(void)
Returns the default currency of the current locale, or NULL if no sensible currency could be identifi...
Definition: gnc-ui-util.c:1136

◆ gnc_locale_default_currency_nodefault()

gnc_commodity* gnc_locale_default_currency_nodefault ( void  )

Returns the default currency of the current locale, or NULL if no sensible currency could be identified from the locale.

Definition at line 1136 of file gnc-ui-util.c.

1137 {
1138  gnc_commodity * currency;
1139  gnc_commodity_table *table;
1140  const char *code;
1141 
1142  table = gnc_get_current_commodities ();
1143  code = gnc_locale_default_iso_currency_code ();
1144 
1145  currency = gnc_commodity_table_lookup (table, GNC_COMMODITY_NS_CURRENCY, code);
1146 
1147  return (currency ? currency : NULL);
1148 }

◆ gnc_print_amount_with_bidi_ltr_isolate()

const char* gnc_print_amount_with_bidi_ltr_isolate ( gnc_numeric  val,
GNCPrintAmountInfo  info 
)

Make a string representation of a gnc_numeric.

Warning, the gnc_numeric is not checked for validity and the returned char* may point to random garbage.

This is the same as xaccPrintAmount but wraps the output with BiDi left to right isolate if a symbol is displayed.

Definition at line 1872 of file gnc-ui-util.c.

1873 {
1874  /* hack alert -- this is not thread safe ... */
1875  static char buf[BUFLEN];
1876  static const char ltr_isolate[] = { 0xe2, 0x81, 0xa6 };
1877  static const char ltr_pop_isolate[] = { 0xe2, 0x81, 0xa9 };
1878  size_t offset = info.use_symbol ? 3 : 0;
1879 
1880  memset (buf, 0, BUFLEN);
1881  if (!xaccSPrintAmount (buf + offset, val, info))
1882  {
1883  buf[0] = '\0';
1884  return buf;
1885  };
1886 
1887  if (!info.use_symbol)
1888  return buf;
1889 
1890  memcpy (buf, ltr_isolate, 3);
1891 
1892  if (buf[BUFLEN - 4] == '\0')
1893  {
1894  size_t length = strlen (buf);
1895  memcpy (buf + length, ltr_pop_isolate, 3);
1896  }
1897  else
1898  {
1899  buf[BUFLEN - 1] = '\0';
1900  memcpy (buf + BUFLEN - 4, ltr_pop_isolate, 3);
1901 
1902  PWARN("buffer length %d exceeded, string truncated was %s", BUFLEN, buf);
1903  }
1904  /* its OK to return buf, since we declared it static
1905  and is immediately g_strdup'd */
1906  return buf;
1907 }
#define PWARN(format, args...)
Log a warning.
Definition: qoflog.h:250
int xaccSPrintAmount(char *bufp, gnc_numeric val, GNCPrintAmountInfo info)
Make a string representation of a gnc_numeric.
Definition: gnc-ui-util.c:1728

◆ gnc_wrap_text_with_bidi_ltr_isolate()

gchar* gnc_wrap_text_with_bidi_ltr_isolate ( const char *  text)

This function helps with GTK's use of 'Unicode Bidirectional Text Algorithm'.

To keep the format of the text, this function wraps the text with a BiDi isolate charatcter and a BiDi closing character.

This helps with monetary values in RTL languages that display the currency symbol.

◆ xaccParseAmount()

gboolean xaccParseAmount ( const char *  in_str,
gboolean  monetary,
gnc_numeric *  result,
char **  endstr 
)

Parses in_str to obtain a numeric result.

The routine will parse as much of in_str as it can to obtain a single number. The number is parsed using the current locale information and the 'monetary' flag. The routine will return TRUE if it successfully parsed a number and FALSE otherwise. If TRUE is returned and result is non-NULL, the value of the parsed number is stored in *result. If FALSE is returned, *result is unchanged. If TRUE is returned and endstr is non-NULL, the location of the first character in in_str not used by the parser will be returned in *endstr. If FALSE is returned and endstr is non-NULL, *endstr will point to in_str.

Definition at line 2154 of file gnc-ui-util.c.

2156 {
2157  return xaccParseAmountPosSign (in_str, monetary, result, endstr, FALSE);
2158 }
gboolean xaccParseAmountPosSign(const char *in_str, gboolean monetary, gnc_numeric *result, char **endstr, gboolean skip)
Parses in_str to a gnc_numeric, with a flag to indicate whether the locale&#39;s positive sign (or in abs...
Definition: gnc-ui-util.c:2161

◆ xaccParseAmountExtended()

gboolean xaccParseAmountExtended ( const char *  in_str,
gboolean  monetary,
gunichar  negative_sign,
gunichar  decimal_point,
gunichar  group_separator,
const char *  ignore_list,
gnc_numeric *  result,
char **  endstr 
)

Converts a string to a gnc_numeric.

The caller must provide all the locale-specific information.

ignore_list is a list of characters that are completely ignored while processing the input string. If ignore_list is NULL, nothing is ignored.

Definition at line 2200 of file gnc-ui-util.c.

2204 {
2205  gboolean is_negative;
2206  gboolean got_decimal;
2207  gboolean need_paren;
2208  long long int numer;
2209  long long int denom;
2210  int count;
2211 
2212  ParseState state;
2213 
2214  const gchar *in;
2215  gunichar uc;
2216  gchar *out_str;
2217  gchar *out;
2218 
2219  /* Initialize *endstr to in_str */
2220  if (endstr != NULL)
2221  *endstr = (char *) in_str;
2222 
2223  if (in_str == NULL)
2224  return FALSE;
2225 
2226  if (!g_utf8_validate(in_str, -1, &in))
2227  {
2228  printf("Invalid utf8 string '%s'. Bad character at position %ld.\n",
2229  in_str, g_utf8_pointer_to_offset (in_str, in));
2230  return FALSE;
2231  }
2232 
2233  /* 'out_str' will be used to store digits for numeric conversion.
2234  * 'out' will be used to traverse out_str. */
2235  out = out_str = g_new(gchar, strlen(in_str) + 128);
2236 
2237  /* 'in' is used to traverse 'in_str'. */
2238  in = in_str;
2239 
2240  is_negative = FALSE;
2241  got_decimal = FALSE;
2242  need_paren = FALSE;
2243  numer = 0;
2244  denom = 1;
2245 
2246  /* Initialize the state machine */
2247  state = START_ST;
2248 
2249  /* This while loop implements a state machine for parsing numbers. */
2250  while (TRUE)
2251  {
2252  ParseState next_state = state;
2253 
2254  uc = g_utf8_get_char(in);
2255 
2256  /* Ignore anything in the 'ignore list' */
2257  if (ignore_list && uc && g_utf8_strchr(ignore_list, -1, uc) != NULL)
2258  {
2259  in = g_utf8_next_char(in);
2260  continue;
2261  }
2262 
2263  /* Note we never need to check for the end of 'in_str' explicitly.
2264  * The 'else' clauses on all the state transitions will handle that. */
2265  switch (state)
2266  {
2267  /* START_ST means we have parsed 0 or more whitespace characters */
2268  case START_ST:
2269  if (g_unichar_isdigit(uc))
2270  {
2271  count = g_unichar_to_utf8(uc, out);
2272  out += count; /* we record the digits themselves in out_str
2273  * for later conversion by libc routines */
2274  next_state = NUMER_ST;
2275  }
2276  else if (uc == decimal_point)
2277  {
2278  next_state = FRAC_ST;
2279  }
2280  else if (g_unichar_isspace(uc))
2281  {
2282  }
2283  else if (uc == negative_sign)
2284  {
2285  is_negative = TRUE;
2286  next_state = NEG_ST;
2287  }
2288  else if (uc == '(')
2289  {
2290  is_negative = TRUE;
2291  need_paren = TRUE;
2292  next_state = NEG_ST;
2293  }
2294  else
2295  {
2296  next_state = NO_NUM_ST;
2297  }
2298 
2299  break;
2300 
2301  /* NEG_ST means we have just parsed a negative sign. For now,
2302  * we only recognize formats where the negative sign comes first. */
2303  case NEG_ST:
2304  if (g_unichar_isdigit(uc))
2305  {
2306  count = g_unichar_to_utf8(uc, out);
2307  out += count;
2308  next_state = NUMER_ST;
2309  }
2310  else if (uc == decimal_point)
2311  {
2312  next_state = FRAC_ST;
2313  }
2314  else if (g_unichar_isspace(uc))
2315  {
2316  }
2317  else
2318  {
2319  next_state = NO_NUM_ST;
2320  }
2321 
2322  break;
2323 
2324  /* NUMER_ST means we have started parsing the number, but
2325  * have not encountered a decimal separator. */
2326  case NUMER_ST:
2327  if (g_unichar_isdigit(uc))
2328  {
2329  count = g_unichar_to_utf8(uc, out);
2330  out += count;
2331  }
2332  else if (uc == decimal_point)
2333  {
2334  next_state = FRAC_ST;
2335  }
2336  else if (uc == group_separator)
2337  {
2338  ; //ignore it
2339  }
2340  else if (uc == ')' && need_paren)
2341  {
2342  next_state = DONE_ST;
2343  need_paren = FALSE;
2344  }
2345  else
2346  {
2347  next_state = DONE_ST;
2348  }
2349 
2350  break;
2351 
2352  /* FRAC_ST means we are now parsing fractional digits. */
2353  case FRAC_ST:
2354  if (g_unichar_isdigit(uc))
2355  {
2356  count = g_unichar_to_utf8(uc, out);
2357  out += count;
2358  }
2359  else if (uc == decimal_point)
2360  {
2361  /* If a subsequent decimal point is also whitespace,
2362  * assume it was intended as such and stop parsing.
2363  * Otherwise, there is a problem. */
2364  if (g_unichar_isspace(decimal_point))
2365  next_state = DONE_ST;
2366  else
2367  next_state = NO_NUM_ST;
2368  }
2369  else if (uc == group_separator)
2370  {
2371  /* If a subsequent group separator is also whitespace,
2372  * assume it was intended as such and stop parsing.
2373  * Otherwise ignore it. */
2374  if (g_unichar_isspace(group_separator))
2375  next_state = DONE_ST;
2376  }
2377  else if (uc == ')' && need_paren)
2378  {
2379  next_state = DONE_ST;
2380  need_paren = FALSE;
2381  }
2382  else
2383  {
2384  next_state = DONE_ST;
2385  }
2386 
2387  break;
2388 
2389  default:
2390  PERR("bad state");
2391  g_assert_not_reached();
2392  break;
2393  }
2394 
2395  /* If we're moving into the FRAC_ST or out of the machine
2396  * without going through FRAC_ST, record the integral value. */
2397  if (((next_state == FRAC_ST) && (state != FRAC_ST)) ||
2398  ((next_state == DONE_ST) && !got_decimal))
2399  {
2400  *out = '\0';
2401 
2402  if (*out_str != '\0' && sscanf(out_str, QOF_SCANF_LLD, &numer) < 1)
2403  {
2404  next_state = NO_NUM_ST;
2405  }
2406  else if (next_state == FRAC_ST)
2407  {
2408  /* reset the out pointer to record the fraction */
2409  out = out_str;
2410  *out = '\0';
2411 
2412  got_decimal = TRUE;
2413  }
2414  }
2415 
2416  state = next_state;
2417  if (done_state (state))
2418  break;
2419 
2420  in = g_utf8_next_char(in);
2421  }
2422 
2423  /* If there was an error, just quit */
2424  if (need_paren || (state == NO_NUM_ST))
2425  {
2426  g_free(out_str);
2427  return FALSE;
2428  }
2429 
2430  /* Cap the end of the fraction string, if any */
2431  *out = '\0';
2432 
2433  /* Add in fractional value */
2434  if (got_decimal && (*out_str != '\0'))
2435  {
2436  size_t len;
2437  long long int fraction;
2438 
2439  len = strlen(out_str);
2440 
2441  if (len > 12)
2442  {
2443  out_str[12] = '\0';
2444  len = 12;
2445  }
2446 
2447  if (sscanf (out_str, QOF_SCANF_LLD, &fraction) < 1)
2448  {
2449  g_free(out_str);
2450  return FALSE;
2451  }
2452 
2453  denom = multiplier(len);
2454  numer *= denom;
2455  numer += fraction;
2456  }
2457  else if (monetary && auto_decimal_enabled && !got_decimal)
2458  {
2459  if ((auto_decimal_places > 0) && (auto_decimal_places <= 12))
2460  {
2461  denom = multiplier(auto_decimal_places);
2462 
2463  /* No need to multiply numer by denom at this point,
2464  * since by specifying the auto decimal places the
2465  * user has effectively determined the scaling factor
2466  * for the numerator they entered.
2467  */
2468  }
2469  }
2470 
2471  if (result != NULL)
2472  {
2473  *result = gnc_numeric_create (numer, denom);
2474  if (is_negative)
2475  *result = gnc_numeric_neg (*result);
2476  }
2477 
2478  if (endstr != NULL)
2479  *endstr = (char *) in;
2480 
2481  g_free (out_str);
2482 
2483  return TRUE;
2484 }
gnc_numeric gnc_numeric_neg(gnc_numeric a)
Returns a newly created gnc_numeric that is the negative of the given gnc_numeric value...
#define PERR(format, args...)
Log a serious error.
Definition: qoflog.h:244

◆ xaccParseAmountPosSign()

gboolean xaccParseAmountPosSign ( const char *  in_str,
gboolean  monetary,
gnc_numeric *  result,
char **  endstr,
gboolean  skip 
)

Parses in_str to a gnc_numeric, with a flag to indicate whether the locale's positive sign (or in absence the '+') character is ignored.

Setting skip to TRUE will cause the function to ignore any positive sign. Setting it to FALSE, and positive signs will be treated as unrecognized characters. xaccParseAmount will run as if skip is FALSE for compatibility reasons (gnc-expression-parser depends on this behaviour).

Definition at line 2161 of file gnc-ui-util.c.

2163 {
2164  struct lconv *lc = gnc_localeconv();
2165 
2166  gunichar negative_sign;
2167  gunichar decimal_point;
2168  gunichar group_separator;
2169  gchar *ignore = NULL;
2170  char *plus_sign = "+";
2171 
2172  negative_sign = g_utf8_get_char(lc->negative_sign);
2173  if (monetary)
2174  {
2175  group_separator = g_utf8_get_char(lc->mon_thousands_sep);
2176  decimal_point = g_utf8_get_char(lc->mon_decimal_point);
2177  }
2178  else
2179  {
2180  group_separator = g_utf8_get_char(lc->thousands_sep);
2181  decimal_point = g_utf8_get_char(lc->decimal_point);
2182  }
2183 
2184  if (skip)
2185  {
2186  /* We want the locale's positive sign to be ignored.
2187  * If the locale doesn't specify one, we assume "+" as
2188  * an optional positive sign and ignore that */
2189  ignore = lc->positive_sign;
2190  if (!ignore || !*ignore)
2191  ignore = plus_sign;
2192  }
2193 
2194  return xaccParseAmountExtended(in_str, monetary, negative_sign,
2195  decimal_point, group_separator,
2196  ignore, result, endstr);
2197 }
gboolean xaccParseAmountExtended(const char *in_str, gboolean monetary, gunichar negative_sign, gunichar decimal_point, gunichar group_separator, const char *ignore_list, gnc_numeric *result, char **endstr)
Converts a string to a gnc_numeric.
Definition: gnc-ui-util.c:2200

◆ xaccPrintAmount()

const char* xaccPrintAmount ( gnc_numeric  val,
GNCPrintAmountInfo  info 
)

Make a string representation of a gnc_numeric.

Warning, the gnc_numeric is not checked for validity and the returned char* may point to random garbage.

Definition at line 1859 of file gnc-ui-util.c.

1860 {
1861  /* hack alert -- this is not thread safe ... */
1862  static char buf[BUFLEN];
1863 
1864  if (!xaccSPrintAmount (buf, val, info))
1865  buf[0] = '\0';
1866 
1867  /* its OK to return buf, since we declared it static */
1868  return buf;
1869 }
int xaccSPrintAmount(char *bufp, gnc_numeric val, GNCPrintAmountInfo info)
Make a string representation of a gnc_numeric.
Definition: gnc-ui-util.c:1728

◆ xaccSPrintAmount()

int xaccSPrintAmount ( char *  bufp,
gnc_numeric  val,
GNCPrintAmountInfo  info 
)

Make a string representation of a gnc_numeric.

Warning, the gnc_numeric is not checked for validity and the contents of the buffer will be unchanged. It is up to the calling function to ensure that buf is large enough for the results.

Parameters
bufpShould be at least 64 chars.

Definition at line 1728 of file gnc-ui-util.c.

1729 {
1730  struct lconv *lc;
1731 
1732  char *orig_bufp = bufp;
1733  const char *currency_symbol;
1734  const char *sign;
1735 
1736  char cs_precedes;
1737  char sep_by_space;
1738  char sign_posn;
1739 
1740  gboolean print_sign = TRUE;
1741  gboolean print_absolute = FALSE;
1742 
1743  if (!bufp)
1744  return 0;
1745 
1746  lc = gnc_localeconv();
1747  if (info.use_locale)
1748  if (gnc_numeric_negative_p (val))
1749  {
1750  cs_precedes = lc->n_cs_precedes;
1751  sep_by_space = lc->n_sep_by_space;
1752  }
1753  else
1754  {
1755  cs_precedes = lc->p_cs_precedes;
1756  sep_by_space = lc->p_sep_by_space;
1757  }
1758  else
1759  {
1760  cs_precedes = TRUE;
1761  sep_by_space = TRUE;
1762  }
1763 
1764  if (info.commodity && info.use_symbol)
1765  {
1766  currency_symbol = gnc_commodity_get_nice_symbol (info.commodity);
1767  if (!gnc_commodity_is_iso (info.commodity))
1768  {
1769  cs_precedes = FALSE;
1770  sep_by_space = TRUE;
1771  }
1772  }
1773  else /* !info.use_symbol || !info.commodity */
1774  currency_symbol = "";
1775 
1776  if (gnc_numeric_negative_p (val))
1777  {
1778  sign = lc->negative_sign;
1779  sign_posn = lc->n_sign_posn;
1780  }
1781  else
1782  {
1783  sign = lc->positive_sign;
1784  sign_posn = lc->p_sign_posn;
1785  }
1786 
1787  if (gnc_numeric_zero_p (val) || (sign == NULL) || (sign[0] == 0))
1788  print_sign = FALSE;
1789 
1790  /* See if we print sign now */
1791  if (print_sign && (sign_posn == 1))
1792  bufp = g_stpcpy(bufp, sign);
1793 
1794  /* Now see if we print currency */
1795  if (cs_precedes)
1796  {
1797  /* See if we print sign now */
1798  if (print_sign && (sign_posn == 3))
1799  bufp = g_stpcpy(bufp, sign);
1800 
1801  if (info.use_symbol)
1802  {
1803  bufp = g_stpcpy(bufp, currency_symbol);
1804  if (sep_by_space)
1805  bufp = g_stpcpy(bufp, " ");
1806  }
1807 
1808  /* See if we print sign now */
1809  if (print_sign && (sign_posn == 4))
1810  bufp = g_stpcpy(bufp, sign);
1811  }
1812 
1813  /* Now see if we print parentheses */
1814  if (print_sign && (sign_posn == 0))
1815  {
1816  bufp = g_stpcpy(bufp, "(");
1817  print_absolute = TRUE;
1818  }
1819 
1820  /* Now print the value */
1821  bufp += PrintAmountInternal(bufp,
1822  print_absolute ? gnc_numeric_abs(val) : val,
1823  &info);
1824 
1825  /* Now see if we print parentheses */
1826  if (print_sign && (sign_posn == 0))
1827  bufp = g_stpcpy(bufp, ")");
1828 
1829  /* Now see if we print currency */
1830  if (!cs_precedes)
1831  {
1832  /* See if we print sign now */
1833  if (print_sign && (sign_posn == 3))
1834  bufp = g_stpcpy(bufp, sign);
1835 
1836  if (info.use_symbol)
1837  {
1838  if (sep_by_space)
1839  bufp = g_stpcpy(bufp, " ");
1840  bufp = g_stpcpy(bufp, currency_symbol);
1841  }
1842 
1843  /* See if we print sign now */
1844  if (print_sign && (sign_posn == 4))
1845  bufp = g_stpcpy(bufp, sign);
1846  }
1847 
1848  /* See if we print sign now */
1849  if (print_sign && (sign_posn == 2))
1850  bufp = g_stpcpy(bufp, sign);
1851 
1852  /* return length of printed string */
1853  return (bufp - orig_bufp);
1854 }
gboolean gnc_numeric_zero_p(gnc_numeric a)
Returns 1 if the given gnc_numeric is 0 (zero), else returns 0.
gboolean gnc_numeric_negative_p(gnc_numeric a)
Returns 1 if a < 0, otherwise returns 0.
const char * gnc_commodity_get_nice_symbol(const gnc_commodity *cm)
Retrieve a symbol for the specified commodity, suitable for display to the user.
gnc_numeric gnc_numeric_abs(gnc_numeric a)
Returns a newly created gnc_numeric that is the absolute value of the given gnc_numeric value...
gboolean gnc_commodity_is_iso(const gnc_commodity *cm)
Checks to see if the specified commodity is an ISO 4217 recognized currency.