]> err.no Git - mapper/commitdiff
Fixes
authorKaj-Michael Lang <milang@angel.tal.org>
Fri, 10 Aug 2007 07:25:39 +0000 (10:25 +0300)
committerKaj-Michael Lang <milang@angel.tal.org>
Fri, 10 Aug 2007 07:25:39 +0000 (10:25 +0300)
src/file.c
src/file.h

index 987122b1af28dfaa614c6f09cd2ba80f0d582687..4db8c78414d33e3f780173ff925c360349f54f09 100644 (file)
 #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;
 }
index f8444799f13c16115879a6721613c8e98acb0f45..00f77513d49ba5c5cce41f77ac6cc8c7a2421dd2 100644 (file)
@@ -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);