Bug 799399 - Windows Keypad decimal locale error

On Windows, the keypad decimal isn't a comma in dialogs that use the
GncAmountEdit widget for locales that calls for it.

This appears to be a problem with Gtk so instead do the entry update
in the key press call back instead of trying to change the event and
passing it on.
This commit is contained in:
Robert Fewell
2024-09-12 09:59:15 +01:00
parent f2aff99b4c
commit 4314bf1c9f

View File

@@ -285,15 +285,40 @@ gnc_amount_edit_key_press (GtkWidget *widget, GdkEventKey *event, gpointer user_
#endif
if (event->keyval == GDK_KEY_KP_Decimal)
{
gchar *decimal;
if (gae->print_info.monetary)
{
struct lconv *lc = gnc_localeconv ();
event->keyval = lc->mon_decimal_point[0];
event->string[0] = lc->mon_decimal_point[0];
decimal = g_strdup_printf ("%c", lc->mon_decimal_point[0]);
}
}
else
decimal = g_strdup_printf ("%c",'.');
result = (* GTK_WIDGET_GET_CLASS(widget)->key_press_event)(widget, event);
GtkEditable *editable = GTK_EDITABLE(widget);
gint start_pos, end_pos;
gint position = gtk_editable_get_position (editable);
if (gtk_editable_get_selection_bounds (editable,
&start_pos, &end_pos))
{
position = start_pos;
gtk_editable_delete_selection (editable);
gtk_editable_insert_text (editable,
decimal, -1, &position);
}
else
gtk_editable_insert_text (editable,
decimal, -1, &position);
gtk_editable_set_position (editable, position);
g_free (decimal);
result = TRUE;
}
else
result = (* GTK_WIDGET_GET_CLASS(widget)->key_press_event)(widget, event);
switch (event->keyval)
{