aboutsummaryrefslogtreecommitdiffstats
path: root/composer/e-msg-composer.c
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2007-11-30 02:16:10 +0800
committerMilan Crha <mcrha@src.gnome.org>2007-11-30 02:16:10 +0800
commit462fdd34535c090706e59ce3ffb4aa51bc29a034 (patch)
treef185944f5bcd1141178027dcbf82b2c1ab6f2329 /composer/e-msg-composer.c
parent4bca50f1c5060efbfe2f0c9d011e4d51f1e8be0f (diff)
downloadgsoc2013-evolution-462fdd34535c090706e59ce3ffb4aa51bc29a034.tar.gz
gsoc2013-evolution-462fdd34535c090706e59ce3ffb4aa51bc29a034.tar.zst
gsoc2013-evolution-462fdd34535c090706e59ce3ffb4aa51bc29a034.zip
** Part of fix for bug #271551
2007-11-29 Milan Crha <mcrha@redhat.com> ** Part of fix for bug #271551 * mail/evolution-mail.schemas.in: New key "/apps/evolution/mail/composer/current_folder". * composer/e-msg-composer.h: (e_msg_composer_set_attach_path), (e_msg_composer_get_attach_path): * composer/e-msg-composer.c: (e_msg_composer_set_attach_path), (e_msg_composer_get_attach_path): Functions to set/get attach path to both composer and editor. * composer/e-msg-composer.c: (prepare_engine): Set last used path right after creation of the engine. * composer/e-msg-composer-select-file.c: (get_selector), (select_file_response), (select_attach_response): Using new functions. * composer/listener.c: (impl_event): Store new file path when received event about its change. * composer/e-msg-composer.c: (set_signature_gui): Leak fix. Note: update your GtkHtml to revision 8636 and above. svn path=/trunk/; revision=34613
Diffstat (limited to 'composer/e-msg-composer.c')
-rw-r--r--composer/e-msg-composer.c83
1 files changed, 83 insertions, 0 deletions
diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c
index be3f47e9c9..087e36ce39 100644
--- a/composer/e-msg-composer.c
+++ b/composer/e-msg-composer.c
@@ -86,6 +86,7 @@
#include "misc/e-expander.h"
#include "e-util/e-error.h"
#include "e-util/e-util-private.h"
+#include "e-util/e-util.h"
#include <mail/em-event.h>
#include <camel/camel-session.h>
@@ -132,6 +133,8 @@
#define GNOME_GTKHTML_EDITOR_CONTROL_ID "OAFIID:GNOME_GtkHTML_Editor:" GTKHTML_API_VERSION
+#define COMPOSER_CURRENT_FOLDER_KEY "/apps/evolution/mail/composer/current_folder"
+
#define d(x)
typedef struct _EMsgComposerPrivate EMsgComposerPrivate;
@@ -1061,6 +1064,17 @@ prepare_engine (EMsgComposer *composer)
p->eeditor_engine = CORBA_OBJECT_NIL;
g_warning ("Can't establish Editor Listener\n");
+ } else {
+ gchar *path;
+ GConfClient *gconf = gconf_client_get_default ();
+
+ path = gconf_client_get_string (gconf, COMPOSER_CURRENT_FOLDER_KEY, NULL);
+ g_object_unref (gconf);
+
+ /* change it only if we have set path before */
+ if (path && *path)
+ e_msg_composer_set_attach_path (composer, path);
+ g_free (path);
}
} else {
p->eeditor_engine = CORBA_OBJECT_NIL;
@@ -1070,6 +1084,74 @@ prepare_engine (EMsgComposer *composer)
CORBA_exception_free (&ev);
}
+/**
+ * e_msg_composer_set_attach_path
+ * Attach path is used to be preset when choosing files. This function ensures same path
+ * in editor and in composer.
+ * @param composer Composer.
+ * @param path Path to be used. Should not be NULL.
+ **/
+void
+e_msg_composer_set_attach_path (EMsgComposer *composer, const gchar *path)
+{
+ GConfClient *gconf;
+ GError *error = NULL;
+
+ g_return_if_fail (composer != NULL);
+ g_return_if_fail (path != NULL);
+
+ gconf = gconf_client_get_default ();
+ gconf_client_set_string (gconf, COMPOSER_CURRENT_FOLDER_KEY, path, &error);
+ g_object_unref (gconf);
+
+ if (error) {
+ g_warning ("Could not write current_folder setting: %s", error->message);
+ g_error_free (error);
+ }
+
+ if (composer->priv->eeditor_engine) {
+ CORBA_Environment ev;
+
+ CORBA_exception_init (&ev);
+
+ GNOME_GtkHTML_Editor_Engine_setFilePath (composer->priv->eeditor_engine, path, &ev);
+
+ CORBA_exception_free (&ev);
+ }
+
+ /* do this as last thing here, so we can do e_msg_composer_set_attach_path (composer, e_msg_composer_get_attach_path (composer)) */
+ g_object_set_data_full ((GObject *) composer, "attach_path", g_strdup (path), g_free);
+}
+
+/**
+ * e_msg_composer_get_attach_path
+ * Last path, if any, used to select file.
+ * @param composer Composer.
+ * @return Last used path, or NULL when not set yet.
+ **/
+const gchar *
+e_msg_composer_get_attach_path (EMsgComposer *composer)
+{
+ g_return_val_if_fail (composer != NULL, g_object_get_data ((GObject *) composer, "attach_path"));
+
+ if (composer->priv->eeditor_engine) {
+ char *str;
+ CORBA_Environment ev;
+
+ CORBA_exception_init (&ev);
+
+ str = GNOME_GtkHTML_Editor_Engine_getFilePath (composer->priv->eeditor_engine, &ev);
+ if (ev._major == CORBA_NO_EXCEPTION && str)
+ e_msg_composer_set_attach_path (composer, str);
+ if (str)
+ CORBA_free (str);
+
+ CORBA_exception_free (&ev);
+ }
+
+ return g_object_get_data ((GObject *) composer, "attach_path");
+}
+
static char *
encode_signature_name (const char *name)
{
@@ -4513,6 +4595,7 @@ set_signature_gui (EMsgComposer *composer)
p->signature = mail_config_get_signature_by_name (name);
g_free (name);
}
+ CORBA_free (str);
}
sig_select_item (composer);