static void
solipa_fixed_toggled (GtkCellRendererToggle *cell,
- gchar *path_str,
- gpointer data)
+ gchar *path_str,
+ gpointer data)
{
GtkTreeModel *model = (GtkTreeModel *)data;
GtkTreeIter iter;
gssize str_len;
/* TODO
- * - get number of decimal from locale
+ * - get number of decimals from locale
* - get grouping char from locale
* - get currency symbol from locale
*/
ret = g_strdup ("");
error = NULL;
- regex = g_regex_new ("(-?\\d+)(\\d\\d\\d)", 0, 0, &error);
+ regex = g_regex_new ("(^[-\\d]?\\d+)(\\d\\d\\d)", 0, 0, &error);
if (error != NULL)
{
g_warning ("Error on creating regex: %s.",
return "";
}
- str_format = g_strdup_printf ("%%0%sf", decimals == 0 ? "" : (decimals < 0 ? ".2" : g_strdup_printf (".%d", decimals)));
+ str_format = g_strdup_printf ("%%0%sf", decimals == 0 ? ".0" : (decimals < 0 ? ".2" : g_strdup_printf (".%d", decimals)));
ret = g_strdup_printf (str_format, number);
while (TRUE)
if (with_currency_symbol)
{
- ret = g_strconcat ("\80 ", ret, NULL);
+ ret = g_strconcat ("€ ", ret, NULL);
}
g_regex_unref (regex);
ret = 0.0;
error = NULL;
- regex = g_regex_new ("[\80 .]", 0, 0, &error);
+ regex = g_regex_new ("[€ .]", 0, 0, &error);
if (error != NULL)
{
g_warning ("Error on creating regex: %s.",
main (int argc, char *argv[])
{
gchar *str;
+ guint n_dec = -1;
gtk_init (&argc, &argv);
- str = solipa_format_money (g_strtod (argv[1], NULL), 3, FALSE);
+ if (argc == 3)
+ {
+ n_dec = strtol (argv[2], NULL, 10);
+ }
+
+ g_message ("VALUE %s DOUBLE %s", argv[1], g_strdup_printf (g_strdup_printf ("%%.%df", n_dec), g_strtod (argv[1], NULL)));
+ g_message ("DECIMALS %d", n_dec);
+ str = solipa_format_money (g_strtod (argv[1], NULL), n_dec, FALSE);
g_message ("FORMAT %s", str);
g_message ("UNFORMAT %f", solipa_unformat_money (str));