aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--addressbook/gui/widgets/eab-gui-util.c12
-rw-r--r--addressbook/gui/widgets/eab-gui-util.h3
-rw-r--r--calendar/gui/dialogs/Makefile.am3
-rw-r--r--calendar/gui/dialogs/cal-attachment-select-file.c162
-rw-r--r--calendar/gui/dialogs/cal-attachment-select-file.h36
-rw-r--r--calendar/gui/dialogs/comp-editor.c1
-rw-r--r--doc/reference/shell/tmpl/e-dialog-utils.sgml31
-rw-r--r--doc/reference/shell/tmpl/eshell-unused.sgml28
-rw-r--r--e-util/e-dialog-utils.c115
-rw-r--r--e-util/e-dialog-utils.h7
-rw-r--r--e-util/e-util.c60
-rw-r--r--e-util/e-util.h4
-rw-r--r--mail/e-mail-reader.c40
-rw-r--r--mail/em-utils.c76
-rw-r--r--mail/em-utils.h2
-rw-r--r--modules/addressbook/e-book-shell-view-actions.c12
-rw-r--r--modules/calendar/e-cal-shell-view-actions.c2
-rw-r--r--modules/calendar/e-cal-shell-view-memopad.c2
-rw-r--r--modules/calendar/e-cal-shell-view-taskpad.c2
-rw-r--r--modules/calendar/e-memo-shell-view-actions.c2
-rw-r--r--modules/calendar/e-task-shell-view-actions.c2
-rw-r--r--plugins/backup-restore/backup-restore.c159
-rw-r--r--plugins/itip-formatter/itip-formatter.c14
-rw-r--r--shell/e-shell-utils.c88
-rw-r--r--shell/e-shell-utils.h6
25 files changed, 254 insertions, 615 deletions
diff --git a/addressbook/gui/widgets/eab-gui-util.c b/addressbook/gui/widgets/eab-gui-util.c
index 24fce0a99a..cfdf5876fc 100644
--- a/addressbook/gui/widgets/eab-gui-util.c
+++ b/addressbook/gui/widgets/eab-gui-util.c
@@ -281,14 +281,12 @@ eab_select_source (const gchar *title, const gchar *message, const gchar *select
return source;
}
-void
-eab_suggest_filename (GtkFileChooser *file_chooser,
- GList *contact_list)
+gchar *
+eab_suggest_filename (GList *contact_list)
{
gchar *current_name = NULL;
- g_return_if_fail (GTK_IS_FILE_CHOOSER (file_chooser));
- g_return_if_fail (contact_list != NULL);
+ g_return_val_if_fail (contact_list != NULL, NULL);
if (g_list_length (contact_list) == 1) {
EContact *contact = E_CONTACT (contact_list->data);
@@ -305,9 +303,7 @@ eab_suggest_filename (GtkFileChooser *file_chooser,
if (current_name == NULL)
current_name = make_safe_filename (_("list"));
- gtk_file_chooser_set_current_name (file_chooser, current_name);
-
- g_free (current_name);
+ return current_name;
}
typedef struct ContactCopyProcess_ ContactCopyProcess;
diff --git a/addressbook/gui/widgets/eab-gui-util.h b/addressbook/gui/widgets/eab-gui-util.h
index 838343a357..7a3da96105 100644
--- a/addressbook/gui/widgets/eab-gui-util.h
+++ b/addressbook/gui/widgets/eab-gui-util.h
@@ -43,8 +43,7 @@ void eab_transfer_contacts (EBook *source,
gboolean delete_from_source,
GtkWindow *parent_window);
-void eab_suggest_filename (GtkFileChooser *file_chooser,
- GList *contact_list);
+gchar * eab_suggest_filename (GList *contact_list);
GtkWidget *eab_create_image_chooser_widget (gchar *name, gchar *string1, gchar *string2, gint int1, gint int2);
diff --git a/calendar/gui/dialogs/Makefile.am b/calendar/gui/dialogs/Makefile.am
index fb745fd9dc..d09c906b13 100644
--- a/calendar/gui/dialogs/Makefile.am
+++ b/calendar/gui/dialogs/Makefile.am
@@ -24,7 +24,6 @@ ecalendarinclude_HEADERS = \
comp-editor.h \
alarm-dialog.h \
alarm-list-dialog.h \
- cal-attachment-select-file.h \
cal-prefs-dialog.h \
calendar-setup.h \
cancel-comp.h \
@@ -59,8 +58,6 @@ libcal_dialogs_la_SOURCES = \
alarm-dialog.h \
alarm-list-dialog.c \
alarm-list-dialog.h \
- cal-attachment-select-file.c \
- cal-attachment-select-file.h \
cal-prefs-dialog.c \
cal-prefs-dialog.h \
calendar-setup.c \
diff --git a/calendar/gui/dialogs/cal-attachment-select-file.c b/calendar/gui/dialogs/cal-attachment-select-file.c
deleted file mode 100644
index b303a763ce..0000000000
--- a/calendar/gui/dialogs/cal-attachment-select-file.c
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Harish Krishnaswamy <kharish@novell.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-/* Much of this file has been shamelessly copied from the mail attachment
- * handling code, including the fixmes. Modifications/Additions that are
- * specific to the calendar component have been flagged by some comments
- * fwiw */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <gtk/gtk.h>
-
-#include <glib/gi18n.h>
-
-#include "cal-attachment-select-file.h"
-
-enum {
- SELECTOR_MODE_MULTI = (1 << 0),
- SELECTOR_MODE_SAVE = (1 << 1)
-};
-
-static GtkWidget*
-run_selector(CompEditor *editor, const gchar *title, guint32 flags, gboolean *showinline_p)
-{
- GtkWidget *selection;
- GtkWidget *showinline = NULL;
- gchar *path;
-
- path = g_object_get_data ((GObject *) editor, "attach_path");
-
- if (flags & SELECTOR_MODE_SAVE)
- selection = gtk_file_chooser_dialog_new (title,
- NULL,
- GTK_FILE_CHOOSER_ACTION_SAVE,
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- GTK_STOCK_SAVE, GTK_RESPONSE_OK,
- NULL);
- else
- selection = gtk_file_chooser_dialog_new (title,
- NULL,
- GTK_FILE_CHOOSER_ACTION_OPEN,
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- GTK_STOCK_OPEN, GTK_RESPONSE_OK,
- NULL);
-
- gtk_dialog_set_default_response (GTK_DIALOG (selection), GTK_RESPONSE_OK);
- gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (selection), FALSE);
-
- if ((flags & SELECTOR_MODE_SAVE) == 0)
- gtk_file_chooser_set_select_multiple ((GtkFileChooser *) selection, (flags & SELECTOR_MODE_MULTI));
-
- /* restore last path used */
- if (!path)
- gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (selection), g_get_home_dir ());
- else
- gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (selection), path);
-
- if (showinline_p) {
- showinline = gtk_check_button_new_with_mnemonic (_("_Suggest automatic display of attachment"));
- gtk_widget_show (showinline);
- gtk_file_chooser_set_extra_widget (GTK_FILE_CHOOSER (selection), showinline);
- }
-
- gtk_window_set_transient_for ((GtkWindow *) selection, (GtkWindow *) editor);
- gtk_window_set_wmclass ((GtkWindow *) selection, "fileselection", "Evolution:editor");
- gtk_window_set_modal ((GtkWindow *) selection, TRUE);
-
- gtk_window_set_icon_name (GTK_WINDOW (selection), "mail-message-new");
-
- if (gtk_dialog_run ((GtkDialog *) selection) == GTK_RESPONSE_OK) {
- if (showinline_p)
- *showinline_p = gtk_toggle_button_get_active ((GtkToggleButton *) showinline);
-
- path = g_path_get_dirname (gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (selection)));
-
- g_object_set_data_full ((GObject *) editor, "attach_path", g_strdup_printf ("%s/", path), g_free);
- g_free (path);
- } else {
- gtk_widget_destroy (selection);
- selection = NULL;
- }
-
- return selection;
-}
-
-/**
- * comp_editor_select_file:
- * @editor: a editor
- * @title: the title for the file selection dialog box
- * @save_mode: whether the file selection box should be shown in save mode or not
- *
- * This pops up a file selection dialog box with the given title
- * and allows the user to select a file.
- *
- * Return value: the selected filename, or %NULL if the user
- * cancelled.
- **/
-gchar *
-comp_editor_select_file (CompEditor *editor, const gchar *title, gboolean save_mode)
-{
- guint32 flags = save_mode ? SELECTOR_MODE_SAVE : SELECTOR_MODE_MULTI;
- GtkWidget *selection;
- gchar *name = NULL;
-
- selection = run_selector (editor, title, flags, NULL);
- if (selection) {
- name = g_strdup (gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (selection)));
- gtk_widget_destroy (selection);
- }
-
- return name;
-}
-
-GPtrArray *
-comp_editor_select_file_attachments (CompEditor *editor, gboolean *showinline_p)
-{
- GtkWidget *selection;
- GPtrArray *list = NULL;
-
- selection = run_selector (editor, _("Attach file(s)"), SELECTOR_MODE_MULTI, showinline_p);
-
- if (selection) {
- GSList *l, *n;
-
- if ((l = gtk_file_chooser_get_uris (GTK_FILE_CHOOSER (selection)))) {
- list = g_ptr_array_new ();
-
- while (l) {
- n = l->next;
- g_ptr_array_add (list, l->data);
- g_slist_free_1 (l);
- l = n;
- }
- }
-
- gtk_widget_destroy (selection);
- }
-
- return list;
-}
-
diff --git a/calendar/gui/dialogs/cal-attachment-select-file.h b/calendar/gui/dialogs/cal-attachment-select-file.h
deleted file mode 100644
index b69a741007..0000000000
--- a/calendar/gui/dialogs/cal-attachment-select-file.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Harish K <kharish@novell.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifndef E_MSG_COMPOSER_SELECT_FILE_H
-#define E_MSG_COMPOSER_SELECT_FILE_H
-
-#include "comp-editor.h"
-
-gchar *comp_editor_select_file (CompEditor *editor,
- const gchar *title,
- gboolean save_mode);
-
-GPtrArray *comp_editor_select_file_attachments (CompEditor *editor,
- gboolean *inline_p);
-
-#endif /* CAL_ATTACHMENT_SELECT_FILE_H */
diff --git a/calendar/gui/dialogs/comp-editor.c b/calendar/gui/dialogs/comp-editor.c
index 99dc3ea851..9de8839955 100644
--- a/calendar/gui/dialogs/comp-editor.c
+++ b/calendar/gui/dialogs/comp-editor.c
@@ -62,7 +62,6 @@
#include "comp-editor.h"
#include "comp-editor-util.h"
#include "../calendar-config-keys.h"
-#include "cal-attachment-select-file.h"
#include "widgets/misc/e-attachment-view.h"
#include "widgets/misc/e-attachment-paned.h"
diff --git a/doc/reference/shell/tmpl/e-dialog-utils.sgml b/doc/reference/shell/tmpl/e-dialog-utils.sgml
index 233bac2f49..bdc02e8882 100644
--- a/doc/reference/shell/tmpl/e-dialog-utils.sgml
+++ b/doc/reference/shell/tmpl/e-dialog-utils.sgml
@@ -28,37 +28,6 @@ Dialog Window Functions (Legacy)
@Varargs:
-<!-- ##### FUNCTION e_file_get_save_filesel ##### -->
-<para>
-
-</para>
-
-@parent:
-@title:
-@name:
-@action:
-@Returns:
-
-
-<!-- ##### FUNCTION e_file_can_save ##### -->
-<para>
-
-</para>
-
-@parent:
-@uri:
-@Returns:
-
-
-<!-- ##### FUNCTION e_file_check_local ##### -->
-<para>
-
-</para>
-
-@name:
-@Returns:
-
-
<!-- ##### FUNCTION e_dialog_editable_set ##### -->
<para>
diff --git a/doc/reference/shell/tmpl/eshell-unused.sgml b/doc/reference/shell/tmpl/eshell-unused.sgml
index d3c3dc5210..8c8bcbde7f 100644
--- a/doc/reference/shell/tmpl/eshell-unused.sgml
+++ b/doc/reference/shell/tmpl/eshell-unused.sgml
@@ -1866,6 +1866,23 @@ intelligent
@widget:
@cursor:
+<!-- ##### FUNCTION e_file_can_save ##### -->
+<para>
+
+</para>
+
+@parent:
+@uri:
+@Returns:
+
+<!-- ##### FUNCTION e_file_check_local ##### -->
+<para>
+
+</para>
+
+@name:
+@Returns:
+
<!-- ##### FUNCTION e_file_dialog_save ##### -->
<para>
@@ -1876,6 +1893,17 @@ intelligent
@fname:
@Returns:
+<!-- ##### FUNCTION e_file_get_save_filesel ##### -->
+<para>
+
+</para>
+
+@parent:
+@title:
+@name:
+@action:
+@Returns:
+
<!-- ##### FUNCTION e_shell_backend_get_filename ##### -->
<para>
diff --git a/e-util/e-dialog-utils.c b/e-util/e-dialog-utils.c
index df0d8f5129..19d9030d30 100644
--- a/e-util/e-dialog-utils.c
+++ b/e-util/e-dialog-utils.c
@@ -27,17 +27,6 @@
#include "e-dialog-utils.h"
-#include <errno.h>
-#include <unistd.h>
-#include <glib/gstdio.h>
-
-#include <gconf/gconf-client.h>
-#include <glib/gi18n.h>
-
-#include "e-util/e-util.h"
-#include "e-util/e-error.h"
-
-
/**
* e_notice:
* @parent: the dialog's parent window, or %NULL
@@ -71,107 +60,3 @@ e_notice (gpointer parent, GtkMessageType type, const gchar *format, ...)
gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog);
}
-
-/**
- * e_file_get_save_filesel:
- * @parent: parent window
- * @title: dialog title
- * @name: filename; already in a proper form (suitable for file system)
- * @action: action for dialog
- *
- * Creates a save dialog, using the saved directory from gconf. The dialog has
- * no signals connected and is not shown.
- **/
-GtkWidget *
-e_file_get_save_filesel (GtkWindow *parent,
- const gchar *title,
- const gchar *name,
- GtkFileChooserAction action)
-{
- GtkWidget *filesel;
- gchar *uri;
-
- g_return_val_if_fail (GTK_IS_WINDOW (parent), NULL);
-
- filesel = gtk_file_chooser_dialog_new (
- title, parent, action,
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- (action == GTK_FILE_CHOOSER_ACTION_OPEN) ?
- GTK_STOCK_OPEN : GTK_STOCK_SAVE, GTK_RESPONSE_OK, NULL);
- gtk_dialog_set_default_response (GTK_DIALOG (filesel), GTK_RESPONSE_OK);
- gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (filesel), FALSE);
-
- uri = e_file_get_save_path ();
-
- gtk_file_chooser_set_current_folder_uri (
- GTK_FILE_CHOOSER (filesel), uri);
-
- if (name && name[0])
- gtk_file_chooser_set_current_name (
- GTK_FILE_CHOOSER (filesel), name);
-
- g_free (uri);
-
- return filesel;
-}
-
-/**
- * e_file_can_save:
- *
- * Return TRUE if the URI can be saved to, FALSE otherwise. It checks local
- * files to see if they're regular and can be accessed. If the file exists and
- * is writable, it pops up a dialog asking the user if they want to overwrite
- * it. Returns the users choice.
- **/
-gboolean
-e_file_can_save(GtkWindow *parent, const gchar *uri)
-{
- struct stat st;
- gchar *path;
- gboolean res;
-
- if (!uri || uri[0] == 0)
- return FALSE;
-
- /* Assume remote files are writable; too costly to check */
- if (!e_file_check_local(uri))
- return TRUE;
-
- path = g_filename_from_uri (uri, NULL, NULL);
- if (!path)
- return FALSE;
-
- /* make sure we can actually save to it... */
- if (g_stat (path, &st) != -1 && !S_ISREG (st.st_mode)) {
- g_free(path);
- return FALSE;
- }
-
- res = TRUE;
- if (g_access (path, F_OK) == 0) {
- if (g_access (path, W_OK) != 0) { e_error_run(parent, "mail:no-save-path", path, g_strerror(errno), NULL);
- g_free(path);
- return FALSE;
- }
-
- res = e_error_run(parent, E_ERROR_ASK_FILE_EXISTS_OVERWRITE, path, NULL) == GTK_RESPONSE_OK;
-
- }
-
- g_free(path);
- return res;
-}
-
-gboolean
-e_file_check_local (const gchar *name)
-{
- gchar *uri;
-
- uri = g_filename_to_uri (name, NULL, NULL);
- if (uri) {
- g_free(uri);
- return TRUE;
- }
-
- return FALSE;
-}
diff --git a/e-util/e-dialog-utils.h b/e-util/e-dialog-utils.h
index 2457f1c37a..d1e8b900c0 100644
--- a/e-util/e-dialog-utils.h
+++ b/e-util/e-dialog-utils.h
@@ -29,12 +29,5 @@ void e_notice (gpointer parent,
GtkMessageType type,
const gchar *format,
...);
-GtkWidget * e_file_get_save_filesel (GtkWindow *parent,
- const gchar *title,
- const gchar *name,
- GtkFileChooserAction action);
-gboolean e_file_can_save (GtkWindow *parent,
- const gchar *uri);
-gboolean e_file_check_local (const gchar *name);
#endif /* E_DIALOG_UTILS_H */
diff --git a/e-util/e-util.c b/e-util/e-util.c
index 9ad252a37d..6a9ad6d780 100644
--- a/e-util/e-util.c
+++ b/e-util/e-util.c
@@ -1283,66 +1283,6 @@ get_font_options (void)
return font_options;
}
-/**
- * e_file_update_save_path:
- * @uri: URI to store
- * @free: If TRUE, free uri
- *
- * Save the save_dir path for evolution. If free is TRUE, uri gets freed when
- * done. Genearally, this should be called with the output of
- * gtk_file_chooser_get_current_folder_uri() The URI must be a path URI, not a
- * file URI.
- **/
-void
-e_file_update_save_path (gchar *uri, gboolean free)
-{
- GConfClient *gconf = gconf_client_get_default();
- GError *error = NULL;
-
- gconf_client_set_string(gconf, "/apps/evolution/mail/save_dir", uri, &error);
- if (error != NULL) {
- g_warning("%s (%s) %s", G_STRLOC, G_STRFUNC, error->message);
- g_clear_error(&error);
- }
- g_object_unref(gconf);
- if (free)
- g_free(uri);
-}
-
-/**
- * e_file_get_save_path:
- *
- * Return the save_dir path for evolution. If there isn't a save_dir, returns
- * the users home directory. Returns an allocated URI that should be freed by
- * the caller.
- **/
-gchar *
-e_file_get_save_path (void)
-{
- GConfClient *gconf = gconf_client_get_default();
- GError *error = NULL;
- gchar *uri;
-
- uri = gconf_client_get_string(gconf, "/apps/evolution/mail/save_dir", &error);
- if (error != NULL) {
- g_warning("%s (%s) %s", G_STRLOC, G_STRFUNC, error->message);
- g_clear_error(&error);
- }
- g_object_unref(gconf);
-
- if (uri == NULL) {
- GFile *file;
-
- file = g_file_new_for_path (g_get_home_dir ());
- if (file) {
- uri = g_file_get_uri (file);
- g_object_unref (file);
- }
- }
-
- return (uri);
-}
-
/* Evolution Locks for crash recovery */
#define LOCK_FILE ".running"
diff --git a/e-util/e-util.h b/e-util/e-util.h
index 81ca05327c..d673cfe91a 100644
--- a/e-util/e-util.h
+++ b/e-util/e-util.h
@@ -129,10 +129,6 @@ gchar * e_ascii_dtostr (gchar *buffer,
cairo_font_options_t *
get_font_options (void);
-void e_file_update_save_path (gchar *uri,
- gboolean free);
-gchar * e_file_get_save_path (void);
-
gboolean e_file_lock_create (void);
void e_file_lock_destroy (void);
gboolean e_file_lock_exists (void);
diff --git a/mail/e-mail-reader.c b/mail/e-mail-reader.c
index d77fafc448..02739f04d9 100644
--- a/mail/e-mail-reader.c
+++ b/mail/e-mail-reader.c
@@ -34,7 +34,7 @@
#include "e-util/e-charset.h"
#include "e-util/e-util.h"
#include "e-util/gconf-bridge.h"
-#include "shell/e-shell.h"
+#include "shell/e-shell-utils.h"
#include "widgets/misc/e-popup-action.h"
#include "widgets/misc/e-menu-tool-action.h"
@@ -801,18 +801,50 @@ static void
action_mail_save_as_cb (GtkAction *action,
EMailReader *reader)
{
+ EShell *shell;
+ EShellBackend *shell_backend;
MessageList *message_list;
+ CamelMessageInfo *info;
CamelFolder *folder;
- GtkWindow *window;
GPtrArray *uids;
+ GFile *file;
+ const gchar *title;
+ const gchar *suggestion;
+ gchar *uri;
message_list = e_mail_reader_get_message_list (reader);
- window = e_mail_reader_get_window (reader);
+ shell_backend = e_mail_reader_get_shell_backend (reader);
+ shell = e_shell_backend_get_shell (shell_backend);
folder = message_list->folder;
uids = message_list_get_selected (message_list);
+ g_return_if_fail (uids->len > 0);
+
+ title = ngettext ("Save Message", "Save Messages", uids->len);
+
+ /* Suggest as a filename the subject of the first message. */
+ info = camel_folder_get_message_info (folder, uids->pdata[0]);
+ if (info != NULL) {
+ suggestion = camel_message_info_subject (info);
+ camel_message_info_free (info);
+ } else
+ suggestion = NULL;
+
+ file = e_shell_run_save_dialog (shell, title, suggestion, NULL, NULL);
+
+ if (file == NULL) {
+ em_utils_uids_free (uids);
+ return;
+ }
+
+ uri = g_file_get_uri (file);
+
+ /* This eats the UID array, so do not free it. */
+ mail_save_messages (folder, uids, uri, NULL, NULL);
+
+ g_free (uri);
- em_utils_save_messages (window, folder, uids);
+ g_object_unref (file);
}
static void
diff --git a/mail/em-utils.c b/mail/em-utils.c
index 4f264955bd..ee547c4372 100644
--- a/mail/em-utils.c
+++ b/mail/em-utils.c
@@ -343,82 +343,6 @@ em_filename_make_safe (gchar *string)
}
}
-/* Saving messages... */
-
-struct _save_messages_data {
- CamelFolder *folder;
- GPtrArray *uids;
-};
-
-static void
-emu_save_messages_response(GtkWidget *filesel, gint response, struct _save_messages_data *data)
-{
- gchar *uri;
-
- if (response == GTK_RESPONSE_OK) {
- uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (filesel));
-
- if (!e_file_can_save((GtkWindow *)filesel, uri)) {
- g_free(uri);
- return;
- }
-
- e_file_update_save_path(gtk_file_chooser_get_current_folder_uri(
- GTK_FILE_CHOOSER (filesel)), TRUE);
- mail_save_messages(data->folder, data->uids, uri, NULL, NULL);
- data->uids = NULL;
- g_free(uri);
- }
-
- camel_object_unref(data->folder);
- if (data->uids)
- em_utils_uids_free(data->uids);
- g_free(data);
- gtk_widget_destroy((GtkWidget *)filesel);
-}
-
-/**
- * em_utils_save_messages:
- * @parent: parent window
- * @folder: folder containing messages to save
- * @uids: uids of messages to save
- *
- * Saves a group of messages to disk in mbox format (prompting the
- * user for filename).
- **/
-void
-em_utils_save_messages (GtkWindow *parent, CamelFolder *folder, GPtrArray *uids)
-{
- struct _save_messages_data *data;
- GtkWidget *filesel;
- gchar *filename = NULL;
- CamelMessageInfo *info = NULL;
-
- g_return_if_fail (GTK_IS_WINDOW (parent));
- g_return_if_fail (CAMEL_IS_FOLDER (folder));
- g_return_if_fail (uids != NULL);
-
- info = camel_folder_get_message_info (folder, uids->pdata[0]);
- if (info) {
- filename = g_strdup (camel_message_info_subject (info));
- e_filename_make_safe (filename);
- camel_message_info_free (info);
- }
-
- filesel = e_file_get_save_filesel (parent, _("Save Message..."), filename, GTK_FILE_CHOOSER_ACTION_SAVE);
- if (filename)
- g_free (filename);
-
- camel_object_ref(folder);
-
- data = g_malloc(sizeof(struct _save_messages_data));
- data->folder = folder;
- data->uids = uids;
-
- g_signal_connect(filesel, "response", G_CALLBACK(emu_save_messages_response), data);
- gtk_widget_show((GtkWidget *)filesel);
-}
-
/* ********************************************************************** */
/* Flag-for-Followup... */
diff --git a/mail/em-utils.h b/mail/em-utils.h
index 9bb35b1dc2..b61dce395a 100644
--- a/mail/em-utils.h
+++ b/mail/em-utils.h
@@ -52,8 +52,6 @@ void em_utils_edit_filters (GtkWidget *parent);
void em_filename_make_safe (gchar *string);
void em_utils_edit_vfolders (GtkWidget *parent);
-void em_utils_save_messages (GtkWindow *parent, CamelFolder *folder, GPtrArray *uids);
-
void em_utils_flag_for_followup (EMailReader *reader, CamelFolder *folder, GPtrArray *uids);
void em_utils_flag_for_followup_clear (GtkWindow *parent, CamelFolder *folder, GPtrArray *uids);
void em_utils_flag_for_followup_completed (GtkWindow *parent, CamelFolder *folder, GPtrArray *uids);
diff --git a/modules/addressbook/e-book-shell-view-actions.c b/modules/addressbook/e-book-shell-view-actions.c
index 6882f29e6e..0ec4eac2e6 100644
--- a/modules/addressbook/e-book-shell-view-actions.c
+++ b/modules/addressbook/e-book-shell-view-actions.c
@@ -225,9 +225,11 @@ action_address_book_save_as_cb (GtkAction *action,
if (list == NULL)
goto exit;
+ string = eab_suggest_filename (list);
file = e_shell_run_save_dialog (
- shell, _("Save as vCard"),
- (GtkCallback) eab_suggest_filename, list);
+ shell, _("Save as vCard"), string, NULL, NULL);
+ g_free (string);
+
if (file == NULL)
goto exit;
@@ -540,9 +542,11 @@ action_contact_save_as_cb (GtkAction *action,
if (list == NULL)
goto exit;
+ string = eab_suggest_filename (list);
file = e_shell_run_save_dialog (
- shell, _("Save as vCard"),
- (GtkCallback) eab_suggest_filename, list);
+ shell, _("Save as vCard"), string, NULL, NULL);
+ g_free (string);
+
if (file == NULL)
goto exit;
diff --git a/modules/calendar/e-cal-shell-view-actions.c b/modules/calendar/e-cal-shell-view-actions.c
index f3a0f209d5..d0ab20d138 100644
--- a/modules/calendar/e-cal-shell-view-actions.c
+++ b/modules/calendar/e-cal-shell-view-actions.c
@@ -1099,7 +1099,7 @@ action_event_save_as_cb (GtkAction *action,
icalcomp = event->comp_data->icalcomp;
file = e_shell_run_save_dialog (
- shell, _("Save as iCalendar"), NULL, NULL);
+ shell, _("Save as iCalendar"), NULL, NULL, NULL);
if (file == NULL)
return;
diff --git a/modules/calendar/e-cal-shell-view-memopad.c b/modules/calendar/e-cal-shell-view-memopad.c
index 88cb53ff54..d786f4701a 100644
--- a/modules/calendar/e-cal-shell-view-memopad.c
+++ b/modules/calendar/e-cal-shell-view-memopad.c
@@ -259,7 +259,7 @@ action_calendar_memopad_save_as_cb (GtkAction *action,
g_slist_free (list);
file = e_shell_run_save_dialog (
- shell, _("Save as iCalendar"), NULL, NULL);
+ shell, _("Save as iCalendar"), NULL, NULL, NULL);
if (file == NULL)
return;
diff --git a/modules/calendar/e-cal-shell-view-taskpad.c b/modules/calendar/e-cal-shell-view-taskpad.c
index 5f2fd3ad0f..a00474a572 100644
--- a/modules/calendar/e-cal-shell-view-taskpad.c
+++ b/modules/calendar/e-cal-shell-view-taskpad.c
@@ -327,7 +327,7 @@ action_calendar_taskpad_save_as_cb (GtkAction *action,
g_slist_free (list);
file = e_shell_run_save_dialog (
- shell, _("Save as iCalendar"), NULL, NULL);
+ shell, _("Save as iCalendar"), NULL, NULL, NULL);
if (file == NULL)
return;
diff --git a/modules/calendar/e-memo-shell-view-actions.c b/modules/calendar/e-memo-shell-view-actions.c
index 31f12b3962..4ffaa519e7 100644
--- a/modules/calendar/e-memo-shell-view-actions.c
+++ b/modules/calendar/e-memo-shell-view-actions.c
@@ -497,7 +497,7 @@ action_memo_save_as_cb (GtkAction *action,
g_slist_free (list);
file = e_shell_run_save_dialog (
- shell, _("Save as iCalendar"), NULL, NULL);
+ shell, _("Save as iCalendar"), NULL, NULL, NULL);
if (file == NULL)
return;
diff --git a/modules/calendar/e-task-shell-view-actions.c b/modules/calendar/e-task-shell-view-actions.c
index 282d5a3e75..07558bfa90 100644
--- a/modules/calendar/e-task-shell-view-actions.c
+++ b/modules/calendar/e-task-shell-view-actions.c
@@ -624,7 +624,7 @@ action_task_save_as_cb (GtkAction *action,
g_slist_free (list);
file = e_shell_run_save_dialog (
- shell, _("Save as iCalendar"), NULL, NULL);
+ shell, _("Save as iCalendar"), NULL, NULL, NULL);
if (file == NULL)
return;
diff --git a/plugins/backup-restore/backup-restore.c b/plugins/backup-restore/backup-restore.c
index 50db1bbf76..f02e0d8565 100644
--- a/plugins/backup-restore/backup-restore.c
+++ b/plugins/backup-restore/backup-restore.c
@@ -36,6 +36,7 @@
#include "e-util/e-error.h"
#include "e-util/e-util.h"
#include "e-util/e-dialog-utils.h"
+#include "shell/e-shell-utils.h"
#include "shell/e-shell-window.h"
gboolean e_plugin_ui_init (GtkUIManager *ui_manager,
@@ -124,118 +125,108 @@ dialog_prompt_user(GtkWindow *parent, const gchar *string, const gchar *tag, con
return mask;
}
-static gboolean
-epbr_perform_pre_backup_checks (gchar * dir)
+static void
+set_local_only (GtkFileChooser *file_chooser)
{
-#ifdef G_OS_WIN32
- return TRUE;
-#else
- return (g_access (dir, W_OK) == 0);
-#endif
+ /* XXX Has to be a local file, since the backup utility
+ * takes a filename argument, not a URI. */
+ gtk_file_chooser_set_local_only (file_chooser, TRUE);
}
static void
action_settings_backup_cb (GtkAction *action,
EShellWindow *shell_window)
{
- GtkWidget *dlg;
- GtkWidget *vbox;
- GtkWindow *parent;
- gint response;
-
- parent = GTK_WINDOW (shell_window);
-
- dlg = e_file_get_save_filesel (
- parent, _("Select name of the Evolution backup file"),
- NULL, GTK_FILE_CHOOSER_ACTION_SAVE);
-
- gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dlg), "evolution-backup.tar.gz");
+ GFile *file;
+ GFile *parent;
+ GFileInfo *file_info;
+ const gchar *attribute;
+ GError *error = NULL;
+
+ file = e_shell_run_save_dialog (
+ e_shell_window_get_shell (shell_window),
+ _("Select name of the Evolution backup file"),
+ "evolution-backup.tar.gz", (GtkCallback)
+ set_local_only, NULL);
+
+ if (file == NULL)
+ return;
- vbox = gtk_vbox_new (FALSE, 6);
- gtk_widget_show (vbox);
+ /* Make sure the parent directory can be written to. */
- response = gtk_dialog_run (GTK_DIALOG (dlg));
- if (response == GTK_RESPONSE_OK) {
- gchar *filename;
- guint32 mask;
- gchar *uri = NULL;
- gchar *dir;
+ parent = g_file_get_parent (file);
+ attribute = G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE;
- uri = gtk_file_chooser_get_current_folder_uri(GTK_FILE_CHOOSER (dlg));
- e_file_update_save_path(uri, TRUE);
+ /* XXX The query operation blocks the main loop but we
+ * know it's a local file, so let it slide for now. */
+ file_info = g_file_query_info (
+ parent, attribute, G_FILE_QUERY_INFO_NONE, NULL, &error);
- filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dlg));
- dir = gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER (dlg));
- gtk_widget_destroy (dlg);
+ g_object_unref (parent);
- if (epbr_perform_pre_backup_checks (dir)) {
+ if (error != NULL) {
+ g_warning ("%s", error->message);
+ g_error_free (error);
+ return;
+ }
- mask = dialog_prompt_user (
- parent, _("_Restart Evolution after backup"),
- "org.gnome.backup-restore:backup-confirm", NULL);
- if (mask & BR_OK)
- backup (filename, (mask & BR_START) ? TRUE: FALSE);
- } else {
- e_error_run (parent, "org.gnome.backup-restore:insufficient-permissions", NULL);
+ if (g_file_info_get_attribute_boolean (file_info, attribute)) {
+ guint32 mask;
+ gchar *path;
+
+ mask = dialog_prompt_user (
+ GTK_WINDOW (shell_window),
+ _("_Restart Evolution after backup"),
+ "org.gnome.backup-restore:backup-confirm", NULL);
+ if (mask & BR_OK) {
+ path = g_file_get_path (file);
+ backup (path, (mask & BR_START) ? TRUE: FALSE);
+ g_free (path);
}
-
- g_free (filename);
- g_free (dir);
-
- return;
+ } else {
+ e_error_run (
+ GTK_WINDOW (shell_window),
+ "org.gnome.backup-restore:insufficient-permissions", NULL);
}
- gtk_widget_destroy (dlg);
+ g_object_unref (file_info);
+ g_object_unref (file);
}
static void
action_settings_restore_cb (GtkAction *action,
EShellWindow *shell_window)
{
- GtkWidget *dlg;
- GtkWidget *vbox;
- GtkWindow *parent;
- gint response;
-
- parent = GTK_WINDOW (shell_window);
+ GFile *file;
+ gchar *path;
- dlg = e_file_get_save_filesel (
- parent,
+ file = e_shell_run_open_dialog (
+ e_shell_window_get_shell (shell_window),
_("Select name of the Evolution backup file to restore"),
- NULL, GTK_FILE_CHOOSER_ACTION_OPEN);
-
- vbox = gtk_vbox_new (FALSE, 6);
- gtk_widget_show (vbox);
-
- response = gtk_dialog_run (GTK_DIALOG (dlg));
- if (response == GTK_RESPONSE_OK) {
- gchar *filename;
- gchar *uri = NULL;
-
- uri = gtk_file_chooser_get_current_folder_uri(GTK_FILE_CHOOSER (dlg));
- e_file_update_save_path(uri, TRUE);
+ (GtkCallback) set_local_only, NULL);
- filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dlg));
- gtk_widget_destroy (dlg);
-
- if (sanity_check (filename)) {
- guint32 mask;
+ if (file == NULL)
+ return;
- mask = dialog_prompt_user (
- parent, _("_Restart Evolution after restore"),
- "org.gnome.backup-restore:restore-confirm", NULL);
- if (mask & BR_OK)
- restore (filename, mask & BR_START);
- } else {
- e_error_run (parent, "org.gnome.backup-restore:invalid-backup", NULL);
- }
+ path = g_file_get_path (file);
- g_free (filename);
+ if (sanity_check (path)) {
+ guint32 mask;
- return;
+ mask = dialog_prompt_user (
+ GTK_WINDOW (shell_window),
+ _("_Restart Evolution after restore"),
+ "org.gnome.backup-restore:restore-confirm", NULL);
+ if (mask & BR_OK)
+ restore (path, mask & BR_START);
+ } else {
+ e_error_run (
+ GTK_WINDOW (shell_window),
+ "org.gnome.backup-restore:invalid-backup", NULL);
}
- gtk_widget_destroy (dlg);
+ g_object_unref (file);
+ g_free (path);
}
static void
@@ -255,10 +246,6 @@ static void
file_changed (GtkFileChooser *chooser, GtkAssistant *assistant)
{
gchar *file = NULL, *prevfile = NULL;
- gchar *uri = NULL;
-
- uri = gtk_file_chooser_get_current_folder_uri (GTK_FILE_CHOOSER (chooser));
- e_file_update_save_path (uri, TRUE);
file = gtk_file_chooser_get_filename (chooser);
prevfile = g_object_get_data ((GObject *)assistant, "restore-file");
diff --git a/plugins/itip-formatter/itip-formatter.c b/plugins/itip-formatter/itip-formatter.c
index 658acc07dc..32fdf23e7d 100644
--- a/plugins/itip-formatter/itip-formatter.c
+++ b/plugins/itip-formatter/itip-formatter.c
@@ -1502,22 +1502,24 @@ save_vcalendar_cb (GtkWidget *button, struct _itip_puri *pitip)
EAttachment *attachment;
EShell *shell;
GFile *file;
+ const gchar *suggestion;
g_return_if_fail (pitip != NULL);
g_return_if_fail (pitip->vcalendar != NULL);
g_return_if_fail (pitip->part != NULL);
+ suggestion = camel_mime_part_get_filename (pitip->part);
+ if (suggestion == NULL) {
+ /* Translators: This is a default filename for a calendar. */
+ suggestion = _("calendar.ics");
+ }
+
shell = e_shell_get_default ();
file = e_shell_run_save_dialog (
- shell, _("Save Calendar"), NULL, NULL);
+ shell, _("Save Calendar"), suggestion, NULL, NULL);
if (file == NULL)
return;
- if (!camel_mime_part_get_filename (pitip->part)) {
- /* Translators: This is a default filename for a calendar. */
- camel_mime_part_set_filename (pitip->part, _("calendar.ics"));
- }
-
attachment = e_attachment_new ();
e_attachment_set_mime_part (attachment, pitip->part);
diff --git a/shell/e-shell-utils.c b/shell/e-shell-utils.c
index 9d3d6f5fb4..4d4f0fd2ea 100644
--- a/shell/e-shell-utils.c
+++ b/shell/e-shell-utils.c
@@ -24,9 +24,86 @@
#include <glib/gi18n-lib.h>
/**
+ * e_shell_run_open_dialog:
+ * @shell: an #EShell
+ * @title: file chooser dialog title
+ * @customize_func: optional dialog customization function
+ * @customize_data: optional data to pass to @customize_func
+ *
+ * Runs a #GtkFileChooserDialog in open mode with the given title and
+ * returns the selected #GFile. It automatically remembers the selected
+ * folder. If @customize_func is provided, the function is called just
+ * prior to running the dialog (the file chooser is the first argument,
+ * @customize data is the second). If the user cancels the dialog the
+ * function will return %NULL.
+ *
+ * Returns: the #GFile to open, or %NULL
+ **/
+GFile *
+e_shell_run_open_dialog (EShell *shell,
+ const gchar *title,
+ GtkCallback customize_func,
+ gpointer customize_data)
+{
+ EShellSettings *shell_settings;
+ GtkFileChooser *file_chooser;
+ GFile *chosen_file = NULL;
+ GtkWidget *dialog;
+ GtkWindow *parent;
+ const gchar *property_name;
+ gchar *uri;
+
+ g_return_val_if_fail (E_IS_SHELL (shell), NULL);
+
+ property_name = "file-chooser-folder";
+ shell_settings = e_shell_get_shell_settings (shell);
+
+ parent = e_shell_get_active_window (shell);
+
+ dialog = gtk_file_chooser_dialog_new (
+ title, parent,
+ GTK_FILE_CHOOSER_ACTION_OPEN,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL);
+
+ file_chooser = GTK_FILE_CHOOSER (dialog);
+
+ gtk_dialog_set_default_response (
+ GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT);
+
+ gtk_file_chooser_set_local_only (file_chooser, FALSE);
+
+ /* Restore the current folder from the previous file chooser. */
+ uri = e_shell_settings_get_string (shell_settings, property_name);
+ if (uri != NULL)
+ gtk_file_chooser_set_current_folder_uri (file_chooser, uri);
+ g_free (uri);
+
+ /* Allow further customizations before running the dialog. */
+ if (customize_func != NULL)
+ customize_func (dialog, customize_data);
+
+ if (gtk_dialog_run (GTK_DIALOG (dialog)) != GTK_RESPONSE_ACCEPT)
+ goto exit;
+
+ chosen_file = gtk_file_chooser_get_file (file_chooser);
+
+ /* Save the current folder for subsequent file choosers. */
+ uri = gtk_file_chooser_get_current_folder_uri (file_chooser);
+ e_shell_settings_set_string (shell_settings, property_name, uri);
+ g_free (uri);
+
+exit:
+ gtk_widget_destroy (dialog);
+
+ return chosen_file;
+}
+
+/**
* e_shell_run_save_dialog:
* @shell: an #EShell
* @title: file chooser dialog title
+ * @suggestion: file name suggestion, or %NULL
* @customize_func: optional dialog customization function
* @customize_data: optional data to pass to @customize_func
*
@@ -42,6 +119,7 @@
GFile *
e_shell_run_save_dialog (EShell *shell,
const gchar *title,
+ const gchar *suggestion,
GtkCallback customize_func,
gpointer customize_data)
{
@@ -64,11 +142,12 @@ e_shell_run_save_dialog (EShell *shell,
title, parent,
GTK_FILE_CHOOSER_ACTION_SAVE,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- GTK_STOCK_SAVE, GTK_RESPONSE_OK, NULL);
+ GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, NULL);
file_chooser = GTK_FILE_CHOOSER (dialog);
- gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
+ gtk_dialog_set_default_response (
+ GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT);
gtk_file_chooser_set_local_only (file_chooser, FALSE);
gtk_file_chooser_set_do_overwrite_confirmation (file_chooser, TRUE);
@@ -79,11 +158,14 @@ e_shell_run_save_dialog (EShell *shell,
gtk_file_chooser_set_current_folder_uri (file_chooser, uri);
g_free (uri);
+ if (suggestion != NULL)
+ gtk_file_chooser_set_current_name (file_chooser, suggestion);
+
/* Allow further customizations before running the dialog. */
if (customize_func != NULL)
customize_func (dialog, customize_data);
- if (gtk_dialog_run (GTK_DIALOG (dialog)) != GTK_RESPONSE_OK)
+ if (gtk_dialog_run (GTK_DIALOG (dialog)) != GTK_RESPONSE_ACCEPT)
goto exit;
chosen_file = gtk_file_chooser_get_file (file_chooser);
diff --git a/shell/e-shell-utils.h b/shell/e-shell-utils.h
index 6fedca8a4a..24ca617369 100644
--- a/shell/e-shell-utils.h
+++ b/shell/e-shell-utils.h
@@ -32,8 +32,14 @@
G_BEGIN_DECLS
+GFile * e_shell_run_open_dialog (EShell *shell,
+ const gchar *title,
+ GtkCallback customize_func,
+ gpointer customize_data);
+
GFile * e_shell_run_save_dialog (EShell *shell,
const gchar *title,
+ const gchar *suggestion,
GtkCallback customize_func,
gpointer customize_data);