From: Kaj-Michael Lang Date: Fri, 27 Jul 2007 12:22:40 +0000 (+0300) Subject: Fix handling of dir and file variables X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=30f1c1d7311a141dda23529f7947307c1d214308;p=mapper Fix handling of dir and file variables --- diff --git a/src/file.c b/src/file.c index fdf4c13..017f13b 100644 --- a/src/file.c +++ b/src/file.c @@ -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; }