[grisbi-cvs] grisbi/src gsb_account_property.c, 1.22, 1.23 gsb_autofunc.c, 1.16, 1.17 gsb_currency.c, 1.33, 1.34 gsb_currency_config.c, 1.44, 1.45

Pierre Biava pbiava at users.sourceforge.net
Thu Feb 5 21:22:08 CET 2009


Update of /cvsroot/grisbi/grisbi/src
In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv19906/src

Modified Files:
	gsb_account_property.c gsb_autofunc.c gsb_currency.c 
	gsb_currency_config.c 
Log Message:
gsb_currency.c fix bug combo_box

Index: gsb_account_property.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/gsb_account_property.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- gsb_account_property.c	5 Feb 2009 19:26:53 -0000	1.22
+++ gsb_account_property.c	5 Feb 2009 20:22:06 -0000	1.23
@@ -1,8 +1,8 @@
 /* ************************************************************************** */
 /*                                                                            */
-/*     Copyright (C)	2000-2008 Cédric Auger (cedric at grisbi.org)	      */
-/*			2004-2009 Benjamin Drieu (bdrieu at april.org) 	      */
-/*			http://www.grisbi.org   			      */
+/*     Copyright (C)	2000-2009 Cédric Auger (cedric at grisbi.org)	          */
+/*			2004-2009 Benjamin Drieu (bdrieu at april.org) 	                  */
+/*			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      */
@@ -207,7 +207,8 @@
     gtk_box_pack_start ( GTK_BOX(hbox), label, FALSE, FALSE, 0);
 
     detail_devise_compte = gsb_autofunc_currency_new (TRUE, 0,
-						      G_CALLBACK (gsb_account_property_changed), GINT_TO_POINTER (PROPERTY_CURRENCY),
+						      G_CALLBACK (gsb_account_property_changed), 
+                              GINT_TO_POINTER (PROPERTY_CURRENCY),
 						      NULL, 0 );
     g_signal_connect ( G_OBJECT (detail_devise_compte ), "destroy",
 		       G_CALLBACK ( gtk_widget_destroyed), &detail_devise_compte );
@@ -215,7 +216,8 @@
 
     /* create closed account line */
     detail_compte_cloture = gsb_autofunc_checkbutton_new (_("Closed account"), FALSE,
-							  G_CALLBACK (gsb_account_property_changed), GINT_TO_POINTER (PROPERTY_CLOSED_ACCOUNT),
+							  G_CALLBACK (gsb_account_property_changed), 
+                              GINT_TO_POINTER (PROPERTY_CLOSED_ACCOUNT),
 							  G_CALLBACK (gsb_data_account_set_closed_account), 0 );
     g_signal_connect ( G_OBJECT (detail_compte_cloture ), "destroy",
 		       G_CALLBACK ( gtk_widget_destroyed), &detail_compte_cloture );
@@ -687,6 +689,9 @@
 
     new_currency_number = gsb_currency_get_currency_from_combobox (detail_devise_compte);
 
+    if ( account_currency_number == new_currency_number )
+        return FALSE;
+
     /* set the new currency, must set here and no in the autofunc directly  */
     gsb_data_account_set_currency ( account_number,
 				    new_currency_number );

Index: gsb_currency_config.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/gsb_currency_config.c,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -d -r1.44 -r1.45
--- gsb_currency_config.c	5 Feb 2009 18:56:22 -0000	1.44
+++ gsb_currency_config.c	5 Feb 2009 20:22:06 -0000	1.45
@@ -592,6 +592,7 @@
     GSList *list_tmp;
     gint currency_number;
 
+    devel_debug (NULL);
     currency_number = gsb_currency_config_get_selected ( GTK_TREE_VIEW ( tree_view ) );
     if ( !currency_number )
 	return;
@@ -608,10 +609,11 @@
 
 	if ( gsb_data_transaction_get_currency_number (transaction_number) == currency_number )
 	{
-	    gchar* tmpstr1 = g_strdup_printf ( _("Currency '%s' is used in current file.  Grisbi can't delete it."),
-						    gsb_data_currency_get_name (currency_number));
+	    gchar* tmpstr1 = g_strdup_printf ( _("Currency '%s' is used in current "
+                        "file.  Grisbi can't delete it."),
+                        gsb_data_currency_get_name (currency_number));
 	    gchar* tmpstr2 = g_strdup_printf ( _("Impossible to remove currency '%s'"),
-						    gsb_data_currency_get_name (currency_number) );
+                        gsb_data_currency_get_name (currency_number) );
 	    dialogue_error_hint ( tmpstr1, tmpstr2);
 	    g_free ( tmpstr1 );
 	    g_free ( tmpstr2 );
@@ -631,10 +633,11 @@
 	scheduled_number = gsb_data_scheduled_get_scheduled_number (list_tmp -> data);
 	if ( gsb_data_scheduled_get_currency_number (scheduled_number) == currency_number )
 	{
-	    gchar* tmpstr1 = g_strdup_printf ( _("Currency '%s' is used in current file.  Grisbi can't delete it."),
-						    gsb_data_currency_get_name (currency_number));
+	    gchar* tmpstr1 = g_strdup_printf ( _("Currency '%s' is used in current "
+                        "file. Grisbi can't delete it."),
+                        gsb_data_currency_get_name (currency_number));
 	    gchar* tmpstr2 = g_strdup_printf ( _("Impossible to remove currency '%s'"),
-						    gsb_data_currency_get_name (currency_number) );
+                        gsb_data_currency_get_name (currency_number) );
 	    dialogue_error_hint ( tmpstr1, tmpstr2);
 	    g_free ( tmpstr1 );
 	    g_free ( tmpstr2 );
@@ -1000,56 +1003,54 @@
     {
 	case 1 :
 
-	    currency_name = gtk_entry_get_text ( GTK_ENTRY ( entry_name ));
-	    currency_code = gtk_entry_get_text ( GTK_ENTRY ( entry_code ));
-	    currency_isocode = gtk_entry_get_text ( GTK_ENTRY ( entry_isocode ));
-	    floating_point = utils_str_atoi (gtk_entry_get_text ( GTK_ENTRY ( entry_floating_point )));
-
-	    if ( strlen ( currency_name ) &&
-		 (strlen ( currency_code ) ||
-		  strlen ( currency_isocode )))
-	    {
-		/* check if the currency exists si la devise existe on ne fait rien */
+    currency_name = gtk_entry_get_text ( GTK_ENTRY ( entry_name ));
+    currency_code = gtk_entry_get_text ( GTK_ENTRY ( entry_code ));
+    currency_isocode = gtk_entry_get_text ( GTK_ENTRY ( entry_isocode ));
+    floating_point = utils_str_atoi (gtk_entry_get_text ( GTK_ENTRY ( entry_floating_point )));
 
-		if ( gsb_data_currency_get_number_by_name ( currency_name ) )
-		{
-		    currency_number = 0;
-		}
-		else if ( gsb_data_currency_get_number_by_code_iso4217 ( currency_isocode ) )
-		{
-		    currency_number = 0;
-		}
-		else
-		{
-		    currency_number = gsb_currency_config_create_currency ( currency_name, currency_code,
-									    currency_isocode, floating_point );
-		}
+    if ( strlen ( currency_name ) &&
+     (strlen ( currency_code ) ||
+      strlen ( currency_isocode )))
+    {
+        /* check if the currency exists si la devise existe on ne fait rien */
 
-		/* update the currency list for combobox */
-        /* mise en commentaire car introduit deux bugs 
-         * 1) passage à 0 des variaables no_devise_totaux_categ, no_devise_totaux_ib,
-         *    no_devise_totaux_tiers dans le fichier gribi;
-         * 2) bug affichage de la liste des opérations (passage à 0 de la devise du 
-         *    premier compte de la liste des comptes */
+        if ( gsb_data_currency_get_number_by_name ( currency_name ) )
+        {
+            currency_number = gsb_data_currency_get_number_by_name 
+                        ( currency_name );
+        }
+        else if ( gsb_data_currency_get_number_by_code_iso4217 
+                        ( currency_isocode ) )
+        {
+            currency_number = gsb_data_currency_get_number_by_code_iso4217 
+                        ( currency_isocode );
+        }
+        else
+        {
+            currency_number = gsb_currency_config_create_currency ( currency_name, 
+                        currency_code, currency_isocode, floating_point );
 
-		gsb_currency_update_combobox_currency_list ();
+            /* update the currencies list in account properties */
+            gsb_currency_update_combobox_currency_list ();
 
-		if ( currency_tree_model && currency_number > 0 )
-		{
-		    gsb_currency_append_currency_to_list ( GTK_LIST_STORE ( currency_tree_model ),
-							   currency_number );
-		    gtk_widget_destroy ( GTK_WIDGET ( dialog ));
-		    modification_fichier ( TRUE );
-		    return TRUE;
-		}
-	    }
-	    else
-	    {
-		dialogue_warning_hint ( _("Currency name and either international currency code or currency nickname should be set."),
-					_("All fields are not filled in") );
-		goto dialog_return;
-	    }
-	    break;
+            if ( currency_tree_model && currency_number > 0 )
+            {
+                gsb_currency_append_currency_to_list ( GTK_LIST_STORE ( currency_tree_model ),
+                                   currency_number );
+                gtk_widget_destroy ( GTK_WIDGET ( dialog ));
+                modification_fichier ( TRUE );
+                return TRUE;
+            }
+        }
+    }
+    else
+    {
+        dialogue_warning_hint ( _("Currency name and either international "
+                        "currency code or currency nickname should be set."),
+                        _("All fields are not filled in") );
+        goto dialog_return;
+    }
+    break;
     }
     gtk_widget_destroy ( GTK_WIDGET ( dialog ));
     return TRUE;
@@ -1263,7 +1264,8 @@
 
     model = gtk_tree_view_get_model ( tree_view );
     gtk_list_store_clear ( GTK_LIST_STORE (model) );
-    gsb_currency_config_fill_popup_list ( tree_view, gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(checkbox)) );
+    gsb_currency_config_fill_popup_list ( tree_view, 
+                        gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(checkbox)) );
 
     /* re-select the default currency
      * TODO : should use the GtkTreeModelFilter to show or not the obsoletes currencies,

Index: gsb_currency.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/gsb_currency.c,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -d -r1.33 -r1.34
--- gsb_currency.c	4 Feb 2009 23:10:16 -0000	1.33
+++ gsb_currency.c	5 Feb 2009 20:22:06 -0000	1.34
@@ -1,6 +1,6 @@
 /* ************************************************************************** */
 /*                                                                            */
-/*     Copyright (C)	2000-2007 C�dric Auger (cedric at grisbi.org)	      */
+/*     Copyright (C)	2000-2007 Cédric Auger (cedric at grisbi.org)	      */
 /*			2003-2009 Benjamin Drieu (bdrieu at april.org)	      */
 /* 			http://www.grisbi.org				      */
 /*                                                                            */
@@ -41,6 +41,7 @@
 #include "./utils_files.h"
 #include "./include.h"
 #include "./gsb_currency_config.h"
+#include "./erreur.h"
 #include "./gsb_real.h"
 /*END_INCLUDE*/
 
@@ -55,9 +56,6 @@
 					       GtkWidget *combobox_2 );
 /*END_STATIC*/
 
-/*START_EXTERN*/
-extern GtkWidget *detail_devise_compte;
-/*END_EXTERN*/
 /**
  * the currency list store, contains 3 columns :
  * 1 : the code of the currency
@@ -94,6 +92,7 @@
 
 
 /*START_EXTERN*/
+extern GtkWidget *detail_devise_compte ;
 extern gint mise_a_jour_liste_comptes_accueil;
 extern gint mise_a_jour_liste_echeances_auto_accueil;
 extern gint mise_a_jour_liste_echeances_manuelles_accueil;
@@ -164,7 +163,8 @@
     if (!combobox_currency_store)
 	gsb_currency_create_combobox_store ();
 
-    combo_box = gtk_combo_box_new_with_model (GTK_TREE_MODEL (combobox_currency_store));
+    combo_box = gtk_combo_box_new_with_model (GTK_TREE_MODEL 
+                        (combobox_currency_store));
 
     /* Flag renderer */
     flag_renderer = gtk_cell_renderer_pixbuf_new ();
@@ -272,7 +272,9 @@
 gboolean gsb_currency_update_combobox_currency_list ( void )
 {
     GSList *list_tmp;
+    gint old_currency_number = -1;
 
+    devel_debug (NULL);
     if (!combobox_currency_store
 	||
 	!gsb_data_currency_get_currency_list ())
@@ -282,8 +284,11 @@
      * try to find why. */
     if ( detail_devise_compte )
     {
-	g_signal_handler_block ( detail_devise_compte,
-				 g_object_get_data ( detail_devise_compte, "changed-hook" ) );
+	g_signal_handler_block ( (gpointer *) detail_devise_compte,
+                        (gulong) g_object_get_data ( G_OBJECT 
+                        (detail_devise_compte), "changed-hook" ) );
+    old_currency_number = gtk_combo_box_get_active (GTK_COMBO_BOX 
+                        (detail_devise_compte));
     }
 
     gtk_list_store_clear (GTK_LIST_STORE (combobox_currency_store));
@@ -291,35 +296,34 @@
 
     while ( list_tmp )
     {
-	GtkTreeIter iter;
-	GdkPixbuf * pixbuf;
-	gchar * string;
-	gint currency_number;
-
-	currency_number = gsb_data_currency_get_no_currency (list_tmp -> data);
+        GtkTreeIter iter;
+        GdkPixbuf * pixbuf;
+        gchar * string;
+        gint currency_number;
 
-	string = g_strconcat( PIXMAPS_DIR, C_DIRECTORY_SEPARATOR,
-			      "flags", C_DIRECTORY_SEPARATOR,
-			      gsb_data_currency_get_code_iso4217 (currency_number),
-			      ".png", NULL );
-	pixbuf = gdk_pixbuf_new_from_file ( string, NULL );
-	g_free (string);
+        currency_number = gsb_data_currency_get_no_currency (list_tmp -> data);
+        string = g_strconcat( PIXMAPS_DIR, C_DIRECTORY_SEPARATOR,
+                    "flags", C_DIRECTORY_SEPARATOR,
+                    gsb_data_currency_get_code_iso4217 (currency_number),
+                    ".png", NULL );
+        pixbuf = gdk_pixbuf_new_from_file ( string, NULL );
+        g_free (string);
 
 
-	gtk_list_store_append ( GTK_LIST_STORE (combobox_currency_store), &iter );
-	gchar* tmpstr = g_strconcat ( gsb_data_currency_get_name (currency_number),
-				" (",
-				gsb_data_currency_get_code_or_isocode (currency_number),
-				")",
-				NULL );
-	gtk_list_store_set ( combobox_currency_store, &iter,
-			     CURRENCY_COL_FLAG, pixbuf,
-			     CURRENCY_COL_CODE, gsb_data_currency_get_code_or_isocode (currency_number),
-			     CURRENCY_COL_NAME, tmpstr,
-			     CURRENCY_COL_NUMBER, currency_number,
-			     -1 );
-	g_free ( tmpstr );
-	list_tmp = list_tmp -> next;
+        gtk_list_store_append ( GTK_LIST_STORE (combobox_currency_store), &iter );
+        gchar* tmpstr = g_strconcat ( gsb_data_currency_get_name (currency_number),
+                    " (",
+                    gsb_data_currency_get_code_or_isocode (currency_number),
+                    ")",
+                    NULL );
+        gtk_list_store_set ( combobox_currency_store, &iter,
+                    CURRENCY_COL_FLAG, pixbuf,
+                    CURRENCY_COL_CODE, gsb_data_currency_get_code_or_isocode (currency_number),
+                    CURRENCY_COL_NAME, tmpstr,
+                    CURRENCY_COL_NUMBER, currency_number,
+                    -1 );
+        g_free ( tmpstr );
+        list_tmp = list_tmp -> next;
     }
 
     mise_a_jour_liste_comptes_accueil = 1;
@@ -329,7 +333,10 @@
     if ( detail_devise_compte )
     {
 	g_signal_handler_unblock ( detail_devise_compte,
-				   g_object_get_data ( detail_devise_compte, "changed-hook" ) );
+                        (gulong) g_object_get_data ( G_OBJECT 
+                        (detail_devise_compte), "changed-hook" ) );
+    gtk_combo_box_set_active ( GTK_COMBO_BOX (detail_devise_compte), 
+                    old_currency_number );
     }
 
     return FALSE;

Index: gsb_autofunc.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/gsb_autofunc.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- gsb_autofunc.c	8 Jan 2009 18:47:56 -0000	1.16
+++ gsb_autofunc.c	5 Feb 2009 20:22:06 -0000	1.17
@@ -1341,7 +1341,7 @@
     g_object_set_data ( G_OBJECT (combobox),
 			"number_for_func", GINT_TO_POINTER (number_for_func));
 
-   if (default_func)
+    if (default_func)
 	g_object_set_data ( G_OBJECT (combobox), "changed", 
 			    (gpointer) g_signal_connect_after (G_OBJECT(combobox), "changed",
 							       G_CALLBACK (gsb_autofunc_currency_changed), default_func ));



More information about the cvs mailing list