mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Merge Bob Fewell's 'rtl' into maint.
This commit is contained in:
commit
e63baa6270
@ -560,6 +560,7 @@ gnc_tree_model_account_compute_period_balance (GncTreeModelAccount *model,
|
||||
gboolean *negative)
|
||||
{
|
||||
GncTreeModelAccountPrivate *priv;
|
||||
GNCPrintAmountInfo print_info;
|
||||
time64 t1, t2;
|
||||
gnc_numeric b3;
|
||||
|
||||
@ -583,7 +584,9 @@ gnc_tree_model_account_compute_period_balance (GncTreeModelAccount *model,
|
||||
if (negative)
|
||||
*negative = gnc_numeric_negative_p (b3);
|
||||
|
||||
return g_strdup(xaccPrintAmount (b3, gnc_account_print_info (acct, TRUE)));
|
||||
print_info = gnc_account_print_info (acct, TRUE);
|
||||
|
||||
return g_strdup (gnc_print_amount_with_bidi_ltr_isolate (b3, print_info));
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -399,6 +399,7 @@ gnc_main_window_summary_refresh (GNCMainSummary * summary)
|
||||
for (current = g_list_first(currency_list); current; current = g_list_next(current))
|
||||
{
|
||||
gchar *total_mode_label;
|
||||
gchar *bidi_total, *bidi_asset_amount, *bidi_profit_amount;
|
||||
|
||||
currency_accum = current->data;
|
||||
|
||||
@ -412,16 +413,22 @@ gnc_main_window_summary_refresh (GNCMainSummary * summary)
|
||||
|
||||
gtk_list_store_append(summary->datamodel, &iter);
|
||||
total_mode_label = get_total_mode_label (currency_accum);
|
||||
bidi_total = gnc_wrap_text_with_bidi_ltr_isolate(total_mode_label);
|
||||
bidi_asset_amount = gnc_wrap_text_with_bidi_ltr_isolate(asset_amount_string);
|
||||
bidi_profit_amount = gnc_wrap_text_with_bidi_ltr_isolate(profit_amount_string);
|
||||
gtk_list_store_set(summary->datamodel, &iter,
|
||||
COLUMN_MNEMONIC_TYPE, total_mode_label,
|
||||
COLUMN_MNEMONIC_TYPE, bidi_total,
|
||||
COLUMN_ASSETS, _("Net Assets:"),
|
||||
COLUMN_ASSETS_VALUE, asset_amount_string,
|
||||
COLUMN_ASSETS_VALUE, bidi_asset_amount,
|
||||
COLUMN_ASSETS_NEG, gnc_numeric_negative_p(currency_accum->assets),
|
||||
COLUMN_PROFITS, _("Profits:"),
|
||||
COLUMN_PROFITS_VALUE, profit_amount_string,
|
||||
COLUMN_PROFITS_VALUE, bidi_profit_amount,
|
||||
COLUMN_PROFITS_NEG, gnc_numeric_negative_p(currency_accum->profits),
|
||||
-1);
|
||||
g_free(total_mode_label);
|
||||
g_free(bidi_total);
|
||||
g_free(bidi_asset_amount);
|
||||
g_free(bidi_profit_amount);
|
||||
}
|
||||
gtk_combo_box_set_model(GTK_COMBO_BOX(summary->totals_combo),
|
||||
GTK_TREE_MODEL(summary->datamodel));
|
||||
|
@ -1715,10 +1715,14 @@ static void
|
||||
gnc_invoice_reset_total_label (GtkLabel *label, gnc_numeric amt, gnc_commodity *com)
|
||||
{
|
||||
char string[256];
|
||||
gchar *bidi_string;
|
||||
|
||||
amt = gnc_numeric_convert (amt, gnc_commodity_get_fraction(com), GNC_HOW_RND_ROUND_HALF_UP);
|
||||
xaccSPrintAmount (string, amt, gnc_commodity_print_info (com, TRUE));
|
||||
gtk_label_set_text (label, string);
|
||||
|
||||
bidi_string = gnc_wrap_text_with_bidi_ltr_isolate (string);
|
||||
gtk_label_set_text (label, bidi_string);
|
||||
g_free (bidi_string);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -578,7 +578,7 @@ gsr_update_summary_label( GtkWidget *label,
|
||||
char string[256];
|
||||
const gchar *label_str = NULL;
|
||||
GtkWidget *text_label, *hbox;
|
||||
gchar *tooltip;
|
||||
gchar *bidi_string;
|
||||
|
||||
if ( label == NULL )
|
||||
return;
|
||||
@ -605,11 +605,13 @@ gsr_update_summary_label( GtkWidget *label,
|
||||
}
|
||||
|
||||
gnc_set_label_color( label, amount );
|
||||
gtk_label_set_text( GTK_LABEL(label), string );
|
||||
bidi_string = gnc_wrap_text_with_bidi_ltr_isolate (string);
|
||||
gtk_label_set_text( GTK_LABEL(label), bidi_string );
|
||||
g_free (bidi_string);
|
||||
|
||||
if (label_str)
|
||||
{
|
||||
tooltip = g_strdup_printf ("%s %s", label_str, string);
|
||||
gchar *tooltip = g_strdup_printf ("%s %s", label_str, string);
|
||||
gtk_widget_set_tooltip_text (GTK_WIDGET(hbox), tooltip);
|
||||
g_free (tooltip);
|
||||
}
|
||||
|
@ -146,7 +146,8 @@ gnc_ui_account_get_print_balance (xaccGetBalanceInCurrencyFn fn,
|
||||
balance = gnc_ui_account_get_balance_full(fn, account, recurse,
|
||||
negative, NULL);
|
||||
print_info = gnc_account_print_info(account, TRUE);
|
||||
return g_strdup(xaccPrintAmount(balance, print_info));
|
||||
|
||||
return g_strdup (gnc_print_amount_with_bidi_ltr_isolate (balance, print_info));
|
||||
}
|
||||
|
||||
|
||||
@ -178,7 +179,8 @@ gnc_ui_account_get_print_report_balance (xaccGetBalanceInCurrencyFn fn,
|
||||
balance = gnc_ui_account_get_balance_full(fn, account, recurse,
|
||||
negative, report_commodity);
|
||||
print_info = gnc_commodity_print_info(report_commodity, TRUE);
|
||||
return g_strdup(xaccPrintAmount(balance, print_info));
|
||||
|
||||
return g_strdup (gnc_print_amount_with_bidi_ltr_isolate (balance, print_info));
|
||||
}
|
||||
|
||||
static gnc_numeric
|
||||
@ -312,7 +314,8 @@ gnc_ui_owner_get_print_balance (GncOwner *owner,
|
||||
|
||||
balance = gnc_ui_owner_get_balance_full (owner, negative, NULL);
|
||||
print_info = gnc_commodity_print_info (gncOwnerGetCurrency (owner), TRUE);
|
||||
return g_strdup (xaccPrintAmount (balance, print_info));
|
||||
|
||||
return g_strdup (gnc_print_amount_with_bidi_ltr_isolate (balance, print_info));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -338,6 +341,7 @@ gnc_ui_owner_get_print_report_balance (GncOwner *owner,
|
||||
balance = gnc_ui_owner_get_balance_full (owner, negative,
|
||||
report_commodity);
|
||||
print_info = gnc_commodity_print_info (report_commodity, TRUE);
|
||||
return g_strdup (xaccPrintAmount (balance, print_info));
|
||||
|
||||
return g_strdup (gnc_print_amount_with_bidi_ltr_isolate (balance, print_info));
|
||||
}
|
||||
|
||||
|
@ -1850,11 +1850,13 @@ xaccSPrintAmount (char * bufp, gnc_numeric val, GNCPrintAmountInfo info)
|
||||
return (bufp - orig_bufp);
|
||||
}
|
||||
|
||||
#define BUFLEN 1024
|
||||
|
||||
const char *
|
||||
xaccPrintAmount (gnc_numeric val, GNCPrintAmountInfo info)
|
||||
{
|
||||
/* hack alert -- this is not thread safe ... */
|
||||
static char buf[1024];
|
||||
static char buf[BUFLEN];
|
||||
|
||||
if (!xaccSPrintAmount (buf, val, info))
|
||||
buf[0] = '\0';
|
||||
@ -1863,6 +1865,55 @@ xaccPrintAmount (gnc_numeric val, GNCPrintAmountInfo info)
|
||||
return buf;
|
||||
}
|
||||
|
||||
const char *
|
||||
gnc_print_amount_with_bidi_ltr_isolate (gnc_numeric val, GNCPrintAmountInfo info)
|
||||
{
|
||||
/* hack alert -- this is not thread safe ... */
|
||||
static char buf[BUFLEN];
|
||||
static const char ltr_isolate[] = { 0xe2, 0x81, 0xa6 };
|
||||
static const char ltr_pop_isolate[] = { 0xe2, 0x81, 0xa9 };
|
||||
size_t offset = info.use_symbol ? 3 : 0;
|
||||
|
||||
memset (buf, 0, BUFLEN);
|
||||
if (!xaccSPrintAmount (buf + offset, val, info))
|
||||
{
|
||||
buf[0] = '\0';
|
||||
return buf;
|
||||
};
|
||||
|
||||
if (!info.use_symbol)
|
||||
return buf;
|
||||
|
||||
memcpy (buf, ltr_isolate, 3);
|
||||
|
||||
if (buf[BUFLEN - 4] == '\0')
|
||||
{
|
||||
size_t length = strlen (buf);
|
||||
memcpy (buf + length, ltr_pop_isolate, 3);
|
||||
}
|
||||
else
|
||||
{
|
||||
buf[BUFLEN - 1] = '\0';
|
||||
memcpy (buf + BUFLEN - 4, ltr_pop_isolate, 3);
|
||||
|
||||
PWARN("buffer length %d exceeded, string truncated was %s", BUFLEN, buf);
|
||||
}
|
||||
/* its OK to return buf, since we declared it static
|
||||
and is immediately g_strdup'd */
|
||||
return buf;
|
||||
}
|
||||
|
||||
gchar *
|
||||
gnc_wrap_text_with_bidi_ltr_isolate (const gchar *text)
|
||||
{
|
||||
static const char *ltr = "\u2066"; // ltr isolate
|
||||
static const char *pop = "\u2069"; // pop directional formatting
|
||||
|
||||
if (!text)
|
||||
return NULL;
|
||||
|
||||
return g_strconcat (ltr, text, pop, NULL);
|
||||
}
|
||||
|
||||
/********************************************************************\
|
||||
********************************************************************/
|
||||
|
@ -401,6 +401,28 @@ xaccParseAmountExtended (const char * in_str, gboolean monetary,
|
||||
gunichar group_separator, const char *ignore_list,
|
||||
gnc_numeric *result, char **endstr);
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
const char *
|
||||
gnc_print_amount_with_bidi_ltr_isolate (gnc_numeric val, GNCPrintAmountInfo info);
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
gchar *
|
||||
gnc_wrap_text_with_bidi_ltr_isolate (const char *text);
|
||||
|
||||
/* Initialization ***************************************************/
|
||||
|
||||
void gnc_ui_util_init (void);
|
||||
@ -446,9 +468,9 @@ gchar * gnc_filter_text_for_currency_symbol (const gchar *incoming_text,
|
||||
const gchar *symbol);
|
||||
|
||||
/** Returns the incoming text removed of currency symbol
|
||||
*
|
||||
*
|
||||
* @param comm commodity of entry if known
|
||||
*
|
||||
*
|
||||
* @param incoming_text The text to filter
|
||||
*
|
||||
* @param symbol return the symbol used
|
||||
|
Loading…
Reference in New Issue
Block a user