#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
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;
}
file_save(gchar **dir, gchar **file, GnomeVFSHandle **vfs_handle)
{
GtkWidget *dialog;
-gint r;
gboolean success=FALSE;
#ifdef WITH_HILDON
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;
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;
}
#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);