diff options
-rw-r--r-- | mail/e-mail-reader.c | 4 | ||||
-rw-r--r-- | modules/mail/Makefile.am | 2 | ||||
-rw-r--r-- | modules/mail/e-mail-config-web-view.c | 100 | ||||
-rw-r--r-- | modules/mail/e-mail-config-web-view.h | 30 | ||||
-rw-r--r-- | modules/mail/e-mail-shell-backend.c | 15 | ||||
-rw-r--r-- | modules/mail/evolution-module-mail.c | 2 | ||||
-rw-r--r-- | widgets/misc/e-web-view.c | 211 | ||||
-rw-r--r-- | widgets/misc/e-web-view.h | 9 |
8 files changed, 310 insertions, 63 deletions
diff --git a/mail/e-mail-reader.c b/mail/e-mail-reader.c index 7a8d7a9994..6448f5bf35 100644 --- a/mail/e-mail-reader.c +++ b/mail/e-mail-reader.c @@ -2668,10 +2668,6 @@ e_mail_reader_init (EMailReader *reader) /* Bind properties. */ - e_binding_new ( - shell_settings, "mail-show-animated-images", - web_view, "animate"); - action_name = "mail-caret-mode"; action = e_mail_reader_get_action (reader, action_name); 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 <http://www.gnu.org/licenses/> + * + */ + +#include "e-mail-config-web-view.h" + +#include <shell/e-shell.h> +#include <e-util/e-binding.h> +#include <e-util/e-extension.h> +#include <misc/e-web-view.h> + +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 <http://www.gnu.org/licenses/> + * + */ + +#ifndef E_MAIL_CONFIG_WEB_VIEW_H +#define E_MAIL_CONFIG_WEB_VIEW_H + +#include <glib-object.h> + +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 diff --git a/widgets/misc/e-web-view.c b/widgets/misc/e-web-view.c index e9fc71d7ca..c65f9cf666 100644 --- a/widgets/misc/e-web-view.c +++ b/widgets/misc/e-web-view.c @@ -28,9 +28,10 @@ #include <camel/camel-internet-address.h> #include <camel/camel-url.h> -#include "e-util/e-util.h" -#include "e-util/e-binding.h" -#include "e-util/e-plugin-ui.h" +#include <e-util/e-util.h> +#include <e-util/e-binding.h> +#include <e-util/e-extensible.h> +#include <e-util/e-plugin-ui.h> #include "e-popup-action.h" #include "e-selectable.h" @@ -75,6 +76,9 @@ enum { PROP_DISABLE_PRINTING, PROP_DISABLE_SAVE_TO_DISK, PROP_EDITABLE, + PROP_INLINE_SPELLING, + PROP_MAGIC_LINKS, + PROP_MAGIC_SMILEYS, PROP_OPEN_PROXY, PROP_PASTE_TARGET_LIST, PROP_PRINT_PROXY, @@ -118,6 +122,14 @@ static const gchar *ui = " </popup>" "</ui>"; +/* Forward Declarations */ +static void e_web_view_selectable_init (ESelectableInterface *interface); + +G_DEFINE_TYPE_WITH_CODE ( + EWebView, e_web_view, GTK_TYPE_HTML, + G_IMPLEMENT_INTERFACE (E_TYPE_EXTENSIBLE, NULL) + G_IMPLEMENT_INTERFACE (E_TYPE_SELECTABLE, e_web_view_selectable_init)) + static EWebViewRequest * web_view_request_new (EWebView *web_view, const gchar *uri, @@ -503,6 +515,24 @@ web_view_set_property (GObject *object, g_value_get_boolean (value)); return; + case PROP_INLINE_SPELLING: + e_web_view_set_inline_spelling ( + E_WEB_VIEW (object), + g_value_get_boolean (value)); + return; + + case PROP_MAGIC_LINKS: + e_web_view_set_magic_links ( + E_WEB_VIEW (object), + g_value_get_boolean (value)); + return; + + case PROP_MAGIC_SMILEYS: + e_web_view_set_magic_smileys ( + E_WEB_VIEW (object), + g_value_get_boolean (value)); + return; + case PROP_OPEN_PROXY: e_web_view_set_open_proxy ( E_WEB_VIEW (object), @@ -574,6 +604,24 @@ web_view_get_property (GObject *object, E_WEB_VIEW (object))); return; + case PROP_INLINE_SPELLING: + g_value_set_boolean ( + value, e_web_view_get_inline_spelling ( + E_WEB_VIEW (object))); + return; + + case PROP_MAGIC_LINKS: + g_value_set_boolean ( + value, e_web_view_get_magic_links ( + E_WEB_VIEW (object))); + return; + + case PROP_MAGIC_SMILEYS: + g_value_set_boolean ( + value, e_web_view_get_magic_smileys ( + E_WEB_VIEW (object))); + return; + case PROP_OPEN_PROXY: g_value_set_object ( value, e_web_view_get_open_proxy ( @@ -1004,7 +1052,7 @@ web_view_selectable_select_all (ESelectable *selectable) } static void -web_view_class_init (EWebViewClass *class) +e_web_view_class_init (EWebViewClass *class) { GObjectClass *object_class; GtkWidgetClass *widget_class; @@ -1063,7 +1111,6 @@ web_view_class_init (EWebViewClass *class) PROP_COPY_TARGET_LIST, "copy-target-list"); -#ifndef G_OS_WIN32 g_object_class_install_property ( object_class, PROP_DISABLE_PRINTING, @@ -1072,7 +1119,8 @@ web_view_class_init (EWebViewClass *class) "Disable Printing", NULL, FALSE, - G_PARAM_READWRITE)); + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT)); g_object_class_install_property ( object_class, @@ -1082,8 +1130,8 @@ web_view_class_init (EWebViewClass *class) "Disable Save-to-Disk", NULL, FALSE, - G_PARAM_READWRITE)); -#endif + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT)); g_object_class_install_property ( object_class, @@ -1097,6 +1145,36 @@ web_view_class_init (EWebViewClass *class) g_object_class_install_property ( object_class, + PROP_INLINE_SPELLING, + g_param_spec_boolean ( + "inline-spelling", + "Inline Spelling", + NULL, + FALSE, + G_PARAM_READWRITE)); + + g_object_class_install_property ( + object_class, + PROP_MAGIC_LINKS, + g_param_spec_boolean ( + "magic-links", + "Magic Links", + NULL, + FALSE, + G_PARAM_READWRITE)); + + g_object_class_install_property ( + object_class, + PROP_MAGIC_SMILEYS, + g_param_spec_boolean ( + "magic-smileys", + "Magic Smileys", + NULL, + FALSE, + G_PARAM_READWRITE)); + + g_object_class_install_property ( + object_class, PROP_OPEN_PROXY, g_param_spec_object ( "open-proxy", @@ -1209,7 +1287,7 @@ web_view_class_init (EWebViewClass *class) } static void -web_view_selectable_init (ESelectableInterface *interface) +e_web_view_selectable_init (ESelectableInterface *interface) { interface->update_actions = web_view_selectable_update_actions; interface->cut_clipboard = web_view_selectable_cut_clipboard; @@ -1219,7 +1297,7 @@ web_view_selectable_init (ESelectableInterface *interface) } static void -web_view_init (EWebView *web_view) +e_web_view_init (EWebView *web_view) { GtkUIManager *ui_manager; GtkActionGroup *action_group; @@ -1335,41 +1413,8 @@ web_view_init (EWebView *web_view) id = "org.gnome.evolution.webview"; e_plugin_ui_register_manager (ui_manager, id, web_view); e_plugin_ui_enable_manager (ui_manager, id); -} - -GType -e_web_view_get_type (void) -{ - static GType type = 0; - - if (G_UNLIKELY (type == 0)) { - static const GTypeInfo type_info = { - sizeof (EWebViewClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) web_view_class_init, - (GClassFinalizeFunc) NULL, - NULL, /* class_data */ - sizeof (EWebView), - 0, /* n_preallocs */ - (GInstanceInitFunc) web_view_init, - NULL /* value_table */ - }; - - static const GInterfaceInfo selectable_info = { - (GInterfaceInitFunc) web_view_selectable_init, - (GInterfaceFinalizeFunc) NULL, - NULL /* interface_data */ - }; - - type = g_type_register_static ( - GTK_TYPE_HTML, "EWebView", &type_info, 0); - - g_type_add_interface_static ( - type, E_TYPE_SELECTABLE, &selectable_info); - } - return type; + e_extensible_load_extensions (E_EXTENSIBLE (web_view)); } GtkWidget * @@ -1522,6 +1567,84 @@ e_web_view_set_editable (EWebView *web_view, g_object_notify (G_OBJECT (web_view), "editable"); } +gboolean +e_web_view_get_inline_spelling (EWebView *web_view) +{ + /* XXX This is just here to maintain symmetry + * with e_web_view_set_inline_spelling(). */ + + g_return_val_if_fail (E_IS_WEB_VIEW (web_view), FALSE); + + return gtk_html_get_inline_spelling (GTK_HTML (web_view)); +} + +void +e_web_view_set_inline_spelling (EWebView *web_view, + gboolean inline_spelling) +{ + /* XXX GtkHTML does not utilize GObject properties as well + * as it could. This just wraps gtk_html_set_inline_spelling() + * so we get a "notify::inline-spelling" signal. */ + + g_return_if_fail (E_IS_WEB_VIEW (web_view)); + + gtk_html_set_inline_spelling (GTK_HTML (web_view), inline_spelling); + + g_object_notify (G_OBJECT (web_view), "inline-spelling"); +} + +gboolean +e_web_view_get_magic_links (EWebView *web_view) +{ + /* XXX This is just here to maintain symmetry + * with e_web_view_set_magic_links(). */ + + g_return_val_if_fail (E_IS_WEB_VIEW (web_view), FALSE); + + return gtk_html_get_magic_links (GTK_HTML (web_view)); +} + +void +e_web_view_set_magic_links (EWebView *web_view, + gboolean magic_links) +{ + /* XXX GtkHTML does not utilize GObject properties as well + * as it could. This just wraps gtk_html_set_magic_links() + * so we can get a "notify::magic-links" signal. */ + + g_return_if_fail (E_IS_WEB_VIEW (web_view)); + + gtk_html_set_magic_links (GTK_HTML (web_view), magic_links); + + g_object_notify (G_OBJECT (web_view), "magic-links"); +} + +gboolean +e_web_view_get_magic_smileys (EWebView *web_view) +{ + /* XXX This is just here to maintain symmetry + * with e_web_view_set_magic_smileys(). */ + + g_return_val_if_fail (E_IS_WEB_VIEW (web_view), FALSE); + + return gtk_html_get_magic_smileys (GTK_HTML (web_view)); +} + +void +e_web_view_set_magic_smileys (EWebView *web_view, + gboolean magic_smileys) +{ + /* XXX GtkHTML does not utilize GObject properties as well + * as it could. This just wraps gtk_html_set_magic_smileys() + * so we can get a "notify::magic-smileys" signal. */ + + g_return_if_fail (E_IS_WEB_VIEW (web_view)); + + gtk_html_set_magic_smileys (GTK_HTML (web_view), magic_smileys); + + g_object_notify (G_OBJECT (web_view), "magic-smileys"); +} + const gchar * e_web_view_get_selected_uri (EWebView *web_view) { diff --git a/widgets/misc/e-web-view.h b/widgets/misc/e-web-view.h index 788eadb1b7..0fea6eb3cf 100644 --- a/widgets/misc/e-web-view.h +++ b/widgets/misc/e-web-view.h @@ -106,6 +106,15 @@ void e_web_view_set_disable_save_to_disk gboolean e_web_view_get_editable (EWebView *web_view); void e_web_view_set_editable (EWebView *web_view, gboolean editable); +gboolean e_web_view_get_inline_spelling (EWebView *web_view); +void e_web_view_set_inline_spelling (EWebView *web_view, + gboolean inline_spelling); +gboolean e_web_view_get_magic_links (EWebView *web_view); +void e_web_view_set_magic_links (EWebView *web_view, + gboolean magic_links); +gboolean e_web_view_get_magic_smileys (EWebView *web_view); +void e_web_view_set_magic_smileys (EWebView *web_view, + gboolean magic_smileys); const gchar * e_web_view_get_selected_uri (EWebView *web_view); void e_web_view_set_selected_uri (EWebView *web_view, const gchar *selected_uri); |