mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Add filter for currency symbol for GNCAmountEdit widget
When pasting an amount that includes the currency symbol the validation will silently fail which may lead to unusual behaviour.
This commit is contained in:
@@ -2784,3 +2784,28 @@ gnc_filter_text_for_currency_symbol (const gchar *incoming_text,
|
||||
g_strfreev (split);
|
||||
return ret_text;
|
||||
}
|
||||
|
||||
gchar *
|
||||
gnc_filter_text_for_currency_commodity (const gnc_commodity *comm,
|
||||
const gchar *incoming_text,
|
||||
const gchar **symbol)
|
||||
{
|
||||
if (!incoming_text)
|
||||
{
|
||||
*symbol = NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!gnc_commodity_is_currency (comm))
|
||||
{
|
||||
*symbol = NULL;
|
||||
return g_strdup (incoming_text);
|
||||
}
|
||||
|
||||
if (comm)
|
||||
*symbol = gnc_commodity_get_nice_symbol (comm);
|
||||
else
|
||||
*symbol = gnc_commodity_get_nice_symbol (gnc_default_currency ());
|
||||
|
||||
return gnc_filter_text_for_currency_symbol (incoming_text, *symbol);
|
||||
}
|
||||
|
||||
@@ -433,6 +433,20 @@ void gnc_filter_text_set_cursor_position (const gchar *incoming_text,
|
||||
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
|
||||
*
|
||||
* @return The incoming text with symbol removed to be freed by the caller
|
||||
*/
|
||||
gchar * gnc_filter_text_for_currency_commodity (const gnc_commodity *comm,
|
||||
const gchar *incoming_text,
|
||||
const gchar **symbol);
|
||||
|
||||
#endif
|
||||
/** @} */
|
||||
/** @} */
|
||||
|
||||
Reference in New Issue
Block a user