[grisbi-cvs] grisbi/src gsb_data_transaction.c, 1.79, 1.80 gsb_form_widget.c, 1.42, 1.43 utils_str.c, 1.76, 1.77
Pierre Biava
pbiava at users.sourceforge.net
Sat Jan 16 16:00:34 CET 2010
Update of /cvsroot/grisbi/grisbi/src
In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv12808/src
Modified Files:
gsb_data_transaction.c gsb_form_widget.c utils_str.c
Log Message:
Added a test of validity of the seizure amounts and minor correction
Index: gsb_data_transaction.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/gsb_data_transaction.c,v
retrieving revision 1.79
retrieving revision 1.80
diff -u -d -r1.79 -r1.80
--- gsb_data_transaction.c 13 Jan 2010 22:38:19 -0000 1.79
+++ gsb_data_transaction.c 16 Jan 2010 15:00:31 -0000 1.80
@@ -763,7 +763,8 @@
if ( transaction -> currency_number == return_currency_number )
return gsb_real_adjust_exponent ( transaction -> transaction_amount,
return_exponent );
-
+//~ printf ("get_adjusted_amount transaction_number = %d transaction -> currency_number = %d return_currency_number = %d\n",
+ //~ transaction_number, transaction -> currency_number, return_currency_number);
/* now we can adjust the amount */
/* the exchange is saved in the transaction itself */
if ( transaction -> exchange_rate.mantissa )
@@ -792,7 +793,7 @@
/* The costs are still deducted from the transaction. In case of internal transfer there is no charge. */
amount = gsb_real_sub (amount, transaction -> exchange_fees);
}
- else
+ else if ( return_currency_number > 0 && transaction -> currency_number > 0 )
{
gsb_real current_exchange;
gsb_real current_exchange_fees;
Index: gsb_form_widget.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/gsb_form_widget.c,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -d -r1.42 -r1.43
--- gsb_form_widget.c 13 Jan 2010 19:30:15 -0000 1.42
+++ gsb_form_widget.c 16 Jan 2010 15:00:32 -0000 1.43
@@ -55,10 +55,16 @@
/*START_STATIC*/
static gboolean gsb_form_widget_can_focus ( gint element_number );
-static gboolean gsb_form_widget_entry_get_focus ( GtkWidget *entry, GdkEventFocus *ev, gint *ptr_origin );
+static gboolean gsb_form_widget_entry_get_focus ( GtkWidget *entry,
+ GdkEventFocus *ev,
+ gint *ptr_origin );
+static gboolean gsb_form_widget_amount_entry_changed ( GtkWidget *entry,
+ gpointer null );
+gboolean gsb_form_widget_get_valide_amout_entry ( const gchar *string );
/*END_STATIC*/
/*START_EXTERN*/
+extern GdkColor calendar_entry_color;
extern GtkWidget *form_button_cancel;
extern GtkWidget *form_button_valid;
/*END_EXTERN*/
@@ -169,7 +175,24 @@
break;
case TRANSACTION_FORM_DEBIT:
+ widget = gtk_entry_new ( );
+ g_object_set_data ( G_OBJECT ( widget ), "element_number",
+ GINT_TO_POINTER ( TRANSACTION_FORM_DEBIT ) );
+ g_signal_connect ( G_OBJECT ( widget ),
+ "changed",
+ G_CALLBACK ( gsb_form_widget_amount_entry_changed ),
+ NULL );
+ break;
case TRANSACTION_FORM_CREDIT:
+ widget = gtk_entry_new ( );
+ g_object_set_data ( G_OBJECT ( widget ), "element_number",
+ GINT_TO_POINTER ( TRANSACTION_FORM_CREDIT ) );
+ g_signal_connect ( G_OBJECT ( widget ),
+ "changed",
+ G_CALLBACK ( gsb_form_widget_amount_entry_changed ),
+ NULL );
+ break;
+
case TRANSACTION_FORM_NOTES:
case TRANSACTION_FORM_CHEQUE:
case TRANSACTION_FORM_VOUCHER:
@@ -735,7 +758,9 @@
*
* \return FALSE
* */
-gboolean gsb_form_widget_entry_get_focus ( GtkWidget *entry, GdkEventFocus *ev, gint *ptr_origin )
+gboolean gsb_form_widget_entry_get_focus ( GtkWidget *entry,
+ GdkEventFocus *ev,
+ gint *ptr_origin )
{
GtkWidget *fyear_button;
GtkWidget *widget;
@@ -798,12 +823,6 @@
* to hide the cheque element too */
if ( ! GTK_WIDGET_VISIBLE (widget) )
gtk_widget_hide (gsb_form_widget_get_widget (TRANSACTION_FORM_CHEQUE));
- //~ else if ( gsb_data_payment_get_show_entry ( 0 ) )
- //~ {
- //~ gtk_widget_show (gsb_form_widget_get_widget (TRANSACTION_FORM_CHEQUE));
- //~ }
- //~ else
- //~ gsb_payment_method_changed_callback ( widget, NULL );
widget = gsb_form_widget_get_widget ( TRANSACTION_FORM_CONTRA );
if ( widget && GTK_WIDGET_VISIBLE ( widget ) )
@@ -844,10 +863,6 @@
* to hide the cheque element too */
if ( !GTK_WIDGET_VISIBLE (widget))
gtk_widget_hide (gsb_form_widget_get_widget (TRANSACTION_FORM_CHEQUE));
- //~ else if ( gsb_data_payment_get_show_entry ( 0 ) )
- //~ {
- //~ gtk_widget_show (gsb_form_widget_get_widget (TRANSACTION_FORM_CHEQUE));
- //~ }
widget = gsb_form_widget_get_widget ( TRANSACTION_FORM_CONTRA);
if ( widget && GTK_WIDGET_VISIBLE ( widget ) )
@@ -884,3 +899,97 @@
else
return NULL;
}
+
+
+/**
+ * called when entry changed
+ * check the entry and set the entry red/invalid if not a good number
+ *
+ * \param entry
+ * \param null
+ *
+ * \return FALSE
+ * */
+gboolean gsb_form_widget_amount_entry_changed ( GtkWidget *entry,
+ gpointer null )
+{
+ gboolean valide;
+ gint element_number;
+
+ /* if we are in the form and the entry is empty, do nothing
+ * because it's a special style too */
+ element_number = GPOINTER_TO_INT ( g_object_get_data (
+ G_OBJECT ( entry ), "element_number" ) );
+ if ( g_strcmp0 ( gsb_form_widget_get_name ( element_number ),
+ gtk_entry_get_text ( GTK_ENTRY ( entry ) ) ) == 0 )
+ return FALSE;
+
+ if ( gsb_form_widget_check_empty ( entry ) )
+ return FALSE;
+
+ /* if nothing in the entry, keep the normal style */
+ if ( !strlen ( gtk_entry_get_text ( GTK_ENTRY ( entry ) ) ) )
+ {
+ gtk_widget_modify_base ( entry, GTK_STATE_NORMAL, NULL );
+ return FALSE;
+ }
+
+ valide = gsb_form_widget_get_valide_amout_entry (
+ gtk_entry_get_text ( GTK_ENTRY ( entry ) ) );
+ if ( valide )
+ {
+ /* the entry is valid, make it normal */
+ gtk_widget_modify_base ( entry, GTK_STATE_NORMAL, NULL );
+ }
+ else
+ {
+ /* the entry is not valid, make it red */
+ gtk_widget_modify_base ( entry, GTK_STATE_NORMAL,
+ &calendar_entry_color );
+ }
+
+ return FALSE;
+}
+
+
+/**
+ *
+ *
+ *
+ *
+ * */
+gboolean gsb_form_widget_get_valide_amout_entry ( const gchar *string )
+{
+ struct lconv *conv = localeconv ( );
+ gchar *mon_thousands_sep;
+ gunichar thousands_sep;
+ const gchar *ptr;
+
+ ptr = string;
+ mon_thousands_sep = g_locale_to_utf8 ( conv->mon_thousands_sep,
+ -1, NULL, NULL, NULL );
+ thousands_sep = g_utf8_get_char_validated ( mon_thousands_sep, -1 );
+
+ while ( g_utf8_strlen (ptr, -1) > 0 )
+ {
+ gunichar ch;
+
+ ch = g_utf8_get_char_validated (ptr, -1);
+ if ( !g_unichar_isdefined ( ch ) )
+ return FALSE;
+ if ( !g_ascii_isdigit ( ch ) )
+ {
+ if ( g_unichar_isdefined ( thousands_sep ) )
+ {
+ if ( ch != '.' && ch != ',' && ch != thousands_sep )
+ return FALSE;
+ }
+ else if ( ch != '.' && ch != ',' )
+ return FALSE;
+ }
+
+ ptr = g_utf8_next_char (ptr);
+ }
+
+ return TRUE;
+}
Index: utils_str.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/utils_str.c,v
retrieving revision 1.76
retrieving revision 1.77
diff -u -d -r1.76 -r1.77
--- utils_str.c 13 Jan 2010 19:30:15 -0000 1.76
+++ utils_str.c 16 Jan 2010 15:00:32 -0000 1.77
@@ -904,7 +904,6 @@
ptr = g_strdup ( chaine );
while ( g_utf8_strlen (ptr, -1) > 0 )
{
- ptr = g_utf8_next_char (ptr);
ch = g_utf8_get_char_validated (ptr, -1);
if ( g_unichar_isdefined ( ch ) && g_ascii_isdigit ( ch ) )
{
@@ -913,6 +912,7 @@
tmpstr[i] = ptr[0];
i++;
}
+ ptr = g_utf8_next_char (ptr);
}
return tmpstr;
More information about the cvs
mailing list