diff options
author | Radek Doulik <rodo@ximian.com> | 2001-05-04 03:34:28 +0800 |
---|---|---|
committer | Radek Doulik <rodo@src.gnome.org> | 2001-05-04 03:34:28 +0800 |
commit | 57546880c8e3470834bb7012aee9d892e3ac6708 (patch) | |
tree | 7e35c5570ccc364da9b3eba8d3caa5203869e4c0 | |
parent | 8bf36627ed9264607917c0f46c23d260197875c2 (diff) | |
download | gsoc2013-evolution-57546880c8e3470834bb7012aee9d892e3ac6708.tar.gz gsoc2013-evolution-57546880c8e3470834bb7012aee9d892e3ac6708.tar.zst gsoc2013-evolution-57546880c8e3470834bb7012aee9d892e3ac6708.zip |
signature editing fixes
* signature editing fixes
2001-05-03 Radek Doulik <rodo@ximian.com>
* e-msg-composer.c (get_signature_html): put signature in 100%
width table
(delete_old_signature): look only for first flow with signature == 1
(e_msg_composer_new): don't insert <BR>
(e_msg_composer_new_with_sig_file): ditto
(delete_old_signature): don't delete whole signature paragraph,
but just it's content
(delete_old_signature): if signature isn't found, insert new empty
paragraph to end of document for new signature
(e_msg_composer_set_sig_file): delete signature always
(e_msg_composer_set_sig_file): don't place signature to the end of
document, but place it where previous one was (if there wasn't
then new one is appended to the document)
2001-05-02 Radek Doulik <rodo@ximian.com>
* listener.c (impl_event): do automagic indenting only when
in_signature_insert is FALSE
* e-msg-composer.c (e_msg_composer_set_sig_file): do indent-zero
before signature inserting
(e_msg_composer_set_sig_file): use in_signature_insert flag
2001-05-01 Radek Doulik <rodo@ximian.com>
* listener.c (impl_event): set signature to 0 in newly created
empty paragraphs
(clear_signature): new helper function
svn path=/trunk/; revision=9658
-rw-r--r-- | composer/ChangeLog | 31 | ||||
-rw-r--r-- | composer/e-msg-composer.c | 30 | ||||
-rw-r--r-- | composer/e-msg-composer.h | 2 | ||||
-rw-r--r-- | composer/listener.c | 35 |
4 files changed, 77 insertions, 21 deletions
diff --git a/composer/ChangeLog b/composer/ChangeLog index 5b5e66ac21..3d76a51b49 100644 --- a/composer/ChangeLog +++ b/composer/ChangeLog @@ -1,3 +1,34 @@ +2001-05-03 Radek Doulik <rodo@ximian.com> + + * e-msg-composer.c (get_signature_html): put signature in 100% + width table + (delete_old_signature): look only for first flow with signature == 1 + (e_msg_composer_new): don't insert <BR> + (e_msg_composer_new_with_sig_file): ditto + (delete_old_signature): don't delete whole signature paragraph, + but just it's content + (delete_old_signature): if signature isn't found, insert new empty + paragraph to end of document for new signature + (e_msg_composer_set_sig_file): delete signature always + (e_msg_composer_set_sig_file): don't place signature to the end of + document, but place it where previous one was (if there wasn't + then new one is appended to the document) + +2001-05-02 Radek Doulik <rodo@ximian.com> + + * listener.c (impl_event): do automagic indenting only when + in_signature_insert is FALSE + + * e-msg-composer.c (e_msg_composer_set_sig_file): do indent-zero + before signature inserting + (e_msg_composer_set_sig_file): use in_signature_insert flag + +2001-05-01 Radek Doulik <rodo@ximian.com> + + * listener.c (impl_event): set signature to 0 in newly created + empty paragraphs + (clear_signature): new helper function + 2001-04-26 Dan Winship <danw@ximian.com> * Makefile.am (INCLUDES): Remove UNICODE_CFLAGS diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c index 8565d9becf..dfd63ebf39 100644 --- a/composer/e-msg-composer.c +++ b/composer/e-msg-composer.c @@ -592,7 +592,10 @@ get_signature_html (EMsgComposer *composer) } if (text) { - html = g_strdup_printf ("<!--+GtkHTML:<DATA class=\"ClueFlow\" key=\"signature\" value=\"1\">-->%s%s%s%s", + html = g_strdup_printf ("<!--+GtkHTML:<DATA class=\"ClueFlow\" key=\"signature\" value=\"1\">-->" + "<TABLE WIDTH=\"100%%\" CELLSPACING=\"0\" CELLPADDING=\"0\"><TR><TD>" + "%s%s%s%s" + "</TD></TR></TABLE>", format_html ? "" : "<PRE>\n", format_html || !strncmp ("-- \n", text, 3) ? "" : "--\n", text, @@ -1845,7 +1848,7 @@ e_msg_composer_new (void) new = create_composer (); if (new) - set_editor_text (new, "<BR>"); + set_editor_text (new, ""); return new; } @@ -1865,7 +1868,7 @@ e_msg_composer_new_with_sig_file (const char *sig_file, gboolean send_html) new = create_composer (); if (new) { e_msg_composer_set_send_html (new, send_html); - set_editor_text (new, "<BR>"); + set_editor_text (new, ""); e_msg_composer_set_sig_file (new, sig_file); } @@ -2376,21 +2379,20 @@ static void delete_old_signature (EMsgComposer *composer) { CORBA_Environment ev; - CORBA_boolean rv; /* printf ("delete_old_signature\n"); */ CORBA_exception_init (&ev); GNOME_GtkHTML_Editor_Engine_runCommand (composer->editor_engine, "cursor-bod", &ev); - while (GNOME_GtkHTML_Editor_Engine_searchByData (composer->editor_engine, 1, "ClueFlow", "signature", "1", &ev)) { + if (GNOME_GtkHTML_Editor_Engine_searchByData (composer->editor_engine, 1, "ClueFlow", "signature", "1", &ev)) { /* printf ("found\n"); */ GNOME_GtkHTML_Editor_Engine_runCommand (composer->editor_engine, "select-paragraph", &ev); - rv = GNOME_GtkHTML_Editor_Engine_runCommand (composer->editor_engine, "selection-move-right", &ev); GNOME_GtkHTML_Editor_Engine_runCommand (composer->editor_engine, "delete", &ev); /* selection-move-right doesn't succeed means that we are already on the end of document */ - if (!rv) - break; - } - GNOME_GtkHTML_Editor_Engine_setParagraphData (composer->editor_engine, "signature", "0", &ev); + /* if (!rv) + break; */ + GNOME_GtkHTML_Editor_Engine_setParagraphData (composer->editor_engine, "signature", "0", &ev); + } else + GNOME_GtkHTML_Editor_Engine_runCommand (composer->editor_engine, "insert-paragraph", &ev); CORBA_exception_free (&ev); } @@ -2412,12 +2414,13 @@ e_msg_composer_set_sig_file (EMsgComposer *composer, const char *sig_file) /* printf ("set sig '%s' '%s'\n", sig_file, composer->sig_file); */ + composer->in_signature_insert = TRUE; CORBA_exception_init (&ev); GNOME_GtkHTML_Editor_Engine_freeze (composer->editor_engine, &ev); GNOME_GtkHTML_Editor_Engine_runCommand (composer->editor_engine, "cursor-position-save", &ev); GNOME_GtkHTML_Editor_Engine_undo_begin (composer->editor_engine, "Set signature", "Reset signature", &ev); - if (composer->sig_file) - delete_old_signature (composer); + + delete_old_signature (composer); if (composer->sig_file != sig_file && (!sig_file || !composer->sig_file || strcmp (composer->sig_file, sig_file))) { g_free (composer->sig_file); @@ -2426,10 +2429,10 @@ e_msg_composer_set_sig_file (EMsgComposer *composer, const char *sig_file) html = get_signature_html (composer); if (html) { - GNOME_GtkHTML_Editor_Engine_runCommand (composer->editor_engine, "cursor-eod", &ev); if (!GNOME_GtkHTML_Editor_Engine_isParagraphEmpty (composer->editor_engine, &ev)) GNOME_GtkHTML_Editor_Engine_runCommand (composer->editor_engine, "insert-paragraph", &ev); /* printf ("insert %s\n", html); */ + GNOME_GtkHTML_Editor_Engine_runCommand (composer->editor_engine, "indent-zero", &ev); GNOME_GtkHTML_Editor_Engine_insertHTML (composer->editor_engine, html, &ev); g_free (html); } @@ -2437,6 +2440,7 @@ e_msg_composer_set_sig_file (EMsgComposer *composer, const char *sig_file) GNOME_GtkHTML_Editor_Engine_runCommand (composer->editor_engine, "cursor-position-restore", &ev); GNOME_GtkHTML_Editor_Engine_thaw (composer->editor_engine, &ev); CORBA_exception_free (&ev); + composer->in_signature_insert = FALSE; } /** diff --git a/composer/e-msg-composer.h b/composer/e-msg-composer.h index 461430fd90..68aae2cc73 100644 --- a/composer/e-msg-composer.h +++ b/composer/e-msg-composer.h @@ -85,6 +85,8 @@ struct _EMsgComposer { gboolean view_cc : 1; gboolean view_subject : 1; gboolean has_changed : 1; + + gboolean in_signature_insert : 1; }; struct _EMsgComposerClass { diff --git a/composer/listener.c b/composer/listener.c index 8b13b0be64..0ed868a104 100644 --- a/composer/listener.c +++ b/composer/listener.c @@ -94,6 +94,18 @@ reply_indent (EditorListener *l, CORBA_Environment * ev) GNOME_GtkHTML_Editor_Engine_runCommand (l->composer->editor_engine, "cursor-position-restore", ev); } +static void +clear_signature (GNOME_GtkHTML_Editor_Engine e, CORBA_Environment * ev) +{ + if (GNOME_GtkHTML_Editor_Engine_isParagraphEmpty (e, ev)) + GNOME_GtkHTML_Editor_Engine_setParagraphData (e, "signature", "0", ev); + else if (GNOME_GtkHTML_Editor_Engine_isPreviousParagraphEmpty (e, ev) + && GNOME_GtkHTML_Editor_Engine_runCommand (e, "cursor-backward", ev)) { + GNOME_GtkHTML_Editor_Engine_setParagraphData (e, "signature", "0", ev); + GNOME_GtkHTML_Editor_Engine_runCommand (e, "cursor-forward", ev); + } +} + static CORBA_any * impl_event (PortableServer_Servant _servant, const CORBA_char * name, const CORBA_any * arg, @@ -101,17 +113,24 @@ impl_event (PortableServer_Servant _servant, { EditorListener *l = listener_from_servant (_servant); CORBA_any *rv = NULL; - CORBA_char *orig; /* printf ("impl_event\n"); */ if (!strcmp (name, "command")) { - /* FIXME check for insert-paragraph command */ - orig = GNOME_GtkHTML_Editor_Engine_getParagraphData (l->composer->editor_engine, "orig", ev); - if (ev->_major == CORBA_NO_EXCEPTION) { - if (!strcmp (orig, "1")) - reply_indent (l, ev); - GNOME_GtkHTML_Editor_Engine_setParagraphData (l->composer->editor_engine, "orig", "0", ev); + if (!l->composer->in_signature_insert) { + CORBA_char *orig, *signature; + /* FIXME check for insert-paragraph command */ + orig = GNOME_GtkHTML_Editor_Engine_getParagraphData (l->composer->editor_engine, "orig", ev); + if (ev->_major == CORBA_NO_EXCEPTION) { + if (orig && *orig == '1') + reply_indent (l, ev); + GNOME_GtkHTML_Editor_Engine_setParagraphData (l->composer->editor_engine, "orig", "0", ev); + } + signature = GNOME_GtkHTML_Editor_Engine_getParagraphData (l->composer->editor_engine, "signature", ev); + if (ev->_major == CORBA_NO_EXCEPTION) { + if (signature && *signature == '1') + clear_signature (l->composer->editor_engine, ev); + } } } else if (!strcmp (name, "image_url")) { gchar *url; @@ -119,7 +138,7 @@ impl_event (PortableServer_Servant _servant, if ((url = resolve_image_url (l, BONOBO_ARG_GET_STRING (arg)))) { rv = bonobo_arg_new (TC_string); BONOBO_ARG_SET_STRING (rv, url); - printf ("new url: %s\n", url); + /* printf ("new url: %s\n", url); */ g_free (url); } } |