aboutsummaryrefslogtreecommitdiffstats
path: root/composer
diff options
context:
space:
mode:
Diffstat (limited to 'composer')
-rw-r--r--composer/ChangeLog18
-rw-r--r--composer/e-msg-composer-select-file.c10
-rw-r--r--composer/e-msg-composer.c83
-rw-r--r--composer/e-msg-composer.h4
-rw-r--r--composer/listener.c2
5 files changed, 113 insertions, 4 deletions
diff --git a/composer/ChangeLog b/composer/ChangeLog
index 71a1279662..9a08ccf025 100644
--- a/composer/ChangeLog
+++ b/composer/ChangeLog
@@ -1,3 +1,21 @@
+2007-11-29 Milan Crha <mcrha@redhat.com>
+
+ ** Part of fix for bug #271551
+
+ * e-msg-composer.h: (e_msg_composer_set_attach_path),
+ (e_msg_composer_get_attach_path):
+ * 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.
+ * e-msg-composer.c: (prepare_engine):
+ Set last used path right after creation of the engine.
+ * e-msg-composer-select-file.c: (get_selector), (select_file_response),
+ (select_attach_response): Using new functions.
+ * listener.c: (impl_event): Store new file path when received event
+ about its change.
+
+ * e-msg-composer.c: (set_signature_gui): Leak fix.
+
2007-11-27 Matthew Barnes <mbarnes@redhat.com>
** Fixes part of bug #495123
diff --git a/composer/e-msg-composer-select-file.c b/composer/e-msg-composer-select-file.c
index 4cf92a661e..f0e5b767c9 100644
--- a/composer/e-msg-composer-select-file.c
+++ b/composer/e-msg-composer-select-file.c
@@ -58,9 +58,9 @@ get_selector(struct _EMsgComposer *composer, const char *title, guint32 flags)
GtkWidget *selection;
GtkWidget *showinline = NULL;
GList *icon_list;
- char *path;
+ const char *path;
- path = g_object_get_data ((GObject *) composer, "attach_path");
+ path = e_msg_composer_get_attach_path (composer);
if (flags & SELECTOR_MODE_SAVE)
selection = gtk_file_chooser_dialog_new (title,
@@ -120,7 +120,8 @@ select_file_response(GtkWidget *selector, guint response, struct _EMsgComposer *
name = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (selector));
path = g_path_get_dirname (gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (selector)));
- g_object_set_data_full ((GObject *) composer, "attach_path", path, g_free);
+ e_msg_composer_set_attach_path (composer, path);
+ g_free (path);
func(composer, name);
}
@@ -172,7 +173,8 @@ select_attach_response(GtkWidget *selector, guint response, struct _EMsgComposer
g_free (filename);
}
if (path)
- g_object_set_data_full ((GObject *) composer, "attach_path", path, g_free);
+ e_msg_composer_set_attach_path (composer, path);
+ g_free (path);
func(composer, names, gtk_toggle_button_get_active(showinline));
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);
diff --git a/composer/e-msg-composer.h b/composer/e-msg-composer.h
index d285c0d6f1..19e84170e4 100644
--- a/composer/e-msg-composer.h
+++ b/composer/e-msg-composer.h
@@ -196,6 +196,10 @@ const gchar * e_msg_composer_get_raw_message_text (EMsgC
struct _EAttachmentBar* e_msg_composer_get_attachment_bar (EMsgComposer *composer);
+void e_msg_composer_set_attach_path (EMsgComposer *composer, const gchar *path);
+const gchar * e_msg_composer_get_attach_path (EMsgComposer *composer);
+
+
#ifdef __cplusplus
}
#endif /* __cplusplus */
diff --git a/composer/listener.c b/composer/listener.c
index 474ac5f64f..80fb6dc6c6 100644
--- a/composer/listener.c
+++ b/composer/listener.c
@@ -119,6 +119,8 @@ impl_event (PortableServer_Servant _servant,
} else if (!strcmp (name, "link_clicked")) {
e_msg_composer_link_clicked (l->composer, BONOBO_ARG_GET_STRING (arg));
+ } else if (!strcmp (name, "file_path_changed")) {
+ e_msg_composer_set_attach_path (l->composer, e_msg_composer_get_attach_path (l->composer));
}
return rv ? rv : get_any_null ();