[grisbi-cvs] [SCM] grisbi branch, master, updated. upstream_version_0_9.0-43-g53ce5e7

Pierre Biava nobody at users.sourceforge.net
Sun Mar 6 11:02:14 CET 2011


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

The branch, master has been updated
       via  53ce5e7a2ec2b16cf9ab81785a9a527c352298af (commit)
      from  39a102e6cf669dc92f1abc614ac76295599c04fe (commit)

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

- Log -----------------------------------------------------------------
commit 53ce5e7a2ec2b16cf9ab81785a9a527c352298af
Author: pbiava <pierre.biava at nerim.net>
Date:   Sun Mar 6 09:36:52 2011 +0100

    Fixed a bug export csv files on Windows

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

Changes:
diff --git a/src/etats_csv.c b/src/etats_csv.c
index 86cb6ac..101f512 100644
--- a/src/etats_csv.c
+++ b/src/etats_csv.c
@@ -26,6 +26,7 @@
 #endif
 
 #include "include.h"
+#include <errno.h>
 #include <glib/gstdio.h>
 #include <glib/gi18n.h>
 
@@ -155,20 +156,29 @@ void csv_attach_hsep ( gint x, gint x2, gint y, gint y2)
  */
 gint csv_initialise (GSList * opes_selectionnees, gchar * filename )
 {
+
     g_return_val_if_fail ( filename, FALSE );
+
    /* initialise values */
     csv_lastcol = 0;
     csv_lastline = 1;
 
-    g_unlink ( filename );	/* We don't care if this fails, this
-				 * is just to guarantee next will
-				 * not fail if file is existing.  This
-				 * will help against file races. */
-    csv_out = utf8_fopen ( filename, "w+x" );
+    /* on efface le fichier s'il existe déjà */
+    if ( g_file_test ( filename, G_FILE_TEST_IS_REGULAR ) )
+        g_unlink ( filename );
+
+    csv_out = utf8_fopen ( filename, "w" );
     if ( ! csv_out )
     {
-	dialogue_error ( g_strdup_printf (_("Unable to open file '%s'"), filename ));
-	return FALSE;
+        gchar *sMessage = NULL;
+
+        sMessage = g_strdup_printf ( _("Unable to create file \"%s\" :\n%s"),
+                         filename, g_strerror ( errno ) );
+        dialogue ( sMessage );
+
+        g_free ( sMessage );
+
+        return FALSE;
     }
 
     return TRUE;
diff --git a/src/export_csv.c b/src/export_csv.c
index 9eda479..b550092 100644
--- a/src/export_csv.c
+++ b/src/export_csv.c
@@ -399,16 +399,20 @@ gboolean gsb_csv_export_archive ( const gchar *filename, gint archive_number )
 static FILE *gsb_csv_export_open_file ( const gchar *filename )
 {
     FILE *csv_file;
-    gchar *sMessage = NULL;
 
-    /* Ouverture du fichier, si pb, on marque l'erreur et passe au fichier suivant */
-    if ( !( csv_file = utf8_fopen ( filename, "w" ) ))
+    /* Création du fichier, si pb, on marque l'erreur et passe au fichier suivant */
+    csv_file = utf8_fopen ( filename, "w" );
+    if ( ! csv_file )
     {
-	sMessage = g_strdup_printf ( _("Error opening file \"%s\" :\n%s"),
-				     filename, g_strerror ( errno ) );
-	dialogue ( sMessage );
-	g_free ( sMessage );
-	return NULL;
+        gchar *sMessage = NULL;
+
+        sMessage = g_strdup_printf ( _("Unable to create file \"%s\" :\n%s"),
+                         filename, g_strerror ( errno ) );
+        dialogue ( sMessage );
+
+        g_free ( sMessage );
+
+        return NULL;
     }
 
     return csv_file;
diff --git a/src/plugins/gnucash/gnucash.c b/src/plugins/gnucash/gnucash.c
index a7d5a70..268e47e 100644
--- a/src/plugins/gnucash/gnucash.c
+++ b/src/plugins/gnucash/gnucash.c
@@ -612,11 +612,22 @@ xmlDocPtr parse_gnucash_file ( gchar * filename )
   }
 
   tempname = g_strdup_printf ( "gsbgnc%05d", g_random_int_range (0,99999) );
-  tempfile = utf8_fopen ( tempname, "w+x" );
+  tempfile = utf8_fopen ( tempname, "w" );
   if ( ! tempfile )
   {
-      dialogue_error_hint ( _("Grisbi needs to open a temporary file in order to import Gnucash data but file can't be created.  Check that you have permission to do that."),
-			    g_strdup_printf ( _("Error opening temporary file '%s'." ), tempname ) );
+    gchar *tmp_str;
+    gchar *tmp_str_2;
+
+    tmp_str = g_strdup ( _("Grisbi needs to open a temporary file in order to import Gnucash data "
+                        "but file can't be created.\n"
+                        "Check that you have permission to do that.") );
+    tmp_str_2 = g_strdup_printf ( _("Error opening temporary file '%s'." ), tempname );
+
+    dialogue_error_hint ( tmp_str, tmp_str_2 );
+
+    g_free ( tmp_str );
+    g_free ( tmp_str_2 );
+
       return NULL;
   }
 
diff --git a/src/utils_files.c b/src/utils_files.c
index d16c0e0..6c4066f 100644
--- a/src/utils_files.c
+++ b/src/utils_files.c
@@ -363,31 +363,6 @@ gint get_utf8_line_from_file ( FILE *fichier,
 
 
 /**
- * Make a GtkEntry that will contain a file name, a GtkButton that
- * will pop up a file selector, pack them in a GtkHbox and return it.
- *
- * \return A newly created GtkHbox.
- */
-GtkWidget * my_file_chooser ()
-{
-    GtkWidget * hbox, *entry, *button;
-
-    hbox = gtk_hbox_new ( FALSE, 6 );
-
-    entry = gtk_entry_new ( );
-    gtk_box_pack_start ( GTK_BOX(hbox), entry, TRUE, TRUE, 0 );
-    g_object_set_data ( G_OBJECT(hbox), "entry", entry );
-
-    button = gtk_button_new_with_label ( _("Browse") );
-    gtk_box_pack_start ( GTK_BOX(hbox), button, FALSE, FALSE, 0 );
-
-    g_signal_connect ( G_OBJECT(button), "clicked",
-		       (GCallback) browse_file, entry );
-
-    return hbox;
-}
-
-/**
  * \brief utf8 version of fopen (see fopen for more detail about mode)
  * 
  * convert utf8 file path into the locale OS charset before calling fopen
@@ -397,14 +372,12 @@ GtkWidget * my_file_chooser ()
  *
  * \return file descriptor returned by fopen
  */
-G_MODULE_EXPORT FILE* utf8_fopen(const gchar* utf8filename,gchar* mode)
+G_MODULE_EXPORT FILE* utf8_fopen (const gchar *utf8filename, gchar *mode )
 {
 #ifdef _MSC_VER
-	if(!strncmp(mode, "w+x", 3))
-		mode = "w+";
-    return fopen(g_locale_from_utf8(utf8filename, -1, NULL, NULL, NULL),mode);
+    return fopen ( g_locale_from_utf8 ( utf8filename, -1, NULL, NULL, NULL ), mode );
 #else
-	return fopen(g_filename_from_utf8(utf8filename, -1, NULL, NULL, NULL),mode);
+	return fopen ( g_filename_from_utf8 ( utf8filename, -1, NULL, NULL, NULL ), mode );
 #endif
 }
 
@@ -418,12 +391,12 @@ G_MODULE_EXPORT FILE* utf8_fopen(const gchar* utf8filename,gchar* mode)
  *
  * \return remove returned value
  */
-gint utf8_remove(const gchar* utf8filename)
+gint utf8_remove ( const gchar *utf8filename )
 {
 #ifdef _MSC_VER
-    return remove(g_locale_from_utf8(utf8filename, -1, NULL, NULL, NULL));
+    return remove ( g_locale_from_utf8 ( utf8filename, -1, NULL, NULL, NULL ) );
 #else
-    return remove(g_filename_from_utf8(utf8filename,-1,NULL,NULL,NULL));
+    return remove ( g_filename_from_utf8 ( utf8filename,-1,NULL,NULL,NULL ) );
 #endif
 }
 
@@ -433,9 +406,9 @@ gint utf8_remove(const gchar* utf8filename)
  *
  * \param filename Filename to sanitize.
  */
-gchar * safe_file_name ( gchar* filename )
+gchar *safe_file_name ( gchar *filename )
 {
-    return g_strdelimit ( my_strdup(filename), G_DIR_SEPARATOR_S, '_' );
+    return g_strdelimit ( my_strdup ( filename ), G_DIR_SEPARATOR_S, '_' );
 }
 
 
@@ -446,7 +419,7 @@ gchar * safe_file_name ( gchar* filename )
  *
  * \return chooser
  */
-GtkWidget *utils_files_create_file_chooser ( GtkWidget *parent, gchar * titre )
+GtkWidget *utils_files_create_file_chooser ( GtkWidget *parent, gchar *titre )
 {
     GtkWidget *chooser;
     GtkWidget *bouton_cancel, *bouton_OK;
@@ -502,7 +475,7 @@ void utils_files_file_chooser_cancel ( GtkWidget *bouton, GtkWidget *chooser)
  *
  * \return TRUE if ok
  */
-gboolean utils_files_create_XDG_dir (void)
+gboolean utils_files_create_XDG_dir ( void )
 {
 #ifdef _MSC_VER
     int mode = 0;
diff --git a/src/utils_files.h b/src/utils_files.h
index 836e986..e0c2117 100644
--- a/src/utils_files.h
+++ b/src/utils_files.h
@@ -22,15 +22,14 @@ enum get_filename_returned_value {
 gint get_utf8_line_from_file ( FILE *fichier,
                         gchar **string,
                         const gchar *coding_system );
-GtkWidget * my_file_chooser ();
 gchar* my_get_XDG_grisbi_data_dir ( void );
-gchar* my_get_XDG_grisbirc_dir(void);
-gchar* my_get_grisbirc_dir(void);
+gchar* my_get_XDG_grisbirc_dir ( void );
+gchar* my_get_grisbirc_dir ( void );
 gchar* my_get_gsb_file_default_dir ( void );
-gchar * safe_file_name ( gchar* filename );
-G_MODULE_EXPORT FILE* utf8_fopen(const gchar* utf8filename,gchar* mode);
-gint utf8_remove(const gchar* utf8filename);
-gboolean utils_files_create_XDG_dir (void);
+gchar *safe_file_name ( gchar *filename );
+G_MODULE_EXPORT FILE* utf8_fopen ( const gchar *utf8filename, gchar *mode );
+gint utf8_remove ( const gchar *utf8filename );
+gboolean utils_files_create_XDG_dir ( void );
 GtkWidget *utils_files_create_file_chooser ( GtkWidget *parent, gchar * titre );
 gchar *utils_files_create_sel_charset ( GtkWidget *assistant,
                         const gchar *tmp_str,


hooks/post-receive
-- 
grisbi


More information about the cvs mailing list