** 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
This commit is contained in:
Milan Crha
2007-11-29 18:16:10 +00:00
committed by Milan Crha
parent 4bca50f1c5
commit 462fdd3453
7 changed files with 133 additions and 4 deletions

View File

@ -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

View File

@ -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));

View File

@ -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);

View File

@ -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 */

View File

@ -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 ();

View File

@ -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:

View File

@ -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>