From fe177f5a12127203f0b77c32ec0ae17d7394f6b2 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Mon, 22 Mar 2010 16:03:46 +0000 Subject: Add an extension to configure EWebView. Make EWebView extensible and register an extension to automatically bind every EWebView instance to the appropriate EShellSettings. Conflicts: widgets/misc/e-web-view.c --- modules/mail/Makefile.am | 2 + modules/mail/e-mail-config-web-view.c | 100 ++++++++++++++++++++++++++++++++++ modules/mail/e-mail-config-web-view.h | 30 ++++++++++ modules/mail/e-mail-shell-backend.c | 15 ----- modules/mail/evolution-module-mail.c | 2 + 5 files changed, 134 insertions(+), 15 deletions(-) create mode 100644 modules/mail/e-mail-config-web-view.c create mode 100644 modules/mail/e-mail-config-web-view.h (limited to 'modules/mail') diff --git a/modules/mail/Makefile.am b/modules/mail/Makefile.am index d08a6866e7..323820217b 100644 --- a/modules/mail/Makefile.am +++ b/modules/mail/Makefile.am @@ -21,6 +21,8 @@ libevolution_module_mail_la_SOURCES = \ e-mail-config-format-html.h \ e-mail-config-hook.c \ e-mail-config-hook.h \ + e-mail-config-web-view.c \ + e-mail-config-web-view.h \ e-mail-event-hook.c \ e-mail-event-hook.h \ e-mail-junk-hook.c \ diff --git a/modules/mail/e-mail-config-web-view.c b/modules/mail/e-mail-config-web-view.c new file mode 100644 index 0000000000..5cfb648154 --- /dev/null +++ b/modules/mail/e-mail-config-web-view.c @@ -0,0 +1,100 @@ +/* + * e-mail-config-web-view.c + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) version 3. + * + * This program 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the program; if not, see + * + */ + +#include "e-mail-config-web-view.h" + +#include +#include +#include +#include + +static void +mail_config_web_view_realize (GtkWidget *widget) +{ + EShell *shell; + EShellSettings *shell_settings; + + shell = e_shell_get_default (); + shell_settings = e_shell_get_shell_settings (shell); + + e_binding_new ( + shell_settings, "mail-show-animated-images", + widget, "animate"); + + e_binding_new ( + shell_settings, "composer-inline-spelling", + widget, "inline-spelling"); + + e_binding_new ( + shell_settings, "composer-magic-links", + widget, "magic-links"); + + e_binding_new ( + shell_settings, "composer-magic-smileys", + widget, "magic-smileys"); +} + +static void +mail_config_web_view_constructed (GObject *object) +{ + EExtension *extension; + EExtensible *extensible; + + extension = E_EXTENSION (object); + extensible = e_extension_get_extensible (extension); + + /* Wait to bind shell settings until the EWebView is realized + * so GtkhtmlEditor has a chance to install a GtkHTMLEditorAPI. + * Otherwise our settings will have no effect. */ + + g_signal_connect ( + extensible, "realize", + G_CALLBACK (mail_config_web_view_realize), NULL); +} + +static void +mail_config_web_view_class_init (EExtensionClass *class) +{ + GObjectClass *object_class; + + object_class = G_OBJECT_CLASS (class); + object_class->constructed = mail_config_web_view_constructed; + + class->extensible_type = E_TYPE_WEB_VIEW; +} + +void +e_mail_config_web_view_register_type (GTypeModule *type_module) +{ + static const GTypeInfo type_info = { + sizeof (EExtensionClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) mail_config_web_view_class_init, + (GClassFinalizeFunc) NULL, + NULL, /* class_data */ + sizeof (EExtension), + 0, /* n_preallocs */ + (GInstanceInitFunc) NULL, + NULL /* value_table */ + }; + + g_type_module_register_type ( + type_module, E_TYPE_EXTENSION, + "EMailConfigWebView", &type_info, 0); +} diff --git a/modules/mail/e-mail-config-web-view.h b/modules/mail/e-mail-config-web-view.h new file mode 100644 index 0000000000..c2a8758709 --- /dev/null +++ b/modules/mail/e-mail-config-web-view.h @@ -0,0 +1,30 @@ +/* + * e-mail-config-web-view.h + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) version 3. + * + * This program 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the program; if not, see + * + */ + +#ifndef E_MAIL_CONFIG_WEB_VIEW_H +#define E_MAIL_CONFIG_WEB_VIEW_H + +#include + +G_BEGIN_DECLS + +void e_mail_config_web_view_register_type (GTypeModule *type_module); + +G_END_DECLS + +#endif /* E_MAIL_CONFIG_WEB_VIEW_H */ diff --git a/modules/mail/e-mail-shell-backend.c b/modules/mail/e-mail-shell-backend.c index de8d4f42d9..00b4a78dc6 100644 --- a/modules/mail/e-mail-shell-backend.c +++ b/modules/mail/e-mail-shell-backend.c @@ -408,28 +408,13 @@ mail_shell_backend_window_created_cb (EShell *shell, GtkWindow *window, EShellBackend *shell_backend) { - EShellSettings *shell_settings; static gboolean first_time = TRUE; const gchar *backend_name; - shell_settings = e_shell_get_shell_settings (shell); - /* This applies to both the composer and signature editor. */ if (GTKHTML_IS_EDITOR (window)) { GList *spell_languages; - e_binding_new ( - shell_settings, "composer-inline-spelling", - window, "inline-spelling"); - - e_binding_new ( - shell_settings, "composer-magic-links", - window, "magic-links"); - - e_binding_new ( - shell_settings, "composer-magic-smileys", - window, "magic-smileys"); - spell_languages = e_load_spell_languages (); gtkhtml_editor_set_spell_languages ( GTKHTML_EDITOR (window), spell_languages); diff --git a/modules/mail/evolution-module-mail.c b/modules/mail/evolution-module-mail.c index f6661cda1a..9e9744569b 100644 --- a/modules/mail/evolution-module-mail.c +++ b/modules/mail/evolution-module-mail.c @@ -31,6 +31,7 @@ #include "e-mail-shell-view.h" #include "e-mail-config-format-html.h" +#include "e-mail-config-web-view.h" /* Module Entry Points */ void e_module_load (GTypeModule *type_module); @@ -54,6 +55,7 @@ e_module_load (GTypeModule *type_module) e_mail_shell_view_register_type (type_module); e_mail_config_format_html_register_type (type_module); + e_mail_config_web_view_register_type (type_module); } G_MODULE_EXPORT void -- cgit v1.2.3