Re: [evolution-patches] Bug 21974: Make editor component configurable
- From: Jason Hildebrand <jason peaceworks ca>
- To: Jeffrey Stedfast <fejj ximian com>
- Cc: Not Zed <notzed ximian com>, evolution-patches lists ximian com
- Subject: Re: [evolution-patches] Bug 21974: Make editor component configurable
- Date: Sat, 10 Jan 2004 16:38:07 -0600
On Sat, 2004-01-10 at 08:12, Jeffrey Stedfast wrote:
> On Sat, 2004-01-10 at 03:34, Not Zed wrote:
> > How about a variation of 2:
> >
> > if we can't activate it
> > and the comnponent iid is different
> > fallback silently (or with a g_warning) to the source default
> >
> > I'm a lover of 'graceful degredation', i.e. offer something that
> works
> > rather than nothing or a crash.
> >
> > (and i'm not a fan of popups).
> yea, I was thinking this very same thing yesterday, just never got
> around to sending out the email :-)
Ok, here it is.
--
Jason D. Hildebrand
jason peaceworks ca
Index: composer/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/composer/ChangeLog,v
retrieving revision 1.591
diff -u -r1.591 ChangeLog
--- composer/ChangeLog 7 Jan 2004 21:11:41 -0000 1.591
+++ composer/ChangeLog 10 Jan 2004 22:37:00 -0000
@@ -1,3 +1,12 @@
+2004-01-08 Jason Hildebrand <jason peaceworks ca>
+
+ * e-msg-composer.c: Get the OAFIID of the editor from a gconf key, so
+ that the user can specify an alternate editor. If the editor requires
+ Escape keypresses, don't catch them in the composer.
+
+ * e-msg-composer.h: Added editor_oafiid and catch_escape attributes to
+ EMsgComposer.
+
2004-01-07 Jeffrey Stedfast <fejj ximian com>
* e-msg-composer.c (create_composer): Remove the 6-pixel border
Index: composer/e-msg-composer.c
===================================================================
RCS file: /cvs/gnome/evolution/composer/e-msg-composer.c,v
retrieving revision 1.426
diff -u -r1.426 e-msg-composer.c
--- composer/e-msg-composer.c 7 Jan 2004 21:11:41 -0000 1.426
+++ composer/e-msg-composer.c 10 Jan 2004 22:37:04 -0000
@@ -107,6 +107,7 @@
#include "Editor.h"
#include "listener.h"
+/* when updating the control id, also update the default gconf value */
#define GNOME_GTKHTML_EDITOR_CONTROL_ID "OAFIID:GNOME_GtkHTML_Editor:3.1"
#define d(x) x
@@ -2399,6 +2400,8 @@
g_hash_table_destroy (composer->inline_images);
g_hash_table_destroy (composer->inline_images_by_url);
+ g_free (composer->editor_oafiid);
+
g_free (composer->charset);
g_free (composer->mime_type);
g_free (composer->mime_body);
@@ -2721,6 +2724,7 @@
e_msg_composer_load_config (EMsgComposer *composer)
{
GConfClient *gconf;
+ GError *err = NULL;
gconf = gconf_client_get_default ();
@@ -2734,6 +2738,14 @@
gconf, "/apps/evolution/mail/composer/view/Bcc", NULL);
composer->view_subject = gconf_client_get_bool (
gconf, "/apps/evolution/mail/composer/view/Subject", NULL);
+ composer->editor_oafiid = gconf_client_get_string (
+ gconf, "/apps/evolution/mail/composer/editor_oafiid", &err);
+ /* if any error occurs reading the editor key, fallback to GtkHTML */
+ if (err) {
+ composer->editor_oafiid = g_strdup (GNOME_GTKHTML_EDITOR_CONTROL_ID);
+ g_error_free (err);
+ }
+ composer->catch_escape = TRUE;
g_object_unref (gconf);
}
@@ -2819,7 +2831,9 @@
static int
composer_key_pressed (GtkWidget *widget, GdkEventKey *event, gpointer user_data)
{
- if (event->keyval == GDK_Escape) {
+ EMsgComposer *composer = E_MSG_COMPOSER (widget);
+
+ if (event->keyval == GDK_Escape && composer->catch_escape) {
do_exit (E_MSG_COMPOSER (widget));
g_signal_stop_emission_by_name (widget, "key-press-event");
@@ -2925,6 +2939,7 @@
GConfClient *gconf;
int vis;
BonoboControlFrame *control_frame;
+ gboolean editor_needs_escape = FALSE;
composer = g_object_new (E_TYPE_MSG_COMPOSER, "win_name", _("Compose a message"), NULL);
gtk_window_set_title ((GtkWindow *) composer, _("Compose a message"));
@@ -2983,16 +2998,32 @@
/* Editor component. */
composer->editor = bonobo_widget_new_control (
- GNOME_GTKHTML_EDITOR_CONTROL_ID,
+ composer->editor_oafiid,
bonobo_ui_component_get_container (composer->uic));
+
+ /* if activation of alternate editor failed, try falling back to the GtkHTML editor */
+ if (!composer->editor && strcmp (GNOME_GTKHTML_EDITOR_CONTROL_ID, composer->editor_oafiid)) {
+ composer->editor = bonobo_widget_new_control (
+ GNOME_GTKHTML_EDITOR_CONTROL_ID,
+ bonobo_ui_component_get_container (composer->uic));
+ }
+
+ /* if activation still failed, display the error message from the
+ * _original_ activation attempt. */
if (!composer->editor) {
+ char * msg;
+
+ msg = g_strdup_printf (_("Could not create composer window:\n"
+ "Unable to activate editor component\n"
+ "%s.\n"
+ "Please make sure you have the correct version\n"
+ "of the editor installed.\n"),
+ composer->editor_oafiid);
e_activation_failure_dialog (GTK_WINDOW (composer),
- _("Could not create composer window:\n"
- "Unable to activate HTML editor component.\n"
- "Please make sure you have the correct version\n"
- "of gtkhtml and libgtkhtml installed.\n"),
- GNOME_GTKHTML_EDITOR_CONTROL_ID,
+ msg,
+ composer->editor_oafiid,
"IDL:Bonobo/Control:1.0");
+ g_free(msg);
gtk_object_destroy (GTK_OBJECT (composer));
return NULL;
}
@@ -3056,11 +3087,17 @@
prepare_engine (composer);
if (composer->editor_engine == CORBA_OBJECT_NIL) {
+ char * msg;
+
+ msg = g_strdup_printf (_("Could not create composer window:\n"
+ "Unable to activate editor component\n"
+ "%s.\n"),
+ composer->editor_oafiid);
e_activation_failure_dialog (GTK_WINDOW (composer),
- _("Could not create composer window:\n"
- "Unable to activate HTML editor component."),
- GNOME_GTKHTML_EDITOR_CONTROL_ID,
+ msg,
+ composer->editor_oafiid,
"IDL:GNOME/GtkHTML/Editor/Engine:1.0");
+ g_free(msg);
gtk_object_destroy (GTK_OBJECT (composer));
return NULL;
}
@@ -3073,6 +3110,9 @@
am = autosave_manager_new ();
autosave_manager_register (am, composer);
+
+ bonobo_widget_get_property (BONOBO_WIDGET (composer->editor), "EditorNeedsEscape", TC_CORBA_boolean, &editor_needs_escape, NULL);
+ composer->catch_escape = !editor_needs_escape;
return composer;
}
Index: composer/e-msg-composer.h
===================================================================
RCS file: /cvs/gnome/evolution/composer/e-msg-composer.h,v
retrieving revision 1.86
diff -u -r1.86 e-msg-composer.h
--- composer/e-msg-composer.h 1 Dec 2003 15:20:49 -0000 1.86
+++ composer/e-msg-composer.h 10 Jan 2004 22:37:04 -0000
@@ -72,6 +72,8 @@
GtkWidget *address_dialog;
+ char *editor_oafiid;
+ gboolean catch_escape;
Bonobo_PersistFile persist_file_interface;
Bonobo_PersistStream persist_stream_interface;
GNOME_GtkHTML_Editor_Engine editor_engine;
Index: mail/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/mail/ChangeLog,v
retrieving revision 1.2977
diff -u -r1.2977 ChangeLog
--- mail/ChangeLog 7 Jan 2004 22:12:40 -0000 1.2977
+++ mail/ChangeLog 10 Jan 2004 22:37:08 -0000
@@ -1,3 +1,12 @@
+2004-01-08 Jason Hildebrand <jason peaceworks ca>
+
+ * em-utils.c (em_utils_compose_new_message): Fix crash when composer
+ can't be created.
+
+ * evolution-mail.schemas.in.in: Added
+ /schemas/apps/evolution/mail/composer/editor_oafiid key to let user
+ override editor component.
+
2004-01-07 Jeffrey Stedfast <fejj ximian com>
* mail-component.c (mail_component_init): Don't migrate stuff here
Index: mail/em-utils.c
===================================================================
RCS file: /cvs/gnome/evolution/mail/em-utils.c,v
retrieving revision 1.11
diff -u -r1.11 em-utils.c
--- mail/em-utils.c 22 Dec 2003 14:50:57 -0000 1.11
+++ mail/em-utils.c 10 Jan 2004 22:37:09 -0000
@@ -316,7 +316,8 @@
composer = (GtkWidget *) create_new_composer ();
- gtk_widget_show (composer);
+ if (composer)
+ gtk_widget_show (composer);
}
/**
Index: mail/evolution-mail.schemas.in.in
===================================================================
RCS file: /cvs/gnome/evolution/mail/evolution-mail.schemas.in.in,v
retrieving revision 1.3
diff -u -r1.3 evolution-mail.schemas.in.in
--- mail/evolution-mail.schemas.in.in 11 Dec 2003 04:56:12 -0000 1.3
+++ mail/evolution-mail.schemas.in.in 10 Jan 2004 22:37:10 -0000
@@ -74,6 +74,21 @@
</schema>
<schema>
+ <key>/schemas/apps/evolution/mail/composer/editor_oafiid</key>
+ <applyto>/apps/evolution/mail/composer/editor_oafiid</applyto>
+ <owner>evolution-mail</owner>
+ <type>string</type>
+ <default>OAFIID:GNOME_GtkHTML_Editor:3.1</default>
+ <locale name="C">
+ <short>Activation ID of editor control.</short>
+ <long>
+ Evolution uses the GtkHTML editor by default. Change this
+ ID to use an alternate (compatible) editor.
+ </long>
+ </locale>
+ </schema>
+
+ <schema>
<key>/schemas/apps/evolution/mail/composer/view/From</key>
<applyto>/apps/evolution/mail/composer/view/From</applyto>
<owner>evolution-mail</owner>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]