[grisbi-cvs] grisbi/src custom_list.c, 1.4, 1.5 dialog.c, 1.73, 1.74 dialog.h, 1.32, 1.33 gsb_file_others.c, 1.28, 1.29 gsb_form_widget.c, 1.35, 1.36 import.c, 1.294, 1.295 import.h, 1.43, 1.44 metatree.c, 1.143, 1.144 tiers_onglet.c, 1.167, 1.168 utils_str.c, 1.69, 1.70 utils_str.h, 1.43, 1.44

Pierre Biava pbiava at users.sourceforge.net
Wed Oct 7 23:46:23 CEST 2009


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

Modified Files:
	custom_list.c dialog.c dialog.h gsb_file_others.c 
	gsb_form_widget.c import.c import.h metatree.c tiers_onglet.c 
	utils_str.c utils_str.h 
Log Message:
various bugs correction

Index: gsb_form_widget.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/gsb_form_widget.c,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -d -r1.35 -r1.36
--- gsb_form_widget.c	27 Jun 2009 15:10:52 -0000	1.35
+++ gsb_form_widget.c	7 Oct 2009 21:46:21 -0000	1.36
@@ -42,7 +42,6 @@
 #include "./gsb_fyear.h"
 #include "./gsb_payment_method.h"
 #include "./gtk_combofix.h"
-#include "./dialog.h"
 #include "./traitement_variables.h"
 #include "./gsb_form.h"
 #include "./gsb_data_payment.h"

Index: metatree.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/metatree.c,v
retrieving revision 1.143
retrieving revision 1.144
diff -u -d -r1.143 -r1.144
--- metatree.c	30 Aug 2009 17:59:48 -0000	1.143
+++ metatree.c	7 Oct 2009 21:46:21 -0000	1.144
@@ -2239,7 +2239,7 @@
     GtkTreeIter iter;
     GtkTreePath *path;
     gboolean selection_is_set = FALSE;
-    gint div_id, sub_div_id, current_number;
+    gint div_id = 0, sub_div_id = 0, current_number = 0;
 
     iface = g_object_get_data ( G_OBJECT(model), "metatree-interface" );   
     tree_view = g_object_get_data ( G_OBJECT(model), "tree-view" );

Index: gsb_file_others.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/gsb_file_others.c,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -r1.28 -r1.29
--- gsb_file_others.c	7 Oct 2009 19:30:04 -0000	1.28
+++ gsb_file_others.c	7 Oct 2009 21:46:21 -0000	1.29
@@ -1,6 +1,6 @@
 /* ************************************************************************** */
 /*                                                                            */
-/*     Copyright (C)    2000-2005 Cédric Auger (cedric at grisbi.org)            */
+/*     Copyright (C)    2000-2005 Cédric Auger (cedric at grisbi.org)            */
 /*          http://www.grisbi.org                                             */
 /*                                                                            */
 /*  This program is free software; you can redistribute it and/or modify      */
@@ -579,23 +579,19 @@
 	return FALSE;
     }
 
+    file_content = gsb_string_uniform_new_line ( file_content, 37 );
+
     switch ( origin )
     {
 	case 0:
 	    if ( !strncmp ( file_content,
 			    "<?xml version=\"1.0\"?>\n<Grisbi_categ>",
-			    36 ) ||
-			 !strncmp ( file_content,
-			    "<?xml version=\"1.0\"?>\r\n<Grisbi_categ>",
-			    37 ) )
+			    36 ) )
 	    {
 		/* check if not before 0.6 */
 		if ( !strncmp ( file_content,
 				"<?xml version=\"1.0\"?>\n<Grisbi_categ>\n	<General\n",
-				47 ) ||
-			 !strncmp ( file_content,
-				"<?xml version=\"1.0\"?>\r\n<Grisbi_categ>\r\n	<General\r\n",
-				50 ))
+				47 ) )
 		    return TRUE;
 		else
 		    dialogue_error (_("The file version is below 0.6.0, Grisbi cannot import it."));
@@ -608,19 +604,13 @@
 	    /* check first if it's not below 0.6 */
 	    if ( !strncmp ( file_content,
 			    "<?xml version=\"1.0\"?>\n<Grisbi_ib>",
-			    33 ) ||
-			 !strncmp ( file_content,
-			    "<?xml version=\"1.0\"?>\r\n<Grisbi_ib>",
-			    34 ))
+			    33 ) )
 		    dialogue_error (_("The file version is below 0.6.0, Grisbi cannot import it."));
 	    else
 	    {
 		if ( !strncmp ( file_content,
 				"<?xml version=\"1.0\"?>\n<Grisbi_budget>",
-				37 ) ||
-			 !strncmp ( file_content,
-				"<?xml version=\"1.0\"?>\r\n<Grisbi_budget>",
-				38 ))
+				37 ) )
 		    return TRUE;
 		else
 		    dialogue_error ( _("This is not a budget file, loading canceled..."));
@@ -631,19 +621,13 @@
 	    /* check first if it's not below 0.6 */
 	    if ( !strncmp ( file_content,
 			    "<?xml version=\"1.0\"?>\n<Grisbi_etat>",
-			    35 ) ||
-			 !strncmp ( file_content,
-			    "<?xml version=\"1.0\"?>\r\n<Grisbi_etat>",
-			    36 ))
+			    35 ) )
 		dialogue_error (_("The file version is below 0.6.0, Grisbi cannot import it."));
 	    else
 	    {
 		if ( !strncmp ( file_content,
 				"<?xml version=\"1.0\"?>\n<Grisbi_report>",
-				37 ) ||
-			 !strncmp ( file_content,
-				"<?xml version=\"1.0\"?>\r\n<Grisbi_report>",
-				38 ))
+				37 ) )
 		    return TRUE;
 		else
 		    dialogue_error ( _("This is not a report file, loading canceled..."));

Index: custom_list.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/custom_list.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- custom_list.c	18 Oct 2008 12:39:28 -0000	1.4
+++ custom_list.c	7 Oct 2009 21:46:21 -0000	1.5
@@ -36,7 +36,6 @@
 /*START_INCLUDE*/
 #include "custom_list.h"
 #include "./gsb_data_transaction.h"
-#include "./dialog.h"
 #include "./transaction_list.h"
 #include "./transaction_model.h"
 #include "./erreur.h"

Index: dialog.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/dialog.c,v
retrieving revision 1.73
retrieving revision 1.74
diff -u -d -r1.73 -r1.74
--- dialog.c	3 Oct 2009 22:14:56 -0000	1.73
+++ dialog.c	7 Oct 2009 21:46:21 -0000	1.74
@@ -32,14 +32,17 @@
 /*START_STATIC*/
 static void dialogue_conditional ( gchar *text, gchar *var );
 static void dialogue_conditional_hint ( gchar *hint, gchar *text, gchar *var );
-static GtkDialog *dialogue_conditional_new ( gchar *text, gchar * var, GtkMessageType type,
+static GtkDialog *dialogue_conditional_new ( gchar *text,
+                        gchar *var,
+                        GtkMessageType type,
                         GtkButtonsType buttons );
 static void dialogue_conditional_special ( gchar *text, gchar *var, GtkMessageType type );
+static gboolean dialogue_update_struct_message ( GtkWidget *checkbox,
+                        struct conditional_message *message );
 static gboolean dialogue_update_var ( GtkWidget *checkbox, gint message );
 /*END_STATIC*/
 
 
-
 /*START_EXTERN*/
 extern GtkWidget *window;
 /*END_EXTERN*/
@@ -90,8 +93,8 @@
 
     { "development-version", N_("You are running Grisbi version %s"), 
       N_("Warning, please be aware that the version you run is a DEVELOPMENT version. "
-	 "In any case do not work with this version on your original accounting files. "
-	 "(File format may change and render files incompatible with previous versions)."),
+     "In any case do not work with this version on your original accounting files. "
+     "(File format may change and render files incompatible with previous versions)."),
       FALSE, FALSE },
 
 /*
@@ -103,8 +106,6 @@
 };
 
 
-
-
 /**
  * Display an info dialog window with a hint displayed larger and in
  * bold.
@@ -118,7 +119,6 @@
 }
 
 
-
 /**
  * Display an info dialog window.
  *
@@ -130,7 +130,6 @@
 }
 
 
-
 /**
  * Display an error dialog window
  *
@@ -142,7 +141,6 @@
 }
 
 
-
 /**
  * Display an error dialog window with an optional hint.
  *
@@ -155,7 +153,6 @@
 }
 
 
-
 /**
  * Display a warning dialog window
  *
@@ -167,7 +164,6 @@
 }
 
 
-
 /**
  * Display a warning dialog window with an optional hint.
  *
@@ -180,7 +176,6 @@
 }
 
 
-
 /**
  * Display a dialog window with arbitrary icon.
  * WARNING you may need to escape text with g_markup_escape_text() 
@@ -205,7 +200,6 @@
 }
 
 
-
 /**
  * Display a dialog window with arbitrary icon.
  * WARNING you may need to escape text with g_markup_escape_text() 
@@ -232,16 +226,34 @@
 }
 
 
+/**
+ * Update the value of a message in memory according to the state of a
+ * checkbox button.  These messages are conditional dialogs (see
+ * dialogue_conditional_new()).  Normally called as an event.
+ *
+ * \param checbox   GtkCheckbox that triggered this event.
+ * \param message   struct conditional_message Message
+ *
+ * \return      FALSE.
+ */
+gboolean dialogue_update_struct_message ( GtkWidget *checkbox,
+                        struct conditional_message *message )
+{
+    message -> hidden = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( checkbox ) );
+
+    return FALSE;
+}
+
 
 /**
  * Update the value of a message in memory according to the state of a
  * checkbox button.  These messages are conditional dialogs (see
  * dialogue_conditional_new()).  Normally called as an event.
  *
- * \param checbox	GtkCheckbox that triggered this event.
- * \param message	Message ID.
+ * \param checbox   GtkCheckbox that triggered this event.
+ * \param message   Message ID.
  *
- * \return		FALSE.
+ * \return      FALSE.
  */
 gboolean dialogue_update_var ( GtkWidget *checkbox, gint message )
 {
@@ -264,7 +276,9 @@
  *
  * \return  A newly-created GtkDialog.
  */
-GtkDialog *dialogue_conditional_new ( gchar *text, gchar * var, GtkMessageType type,
+GtkDialog *dialogue_conditional_new ( gchar *text,
+                        gchar *var,
+                        GtkMessageType type,
                         GtkButtonsType buttons )
 {
     GtkWidget * vbox, * checkbox, *dialog;
@@ -306,7 +320,6 @@
 }
 
 
-
 /**
  * This function pop ups a dialog with a hint (first sentence, in
  * bold), an informal text and a checkbox that allow this message not
@@ -325,7 +338,6 @@
 }
 
 
-
 /**
  * This function pop ups a dialog with an informal text and a checkbox
  * that allow this message not to be displayed again thanks to
@@ -342,16 +354,15 @@
 }
 
 
-
 /**
  * This function pop ups a dialog with an informal text and a checkbox
  * that allow this message not to be displayed again thanks to
  * preferences.
  *
- * \param text	Text to be displayed
- * \param var	Variable that both controls whether the dialog will
- *		appear or not and that indicates which variable could
- *		be modified so that this message won't appear again.
+ * \param text  Text to be displayed
+ * \param var   Variable that both controls whether the dialog will
+ *      appear or not and that indicates which variable could
+ *      be modified so that this message won't appear again.
  */
 void dialogue_conditional_special ( gchar *text, gchar *var, GtkMessageType type )
 {
@@ -359,28 +370,13 @@
 
     dialog = dialogue_conditional_new ( text, var, type, GTK_BUTTONS_CLOSE );
     if ( ! dialog )
-	return;
+    return;
 
     gtk_dialog_run ( GTK_DIALOG (dialog) );
     gtk_widget_destroy ( GTK_WIDGET (dialog));
 }
 
 
-
-/**
- * Alias for question_yes_no().
- *
- * \deprecated This should not be used in newly written code.  Use
- * question_yes_no() instead.
- */
-gboolean question ( gchar *texte )
-{
-    return question_yes_no ( texte,
-			     GTK_RESPONSE_NO  );
-}
-
-
-
 /**
  * Pop up a warning dialog window with a question and wait for user to
  * press 'OK' or 'Cancel'.  A hint is displayed on the top of the
@@ -400,17 +396,16 @@
 }
 
 
-
 /**
  * Pop up a warning dialog window with a question and wait for user to
- * press 'OK' or 'Cancel'.
+ * press 'YES' or 'NO'.
   * WARNING you may need to escape text with g_markup_escape_text() 
  * or g_markup_printf_escaped():
  *
  * \param texte  Text to be displayed
  * \param default_answer GTK_RESPONSE_OK or GTK_RESPONSE_CANCEL, will give the focus to the button
  *
- * \return TRUE if user pressed 'OK'.  FALSE otherwise.
+ * \return TRUE if user pressed 'YES'.  FALSE otherwise.
  */
 gboolean question_yes_no ( gchar *text, gint default_answer )
 {
@@ -440,13 +435,13 @@
 /**
  * Pop up a warning dialog window with a question and a checkbox that allow
  * this message not to be displayed again thanks to preferences and wait
- * for user to press 'OK' or 'Cancel'.
+ * for user to press 'YES' or 'NO'.
  *
  * \param var variable that both controls whether the dialog will
  * appear or not and that indicates which variable could be modified
  * so that this message won't appear again.
  *
- * \return TRUE if user pressed 'OK'.  FALSE otherwise.
+ * \return TRUE if user pressed 'YES'.  FALSE otherwise.
  */
 gboolean question_conditional_yes_no ( gchar *var )
 {
@@ -479,48 +474,48 @@
         messages[i].default_answer = FALSE;
 
     gtk_widget_destroy (GTK_WIDGET (dialog));
-    return messages[i].default_answer;	
+    return messages[i].default_answer;
 }
 
 
-
-/**
- * Pop up a warning dialog window with a question and a checkbox that
- * allow this message not to be displayed again thanks to preferences
- * and wait for user to press 'OK' or 'Cancel'.
- *
- * \param hint	Hint to be displayed.
- * \param texte Text to be displayed.
- * \param var	Variable that both controls whether the dialog will
- *		appear or not and that indicates which variable could
- *		be modified so that this message won't appear again.
- *
- * \return	TRUE if user pressed 'OK'.  FALSE otherwise.
- */
-/*gboolean question_conditional_yes_no_special ( gchar * hint, gchar * message, gchar * var )
+gboolean question_conditional_yes_no_with_struct ( struct conditional_message *message )
 {
-    GtkDialog *dialog;
+    GtkWidget *dialog, *vbox, *checkbox;
+    gchar *text;
     gint response;
 
-    dialog = dialogue_conditional_new ( make_hint ( hint, message ), var, GTK_MESSAGE_INFO,
-					GTK_BUTTONS_YES_NO );
-    if ( ! dialog )
-	return FALSE;
+    if ( message -> hidden )
+        return message -> default_answer;
 
-    response = gtk_dialog_run ( GTK_DIALOG (dialog) );
-    gtk_widget_destroy ( GTK_WIDGET (dialog));
-    
-    if ( response == GTK_RESPONSE_YES ) 
-    {
-	*var = 1;
-	return TRUE;
-    }
+    text = make_hint ( message -> hint, message -> message );
+    dialog = gtk_message_dialog_new ( GTK_WINDOW (window),
+                        GTK_DIALOG_DESTROY_WITH_PARENT,
+                        GTK_MESSAGE_WARNING,
+                        GTK_BUTTONS_YES_NO,
+                        "%s", text );
+    gtk_dialog_set_default_response ( GTK_DIALOG( dialog ), GTK_RESPONSE_NO );
+    gtk_label_set_markup ( GTK_LABEL ( GTK_MESSAGE_DIALOG ( dialog )->label ), text );
+
+    vbox = GTK_DIALOG ( dialog ) -> vbox;
+
+    checkbox = gtk_check_button_new_with_label ( _("Do not show this message again") );
+    g_signal_connect ( G_OBJECT ( checkbox ),
+                        "toggled", 
+                        G_CALLBACK ( dialogue_update_struct_message ),
+                        message );
+    gtk_box_pack_start ( GTK_BOX ( vbox ), checkbox, TRUE, TRUE, 6 );
+    gtk_widget_show_all ( checkbox );
+
+    response = gtk_dialog_run (GTK_DIALOG (dialog));
+
+    if ( response == GTK_RESPONSE_YES )
+        message -> default_answer = TRUE;
     else
-    {
-	*var = 0;
-	return FALSE;
-    }
-}*/
+        message -> default_answer = FALSE;
+
+    gtk_widget_destroy (GTK_WIDGET (dialog));
+    return message -> default_answer;
+}
 
 
 /**
@@ -561,6 +556,15 @@
 }
 
 
+/**
+ * use pango layout to produce a string that will contain a text.
+ *
+ * \param attribut  exemple foreground=\"red\", size=\"x-large\"
+ * \param text      Text 
+ *
+ * \return a pango formated string It returns a newly allocated string which must 
+ *         be freed when no more used.
+ */
 gchar *make_pango_attribut ( gchar *attribut, gchar *text )
 {
     gchar *tmpstr;
@@ -570,6 +574,8 @@
 
     return tmpstr;
 }
+
+
 /**
  * use pango layout to produce a string that will contain a text.
  *
@@ -595,8 +601,9 @@
  */
 void dialogue_error_brain_damage ()
 {
-    dialogue_error_hint ( _("Hi, you are in the middle of nowhere, between two lines of code.  Grisbi is expected to crash very soon.  Have a nice day."), 
-			  _("Serious brain damage expected.") );
+    dialogue_error_hint ( _("Hi, you are in the middle of nowhere, between two lines of code."
+                        " Grisbi is expected to crash very soon. Have a nice day."), 
+                        _("Serious brain damage expected.") );
 }
 
 
@@ -607,13 +614,13 @@
  */
 void dialogue_error_memory ()
 {
-    dialogue_error_hint ( _("Bad things will happen soon.  Be sure to save any modification in a separate file in case Grisbi would corrupt files."),
-			  _("Cannot allocate memory") );
+    dialogue_error_hint ( _("Bad things will happen soon.  Be sure to save any modification "
+                        "in a separate file in case Grisbi would corrupt files."),
+                        _("Cannot allocate memory") );
 
 }
 
 
-
 /**
  *
  *
@@ -645,7 +652,6 @@
 }
 
 
-
 /**
  * Display an info dialog window with a hint displayed larger and in
  * bold.
@@ -693,9 +699,6 @@
 
     return string;
 }
-
-
-
 /* Local Variables: */
 /* c-basic-offset: 4 */
 /* End: */

Index: import.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/import.c,v
retrieving revision 1.294
retrieving revision 1.295
diff -u -d -r1.294 -r1.295
--- import.c	3 Oct 2009 22:14:56 -0000	1.294
+++ import.c	7 Oct 2009 21:46:21 -0000	1.295
@@ -3362,14 +3362,10 @@
 }
 
 
-/**
- * callback quand on appuie sur le bouton gestion des associations des tiers
- *
- * \param button
- * \param data
- *
- * */
-GtkWidget * gsb_import_associations_gere_tiers ( )
+/* *******************************************************************************/
+/* page de configuration pour la gestion des associations des tiers              */
+/* *******************************************************************************/
+GtkWidget * gsb_import_associations_gere_tiers ( void )
 {
     GtkWidget *vbox_main, *vbox, *paddingbox, *button;
     GtkWidget *hbox, *vbox2, *sw, *treeview ;
@@ -3440,8 +3436,7 @@
                         3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INT );
 
     /* remplit le modèle si nécessaire */
-    if (g_slist_length ( liste_associations_tiers ) > 0 )
-        gsb_import_associations_fill_model ( list_store );
+    gsb_import_associations_fill_model ( list_store );
 
     /* create the treeview */
     treeview = gtk_tree_view_new_with_model (
@@ -3542,8 +3537,6 @@
 /**
  *
  *
- *
- *
  */
 void gsb_import_associations_init_variables ( void )
 {
@@ -3852,6 +3845,7 @@
     return 0;
 }
 
+
 gint gsb_import_associations_list_append_assoc ( gint payee_number,
                         const gchar *search_str )
 {
@@ -3877,8 +3871,6 @@
 /**
  *
  *
- *
- *
  */
 gboolean gsb_import_associations_check_add_button ( GObject * main_widget )
 {
@@ -3908,6 +3900,7 @@
     return FALSE;
 }
 
+
 /* *******************************************************************************/
 
 

Index: utils_str.h
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/utils_str.h,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -d -r1.43 -r1.44
--- utils_str.h	2 Oct 2009 21:35:04 -0000	1.43
+++ utils_str.h	7 Oct 2009 21:46:21 -0000	1.44
@@ -17,6 +17,7 @@
 gchar * gsb_string_remplace_joker ( const gchar *chaine, gchar *new_str );
 gchar * gsb_string_remplace_string ( gchar * str, gchar *old_str, gchar *new_str );
 gchar * gsb_string_truncate ( gchar * string );
+gchar *gsb_string_uniform_new_line ( const gchar *chaine, gint nbre_char );
 gchar * latin2utf8 ( const gchar * inchar);
 gchar *limit_string ( gchar *string,
                         gint length );

Index: import.h
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/import.h,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -d -r1.43 -r1.44
--- import.h	12 Sep 2009 19:33:40 -0000	1.43
+++ import.h	7 Oct 2009 21:46:21 -0000	1.44
@@ -114,7 +114,7 @@
 /* START_DECLARATION */
 gint gsb_import_associations_cmp_assoc (struct struct_payee_asso *assoc_1,
                                         struct struct_payee_asso *assoc_2);
-GtkWidget * gsb_import_associations_gere_tiers ( );
+GtkWidget * gsb_import_associations_gere_tiers ( void );
 void gsb_import_associations_init_variables ( void );
 gint gsb_import_associations_list_append_assoc ( gint payee_number,
                         const gchar *search_str );

Index: dialog.h
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/dialog.h,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -d -r1.32 -r1.33
--- dialog.h	3 Oct 2009 22:14:56 -0000	1.32
+++ dialog.h	7 Oct 2009 21:46:21 -0000	1.33
@@ -4,6 +4,16 @@
 /* END_INCLUDE_H */
 
 
+struct conditional_message
+{
+    gchar * name;
+    gchar * hint;
+    gchar * message;
+    gboolean hidden;
+    gboolean default_answer;	/** Useful for yes/no questions. */
+};
+
+
 /* START_DECLARATION */
 void dialog_message ( gchar *label, ... );
 void dialogue ( gchar *texte_dialogue );
@@ -23,21 +33,11 @@
 gchar *make_hint ( gchar *hint, gchar *text );
 gchar *make_pango_attribut ( gchar *attribut, gchar *text );
 gchar *make_red ( gchar *text );
-gboolean question ( gchar *texte );
 gboolean question_conditional_yes_no ( gchar *var );
+gboolean question_conditional_yes_no_with_struct ( struct conditional_message *message );
 gboolean question_yes_no ( gchar *text, gint default_answer );
 gboolean question_yes_no_hint ( gchar *hint,
                         gchar *texte,
                         gint default_answer );
 /* END_DECLARATION */
-
-struct conditional_message
-{
-    gchar * name;
-    gchar * hint;
-    gchar * message;
-    gboolean hidden;
-    gboolean default_answer;	/** Useful for yes/no questions. */
-};
-
 #endif

Index: tiers_onglet.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/tiers_onglet.c,v
retrieving revision 1.167
retrieving revision 1.168
diff -u -d -r1.167 -r1.168
--- tiers_onglet.c	3 Oct 2009 22:14:56 -0000	1.167
+++ tiers_onglet.c	7 Oct 2009 21:46:21 -0000	1.168
@@ -38,6 +38,7 @@
 #include "./gsb_assistant.h"
 #include "./gsb_automem.h"
 #include "./gsb_data_form.h"
+#include "./gsb_data_mix.h"
 #include "./gsb_data_payee.h"
 #include "./gsb_data_scheduled.h"
 #include "./gsb_data_transaction.h"
@@ -57,6 +58,7 @@
 #include "./structures.h"
 #include "./gsb_data_form.h"
 #include "./include.h"
+#include "./dialog.h"
 #include "./erreur.h"
 /*END_INCLUDE*/
 
@@ -71,6 +73,12 @@
 static  gboolean gsb_assistant_payees_enter_page_finish ( GtkWidget *assistant );
 static void gsb_assistant_payees_entry_changed ( GtkEditable *editable,
                         GtkWidget *assistant );
+static void gsb_assistant_payees_modifie_operations ( GSList *sup_payees,
+                        gint transaction_number,
+                        gint new_payee_number,
+                        gboolean save_notes,
+                        gboolean extract_num,
+                        gboolean is_transaction );
 static  GtkWidget *gsb_assistant_payees_page_2 ( GtkWidget *assistant );
 static  GtkWidget *gsb_assistant_payees_page_3 ( GtkWidget *assistant );
 static  GtkWidget *gsb_assistant_payees_page_finish ( GtkWidget *assistant );
@@ -103,6 +111,8 @@
 /* structure pour la sauvegarde de la position */
 struct metatree_hold_position *payee_hold_position;
 
+struct conditional_message *overwrite_payee;
+
 /*START_EXTERN*/
 extern GSList *liste_associations_tiers;
 extern MetatreeInterface * payee_interface;
@@ -134,8 +144,9 @@
 gboolean gsb_payee_update_combofix ( void )
 {
     if ( gsb_data_form_check_for_value ( TRANSACTION_FORM_PARTY ))
-	gtk_combofix_set_list ( GTK_COMBOFIX ( gsb_form_widget_get_widget (TRANSACTION_FORM_PARTY)),
-				gsb_data_payee_get_name_and_report_list ());
+    gtk_combofix_set_list ( GTK_COMBOFIX ( gsb_form_widget_get_widget 
+                        (TRANSACTION_FORM_PARTY)),
+                        gsb_data_payee_get_name_and_report_list ());
 
     return FALSE;
 }
@@ -155,11 +166,10 @@
     GtkTreeDragDestIface * dst_iface;
     GtkTreeDragSourceIface * src_iface;
     static GtkTargetEntry row_targets[] = {
-	{ "GTK_TREE_MODEL_ROW", GTK_TARGET_SAME_WIDGET, 0 }
+    { "GTK_TREE_MODEL_ROW", GTK_TARGET_SAME_WIDGET, 0 }
     };
 
     /* création de la fenêtre qui sera renvoyée */
-
     onglet = gtk_vbox_new ( FALSE, 5 );
     gtk_widget_show ( onglet );
 
@@ -169,44 +179,43 @@
 
     /* on y ajoute la barre d'outils */
     gtk_box_pack_start ( GTK_BOX ( onglet ),
-			 creation_barre_outils_tiers(),
-			 FALSE,
-			 FALSE,
-			 0 );
+                        creation_barre_outils_tiers ( ),
+                        FALSE,
+                        FALSE,
+                        0 );
 
     /* création de l'arbre principal */
     scroll_window = gtk_scrolled_window_new ( NULL, NULL );
     gtk_scrolled_window_set_policy ( GTK_SCROLLED_WINDOW ( scroll_window ),
-				     GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC );
+                        GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC );
     gtk_scrolled_window_set_shadow_type ( GTK_SCROLLED_WINDOW(scroll_window),
-					  GTK_SHADOW_IN );
+                        GTK_SHADOW_IN );
     gtk_box_pack_start ( GTK_BOX ( onglet ), scroll_window, TRUE, TRUE, 0 );
     gtk_widget_show ( scroll_window );
 
     /* Create model */
     gtk_tree_sortable_set_sort_column_id ( GTK_TREE_SORTABLE(payee_tree_model),
-					   META_TREE_TEXT_COLUMN, GTK_SORT_ASCENDING );
-    gtk_tree_sortable_set_sort_func ( GTK_TREE_SORTABLE(payee_tree_model),
-				      META_TREE_TEXT_COLUMN, metatree_sort_column,
-				      NULL, NULL );
+                        META_TREE_TEXT_COLUMN, GTK_SORT_ASCENDING );
+    gtk_tree_sortable_set_sort_func ( GTK_TREE_SORTABLE (payee_tree_model),
+                        META_TREE_TEXT_COLUMN, metatree_sort_column,
+                        NULL, NULL );
     g_object_set_data ( G_OBJECT ( payee_tree_model), "metatree-interface",
-			payee_interface );
+                        payee_interface );
 
     /* Create container + TreeView */
     gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (payee_tree), TRUE);
     gtk_tree_view_enable_model_drag_source(GTK_TREE_VIEW(payee_tree),
-					   GDK_BUTTON1_MASK, row_targets, 1,
-					   GDK_ACTION_MOVE | GDK_ACTION_COPY );
+                        GDK_BUTTON1_MASK, row_targets, 1,
+                        GDK_ACTION_MOVE | GDK_ACTION_COPY );
     gtk_tree_view_enable_model_drag_dest ( GTK_TREE_VIEW(payee_tree), row_targets,
-					   1, GDK_ACTION_MOVE | GDK_ACTION_COPY );
+                        1, GDK_ACTION_MOVE | GDK_ACTION_COPY );
     gtk_tree_view_set_reorderable (GTK_TREE_VIEW(payee_tree), TRUE);
     gtk_tree_selection_set_mode ( gtk_tree_view_get_selection ( GTK_TREE_VIEW(payee_tree)),
-				  GTK_SELECTION_SINGLE );
+                    GTK_SELECTION_SINGLE );
     gtk_tree_view_set_model (GTK_TREE_VIEW (payee_tree),
-			     GTK_TREE_MODEL (payee_tree_model));
+                    GTK_TREE_MODEL (payee_tree_model));
     g_object_unref (G_OBJECT(payee_tree_model));
-    g_object_set_data ( G_OBJECT(payee_tree_model), "tree-view",
-			payee_tree );
+    g_object_set_data ( G_OBJECT(payee_tree_model), "tree-view", payee_tree );
 
     /* Make category column */
     cell = gtk_cell_renderer_text_new ();
@@ -272,11 +281,17 @@
     /* création de la structure de sauvegarde de la position */
     payee_hold_position = g_malloc0 ( sizeof ( struct metatree_hold_position ) );
 
+    /* création de la structure pour le remplacement des notes */
+    overwrite_payee = g_malloc0 ( sizeof (struct conditional_message ) );
+    overwrite_payee -> name = g_strdup ( "crush-existing-note" );
+    overwrite_payee -> hint = g_strdup ( _("Warning you will crush the existing note.") );
+    overwrite_payee -> hidden = FALSE;
+    overwrite_payee -> default_answer = FALSE;
+
     return ( onglet );
 }
 
 
-
 /**
  * Create a button bar allowing to act on the payee list.  Some of
  * these buttons are "linked" to the selection status of the payee
@@ -563,6 +578,7 @@
     GtkTreeSelection * selection;
     GtkTreeModel * model;
     GtkTreeIter iter;
+    GtkTreePath *path;
     gint no_division = -1;
     gint payee_number = 0;
     gchar * title;
@@ -574,7 +590,7 @@
     selection = gtk_tree_view_get_selection ( view );
     if ( selection && gtk_tree_selection_get_selected(selection, &model, &iter))
     {
-	gtk_tree_model_get ( model, &iter,
+    gtk_tree_model_get ( model, &iter,
                         META_TREE_POINTER_COLUMN, &payee_number,
                         META_TREE_NO_DIV_COLUMN, &no_division,
                         -1 );
@@ -616,7 +632,7 @@
 
     entry_name = gtk_entry_new ();
     gtk_entry_set_text ( GTK_ENTRY ( entry_name ),
-			 gsb_data_payee_get_name(payee_number,
+                        gsb_data_payee_get_name(payee_number,
                         TRUE));
     gtk_widget_set_size_request ( entry_name, 400, -1 );
     gtk_table_attach ( GTK_TABLE(table), entry_name, 1, 2, 0, 1, GTK_EXPAND|GTK_FILL, 0, 0, 0 );
@@ -641,41 +657,42 @@
 
     while ( 1 )
     {
-	if ( gtk_dialog_run ( GTK_DIALOG(dialog) ) != GTK_RESPONSE_OK )
-	{
-        sortie_edit_payee = TRUE;
-	    gtk_widget_destroy ( GTK_WIDGET ( dialog ) );
-        g_free ( title );
-        g_free ( old_payee );
+        if ( gtk_dialog_run ( GTK_DIALOG(dialog) ) != GTK_RESPONSE_OK )
+        {
+            sortie_edit_payee = TRUE;
+            gtk_widget_destroy ( GTK_WIDGET ( dialog ) );
+            g_free ( title );
+            g_free ( old_payee );
 
-	    return FALSE;
-	}
+            return FALSE;
+        }
 
-	if ( ! gsb_data_payee_get_number_by_name ( gtk_entry_get_text ( GTK_ENTRY ( entry_name ) ),
-                        FALSE ) ||
-	     gsb_data_payee_get_number_by_name ( gtk_entry_get_text ( GTK_ENTRY ( entry_name ) ),
-                        FALSE ) == payee_number )
-	{
-	    gsb_data_payee_set_name ( payee_number,
+        if ( ! gsb_data_payee_get_number_by_name ( gtk_entry_get_text (
+         GTK_ENTRY ( entry_name ) ), FALSE )
+         ||
+         gsb_data_payee_get_number_by_name ( gtk_entry_get_text (
+         GTK_ENTRY ( entry_name ) ), FALSE ) == payee_number )
+        {
+            gsb_data_payee_set_name ( payee_number,
                         gtk_entry_get_text ( GTK_ENTRY (entry_name)));
 	    break;
 	}
-	else
-	{
-	    gchar * message;
+        else
+        {
+            gchar *message;
 
-	    message = g_strdup_printf ( _("You tried to rename current payee to '%s' "
-                        "but this payee already exists.  Please "
-                        "choose another name."),
-                        gtk_entry_get_text ( GTK_ENTRY ( entry_name ) ) );
-	    dialogue_warning_hint ( message, _("Payee already exists") );
-	    g_free ( message );
-	}
+            message = g_strdup_printf ( _("You tried to rename current payee to '%s' "
+                            "but this payee already exists.  Please "
+                            "choose another name."),
+                            gtk_entry_get_text ( GTK_ENTRY ( entry_name ) ) );
+            dialogue_warning_hint ( message, _("Payee already exists") );
+            g_free ( message );
+        }
     }
 
     /* get the description */
     gsb_data_payee_set_description ( payee_number,
-				     gsb_editable_text_view_get_content ( entry_description ));
+                        gsb_editable_text_view_get_content ( entry_description ));
 
     gtk_widget_destroy ( dialog );
 
@@ -684,7 +701,14 @@
                         div_iter, payee_number );
     payee_tree_update_transactions ( model, payee_interface,
                         div_iter, payee_number, old_payee );
-    gtk_tree_selection_select_iter ( selection, div_iter );
+
+    /* et on centre l'affichage dessus */
+    div_iter = get_iter_from_div ( model, payee_number, 0 );
+    path = gtk_tree_model_get_path ( GTK_TREE_MODEL ( model ), div_iter );
+    gtk_tree_selection_select_iter (selection, div_iter);
+    gtk_tree_view_scroll_to_cell ( GTK_TREE_VIEW (payee_tree), path, NULL, TRUE, 0.5, 0.5 );
+    gtk_tree_path_free ( path );
+
     gtk_widget_grab_focus ( GTK_WIDGET ( view ) );
     gtk_tree_iter_free (div_iter);
     g_free ( title );
@@ -783,41 +807,41 @@
     devel_debug ( "PAGE 1" );
 
     assistant = gsb_assistant_new ( _("Manage the payees"),
-				    _("This wizard will help you to simplify the list of payees.\n\n"
-                    "Warning the changes you will make be irreparable.\n\n"
-                    "It is better to make a backup of your Grisbi file if you have not yet done. "),
-				    "payeeslg.png",
-				    NULL );
+                        _("This wizard will help you to simplify the list of payees.\n\n"
+                        "Warning the changes you will make be irreparable.\n\n"
+                        "It is better to make a backup of your Grisbi file if you have not yet done. "),
+                        "payeeslg.png",
+                        NULL );
 
     gsb_assistant_add_page ( assistant,
-			     gsb_assistant_payees_page_2 (assistant),
-			     PAYEES_ASSISTANT_PAGE_2,
-			     PAYEES_ASSISTANT_INTRO,
-			     PAYEES_ASSISTANT_PAGE_3,
-			     G_CALLBACK (gsb_assistant_payees_enter_page_2) );
+                        gsb_assistant_payees_page_2 ( assistant ),
+                        PAYEES_ASSISTANT_PAGE_2,
+                        PAYEES_ASSISTANT_INTRO,
+                        PAYEES_ASSISTANT_PAGE_3,
+                            G_CALLBACK ( gsb_assistant_payees_enter_page_2 ) );
 
     gsb_assistant_add_page ( assistant,
-			     gsb_assistant_payees_page_3 (assistant),
-			     PAYEES_ASSISTANT_PAGE_3,
-			     PAYEES_ASSISTANT_PAGE_2,
-			     PAYEES_ASSISTANT_PAGE_FINISH,
-			     G_CALLBACK (gsb_assistant_payees_enter_page_3 ) );
+                        gsb_assistant_payees_page_3 ( assistant ),
+                    PAYEES_ASSISTANT_PAGE_3,
+                    PAYEES_ASSISTANT_PAGE_2,
+                    PAYEES_ASSISTANT_PAGE_FINISH,
+                    G_CALLBACK ( gsb_assistant_payees_enter_page_3 ) );
 
     gsb_assistant_add_page ( assistant,
-			     gsb_assistant_payees_page_finish (assistant),
-			     PAYEES_ASSISTANT_PAGE_FINISH,
-			     PAYEES_ASSISTANT_PAGE_3,
-			     0,
-			     G_CALLBACK (gsb_assistant_payees_enter_page_finish) );
+                    gsb_assistant_payees_page_finish ( assistant ),
+                    PAYEES_ASSISTANT_PAGE_FINISH,
+                    PAYEES_ASSISTANT_PAGE_3,
+                    0,
+                    G_CALLBACK ( gsb_assistant_payees_enter_page_finish) );
 
-    return_value = gsb_assistant_run (assistant);
+    return_value = gsb_assistant_run ( assistant );
 
-    if (return_value == GTK_RESPONSE_APPLY)
+    if ( return_value == GTK_RESPONSE_APPLY )
     {
-        GSList *tmp_list;
         GSList *sup_payees;
+        GSList *tmp_list;
         GtkTreeSelection *selection;
-        GtkTreeIter iter;
+        GtkTreeIter *iter;
         GtkTreePath *path = NULL;
         GtkComboFix *combo;
         const gchar *str_cherche;
@@ -826,15 +850,19 @@
         gint nb_removed;
         gboolean save_notes = FALSE;
         gboolean extract_num = FALSE;
-        gboolean valid = FALSE;
         struct struct_payee_asso *assoc;
 
         /* on remplace les anciens tiers par le nouveau et on sauvegarde si nécessaire */
         gsb_status_wait ( TRUE );
+
         sup_payees = g_object_get_data ( G_OBJECT (assistant), "sup_payees" );
-        new_payee_number = gsb_data_payee_get_number_by_name (
+        if ( (nb_removed = g_slist_length ( sup_payees ) ) == 1 )
+            new_payee_number = GPOINTER_TO_INT ( sup_payees -> data );
+        else
+            new_payee_number = gsb_data_payee_get_number_by_name (
                         gtk_entry_get_text ( g_object_get_data (
                         G_OBJECT (assistant), "new_payee") ), TRUE );
+
         /* on sauvegarde la chaine de recherche */
         combo = g_object_get_data ( G_OBJECT (assistant), "payee");
         str_cherche = gtk_combofix_get_text ( combo );
@@ -847,129 +875,88 @@
                         "check_option_2" ) ) );
 
         /* on ajoute la nouvelle association à la liste des assoc */
-        assoc = g_malloc ( sizeof (struct struct_payee_asso) );
-        assoc -> payee_number = new_payee_number;
-        assoc -> search_str = g_strdup ( str_cherche );
-        if ( ! g_slist_find_custom (liste_associations_tiers,
-                        assoc,
-                        (GCompareFunc) gsb_import_associations_cmp_assoc) )
+        if ( nb_removed > 1 )
         {
-            liste_associations_tiers = g_slist_insert_sorted (
+            assoc = g_malloc ( sizeof ( struct struct_payee_asso ) );
+            assoc -> payee_number = new_payee_number;
+            assoc -> search_str = g_strdup ( str_cherche );
+            if ( !g_slist_find_custom ( liste_associations_tiers,
+                        assoc,
+                        (GCompareFunc) gsb_import_associations_cmp_assoc ) )
+            {
+                liste_associations_tiers = g_slist_insert_sorted (
                         liste_associations_tiers,
                         assoc,
-                        (GCompareFunc) gsb_import_associations_cmp_assoc);
-        }
-        tmp_list = gsb_data_transaction_get_complete_transactions_list ( );
+                        (GCompareFunc) gsb_import_associations_cmp_assoc );
+            }
 
-        while (tmp_list)
-        {
-            gint payee_number;
-            gint transaction_number;
-            gchar *nombre;
+            tmp_list = gsb_data_transaction_get_complete_transactions_list ( );
+            while ( tmp_list )
+            {
+                gint transaction_number;
 
-            transaction_number =
-                        gsb_data_transaction_get_transaction_number (
+                transaction_number = gsb_data_transaction_get_transaction_number (
                         tmp_list -> data );
-            payee_number = gsb_data_transaction_get_party_number (
-                        transaction_number );
-            if ( g_slist_find (sup_payees, GINT_TO_POINTER (payee_number)))
-            {
-                gsb_data_transaction_set_party_number ( transaction_number,
-						new_payee_number );
-                if ( save_notes )
-                {
-                    if ( my_strcmp ( (gchar *) gsb_data_payee_get_name (
-                        payee_number, TRUE ),
-                        (gchar *) gsb_data_payee_get_name (
-                        new_payee_number, TRUE ) ) != 0 )
-                    gsb_data_transaction_set_notes ( transaction_number,
-                        gsb_data_payee_get_name ( payee_number, TRUE ) );
-                }
-                if ( extract_num )
-                {
-                    nombre = gsb_string_extract_int (
-                        gsb_data_payee_get_name ( payee_number, FALSE ) );
-                    gsb_data_transaction_set_method_of_payment_content (
-                        transaction_number, nombre );
-                    g_free ( nombre );
-                }
+                gsb_assistant_payees_modifie_operations ( sup_payees,
+                        transaction_number,
+                        new_payee_number,
+                        save_notes,
+                        extract_num,
+                        TRUE );
+                tmp_list = tmp_list -> next;
             }
-            tmp_list = tmp_list -> next;
-        }
-        transaction_list_update_element (ELEMENT_PARTY);
+            transaction_list_update_element (ELEMENT_PARTY);
 
-        /* on fait la même chose pour les opérations planifiées */
-        tmp_list = gsb_data_scheduled_get_scheduled_list ();
+            /* on fait la même chose pour les opérations planifiées */
+            tmp_list = gsb_data_scheduled_get_scheduled_list ( );
 
-        while (tmp_list)
-        {
-            gint payee_number;
-            gint scheduled_number;
-            gchar *nombre;
+            while ( tmp_list )
+            {
+                gint scheduled_number;
 
-            scheduled_number =
-                        gsb_data_scheduled_get_scheduled_number (
+                scheduled_number = gsb_data_scheduled_get_scheduled_number (
                         tmp_list -> data );
-            payee_number = gsb_data_scheduled_get_party_number (
-                        scheduled_number );
-            if ( g_slist_find (sup_payees, GINT_TO_POINTER (payee_number)))
+                gsb_assistant_payees_modifie_operations ( sup_payees,
+                        scheduled_number,
+                        new_payee_number,
+                        save_notes,
+                        extract_num,
+                        FALSE );
+                tmp_list = tmp_list -> next;
+            }
+            /* on efface les tiers inutilisés */
+            nb_removed = gsb_data_payee_remove_unused ();
+            payee_fill_tree ();
+            if ( nb_removed == 1 )
             {
-                gsb_data_scheduled_set_party_number ( scheduled_number,
-						new_payee_number );
-                if ( save_notes )
-                    if ( my_strcmp ( (gchar *) gsb_data_payee_get_name (
-                        payee_number, TRUE ),
-                        (gchar *) gsb_data_payee_get_name (
-                        new_payee_number, TRUE ) ) != 0 )
-                        gsb_data_scheduled_set_notes ( scheduled_number,
-                        gsb_data_payee_get_name ( payee_number, TRUE ) );
-                if ( extract_num )
-                {
-                    nombre = gsb_string_extract_int (
-                        gsb_data_payee_get_name ( payee_number, FALSE ) );
-                    gsb_data_scheduled_set_method_of_payment_content (
-                        scheduled_number, nombre );
-                }
+                tmpstr = g_strdup_printf ( _("One payee was replaced with a new one."));
             }
-            tmp_list = tmp_list -> next;
+            else
+            {
+                tmpstr = g_strdup_printf ( _("%d payees were replaced with a new one."), 
+                            nb_removed);
+            }
+            dialogue (tmpstr);
+            g_free (tmpstr);
         }
-        /* on efface les tiers inutilisés */
-        nb_removed = gsb_data_payee_remove_unused ();
-        payee_fill_tree ();
-		if ( nb_removed == 1 )
-		{
-        	tmpstr = g_strdup_printf ( _("One payee was replaced with a new one."));
-		}
-		else
-		{
-			tmpstr = g_strdup_printf ( _("%d payees were replaced with a new one."), 
-                        nb_removed);
-		}
-        dialogue (tmpstr);
-        g_free (tmpstr);
+        else
+        {
+            gsb_data_payee_set_name ( new_payee_number,
+                        gtk_entry_get_text ( g_object_get_data (
+                        G_OBJECT (assistant), "new_payee") ) );
+            payee_fill_tree ();
+        }
+
         if ( etat.modification_fichier == 0 )
             modification_fichier ( TRUE );
+
         /* On sélectionne le nouveau tiers */
-        valid = gtk_tree_model_get_iter_first ( GTK_TREE_MODEL (
-                    payee_tree_model), &iter );
-        while (valid)
-        {
-            gint payee_number;
+        iter = get_iter_from_div ( GTK_TREE_MODEL ( payee_tree_model ), new_payee_number, 0 );
+        path = gtk_tree_model_get_path ( GTK_TREE_MODEL ( payee_tree_model ), iter );
 
-            gtk_tree_model_get ( GTK_TREE_MODEL (payee_tree_model),
-                    &iter, META_TREE_POINTER_COLUMN, &payee_number, -1 );
-            if ( payee_number == new_payee_number )
-            {
-                path = gtk_tree_model_get_path ( GTK_TREE_MODEL (
-                    payee_tree_model), &iter );
-                break;
-            }
-            valid = gtk_tree_model_iter_next ( GTK_TREE_MODEL (
-                    payee_tree_model), &iter );
-        }
         /* et on centre l'affichage dessus */
         selection = gtk_tree_view_get_selection ( GTK_TREE_VIEW (payee_tree) );
-        gtk_tree_selection_select_iter (selection, &iter);
+        gtk_tree_selection_select_iter (selection, iter);
         gtk_tree_view_scroll_to_cell ( GTK_TREE_VIEW (payee_tree), path,
                         NULL, TRUE, 0.5, 0.5 );
         gtk_tree_path_free ( path );
@@ -1358,23 +1345,23 @@
     combo = g_object_get_data ( G_OBJECT (assistant), "payee");
     str_cherche = gtk_combofix_get_text ( combo );
     entry = g_object_get_data ( G_OBJECT (assistant), "new_payee");
-	if ( g_slist_length (sup_payees) == 1 )
-	{
+    if ( g_slist_length (sup_payees) == 1 )
+    {
     tmpstr = g_strdup_printf (
                         _("You are about to replace one payee which name contain %s by %s\n\n"
                         "Are you sure?"),
                         gsb_string_remplace_joker ( str_cherche, "..." ),
                         gtk_entry_get_text ( entry) );
-	}
-	else
-	{
+    }
+    else
+    {
     tmpstr = g_markup_printf_escaped (
                         _("You are about to replace %d payees whose names contain %s by %s\n\n"
                         "Are you sure?"),
                         g_slist_length (sup_payees),
                         gsb_string_remplace_joker ( str_cherche, "..." ),
                         gtk_entry_get_text ( entry) );
-	}
+    }
     label = g_object_get_data ( G_OBJECT (assistant), "finish_label" );
     gtk_label_set_markup ( label, tmpstr );
 
@@ -1605,6 +1592,64 @@
     else
         return 0;
 }
+
+
+/**
+ *
+ *
+ */
+void gsb_assistant_payees_modifie_operations ( GSList *sup_payees,
+                        gint transaction_number,
+                        gint new_payee_number,
+                        gboolean save_notes,
+                        gboolean extract_num,
+                        gboolean is_transaction )
+{
+    gchar *tmpstr;
+    gint payee_number;
+    gchar *nombre;
+    gboolean question = TRUE;
+
+    payee_number = gsb_data_mix_get_party_number ( transaction_number, is_transaction );
+    if ( g_slist_find ( sup_payees, GINT_TO_POINTER ( payee_number ) ) )
+    {
+        gsb_data_mix_set_party_number ( transaction_number,
+                new_payee_number, is_transaction );
+        if ( save_notes )
+        {
+            tmpstr = g_strdup ( gsb_data_mix_get_notes (
+                        transaction_number, is_transaction ) );
+            if ( tmpstr && strlen ( tmpstr ) )
+            {
+                overwrite_payee -> message = g_strdup_printf (
+                    _("Do you want overwrite the existing note.\n\n"
+                    "If you answer YES, the existing note will be replaced by %s."),
+                    gsb_data_payee_get_name ( payee_number, TRUE ) );
+
+                if ( question_conditional_yes_no_with_struct (
+                 overwrite_payee ) == FALSE )
+                    question = FALSE;
+                g_free ( tmpstr );
+            }
+            else 
+                question = TRUE;
+            if ( question && my_strcmp ( (gchar *) gsb_data_payee_get_name (
+                payee_number, TRUE ),
+                (gchar *) gsb_data_payee_get_name (
+                new_payee_number, TRUE ) ) != 0 )
+            gsb_data_mix_set_notes ( transaction_number,
+                gsb_data_payee_get_name ( payee_number, TRUE ), is_transaction );
+        }
+        if ( extract_num )
+        {
+            nombre = gsb_string_extract_int (
+                gsb_data_payee_get_name ( payee_number, FALSE ) );
+            gsb_data_mix_set_method_of_payment_content (
+                transaction_number, nombre, is_transaction );
+            g_free ( nombre );
+        }
+    }
+}
 /* Local Variables: */
 /* c-basic-offset: 4 */
 /* End: */

Index: utils_str.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/utils_str.c,v
retrieving revision 1.69
retrieving revision 1.70
diff -u -d -r1.69 -r1.70
--- utils_str.c	27 Sep 2009 15:30:49 -0000	1.69
+++ utils_str.c	7 Oct 2009 21:46:21 -0000	1.70
@@ -892,6 +892,34 @@
 
 
 /**
+ * uniformisation des CR+LF dans les fichiers importés
+ *
+ * \param chaine
+ *
+ * \return chaine au format unix
+ */
+gchar *gsb_string_uniform_new_line ( const gchar *chaine, gint nbre_char )
+{
+    gchar **tab_str;
+
+    if ( g_strstr_len ( chaine, nbre_char, "\r\n" ) )
+    {
+        tab_str = g_strsplit_set ( chaine, "\r", 0 );
+        return g_strjoinv ( "", tab_str );
+    }
+    else if ( g_strstr_len ( chaine, nbre_char, "\r" ) 
+     && 
+     !g_strstr_len ( chaine, nbre_char, "\n" ) )
+    {
+        tab_str = g_strsplit_set ( chaine, "\r", 0 );
+        return g_strjoinv ( "\n", tab_str );
+    }
+    else if ( g_strstr_len ( chaine, nbre_char, "\n" ) )
+        return g_strdup ( chaine );
+    else
+        return NULL;
+}
+/**
  * all the gtk_entry_set_text in grisbi should be my_gtk_entry_set_text which just
  * check if the text is not NULL, and if NULL, erase the entry
  * the original gtk function returns a warning in that case and do nothing



More information about the cvs mailing list