diff options
author | Milan Crha <mcrha@redhat.com> | 2007-11-30 02:16:10 +0800 |
---|---|---|
committer | Milan Crha <mcrha@src.gnome.org> | 2007-11-30 02:16:10 +0800 |
commit | 462fdd34535c090706e59ce3ffb4aa51bc29a034 (patch) | |
tree | f185944f5bcd1141178027dcbf82b2c1ab6f2329 | |
parent | 4bca50f1c5060efbfe2f0c9d011e4d51f1e8be0f (diff) | |
download | gsoc2013-evolution-462fdd34535c090706e59ce3ffb4aa51bc29a034.tar gsoc2013-evolution-462fdd34535c090706e59ce3ffb4aa51bc29a034.tar.gz gsoc2013-evolution-462fdd34535c090706e59ce3ffb4aa51bc29a034.tar.bz2 gsoc2013-evolution-462fdd34535c090706e59ce3ffb4aa51bc29a034.tar.lz gsoc2013-evolution-462fdd34535c090706e59ce3ffb4aa51bc29a034.tar.xz 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
-rw-r--r-- | composer/ChangeLog | 18 | ||||
-rw-r--r-- | composer/e-msg-composer-select-file.c | 10 | ||||
-rw-r--r-- | composer/e-msg-composer.c | 83 | ||||
-rw-r--r-- | composer/e-msg-composer.h | 4 | ||||
-rw-r--r-- | composer/listener.c | 2 | ||||
-rw-r--r-- | mail/ChangeLog | 7 | ||||
-rw-r--r-- | mail/evolution-mail.schemas.in | 13 |
7 files changed, 133 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 (); diff --git a/mail/ChangeLog b/mail/ChangeLog index feb3a52fb8..7165f155fd 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,10 @@ +2007-11-29 Milan Crha <mcrha@redhat.com> + + ** Part of fix for bug #271551 + + * evolution-mail.schemas.in: + New key "/apps/evolution/mail/composer/current_folder". + 2007-11-28 Matthew Barnes <mbarnes@redhat.com> * mail-session.c: diff --git a/mail/evolution-mail.schemas.in b/mail/evolution-mail.schemas.in index 7048d77933..a60d34d8ce 100644 --- a/mail/evolution-mail.schemas.in +++ b/mail/evolution-mail.schemas.in @@ -1116,5 +1116,18 @@ </locale> </schema> + <schema> + <key>/schemas/apps/evolution/mail/composer/current_folder</key> + <applyto>/apps/evolution/mail/composer/current_folder</applyto> + <owner>evolution-mail</owner> + <type>string</type> + <locale name="C"> + <short>Composer load/attach directory</short> + <long> + Directory for loading/attaching files to composer + </long> + </locale> + </schema> + </schemalist> </gconfschemafile> |