aboutsummaryrefslogtreecommitdiffstats
path: root/composer
diff options
context:
space:
mode:
Diffstat (limited to 'composer')
-rw-r--r--composer/Makefile.am7
-rw-r--r--composer/e-composer-actions.c35
-rw-r--r--composer/e-composer-from-header.c6
-rw-r--r--composer/e-composer-from-header.h4
-rw-r--r--composer/e-composer-header-table.c50
-rw-r--r--composer/e-composer-header-table.h5
-rw-r--r--composer/e-composer-header.c22
-rw-r--r--composer/e-composer-header.h6
-rw-r--r--composer/e-composer-name-header.c35
-rw-r--r--composer/e-composer-post-header.c91
-rw-r--r--composer/e-composer-post-header.h5
-rw-r--r--composer/e-composer-private.c15
-rw-r--r--composer/e-composer-private.h6
-rw-r--r--composer/e-msg-composer.c575
-rw-r--r--composer/e-msg-composer.h16
15 files changed, 387 insertions, 491 deletions
diff --git a/composer/Makefile.am b/composer/Makefile.am
index 97af16bec5..e20f3f007e 100644
--- a/composer/Makefile.am
+++ b/composer/Makefile.am
@@ -38,8 +38,6 @@ AM_CPPFLAGS = \
$(EVOLUTION_MAIL_CFLAGS)
libcomposer_la_SOURCES = \
- $(IDL_GENERATED) \
- $(HTML_EDITOR_GENERATED) \
$(libcomposerinclude_HEADERS) \
e-composer-actions.c \
e-composer-autosave.c \
@@ -52,6 +50,9 @@ libcomposer_la_SOURCES = \
e-composer-text-header.c \
e-msg-composer.c
+libcomposer_la_LIBADD = \
+ $(top_builddir)/widgets/misc/libemiscwidgets.la \
+ $(top_builddir)/em-format/libemformat.la
uidir = $(evolutionuidir)
ui_DATA = evolution-composer.ui
@@ -61,7 +62,7 @@ EXTRA_DIST = \
mail-composer.error.xml \
ChangeLog.pre-1-4
-BUILT_SOURCES = $(IDL_GENERATED) $(HTML_EDITOR_GENERATED) $(error_DATA)
+BUILT_SOURCES = $(error_DATA)
CLEANFILES = $(BUILT_SOURCES)
dist-hook:
diff --git a/composer/e-composer-actions.c b/composer/e-composer-actions.c
index 3b40d270f0..bceeb1a9f5 100644
--- a/composer/e-composer-actions.c
+++ b/composer/e-composer-actions.c
@@ -21,11 +21,6 @@
#include <errno.h>
#include <fcntl.h>
#include <e-util/e-error.h>
-#include <mail/em-event.h>
-#include <mail/em-format-html-print.h>
-#include <mail/em-composer-utils.h>
-
-#include "misc/e-charset-picker.h"
static void
action_attach_cb (GtkAction *action,
@@ -50,7 +45,7 @@ action_charset_cb (GtkRadioAction *action,
if (action != current)
return;
- charset = gtk_action_get_name (GTK_ACTION (current));
+ charset = g_object_get_data (G_OBJECT (action), "charset");
g_free (composer->priv->charset);
composer->priv->charset = g_strdup (charset);
@@ -128,15 +123,9 @@ action_print_cb (GtkAction *action,
EMsgComposer *composer)
{
GtkPrintOperationAction print_action;
- CamelMimeMessage *message;
- EMFormatHTMLPrint *efhp;
print_action = GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG;
- message = e_msg_composer_get_message (composer, 1);
-
- efhp = em_format_html_print_new (NULL, print_action);
- em_format_html_print_raw_message (efhp, message);
- g_object_unref (efhp);
+ e_msg_composer_print (composer, print_action);
}
static void
@@ -144,15 +133,9 @@ action_print_preview_cb (GtkAction *action,
EMsgComposer *composer)
{
GtkPrintOperationAction print_action;
- CamelMimeMessage *message;
- EMFormatHTMLPrint *efhp;
print_action = GTK_PRINT_OPERATION_ACTION_PREVIEW;
- message = e_msg_composer_get_message_print (composer, 1);
-
- efhp = em_format_html_print_new (NULL, print_action);
- em_format_html_print_raw_message (efhp, message);
- g_object_unref (efhp);
+ e_msg_composer_print (composer, print_action);
}
static void
@@ -263,6 +246,8 @@ static void
action_send_options_cb (GtkAction *action,
EMsgComposer *composer)
{
+ /* FIXME: KILL-BONOBO - should this be here when -no-undefined removed? */
+ /*
EMEvent *event = em_event_peek ();
EMEventTargetComposer *target;
@@ -274,6 +259,7 @@ action_send_options_cb (GtkAction *action,
(EEvent *) event,
"composer.selectsendoption",
(EEventTarget *) target);
+ */
if (!composer->priv->send_invoked)
e_error_run (
@@ -283,9 +269,12 @@ action_send_options_cb (GtkAction *action,
static void
action_new_message_cb (GtkAction *action,
- EMsgComposer *composer)
+ EMsgComposer *composer)
{
- em_utils_compose_new_message (NULL);
+ EMsgComposer *new_composer;
+
+ new_composer = e_msg_composer_new ();
+ gtk_widget_show (GTK_WIDGET (new_composer));
}
static void
@@ -508,7 +497,7 @@ e_composer_actions_init (EMsgComposer *composer)
gtk_action_group_set_translation_domain (
action_group, GETTEXT_PACKAGE);
e_charset_add_radio_actions (
- action_group, composer->priv->charset,
+ action_group, "charset-", composer->priv->charset,
G_CALLBACK (action_charset_cb), composer);
gtk_ui_manager_insert_action_group (ui_manager, action_group, 0);
diff --git a/composer/e-composer-from-header.c b/composer/e-composer-from-header.c
index 320768c79c..cade5bfed3 100644
--- a/composer/e-composer-from-header.c
+++ b/composer/e-composer-from-header.c
@@ -111,11 +111,13 @@ e_composer_from_header_new (const gchar *label)
}
EComposerHeader *
-e_composer_from_header_new_with_action (const gchar *label, const gchar *action)
+e_composer_from_header_new_with_action (const gchar *label,
+ const gchar *action)
{
return g_object_new (
E_TYPE_COMPOSER_FROM_HEADER, "label", label,
- "button", FALSE, "addaction_text", action, "addaction", action!= NULL, NULL);
+ "button", FALSE, "addaction_text", action,
+ "addaction", action != NULL, NULL);
}
EAccountList *
diff --git a/composer/e-composer-from-header.h b/composer/e-composer-from-header.h
index 3fbf5a7012..9f9a0e0f82 100644
--- a/composer/e-composer-from-header.h
+++ b/composer/e-composer-from-header.h
@@ -63,7 +63,9 @@ struct _EComposerFromHeaderClass {
GType e_composer_from_header_get_type (void);
EComposerHeader * e_composer_from_header_new (const gchar *label);
-EComposerHeader * e_composer_from_header_new_with_action (const gchar *label, const gchar *action);
+EComposerHeader * e_composer_from_header_new_with_action
+ (const gchar *label,
+ const gchar *action);
EAccountList * e_composer_from_header_get_account_list
(EComposerFromHeader *header);
void e_composer_from_header_set_account_list
diff --git a/composer/e-composer-header-table.c b/composer/e-composer-header-table.c
index 55dc6a65a0..47885df074 100644
--- a/composer/e-composer-header-table.c
+++ b/composer/e-composer-header-table.c
@@ -160,11 +160,11 @@ composer_header_table_notify_header (EComposerHeader *header,
{
GtkWidget *parent;
- if (strcmp (property_name, "destinations-to") == 0) {
- parent = g_object_get_data((GObject *)header->input_widget, "parent");
- } else {
+ if (strcmp (property_name, "destinations-to") == 0)
+ parent = g_object_get_data (
+ G_OBJECT (header->input_widget), "parent");
+ else
parent = gtk_widget_get_parent (header->input_widget);
- }
g_return_if_fail (E_IS_COMPOSER_HEADER_TABLE (parent));
g_object_notify (G_OBJECT (parent), property_name);
}
@@ -177,7 +177,7 @@ composer_header_table_notify_widget (GtkWidget *widget,
if (composer_lite) {
parent = gtk_widget_get_parent (widget);
- parent = g_object_get_data ((GObject *)parent, "pdata");
+ parent = g_object_get_data (G_OBJECT (parent), "pdata");
} else
parent = gtk_widget_get_parent (widget);
g_return_if_fail (E_IS_COMPOSER_HEADER_TABLE (parent));
@@ -534,7 +534,6 @@ composer_header_table_constructor (GType type,
if (composer_lite)
gtk_widget_show_all ((GtkWidget *)priv->actions_container);
-
ii = E_COMPOSER_HEADER_FROM;
/* Leave room in the "From" row for signature stuff. */
@@ -559,11 +558,16 @@ composer_header_table_constructor (GType type,
gtk_table_attach (
GTK_TABLE (object), priv->signature_combo_box,
3, 4, ii, ii + 1, composer_lite ? GTK_FILL: 0, 0, 0, 3);
- } else {
+ } else {
GtkWidget *box = gtk_hbox_new (FALSE, 0);
- gtk_box_pack_start ((GtkBox *)box, priv->signature_label, FALSE, FALSE, 4);
- gtk_box_pack_end ((GtkBox *)box, priv->signature_combo_box, TRUE, TRUE, 0);
- g_object_set_data ((GObject *)box, "pdata", object);
+
+ gtk_box_pack_start (
+ GTK_BOX (box), priv->signature_label,
+ FALSE, FALSE, 4);
+ gtk_box_pack_end (
+ GTK_BOX (box), priv->signature_combo_box,
+ TRUE, TRUE, 0);
+ g_object_set_data (G_OBJECT (box), "pdata", object);
gtk_table_attach (
GTK_TABLE (object), box,
3, 4, ii, ii + 1, GTK_FILL, 0, 0, 3);
@@ -962,13 +966,13 @@ composer_header_table_init (EComposerHeaderTable *table)
table->priv->headers[E_COMPOSER_HEADER_TO] = header;
header = e_composer_name_header_new_with_action (
- _("_Cc:"), _("CC"), name_selector);
+ _("_Cc:"), _("Show CC"), name_selector);
e_composer_header_set_input_tooltip (header, HEADER_TOOLTIP_CC);
composer_header_table_bind_header ("destinations-cc", "changed", header);
table->priv->headers[E_COMPOSER_HEADER_CC] = header;
header = e_composer_name_header_new_with_action (
- _("_Bcc:"), _("BCC"), name_selector);
+ _("_Bcc:"), _("Show BCC"), name_selector);
e_composer_header_set_input_tooltip (header, HEADER_TOOLTIP_BCC);
composer_header_table_bind_header ("destinations-bcc", "changed", header);
table->priv->headers[E_COMPOSER_HEADER_BCC] = header;
@@ -1050,28 +1054,6 @@ e_composer_header_table_get_header (EComposerHeaderTable *table,
return table->priv->headers[type];
}
-void
-e_composer_header_table_set_header_visible (EComposerHeaderTable *table,
- EComposerHeaderType type,
- gboolean visible)
-{
- EComposerHeader *header;
-
- header = e_composer_header_table_get_header (table, type);
- e_composer_header_set_visible (header, visible);
-
- /* Signature widgets track the "From" header. */
- if (type == E_COMPOSER_HEADER_FROM) {
- if (visible) {
- gtk_widget_show (table->priv->signature_label);
- gtk_widget_show (table->priv->signature_combo_box);
- } else {
- gtk_widget_hide (table->priv->signature_label);
- gtk_widget_hide (table->priv->signature_combo_box);
- }
- }
-}
-
EAccount *
e_composer_header_table_get_account (EComposerHeaderTable *table)
{
diff --git a/composer/e-composer-header-table.h b/composer/e-composer-header-table.h
index 146868a864..91ad56da46 100644
--- a/composer/e-composer-header-table.h
+++ b/composer/e-composer-header-table.h
@@ -149,10 +149,7 @@ const gchar * e_composer_header_table_get_subject
void e_composer_header_table_set_subject
(EComposerHeaderTable *table,
const gchar *subject);
-void e_composer_header_table_set_header_visible
- (EComposerHeaderTable *table,
- EComposerHeaderType type,
- gboolean visible);
+
G_END_DECLS
#endif /* E_COMPOSER_HEADER_TABLE_H */
diff --git a/composer/e-composer-header.c b/composer/e-composer-header.c
index 334464eddd..fd71bab4d9 100644
--- a/composer/e-composer-header.c
+++ b/composer/e-composer-header.c
@@ -21,7 +21,7 @@
*/
#include "e-composer-header.h"
-#include <glib/gi18n.h>
+
#define E_COMPOSER_HEADER_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE \
((obj), E_TYPE_COMPOSER_HEADER, EComposerHeaderPrivate))
@@ -111,19 +111,9 @@ composer_header_constructor (GType type,
box = gtk_hbox_new (FALSE, 0);
tmp = gtk_image_new_from_stock("gtk-add", GTK_ICON_SIZE_BUTTON);
gtk_box_pack_start((GtkBox *)box, tmp, FALSE, FALSE, 3);
- g_object_set_data ((GObject *)header->priv->action_label, "add", tmp);
- tmp = gtk_image_new_from_stock("gtk-remove", GTK_ICON_SIZE_BUTTON);
- gtk_box_pack_start((GtkBox *)box, tmp, FALSE, FALSE, 3);
- g_object_set_data ((GObject *)header->priv->action_label, "remove", tmp);
- gtk_widget_hide (tmp);
- tmp = header->priv->action_label;
- str = g_strdup_printf ("<span>%s %s</span>", _("Show"), header->priv->addaction_text);
- g_object_set_data ((GObject *)tmp, "show", str);
+ tmp = gtk_label_new (NULL);
+ str = g_strdup_printf ("<span foreground='blue' underline='single' underline_color='blue' >%s</span>", header->priv->addaction_text);
gtk_label_set_markup((GtkLabel *)tmp, str);
- str = g_strdup_printf ("<span>%s %s</span>", _("Hide"), header->priv->addaction_text);
- g_object_set_data ((GObject *)tmp, "hide", str);
-
- header->priv->action_label = tmp;
gtk_box_pack_start((GtkBox *)box, tmp, FALSE, FALSE, 3);
gtk_container_add((GtkContainer *)header->action_widget, box);
gtk_widget_show_all(header->action_widget);
@@ -340,7 +330,8 @@ composer_header_class_init (EComposerHeaderClass *class)
"changed",
G_TYPE_FROM_CLASS (class),
G_SIGNAL_RUN_LAST,
- 0, NULL, NULL,
+ G_STRUCT_OFFSET (EComposerHeaderClass, changed),
+ NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
@@ -348,7 +339,8 @@ composer_header_class_init (EComposerHeaderClass *class)
"clicked",
G_TYPE_FROM_CLASS (class),
G_SIGNAL_RUN_LAST,
- 0, NULL, NULL,
+ G_STRUCT_OFFSET (EComposerHeaderClass, clicked),
+ NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
}
diff --git a/composer/e-composer-header.h b/composer/e-composer-header.h
index e1d7d923ab..33600900e9 100644
--- a/composer/e-composer-header.h
+++ b/composer/e-composer-header.h
@@ -28,7 +28,7 @@
((obj), E_TYPE_COMPOSER_HEADER, EComposerHeader))
#define E_COMPOSER_HEADER_CLASS(cls) \
(G_TYPE_CHECK_CLASS_CAST \
- ((obj), E_TYPE_COMPOSER_HEADER, EComposerHeaderClass))
+ ((cls), E_TYPE_COMPOSER_HEADER, EComposerHeaderClass))
#define E_IS_COMPOSER_HEADER(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE \
((obj), E_TYPE_COMPOSER_HEADER))
@@ -55,6 +55,10 @@ struct _EComposerHeader {
struct _EComposerHeaderClass {
GObjectClass parent_class;
+
+ /* Signals */
+ void (*changed) (EComposerHeader *header);
+ void (*clicked) (EComposerHeader *header);
};
GType e_composer_header_get_type (void);
diff --git a/composer/e-composer-name-header.c b/composer/e-composer-name-header.c
index 47936eeeab..5eed2e42c1 100644
--- a/composer/e-composer-name-header.c
+++ b/composer/e-composer-name-header.c
@@ -48,18 +48,6 @@ struct _EComposerNameHeaderPrivate {
static gpointer parent_class;
static void
-composer_name_header_clicked_cb (EComposerNameHeader *header)
-{
- ENameSelectorDialog *dialog;
-
- dialog = e_name_selector_peek_dialog (header->priv->name_selector);
- e_name_selector_dialog_set_destination_index (
- dialog, header->priv->destination_index);
- gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_hide (GTK_WIDGET (dialog));
-}
-
-static void
composer_name_header_entry_changed_cb (ENameSelectorEntry *entry,
EComposerNameHeader *header)
{
@@ -133,10 +121,6 @@ composer_name_header_constructor (GType type,
NULL);
E_COMPOSER_HEADER (object)->input_widget = g_object_ref_sink (entry);
- g_signal_connect (
- object, "clicked",
- G_CALLBACK (composer_name_header_clicked_cb), NULL);
-
return object;
}
@@ -195,9 +179,25 @@ composer_name_header_dispose (GObject *object)
}
static void
+composer_name_header_clicked (EComposerHeader *header)
+{
+ EComposerNameHeaderPrivate *priv;
+ ENameSelectorDialog *dialog;
+
+ priv = E_COMPOSER_NAME_HEADER_GET_PRIVATE (header);
+
+ dialog = e_name_selector_peek_dialog (priv->name_selector);
+ e_name_selector_dialog_set_destination_index (
+ dialog, priv->destination_index);
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_hide (GTK_WIDGET (dialog));
+}
+
+static void
composer_name_header_class_init (EComposerNameHeaderClass *class)
{
GObjectClass *object_class;
+ EComposerHeaderClass *header_class;
parent_class = g_type_class_peek_parent (class);
g_type_class_add_private (class, sizeof (EComposerNameHeaderPrivate));
@@ -208,6 +208,9 @@ composer_name_header_class_init (EComposerNameHeaderClass *class)
object_class->get_property = composer_name_header_get_property;
object_class->dispose = composer_name_header_dispose;
+ header_class = E_COMPOSER_HEADER_CLASS (class);
+ header_class->clicked = composer_name_header_clicked;
+
g_object_class_install_property (
object_class,
PROP_NAME_SELECTOR,
diff --git a/composer/e-composer-post-header.c b/composer/e-composer-post-header.c
index 59d81b80ac..cb297fe375 100644
--- a/composer/e-composer-post-header.c
+++ b/composer/e-composer-post-header.c
@@ -22,9 +22,7 @@
#include <string.h>
#include <glib/gi18n.h>
-
-#include "mail/em-folder-selector.h"
-#include "mail/em-folder-tree.h"
+#include <camel/camel-url.h>
#define E_COMPOSER_POST_HEADER_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE \
@@ -43,10 +41,6 @@ struct _EComposerPostHeaderPrivate {
static gpointer parent_class;
-/* Forward Declarations (to avoid pulling in Bonobo stuff) */
-struct _MailComponent *mail_component_peek (void);
-struct _EMFolderTreeModel *mail_component_peek_tree_model (struct _MailComponent *component);
-
static gchar *
composer_post_header_folder_name_to_string (EComposerPostHeader *header,
const gchar *url)
@@ -106,56 +100,6 @@ composer_post_header_split_csv (const gchar *csv)
return g_list_reverse (list);
}
-static void
-composer_post_header_changed_cb (EComposerPostHeader *header)
-{
- header->priv->custom = TRUE;
-}
-
-static void
-composer_post_header_clicked_cb (EComposerPostHeader *header)
-{
- EMFolderTreeModel *model;
- GtkWidget *folder_tree;
- GtkWidget *dialog;
- GList *list;
-
- model = mail_component_peek_tree_model (mail_component_peek ());
- folder_tree = em_folder_tree_new_with_model (model);
-
- em_folder_tree_set_multiselect (
- EM_FOLDER_TREE (folder_tree), TRUE);
- em_folder_tree_set_excluded (
- EM_FOLDER_TREE (folder_tree),
- EMFT_EXCLUDE_NOSELECT |
- EMFT_EXCLUDE_VIRTUAL |
- EMFT_EXCLUDE_VTRASH);
-
- dialog = em_folder_selector_new (
- EM_FOLDER_TREE (folder_tree),
- EM_FOLDER_SELECTOR_CAN_CREATE,
- _("Posting destination"),
- _("Choose folders to post the message to."),
- NULL);
-
- list = e_composer_post_header_get_folders (header);
- em_folder_selector_set_selected_list (
- EM_FOLDER_SELECTOR (dialog), list);
- g_list_foreach (list, (GFunc) g_free, NULL);
- g_list_free (list);
-
- if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK) {
- list = em_folder_selector_get_selected_uris (
- EM_FOLDER_SELECTOR (dialog));
- e_composer_post_header_set_folders (header, list);
- header->priv->custom = FALSE;
- g_list_foreach (list, (GFunc) g_free, NULL);
- g_list_free (list);
- }
-
- gtk_widget_destroy (dialog);
-}
-
static GObject *
composer_post_header_constructor (GType type,
guint n_construct_properties,
@@ -171,14 +115,6 @@ composer_post_header_constructor (GType type,
E_COMPOSER_HEADER (object),
_("Click here to select folders to post to"));
- g_signal_connect (
- object, "changed",
- G_CALLBACK (composer_post_header_changed_cb), NULL);
-
- g_signal_connect (
- object, "clicked",
- G_CALLBACK (composer_post_header_clicked_cb), NULL);
-
return object;
}
@@ -246,9 +182,30 @@ composer_post_header_finalize (GObject *object)
}
static void
+composer_post_header_changed (EComposerHeader *header)
+{
+ EComposerPostHeaderPrivate *priv;
+
+ priv = E_COMPOSER_POST_HEADER_GET_PRIVATE (header);
+
+ priv->custom = TRUE;
+}
+
+static void
+composer_post_header_clicked (EComposerHeader *header)
+{
+ EComposerPostHeaderPrivate *priv;
+
+ priv = E_COMPOSER_POST_HEADER_GET_PRIVATE (header);
+
+ priv->custom = FALSE;
+}
+
+static void
composer_post_header_class_init (EComposerPostHeaderClass *class)
{
GObjectClass *object_class;
+ EComposerHeaderClass *header_class;
parent_class = g_type_class_peek_parent (class);
g_type_class_add_private (class, sizeof (EComposerPostHeaderPrivate));
@@ -260,6 +217,10 @@ composer_post_header_class_init (EComposerPostHeaderClass *class)
object_class->dispose = composer_post_header_dispose;
object_class->finalize = composer_post_header_finalize;
+ header_class = E_COMPOSER_HEADER_CLASS (class);
+ header_class->changed = composer_post_header_changed;
+ header_class->clicked = composer_post_header_clicked;
+
g_object_class_install_property (
object_class,
PROP_ACCOUNT,
diff --git a/composer/e-composer-post-header.h b/composer/e-composer-post-header.h
index 40dc5a8d58..c38bfe2d17 100644
--- a/composer/e-composer-post-header.h
+++ b/composer/e-composer-post-header.h
@@ -46,6 +46,8 @@
G_BEGIN_DECLS
+/* Avoid including files from the Mail module. */
+
typedef struct _EComposerPostHeader EComposerPostHeader;
typedef struct _EComposerPostHeaderClass EComposerPostHeaderClass;
typedef struct _EComposerPostHeaderPrivate EComposerPostHeaderPrivate;
@@ -60,7 +62,8 @@ struct _EComposerPostHeaderClass {
};
GType e_composer_post_header_get_type (void);
-EComposerHeader * e_composer_post_header_new (const gchar *label);
+EComposerHeader *
+ e_composer_post_header_new (const gchar *label);
EAccount * e_composer_post_header_get_account
(EComposerPostHeader *header);
void e_composer_post_header_set_account
diff --git a/composer/e-composer-private.c b/composer/e-composer-private.c
index 9a506fa862..bfb14b451a 100644
--- a/composer/e-composer-private.c
+++ b/composer/e-composer-private.c
@@ -17,7 +17,6 @@
#include "e-composer-private.h"
#include "e-util/e-util-private.h"
-#include "widgets/misc/e-attachment-icon-view.h"
static void
composer_setup_charset_menu (EMsgComposer *composer)
@@ -28,10 +27,12 @@ composer_setup_charset_menu (EMsgComposer *composer)
guint merge_id;
ui_manager = gtkhtml_editor_get_ui_manager (GTKHTML_EDITOR (composer));
- list = gtk_action_group_list_actions (composer->priv->charset_actions);
path = "/main-menu/edit-menu/pre-spell-check/charset-menu";
merge_id = gtk_ui_manager_new_merge_id (ui_manager);
+ list = gtk_action_group_list_actions (composer->priv->charset_actions);
+ list = g_list_sort (list, (GCompareFunc) e_action_compare_by_label);
+
while (list != NULL) {
GtkAction *action = list->data;
@@ -86,8 +87,8 @@ e_composer_private_init (EMsgComposer *composer)
GtkhtmlEditor *editor;
GtkUIManager *ui_manager;
- GtkWidget *widget;
GtkWidget *container;
+ GtkWidget *widget;
GtkWidget *send_widget;
const gchar *path;
gchar *filename;
@@ -101,7 +102,7 @@ e_composer_private_init (EMsgComposer *composer)
widget = gtkhtml_editor_get_managed_widget (editor, "/main-menu");
gtk_widget_hide (widget);
widget = gtkhtml_editor_get_managed_widget (editor, "/main-toolbar");
- gtk_toolbar_set_style ((GtkToolbar *)widget, GTK_TOOLBAR_BOTH_HORIZ);
+ gtk_toolbar_set_style (GTK_TOOLBAR (widget), GTK_TOOLBAR_BOTH_HORIZ);
gtk_widget_hide (widget);
}
@@ -198,7 +199,6 @@ e_composer_private_init (EMsgComposer *composer)
gtk_container_remove((GtkContainer *)send_widget, gtk_bin_get_child ((GtkBin *)send_widget));
gtk_container_add((GtkContainer *)send_widget, tmp);
gtk_button_set_relief ((GtkButton *)send_widget, GTK_RELIEF_NORMAL);
-
path = "/main-toolbar/pre-main-toolbar/save-draft";
send_widget = gtk_ui_manager_get_widget (ui_manager, path);
tmp = gtk_hbox_new (FALSE, 0);
@@ -297,6 +297,11 @@ e_composer_private_dispose (EMsgComposer *composer)
composer->priv->header_table = NULL;
}
+ if (composer->priv->attachment_paned != NULL) {
+ g_object_unref (composer->priv->attachment_paned);
+ composer->priv->attachment_paned = NULL;
+ }
+
if (composer->priv->charset_actions != NULL) {
g_object_unref (composer->priv->charset_actions);
composer->priv->charset_actions = NULL;
diff --git a/composer/e-composer-private.h b/composer/e-composer-private.h
index 49d9ae6d74..1d0c19f366 100644
--- a/composer/e-composer-private.h
+++ b/composer/e-composer-private.h
@@ -29,7 +29,10 @@
#include "e-composer-autosave.h"
#include "e-composer-header-table.h"
#include "e-util/e-binding.h"
+#include "e-util/e-charset.h"
+#include "e-util/e-util.h"
#include "e-util/gconf-bridge.h"
+#include "widgets/misc/e-attachment-icon-view.h"
#include "widgets/misc/e-attachment-paned.h"
#include "widgets/misc/e-attachment-store.h"
@@ -104,7 +107,6 @@ struct _EMsgComposerPrivate {
gchar *mime_type, *mime_body, *charset;
- guint32 attachment_bar_visible : 1;
guint32 is_alternative : 1;
guint32 autosaved : 1;
guint32 mode_post : 1;
@@ -113,8 +115,6 @@ struct _EMsgComposerPrivate {
CamelMimeMessage *redirect;
- guint notify_id;
-
gboolean send_invoked;
};
diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c
index d7d9c034c0..c2d8899b81 100644
--- a/composer/e-msg-composer.c
+++ b/composer/e-msg-composer.c
@@ -23,17 +23,6 @@
*
*/
-/*
-
- TODO
-
- - Somehow users should be able to see if any file (s) are attached even when
- the attachment bar is not shown.
-
- Should use EventSources to keep track of global changes made to configuration
- values. Right now it ignores the problem olympically. Miguel.
-*/
-
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
@@ -59,50 +48,40 @@
#include <glade/glade.h>
#include "e-util/e-dialog-utils.h"
-#include "misc/e-charset-picker.h"
#include "e-util/e-error.h"
+#include "e-util/e-mktemp.h"
#include "e-util/e-plugin-ui.h"
#include "e-util/e-util-private.h"
-#include "e-util/e-util.h"
-#include "e-util/e-mktemp.h"
-#include <mail/em-event.h>
+#include "e-util/e-account-utils.h"
+#include "e-util/e-signature-utils.h"
#include "e-signature-combo-box.h"
+#include "shell/e-shell.h"
+#include "em-format/em-format.h"
+#include "em-format/em-format-quote.h"
-#include <camel/camel-session.h>
#include <camel/camel-charset-map.h>
+#include <camel/camel-cipher-context.h>
+#include <camel/camel-folder.h>
+#include <camel/camel-gpg-context.h>
#include <camel/camel-iconv.h>
-#include <camel/camel-stream-filter.h>
#include <camel/camel-mime-filter-charset.h>
-#include <camel/camel-stream-mem.h>
-#include <camel/camel-stream-fs.h>
#include <camel/camel-mime-filter-tohtml.h>
-#include <camel/camel-multipart-signed.h>
#include <camel/camel-multipart-encrypted.h>
+#include <camel/camel-multipart-signed.h>
+#include <camel/camel-stream-filter.h>
+#include <camel/camel-stream-fs.h>
+#include <camel/camel-stream-mem.h>
#include <camel/camel-string-utils.h>
-#include <camel/camel-cipher-context.h>
#if defined (HAVE_NSS)
#include <camel/camel-smime-context.h>
#endif
-#include "mail/em-utils.h"
-#include "mail/em-composer-utils.h"
-#include "mail/mail-config.h"
-#include "mail/mail-crypto.h"
-#include "mail/mail-tools.h"
-#include "mail/mail-ops.h"
-#include "mail/mail-mt.h"
-#include "mail/mail-session.h"
-#include "mail/em-popup.h"
-#include "mail/em-menu.h"
-
#include "e-msg-composer.h"
#include "e-attachment.h"
#include "e-composer-autosave.h"
#include "e-composer-private.h"
#include "e-composer-header-table.h"
-#include "evolution-shell-component-utils.h"
-
#ifdef HAVE_XFREE
#include <X11/XF86keysym.h>
#endif
@@ -116,6 +95,7 @@
enum {
SEND,
SAVE_DRAFT,
+ PRINT,
LAST_SIGNAL
};
@@ -142,6 +122,104 @@ static void handle_multipart_alternative (EMsgComposer *composer, CamelMultipart
static void handle_multipart_encrypted (EMsgComposer *composer, CamelMimePart *multipart, gint depth);
static void handle_multipart_signed (EMsgComposer *composer, CamelMultipart *multipart, gint depth);
+/**
+ * emcu_part_to_html:
+ * @part:
+ *
+ * Converts a mime part's contents into html text. If @credits is given,
+ * then it will be used as an attribution string, and the
+ * content will be cited. Otherwise no citation or attribution
+ * will be performed.
+ *
+ * Return Value: The part in displayable html format.
+ **/
+static gchar *
+emcu_part_to_html (CamelMimePart *part, gssize *len, EMFormat *source)
+{
+ EMFormatQuote *emfq;
+ CamelStreamMem *mem;
+ GByteArray *buf;
+ gchar *text;
+
+ buf = g_byte_array_new ();
+ mem = (CamelStreamMem *) camel_stream_mem_new ();
+ camel_stream_mem_set_byte_array (mem, buf);
+
+ emfq = em_format_quote_new(NULL, (CamelStream *)mem, 0);
+ ((EMFormat *) emfq)->composer = TRUE;
+ if (source) {
+ /* copy over things we can, other things are internal, perhaps need different api than 'clone' */
+ if (source->default_charset)
+ em_format_set_default_charset((EMFormat *)emfq, source->default_charset);
+ if (source->charset)
+ em_format_set_default_charset((EMFormat *)emfq, source->charset);
+ }
+ em_format_part((EMFormat *) emfq, (CamelStream *)mem, part);
+ g_object_unref(emfq);
+
+ camel_stream_write((CamelStream *) mem, "", 1);
+ camel_object_unref(mem);
+
+ text = (gchar *)buf->data;
+ if (len)
+ *len = buf->len-1;
+ g_byte_array_free (buf, FALSE);
+
+ return text;
+}
+
+/* copy of em_utils_prompt_user from mailer */
+static gboolean
+emcu_prompt_user (GtkWindow *parent, const gchar *promptkey, const gchar *tag, const gchar *arg0, ...)
+{
+ GtkWidget *mbox, *check = NULL;
+ va_list ap;
+ gint button;
+ GConfClient *gconf = gconf_client_get_default ();
+
+ if (promptkey
+ && !gconf_client_get_bool(gconf, promptkey, NULL)) {
+ g_object_unref (gconf);
+ return TRUE;
+ }
+
+ va_start(ap, arg0);
+ mbox = e_error_newv(parent, tag, arg0, ap);
+ va_end(ap);
+
+ if (promptkey) {
+ check = gtk_check_button_new_with_mnemonic (_("_Do not show this message again."));
+ gtk_container_set_border_width((GtkContainer *)check, 12);
+ gtk_box_pack_start ((GtkBox *)((GtkDialog *) mbox)->vbox, check, TRUE, TRUE, 0);
+ gtk_widget_show (check);
+ }
+
+ button = gtk_dialog_run ((GtkDialog *) mbox);
+ if (promptkey)
+ gconf_client_set_bool(gconf, promptkey, !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(check)), NULL);
+
+ gtk_widget_destroy(mbox);
+ g_object_unref (gconf);
+
+ return button == GTK_RESPONSE_YES;
+}
+
+/* copy of mail_tool_remove_xevolution_headers */
+static struct _camel_header_raw *
+emcu_remove_xevolution_headers (CamelMimeMessage *message)
+{
+ struct _camel_header_raw *scan, *list = NULL;
+
+ for (scan = ((CamelMimePart *)message)->headers;scan;scan=scan->next)
+ if (!strncmp(scan->name, "X-Evolution", 11))
+ camel_header_raw_append(&list, scan->name, scan->value, scan->offset);
+
+ for (scan=list;scan;scan=scan->next)
+ camel_medium_remove_header((CamelMedium *)message, scan->name);
+
+ return list;
+}
+
static EDestination**
destination_list_to_vector_sized (GList *list, gint n)
{
@@ -476,6 +554,7 @@ build_message (EMsgComposer *composer,
CamelMultipart *body = NULL;
CamelContentType *type;
CamelMimeMessage *new;
+ CamelSession *session;
CamelStream *stream;
CamelMimePart *part;
CamelException ex;
@@ -495,6 +574,7 @@ build_message (EMsgComposer *composer,
account = e_composer_header_table_get_account (table);
view = e_msg_composer_get_attachment_view (composer);
store = e_attachment_view_get_store (view);
+ session = e_msg_composer_get_session (composer);
/* evil kludgy hack for Redirect */
if (p->redirect) {
@@ -746,8 +826,14 @@ build_message (EMsgComposer *composer,
if (pgp_sign) {
CamelMimePart *npart = camel_mime_part_new ();
- cipher = mail_crypto_get_pgp_cipher_context (account);
- camel_cipher_sign (cipher, pgp_userid, CAMEL_CIPHER_HASH_SHA1, part, npart, &ex);
+ cipher = camel_gpg_context_new (session);
+ if (account != NULL)
+ camel_gpg_context_set_always_trust (
+ CAMEL_GPG_CONTEXT (cipher),
+ account->pgp_always_trust);
+ camel_cipher_sign (
+ cipher, pgp_userid, CAMEL_CIPHER_HASH_SHA1,
+ part, npart, &ex);
camel_object_unref (cipher);
if (camel_exception_is_set (&ex)) {
@@ -766,8 +852,14 @@ build_message (EMsgComposer *composer,
if (account && account->pgp_encrypt_to_self && pgp_userid)
g_ptr_array_add (recipients, g_strdup (pgp_userid));
- cipher = mail_crypto_get_pgp_cipher_context (account);
- camel_cipher_encrypt (cipher, pgp_userid, recipients, part, npart, &ex);
+ cipher = camel_gpg_context_new (session);
+ if (account != NULL)
+ camel_gpg_context_set_always_trust (
+ CAMEL_GPG_CONTEXT (cipher),
+ account->pgp_always_trust);
+ camel_cipher_encrypt (
+ cipher, pgp_userid, recipients,
+ part, npart, &ex);
camel_object_unref (cipher);
if (account && account->pgp_encrypt_to_self && pgp_userid)
@@ -841,6 +933,7 @@ build_message (EMsgComposer *composer,
}
if (smime_encrypt) {
+
/* check to see if we should encrypt to self, NB removed after use */
if (account->smime_encrypt_to_self)
g_ptr_array_add (recipients, g_strdup (account->smime_encrypt_key));
@@ -920,103 +1013,6 @@ skip_content:
/* Signatures */
static gchar *
-get_file_content (EMsgComposer *composer,
- const gchar *filename,
- gboolean want_html,
- guint flags,
- gboolean warn)
-{
- CamelStreamFilter *filtered_stream;
- CamelStreamMem *memstream;
- CamelMimeFilter *html, *charenc;
- CamelStream *stream;
- GByteArray *buffer;
- gchar *charset;
- gchar *content;
- gint fd;
-
- fd = g_open (filename, O_RDONLY, 0);
- if (fd == -1) {
- if (warn)
- e_error_run ((GtkWindow *)composer, "mail-composer:no-sig-file",
- filename, g_strerror (errno), NULL);
- return g_strdup ("");
- }
-
- stream = camel_stream_fs_new_with_fd (fd);
-
- if (want_html) {
- filtered_stream = camel_stream_filter_new_with_stream (stream);
- camel_object_unref (stream);
-
- html = camel_mime_filter_tohtml_new (flags, 0);
- camel_stream_filter_add (filtered_stream, html);
- camel_object_unref (html);
-
- stream = (CamelStream *) filtered_stream;
- }
-
- memstream = (CamelStreamMem *) camel_stream_mem_new ();
- buffer = g_byte_array_new ();
- camel_stream_mem_set_byte_array (memstream, buffer);
-
- camel_stream_write_to_stream (stream, (CamelStream *) memstream);
- camel_object_unref (stream);
-
- /* The newer signature UI saves signatures in UTF-8, but we still need to check that
- the signature is valid UTF-8 because it is possible that the user imported a
- signature file that is in his/her locale charset. If it's not in UTF-8 and not in
- the charset the composer is in (or their default mail charset) then
- there's nothing we can do. */
- if (buffer->len && !g_utf8_validate ((const gchar *)buffer->data, buffer->len, NULL)) {
- stream = (CamelStream *) memstream;
- memstream = (CamelStreamMem *) camel_stream_mem_new ();
- camel_stream_mem_set_byte_array (memstream, g_byte_array_new ());
-
- filtered_stream = camel_stream_filter_new_with_stream (stream);
- camel_object_unref (stream);
-
- charset = composer && composer->priv->charset ? composer->priv->charset : NULL;
- charset = charset ? g_strdup (charset) : e_composer_get_default_charset ();
- if ((charenc = (CamelMimeFilter *) camel_mime_filter_charset_new_convert (charset, "UTF-8"))) {
- camel_stream_filter_add (filtered_stream, charenc);
- camel_object_unref (charenc);
- }
-
- g_free (charset);
-
- camel_stream_write_to_stream ((CamelStream *) filtered_stream, (CamelStream *) memstream);
- camel_object_unref (filtered_stream);
- g_byte_array_free (buffer, TRUE);
-
- buffer = memstream->buffer;
- }
-
- camel_object_unref (memstream);
-
- g_byte_array_append (buffer, (const guint8 *)"", 1);
- content = (gchar *)buffer->data;
- g_byte_array_free (buffer, FALSE);
-
- return content;
-}
-
-gchar *
-e_msg_composer_get_sig_file_content (const gchar *sigfile, gboolean in_html)
-{
- if (!sigfile || !*sigfile) {
- return NULL;
- }
-
- return get_file_content (NULL, sigfile, !in_html,
- CAMEL_MIME_FILTER_TOHTML_PRESERVE_8BIT |
- CAMEL_MIME_FILTER_TOHTML_CONVERT_URLS |
- CAMEL_MIME_FILTER_TOHTML_CONVERT_ADDRESSES |
- CAMEL_MIME_FILTER_TOHTML_CONVERT_SPACES,
- FALSE);
-}
-
-static gchar *
encode_signature_name (const gchar *name)
{
const gchar *s;
@@ -1106,34 +1102,6 @@ decode_signature_name (const gchar *name)
return dname;
}
-static gboolean
-add_signature_delim (void)
-{
- gboolean res;
- GConfClient *client = gconf_client_get_default ();
-
- res = !gconf_client_get_bool (client, COMPOSER_GCONF_NO_SIGNATURE_DELIM_KEY, NULL);
-
- g_object_unref (client);
-
- return res;
-}
-
-static gboolean
-is_top_signature (void)
-{
- GConfClient *gconf;
- gboolean res = FALSE;
-
- gconf = gconf_client_get_default ();
-
- res = gconf_client_get_bool (gconf, COMPOSER_GCONF_TOP_SIGNATURE_KEY, NULL);
-
- g_object_unref (gconf);
-
- return res;
-}
-
#define CONVERT_SPACES CAMEL_MIME_FILTER_TOHTML_CONVERT_SPACES
#define NO_SIGNATURE_TEXT \
"<!--+GtkHTML:<DATA class=\"ClueFlow\" key=\"signature\" value=\"1\">-->" \
@@ -1145,7 +1113,7 @@ get_signature_html (EMsgComposer *composer)
EComposerHeaderTable *table;
gchar *text = NULL, *html = NULL;
ESignature *signature;
- gboolean format_html, add_delim;
+ gboolean format_html;
table = e_msg_composer_get_header_table (composer);
signature = e_composer_header_table_get_signature (table);
@@ -1153,19 +1121,18 @@ get_signature_html (EMsgComposer *composer)
if (!signature)
return NULL;
- add_delim = add_signature_delim ();
-
if (!signature->autogen) {
if (!signature->filename)
return NULL;
format_html = signature->html;
- if (signature->script) {
- text = mail_config_signature_run_script (signature->filename);
- } else {
- text = e_msg_composer_get_sig_file_content (signature->filename, format_html);
- }
+ if (signature->script)
+ text = e_run_signature_script (
+ signature->filename);
+ else
+ text = e_read_signature_file (
+ signature, TRUE, NULL);
} else {
EAccount *account;
EAccountIdentity *id;
@@ -1182,8 +1149,7 @@ get_signature_html (EMsgComposer *composer)
name = id->name ? camel_text_to_html (id->name, CONVERT_SPACES, 0) : NULL;
organization = id->organization ? camel_text_to_html (id->organization, CONVERT_SPACES, 0) : NULL;
- text = g_strdup_printf ("%s%s%s%s%s%s%s%s%s",
- add_delim ? "-- <BR>" : "",
+ text = g_strdup_printf ("-- <BR>%s%s%s%s%s%s%s%s",
name ? name : "",
(address && *address) ? " &lt;<A HREF=\"mailto:" : "",
address ? address : "",
@@ -1213,13 +1179,12 @@ get_signature_html (EMsgComposer *composer)
"<!--+GtkHTML:<DATA class=\"ClueFlow\" key=\"signature_name\" value=\"uid:%s\">-->"
"<TABLE WIDTH=\"100%%\" CELLSPACING=\"0\" CELLPADDING=\"0\"><TR><TD><BR>"
"%s%s%s%s"
- "%s</TD></TR></TABLE>",
+ "</TD></TR></TABLE>",
encoded_uid ? encoded_uid : "",
format_html ? "" : "<PRE>\n",
- format_html || !add_delim || (!strncmp ("-- \n", text, 4) || strstr (text, "\n-- \n")) ? "" : "-- \n",
+ format_html || (!strncmp ("-- \n", text, 4) || strstr (text, "\n-- \n")) ? "" : "-- \n",
text,
- format_html ? "" : "</PRE>\n",
- is_top_signature () ? "<BR>" : "");
+ format_html ? "" : "</PRE>\n");
g_free (text);
g_free (encoded_uid);
text = html;
@@ -1233,11 +1198,17 @@ set_editor_text (EMsgComposer *composer,
const gchar *text,
gboolean set_signature)
{
- gchar *body = NULL;
+ EShell *shell;
+ EShellSettings *shell_settings;
+ gboolean reply_signature_on_top;
+ gchar *body = NULL, *html = NULL;
g_return_if_fail (E_IS_MSG_COMPOSER (composer));
g_return_if_fail (text != NULL);
+ shell = e_shell_get_default ();
+ shell_settings = e_shell_get_shell_settings (shell);
+
/*
Keeping Signatures in the beginning of composer
@@ -1252,9 +1223,30 @@ set_editor_text (EMsgComposer *composer,
*/
- if (is_top_signature ()) {
- /* put marker to the top */
- body = g_strdup_printf ("<BR>" NO_SIGNATURE_TEXT "%s", text);
+ reply_signature_on_top = e_shell_settings_get_boolean (
+ shell_settings, "composer-top-signature");
+
+ if (set_signature && reply_signature_on_top) {
+ gchar *tmp = NULL;
+ tmp = get_signature_html (composer);
+ if (tmp) {
+ /* Minimizing the damage. Make it just a part of the body instead of a signature */
+ html = strstr (tmp, "-- \n");
+ if (html) {
+ /* That two consecutive - symbols followed by a space */
+ *(html+1) = ' ';
+ body = g_strdup_printf ("</br>%s</br>%s", tmp, text);
+ } else {
+ /* HTML Signature. Make it as part of body */
+ body = g_strdup_printf ("</br>%s</br>%s", tmp, text);
+ }
+ g_free (tmp);
+ } else {
+ /* No signature set */
+ body = g_strdup_printf ("<!--+GtkHTML:<DATA class=\"ClueFlow\" key=\"signature\" value=\"1\">-->"
+ "<!--+GtkHTML:<DATA class=\"ClueFlow\" key=\"signature_name\" value=\"uid:Noname\">-->"
+ "<TABLE WIDTH=\"100%%\" CELLSPACING=\"0\" CELLPADDING=\"0\"><TR><TD> </TD></TR></TABLE>%s", text);
+ }
} else {
/* no marker => to the bottom */
body = g_strdup_printf ("%s<BR>", text);
@@ -1291,14 +1283,6 @@ autosave_load_draft (const gchar *filename)
if (e_composer_autosave_snapshot (composer))
g_unlink (filename);
- g_signal_connect (
- composer, "send",
- G_CALLBACK (em_utils_composer_send_cb), NULL);
-
- g_signal_connect (
- composer, "save-draft",
- G_CALLBACK (em_utils_composer_save_draft_cb), NULL);
-
gtk_widget_show (GTK_WIDGET (composer));
}
@@ -1366,7 +1350,7 @@ msg_composer_account_changed_cb (EMsgComposer *composer)
gtk_toggle_action_set_active (action, active);
uid = account->id->sig_uid;
- signature = uid ? mail_config_get_signature_by_uid (uid) : NULL;
+ signature = uid ? e_get_signature_by_uid (uid) : NULL;
e_composer_header_table_set_signature (table, signature);
/* XXX This should be done more generically. The composer
@@ -1420,53 +1404,6 @@ msg_composer_account_list_changed_cb (EMsgComposer *composer)
g_object_unref (iterator);
}
-static void
-msg_composer_update_preferences (GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry,
- EMsgComposer *composer)
-{
- GtkhtmlEditor *editor;
- gboolean enable;
- GError *error = NULL;
-
- editor = GTKHTML_EDITOR (composer);
-
- if (entry) {
- if (strcmp(gconf_entry_get_key(entry), COMPOSER_GCONF_INLINE_SPELLING_KEY) != 0 &&
- strcmp(gconf_entry_get_key(entry), COMPOSER_GCONF_MAGIC_LINKS_KEY) != 0 &&
- strcmp(gconf_entry_get_key(entry), COMPOSER_GCONF_MAGIC_SMILEYS_KEY) != 0)
- return;
- }
-
- enable = gconf_client_get_bool (
- client, COMPOSER_GCONF_INLINE_SPELLING_KEY, &error);
- if (error == NULL)
- gtkhtml_editor_set_inline_spelling (editor, enable);
- else {
- g_warning ("%s", error->message);
- g_clear_error (&error);
- }
-
- enable = gconf_client_get_bool (
- client, COMPOSER_GCONF_MAGIC_LINKS_KEY, &error);
- if (error == NULL)
- gtkhtml_editor_set_magic_links (editor, enable);
- else {
- g_warning ("%s", error->message);
- g_clear_error (&error);
- }
-
- enable = gconf_client_get_bool (
- client, COMPOSER_GCONF_MAGIC_SMILEYS_KEY, &error);
- if (error == NULL)
- gtkhtml_editor_set_magic_smileys (editor, enable);
- else {
- g_warning ("%s", error->message);
- g_clear_error (&error);
- }
-}
-
struct _drop_data {
EMsgComposer *composer;
@@ -1477,10 +1414,6 @@ struct _drop_data {
guint32 action;
guint info;
guint time;
-
- guint move:1;
- guint moved:1;
- guint aborted:1;
};
static void
@@ -1497,11 +1430,11 @@ msg_composer_constructor (GType type,
guint n_construct_properties,
GObjectConstructParam *construct_properties)
{
+ EShell *shell;
+ EShellSettings *shell_settings;
GObject *object;
EMsgComposer *composer;
GtkToggleAction *action;
- GList *spell_languages;
- GConfClient *client;
GArray *array;
gboolean active;
guint binding_id;
@@ -1511,9 +1444,11 @@ msg_composer_constructor (GType type,
type, n_construct_properties, construct_properties);
composer = E_MSG_COMPOSER (object);
- client = gconf_client_get_default ();
array = composer->priv->gconf_bridge_binding_ids;
+ shell = e_shell_get_default ();
+ shell_settings = e_shell_get_shell_settings (shell);
+
/* Restore Persistent State */
binding_id = gconf_bridge_bind_property (
@@ -1530,29 +1465,16 @@ msg_composer_constructor (GType type,
/* Honor User Preferences */
- active = gconf_client_get_bool (
- client, COMPOSER_GCONF_SEND_HTML_KEY, NULL);
+ active = e_shell_settings_get_boolean (
+ shell_settings, "composer-format-html");
gtkhtml_editor_set_html_mode (GTKHTML_EDITOR (composer), active);
action = GTK_TOGGLE_ACTION (ACTION (REQUEST_READ_RECEIPT));
- active = gconf_client_get_bool (
- client, COMPOSER_GCONF_REQUEST_RECEIPT_KEY, NULL);
+ active = e_shell_settings_get_boolean (
+ shell_settings, "composer-request-receipt");
gtk_toggle_action_set_active (action, active);
- spell_languages = e_load_spell_languages ();
- gtkhtml_editor_set_spell_languages (
- GTKHTML_EDITOR (composer), spell_languages);
- g_list_free (spell_languages);
-
- gconf_client_add_dir (
- client, COMPOSER_GCONF_PREFIX,
- GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
- composer->priv->notify_id = gconf_client_notify_add (
- client, COMPOSER_GCONF_PREFIX, (GConfClientNotifyFunc)
- msg_composer_update_preferences, composer, NULL, NULL);
- msg_composer_update_preferences (client, 0, NULL, composer);
-
- g_object_unref (client);
+ e_shell_watch_window (shell, GTK_WINDOW (object));
return object;
}
@@ -1599,15 +1521,6 @@ msg_composer_destroy (GtkObject *object)
composer->priv->address_dialog = NULL;
}
- if (composer->priv->notify_id) {
- GConfClient *client;
-
- client = gconf_client_get_default ();
- gconf_client_notify_remove (client, composer->priv->notify_id);
- composer->priv->notify_id = 0;
- g_object_unref (client);
- }
-
/* Chain up to parent's destroy() method. */
GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
@@ -1815,7 +1728,7 @@ msg_composer_paste_clipboard (GtkhtmlEditor *editor)
clipboard = gtk_widget_get_clipboard (widget, GDK_SELECTION_CLIPBOARD);
/* Assume the clipboard has an image. The return
- * value will be NULL we we assumed wrong. */
+ * value will be NULL if we assumed wrong. */
pixbuf = gtk_clipboard_wait_for_image (clipboard);
if (!GDK_IS_PIXBUF (pixbuf))
goto chainup;
@@ -2126,7 +2039,7 @@ msg_composer_class_init (EMsgComposerClass *class)
signals[SEND] = g_signal_new (
"send",
- E_TYPE_MSG_COMPOSER,
+ G_OBJECT_CLASS_TYPE (class),
G_SIGNAL_RUN_LAST,
0, NULL, NULL,
g_cclosure_marshal_VOID__VOID,
@@ -2134,11 +2047,20 @@ msg_composer_class_init (EMsgComposerClass *class)
signals[SAVE_DRAFT] = g_signal_new (
"save-draft",
- E_TYPE_MSG_COMPOSER,
+ G_OBJECT_CLASS_TYPE (class),
G_SIGNAL_RUN_LAST,
0, NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
+
+ signals[PRINT] = g_signal_new (
+ "print",
+ G_OBJECT_CLASS_TYPE (class),
+ G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL,
+ g_cclosure_marshal_VOID__ENUM,
+ G_TYPE_NONE, 1,
+ GTK_TYPE_PRINT_OPERATION_ACTION);
}
static void
@@ -2153,6 +2075,7 @@ msg_composer_init (EMsgComposer *composer)
GtkUIManager *ui_manager;
GtkhtmlEditor *editor;
GtkHTML *html;
+ const gchar *id;
gint n_targets;
composer->lite = composer_lite;
@@ -2190,9 +2113,9 @@ msg_composer_init (EMsgComposer *composer)
/* Configure Headers */
e_composer_header_table_set_account_list (
- table, mail_config_get_accounts ());
+ table, e_get_account_list ());
e_composer_header_table_set_signature_list (
- table, mail_config_get_signatures ());
+ table, e_get_signature_list ());
g_signal_connect_swapped (
table, "notify::account",
@@ -2242,8 +2165,9 @@ msg_composer_init (EMsgComposer *composer)
/* Initialization may have tripped the "changed" state. */
gtkhtml_editor_set_changed (editor, FALSE);
- e_plugin_ui_register_manager (
- "org.gnome.evolution.composer", ui_manager, composer);
+ id = "org.gnome.evolution.composer";
+ e_plugin_ui_register_manager (ui_manager, id, composer);
+ e_plugin_ui_enable_manager (ui_manager, id);
}
GType
@@ -2486,7 +2410,7 @@ handle_multipart_signed (EMsgComposer *composer,
gchar *html;
gssize length;
- html = em_utils_part_to_html (mime_part, &length, NULL);
+ html = emcu_part_to_html (mime_part, &length, NULL);
e_msg_composer_set_pending_body (composer, html, length);
} else {
e_msg_composer_attach (composer, mime_part);
@@ -2502,6 +2426,7 @@ handle_multipart_encrypted (EMsgComposer *composer,
CamelCipherContext *cipher;
CamelDataWrapper *content;
CamelMimePart *mime_part;
+ CamelSession *session;
CamelException ex;
CamelCipherValidity *valid;
GtkToggleAction *action;
@@ -2511,7 +2436,8 @@ handle_multipart_encrypted (EMsgComposer *composer,
gtk_toggle_action_set_active (action, TRUE);
camel_exception_init (&ex);
- cipher = mail_crypto_get_pgp_cipher_context (NULL);
+ session = e_msg_composer_get_session (composer);
+ cipher = camel_gpg_context_new (session);
mime_part = camel_mime_part_new ();
valid = camel_cipher_decrypt (cipher, multipart, mime_part, &ex);
camel_object_unref (cipher);
@@ -2549,7 +2475,7 @@ handle_multipart_encrypted (EMsgComposer *composer,
gchar *html;
gssize length;
- html = em_utils_part_to_html (mime_part, &length, NULL);
+ html = emcu_part_to_html (mime_part, &length, NULL);
e_msg_composer_set_pending_body (composer, html, length);
} else {
e_msg_composer_attach (composer, mime_part);
@@ -2615,7 +2541,7 @@ handle_multipart_alternative (EMsgComposer *composer,
gchar *html;
gssize length;
- html = em_utils_part_to_html (text_part, &length, NULL);
+ html = emcu_part_to_html (text_part, &length, NULL);
e_msg_composer_set_pending_body (composer, html, length);
}
}
@@ -2665,7 +2591,7 @@ handle_multipart (EMsgComposer *composer,
/* Since the first part is not multipart/alternative,
* this must be the body. */
- html = em_utils_part_to_html (mime_part, &length, NULL);
+ html = emcu_part_to_html (mime_part, &length, NULL);
e_msg_composer_set_pending_body (composer, html, length);
} else if (camel_mime_part_get_content_id (mime_part) ||
camel_mime_part_get_content_location (mime_part)) {
@@ -2696,11 +2622,11 @@ set_signature_gui (EMsgComposer *composer)
data = gtkhtml_editor_get_paragraph_data (editor, "signature_name");
if (g_str_has_prefix (data, "uid:")) {
decoded = decode_signature_name (data + 4);
- signature = mail_config_get_signature_by_uid (decoded);
+ signature = e_get_signature_by_uid (decoded);
g_free (decoded);
} else if (g_str_has_prefix (data, "name:")) {
decoded = decode_signature_name (data + 5);
- signature = mail_config_get_signature_by_name (decoded);
+ signature = e_get_signature_by_name (decoded);
g_free (decoded);
}
@@ -2757,10 +2683,12 @@ e_msg_composer_new_with_message (CamelMimeMessage *message)
account_name = g_strdup (account_name);
g_strstrip (account_name);
- if ((account = mail_config_get_account_by_uid (account_name)) == NULL)
- /* 'old' setting */
- account = mail_config_get_account_by_name (account_name);
- if (account) {
+ account = e_get_account_by_uid (account_name);
+ if (account == NULL)
+ /* XXX Backwards compatibility */
+ account = e_get_account_by_name (account_name);
+
+ if (account != NULL) {
g_free (account_name);
account_name = g_strdup (account->name);
}
@@ -2925,7 +2853,7 @@ e_msg_composer_new_with_message (CamelMimeMessage *message)
}
/* Remove any other X-Evolution-* headers that may have been set */
- xev = mail_tool_remove_xevolution_headers (message);
+ xev = emcu_remove_xevolution_headers (message);
camel_header_raw_clear (&xev);
/* Check for receipt request */
@@ -2981,7 +2909,7 @@ e_msg_composer_new_with_message (CamelMimeMessage *message)
gchar *html;
gssize length;
- html = em_utils_part_to_html ((CamelMimePart *)message, &length, NULL);
+ html = emcu_part_to_html ((CamelMimePart *)message, &length, NULL);
e_msg_composer_set_pending_body (composer, html, length);
}
@@ -3054,6 +2982,35 @@ e_msg_composer_new_redirect (CamelMimeMessage *message,
}
/**
+ * e_msg_composer_get_session:
+ * @composer: an #EMsgComposer
+ *
+ * Returns the mail module's global #CamelSession instance. Calling
+ * this function will load the mail module if it isn't already loaded.
+ *
+ * Returns: the mail module's #CamelSession
+ **/
+CamelSession *
+e_msg_composer_get_session (EMsgComposer *composer)
+{
+ EShell *shell;
+ EShellSettings *shell_settings;
+ CamelSession *session;
+
+ /* FIXME EMsgComposer should own a reference to EShell. */
+
+ g_return_val_if_fail (E_IS_MSG_COMPOSER (composer), NULL);
+
+ shell = e_shell_get_default ();
+ shell_settings = e_shell_get_shell_settings (shell);
+
+ session = e_shell_settings_get_pointer (shell_settings, "mail-session");
+ g_return_val_if_fail (CAMEL_IS_SESSION (session), NULL);
+
+ return session;
+}
+
+/**
* e_msg_composer_send:
* @composer: an #EMsgComposer
*
@@ -3089,6 +3046,22 @@ e_msg_composer_save_draft (EMsgComposer *composer)
e_composer_autosave_set_saved (composer, FALSE);
}
+/**
+ * e_msg_composer_print:
+ * @composer: an #EMsgComposer
+ * @action: the print action to start
+ *
+ * Print the message in @composer.
+ **/
+void
+e_msg_composer_print (EMsgComposer *composer,
+ GtkPrintOperationAction action)
+{
+ g_return_if_fail (E_IS_MSG_COMPOSER (composer));
+
+ g_signal_emit (composer, signals[PRINT], 0, action);
+}
+
static GList *
add_recipients (GList *list, const gchar *recips)
{
@@ -3575,7 +3548,7 @@ e_msg_composer_get_message (EMsgComposer *composer,
store = e_attachment_view_get_store (view);
if (e_attachment_store_get_num_loading (store) > 0) {
- if (!em_utils_prompt_user (GTK_WINDOW (composer), NULL,
+ if (!emcu_prompt_user (GTK_WINDOW (composer), NULL,
"mail-composer:ask-send-message-pending-download", NULL)) {
return NULL;
}
@@ -3752,7 +3725,6 @@ e_msg_composer_show_sig_file (EMsgComposer *composer)
GtkhtmlEditor *editor;
GtkHTML *html;
gchar *html_text;
- gboolean top_signature;
g_return_if_fail (E_IS_MSG_COMPOSER (composer));
@@ -3779,8 +3751,6 @@ e_msg_composer_show_sig_file (EMsgComposer *composer)
}
gtkhtml_editor_run_command (editor, "unblock-selection");
- top_signature = is_top_signature ();
-
html_text = get_signature_html (composer);
if (html_text) {
gtkhtml_editor_run_command (editor, "insert-paragraph");
@@ -3794,10 +3764,6 @@ e_msg_composer_show_sig_file (EMsgComposer *composer)
gtkhtml_editor_run_command (editor, "style-normal");
gtkhtml_editor_insert_html (editor, html_text);
g_free (html_text);
- } else if (top_signature) {
- /* insert paragraph after the signature ClueFlow things */
- gtkhtml_editor_run_command (editor, "cursor-forward");
- gtkhtml_editor_run_command (editor, "insert-paragraph");
}
gtkhtml_editor_undo_end (editor);
@@ -3939,17 +3905,8 @@ e_msg_composer_load_from_file (const gchar *filename)
camel_object_unref (stream);
composer = e_msg_composer_new_with_message (msg);
- if (composer != NULL) {
- g_signal_connect (
- composer, "send",
- G_CALLBACK (em_utils_composer_send_cb), NULL);
-
- g_signal_connect (
- composer, "save-draft",
- G_CALLBACK (em_utils_composer_save_draft_cb), NULL);
-
+ if (composer != NULL)
gtk_widget_show (GTK_WIDGET (composer));
- }
return composer;
}
diff --git a/composer/e-msg-composer.h b/composer/e-msg-composer.h
index 434f330e9a..1d5eb39d80 100644
--- a/composer/e-msg-composer.h
+++ b/composer/e-msg-composer.h
@@ -25,6 +25,7 @@
#include <camel/camel-internet-address.h>
#include <camel/camel-mime-message.h>
+#include <camel/camel-session.h>
#include <libedataserver/e-account.h>
#include <libebook/e-destination.h>
#include <gtkhtml-editor.h>
@@ -67,21 +68,21 @@ struct _EMsgComposerClass {
GtkhtmlEditorClass parent_class;
};
-struct _EAttachmentBar;
-
GType e_msg_composer_get_type (void);
EMsgComposer * e_msg_composer_new (void);
-EMsgComposer * e_msg_composer_lite_new (void);
-
+void e_msg_composer_set_lite (void);
+gboolean e_msg_composer_get_lite (void);
+EMsgComposer * e_msg_composer_lite_new (void);
EMsgComposer * e_msg_composer_new_with_message (CamelMimeMessage *msg);
EMsgComposer * e_msg_composer_new_from_url (const gchar *url);
EMsgComposer * e_msg_composer_new_redirect (CamelMimeMessage *message,
const gchar *resent_from);
-void e_msg_composer_set_lite (void);
-gboolean e_msg_composer_get_lite (void);
+CamelSession * e_msg_composer_get_session (EMsgComposer *composer);
void e_msg_composer_send (EMsgComposer *composer);
void e_msg_composer_save_draft (EMsgComposer *composer);
+void e_msg_composer_print (EMsgComposer *composer,
+ GtkPrintOperationAction action);
void e_msg_composer_set_alternative (EMsgComposer *composer,
gboolean alt);
@@ -129,9 +130,6 @@ void e_msg_composer_set_enable_autosave
(EMsgComposer *composer,
gboolean enabled);
-gchar * e_msg_composer_get_sig_file_content
- (const gchar *sigfile,
- gboolean in_html);
void e_msg_composer_add_message_attachments
(EMsgComposer *composer,
CamelMimeMessage *message,