aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRadek Doulik <rodo@helixcode.com>2000-11-01 01:10:42 +0800
committerRadek Doulik <rodo@src.gnome.org>2000-11-01 01:10:42 +0800
commitfee9d1b411184ef7fee35d1b72871a29e340b0c2 (patch)
tree5e1b00dc04f01e011c14546249b0f3237d77dc8d
parent1c7ba10a5d5ecfea514da87de1a23278f4d43f00 (diff)
downloadgsoc2013-evolution-fee9d1b411184ef7fee35d1b72871a29e340b0c2.tar
gsoc2013-evolution-fee9d1b411184ef7fee35d1b72871a29e340b0c2.tar.gz
gsoc2013-evolution-fee9d1b411184ef7fee35d1b72871a29e340b0c2.tar.bz2
gsoc2013-evolution-fee9d1b411184ef7fee35d1b72871a29e340b0c2.tar.lz
gsoc2013-evolution-fee9d1b411184ef7fee35d1b72871a29e340b0c2.tar.xz
gsoc2013-evolution-fee9d1b411184ef7fee35d1b72871a29e340b0c2.tar.zst
gsoc2013-evolution-fee9d1b411184ef7fee35d1b72871a29e340b0c2.zip
better reply editing, uses new HTMLEditor::Engine,Listener interfaces
you need fresh CVS gtkhtml to try that 2000-10-31 Radek Doulik <rodo@helixcode.com> * e-msg-composer.c (prepare_engine): new function, tries prepare editor engine (mark_orig_text): marks original text in editor (set_editor_text): call mark_orig_text (create_composer): call prepare_engine * Makefile.am (IDL_GENERATED): added HTMLEditor generated files to IDL_GENERATED ($(IDL_GENERATED)): generate also files from HTMLEditor.idl (libcomposer_la_SOURCES): added listener.[ch] * e-msg-composer.h: added editor_engine and editor_listener to EMsgComposer * listener.[ch]: new files, implementation of HTMLEditor::Listener svn path=/trunk/; revision=6292
-rw-r--r--composer/.cvsignore4
-rw-r--r--composer/ChangeLog18
-rw-r--r--composer/HTMLEditor.idl56
-rw-r--r--composer/Makefile.am15
-rw-r--r--composer/e-msg-composer.c79
-rw-r--r--composer/e-msg-composer.h10
-rw-r--r--composer/listener.c163
-rw-r--r--composer/listener.h56
8 files changed, 386 insertions, 15 deletions
diff --git a/composer/.cvsignore b/composer/.cvsignore
index 430d126b34..d418fe2d1c 100644
--- a/composer/.cvsignore
+++ b/composer/.cvsignore
@@ -9,3 +9,7 @@ Composer-stubs.c
Composer-skels.c
Composer-common.c
Composer.h
+HTMLEditor-stubs.c
+HTMLEditor-skels.c
+HTMLEditor.h
+HTMLEditor-common.c
diff --git a/composer/ChangeLog b/composer/ChangeLog
index a0bcbf194e..73f4074572 100644
--- a/composer/ChangeLog
+++ b/composer/ChangeLog
@@ -1,3 +1,21 @@
+2000-10-31 Radek Doulik <rodo@helixcode.com>
+
+ * e-msg-composer.c (prepare_engine): new function, tries prepare
+ editor engine
+ (mark_orig_text): marks original text in editor
+ (set_editor_text): call mark_orig_text
+ (create_composer): call prepare_engine
+
+ * Makefile.am (IDL_GENERATED): added HTMLEditor generated files to
+ IDL_GENERATED
+ ($(IDL_GENERATED)): generate also files from HTMLEditor.idl
+ (libcomposer_la_SOURCES): added listener.[ch]
+
+ * e-msg-composer.h: added editor_engine and editor_listener to
+ EMsgComposer
+
+ * listener.[ch]: new files, implementation of HTMLEditor::Listener
+
2000-10-27 Ettore Perazzoli <ettore@helixcode.com>
* Makefile.am ($(IDL_GENERATED)): Get `Composer.idl' from
diff --git a/composer/HTMLEditor.idl b/composer/HTMLEditor.idl
new file mode 100644
index 0000000000..ec1e971f22
--- /dev/null
+++ b/composer/HTMLEditor.idl
@@ -0,0 +1,56 @@
+/* -*- Mode: IDL; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Interface for the HTML Editor.
+ *
+ * Authors:
+ * Larry Ewing <lewing@helixcode.com>
+ * Radek Doulik <rodo@helixcode.com>
+ *
+ * Copyright (C) 2000 Helix Code, Inc.
+ */
+
+#include <Bonobo.idl>
+
+module HTMLEditor {
+ interface Resolver : Bonobo::Unknown {
+ exception NotFound {};
+
+ void loadURL (in Bonobo::ProgressiveDataSink sink, in string url) raises (NotFound);
+ };
+
+ struct Arg {
+ any value;
+ };
+ typedef sequence<Arg> ListenerArgs;
+
+ interface Listener : Bonobo::Unknown {
+ void event (in string name, in ListenerArgs args);
+ };
+
+ interface Engine : Bonobo::Unknown {
+ attribute Listener listener;
+
+ /*
+ * return data of current paragraph
+ */
+ any get_paragraph_data (in string key);
+
+ /*
+ * sets data on current paragraph
+ */
+ void set_paragraph_data (in string key, in any value);
+
+ /*
+ * set data which are set to objects of given type while inserting
+ * we will use that to mark original text paragraph(s) in composer
+ * and use that data later in editing to implement better reply
+ * editing
+ */
+ void set_object_data_by_type (in string type_name, in string key, in any data);
+
+ /*
+ * execute editor command
+ */
+ void command (in string command);
+ };
+};
diff --git a/composer/Makefile.am b/composer/Makefile.am
index cfd50b8cbc..7c0b12315d 100644
--- a/composer/Makefile.am
+++ b/composer/Makefile.am
@@ -2,19 +2,26 @@
IDLS = \
Evolution-Composer.idl \
- Composer.idl
+ Composer.idl \
+ HTMLEditor.idl
IDL_GENERATED = \
Composer.h \
Composer-common.c \
Composer-skels.c \
- Composer-stubs.c
+ Composer-stubs.c \
+ HTMLEditor.h \
+ HTMLEditor-common.c \
+ HTMLEditor-skels.c \
+ HTMLEditor-stubs.c
selectnamesdir = $(top_srcdir)/addressbook/gui/component/select-names
$(IDL_GENERATED): $(IDLS) $(selectnamesdir)/Evolution-Addressbook-SelectNames.idl
$(ORBIT_IDL) -I $(datadir)/idl `$(GNOME_CONFIG) --cflags idl` \
-I $(selectnamesdir) -I . $(srcdir)/Composer.idl
+ $(ORBIT_IDL) -I $(datadir)/idl `$(GNOME_CONFIG) --cflags idl` \
+ -I $(selectnamesdir) -I . $(srcdir)/HTMLEditor.idl
##
@@ -64,7 +71,9 @@ libcomposer_la_SOURCES = \
e-icon-list.c \
e-icon-list.h \
evolution-composer.c \
- evolution-composer.h
+ evolution-composer.h \
+ listener.c \
+ listener.h
EXTRA_DIST = \
$(glade_DATA) \
diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c
index 5f7e673bc2..28b9eb7fac 100644
--- a/composer/e-msg-composer.c
+++ b/composer/e-msg-composer.c
@@ -57,6 +57,9 @@
#include "e-msg-composer-hdrs.h"
#include "e-msg-composer-select-file.h"
+#include "HTMLEditor.h"
+#include "listener.h"
+
#define HTML_EDITOR_CONTROL_ID "OAFIID:control:html-editor:63c5499b-8b0c-475a-9948-81ec96a9662c"
@@ -318,14 +321,61 @@ get_signature (const char *sigfile)
}
static void
-set_editor_text (BonoboWidget *editor, const char *sig_file, const char *text)
+prepare_engine (EMsgComposer *composer)
+{
+ CORBA_Environment ev;
+
+ g_assert (composer);
+ g_assert (E_IS_MSG_COMPOSER (composer));
+
+ /* printf ("prepare_engine\n"); */
+
+ CORBA_exception_init (&ev);
+ composer->editor_engine = (HTMLEditor_Engine) bonobo_object_client_query_interface
+ (bonobo_widget_get_server (BONOBO_WIDGET (composer->editor)), "IDL:HTMLEditor/Engine:1.0", &ev);
+ if (composer->editor_engine != CORBA_OBJECT_NIL) {
+
+ /* printf ("trying set listener\n"); */
+ composer->editor_listener = BONOBO_OBJECT (html_editor_listener_new (composer));
+ if (composer->editor_listener != CORBA_OBJECT_NIL)
+ HTMLEditor_Engine__set_listener (composer->editor_engine,
+ (HTMLEditor_Listener)
+ bonobo_object_dup_ref
+ (bonobo_object_corba_objref (composer->editor_listener), &ev),
+ &ev);
+ }
+ CORBA_exception_free (&ev);
+}
+
+static void
+mark_orig_text (EMsgComposer *composer)
+{
+ g_assert (composer);
+ g_assert (E_IS_MSG_COMPOSER (composer));
+
+ if (composer->editor_engine != CORBA_OBJECT_NIL) {
+ CORBA_Environment ev;
+ CORBA_any *flag = bonobo_arg_new (TC_boolean);
+ *((CORBA_boolean *) flag->_value) = CORBA_TRUE;
+
+ CORBA_exception_init (&ev);
+ HTMLEditor_Engine_set_object_data_by_type (composer->editor_engine, "ClueFlow", "orig", flag, &ev);
+ CORBA_free (flag);
+ CORBA_exception_free (&ev);
+ }
+}
+
+static void
+set_editor_text (EMsgComposer *composer, const char *sig_file, const char *text)
{
Bonobo_PersistStream persist;
BonoboStream *stream;
+ BonoboWidget *editor;
CORBA_Environment ev;
char *sig, *fulltext;
- sig = get_signature (sig_file);
+ editor = BONOBO_WIDGET (composer->editor);
+ sig = get_signature (sig_file);
if (sig) {
if (!strncmp ("-- \n", sig, 3))
fulltext = g_strdup_printf ("%s<br>\n<pre>\n%s</pre>",
@@ -360,6 +410,8 @@ set_editor_text (BonoboWidget *editor, const char *sig_file, const char *text)
Bonobo_Unknown_unref (persist, &ev);
CORBA_exception_free (&ev);
bonobo_object_unref (BONOBO_OBJECT(stream));
+
+ mark_orig_text (composer);
}
@@ -978,8 +1030,16 @@ destroy (GtkObject *object)
CORBA_Object_release (composer->persist_file_interface, &ev);
}
+ if (composer->editor_engine != CORBA_OBJECT_NIL) {
+ Bonobo_Unknown_unref (composer->editor_engine, &ev);
+ CORBA_Object_release (composer->editor_engine, &ev);
+ }
+
CORBA_exception_free (&ev);
-
+
+ if (composer->editor_listener)
+ bonobo_object_unref (composer->editor_listener);
+
if (GTK_OBJECT_CLASS (parent_class)->destroy != NULL)
(* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
}
@@ -1082,6 +1142,7 @@ init (EMsgComposer *composer)
composer->persist_file_interface = CORBA_OBJECT_NIL;
composer->persist_stream_interface = CORBA_OBJECT_NIL;
+ composer->editor_engine = CORBA_OBJECT_NIL;
composer->attachment_bar_visible = FALSE;
composer->send_html = FALSE;
@@ -1211,6 +1272,8 @@ create_composer (void)
gtk_object_unref (GTK_OBJECT (new));
return NULL;
}
+ prepare_engine (new);
+
return new;
}
@@ -1229,7 +1292,7 @@ e_msg_composer_new (void)
new = create_composer ();
if (new) {
/* Load the signature, if any. */
- set_editor_text (BONOBO_WIDGET (new->editor), NULL, "");
+ set_editor_text (new, NULL, "");
}
return new;
@@ -1250,7 +1313,7 @@ e_msg_composer_new_with_sig_file (const char *sig_file)
new = create_composer ();
if (new) {
/* Load the signature, if any. */
- set_editor_text (BONOBO_WIDGET (new->editor), sig_file, "");
+ set_editor_text (new, sig_file, "");
e_msg_composer_set_sig_file (new, sig_file);
}
@@ -1572,8 +1635,7 @@ e_msg_composer_new_from_url (const char *url)
if (body) {
char *htmlbody = e_text_to_html (body, E_TEXT_TO_HTML_PRE);
- set_editor_text (BONOBO_WIDGET (composer->editor),
- NULL, htmlbody);
+ set_editor_text (composer, NULL, htmlbody);
g_free (htmlbody);
}
@@ -1637,8 +1699,7 @@ e_msg_composer_set_body_text (EMsgComposer *composer, const char *text)
{
g_return_if_fail (E_IS_MSG_COMPOSER (composer));
- set_editor_text (BONOBO_WIDGET (composer->editor),
- composer->sig_file, text);
+ set_editor_text (composer, composer->sig_file, text);
}
diff --git a/composer/e-msg-composer.h b/composer/e-msg-composer.h
index 68ab9bef7c..391831d776 100644
--- a/composer/e-msg-composer.h
+++ b/composer/e-msg-composer.h
@@ -24,11 +24,15 @@
#ifndef ___E_MSG_COMPOSER_H__
#define ___E_MSG_COMPOSER_H__
+typedef struct _EMsgComposer EMsgComposer;
+typedef struct _EMsgComposerClass EMsgComposerClass;
+
#include <gnome.h>
#include <bonobo.h>
#include "e-msg-composer-attachment-bar.h"
#include "e-msg-composer-hdrs.h"
+#include "HTMLEditor.h"
#ifdef __cplusplus
extern "C" {
@@ -43,8 +47,6 @@ extern "C" {
#define E_IS_MSG_COMPOSER_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_TYPE_MSG_COMPOSER))
-typedef struct _EMsgComposer EMsgComposer;
-typedef struct _EMsgComposerClass EMsgComposerClass;
struct _EMsgComposer {
BonoboWin parent;
@@ -63,7 +65,9 @@ struct _EMsgComposer {
Bonobo_PersistFile persist_file_interface;
Bonobo_PersistStream persist_stream_interface;
-
+ HTMLEditor_Engine editor_engine;
+ BonoboObject *editor_listener;
+
char *sig_file;
gboolean attachment_bar_visible : 1;
diff --git a/composer/listener.c b/composer/listener.c
new file mode 100644
index 0000000000..d97dd02df9
--- /dev/null
+++ b/composer/listener.c
@@ -0,0 +1,163 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/* This file is part of gnome-spell bonobo component
+
+ Copyright (C) 2000 Helix Code, Inc.
+ Authors: Radek Doulik <rodo@helixcode.com>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#include <config.h>
+#include <bonobo.h>
+
+#include "listener.h"
+
+static BonoboObjectClass *listener_parent_class;
+static POA_HTMLEditor_Listener__vepv listener_vepv;
+
+inline static HTMLEditorListener *
+html_editor_listener_from_servant (PortableServer_Servant servant)
+{
+ return HTML_EDITOR_LISTENER (bonobo_object_from_servant (servant));
+}
+
+static void
+impl_event (PortableServer_Servant _servant, const CORBA_char * name,
+ const HTMLEditor_ListenerArgs * args,
+ CORBA_Environment * ev)
+{
+ HTMLEditorListener *l = html_editor_listener_from_servant (_servant);
+ BonoboArg *arg;
+
+ /* printf ("impl_event\n"); */
+
+ arg = HTMLEditor_Engine_get_paragraph_data (l->composer->editor_engine, "orig", ev);
+ if (ev->_major == CORBA_NO_EXCEPTION && arg) {
+ if (CORBA_TypeCode_equal (arg->_type, TC_boolean, ev) && BONOBO_ARG_GET_BOOLEAN (arg)) {
+ HTMLEditor_Engine_command (l->composer->editor_engine, "style-normal", ev);
+ HTMLEditor_Engine_command (l->composer->editor_engine, "indent-zero", ev);
+ HTMLEditor_Engine_command (l->composer->editor_engine, "italic-off", ev);
+ }
+ BONOBO_ARG_SET_BOOLEAN (arg, CORBA_FALSE);
+ HTMLEditor_Engine_set_paragraph_data (l->composer->editor_engine, "orig", arg, ev);
+ }
+}
+
+POA_HTMLEditor_Listener__epv *
+html_editor_listener_get_epv (void)
+{
+ POA_HTMLEditor_Listener__epv *epv;
+
+ epv = g_new0 (POA_HTMLEditor_Listener__epv, 1);
+
+ epv->event = impl_event;
+
+ return epv;
+}
+
+static void
+init_listener_corba_class (void)
+{
+ listener_vepv.Bonobo_Unknown_epv = bonobo_object_get_epv ();
+ listener_vepv.HTMLEditor_Listener_epv = html_editor_listener_get_epv ();
+}
+
+static void
+listener_class_init (HTMLEditorListenerClass *klass)
+{
+ listener_parent_class = gtk_type_class (bonobo_object_get_type ());
+
+ init_listener_corba_class ();
+}
+
+GtkType
+html_editor_listener_get_type (void)
+{
+ static GtkType type = 0;
+
+ if (!type){
+ GtkTypeInfo info = {
+ "HTMLEditorListener",
+ sizeof (HTMLEditorListener),
+ sizeof (HTMLEditorListenerClass),
+ (GtkClassInitFunc) listener_class_init,
+ (GtkObjectInitFunc) NULL,
+ NULL, /* reserved 1 */
+ NULL, /* reserved 2 */
+ (GtkClassInitFunc) NULL
+ };
+
+ type = gtk_type_unique (bonobo_object_get_type (), &info);
+ }
+
+ return type;
+}
+
+HTMLEditorListener *
+html_editor_listener_construct (HTMLEditorListener *listener, HTMLEditor_Listener corba_listener)
+{
+ g_return_val_if_fail (listener != NULL, NULL);
+ g_return_val_if_fail (IS_HTML_EDITOR_LISTENER (listener), NULL);
+ g_return_val_if_fail (corba_listener != CORBA_OBJECT_NIL, NULL);
+
+ if (!bonobo_object_construct (BONOBO_OBJECT (listener), (CORBA_Object) corba_listener))
+ return NULL;
+
+ return listener;
+}
+
+static HTMLEditor_Listener
+create_listener (BonoboObject *listener)
+{
+ POA_HTMLEditor_Listener *servant;
+ CORBA_Environment ev;
+
+ servant = (POA_HTMLEditor_Listener *) g_new0 (BonoboObjectServant, 1);
+ servant->vepv = &listener_vepv;
+
+ CORBA_exception_init (&ev);
+ POA_HTMLEditor_Listener__init ((PortableServer_Servant) servant, &ev);
+ ORBIT_OBJECT_KEY(servant->_private)->object = NULL;
+
+ if (ev._major != CORBA_NO_EXCEPTION){
+ g_free (servant);
+ CORBA_exception_free (&ev);
+ return CORBA_OBJECT_NIL;
+ }
+
+ CORBA_exception_free (&ev);
+
+ return (HTMLEditor_Listener) bonobo_object_activate_servant (listener, servant);
+}
+
+HTMLEditorListener *
+html_editor_listener_new (EMsgComposer *composer)
+{
+ HTMLEditorListener *listener;
+ HTMLEditor_Listener corba_listener;
+
+ listener = gtk_type_new (HTML_EDITOR_LISTENER_TYPE);
+ listener->composer = composer;
+
+ corba_listener = create_listener (BONOBO_OBJECT (listener));
+
+ if (corba_listener == CORBA_OBJECT_NIL) {
+ bonobo_object_unref (BONOBO_OBJECT (listener));
+ return NULL;
+ }
+
+ return html_editor_listener_construct (listener, corba_listener);
+}
diff --git a/composer/listener.h b/composer/listener.h
new file mode 100644
index 0000000000..e2815a3221
--- /dev/null
+++ b/composer/listener.h
@@ -0,0 +1,56 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/* This file is part of gnome-spell bonobo component
+
+ Copyright (C) 2000 Helix Code, Inc.
+ Authors: Radek Doulik <rodo@helixcode.com>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#ifndef LISTENER_H_
+#define LISTENER_H_
+
+#include <libgnome/gnome-defs.h>
+#include <bonobo/bonobo-object.h>
+#include "HTMLEditor.h"
+#include "e-msg-composer.h"
+
+BEGIN_GNOME_DECLS
+
+#define HTML_EDITOR_LISTENER_TYPE (html_editor_listener_get_type ())
+#define HTML_EDITOR_LISTENER(o) (GTK_CHECK_CAST ((o), HTML_EDITOR_LISTENER_TYPE, HTMLEditorListener))
+#define HTML_EDITOR_LISTENER_CLASS(k) (GTK_CHECK_CLASS_CAST((k), HTML_EDITOR_LISTENER_TYPE, HTMLEditorListenerClass))
+#define IS_HTML_EDITOR_LISTENER(o) (GTK_CHECK_TYPE ((o), HTML_EDITOR_LISTENER_TYPE))
+#define IS_HTML_EDITOR_LISTENER_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), HTML_EDITOR_LISTENER_TYPE))
+
+typedef struct {
+ BonoboObject parent;
+ EMsgComposer *composer;
+} HTMLEditorListener;
+
+typedef struct {
+ BonoboObjectClass parent_class;
+} HTMLEditorListenerClass;
+
+GtkType html_editor_listener_get_type (void);
+HTMLEditorListener *html_editor_listener_construct (HTMLEditorListener *listener,
+ HTMLEditor_Listener corba_listener);
+HTMLEditorListener *html_editor_listener_new (EMsgComposer *composer);
+POA_HTMLEditor_Listener__epv *html_editor_listener_get_epv (void);
+
+END_GNOME_DECLS
+
+#endif /* LISTENER_H_ */