aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEttore Perazzoli <ettore@src.gnome.org>2000-07-23 21:55:13 +0800
committerEttore Perazzoli <ettore@src.gnome.org>2000-07-23 21:55:13 +0800
commite3f8e22df0178b8c471f0a4f6e57ac76d1f1c36c (patch)
tree58a8929b11f8e3d517a953b37d0a4e800e256716
parenta80bd46ba3507bfceb1a70300f71aef1ea821e75 (diff)
downloadgsoc2013-evolution-e3f8e22df0178b8c471f0a4f6e57ac76d1f1c36c.tar
gsoc2013-evolution-e3f8e22df0178b8c471f0a4f6e57ac76d1f1c36c.tar.gz
gsoc2013-evolution-e3f8e22df0178b8c471f0a4f6e57ac76d1f1c36c.tar.bz2
gsoc2013-evolution-e3f8e22df0178b8c471f0a4f6e57ac76d1f1c36c.tar.lz
gsoc2013-evolution-e3f8e22df0178b8c471f0a4f6e57ac76d1f1c36c.tar.xz
gsoc2013-evolution-e3f8e22df0178b8c471f0a4f6e57ac76d1f1c36c.tar.zst
gsoc2013-evolution-e3f8e22df0178b8c471f0a4f6e57ac76d1f1c36c.zip
Add a "Send HTML mail" toggle in the message composer.
svn path=/trunk/; revision=4284
-rw-r--r--composer/ChangeLog24
-rw-r--r--composer/e-msg-composer.c216
-rw-r--r--composer/e-msg-composer.h5
-rw-r--r--mail/ChangeLog5
-rw-r--r--mail/mail-ops.c37
5 files changed, 211 insertions, 76 deletions
diff --git a/composer/ChangeLog b/composer/ChangeLog
index 184b915b65..780e111585 100644
--- a/composer/ChangeLog
+++ b/composer/ChangeLog
@@ -1,5 +1,29 @@
2000-07-23 Ettore Perazzoli <ettore@helixcode.com>
+ * e-msg-composer.c (menu_format_html_cb): New callback for the
+ "Send HTML" menu toggle item.
+ (create_menubar_format): New.
+ (create_menubar): Call it.
+ (create_menubar_options): Removed.
+ (init): Initialize `send_html' and `attachment_bar_visible' to
+ FALSE.
+ (get_signature): Add `void' to the declaration. This is C, not
+ C++.
+ (menu_file_close_cb): Renamed from `exit_cb'.
+ (menu_file_send_cb): Renamed from `send_cb'.
+ (menu_file_save_as_cb): Renamed from `save_as_cb'.
+ (menu_file_save_cb): Renamed from `save_cb'.
+ (menu_file_open_cb): Renamed from `open_cb'.
+ (menu_file_add_attachment_cb): Renamed from `add_attachment_cb'.
+ (menu_file_insert_file_cb): Renamed from `insert_file_cb'.
+ (e_msg_composer_set_send_html): New.
+ (build_message): Use the `send_html' flag instead of peeking the
+ `msg_format' gnome-config value directly.
+
+ * e-msg-composer.h: New member `send_html' in `EMsgComposer'.
+
+2000-07-23 Ettore Perazzoli <ettore@helixcode.com>
+
* e-msg-composer.c: Changed to use BonoboUIHandler stuff directly
instead of translating from GnomeUIInfo.
(create_menubar_file): New.
diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c
index e537d7575b..7249350d0e 100644
--- a/composer/e-msg-composer.c
+++ b/composer/e-msg-composer.c
@@ -60,7 +60,7 @@
#define HTML_EDITOR_CONTROL_ID "control:html-editor"
#endif
-
+
#define DEFAULT_WIDTH 600
#define DEFAULT_HEIGHT 500
@@ -74,6 +74,7 @@ static guint signals[LAST_SIGNAL] = { 0 };
static GnomeAppClass *parent_class = NULL;
+
static GtkWidget *
create_editor (EMsgComposer *composer)
{
@@ -207,20 +208,15 @@ build_message (EMsgComposer *composer)
CamelMimePart *part;
char *html = NULL, *plain = NULL, *fmt = NULL;
int i;
- char *string;
MsgFormat type = MSG_FORMAT_ALTERNATIVE;
- char *path;
if (composer->persist_stream_interface == CORBA_OBJECT_NIL)
return NULL;
- path = g_strdup_printf ("=%s/config=/mail/msg_format", evolution_dir);
- string = gnome_config_get_string (path);
- g_free (path);
- if (string) {
- if (!strcasecmp(string, "plain"))
- type = MSG_FORMAT_PLAIN;
- }
+ if (composer->send_html)
+ type = MSG_FORMAT_ALTERNATIVE;
+ else
+ type = MSG_FORMAT_PLAIN;
new = camel_mime_message_new ();
@@ -310,7 +306,7 @@ build_message (EMsgComposer *composer)
}
static char *
-get_signature ()
+get_signature (void)
{
char *path, *sigfile, *rawsig;
static char *htmlsig = NULL;
@@ -501,12 +497,12 @@ do_exit (EMsgComposer *composer)
}
-/* Message composer window callbacks. */
+/* Menu callbacks. */
static void
-open_cb (BonoboUIHandler *uih,
- void *data,
- const char *path)
+menu_file_open_cb (BonoboUIHandler *uih,
+ void *data,
+ const char *path)
{
EMsgComposer *composer;
char *file_name;
@@ -523,9 +519,9 @@ open_cb (BonoboUIHandler *uih,
}
static void
-save_cb (BonoboUIHandler *uih,
- void *data,
- const char *path)
+menu_file_save_cb (BonoboUIHandler *uih,
+ void *data,
+ const char *path)
{
EMsgComposer *composer;
CORBA_char *file_name;
@@ -548,9 +544,9 @@ save_cb (BonoboUIHandler *uih,
}
static void
-save_as_cb (BonoboUIHandler *uih,
- void *data,
- const char *path)
+menu_file_save_as_cb (BonoboUIHandler *uih,
+ void *data,
+ const char *path)
{
EMsgComposer *composer;
@@ -560,18 +556,18 @@ save_as_cb (BonoboUIHandler *uih,
}
static void
-send_cb (BonoboUIHandler *uih,
- void *data,
- const char *path)
+menu_file_send_cb (BonoboUIHandler *uih,
+ void *data,
+ const char *path)
{
/* FIXME: We should really write this to Outbox in the future? */
gtk_signal_emit (GTK_OBJECT (data), signals[SEND]);
}
static void
-exit_cb (BonoboUIHandler *uih,
- void *data,
- const char *path)
+menu_file_close_cb (BonoboUIHandler *uih,
+ void *data,
+ const char *path)
{
EMsgComposer *composer;
@@ -580,20 +576,9 @@ exit_cb (BonoboUIHandler *uih,
}
static void
-menu_view_attachments_activate_cb (BonoboUIHandler *uih,
- void *data,
- const char *path)
-{
- gboolean state;
-
- state = bonobo_ui_handler_menu_get_toggle_state (uih, path);
- e_msg_composer_show_attachments (E_MSG_COMPOSER (data), state);
-}
-
-static void
-add_attachment_cb (BonoboUIHandler *uih,
- void *data,
- const char *path)
+menu_file_add_attachment_cb (BonoboUIHandler *uih,
+ void *data,
+ const char *path)
{
EMsgComposer *composer;
@@ -605,6 +590,17 @@ add_attachment_cb (BonoboUIHandler *uih,
}
static void
+menu_view_attachments_activate_cb (BonoboUIHandler *uih,
+ void *data,
+ const char *path)
+{
+ gboolean state;
+
+ state = bonobo_ui_handler_menu_get_toggle_state (uih, path);
+ e_msg_composer_show_attachments (E_MSG_COMPOSER (data), state);
+}
+
+static void
insert_file_ok_cb (GtkWidget *widget, void *user_data)
{
GtkFileSelection *fs;
@@ -751,7 +747,7 @@ insert_file_ok_cb (GtkWidget *widget, void *user_data)
}
static void
-insert_file_cb (BonoboUIHandler *uih,
+menu_file_insert_file_cb (BonoboUIHandler *uih,
void *data,
const char *path)
{
@@ -773,21 +769,24 @@ insert_file_cb (BonoboUIHandler *uih,
}
static void
-attachment_bar_changed_cb (EMsgComposerAttachmentBar *bar,
- void *data)
+menu_format_html_cb (BonoboUIHandler *uih,
+ void *data,
+ const char *path)
{
EMsgComposer *composer;
-
+ gboolean new_state;
+
composer = E_MSG_COMPOSER (data);
- if (e_msg_composer_attachment_bar_get_num_attachments (bar) > 0)
- e_msg_composer_show_attachments (composer, TRUE);
- else
- e_msg_composer_show_attachments (composer, FALSE);
+ new_state = bonobo_ui_handler_menu_get_toggle_state (uih, path);
+ if ((new_state && composer->send_html) || (! new_state && ! composer->send_html))
+ return;
+
+ e_msg_composer_set_send_html (composer, new_state);
}
-/* Menu bar implementation. */
+/* Menu bar creation. */
static void
create_menubar_file (EMsgComposer *composer,
@@ -806,7 +805,7 @@ create_menubar_file (EMsgComposer *composer,
BONOBO_UI_HANDLER_PIXMAP_STOCK,
GNOME_STOCK_MENU_OPEN,
0, 0,
- open_cb, composer);
+ menu_file_open_cb, composer);
bonobo_ui_handler_menu_new_item (uih, "/File/Save",
_("_Save..."),
@@ -815,7 +814,7 @@ create_menubar_file (EMsgComposer *composer,
BONOBO_UI_HANDLER_PIXMAP_STOCK,
GNOME_STOCK_MENU_SAVE,
0, 0,
- save_cb, composer);
+ menu_file_save_cb, composer);
bonobo_ui_handler_menu_new_item (uih, "/File/Save as",
_("_Save as..."),
@@ -824,7 +823,7 @@ create_menubar_file (EMsgComposer *composer,
BONOBO_UI_HANDLER_PIXMAP_STOCK,
GNOME_STOCK_MENU_SAVE_AS,
0, 0,
- save_as_cb, composer);
+ menu_file_save_as_cb, composer);
bonobo_ui_handler_menu_new_item (uih, "/File/Save in folder",
_("Save in _folder..."),
@@ -842,7 +841,7 @@ create_menubar_file (EMsgComposer *composer,
-1,
BONOBO_UI_HANDLER_PIXMAP_NONE, NULL,
0, 0,
- insert_file_cb, composer);
+ menu_file_insert_file_cb, composer);
bonobo_ui_handler_menu_new_separator (uih, "/File/Separator2", -1);
@@ -853,7 +852,7 @@ create_menubar_file (EMsgComposer *composer,
BONOBO_UI_HANDLER_PIXMAP_STOCK,
GNOME_STOCK_MENU_MAIL_SND,
0, 0,
- send_cb, composer);
+ menu_file_send_cb, composer);
bonobo_ui_handler_menu_new_separator (uih, "/File/Separator3", -1);
@@ -864,7 +863,7 @@ create_menubar_file (EMsgComposer *composer,
BONOBO_UI_HANDLER_PIXMAP_STOCK,
GNOME_STOCK_MENU_CLOSE,
0, 0,
- exit_cb, composer);
+ menu_file_close_cb, composer);
}
static void
@@ -879,6 +878,26 @@ create_menubar_edit (EMsgComposer *composer,
}
static void
+create_menubar_format (EMsgComposer *composer,
+ BonoboUIHandler *uih)
+{
+ bonobo_ui_handler_menu_new_subtree (uih, "/Format",
+ _("_Format"),
+ NULL, -1,
+ BONOBO_UI_HANDLER_PIXMAP_NONE, NULL,
+ 0, 0);
+
+ bonobo_ui_handler_menu_new_toggleitem (uih, "/Format/HTML",
+ _("HTML"),
+ _("Send the mail in HTML format"),
+ -1,
+ 0, 0,
+ menu_format_html_cb, composer);
+
+ bonobo_ui_handler_menu_set_toggle_state (uih, "/Format/HTML", composer->send_html);
+}
+
+static void
create_menubar_view (EMsgComposer *composer,
BonoboUIHandler *uih)
{
@@ -897,17 +916,6 @@ create_menubar_view (EMsgComposer *composer,
}
static void
-create_menubar_options (EMsgComposer *composer,
- BonoboUIHandler *uih)
-{
- bonobo_ui_handler_menu_new_subtree (uih, "/Options",
- _("_Options"),
- NULL, -1,
- BONOBO_UI_HANDLER_PIXMAP_NONE, NULL,
- 0, 0);
-}
-
-static void
create_menubar (EMsgComposer *composer)
{
BonoboUIHandler *uih;
@@ -915,10 +923,10 @@ create_menubar (EMsgComposer *composer)
uih = composer->uih;
bonobo_ui_handler_create_menubar (uih);
- create_menubar_file (composer, uih);
- create_menubar_edit (composer, uih);
- create_menubar_view (composer, uih);
- create_menubar_options (composer, uih);
+ create_menubar_file (composer, uih);
+ create_menubar_edit (composer, uih);
+ create_menubar_format (composer, uih);
+ create_menubar_view (composer, uih);
}
@@ -940,7 +948,7 @@ create_toolbar (EMsgComposer *composer)
BONOBO_UI_HANDLER_PIXMAP_STOCK,
GNOME_STOCK_PIXMAP_MAIL_SND,
0, 0,
- send_cb, composer);
+ menu_file_send_cb, composer);
bonobo_ui_handler_toolbar_new_item (uih,
"/Toolbar/Attach",
@@ -950,7 +958,24 @@ create_toolbar (EMsgComposer *composer)
BONOBO_UI_HANDLER_PIXMAP_STOCK,
GNOME_STOCK_PIXMAP_ATTACH,
0, 0,
- add_attachment_cb, composer);
+ menu_file_add_attachment_cb, composer);
+}
+
+
+/* Miscellaneous callbacks. */
+
+static void
+attachment_bar_changed_cb (EMsgComposerAttachmentBar *bar,
+ void *data)
+{
+ EMsgComposer *composer;
+
+ composer = E_MSG_COMPOSER (data);
+
+ if (e_msg_composer_attachment_bar_get_num_attachments (bar) > 0)
+ e_msg_composer_show_attachments (composer, TRUE);
+ else
+ e_msg_composer_show_attachments (composer, FALSE);
}
@@ -1068,8 +1093,12 @@ init (EMsgComposer *composer)
composer->persist_file_interface = CORBA_OBJECT_NIL;
composer->persist_stream_interface = CORBA_OBJECT_NIL;
+
+ composer->attachment_bar_visible = FALSE;
+ composer->send_html = FALSE;
}
+
GtkType
e_msg_composer_get_type (void)
{
@@ -1438,3 +1467,44 @@ e_msg_composer_get_message (EMsgComposer *composer)
return build_message (composer);
}
+
+
+/**
+ * e_msg_composer_set_send_html:
+ * @composer: A message composer widget
+ * @send_html: Whether the composer should have the "Send HTML" flag set
+ *
+ * Set the status of the "Send HTML" toggle item. The user can override it.
+ **/
+void
+e_msg_composer_set_send_html (EMsgComposer *composer,
+ gboolean send_html)
+{
+ g_return_if_fail (composer != NULL);
+ g_return_if_fail (E_IS_MSG_COMPOSER (composer));
+
+ if (composer->send_html && send_html)
+ return;
+ if (! composer->send_html && ! send_html)
+ return;
+
+ composer->send_html = send_html;
+ bonobo_ui_handler_menu_set_toggle_state (composer->uih, "/Format/HTML", send_html);
+}
+
+/**
+ * e_msg_composer_get_send_html:
+ * @composer: A message composer widget
+ *
+ * Get the status of the "Send HTML mail" flag.
+ *
+ * Return value: The status of the "Send HTML mail" flag.
+ **/
+gboolean
+e_msg_composer_get_send_html (EMsgComposer *composer)
+{
+ g_return_val_if_fail (composer != NULL, FALSE);
+ g_return_val_if_fail (E_IS_MSG_COMPOSER (composer), FALSE);
+
+ return composer->send_html;
+}
diff --git a/composer/e-msg-composer.h b/composer/e-msg-composer.h
index a8abf611dc..2b802ffc19 100644
--- a/composer/e-msg-composer.h
+++ b/composer/e-msg-composer.h
@@ -65,6 +65,7 @@ struct _EMsgComposer {
Bonobo_PersistStream persist_stream_interface;
gboolean attachment_bar_visible : 1;
+ gboolean send_html : 1;
};
struct _EMsgComposerClass {
@@ -98,6 +99,10 @@ void e_msg_composer_attach (EMsgComposer *composer,
CamelMimeMessage *e_msg_composer_get_message (EMsgComposer *composer);
+void e_msg_composer_set_send_html (EMsgComposer *composer,
+ gboolean send_html);
+gboolean e_msg_composer_get_send_html (EMsgComposer *composer);
+
#ifdef __cplusplus
}
#endif /* __cplusplus */
diff --git a/mail/ChangeLog b/mail/ChangeLog
index b00f4e3086..5fff503a98 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,5 +1,10 @@
2000-07-23 Ettore Perazzoli <ettore@helixcode.com>
+ * mail-ops.c (create_message_composer): New.
+ (compose_msg): Use it.
+ (send_to_url): Likewise.
+ (forward_msg): Likewise.
+
* folder-browser-factory.c (control_activate): Use `_()' instead
of `N_()'.
diff --git a/mail/mail-ops.c b/mail/mail-ops.c
index 94cd42fae0..c28564aad8 100644
--- a/mail/mail-ops.c
+++ b/mail/mail-ops.c
@@ -568,6 +568,37 @@ free_psd (GtkWidget *composer, gpointer user_data)
g_free (psd);
}
+static GtkWidget *
+create_msg_composer (const char *url)
+{
+ GtkWidget *composer_widget;
+ gboolean send_html;
+ char *path;
+ char *string;
+
+ path = g_strdup_printf ("=%s/config=/mail/msg_format", evolution_dir);
+ string = gnome_config_get_string (path);
+ g_free (path);
+
+ if (string == NULL) {
+ send_html = FALSE;
+ } else {
+ if (!strcasecmp(string, "plain"))
+ send_html = FALSE;
+ else
+ send_html = TRUE;
+ }
+
+ if (url != NULL)
+ composer_widget = e_msg_composer_new_from_url (url);
+ else
+ composer_widget = e_msg_composer_new ();
+
+ e_msg_composer_set_send_html (E_MSG_COMPOSER (composer_widget), send_html);
+
+ return composer_widget;
+}
+
void
compose_msg (GtkWidget *widget, gpointer user_data)
{
@@ -576,7 +607,7 @@ compose_msg (GtkWidget *widget, gpointer user_data)
if (!check_configured ())
return;
- composer = e_msg_composer_new ();
+ composer = create_msg_composer (NULL);
gtk_signal_connect (GTK_OBJECT (composer), "send",
GTK_SIGNAL_FUNC (composer_send_cb), NULL);
@@ -592,7 +623,7 @@ send_to_url (const char *url)
if (!check_configured ())
return;
- composer = e_msg_composer_new_from_url (url);
+ composer = create_msg_composer (url);
gtk_signal_connect (GTK_OBJECT (composer), "send",
GTK_SIGNAL_FUNC (composer_send_cb), NULL);
@@ -681,7 +712,7 @@ forward_msg (GtkWidget *button, gpointer user_data)
if (!check_configured () || !cursor_msg)
return;
- composer = E_MSG_COMPOSER (e_msg_composer_new ());
+ composer = E_MSG_COMPOSER (create_msg_composer (NULL));
message_list_foreach (fb->message_list, attach_msg, composer);
from = camel_mime_message_get_from (cursor_msg);