diff options
Diffstat (limited to 'modules/settings')
-rw-r--r-- | modules/settings/e-settings-mail-formatter.c | 77 | ||||
-rw-r--r-- | modules/settings/e-settings-mail-reader.c | 23 | ||||
-rw-r--r-- | modules/settings/e-settings-web-view-gtkhtml.c | 146 | ||||
-rw-r--r-- | modules/settings/e-settings-web-view.c | 30 |
4 files changed, 147 insertions, 129 deletions
diff --git a/modules/settings/e-settings-mail-formatter.c b/modules/settings/e-settings-mail-formatter.c index 1efd290690..7733c02c74 100644 --- a/modules/settings/e-settings-mail-formatter.c +++ b/modules/settings/e-settings-mail-formatter.c @@ -22,7 +22,6 @@ #include "e-settings-mail-formatter.h" -#include <shell/e-shell.h> #include <e-util/e-util.h> #include <em-format/e-mail-formatter.h> #include <mail/e-mail-reader-utils.h> @@ -51,6 +50,24 @@ settings_mail_formatter_get_extensible (ESettingsMailFormatter *extension) return E_MAIL_FORMATTER (extensible); } +static gboolean +settings_mail_formatter_map_string_to_color (GValue *value, + GVariant *variant, + gpointer user_data) +{ + GdkColor color; + const gchar *string; + gboolean success = FALSE; + + string = g_variant_get_string (variant, NULL); + if (gdk_color_parse (string, &color)) { + g_value_set_boxed (value, &color); + success = TRUE; + } + + return success; +} + static void settings_mail_formatter_headers_changed_cb (GSettings *settings, const gchar *key, @@ -91,14 +108,15 @@ settings_mail_formatter_dispose (GObject *object) priv = E_SETTINGS_MAIL_FORMATTER_GET_PRIVATE (object); - if (priv->settings != NULL) { + if (priv->headers_changed_id > 0) { g_signal_handler_disconnect ( priv->settings, priv->headers_changed_id); - g_object_unref (priv->settings); - priv->settings = NULL; + priv->headers_changed_id = 0; } + g_clear_object (&priv->settings); + /* Chain up to parent's dispose() method. */ G_OBJECT_CLASS (e_settings_mail_formatter_parent_class)-> dispose (object); @@ -109,46 +127,45 @@ settings_mail_formatter_constructed (GObject *object) { ESettingsMailFormatter *extension; EMailFormatter *formatter; - EShellSettings *shell_settings; - EShell *shell; + GSettings *settings; extension = E_SETTINGS_MAIL_FORMATTER (object); formatter = settings_mail_formatter_get_extensible (extension); - shell = e_shell_get_default (); - shell_settings = e_shell_get_shell_settings (shell); + settings = extension->priv->settings; - g_object_bind_property_full ( - shell_settings, "mail-citation-color", + g_settings_bind_with_mapping ( + settings, "citation-color", formatter, "citation-color", - G_BINDING_SYNC_CREATE, - e_binding_transform_string_to_color, - NULL, NULL, (GDestroyNotify) NULL); + G_SETTINGS_BIND_GET, + settings_mail_formatter_map_string_to_color, + (GSettingsBindSetMapping) NULL, + NULL, (GDestroyNotify) NULL); - g_object_bind_property ( - shell_settings, "mail-mark-citations", + g_settings_bind ( + settings, "mark-citations", formatter, "mark-citations", - G_BINDING_SYNC_CREATE); + G_SETTINGS_BIND_GET); - g_object_bind_property ( - shell_settings, "mail-image-loading-policy", + g_settings_bind ( + settings, "image-loading-policy", formatter, "image-loading-policy", G_BINDING_SYNC_CREATE); - g_object_bind_property ( - shell_settings, "mail-show-sender-photo", + g_settings_bind ( + settings, "show-sender-photo", formatter, "show-sender-photo", - G_BINDING_SYNC_CREATE); + G_SETTINGS_BIND_GET); - g_object_bind_property ( - shell_settings, "mail-show-real-date", + g_settings_bind ( + settings, "show-real-date", formatter, "show-real-date", - G_BINDING_SYNC_CREATE); + G_SETTINGS_BIND_GET); - g_object_bind_property ( - shell_settings, "mail-show-animated-images", + g_settings_bind ( + settings, "show-animated-images", formatter, "animate-images", - G_BINDING_SYNC_CREATE); + G_SETTINGS_BIND_GET); extension->priv->headers_changed_id = g_signal_connect ( extension->priv->settings, "changed::headers", @@ -189,10 +206,12 @@ e_settings_mail_formatter_class_finalize (ESettingsMailFormatterClass *class) static void e_settings_mail_formatter_init (ESettingsMailFormatter *extension) { + GSettings *settings; + extension->priv = E_SETTINGS_MAIL_FORMATTER_GET_PRIVATE (extension); - extension->priv->settings = - g_settings_new ("org.gnome.evolution.mail"); + settings = g_settings_new ("org.gnome.evolution.mail"); + extension->priv->settings = settings; } void diff --git a/modules/settings/e-settings-mail-reader.c b/modules/settings/e-settings-mail-reader.c index 17ab57b3b8..d333c81bf0 100644 --- a/modules/settings/e-settings-mail-reader.c +++ b/modules/settings/e-settings-mail-reader.c @@ -43,31 +43,34 @@ settings_mail_reader_idle_cb (EExtension *extension) { EExtensible *extensible; GtkActionGroup *action_group; - EShellSettings *shell_settings; ESourceRegistry *registry; + GSettings *settings; ESource *source; EShell *shell; extensible = e_extension_get_extensible (extension); - shell = e_shell_get_default (); - registry = e_shell_get_registry (shell); - shell_settings = e_shell_get_shell_settings (shell); + settings = g_settings_new ("org.gnome.evolution.mail"); - g_object_bind_property ( - shell_settings, "mail-forward-style", + g_settings_bind ( + settings, "forward-style-name", extensible, "forward-style", - G_BINDING_SYNC_CREATE); + G_SETTINGS_BIND_GET); - g_object_bind_property ( - shell_settings, "mail-reply-style", + g_settings_bind ( + settings, "reply-style-name", extensible, "reply-style", - G_BINDING_SYNC_CREATE); + G_SETTINGS_BIND_GET); + + g_object_unref (settings); action_group = e_mail_reader_get_action_group ( E_MAIL_READER (extensible), E_MAIL_READER_ACTION_GROUP_SEARCH_FOLDERS); + shell = e_shell_get_default (); + registry = e_shell_get_registry (shell); + source = e_source_registry_ref_source (registry, "vfolder"); g_object_bind_property ( diff --git a/modules/settings/e-settings-web-view-gtkhtml.c b/modules/settings/e-settings-web-view-gtkhtml.c index 49e8112601..297e88f508 100644 --- a/modules/settings/e-settings-web-view-gtkhtml.c +++ b/modules/settings/e-settings-web-view-gtkhtml.c @@ -25,7 +25,7 @@ #include "e-settings-web-view-gtkhtml.h" -#include <shell/e-shell.h> +#include <e-util/e-util.h> #define E_SETTINGS_WEB_VIEW_GTKHTML_GET_PRIVATE(obj) \ (G_TYPE_INSTANCE_GET_PRIVATE \ @@ -33,7 +33,7 @@ struct _ESettingsWebViewGtkHTMLPrivate { GtkCssProvider *css_provider; - EShellSettings *shell_settings; + GSettings *settings; }; G_DEFINE_DYNAMIC_TYPE ( @@ -74,33 +74,28 @@ settings_web_view_gtkhtml_load_style (ESettingsWebViewGtkHTML *extension) gboolean custom_fonts; gboolean mark_citations; EExtensible *extensible; - EShellSettings *shell_settings; GtkStyleContext *style_context; + GSettings *settings; GError *error = NULL; /* Some of our mail and composer preferences are passed down to * GtkHtml through style properties, unfortunately. This builds * a style sheet for the EWebView using values from GSettings. */ - shell_settings = extension->priv->shell_settings; - - custom_fonts = e_shell_settings_get_boolean ( - shell_settings, "mail-use-custom-fonts"); - - monospace_font = e_shell_settings_get_string ( - shell_settings, "mail-font-monospace"); - - variable_font = e_shell_settings_get_string ( - shell_settings, "mail-font-variable"); - - mark_citations = e_shell_settings_get_boolean ( - shell_settings, "mail-mark-citations"); - - citation_color = e_shell_settings_get_string ( - shell_settings, "mail-citation-color"); - - spell_color = e_shell_settings_get_string ( - shell_settings, "composer-spell-color"); + settings = extension->priv->settings; + + custom_fonts = + g_settings_get_boolean (settings, "use-custom-font"); + monospace_font = + g_settings_get_string (settings, "monospace-font"); + variable_font = + g_settings_get_string (settings, "variable-width-font"); + mark_citations = + g_settings_get_boolean (settings, "mark-citations"); + citation_color = + g_settings_get_string (settings, "citation-color"); + spell_color = + g_settings_get_string (settings, "composer-spell-color"); buffer = g_string_new ("EWebViewGtkHTML {\n"); @@ -150,27 +145,35 @@ settings_web_view_gtkhtml_load_style (ESettingsWebViewGtkHTML *extension) } static void +settings_web_view_gtkhtml_changed_cb (GSettings *settings, + const gchar *key, + ESettingsWebViewGtkHTML *extension) +{ + settings_web_view_gtkhtml_load_style (extension); +} + +static void settings_web_view_gtkhtml_realize (GtkWidget *widget, ESettingsWebViewGtkHTML *extension) { - EShellSettings *shell_settings; + GSettings *settings; - shell_settings = extension->priv->shell_settings; + settings = extension->priv->settings; - g_object_bind_property ( - shell_settings, "composer-inline-spelling", + g_settings_bind ( + settings, "composer-inline-spelling", widget, "inline-spelling", - G_BINDING_SYNC_CREATE); + G_SETTINGS_BIND_GET); - g_object_bind_property ( - shell_settings, "composer-magic-links", + g_settings_bind ( + settings, "composer-magic-links", widget, "magic-links", - G_BINDING_SYNC_CREATE); + G_SETTINGS_BIND_GET); - g_object_bind_property ( - shell_settings, "composer-magic-smileys", + g_settings_bind ( + settings, "composer-magic-smileys", widget, "magic-smileys", - G_BINDING_SYNC_CREATE); + G_SETTINGS_BIND_GET); gtk_style_context_add_provider ( gtk_widget_get_style_context (widget), @@ -181,34 +184,34 @@ settings_web_view_gtkhtml_realize (GtkWidget *widget, /* Reload the style sheet when certain settings change. */ - g_signal_connect_swapped ( - shell_settings, "notify::mail-use-custom-fonts", - G_CALLBACK (settings_web_view_gtkhtml_load_style), + g_signal_connect ( + settings, "changed::use-custom-font", + G_CALLBACK (settings_web_view_gtkhtml_changed_cb), extension); - g_signal_connect_swapped ( - shell_settings, "notify::mail-font-monospace", - G_CALLBACK (settings_web_view_gtkhtml_load_style), + g_signal_connect ( + settings, "changed::monospace-font", + G_CALLBACK (settings_web_view_gtkhtml_changed_cb), extension); - g_signal_connect_swapped ( - shell_settings, "notify::mail-font-variable", - G_CALLBACK (settings_web_view_gtkhtml_load_style), + g_signal_connect ( + settings, "changed::variable-width-font", + G_CALLBACK (settings_web_view_gtkhtml_changed_cb), extension); - g_signal_connect_swapped ( - shell_settings, "notify::mail-mark-citations", - G_CALLBACK (settings_web_view_gtkhtml_load_style), + g_signal_connect ( + settings, "changed::mark-citations", + G_CALLBACK (settings_web_view_gtkhtml_changed_cb), extension); - g_signal_connect_swapped ( - shell_settings, "notify::mail-citation-color", - G_CALLBACK (settings_web_view_gtkhtml_load_style), + g_signal_connect ( + settings, "changed::citation-color", + G_CALLBACK (settings_web_view_gtkhtml_changed_cb), extension); - g_signal_connect_swapped ( - shell_settings, "notify::composer-spell-color", - G_CALLBACK (settings_web_view_gtkhtml_load_style), + g_signal_connect ( + settings, "changed::composer-spell-color", + G_CALLBACK (settings_web_view_gtkhtml_changed_cb), extension); } @@ -219,19 +222,15 @@ settings_web_view_gtkhtml_dispose (GObject *object) priv = E_SETTINGS_WEB_VIEW_GTKHTML_GET_PRIVATE (object); - if (priv->css_provider != NULL) { - g_object_unref (priv->css_provider); - priv->css_provider = NULL; - } - - if (priv->shell_settings != NULL) { + if (priv->settings != NULL) { g_signal_handlers_disconnect_by_func ( - priv->shell_settings, - settings_web_view_gtkhtml_load_style, object); - g_object_unref (priv->shell_settings); - priv->shell_settings = NULL; + priv->settings, + settings_web_view_gtkhtml_changed_cb, object); } + g_clear_object (&priv->css_provider); + g_clear_object (&priv->settings); + /* Chain up to parent's dispose() method. */ G_OBJECT_CLASS (e_settings_web_view_gtkhtml_parent_class)-> dispose (object); @@ -240,27 +239,17 @@ settings_web_view_gtkhtml_dispose (GObject *object) static void settings_web_view_gtkhtml_constructed (GObject *object) { - EShell *shell; - EShellSettings *shell_settings; - ESettingsWebViewGtkHTML *extension; EExtensible *extensible; - shell = e_shell_get_default (); - shell_settings = e_shell_get_shell_settings (shell); - - extension = (ESettingsWebViewGtkHTML *) object; - extensible = e_extension_get_extensible (E_EXTENSION (extension)); - - extension->priv->css_provider = gtk_css_provider_new (); - extension->priv->shell_settings = g_object_ref (shell_settings); + extensible = e_extension_get_extensible (E_EXTENSION (object)); - /* Wait to bind shell settings until the EWebView is realized - * so GtkhtmlEditor has a chance to install a GtkHTMLEditorAPI. + /* Wait to bind 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 (settings_web_view_gtkhtml_realize), extension); + G_CALLBACK (settings_web_view_gtkhtml_realize), object); /* Chain up to parent's constructed() method. */ G_OBJECT_CLASS (e_settings_web_view_gtkhtml_parent_class)-> @@ -292,8 +281,15 @@ e_settings_web_view_gtkhtml_class_finalize (ESettingsWebViewGtkHTMLClass *class) static void e_settings_web_view_gtkhtml_init (ESettingsWebViewGtkHTML *extension) { + GSettings *settings; + extension->priv = E_SETTINGS_WEB_VIEW_GTKHTML_GET_PRIVATE (extension); + + extension->priv->css_provider = gtk_css_provider_new (); + + settings = g_settings_new ("org.gnome.evolution.mail"); + extension->priv->settings = settings; } void diff --git a/modules/settings/e-settings-web-view.c b/modules/settings/e-settings-web-view.c index c8da19f377..843a75070c 100644 --- a/modules/settings/e-settings-web-view.c +++ b/modules/settings/e-settings-web-view.c @@ -25,7 +25,7 @@ #include "e-settings-web-view.h" -#include <shell/e-shell.h> +#include <e-util/e-util.h> #define E_SETTINGS_WEB_VIEW_GET_PRIVATE(obj) \ (G_TYPE_INSTANCE_GET_PRIVATE \ @@ -43,29 +43,29 @@ G_DEFINE_DYNAMIC_TYPE ( static void settings_web_view_constructed (GObject *object) { - EShell *shell; - EShellSettings *shell_settings; + GSettings *settings; EExtensible *extensible; - shell = e_shell_get_default (); - shell_settings = e_shell_get_shell_settings (shell); - extensible = e_extension_get_extensible (E_EXTENSION (object)); - g_object_bind_property ( - shell_settings, "composer-inline-spelling", + settings = g_settings_new ("org.gnome.evolution.mail"); + + g_settings_bind ( + settings, "composer-inline-spelling", extensible, "inline-spelling", - G_BINDING_SYNC_CREATE); + G_SETTINGS_BIND_GET); - g_object_bind_property ( - shell_settings, "composer-magic-links", + g_settings_bind ( + settings, "composer-magic-links", extensible, "magic-links", - G_BINDING_SYNC_CREATE); + G_SETTINGS_BIND_GET); - g_object_bind_property ( - shell_settings, "composer-magic-smileys", + g_settings_bind ( + settings, "composer-magic-smileys", extensible, "magic-smileys", - G_BINDING_SYNC_CREATE); + G_SETTINGS_BIND_GET); + + g_object_unref (settings); /* Chain up to parent's constructed() method. */ G_OBJECT_CLASS (e_settings_web_view_parent_class)-> |