diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2010-03-23 00:03:46 +0800 |
---|---|---|
committer | Michael Meeks <michael.meeks@novell.com> | 2010-04-07 19:14:43 +0800 |
commit | fe177f5a12127203f0b77c32ec0ae17d7394f6b2 (patch) | |
tree | bc06700f8a31c60df514a204b3804f86bcf1228c /widgets/misc | |
parent | bcc26ae24c1b223667807825d1a7bd4bc4574a32 (diff) | |
download | gsoc2013-evolution-fe177f5a12127203f0b77c32ec0ae17d7394f6b2.tar.gz gsoc2013-evolution-fe177f5a12127203f0b77c32ec0ae17d7394f6b2.tar.zst gsoc2013-evolution-fe177f5a12127203f0b77c32ec0ae17d7394f6b2.zip |
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
Diffstat (limited to 'widgets/misc')
-rw-r--r-- | widgets/misc/e-web-view.c | 209 | ||||
-rw-r--r-- | widgets/misc/e-web-view.h | 9 |
2 files changed, 176 insertions, 42 deletions
diff --git a/widgets/misc/e-web-view.c b/widgets/misc/e-web-view.c index ce41c32d4c..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; @@ -1071,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, @@ -1081,7 +1130,8 @@ web_view_class_init (EWebViewClass *class) "Disable Save-to-Disk", NULL, FALSE, - G_PARAM_READWRITE)); + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT)); g_object_class_install_property ( object_class, @@ -1095,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", @@ -1207,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; @@ -1217,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; @@ -1333,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 * @@ -1520,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); |