diff options
author | Srinivasa Ragavan <sragavan@src.gnome.org> | 2006-05-25 14:04:48 +0800 |
---|---|---|
committer | Srinivasa Ragavan <sragavan@src.gnome.org> | 2006-05-25 14:04:48 +0800 |
commit | 24368cf92dd5eaae1b41b3f191a25e2cbc45e824 (patch) | |
tree | f250be111bc4afa6440414ada53ff051bb30ff0d /e-util | |
parent | 0fdf8a120ccb5638527293f6155d0e16af571732 (diff) | |
download | gsoc2013-evolution-24368cf92dd5eaae1b41b3f191a25e2cbc45e824.tar.gz gsoc2013-evolution-24368cf92dd5eaae1b41b3f191a25e2cbc45e824.tar.zst gsoc2013-evolution-24368cf92dd5eaae1b41b3f191a25e2cbc45e824.zip |
Added code to save/attach files/mails/events to/from remote shares
svn path=/trunk/; revision=32023
Diffstat (limited to 'e-util')
-rw-r--r-- | e-util/ChangeLog | 9 | ||||
-rw-r--r-- | e-util/e-dialog-utils.c | 12 | ||||
-rw-r--r-- | e-util/e-util.c | 30 | ||||
-rw-r--r-- | e-util/e-util.h | 2 |
4 files changed, 50 insertions, 3 deletions
diff --git a/e-util/ChangeLog b/e-util/ChangeLog index c4feb62919..3f7f44ce75 100644 --- a/e-util/ChangeLog +++ b/e-util/ChangeLog @@ -1,3 +1,12 @@ +2006-05-25 Srinivasa Ragavan <sragavan@novell.com> + + * e-dialog-utils.c: (save_ok), (e_file_dialog_save), + (save_folder_ok), (e_file_dialog_save_folder): Added code + to enable file chooser to work with remote shares + * e-util.c: (e_write_file), (e_write_file_uri): Added + a new api to write to remote shares. + * e-util.h: + 2006-04-26 Li Yuan <li.yuan@sun.com> * e-text-event-processor-emacs-like.c: diff --git a/e-util/e-dialog-utils.c b/e-util/e-dialog-utils.c index 63353a723e..44c5c24194 100644 --- a/e-util/e-dialog-utils.c +++ b/e-util/e-dialog-utils.c @@ -260,6 +260,7 @@ save_ok (GtkWidget *widget, gpointer data) { GtkWidget *fs; char **filename = data; + char *uri; const char *path; int btn = GTK_RESPONSE_YES; GConfClient *gconf = gconf_client_get_default(); @@ -268,6 +269,7 @@ save_ok (GtkWidget *widget, gpointer data) fs = gtk_widget_get_toplevel (widget); #ifdef USE_GTKFILECHOOSER path = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (fs)); + uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (fs)); #else path = gtk_file_selection_get_filename (GTK_FILE_SELECTION (fs)); #endif @@ -291,7 +293,7 @@ save_ok (GtkWidget *widget, gpointer data) dir = g_path_get_dirname (path); gconf_client_set_string(gconf, "/apps/evolution/mail/save_dir", dir, NULL); g_free (dir); - *filename = g_strdup (path); + *filename = uri; } g_object_unref(gconf); @@ -333,7 +335,8 @@ e_file_dialog_save (const char *title, const char *fname) NULL); gtk_dialog_set_default_response (GTK_DIALOG (selection), GTK_RESPONSE_ACCEPT); gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (selection), dir); - + gtk_file_chooser_set_local_only (selection, FALSE); + if (fname) gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER (selection), fname); @@ -365,19 +368,21 @@ save_folder_ok (GtkWidget *widget, gpointer data) { GtkWidget *fs; char **filename = data; + char *uri; const char *path; GConfClient *gconf = gconf_client_get_default(); fs = gtk_widget_get_toplevel (widget); #ifdef USE_GTKFILECHOOSER path = gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER (fs)); + uri = gtk_file_chooser_get_current_folder_uri (GTK_FILE_CHOOSER (fs)); #else path = gtk_file_selection_get_filename (GTK_FILE_SELECTION (fs)); #endif gconf_client_set_string(gconf, "/apps/evolution/mail/save_dir", path, NULL); g_object_unref(gconf); - *filename = g_strdup (path); + *filename = uri; gtk_main_quit (); } @@ -419,6 +424,7 @@ e_file_dialog_save_folder (const char *title) GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, NULL); gtk_dialog_set_default_response (GTK_DIALOG (selection), GTK_RESPONSE_ACCEPT); + gtk_file_chooser_set_local_only (selection, FALSE); gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (selection), dir); g_signal_connect (G_OBJECT (selection), "response", G_CALLBACK (folderchooser_response), &filename); diff --git a/e-util/e-util.c b/e-util/e-util.c index 73a1842919..bfafdc8771 100644 --- a/e-util/e-util.c +++ b/e-util/e-util.c @@ -39,6 +39,7 @@ #include <glib/gstdio.h> #include <gtk/gtk.h> #include <libgnome/gnome-util.h> +#include <libgnomevfs/gnome-vfs.h> #ifdef G_OS_WIN32 #include <windows.h> @@ -239,6 +240,35 @@ e_write_file(const char *filename, const char *data, int flags) } gint +e_write_file_uri (const char *filename, const char *data) +{ + guint64 length = strlen(data); + guint64 bytes; + GnomeVFSResult result; + GnomeVFSHandle *handle = NULL; + + result = gnome_vfs_create (&handle, filename, GNOME_VFS_OPEN_WRITE, TRUE, 0755); + if (result != GNOME_VFS_OK) { + g_warning ("Couldn't save item"); + return 1; + } + + while (length > 0) { + gnome_vfs_write(handle, data, length, &bytes); + if (bytes > 0) { + length -= bytes; + data += bytes; + } else { + gnome_vfs_close(handle); + return 1; + } + } + + gnome_vfs_close (handle); + return 0; +} + +gint e_write_file_mkstemp(char *filename, const char *data) { int fd; diff --git a/e-util/e-util.h b/e-util/e-util.h index b80915f8f0..559a1a1ee7 100644 --- a/e-util/e-util.h +++ b/e-util/e-util.h @@ -154,6 +154,8 @@ char *e_read_file (cons int e_write_file (const char *filename, const char *data, int flags); +int e_write_file_uri (const char *filename, + const char *data); int e_write_file_mkstemp (char *filename, const char *data); |