[grisbi-cvs] grisbi/src gsb_data_account.c, 1.78, 1.79 gsb_form.c, 1.124, 1.125 gsb_form.h, 1.26, 1.27 gsb_form_widget.c, 1.32, 1.33 gsb_form_widget.h, 1.4, 1.5 gsb_payment_method.c, 1.17, 1.18 gsb_payment_method.h, 1.7, 1.8 parametres.h, 1.28, 1.29

Pierre Biava pbiava at users.sourceforge.net
Mon May 25 21:42:29 CEST 2009


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

Modified Files:
	gsb_data_account.c gsb_form.c gsb_form.h gsb_form_widget.c 
	gsb_form_widget.h gsb_payment_method.c gsb_payment_method.h 
	parametres.h 
Log Message:
fix the bug 494

Index: gsb_form.h
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/gsb_form.h,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- gsb_form.h	26 Apr 2009 17:39:34 -0000	1.26
+++ gsb_form.h	25 May 2009 19:42:27 -0000	1.27
@@ -22,27 +22,27 @@
 
 /* START_DECLARATION */
 gboolean gsb_form_allocate_size ( GtkWidget *table,
-				  GtkAllocation *allocation,
-				  gpointer null );
+                        GtkAllocation *allocation,
+                        gpointer null );
 gboolean gsb_form_button_press_event ( GtkWidget *entry,
-				       GdkEventButton *ev,
-				       gint *ptr_origin );
+                        GdkEventButton *ev,
+                        gint *ptr_origin );
 gboolean gsb_form_change_sensitive_buttons ( gboolean sensitive );
 void gsb_form_check_auto_separator ( GtkWidget *entry );
 gboolean gsb_form_clean ( gint account_number );
 void gsb_form_create_widgets ( void );
 gboolean gsb_form_entry_get_focus ( GtkWidget *entry );
 gboolean gsb_form_entry_lose_focus ( GtkWidget *entry,
-				     GdkEventFocus *ev,
-				     gint *ptr_origin );
+                        GdkEventFocus *ev,
+                        gint *ptr_origin );
 gboolean gsb_form_escape_form ( void );
 gboolean gsb_form_fill_by_transaction ( gint transaction_number,
-					gint is_transaction,
-					gboolean grab_focus );
+                        gint is_transaction,
+                        gboolean grab_focus );
 void gsb_form_fill_element ( gint element_number,
-			     gint account_number,
-			     gint transaction_number,
-			     gboolean is_transaction );
+                        gint account_number,
+                        gint transaction_number,
+                        gboolean is_transaction );
 gboolean gsb_form_fill_from_account ( gint account_number );
 gboolean gsb_form_finish_edition ( void );
 gint gsb_form_get_account_number ( void );
@@ -51,13 +51,13 @@
 GtkWidget *gsb_form_get_scheduler_part ( void );
 gboolean gsb_form_is_visible ( void );
 gboolean gsb_form_key_press_event ( GtkWidget *widget,
-				    GdkEventKey *ev,
-				    gint *ptr_origin );
+                        GdkEventKey *ev,
+                        gint *ptr_origin );
 GtkWidget *gsb_form_new ( void );
 gboolean gsb_form_set_expander_visible ( gboolean visible,
-					 gboolean transactions_list );
+                        gboolean transactions_list );
 gboolean gsb_form_set_sensitive ( gboolean split,
-				  gboolean split_child);
+                        gboolean split_child);
 gboolean gsb_form_show ( gboolean show );
 gboolean gsb_form_switch_expander ( void );
 /* END_DECLARATION */

Index: gsb_form_widget.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/gsb_form_widget.c,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -d -r1.32 -r1.33
--- gsb_form_widget.c	24 May 2009 16:42:39 -0000	1.32
+++ gsb_form_widget.c	25 May 2009 19:42:27 -0000	1.33
@@ -66,6 +66,8 @@
 /** contains a list of struct_element according to the current form */
 static GSList *form_list_widgets = NULL;
 
+static gchar *old_debit = NULL;
+static gchar *old_credit = NULL;
 
 /**
  * return the list wich contains the widgets of the form
@@ -741,9 +743,9 @@
     /* still not found, if change the content of the form, something come in entry
      * wich is nothing, so protect here */
     if ( !GTK_IS_WIDGET (entry)
-	 ||
-	 !GTK_IS_ENTRY (entry))
-	return FALSE;
+     ||
+     !GTK_IS_ENTRY (entry))
+    return FALSE;
 
     /* it clears the entry in question */
     if ( gsb_form_widget_check_empty (entry) )
@@ -758,11 +760,18 @@
     switch ( element_number )
     {
     case TRANSACTION_FORM_DEBIT :
-	    /* we change the payment method to adapt it for the debit */
+        /* on met old_debit = NULl car avec g_free plantage */
+        if ( old_debit && strlen ( old_debit ) > 0 )
+            old_debit = NULL;
+
+        /* we change the payment method to adapt it for the debit */
         /* empty the credit */
         widget = gsb_form_widget_get_widget (TRANSACTION_FORM_CREDIT);
         if (!gsb_form_widget_check_empty (widget))
         {
+            old_credit = g_strdup ( gtk_entry_get_text ( GTK_ENTRY (
+                        gsb_form_widget_get_widget ( TRANSACTION_FORM_CREDIT ) ) ) );
+            printf ("old_credit = %s\n", old_credit );
             gtk_entry_set_text ( GTK_ENTRY (widget),
                      gsb_form_widget_get_name (TRANSACTION_FORM_CREDIT));
             gsb_form_widget_set_empty ( widget,
@@ -796,13 +805,20 @@
             }
         }
         gsb_form_check_auto_separator (entry);
-	    break;
-	case TRANSACTION_FORM_CREDIT :
-	    /* we change the payment method to adapt it for the debit */
+        break;
+    case TRANSACTION_FORM_CREDIT :
+         /* on met old_credit = NULl car avec g_free plantage */
+        if ( old_credit && strlen ( old_credit ) > 0 )
+            old_credit = NULL;
+
+        /* we change the payment method to adapt it for the debit */
         /* empty the credit */
         widget = gsb_form_widget_get_widget (TRANSACTION_FORM_DEBIT);
         if (!gsb_form_widget_check_empty (widget))
         {
+            old_debit = g_strdup ( gtk_entry_get_text ( GTK_ENTRY (
+                        gsb_form_widget_get_widget ( TRANSACTION_FORM_DEBIT ) ) ) );
+            printf ("old_debit = %s\n", old_debit );
             gtk_entry_set_text ( GTK_ENTRY (widget),
                      gsb_form_widget_get_name (TRANSACTION_FORM_DEBIT));
             gsb_form_widget_set_empty ( widget,
@@ -835,7 +851,7 @@
             }
         }
         gsb_form_check_auto_separator (entry);
-	    break;
+        break;
     }
     
     /* sensitive the valid and cancel buttons */
@@ -849,3 +865,21 @@
 
     return FALSE;
 }
+
+
+gchar *gsb_form_widget_get_old_credit ( void )
+{
+    if ( old_credit && strlen ( old_credit ) > 0 )
+        return g_strdup ( old_credit );
+    else
+        return NULL;
+}
+
+
+gchar *gsb_form_widget_get_old_debit ( void )
+{
+    if ( old_debit && strlen ( old_debit ) > 0 )
+        return g_strdup ( old_debit );
+    else
+        return NULL;
+}

Index: gsb_form.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/gsb_form.c,v
retrieving revision 1.124
retrieving revision 1.125
diff -u -d -r1.124 -r1.125
--- gsb_form.c	24 May 2009 16:42:39 -0000	1.124
+++ gsb_form.c	25 May 2009 19:42:27 -0000	1.125
@@ -1506,34 +1506,36 @@
     gint element_number;
     GtkWidget *widget;
     gint account_number;
+    gint transaction_number;
 
     devel_debug (NULL);
     /* still not found, if change the content of the form, something come in entry
      * wich is nothing, so protect here */
     if ( !GTK_IS_WIDGET (entry)
-	 ||
-	 !GTK_IS_ENTRY (entry))
-	return FALSE;
+     ||
+     !GTK_IS_ENTRY (entry))
+    return FALSE;
 
     /* remove the selection */
-    gtk_editable_select_region ( GTK_EDITABLE ( entry ),
-				 0,
-				 0 );
+    gtk_editable_select_region ( GTK_EDITABLE ( entry ), 0, 0 );
     element_number = GPOINTER_TO_INT (ptr_origin);
     account_number = gsb_form_get_account_number ();
+    transaction_number = GPOINTER_TO_INT ( g_object_get_data (
+                        G_OBJECT ( gsb_form_get_form_widget ( ) ),
+                        "transaction_number_in_form" ) );
 
     /* sometimes the combofix popus stays showed, so remove here */
     if ( element_number == TRANSACTION_FORM_PARTY
-	 ||
-	 element_number == TRANSACTION_FORM_CATEGORY
-	 ||
-	 element_number == TRANSACTION_FORM_BUDGET )
+     ||
+     element_number == TRANSACTION_FORM_CATEGORY
+     ||
+     element_number == TRANSACTION_FORM_BUDGET )
     {
-	widget = gsb_form_widget_get_widget (element_number);
+    widget = gsb_form_widget_get_widget (element_number);
 
-	gtk_grab_remove ( GTK_COMBOFIX ( widget ) -> popup );
-	gdk_pointer_ungrab ( GDK_CURRENT_TIME );
-	gtk_widget_hide ( GTK_COMBOFIX ( widget ) ->popup );
+    gtk_grab_remove ( GTK_COMBOFIX ( widget ) -> popup );
+    gdk_pointer_ungrab ( GDK_CURRENT_TIME );
+    gtk_widget_hide ( GTK_COMBOFIX ( widget ) ->popup );
     }
 
     /* string will be filled only if the field is empty */
@@ -1541,102 +1543,189 @@
 
     switch ( element_number )
     {
-	case TRANSACTION_FORM_PARTY :
-	    /* we complete the transaction */
-	    if ( !gsb_form_transaction_complete_form_by_payee (gtk_entry_get_text (GTK_ENTRY (entry))))
-		string = gsb_form_widget_get_name (TRANSACTION_FORM_PARTY);
-	    break;
+    case TRANSACTION_FORM_PARTY :
+        /* we complete the transaction */
+        if ( !gsb_form_transaction_complete_form_by_payee (gtk_entry_get_text (GTK_ENTRY (entry))))
+        string = gsb_form_widget_get_name (TRANSACTION_FORM_PARTY);
+        break;
 
-	case TRANSACTION_FORM_DEBIT :
-	    /* we change the payment method to adapt it for the debit */
-	    if ( strlen ( gtk_entry_get_text ( GTK_ENTRY (entry))))
-	    {
-		/* empty the credit */
-		widget = gsb_form_widget_get_widget (TRANSACTION_FORM_CREDIT);
-		if (!gsb_form_widget_check_empty (widget))
-		{
-		    gtk_entry_set_text ( GTK_ENTRY (widget),
-					 gsb_form_widget_get_name (TRANSACTION_FORM_CREDIT));
-		    gsb_form_widget_set_empty ( widget,
-						TRUE );
-		}
+    case TRANSACTION_FORM_DEBIT :
+        /* we change the payment method to adapt it for the debit */
+        if ( strlen ( gtk_entry_get_text ( GTK_ENTRY (entry))))
+        {
+        /* empty the credit */
+        widget = gsb_form_widget_get_widget (TRANSACTION_FORM_CREDIT);
+        if (!gsb_form_widget_check_empty (widget))
+        {
+            gtk_entry_set_text ( GTK_ENTRY ( widget ),
+                        gsb_form_widget_get_name ( TRANSACTION_FORM_CREDIT ) );
+            gsb_form_widget_set_empty ( widget, TRUE );
+        }
 
-		widget = gsb_form_widget_get_widget ( TRANSACTION_FORM_TYPE);
+        widget = gsb_form_widget_get_widget ( TRANSACTION_FORM_TYPE);
 
-		/* change the method of payment if necessary
-		 * (if grey, it's a child of split so do nothing) */
-		if ( widget
-		     &&
-		     GTK_WIDGET_SENSITIVE (widget))
-		{
-		    /* change the signe of the method of payment and the contra */
-		    if ( gsb_payment_method_get_combo_sign (widget) == GSB_PAYMENT_CREDIT)
-		    {
-			gsb_payment_method_create_combo_list ( widget,
-							       GSB_PAYMENT_DEBIT,
-							       account_number, 0 );
-			/* if there is no payment method, the last function hide it, but we have
-			 * to hide the cheque element too */
-			if ( !GTK_WIDGET_VISIBLE (widget))
-			    gtk_widget_hide (gsb_form_widget_get_widget (TRANSACTION_FORM_CHEQUE));
+        /* change the method of payment if necessary
+         * (if grey, it's a child of split so do nothing) */
+        if ( widget
+            &&
+            GTK_WIDGET_SENSITIVE (widget))
+        {
+            /* change the signe of the method of payment and the contra */
+            if ( gsb_payment_method_get_combo_sign ( widget ) == GSB_PAYMENT_CREDIT)
+            {
+            gsb_payment_method_create_combo_list ( widget,
+                                            GSB_PAYMENT_DEBIT,
+                                            account_number, 0 );
+            /* if there is no payment method, the last function hide it, but we have
+             * to hide the cheque element too */
+            if ( !GTK_WIDGET_VISIBLE ( widget ) )
+                gtk_widget_hide ( gsb_form_widget_get_widget ( TRANSACTION_FORM_CHEQUE ) );
 
-			widget = gsb_form_widget_get_widget (TRANSACTION_FORM_CONTRA);
-			if ( GTK_WIDGET_VISIBLE (widget))
-			    gsb_payment_method_create_combo_list ( gsb_form_widget_get_widget (TRANSACTION_FORM_CONTRA),
-								   GSB_PAYMENT_CREDIT,
-								   account_number, 0 );
-		    }
-		}
-		gsb_form_check_auto_separator (entry);
-	    }
-	    else
-		string = gsb_form_widget_get_name (TRANSACTION_FORM_DEBIT);
-	    break;
+            widget = gsb_form_widget_get_widget ( TRANSACTION_FORM_CONTRA );
+            if ( GTK_WIDGET_VISIBLE ( widget ) )
+                gsb_payment_method_create_combo_list ( gsb_form_widget_get_widget (
+                                            TRANSACTION_FORM_CONTRA ),
+                                            GSB_PAYMENT_CREDIT,
+                                            account_number, 0 );
+            }
+        }
+        gsb_form_check_auto_separator (entry);
+        }
+        else
+        {
+            /* si pas de nouveau débit on essaie de remettre l'ancien crédit */
+            if ( (string = gsb_form_widget_get_old_credit ( ) ) )
+            {
+                GtkWidget * widget_prov = gsb_form_widget_get_widget (
+                        TRANSACTION_FORM_CREDIT );
 
-	case TRANSACTION_FORM_CREDIT :
-	    /* we change the payment method to adapt it for the debit */
-	    if ( strlen ( gtk_entry_get_text ( GTK_ENTRY (entry))))
-	    {
-		/* empty the credit */
-		widget = gsb_form_widget_get_widget (TRANSACTION_FORM_DEBIT);
-		if (!gsb_form_widget_check_empty (widget))
-		{
-		    gtk_entry_set_text ( GTK_ENTRY (widget),
-					 gsb_form_widget_get_name (TRANSACTION_FORM_DEBIT));
-		    gsb_form_widget_set_empty ( widget,
-						TRUE );
-		}
-		widget = gsb_form_widget_get_widget ( TRANSACTION_FORM_TYPE);
+                gtk_entry_set_text ( GTK_ENTRY ( widget_prov ), string );
+                gsb_form_widget_set_empty ( widget_prov, FALSE );
+                g_free ( string );
+                
+                widget = gsb_form_widget_get_widget ( TRANSACTION_FORM_TYPE );
+                if ( widget
+                     &&
+                     GTK_WIDGET_SENSITIVE ( widget ) )
+                {
+                    /* change the signe of the method of payment and the contra */
+                    if ( gsb_payment_method_get_combo_sign ( widget ) == GSB_PAYMENT_DEBIT )
+                    {
+                    gint payement_number =  
+                        gsb_data_transaction_get_method_of_payment_number (
+                        transaction_number );
 
-		/* change the method of payment if necessary
-		 * (if grey, it's a child of split so do nothing) */
-		if ( widget
-		     &&
-		     GTK_WIDGET_SENSITIVE (widget))
-		{
-		    /* change the signe of the method of payment and the contra */
-		    if ( gsb_payment_method_get_combo_sign (widget) == GSB_PAYMENT_DEBIT)
-		    {
-			gsb_payment_method_create_combo_list ( widget,
-							       GSB_PAYMENT_CREDIT,
-							       account_number, 0 );
-			/* if there is no payment method, the last function hide it, but we have
-			 * to hide the cheque element too */
-			if ( !GTK_WIDGET_VISIBLE (widget))
-			    gtk_widget_hide (gsb_form_widget_get_widget (TRANSACTION_FORM_CHEQUE));
+                    gsb_payment_method_create_combo_list ( widget,
+                                            GSB_PAYMENT_CREDIT,
+                                            account_number, 0 );
+                    gsb_payment_method_set_payment_position ( widget, payement_number );
 
-			widget = gsb_form_widget_get_widget ( TRANSACTION_FORM_CONTRA);
-			if ( GTK_WIDGET_VISIBLE (widget))
-			    gsb_payment_method_create_combo_list ( widget,
-								   GSB_PAYMENT_DEBIT,
-								   account_number, 0 );
-		    }
-		}
-		gsb_form_check_auto_separator (entry);
-	    }
-	    else
-		string = gsb_form_widget_get_name (TRANSACTION_FORM_CREDIT);
-	    break;
+                    /* if there is no payment method, the last function hide it, but we have
+                     * to hide the cheque element too */
+                    if ( !GTK_WIDGET_VISIBLE (widget))
+                        gtk_widget_hide (gsb_form_widget_get_widget (
+                                            TRANSACTION_FORM_CHEQUE ) );
+
+                    widget = gsb_form_widget_get_widget (TRANSACTION_FORM_CONTRA);
+                    if ( GTK_WIDGET_VISIBLE (widget))
+                        gsb_payment_method_create_combo_list ( gsb_form_widget_get_widget (
+                                            TRANSACTION_FORM_CONTRA ),
+                                            GSB_PAYMENT_DEBIT,
+                                            account_number, 0 );
+                    }
+                }
+            }
+            string = gsb_form_widget_get_name (TRANSACTION_FORM_DEBIT);
+        }
+        break;
+
+    case TRANSACTION_FORM_CREDIT :
+        /* we change the payment method to adapt it for the debit */
+        if ( strlen ( gtk_entry_get_text ( GTK_ENTRY (entry))))
+        {
+        /* empty the credit */
+        widget = gsb_form_widget_get_widget (TRANSACTION_FORM_DEBIT);
+        if (!gsb_form_widget_check_empty (widget))
+        {
+            gtk_entry_set_text ( GTK_ENTRY (widget),
+                        gsb_form_widget_get_name (TRANSACTION_FORM_DEBIT));
+            gsb_form_widget_set_empty ( widget, TRUE );
+        }
+        widget = gsb_form_widget_get_widget ( TRANSACTION_FORM_TYPE);
+
+        /* change the method of payment if necessary
+         * (if grey, it's a child of split so do nothing) */
+        if ( widget
+             &&
+             GTK_WIDGET_SENSITIVE (widget))
+        {
+            /* change the signe of the method of payment and the contra */
+            if ( gsb_payment_method_get_combo_sign (widget) == GSB_PAYMENT_DEBIT)
+            {
+            gsb_payment_method_create_combo_list ( widget,
+                        GSB_PAYMENT_CREDIT,
+                        account_number, 0 );
+            /* if there is no payment method, the last function hide it, but we have
+             * to hide the cheque element too */
+            if ( !GTK_WIDGET_VISIBLE (widget))
+                gtk_widget_hide (gsb_form_widget_get_widget (TRANSACTION_FORM_CHEQUE));
+
+            widget = gsb_form_widget_get_widget ( TRANSACTION_FORM_CONTRA);
+            if ( GTK_WIDGET_VISIBLE (widget))
+                gsb_payment_method_create_combo_list ( widget,
+                        GSB_PAYMENT_DEBIT,
+                        account_number, 0 );
+            }
+        }
+        gsb_form_check_auto_separator (entry);
+        }
+        else
+        {
+            /* si pas de nouveau credit on essaie de remettre l'ancien débit */
+            if ( (string = gsb_form_widget_get_old_debit ( ) ) )
+            {
+                GtkWidget * widget_prov = gsb_form_widget_get_widget (
+                        TRANSACTION_FORM_DEBIT );
+
+                gtk_entry_set_text ( GTK_ENTRY ( widget_prov ), string );
+                gsb_form_widget_set_empty ( widget_prov, FALSE );
+                g_free ( string );
+
+                widget = gsb_form_widget_get_widget ( TRANSACTION_FORM_TYPE );
+                if ( widget
+                     &&
+                     GTK_WIDGET_SENSITIVE ( widget ) )
+                {
+                    /* change the signe of the method of payment and the contra */
+                    if ( gsb_payment_method_get_combo_sign ( widget ) == GSB_PAYMENT_CREDIT )
+                    {
+                    gint payement_number =
+                        gsb_data_transaction_get_method_of_payment_number (
+                        transaction_number );
+
+                    gsb_payment_method_create_combo_list ( widget,
+                                            GSB_PAYMENT_DEBIT,
+                                            account_number, 0 );
+                    gsb_payment_method_set_payment_position ( widget, payement_number );
+                    
+                    /* if there is no payment method, the last function hide it, but we have
+                     * to hide the cheque element too */
+                    if ( !GTK_WIDGET_VISIBLE (widget))
+                        gtk_widget_hide (gsb_form_widget_get_widget (
+                                            TRANSACTION_FORM_CHEQUE ) );
+
+                    widget = gsb_form_widget_get_widget (TRANSACTION_FORM_CONTRA);
+                    if ( GTK_WIDGET_VISIBLE (widget))
+                        gsb_payment_method_create_combo_list ( gsb_form_widget_get_widget (
+                                            TRANSACTION_FORM_CONTRA ),
+                                            GSB_PAYMENT_CREDIT,
+                                            account_number, 0 );
+                    }
+                }
+            }
+            string = gsb_form_widget_get_name ( TRANSACTION_FORM_CREDIT );
+        }
+        break;
 
 	case TRANSACTION_FORM_CATEGORY :
 	    if ( strlen ( gtk_entry_get_text ( GTK_ENTRY (entry))))
@@ -2002,36 +2091,8 @@
             }
             gsb_form_widget_set_focus ( element_suivant );
         }
-	    if ( element_suivant == TRANSACTION_FORM_CREDIT )
-        {
-            if ( gsb_form_widget_check_empty (
-                        gsb_form_widget_get_widget (element_suivant)) &&
-                        !gsb_form_widget_check_empty (
-                        gsb_form_widget_get_widget (TRANSACTION_FORM_DEBIT)))
-            {
-                gsb_form_widget_set_focus ( TRANSACTION_FORM_DEBIT );
-            }
-            else
-                gsb_form_widget_set_focus ( element_suivant );
-        }
-        else if ( element_suivant == TRANSACTION_FORM_DEBIT )
-        {
-            if ( strlen (gtk_entry_get_text (GTK_ENTRY (widget))) > 0 )
-            {
-                do {
-                    element_suivant = gsb_form_widget_next_element (
-                                        account_number, element_suivant, GSB_LEFT );
-                } while ( element_suivant == TRANSACTION_FORM_DEBIT ||
-                            element_suivant == TRANSACTION_FORM_CREDIT );
-                gsb_form_widget_set_focus ( element_suivant );
-            }
-            else
-            {
-                gsb_form_widget_set_focus ( element_suivant );
-            }
-        }
-	    else
-            gsb_form_widget_set_focus ( element_suivant );
+
+        gsb_form_widget_set_focus ( element_suivant );
 	    return TRUE;
 	    break;
 
@@ -2053,44 +2114,9 @@
             }
             gsb_form_widget_set_focus ( element_suivant );
         }
+
 	    if ( element_suivant == -2 )
             gsb_form_finish_edition();
-        /* fix the bug 494 */
-        /* si element_suivant est débit */
-        else if ( element_suivant == TRANSACTION_FORM_DEBIT )
-        {
-            /* si débit est vide et crédit rempli je vais à crédit */
-            if ( gsb_form_widget_check_empty (
-                        gsb_form_widget_get_widget (element_suivant)) &&
-                        !gsb_form_widget_check_empty (
-                        gsb_form_widget_get_widget (TRANSACTION_FORM_CREDIT)))
-            {
-                gsb_form_widget_set_focus ( TRANSACTION_FORM_CREDIT );
-            }
-            /* sinon je reste à débit */
-            else
-                gsb_form_widget_set_focus ( element_suivant );
-        }
-        /* si element suivant est crédit */
-        else if ( element_suivant == TRANSACTION_FORM_CREDIT )
-        {
-            /* je regarde ce que vaut débit et si il y a quelque chose je saute crédit */
-            if ( strlen (gtk_entry_get_text (GTK_ENTRY (widget))) > 0 )
-            {
-                do {
-                    element_suivant = gsb_form_widget_next_element (
-                                        account_number, element_suivant, GSB_RIGHT );
-                } while ( element_suivant == TRANSACTION_FORM_DEBIT ||
-                            element_suivant == TRANSACTION_FORM_CREDIT );
-                gsb_form_widget_set_focus ( element_suivant );
-            }
-            /* sinon je reste à crédit */
-            else
-            {
-                gsb_form_widget_set_focus ( element_suivant );
-            }
-        }
-        /* sinon je donne le focus à l'élément suivant */
 	    else
             gsb_form_widget_set_focus ( element_suivant );
 	    return TRUE;

Index: parametres.h
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/parametres.h,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -r1.28 -r1.29
--- parametres.h	30 Mar 2009 15:11:08 -0000	1.28
+++ parametres.h	25 May 2009 19:42:27 -0000	1.29
@@ -34,10 +34,10 @@
 
 /*START_DECLARATION*/
 gboolean gsb_config_backup_dir_chosen ( GtkWidget *button,
-					GtkWidget *dialog );
+                        GtkWidget *dialog );
 gboolean gsb_gui_encryption_toggled ( GtkWidget * checkbox, gpointer data );
 gboolean gsb_preferences_menu_open ( GtkWidget *menu_item,
-				     gpointer page_ptr );
+                        gpointer page_ptr );
 gboolean preferences ( gint page );
 /*END_DECLARATION*/
 

Index: gsb_form_widget.h
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/gsb_form_widget.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- gsb_form_widget.h	16 Oct 2007 18:10:39 -0000	1.4
+++ gsb_form_widget.h	25 May 2009 19:42:27 -0000	1.5
@@ -19,16 +19,18 @@
 /* START_DECLARATION */
 gboolean gsb_form_widget_check_empty ( GtkWidget *entry );
 GtkWidget *gsb_form_widget_create ( gint element_number,
-				    gint account_number );
+                        gint account_number );
 gboolean gsb_form_widget_free_list ( void );
 GSList *gsb_form_widget_get_list ( void );
 gchar *gsb_form_widget_get_name ( gint element_number );
+gchar *gsb_form_widget_get_old_credit ( void );
+gchar *gsb_form_widget_get_old_debit ( void );
 GtkWidget *gsb_form_widget_get_widget ( gint element_number );
 gint gsb_form_widget_next_element ( gint account_number,
-				    gint element_number,
-				    gint direction );
+                        gint element_number,
+                        gint direction );
 void gsb_form_widget_set_empty ( GtkWidget *entry,
-				 gboolean empty );
+                    gboolean empty );
 void gsb_form_widget_set_focus ( gint element_number );
 /* END_DECLARATION */
 #endif

Index: gsb_payment_method.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/gsb_payment_method.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- gsb_payment_method.c	10 May 2009 13:06:56 -0000	1.17
+++ gsb_payment_method.c	25 May 2009 19:42:27 -0000	1.18
@@ -1,8 +1,8 @@
 /* ************************************************************************** */
 /*                                                                            */
-/*     Copyright (C)	2000-2008 Cédric Auger (cedric at grisbi.org)            */
-/*			2003-2008 Benjamin Drieu (bdrieu at april.org)                       */
-/* 			http://www.grisbi.org                                             */
+/*     Copyright (C)    2000-2008 Cédric Auger (cedric at grisbi.org)            */
+/*          2003-2008 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      */
@@ -42,7 +42,7 @@
 
 /*START_STATIC*/
 static gint gsb_payment_method_get_payment_position ( GtkWidget *combo_box,
-					       gint payment_number );
+                        gint payment_number );
 /*END_STATIC*/
 
 /*START_EXTERN*/
@@ -65,9 +65,9 @@
  * \return FALSE if fail, TRUE if ok
  * */
 gboolean gsb_payment_method_create_combo_list ( GtkWidget *combo_box,
-						gint sign,
-						gint account_number,
-						gint exclude )
+                        gint sign,
+                        gint account_number,
+                        gint exclude )
 {
     GtkWidget *widget =  NULL;
     GtkListStore *store;
@@ -220,7 +220,7 @@
  * \return the position of the payment or -1 if not found
  * */
 gint gsb_payment_method_get_payment_position ( GtkWidget *combo_box,
-					       gint payment_number )
+                        gint payment_number )
 {
     gint i = 0;
     GtkTreeModel *model;
@@ -255,6 +255,44 @@
 
 
 /**
+ * set active the payment number in param
+ *
+ * \param       combo_box
+ * \param       payment_number
+ *
+ * */
+void gsb_payment_method_set_payment_position ( GtkWidget *combo_box,
+                        gint payment_number )
+{
+    gint i = 0;
+    GtkTreeModel *model;
+    GtkTreeIter iter;
+
+    if ( !payment_number || !combo_box )
+    return;
+
+    model = gtk_combo_box_get_model ( GTK_COMBO_BOX ( combo_box ) );
+    if ( gtk_tree_model_get_iter_first ( GTK_TREE_MODEL ( model ), &iter ) )
+    {
+    do
+    {
+        gint tmp;
+
+        gtk_tree_model_get ( GTK_TREE_MODEL ( model ), &iter, 1, &tmp, -1 );
+        if ( tmp == payment_number )
+        {
+            gtk_combo_box_set_active_iter ( GTK_COMBO_BOX (combo_box), &iter );
+            return;
+        }
+        i++; 
+    }
+    while ( gtk_tree_model_iter_next ( GTK_TREE_MODEL ( model ), &iter ) );
+    }
+    return;
+}
+
+
+/**
  * set the given payment number in the combobox
  * if not found, set the default payment number for that account
  *
@@ -265,7 +303,7 @@
  * \return TRUE if we can set the payment_number, FALSE if it's the default wich is set
  * */
 gboolean gsb_payment_method_set_combobox_history ( GtkWidget *combo_box,
-						   gint payment_number )
+                        gint payment_number )
 {
     gint position;
     gboolean return_value;
@@ -303,7 +341,7 @@
  * \return FALSE
  * */
 gboolean gsb_payment_method_changed_callback ( GtkWidget *combo_box,
-					       gpointer null )
+                        gpointer null )
 {
     gint payment_number;
     GtkWidget *cheque_entry;

Index: gsb_data_account.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/gsb_data_account.c,v
retrieving revision 1.78
retrieving revision 1.79
diff -u -d -r1.78 -r1.79
--- gsb_data_account.c	23 May 2009 21:48:22 -0000	1.78
+++ gsb_data_account.c	25 May 2009 19:42:27 -0000	1.79
@@ -127,8 +127,8 @@
 /*END_STATIC*/
 
 /*START_EXTERN*/
-extern gsb_real null_real;
 extern gsb_real error_real;
+extern gsb_real null_real;
 extern gint tab_affichage_ope[TRANSACTION_LIST_ROWS_NB][CUSTOM_MODEL_VISIBLE_COLUMNS];
 /*END_EXTERN*/
 

Index: gsb_payment_method.h
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/gsb_payment_method.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- gsb_payment_method.h	8 Oct 2008 15:23:50 -0000	1.7
+++ gsb_payment_method.h	25 May 2009 19:42:27 -0000	1.8
@@ -7,14 +7,16 @@
 
 /* START_DECLARATION */
 gboolean gsb_payment_method_changed_callback ( GtkWidget *combo_box,
-					       gpointer null );
+                        gpointer null );
 gboolean gsb_payment_method_create_combo_list ( GtkWidget *combo_box,
-						gint sign,
-						gint account_number,
-						gint exclude );
+                        gint sign,
+                        gint account_number,
+                        gint exclude );
 gint gsb_payment_method_get_combo_sign ( GtkWidget *combo_box );
 gint gsb_payment_method_get_selected_number ( GtkWidget *combo_box );
 gboolean gsb_payment_method_set_combobox_history ( GtkWidget *combo_box,
-						   gint payment_number );
+                        gint payment_number );
+void gsb_payment_method_set_payment_position ( GtkWidget *combo_box,
+                        gint payment_number );
 /* END_DECLARATION */
 #endif



More information about the cvs mailing list