[grisbi-cvs] grisbi/src gsb_file.c, 1.39, 1.40 gsb_file_load.c, 1.147, 1.148 gsb_form_widget.c, 1.27, 1.28

Pierre Biava pbiava at users.sourceforge.net
Sat Feb 7 21:19:17 CET 2009


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

Modified Files:
	gsb_file.c gsb_file_load.c gsb_form_widget.c 
Log Message:
Adding the backup of an old file grisbi

Index: gsb_form_widget.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/gsb_form_widget.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- gsb_form_widget.c	6 Feb 2009 22:05:04 -0000	1.27
+++ gsb_form_widget.c	7 Feb 2009 20:19:15 -0000	1.28
@@ -42,6 +42,7 @@
 #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: gsb_file.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/gsb_file.c,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -d -r1.39 -r1.40
--- gsb_file.c	25 Jan 2009 07:50:09 -0000	1.39
+++ gsb_file.c	7 Feb 2009 20:19:14 -0000	1.40
@@ -359,8 +359,9 @@
     gsb_status_message ( _("Loading accounts") );
 
     /* try to load the file */
-    /* FIXME:BUG under Windows: for unknwon reason yet filename is cleared when returning from gsb_file_load_open_file!
-       making application crashes! */
+    /* FIXME:BUG under Windows: for unknwon reason yet filename is cleared 
+     * when returning from gsb_file_load_open_file!
+     * making application crashes! */
 
     if ( gsb_file_load_open_file (filename))
     {

Index: gsb_file_load.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/gsb_file_load.c,v
retrieving revision 1.147
retrieving revision 1.148
diff -u -d -r1.147 -r1.148
--- gsb_file_load.c	24 Jan 2009 17:56:58 -0000	1.147
+++ gsb_file_load.c	7 Feb 2009 20:19:15 -0000	1.148
@@ -84,6 +84,7 @@
 static gboolean gsb_file_load_check_new_structure ( gchar *file_content );
 static void gsb_file_load_color_part ( const gchar **attribute_names,
 				const gchar **attribute_values );
+static gboolean gsb_file_load_copy_old_file ( gchar *filename );
 static void gsb_file_load_currency ( const gchar **attribute_names,
 			      const gchar **attribute_values );
 static void gsb_file_load_currency_link ( const gchar **attribute_names,
@@ -319,6 +320,10 @@
 	}
 	else
 	{
+        /* backup of an old file grisbi */
+        if ( ! gsb_file_load_copy_old_file ( filename ) )
+            return FALSE;
+
 	    /* fill the GMarkupParser for the last xml structure */
 	    markup_parser -> start_element = (void *) gsb_file_load_start_element_before_0_6;
 	    markup_parser -> end_element = (void *) gsb_file_load_end_element_before_0_6;
@@ -7648,6 +7653,41 @@
 }
 
 
+/** 
+ * save an old grisbi file 
+ *
+ * \param filename the name of the file
+ *
+ * \return TRUE : ok, FALSE : problem
+ * */
+gboolean gsb_file_load_copy_old_file ( gchar *filename )
+{
+    if ( g_str_has_suffix (filename, ".gsb" ) )
+    {
+        gchar *new_filename;
+        GFile * file_ori;
+        GFile * file_copy;
+        GError * error = NULL;
+
+        new_filename = gsb_string_remplace_string ( filename, ".gsb",
+                        "-old-version.gsb" );
+        file_ori = g_file_new_for_path ( filename );
+        file_copy = g_file_new_for_path ( new_filename );
+        if ( g_file_copy ( file_ori, file_copy, G_FILE_COPY_OVERWRITE, 
+                        NULL, NULL, NULL, &error ) )
+        {
+            gchar *tmpstr = g_strdup_printf ( 
+                        _("Your old file grisbi was saved as: \n\n%s"),
+                        basename ( new_filename ) );
+            dialogue ( tmpstr );
+            g_free ( tmpstr );
+            return TRUE;
+        }
+        else
+            dialogue_error (error -> message );
+    }
+    return FALSE;
+}
 /* Local Variables: */
 /* c-basic-offset: 4 */
 /* End: */



More information about the cvs mailing list