]> err.no Git - mapper/commitdiff
Fix handling of dir and file variables
authorKaj-Michael Lang <milang@angel.tal.org>
Fri, 27 Jul 2007 12:22:40 +0000 (15:22 +0300)
committerKaj-Michael Lang <milang@angel.tal.org>
Fri, 27 Jul 2007 12:22:40 +0000 (15:22 +0300)
src/file.c

index fdf4c1300ed461011940970e8415bb3d58083c18..017f13b56b9054f819922ef7eabe48df22accbf7 100644 (file)
@@ -15,7 +15,7 @@
  * Open a file for reading.
  */
 gboolean
-file_open(gchar *dir, gchar *file, gchar *new_file)
+file_open(gchar **dir, gchar **file, gchar *new_file)
 {
 GtkWidget *dialog;
 gint r;
@@ -31,11 +31,11 @@ dialog = gtk_file_chooser_dialog_new("Open...", GTK_WINDOW(_window), GTK_FILE_CH
                                                     GTK_RESPONSE_ACCEPT, NULL);
 #endif
 
-if (dir)
-       gtk_file_chooser_set_current_folder_uri(GTK_FILE_CHOOSER(dialog), dir);
+if (dir && *dir)
+       gtk_file_chooser_set_current_folder_uri(GTK_FILE_CHOOSER(dialog), *dir);
 
-if (file)
-       gtk_file_chooser_set_uri(GTK_FILE_CHOOSER(dialog), file);
+if (file && *file)
+       gtk_file_chooser_set_uri(GTK_FILE_CHOOSER(dialog), *file);
 
 new_file=NULL;
 
@@ -55,7 +55,7 @@ return success;
  * Open a file for writing. Return a GnomeVFSHandle to the file for writing.
  */
 gboolean
-file_save(gchar *dir, gchar *file, GnomeVFSHandle **vfs_handle)
+file_save(gchar **dir, gchar **file, GnomeVFSHandle **vfs_handle)
 {
 GtkWidget *dialog;
 gint r;
@@ -72,11 +72,11 @@ dialog = gtk_file_chooser_dialog_new("Save...", GTK_WINDOW(_window), GTK_FILE_CH
 gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(dialog), TRUE);
 #endif
 
-if (dir)
-       gtk_file_chooser_set_current_folder_uri(GTK_FILE_CHOOSER(dialog), dir);
+if (dir && *dir)
+       gtk_file_chooser_set_current_folder_uri(GTK_FILE_CHOOSER(dialog), *dir);
 
-if (file)
-       gtk_file_chooser_set_uri(GTK_FILE_CHOOSER(dialog), file);
+if (file && *file)
+       gtk_file_chooser_set_uri(GTK_FILE_CHOOSER(dialog), *file);
 
 r=gtk_dialog_run(GTK_DIALOG(dialog));
 if (r==GTK_RESPONSE_ACCEPT || r==GTK_RESPONSE_OK) {
@@ -91,12 +91,12 @@ if (r==GTK_RESPONSE_ACCEPT || r==GTK_RESPONSE_OK) {
                success=FALSE;
        } else {
                if (dir) {
-                       g_free(dir);
-                       dir = gtk_file_chooser_get_current_folder_uri(GTK_FILE_CHOOSER(dialog));
+                       g_free(*dir);
+                       *dir = gtk_file_chooser_get_current_folder_uri(GTK_FILE_CHOOSER(dialog));
                }
                if (file) {
-                       g_free(file);
-                       file = gtk_file_chooser_get_uri(GTK_FILE_CHOOSER(dialog));
+                       g_free(*file);
+                       *file = gtk_file_chooser_get_uri(GTK_FILE_CHOOSER(dialog));
                }
                success=TRUE;
        }
@@ -112,7 +112,7 @@ file_open_get_content(gchar *file, gchar *dir, gchar **buffer, guint *bytes)
 gchar *file_uri_str;
 GnomeVFSResult vfs_result;
 
-if (!file_open(file,dir, file_uri_str)) {
+if (!file_open(&file,&dir,file_uri_str)) {
        buffer=NULL;
        return TRUE;
 }