diff options
author | Radek Doulik <rodo@src.gnome.org> | 2000-11-09 01:31:57 +0800 |
---|---|---|
committer | Radek Doulik <rodo@src.gnome.org> | 2000-11-09 01:31:57 +0800 |
commit | c13e8b432e8f4bd16176e462cfd548aa00f2b922 (patch) | |
tree | 8c798afc89be9ae897e83f32851caabb3e6b114e | |
parent | 23604a297a7eb5331133c104a04cf5ac363606b7 (diff) | |
download | gsoc2013-evolution-c13e8b432e8f4bd16176e462cfd548aa00f2b922.tar gsoc2013-evolution-c13e8b432e8f4bd16176e462cfd548aa00f2b922.tar.gz gsoc2013-evolution-c13e8b432e8f4bd16176e462cfd548aa00f2b922.tar.bz2 gsoc2013-evolution-c13e8b432e8f4bd16176e462cfd548aa00f2b922.tar.lz gsoc2013-evolution-c13e8b432e8f4bd16176e462cfd548aa00f2b922.tar.xz gsoc2013-evolution-c13e8b432e8f4bd16176e462cfd548aa00f2b922.tar.zst gsoc2013-evolution-c13e8b432e8f4bd16176e462cfd548aa00f2b922.zip |
(get_signature): added in_html arg, it tells if we should use HTML
signature
(set_editor_text): try to use HTML signature
(e_msg_composer_new_with_sig_file): added send_html arg to be able
to use HTML signature
svn path=/trunk/; revision=6510
-rw-r--r-- | composer/ChangeLog | 5 | ||||
-rw-r--r-- | composer/e-msg-composer.c | 59 | ||||
-rw-r--r-- | composer/e-msg-composer.h | 3 |
3 files changed, 44 insertions, 23 deletions
diff --git a/composer/ChangeLog b/composer/ChangeLog index 9661b929a9..4681985dae 100644 --- a/composer/ChangeLog +++ b/composer/ChangeLog @@ -4,6 +4,11 @@ function (destroy): use e_msg_composer_clear_inlined_table, destroy inlined_images hash table + (get_signature): added in_html arg, it tells if we should use HTML + signature + (set_editor_text): try to use HTML signature + (e_msg_composer_new_with_sig_file): added send_html arg to be able + to use HTML signature * listener.c (resolve_image_url): don't add inlined images to attachement bar diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c index 2b3e8f9376..37c2846762 100644 --- a/composer/e-msg-composer.c +++ b/composer/e-msg-composer.c @@ -396,39 +396,43 @@ build_message (EMsgComposer *composer) } static char * -get_signature (const char *sigfile) +get_signature (const char *sigfile, gboolean in_html) { GString *rawsig; - char buf[1024]; - char *htmlsig = NULL; + gchar buf[1024]; + gchar *file_name; + gchar *htmlsig = NULL; int fd, n; - + if (!sigfile || !*sigfile) { return NULL; } + + file_name = in_html ? g_strconcat (sigfile, ".html", NULL) : (gchar *) sigfile; - fd = open (sigfile, O_RDONLY); + fd = open (file_name, O_RDONLY); if (fd == -1) { char *msg; msg = g_strdup_printf (_("Could not open signature file %s:\n" - "%s"), sigfile, g_strerror (errno)); + "%s"), file_name, g_strerror (errno)); gnome_error_dialog (msg); g_free (msg); - return NULL; - } - - rawsig = g_string_new (""); - while ((n = read (fd, buf, 1023)) > 0) { - buf[n] = '\0'; - g_string_append (rawsig, buf); + htmlsig = NULL; + } else { + rawsig = g_string_new (""); + while ((n = read (fd, buf, 1023)) > 0) { + buf[n] = '\0'; + g_string_append (rawsig, buf); + } + close (fd); + + htmlsig = in_html ? rawsig->str : e_text_to_html (rawsig->str, 0); + g_string_free (rawsig, !in_html); } - close (fd); - - htmlsig = e_text_to_html (rawsig->str, 0); - g_string_free (rawsig, TRUE); - + if (in_html) g_free (file_name); + return htmlsig; } @@ -485,11 +489,21 @@ set_editor_text (EMsgComposer *composer, const char *sig_file, const char *text) BonoboWidget *editor; CORBA_Environment ev; char *sig, *fulltext; - + gboolean html_sig = composer->send_html; + editor = BONOBO_WIDGET (composer->editor); - sig = get_signature (sig_file); + sig = get_signature (sig_file, html_sig); + /* if we tried HTML sig and it's not available, try also non HTML signature */ + if (html_sig && !sig) { + html_sig = FALSE; + sig = get_signature (sig_file, html_sig); + } + if (sig) { - if (!strncmp ("-- \n", sig, 3)) + if (html_sig) + fulltext = g_strdup_printf ("%s<br>%s", + text, sig); + else if (!strncmp ("-- \n", sig, 3)) fulltext = g_strdup_printf ("%s<br>\n<pre>\n%s</pre>", text, sig); else @@ -1423,12 +1437,13 @@ e_msg_composer_new (void) * Return value: A pointer to the newly created widget **/ EMsgComposer * -e_msg_composer_new_with_sig_file (const char *sig_file) +e_msg_composer_new_with_sig_file (const char *sig_file, gboolean send_html) { EMsgComposer *new; new = create_composer (); if (new) { + e_msg_composer_set_send_html (new, send_html); /* Load the signature, if any. */ set_editor_text (new, sig_file, ""); diff --git a/composer/e-msg-composer.h b/composer/e-msg-composer.h index 77ba51c944..f5de97cbf2 100644 --- a/composer/e-msg-composer.h +++ b/composer/e-msg-composer.h @@ -86,7 +86,8 @@ struct _EMsgComposerClass { GtkType e_msg_composer_get_type (void); void e_msg_composer_construct (EMsgComposer *composer); EMsgComposer *e_msg_composer_new (void); -EMsgComposer *e_msg_composer_new_with_sig_file (const char *sig_file); +EMsgComposer *e_msg_composer_new_with_sig_file (const char *sig_file, + gboolean send_html); EMsgComposer *e_msg_composer_new_with_message (CamelMimeMessage *msg); EMsgComposer *e_msg_composer_new_from_url (const char *url); void e_msg_composer_show_attachments (EMsgComposer *composer, |