[grisbi-cvs] [SCM] grisbi branch, master, updated. upstream_version_0_7_3-74-gb20fca2

Pierre Biava nobody at users.sourceforge.net
Sun Oct 10 14:18:08 CEST 2010


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "grisbi".

The branch, master has been updated
       via  b20fca29525c9cd2140d191d7944c91ad612a3f5 (commit)
       via  773cfa6aa083e97742b814e4c1f7caa6fbdd3a34 (commit)
      from  9ab53d826b79f50da25d18553787bacf49e87227 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit b20fca29525c9cd2140d191d7944c91ad612a3f5
Author: pbiava <pierre.biava at nerim.net>
Date:   Sun Oct 10 10:08:42 2010 +0200

    fixed bug 1181: adding multiply operation

commit 773cfa6aa083e97742b814e4c1f7caa6fbdd3a34
Author: pbiava <pierre.biava at nerim.net>
Date:   Sun Oct 10 08:45:47 2010 +0200

    fixes a bug when incrementing the number of check

-----------------------------------------------------------------------

Changes:
diff --git a/src/gsb_data_payment.c b/src/gsb_data_payment.c
index 39cbc14..1229fa4 100644
--- a/src/gsb_data_payment.c
+++ b/src/gsb_data_payment.c
@@ -820,26 +820,9 @@ gchar *gsb_data_payment_incremente_last_number ( gint payment_number,
 {
     const gchar *last_number;
     gchar *new_number;
-    gchar *prefix = NULL;
-    gint number = 0;
-    gint i = 0;
 
     last_number = gsb_data_payment_get_last_number ( payment_number );
-    if ( last_number && strlen ( last_number ) > 0 )
-    {
-        while ( last_number[i] == '0' )
-        {
-            i++;
-        }
-        if ( i > 0 )
-            prefix = g_strndup ( last_number, i );
-    }
-    
-    number = utils_str_atoi ( last_number );
-    number += increment;
-    new_number = utils_str_itoa ( number );
-    if ( prefix && strlen ( prefix ) > 0 )
-        new_number = g_strconcat ( prefix, new_number, NULL );
+    new_number = utils_str_incremente_number_from_str ( last_number, increment );
 
     return new_number;
 }
diff --git a/src/gsb_form_widget.c b/src/gsb_form_widget.c
index c7a761a..6002254 100644
--- a/src/gsb_form_widget.c
+++ b/src/gsb_form_widget.c
@@ -971,6 +971,12 @@ gboolean gsb_form_widget_get_valide_amout_entry ( const gchar *string )
     const gchar *ptr;
 
     ptr = string;
+
+    if ( ( g_utf8_strchr ( ptr, -1, '*' ) && g_utf8_strchr ( ptr, -1, '+' ) )
+     ||
+     ( g_utf8_strchr ( ptr, -1, '*' ) && g_utf8_strchr ( ptr, -1, '-' ) ) )
+        return FALSE;
+
     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 );
@@ -986,12 +992,10 @@ gboolean gsb_form_widget_get_valide_amout_entry ( const gchar *string )
         {
             if ( g_unichar_isdefined ( thousands_sep ) )
             {
-                if ( ch != '.' && ch != ',' && ch != '+' && ch != '-'
-                 && ch != thousands_sep
-                  )
+                if ( ch != '.' && ch != ',' && ch != '+' && ch != '-' && ch != '*' && ch != thousands_sep )
                     return FALSE;
             }
-            else if ( ch != '.' && ch != ',' && ch != '+' && ch != '-' )
+            else if ( ch != '.' && ch != ',' && ch != '+' && ch != '-' && ch != '*' )
                     return FALSE;
         }
 
diff --git a/src/utils_editables.c b/src/utils_editables.c
index 0128bc9..5e339a9 100644
--- a/src/utils_editables.c
+++ b/src/utils_editables.c
@@ -1,8 +1,9 @@
 /* ************************************************************************** */
 /*                                                                            */
-/*     Copyright (C)	2000-2008 Cedric Auger (cedric at grisbi.org)	      */
-/*			2003-2008 Benjamin Drieu (bdrieu at april.org)	      */
-/* 			http://www.grisbi.org				      */
+/*     Copyright (C)    2000-2008 Cedric Auger (cedric at grisbi.org)            */
+/*          2003-2008 Benjamin Drieu (bdrieu at april.org)                       */
+/*          2008-2010 Pierre Biava (grisbi at pierre.biava.name)                 */
+/*          http://www.grisbi.org                                             */
 /*                                                                            */
 /*  This program is free software; you can redistribute it and/or modify      */
 /*  it under the terms of the GNU General Public License as published by      */
@@ -27,7 +28,6 @@
 #include "utils_editables.h"
 #include "gsb_real.h"
 #include "utils_str.h"
-#include "gsb_real.h"
 /*END_INCLUDE*/
 
 /*START_STATIC*/
@@ -38,8 +38,6 @@ extern gsb_real null_real;
 /*END_EXTERN*/
 
 
-
-
 /**
  * create a normalised text view for grisbi and add the value inside
  *
@@ -125,14 +123,11 @@ gboolean gsb_editable_erase_text_view ( GtkWidget *button,
  */
 void increment_decrement_champ ( GtkWidget *entry, gint increment )
 {
-    gdouble number;
 	gchar* tmpstr;
 
-    number = utils_str_atoi (gtk_entry_get_text ( GTK_ENTRY ( entry )));
-    number += increment;
-
-    tmpstr = utils_str_itoa ( number );
+    tmpstr = utils_str_incremente_number_from_str ( gtk_entry_get_text ( GTK_ENTRY ( entry ) ), 1 );
     gtk_entry_set_text ( GTK_ENTRY ( entry ), tmpstr );
+
     g_free ( tmpstr );
 }
 
@@ -152,27 +147,52 @@ gsb_real gsb_utils_edit_calculate_entry ( GtkWidget *entry )
     gsb_real total = null_real;
 	
     string = my_strdup (gtk_entry_get_text ( GTK_ENTRY (entry)));
-    /* modified by pbiava 02/13/2009 To avoid a crash at the entrance to a 0 */
-    if (string && strlen (string))
-        pointeur = string + strlen (string);
+
+    if ( string && strlen ( string ) )
+        pointeur = string + strlen ( string );
     else
         return total;
 
-    while ( pointeur != string )
+    if ( g_utf8_strchr ( string, -1, '-' ) || g_utf8_strchr ( string, -1, '+' ) )
     {
-	if ( pointeur[0] == '+'
-	     ||
-	     pointeur[0] == '-' )
-	{
-	    total = gsb_real_add ( total,
-				   gsb_real_get_from_string (pointeur));
-	    pointeur[0] = 0;
-	}
-	pointeur--;
+        while ( pointeur != string )
+        {
+            if ( pointeur[0] == '+'
+                 ||
+                 pointeur[0] == '-' )
+            {
+                total = gsb_real_add ( total,
+                            gsb_real_get_from_string ( pointeur ) );
+                pointeur[0] = 0;
+            }
+            
+            pointeur--;
+        }
+        total = gsb_real_add ( total,
+                        gsb_real_get_from_string ( pointeur ) );
     }
-    total = gsb_real_add ( total,
-			   gsb_real_get_from_string (pointeur));
-    g_free (string);
+    else
+    {
+        total.mantissa = 1;
+        total.exponent = 0;
+
+        while ( pointeur != string )
+        {
+            if ( pointeur[0] == '*' )
+            {
+                total = gsb_real_mul ( total,
+                            gsb_real_get_from_string ( pointeur + 1 ) );
+                pointeur[0] = 0;
+            }
+            
+            pointeur--;
+        }
+        total = gsb_real_mul ( total,
+                        gsb_real_get_from_string ( pointeur ) );
+    }
+
+    g_free ( string );
+
     return total;
 }
 
diff --git a/src/utils_str.c b/src/utils_str.c
index f8881d5..b86cda5 100644
--- a/src/utils_str.c
+++ b/src/utils_str.c
@@ -1032,6 +1032,42 @@ gchar *utils_str_colon ( const gchar *s )
 }
 
 
+/**
+ * adapte l'utilisation de : en fonction de la langue de l'utilisateur
+ *
+ *
+ *
+ * */
+gchar *utils_str_incremente_number_from_str ( const gchar *str_number, gint increment )
+{
+    gchar *new_str_number;
+    gchar *prefix = NULL;
+    gint number = 0;
+    gint i = 0;
+
+    if ( str_number && strlen ( str_number ) > 0 )
+    {
+        while ( str_number[i] == '0' )
+        {
+            i++;
+        }
+        if ( i > 0 )
+            prefix = g_strndup ( str_number, i );
+    
+        number = utils_str_atoi ( str_number );
+    }
+
+    number += increment;
+
+    new_str_number = utils_str_itoa ( number );
+
+    if ( prefix && strlen ( prefix ) > 0 )
+        new_str_number = g_strconcat ( prefix, new_str_number, NULL );
+
+    return new_str_number;
+}
+
+
 /* Local Variables: */
 /* c-basic-offset: 4 */
 /* End: */
diff --git a/src/utils_str.h b/src/utils_str.h
index 83ae617..9ec4e17 100644
--- a/src/utils_str.h
+++ b/src/utils_str.h
@@ -42,6 +42,7 @@ gint utils_str_get_nbre_motifs ( const gchar *chaine, const gchar *motif );
 G_MODULE_EXPORT gchar *utils_str_colon ( const gchar *s );
 gchar *utils_str_itoa ( gint integer );
 gchar *utils_str_dtostr ( gdouble number, gint nbre_decimal, gboolean canonical );
+gchar *utils_str_incremente_number_from_str ( const gchar *str_number, gint increment );
 gchar *utils_str_localise_decimal_point_from_string ( const gchar *string );
 gchar *utils_str_reduce_exponant_from_string ( const gchar *amount_string,
                         gint exponent );


hooks/post-receive
-- 
grisbi


More information about the cvs mailing list