From: Kaj-Michael Lang Date: Fri, 10 Aug 2007 07:25:39 +0000 (+0300) Subject: Fixes X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=48ab8d12b4992f42cdafaf0f1e19e51cc525c553;p=mapper Fixes --- diff --git a/src/file.c b/src/file.c index 987122b..4db8c78 100644 --- a/src/file.c +++ b/src/file.c @@ -11,15 +11,15 @@ #include "settings.h" #include "ui-common.h" #include "hildon-wrappers.h" +#include "file.h" /** * 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; gboolean success=FALSE; #ifdef WITH_HILDON @@ -29,22 +29,24 @@ dialog = gtk_file_chooser_dialog_new("Open...", GTK_WINDOW(_window), GTK_FILE_CH GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OPEN, - GTK_RESPONSE_ACCEPT, NULL); + GTK_RESPONSE_OK, NULL); #endif -if (dir && *dir) +if (dir && *dir) { gtk_file_chooser_set_current_folder_uri(GTK_FILE_CHOOSER(dialog), *dir); +} else { + gtk_file_chooser_set_current_folder_uri(GTK_FILE_CHOOSER(dialog), g_get_home_dir()); +} if (file && *file) gtk_file_chooser_set_uri(GTK_FILE_CHOOSER(dialog), *file); -new_file=NULL; +*new_file=NULL; -r=gtk_dialog_run(GTK_DIALOG(dialog)); -if (r==GTK_RESPONSE_ACCEPT || r==GTK_RESPONSE_OK) { +if (gtk_dialog_run(GTK_DIALOG(dialog))==GTK_RESPONSE_OK) { /* Get the selected filename. */ - new_file = gtk_file_chooser_get_uri(GTK_FILE_CHOOSER(dialog)); - g_printf("file: %s\n", new_file); + *new_file = gtk_file_chooser_get_uri(GTK_FILE_CHOOSER(dialog)); + g_printf("file: %s\n", *new_file); success=TRUE; } @@ -59,7 +61,6 @@ gboolean file_save(gchar **dir, gchar **file, GnomeVFSHandle **vfs_handle) { GtkWidget *dialog; -gint r; gboolean success=FALSE; #ifdef WITH_HILDON @@ -69,18 +70,20 @@ dialog = gtk_file_chooser_dialog_new("Save...", GTK_WINDOW(_window), GTK_FILE_CH GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_SAVE, - GTK_RESPONSE_ACCEPT, NULL); + GTK_RESPONSE_OK, NULL); gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(dialog), TRUE); #endif -if (dir && *dir) +if (dir && *dir) { gtk_file_chooser_set_current_folder_uri(GTK_FILE_CHOOSER(dialog), *dir); +} else { + gtk_file_chooser_set_current_folder_uri(GTK_FILE_CHOOSER(dialog), g_get_home_dir()); +} 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) { +if (gtk_dialog_run(GTK_DIALOG(dialog))==GTK_RESPONSE_OK) { gchar *file_uri_str; GnomeVFSResult vfs_result; @@ -113,7 +116,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; } diff --git a/src/file.h b/src/file.h index f844479..00f7751 100644 --- a/src/file.h +++ b/src/file.h @@ -2,7 +2,7 @@ #define _MAPPER_FILE_H gboolean file_save(gchar **dir, gchar **file, GnomeVFSHandle **vfs); -gboolean file_open(gchar **dir, gchar **file, GnomeVFSHandle **vfs); +gboolean file_open(gchar **dir, gchar **file, gchar **new_file); gboolean open_file(gchar ** bytes_out, GnomeVFSHandle ** handle_out, gint * size_out, gchar ** dir, gchar ** file, GtkFileChooserAction chooser_action);