Thoughts and ideas to replace gtkhtml with gtkmozembed

From Evolution

Contents

[edit]

Information about makig a GtkMozEmbed instance editable

http://cvs.gnome.org/viewcvs/gtkmozedit

This sample is very interesting. It shows how you can, using DOM, access the html nodes (and modify them).

http://cvs.gnome.org/viewcvs/gtkmozedit/demo/demo2.c?rev=HEAD&view=markup

GtkMozEdit implements this information already: http://lxr.mozilla.org/seamonkey/source/editor/docs/Editor_Embedding_Guide.html

nsCOMPtr<nsIWebBrowser> browser;
gtk_moz_embed_get_nsIWebBrowser (embed, getter_AddRefs (browser));
nsCOMPtr<nsIEditingSession> editingSession (do_GetInterface (browser));
if (editingSession)
        editingSession->MakeWindowEditable(domWindow, "html", PR_TRUE);
nsCOMPtr<nsICommandManager> cmdManager (do_GetInterface (browser));
cmdManager->DoCommand(aCommand, aCommandParams);

For example

cmdManager->DoCommand(cmd_insertHTML, aCommandParams);

And you have methods like, GetNext (to get the next element), HasMoreElements, GetValueType, GetStringValue etcetera. Which can be useful for the spellchecker implementation.

[edit]

Idea one

Reimplement Editor.idl (gtkhtml/components/html-editor) (Create a new Bonobo component)

[edit]

Idea two

Remove the Bonobo stuff and implement it as a widget

Issues:

mail/em-composer-utils.c and composer/listener.c don't only use the API but also use some members (that ought to be private) of the struct (editor_engine).

Therefore a good excercise before attempting to replace the bonobo stuff with a widget (which should happen before trying to replace gtkhtml with gtkmozembed) would be to create a EMsgComposerPrivate *Priv and move all the members of EMsgComposer to that struct in e-msg-composer.c and fix all the shit :)

[edit]

Difficulties

  • runCommand: Map all the GTK_HTML_COMMAND_* commands to commandManager commands (see below)
  • getParagraphData: Unknown/uninvestigated
  • setParagraphData: Unknown/uninvestigated
  • setObjectDataByType: Unknown/uninvestigated
  • searchByData: Unknown/uninvestigated
  • isParagraphEmpty: Unknown/uninvestigated
  • isPreviousParagraphEmpty: Unknown/uninvestigated
  • insertHTML: Easy (cmd_insertHTML)
  • freeze: Unknown/uninvestigated
  • thaw: Unknown/uninvestigated
  • undoBegin: Unknown/uninvestigated
  • undoEnd: Unknown/uninvestigated
  • ignoreWord: Unknown/uninvestigated
  • dropUndo: Unknown/uninvestigated
  • hasUndo: Unknown/uninvestigated
[edit]

Commands to support

$ grep runCommand * -r | grep GNOME_GtkHTML_Editor_Engine_runCommand | cut -d "\"" -f 2 | sort | uniq
block-redraw
block-selection
bold-off
cursor-backward
cursor-bod
cursor-forward
cursor-position-restore
cursor-position-save
delete
delete-back
disable-selection
editable-off
grab-focus
indent-zero
insert-paragraph
is-saved
italic-off
saved
save-data-off
save-data-on
select-all
select-paragraph
strikeout-off
style-normal
text-default-color
unblock-redraw
unblock-selection
underline-off
$
[edit]

Replaceable with

  • bold-off, italic-off, strikeout-off, underline-off: cmd_removeStyles, cmd_bold, cmd_italics, cmd_underline, cmd_tt, cmd_strikethru, etc, etc
  • editable-off: MakeWindowEditable (..., False)
  • indent-zero: cmd_indent, cmd_outdent
  • insert-paragraph: cmd_insertHTML, cmd_insertLinkNoUI, cmd_insertImageNoUI, cmd_insertHR
  • select-all, select-paragraph: cmd_selectTop, cmd_selectBottom, cmd_selectLineNext, cmd_selectLinePrevious, cmd_selectCharPrevious, cmd_selectCharNext, cmd_selectBeginLine, cmd_selectEndLine, cmd_selectWordPrevious, cmd_selectWordNext
  • text-default-color: cmd_fontColor