Re: [evolution-patches] Bug 21974: Make editor component configurable



a few comments below.

Jeff

On Sun, 2004-11-07 at 13:34 -0600, Jason Hildebrand wrote:
> Hi Jeffrey,
> 
> I submitted this patch way back prior to the Evo 2.0 freeze.  It makes
> it
> possible to use an alternate editor instead of GtkHTML by setting 
> the /apps/evolution/mail/composer/editor_oafiid gconf key.  
> 
> The patch was reviewed at that time, but didn't actually get committed
> before 
> the freeze.
> 
> I've just updated it to apply cleanly to CVS head, and have compiled
> and
> tested it, and would appreciate it if you could review/commit it now.
> 
> peace,
> Jason
> 
> 
> 
> 
> 
> 
> 
> text/x-patch
> attachment
> (gconf-editor-oafiid.patch)
> 
> Index: composer/ChangeLog
> ===================================================================
> RCS file: /cvs/gnome/evolution/composer/ChangeLog,v
> retrieving revision 1.669
> diff -u -p -r1.669 ChangeLog
> --- composer/ChangeLog  28 Oct 2004 09:25:47 -0000      1.669
> +++ composer/ChangeLog  7 Nov 2004 19:23:11 -0000
> @@ -1,3 +1,9 @@
> +2004-11-07  Jason Hildebrand <jason peaceworks ca>
> +
> +    * e-msg-composer.c:
> use /apps/evolution/mail/composer/editor_oafiid 
> +    gconf key to get oafiid of editor component to use.  Fallback to
> +    using GtkHTML if there are any errors instantiating the editor.
> +
>  2004-10-28  Not Zed  <NotZed Ximian com>
>  
>         * e-msg-composer.c (drag_data_received): fix the popup id.
> Index: composer/e-msg-composer.c
> ===================================================================
> RCS file: /cvs/gnome/evolution/composer/e-msg-composer.c,v
> retrieving revision 1.490
> diff -u -p -r1.490 e-msg-composer.c
> --- composer/e-msg-composer.c   28 Oct 2004 09:25:47 -0000      1.490
> +++ composer/e-msg-composer.c   7 Nov 2004 19:23:16 -0000
> @@ -2517,6 +2517,8 @@ composer_finalise (GObject *object)
>         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);
> @@ -3077,6 +3079,7 @@ static void
>  e_msg_composer_load_config (EMsgComposer *composer, int visible_mask)
>  {
>         GConfClient *gconf;
> +       GError *err = NULL;
>         
>         gconf = gconf_client_get_default ();
>         
> @@ -3094,6 +3097,17 @@ e_msg_composer_load_config (EMsgComposer
>                 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, or if key is
> empty, fallback to GtkHTML */
> +       if (err || composer->editor_oafiid == NULL || !
> composer->editor_oafiid[0]) {

I don't think you should check err NULLness here, you accomplish the
same with checking the return value of the oafiid.

> +        if (composer->editor_oafiid) {
> +            g_free (composer->editor_oafiid);
> +        }

just g_free (composer->editor_oafiid);

no need to check non-NULL first. Also, for style - don't use braces if
there is only one statement to call.

> +               composer->editor_oafiid = g_strdup
> (GNOME_GTKHTML_EDITOR_CONTROL_ID);
> +               g_error_free (err);

since you don't actually use err, why even bother having it?

> +       }
> +       composer->catch_escape = TRUE;
>         
>         /* if we're mailing, you cannot disable to so it should appear
> checked */
>         if (visible_mask & E_MSG_COMPOSER_VISIBLE_TO)
> @@ -3202,7 +3216,7 @@ msg_composer_destroy_notify (void *data)
>  static int
>  composer_key_pressed (EMsgComposer *composer, GdkEventKey *event,
> void *user_data)
>  {
> -       if (event->keyval == GDK_Escape) {
> +       if (event->keyval == GDK_Escape && composer->catch_escape) {
>                 do_exit (composer);
>                 g_signal_stop_emission_by_name (composer,
> "key-press-event");
>                 return TRUE;
> @@ -3325,6 +3339,7 @@ create_composer (int visible_mask)
>         GList *icon_list;
>         BonoboControlFrame *control_frame;
>         GdkPixbuf *attachment_pixbuf;
> +       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"));
> @@ -3380,8 +3395,18 @@ create_composer (int visible_mask)
>  
>         /* 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 && composer->editor_oafiid && 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) {
>                 e_error_run (GTK_WINDOW (composer),
> "mail-composer:no-editor-control", NULL);
>                 gtk_object_destroy (GTK_OBJECT (composer));
> @@ -3494,6 +3519,9 @@ create_composer (int visible_mask)
>                 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;
>  
>         composer->has_changed = FALSE;
>         
> Index: composer/e-msg-composer.h
> ===================================================================
> RCS file: /cvs/gnome/evolution/composer/e-msg-composer.h,v
> retrieving revision 1.91
> diff -u -p -r1.91 e-msg-composer.h
> --- composer/e-msg-composer.h   27 Jul 2004 16:52:17 -0000      1.91
> +++ composer/e-msg-composer.h   7 Nov 2004 19:23:17 -0000
> @@ -74,6 +74,8 @@ struct _EMsgComposer {
>         
>         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.3493
> diff -u -p -r1.3493 ChangeLog
> --- mail/ChangeLog      3 Nov 2004 09:47:23 -0000       1.3493
> +++ mail/ChangeLog      7 Nov 2004 19:23:27 -0000
> @@ -1,3 +1,11 @@
> +2004-11-07  Jason Hildebrand <jason peaceworks ca>
> +
> +    * evolution-mail.schemas.in.in: added 
> +    /apps/evolution/mail/composer/editor_oafiid gconf key which can
> +    be used to specify an alternate editor component.  If empty or 
> +    invalid, GtkHTML is used.
> +
> +
>  2004-11-03  Not Zed  <NotZed Ximian com>
>  
>         * em-folder-view.c (emfv_popup): Fix the popup id.
> Index: mail/evolution-mail.schemas.in.in
> ===================================================================
> RCS file: /cvs/gnome/evolution/mail/evolution-mail.schemas.in.in,v
> retrieving revision 1.17
> diff -u -p -r1.17 evolution-mail.schemas.in.in
> --- mail/evolution-mail.schemas.in.in   10 May 2004 19:35:38
> -0000      1.17
> +++ mail/evolution-mail.schemas.in.in   7 Nov 2004 19:23:28 -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></default>
> +      <locale name="C">
> +         <short>Activation ID (OAFIID) 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
-- 
Jeffrey Stedfast
Evolution Hacker - Novell, Inc.
fejj ximian com  - www.novell.com

Attachment: smime.p7s
Description: S/MIME cryptographic signature



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]