diff options
Diffstat (limited to 'modules')
-rw-r--r-- | modules/mail/Makefile.am | 2 | ||||
-rw-r--r-- | modules/mail/e-mail-attachment-handler.c | 18 | ||||
-rw-r--r-- | modules/mail/e-mail-shell-backend.c | 86 | ||||
-rw-r--r-- | modules/mail/e-mail-shell-settings.c | 386 | ||||
-rw-r--r-- | modules/mail/e-mail-shell-settings.h | 33 | ||||
-rw-r--r-- | modules/mail/e-mail-shell-sidebar.c | 24 | ||||
-rw-r--r-- | modules/mail/e-mail-shell-view-actions.c | 24 | ||||
-rw-r--r-- | modules/mail/em-composer-prefs.c | 264 | ||||
-rw-r--r-- | modules/mail/em-mailer-prefs.c | 407 | ||||
-rw-r--r-- | modules/mail/em-mailer-prefs.h | 5 | ||||
-rw-r--r-- | modules/mailto-handler/evolution-mailto-handler.c | 39 | ||||
-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 | ||||
-rw-r--r-- | modules/text-highlight/e-mail-formatter-text-highlight.c | 61 |
16 files changed, 592 insertions, 1033 deletions
diff --git a/modules/mail/Makefile.am b/modules/mail/Makefile.am index bbf8366cfb..a488ba292e 100644 --- a/modules/mail/Makefile.am +++ b/modules/mail/Makefile.am @@ -23,8 +23,6 @@ module_mail_la_SOURCES = \ e-mail-shell-backend.h \ e-mail-shell-content.c \ e-mail-shell-content.h \ - e-mail-shell-settings.c \ - e-mail-shell-settings.h \ e-mail-shell-sidebar.c \ e-mail-shell-sidebar.h \ e-mail-shell-view.c \ diff --git a/modules/mail/e-mail-attachment-handler.c b/modules/mail/e-mail-attachment-handler.c index 98680f8299..d6caecf556 100644 --- a/modules/mail/e-mail-attachment-handler.c +++ b/modules/mail/e-mail-attachment-handler.c @@ -121,19 +121,18 @@ mail_attachment_handler_forward (GtkAction *action, EAttachmentHandler *handler) { EMailAttachmentHandlerPrivate *priv; - EShellSettings *shell_settings; + GSettings *settings; EMailForwardStyle style; CamelMimeMessage *message; - const gchar *property_name; priv = E_MAIL_ATTACHMENT_HANDLER_GET_PRIVATE (handler); message = mail_attachment_handler_get_selected_message (handler); g_return_if_fail (message != NULL); - property_name = "mail-forward-style"; - shell_settings = e_shell_get_shell_settings (priv->shell); - style = e_shell_settings_get_int (shell_settings, property_name); + settings = g_settings_new ("org.gnome.evolution.mail"); + style = g_settings_get_enum (settings, "forward-style-name"); + g_object_unref (settings); em_utils_forward_message ( priv->shell, CAMEL_SESSION (priv->session), @@ -147,19 +146,18 @@ mail_attachment_handler_reply (EAttachmentHandler *handler, EMailReplyType reply_type) { EMailAttachmentHandlerPrivate *priv; - EShellSettings *shell_settings; + GSettings *settings; EMailReplyStyle style; CamelMimeMessage *message; - const gchar *property_name; priv = E_MAIL_ATTACHMENT_HANDLER_GET_PRIVATE (handler); message = mail_attachment_handler_get_selected_message (handler); g_return_if_fail (message != NULL); - property_name = "mail-reply-style"; - shell_settings = e_shell_get_shell_settings (priv->shell); - style = e_shell_settings_get_int (shell_settings, property_name); + settings = g_settings_new ("org.gnome.evolution.mail"); + style = g_settings_get_enum (settings, "reply-style-name"); + g_object_unref (settings); em_utils_reply_to_message ( priv->shell, message, diff --git a/modules/mail/e-mail-shell-backend.c b/modules/mail/e-mail-shell-backend.c index 1abcb8a136..ecb295ea10 100644 --- a/modules/mail/e-mail-shell-backend.c +++ b/modules/mail/e-mail-shell-backend.c @@ -53,7 +53,6 @@ #include <em-format/e-mail-formatter.h> #include <em-format/e-mail-part-utils.h> -#include "e-mail-shell-settings.h" #include "e-mail-shell-sidebar.h" #include "e-mail-shell-view.h" #include "em-account-prefs.h" @@ -369,7 +368,7 @@ mail_shell_backend_window_added_cb (GtkApplication *application, /* This applies to both the composer and signature editor. */ if (GTKHTML_IS_EDITOR (window)) { - EShellSettings *shell_settings; + GSettings *settings; GList *spell_languages; gboolean active = TRUE; @@ -378,12 +377,14 @@ mail_shell_backend_window_added_cb (GtkApplication *application, GTKHTML_EDITOR (window), spell_languages); g_list_free (spell_languages); - shell_settings = e_shell_get_shell_settings (shell); + settings = g_settings_new ("org.gnome.evolution.mail"); /* Express mode does not honor this setting. */ if (!e_shell_get_express_mode (shell)) - active = e_shell_settings_get_boolean ( - shell_settings, "composer-format-html"); + active = g_settings_get_boolean ( + settings, "composer-send-html"); + + g_object_unref (settings); gtkhtml_editor_set_html_mode (GTKHTML_EDITOR (window), active); } @@ -513,15 +514,14 @@ static void mail_shell_backend_constructed (GObject *object) { EShell *shell; - EShellSettings *shell_settings; EShellBackend *shell_backend; EMailSession *mail_session; CamelService *vstore; GtkWidget *preferences_window; + GSettings *settings; shell_backend = E_SHELL_BACKEND (object); shell = e_shell_backend_get_shell (shell_backend); - shell_settings = e_shell_get_shell_settings (shell); /* Chain up to parent's constructed() method. */ G_OBJECT_CLASS (e_mail_shell_backend_parent_class)->constructed (object); @@ -543,8 +543,6 @@ mail_shell_backend_constructed (GObject *object) G_CALLBACK (mail_shell_backend_window_added_cb), shell_backend); - e_mail_shell_settings_init (shell_backend); - /* Setup preference widget factories */ preferences_window = e_shell_get_preferences_window (shell); @@ -589,10 +587,14 @@ mail_shell_backend_constructed (GObject *object) CAMEL_SESSION (mail_session), E_MAIL_SESSION_VFOLDER_UID); g_return_if_fail (vstore != NULL); - g_object_bind_property ( - shell_settings, "mail-enable-unmatched-search-folder", + settings = g_settings_new ("org.gnome.evolution.mail"); + + g_settings_bind ( + settings, "enable-unmatched", vstore, "unmatched-enabled", - G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL); + G_SETTINGS_BIND_DEFAULT); + + g_object_unref (settings); g_object_unref (vstore); } @@ -630,38 +632,31 @@ mail_shell_backend_start (EShellBackend *shell_backend) static gboolean mail_shell_backend_delete_junk_policy_decision (EMailBackend *backend) { - EShell *shell; - EShellSettings *shell_settings; GSettings *settings; gboolean delete_junk; - gint empty_date; - gint empty_days; + gint empty_date = 0; + gint empty_days = 0; gint now; - shell = e_shell_backend_get_shell (E_SHELL_BACKEND (backend)); - settings = g_settings_new ("org.gnome.evolution.mail"); - shell_settings = e_shell_get_shell_settings (shell); now = time (NULL) / 60 / 60 / 24; - delete_junk = e_shell_settings_get_boolean ( - shell_settings, "mail-empty-junk-on-exit"); - - /* XXX No EShellSettings properties for these keys. */ - - empty_date = empty_days = 0; + delete_junk = g_settings_get_boolean (settings, "junk-empty-on-exit"); if (delete_junk) { - empty_days = g_settings_get_int (settings, "junk-empty-on-exit-days"); - empty_date = g_settings_get_int (settings, "junk-empty-date"); + empty_days = g_settings_get_int ( + settings, "junk-empty-on-exit-days"); + empty_date = g_settings_get_int ( + settings, "junk-empty-date"); } - delete_junk = delete_junk && ((empty_days == 0) || (empty_days > 0 && empty_date + empty_days <= now)); + delete_junk = delete_junk && ( + (empty_days == 0) || + (empty_days > 0 && empty_date + empty_days <= now)); - if (delete_junk) { + if (delete_junk) g_settings_set_int (settings, "junk-empty-date", now); - } g_object_unref (settings); @@ -671,38 +666,31 @@ mail_shell_backend_delete_junk_policy_decision (EMailBackend *backend) static gboolean mail_shell_backend_empty_trash_policy_decision (EMailBackend *backend) { - EShell *shell; - EShellSettings *shell_settings; GSettings *settings; gboolean empty_trash; - gint empty_date; - gint empty_days; + gint empty_date = 0; + gint empty_days = 0; gint now; - shell = e_shell_backend_get_shell (E_SHELL_BACKEND (backend)); - settings = g_settings_new ("org.gnome.evolution.mail"); - shell_settings = e_shell_get_shell_settings (shell); now = time (NULL) / 60 / 60 / 24; - empty_trash = e_shell_settings_get_boolean ( - shell_settings, "mail-empty-trash-on-exit"); - - /* XXX No EShellSettings properties for these keys. */ - - empty_date = empty_days = 0; + empty_trash = g_settings_get_boolean (settings, "trash-empty-on-exit"); if (empty_trash) { - empty_days = g_settings_get_int (settings, "trash-empty-on-exit-days"); - empty_date = g_settings_get_int (settings, "trash-empty-date"); + empty_days = g_settings_get_int ( + settings, "trash-empty-on-exit-days"); + empty_date = g_settings_get_int ( + settings, "trash-empty-date"); } - empty_trash = empty_trash && ((empty_days == 0) || (empty_days > 0 && empty_date + empty_days <= now)); + empty_trash = empty_trash && ( + (empty_days == 0) || + (empty_days > 0 && empty_date + empty_days <= now)); - if (empty_trash) { + if (empty_trash) g_settings_set_int (settings, "trash-empty-date", now); - } g_object_unref (settings); @@ -852,8 +840,6 @@ e_mail_shell_backend_edit_account (EMailShellBackend *mail_shell_backend, /******************* Code below here belongs elsewhere. *******************/ -#include "shell/e-shell-settings.h" - static GSList * mail_labels_get_filter_options (gboolean include_none) { diff --git a/modules/mail/e-mail-shell-settings.c b/modules/mail/e-mail-shell-settings.c deleted file mode 100644 index 6982345b88..0000000000 --- a/modules/mail/e-mail-shell-settings.c +++ /dev/null @@ -1,386 +0,0 @@ -/* - * e-mail-shell-settings.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/> - * - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include "e-mail-shell-settings.h" - -#include <mail/e-mail-backend.h> - -#include <shell/e-shell.h> - -#define MAIL_SCHEMA "org.gnome.evolution.mail" - -static gboolean -transform_no_folder_dots_to_ellipsize (GBinding *binding, - const GValue *source_value, - GValue *target_value, - gpointer user_data) -{ - PangoEllipsizeMode ellipsize; - - if (g_value_get_boolean (source_value)) - ellipsize = PANGO_ELLIPSIZE_NONE; - else - ellipsize = PANGO_ELLIPSIZE_END; - - g_value_set_enum (target_value, ellipsize); - - return TRUE; -} - -void -e_mail_shell_settings_init (EShellBackend *shell_backend) -{ - EShell *shell; - EShellSettings *shell_settings; - EMailBackend *backend; - EMailSession *session; - - shell = e_shell_backend_get_shell (shell_backend); - shell_settings = e_shell_get_shell_settings (shell); - - backend = E_MAIL_BACKEND (shell_backend); - session = e_mail_backend_get_session (backend); - - /*** Global Objects ***/ - - e_shell_settings_install_property ( - g_param_spec_pointer ( - "mail-session", - NULL, - NULL, - G_PARAM_READWRITE)); - - e_shell_settings_set_pointer ( - shell_settings, "mail-session", - g_object_ref (session)); - - /*** Mail Preferences ***/ - - e_shell_settings_install_property_for_key ( - "mail-address-compress", - MAIL_SCHEMA, - "address-compress"); - - e_shell_settings_install_property_for_key ( - "mail-address-count", - MAIL_SCHEMA, - "address-count"); - - e_shell_settings_install_property_for_key ( - "mail-charset", - MAIL_SCHEMA, - "charset"); - - e_shell_settings_install_property_for_key ( - "mail-check-for-junk", - MAIL_SCHEMA, - "junk-check-incoming"); - - e_shell_settings_install_property_for_key ( - "mail-check-on-start", - MAIL_SCHEMA, - "send-recv-on-start"); - - e_shell_settings_install_property_for_key ( - "mail-check-all-on-start", - MAIL_SCHEMA, - "send-recv-all-on-start"); - - e_shell_settings_install_property_for_key ( - "mail-citation-color", - MAIL_SCHEMA, - "citation-color"); - - e_shell_settings_install_property_for_key ( - "mail-confirm-expunge", - MAIL_SCHEMA, - "prompt-on-expunge"); - - e_shell_settings_install_property_for_key ( - "mail-confirm-unwanted-html", - MAIL_SCHEMA, - "prompt-on-unwanted-html"); - - e_shell_settings_install_property_for_key ( - "mail-empty-junk-on-exit", - MAIL_SCHEMA, - "junk-empty-on-exit"); - - e_shell_settings_install_property_for_key ( - "mail-empty-trash-on-exit", - MAIL_SCHEMA, - "trash-empty-on-exit"); - - e_shell_settings_install_property_for_key ( - "mail-enable-unmatched-search-folder", - MAIL_SCHEMA, - "enable-unmatched"); - - e_shell_settings_install_property_for_key ( - "mail-font-monospace", - MAIL_SCHEMA, - "monospace-font"); - - e_shell_settings_install_property_for_key ( - "mail-font-variable", - MAIL_SCHEMA, - "variable-width-font"); - - /* This value corresponds to the EMailForwardStyle enum. */ - e_shell_settings_install_property_for_key ( - "mail-forward-style", - MAIL_SCHEMA, - "forward-style"); - - /* This value corresponds to MailConfigHTTPMode enum. */ - e_shell_settings_install_property_for_key ( - "mail-image-loading-policy", - MAIL_SCHEMA, - "load-http-images"); - - e_shell_settings_install_property_for_key ( - "mail-magic-spacebar", - MAIL_SCHEMA, - "magic-spacebar"); - - e_shell_settings_install_property_for_key ( - "mail-global-view-setting", - MAIL_SCHEMA, - "global-view-setting"); - - e_shell_settings_install_property_for_key ( - "mail-mark-citations", - MAIL_SCHEMA, - "mark-citations"); - - e_shell_settings_install_property_for_key ( - "mail-mark-seen", - MAIL_SCHEMA, - "mark-seen"); - - e_shell_settings_install_property_for_key ( - "mail-mark-seen-timeout", - MAIL_SCHEMA, - "mark-seen-timeout"); - - /* Do not bind to this. Use "mail-sidebar-ellipsize" instead. */ - e_shell_settings_install_property_for_key ( - "mail-no-folder-dots", - MAIL_SCHEMA, - "no-folder-dots"); - - e_shell_settings_install_property_for_key ( - "mail-only-local-photos", - MAIL_SCHEMA, - "photo-local"); - - e_shell_settings_install_property_for_key ( - "mail-show-real-date", - MAIL_SCHEMA, - "show-real-date"); - - e_shell_settings_install_property_for_key ( - "mail-sort-accounts-alpha", - MAIL_SCHEMA, - "sort-accounts-alpha"); - - e_shell_settings_install_property_for_key ( - "mail-prompt-delete-in-vfolder", - MAIL_SCHEMA, - "prompt-on-delete-in-vfolder"); - - /* This value corresponds to the EMailReplyStyle enum, - * but the ordering of the combo box items in preferences - * has changed. We use transformation functions there. */ - e_shell_settings_install_property_for_key ( - "mail-reply-style", - MAIL_SCHEMA, - "reply-style"); - - e_shell_settings_install_property_for_key ( - "mail-safe-list", - MAIL_SCHEMA, - "safe-list"); - - e_shell_settings_install_property_for_key ( - "mail-show-animated-images", - MAIL_SCHEMA, - "show-animated-images"); - - e_shell_settings_install_property_for_key ( - "mail-show-sender-photo", - MAIL_SCHEMA, - "show-sender-photo"); - - e_shell_settings_install_property_for_key ( - "mail-sidebar-search", - MAIL_SCHEMA, - "side-bar-search"); - - e_shell_settings_install_property_for_key ( - "mail-thread-by-subject", - MAIL_SCHEMA, - "thread-subject"); - - e_shell_settings_install_property_for_key ( - "mail-use-custom-fonts", - MAIL_SCHEMA, - "use-custom-font"); - - /*** Composer Preferences ***/ - - e_shell_settings_install_property_for_key ( - "composer-charset", - MAIL_SCHEMA, - "composer-charset"); - - e_shell_settings_install_property_for_key ( - "composer-format-html", - MAIL_SCHEMA, - "composer-send-html"); - - e_shell_settings_install_property_for_key ( - "composer-inline-spelling", - MAIL_SCHEMA, - "composer-inline-spelling"); - - e_shell_settings_install_property_for_key ( - "composer-magic-links", - MAIL_SCHEMA, - "composer-magic-links"); - - e_shell_settings_install_property_for_key ( - "composer-magic-smileys", - MAIL_SCHEMA, - "composer-magic-smileys"); - - e_shell_settings_install_property_for_key ( - "composer-outlook-filenames", - MAIL_SCHEMA, - "composer-outlook-filenames"); - - e_shell_settings_install_property_for_key ( - "composer-localized-re", - MAIL_SCHEMA, - "composer-localized-re"); - - e_shell_settings_install_property_for_key ( - "composer-ignore-list-reply-to", - MAIL_SCHEMA, - "composer-ignore-list-reply-to"); - - e_shell_settings_install_property_for_key ( - "composer-group-reply-to-list", - MAIL_SCHEMA, - "composer-group-reply-to-list"); - - e_shell_settings_install_property_for_key ( - "composer-sign-reply-if-signed", - MAIL_SCHEMA, - "composer-sign-reply-if-signed"); - - e_shell_settings_install_property_for_key ( - "composer-prompt-only-bcc", - MAIL_SCHEMA, - "prompt-on-only-bcc"); - - e_shell_settings_install_property_for_key ( - "composer-prompt-private-list-reply", - MAIL_SCHEMA, - "prompt-on-private-list-reply"); - - e_shell_settings_install_property_for_key ( - "composer-prompt-reply-many-recips", - MAIL_SCHEMA, - "prompt-on-reply-many-recips"); - - e_shell_settings_install_property_for_key ( - "composer-prompt-list-reply-to", - MAIL_SCHEMA, - "prompt-on-list-reply-to"); - - e_shell_settings_install_property_for_key ( - "composer-prompt-empty-subject", - MAIL_SCHEMA, - "prompt-on-empty-subject"); - - e_shell_settings_install_property_for_key ( - "composer-prompt-send-invalid-recip", - MAIL_SCHEMA, - "prompt-on-invalid-recip"); - - e_shell_settings_install_property_for_key ( - "composer-reply-start-bottom", - MAIL_SCHEMA, - "composer-reply-start-bottom"); - - e_shell_settings_install_property_for_key ( - "composer-request-receipt", - MAIL_SCHEMA, - "composer-request-receipt"); - - e_shell_settings_install_property_for_key ( - "composer-spell-color", - MAIL_SCHEMA, - "composer-spell-color"); - - e_shell_settings_install_property_for_key ( - "composer-top-signature", - MAIL_SCHEMA, - "composer-top-signature"); - - e_shell_settings_install_property_for_key ( - "composer-no-signature-delim", - MAIL_SCHEMA, - "composer-no-signature-delim"); - - e_shell_settings_install_property_for_key ( - "composer-gallery-path", - MAIL_SCHEMA, - "composer-gallery-path"); - - e_shell_settings_install_property_for_key ( - "mail-headers-collapsed", - MAIL_SCHEMA, - "headers-collapsed"); - - e_shell_settings_install_property ( - g_param_spec_enum ( - "mail-sidebar-ellipsize", - NULL, - NULL, - PANGO_TYPE_ELLIPSIZE_MODE, - PANGO_ELLIPSIZE_NONE, - G_PARAM_READWRITE)); - - g_object_bind_property_full ( - shell_settings, "mail-no-folder-dots", - shell_settings, "mail-sidebar-ellipsize", - G_BINDING_SYNC_CREATE, - transform_no_folder_dots_to_ellipsize, - NULL, - g_object_ref (shell_settings), - (GDestroyNotify) g_object_unref); -} diff --git a/modules/mail/e-mail-shell-settings.h b/modules/mail/e-mail-shell-settings.h deleted file mode 100644 index 1faf6c6faf..0000000000 --- a/modules/mail/e-mail-shell-settings.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * e-mail-shell-settings.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/> - * - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifndef E_MAIL_SHELL_SETTINGS_H -#define E_MAIL_SHELL_SETTINGS_H - -#include <shell/e-shell-backend.h> - -G_BEGIN_DECLS - -void e_mail_shell_settings_init (EShellBackend *shell_backend); - -G_END_DECLS - -#endif /* E_MAIL_SHELL_SETTINGS_H */ diff --git a/modules/mail/e-mail-shell-sidebar.c b/modules/mail/e-mail-shell-sidebar.c index 2c2cdfb4d5..7f3c569288 100644 --- a/modules/mail/e-mail-shell-sidebar.c +++ b/modules/mail/e-mail-shell-sidebar.c @@ -122,12 +122,9 @@ static void mail_shell_sidebar_constructed (GObject *object) { EMailShellSidebar *mail_shell_sidebar; - EShellSettings *shell_settings; EShellBackend *shell_backend; EShellSidebar *shell_sidebar; - EShellWindow *shell_window; EShellView *shell_view; - EShell *shell; EMailBackend *backend; EMailSession *session; EAlertSink *alert_sink; @@ -135,6 +132,7 @@ mail_shell_sidebar_constructed (GObject *object) GtkTreeView *tree_view; GtkWidget *container; GtkWidget *widget; + GSettings *settings; /* Chain up to parent's constructed method. */ G_OBJECT_CLASS (e_mail_shell_sidebar_parent_class)->constructed (object); @@ -142,10 +140,6 @@ mail_shell_sidebar_constructed (GObject *object) shell_sidebar = E_SHELL_SIDEBAR (object); shell_view = e_shell_sidebar_get_shell_view (shell_sidebar); shell_backend = e_shell_view_get_shell_backend (shell_view); - shell_window = e_shell_view_get_shell_window (shell_view); - - shell = e_shell_window_get_shell (shell_window); - shell_settings = e_shell_get_shell_settings (shell); backend = E_MAIL_BACKEND (shell_backend); session = e_mail_backend_get_session (backend); @@ -179,15 +173,19 @@ mail_shell_sidebar_constructed (GObject *object) widget, "key-file", G_BINDING_SYNC_CREATE); - g_object_bind_property ( - shell_settings, "mail-sidebar-ellipsize", + settings = g_settings_new ("org.gnome.evolution.mail"); + + g_settings_bind ( + settings, "side-bar-ellipsize-mode", widget, "ellipsize", - G_BINDING_SYNC_CREATE); + G_SETTINGS_BIND_GET); - g_object_bind_property ( - shell_settings, "mail-sidebar-search", + g_settings_bind ( + settings, "side-bar-search", widget, "enable-search", - G_BINDING_SYNC_CREATE); + G_SETTINGS_BIND_GET); + + g_object_unref (settings); g_signal_connect_swapped ( widget, "key-file-changed", diff --git a/modules/mail/e-mail-shell-view-actions.c b/modules/mail/e-mail-shell-view-actions.c index 92cb0d5814..ed5b30702c 100644 --- a/modules/mail/e-mail-shell-view-actions.c +++ b/modules/mail/e-mail-shell-view-actions.c @@ -953,10 +953,8 @@ static void action_mail_smart_backward_cb (GtkAction *action, EMailShellView *mail_shell_view) { - EShell *shell; EShellView *shell_view; EShellWindow *shell_window; - EShellSettings *shell_settings; EMailShellContent *mail_shell_content; EMailShellSidebar *mail_shell_sidebar; EMFolderTree *folder_tree; @@ -967,6 +965,7 @@ action_mail_smart_backward_cb (GtkAction *action, GtkWidget *window; GtkAdjustment *adj; EMailDisplay *display; + GSettings *settings; gboolean caret_mode; gboolean magic_spacebar; gdouble value; @@ -975,8 +974,6 @@ action_mail_smart_backward_cb (GtkAction *action, shell_view = E_SHELL_VIEW (mail_shell_view); shell_window = e_shell_view_get_shell_window (shell_view); - shell = e_shell_window_get_shell (shell_window); - shell_settings = e_shell_get_shell_settings (shell); mail_shell_content = mail_shell_view->priv->mail_shell_content; mail_view = e_mail_shell_content_get_mail_view (mail_shell_content); @@ -988,8 +985,9 @@ action_mail_smart_backward_cb (GtkAction *action, display = e_mail_reader_get_mail_display (reader); message_list = e_mail_reader_get_message_list (reader); - magic_spacebar = e_shell_settings_get_boolean ( - shell_settings, "mail-magic-spacebar"); + settings = g_settings_new ("org.gnome.evolution.mail"); + magic_spacebar = g_settings_get_boolean (settings, "magic-spacebar"); + g_object_unref (settings); toggle_action = GTK_TOGGLE_ACTION (ACTION (MAIL_CARET_MODE)); caret_mode = gtk_toggle_action_get_active (toggle_action); @@ -1005,7 +1003,7 @@ action_mail_smart_backward_cb (GtkAction *action, if (caret_mode || !magic_spacebar) return; - /* XXX Are two separate calls really necessary? */ + /* XXX Are two separate calls really necessary? */ if (message_list_select ( MESSAGE_LIST (message_list), @@ -1038,10 +1036,8 @@ static void action_mail_smart_forward_cb (GtkAction *action, EMailShellView *mail_shell_view) { - EShell *shell; EShellView *shell_view; EShellWindow *shell_window; - EShellSettings *shell_settings; EMailShellContent *mail_shell_content; EMailShellSidebar *mail_shell_sidebar; EMFolderTree *folder_tree; @@ -1052,6 +1048,7 @@ action_mail_smart_forward_cb (GtkAction *action, GtkAdjustment *adj; GtkToggleAction *toggle_action; EMailDisplay *display; + GSettings *settings; gboolean caret_mode; gboolean magic_spacebar; gdouble value; @@ -1061,8 +1058,6 @@ action_mail_smart_forward_cb (GtkAction *action, shell_view = E_SHELL_VIEW (mail_shell_view); shell_window = e_shell_view_get_shell_window (shell_view); - shell = e_shell_window_get_shell (shell_window); - shell_settings = e_shell_get_shell_settings (shell); mail_shell_content = mail_shell_view->priv->mail_shell_content; mail_view = e_mail_shell_content_get_mail_view (mail_shell_content); @@ -1074,8 +1069,9 @@ action_mail_smart_forward_cb (GtkAction *action, display = e_mail_reader_get_mail_display (reader); message_list = e_mail_reader_get_message_list (reader); - magic_spacebar = e_shell_settings_get_boolean ( - shell_settings, "mail-magic-spacebar"); + settings = g_settings_new ("org.gnome.evolution.mail"); + magic_spacebar = g_settings_get_boolean (settings, "magic-spacebar"); + g_object_unref (settings); toggle_action = GTK_TOGGLE_ACTION (ACTION (MAIL_CARET_MODE)); caret_mode = gtk_toggle_action_get_active (toggle_action); @@ -1092,7 +1088,7 @@ action_mail_smart_forward_cb (GtkAction *action, if (caret_mode || !magic_spacebar) return; - /* XXX Are two separate calls really necessary? */ + /* XXX Are two separate calls really necessary? */ if (message_list_select ( MESSAGE_LIST (message_list), diff --git a/modules/mail/em-composer-prefs.c b/modules/mail/em-composer-prefs.c index 58066e0f0b..7d80bbcb1c 100644 --- a/modules/mail/em-composer-prefs.c +++ b/modules/mail/em-composer-prefs.c @@ -52,75 +52,50 @@ G_DEFINE_TYPE ( GTK_TYPE_VBOX) static gboolean -transform_old_to_new_reply_style (GBinding *binding, - const GValue *source_value, - GValue *target_value, - gpointer user_data) +composer_prefs_map_string_to_color (GValue *value, + GVariant *variant, + gpointer user_data) { - gboolean success = TRUE; - - /* XXX This is the kind of legacy crap we wind up - * with when we don't migrate things properly. */ - - switch (g_value_get_int (source_value)) { - case 0: /* Quoted: 0 -> 2 */ - g_value_set_int (target_value, 2); - break; - - case 1: /* Do Not Quote: 1 -> 3 */ - g_value_set_int (target_value, 3); - break; - - case 2: /* Attach: 2 -> 0 */ - g_value_set_int (target_value, 0); - break; - - case 3: /* Outlook: 3 -> 1 */ - g_value_set_int (target_value, 1); - break; - - default: - success = FALSE; - break; + 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 gboolean -transform_new_to_old_reply_style (GBinding *binding, - const GValue *source_value, - GValue *target_value, - gpointer user_data) +static GVariant * +composer_prefs_map_color_to_string (const GValue *value, + const GVariantType *expected_type, + gpointer user_data) { - gboolean success = TRUE; - - /* XXX This is the kind of legacy crap we wind up - * with when we don't migrate things properly. */ - - switch (g_value_get_int (source_value)) { - case 0: /* Attach: 0 -> 2 */ - g_value_set_int (target_value, 2); - break; - - case 1: /* Outlook: 1 -> 3 */ - g_value_set_int (target_value, 3); - break; - - case 2: /* Quoted: 2 -> 0 */ - g_value_set_int (target_value, 0); - break; - - case 3: /* Do Not Quote: 3 -> 1 */ - g_value_set_int (target_value, 1); - break; - - default: - success = FALSE; - break; + GVariant *variant; + const GdkColor *color; + + color = g_value_get_boxed (value); + if (color == NULL) { + variant = g_variant_new_string (""); + } else { + gchar *string; + + /* Encode the color manually because CSS styles expect + * color codes as #rrggbb, whereas gdk_color_to_string() + * returns color codes as #rrrrggggbbbb. */ + string = g_strdup_printf ( + "#%02x%02x%02x", + (gint) color->red * 256 / 65536, + (gint) color->green * 256 / 65536, + (gint) color->blue * 256 / 65536); + variant = g_variant_new_string (string); + g_free (string); } - return success; + return variant; } static void @@ -302,7 +277,7 @@ em_composer_prefs_construct (EMComposerPrefs *prefs, { GtkWidget *toplevel, *widget, *info_pixmap; GtkWidget *container; - EShellSettings *shell_settings; + GSettings *settings; ESourceRegistry *registry; GtkTreeView *view; GtkListStore *store; @@ -314,7 +289,8 @@ em_composer_prefs_construct (EMComposerPrefs *prefs, gint i; registry = e_shell_get_registry (shell); - shell_settings = e_shell_get_shell_settings (shell); + + settings = g_settings_new ("org.gnome.evolution.mail"); /* Make sure our custom widget classes are registered with * GType before we load the GtkBuilder definition file. */ @@ -343,129 +319,113 @@ em_composer_prefs_construct (EMComposerPrefs *prefs, /* Express mode does not honor this setting. */ widget = e_builder_get_widget (prefs->builder, "chkSendHTML"); - if (e_shell_get_express_mode (shell)) + if (e_shell_get_express_mode (shell)) { gtk_widget_hide (widget); - else - g_object_bind_property ( - shell_settings, "composer-format-html", + } else { + g_settings_bind ( + settings, "composer-send-html", widget, "active", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); + G_SETTINGS_BIND_DEFAULT); + } widget = e_builder_get_widget (prefs->builder, "chkPromptEmptySubject"); - g_object_bind_property ( - shell_settings, "composer-prompt-empty-subject", + g_settings_bind ( + settings, "prompt-on-empty-subject", widget, "active", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); + G_SETTINGS_BIND_DEFAULT); widget = e_builder_get_widget (prefs->builder, "chkPromptBccOnly"); - g_object_bind_property ( - shell_settings, "composer-prompt-only-bcc", + g_settings_bind ( + settings, "prompt-on-only-bcc", widget, "active", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); + G_SETTINGS_BIND_DEFAULT); widget = e_builder_get_widget (prefs->builder, "chkPromptPrivateListReply"); - g_object_bind_property ( - shell_settings, "composer-prompt-private-list-reply", + g_settings_bind ( + settings, "prompt-on-private-list-reply", widget, "active", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); + G_SETTINGS_BIND_DEFAULT); widget = e_builder_get_widget (prefs->builder, "chkPromptReplyManyRecips"); - g_object_bind_property ( - shell_settings, "composer-prompt-reply-many-recips", + g_settings_bind ( + settings, "prompt-on-reply-many-recips", widget, "active", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); + G_SETTINGS_BIND_DEFAULT); widget = e_builder_get_widget (prefs->builder, "chkPromptListReplyTo"); - g_object_bind_property ( - shell_settings, "composer-prompt-list-reply-to", + g_settings_bind ( + settings, "prompt-on-list-reply-to", widget, "active", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); + G_SETTINGS_BIND_DEFAULT); widget = e_builder_get_widget (prefs->builder, "chkPromptSendInvalidRecip"); - g_object_bind_property ( - shell_settings, "composer-prompt-send-invalid-recip", + g_settings_bind ( + settings, "prompt-on-invalid-recip", widget, "active", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); + G_SETTINGS_BIND_DEFAULT); widget = e_builder_get_widget (prefs->builder, "chkAutoSmileys"); - g_object_bind_property ( - shell_settings, "composer-magic-smileys", + g_settings_bind ( + settings, "composer-magic-smileys", widget, "active", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); + G_SETTINGS_BIND_DEFAULT); widget = e_builder_get_widget (prefs->builder, "chkRequestReceipt"); - g_object_bind_property ( - shell_settings, "composer-request-receipt", + g_settings_bind ( + settings, "composer-request-receipt", widget, "active", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); + G_SETTINGS_BIND_DEFAULT); widget = e_builder_get_widget (prefs->builder, "chkReplyStartBottom"); - g_object_bind_property ( - shell_settings, "composer-reply-start-bottom", + g_settings_bind ( + settings, "composer-reply-start-bottom", widget, "active", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); + G_SETTINGS_BIND_DEFAULT); widget = e_builder_get_widget (prefs->builder, "chkOutlookFilenames"); - g_object_bind_property ( - shell_settings, "composer-outlook-filenames", + g_settings_bind ( + settings, "composer-outlook-filenames", widget, "active", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); + G_SETTINGS_BIND_DEFAULT); widget = e_builder_get_widget (prefs->builder, "chkIgnoreListReplyTo"); - g_object_bind_property ( - shell_settings, "composer-ignore-list-reply-to", + g_settings_bind ( + settings, "composer-ignore-list-reply-to", widget, "active", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); + G_SETTINGS_BIND_DEFAULT); widget = e_builder_get_widget (prefs->builder, "chkGroupReplyToList"); - g_object_bind_property ( - shell_settings, "composer-group-reply-to-list", + g_settings_bind ( + settings, "composer-group-reply-to-list", widget, "active", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); + G_SETTINGS_BIND_DEFAULT); widget = e_builder_get_widget (prefs->builder, "chkSignReplyIfSigned"); - g_object_bind_property ( - shell_settings, "composer-sign-reply-if-signed", + g_settings_bind ( + settings, "composer-sign-reply-if-signed", widget, "active", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); + G_SETTINGS_BIND_DEFAULT); widget = e_builder_get_widget (prefs->builder, "chkTopSignature"); - g_object_bind_property ( - shell_settings, "composer-top-signature", + g_settings_bind ( + settings, "composer-top-signature", widget, "active", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); + G_SETTINGS_BIND_DEFAULT); widget = e_builder_get_widget (prefs->builder, "chkEnableSpellChecking"); - g_object_bind_property ( - shell_settings, "composer-inline-spelling", + g_settings_bind ( + settings, "composer-inline-spelling", widget, "active", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); + G_SETTINGS_BIND_DEFAULT); widget = e_charset_combo_box_new (); container = e_builder_get_widget (prefs->builder, "hboxComposerCharset"); gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0); gtk_widget_show (widget); - g_object_bind_property ( - shell_settings, "composer-charset", + g_settings_bind ( + settings, "composer-charset", widget, "charset", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); + G_SETTINGS_BIND_DEFAULT); container = e_builder_get_widget (prefs->builder, "lblCharset"); gtk_label_set_mnemonic_widget (GTK_LABEL (container), widget); @@ -500,34 +460,28 @@ em_composer_prefs_construct (EMComposerPrefs *prefs, GTK_STOCK_DIALOG_INFO, GTK_ICON_SIZE_BUTTON); widget = e_builder_get_widget (prefs->builder, "colorButtonSpellCheckColor"); - g_object_bind_property_full ( - shell_settings, "composer-spell-color", + g_settings_bind_with_mapping ( + settings, "composer-spell-color", widget, "color", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE, - e_binding_transform_string_to_color, - e_binding_transform_color_to_string, + G_SETTINGS_BIND_DEFAULT, + composer_prefs_map_string_to_color, + composer_prefs_map_color_to_string, NULL, (GDestroyNotify) NULL); spell_setup (prefs); /* Forwards and Replies */ widget = e_builder_get_widget (prefs->builder, "comboboxForwardStyle"); - g_object_bind_property ( - shell_settings, "mail-forward-style", - widget, "active", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); + g_settings_bind ( + settings, "forward-style-name", + widget, "active-id", + G_SETTINGS_BIND_DEFAULT); widget = e_builder_get_widget (prefs->builder, "comboboxReplyStyle"); - g_object_bind_property_full ( - shell_settings, "mail-reply-style", - widget, "active", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE, - transform_old_to_new_reply_style, - transform_new_to_old_reply_style, - NULL, (GDestroyNotify) NULL); + g_settings_bind ( + settings, "reply-style-name", + widget, "active-id", + G_SETTINGS_BIND_DEFAULT); /* Signatures */ container = e_builder_get_widget ( @@ -544,10 +498,10 @@ em_composer_prefs_construct (EMComposerPrefs *prefs, /* Express mode does not honor this setting. */ if (!e_shell_get_express_mode (shell)) - g_object_bind_property ( - shell_settings, "composer-format-html", + g_settings_bind ( + settings, "composer-send-html", widget, "prefer-html", - G_BINDING_SYNC_CREATE); + G_SETTINGS_BIND_GET); /* Sanitize the dialog for Express mode */ e_shell_hide_widgets_for_express_mode ( @@ -561,6 +515,8 @@ em_composer_prefs_construct (EMComposerPrefs *prefs, e_config_set_target ((EConfig *) ec, (EConfigTarget *) target); toplevel = e_config_create_widget ((EConfig *) ec); gtk_container_add (GTK_CONTAINER (prefs), toplevel); + + g_object_unref (settings); } GtkWidget * diff --git a/modules/mail/em-mailer-prefs.c b/modules/mail/em-mailer-prefs.c index 83a23ef735..469425ff41 100644 --- a/modules/mail/em-mailer-prefs.c +++ b/modules/mail/em-mailer-prefs.c @@ -117,35 +117,79 @@ em_mailer_prefs_init (EMMailerPrefs *preferences) } static gboolean -mark_seen_milliseconds_to_seconds (GBinding *binding, - const GValue *source_value, - GValue *target_value, - gpointer user_data) +mailer_prefs_map_milliseconds_to_seconds (GValue *value, + GVariant *variant, + gpointer user_data) { - gint milliseconds; + gint32 milliseconds; gdouble seconds; - milliseconds = g_value_get_int (source_value); + milliseconds = g_variant_get_int32 (variant); seconds = milliseconds / 1000.0; - g_value_set_double (target_value, seconds); + g_value_set_double (value, seconds); return TRUE; } -static gboolean -mark_seen_seconds_to_milliseconds (GBinding *binding, - const GValue *source_value, - GValue *target_value, - gpointer user_data) +static GVariant * +mailer_prefs_map_seconds_to_milliseconds (const GValue *value, + const GVariantType *expected_type, + gpointer user_data) { - gint milliseconds; + gint32 milliseconds; gdouble seconds; - seconds = g_value_get_double (source_value); + seconds = g_value_get_double (value); milliseconds = seconds * 1000; - g_value_set_int (target_value, milliseconds); - return TRUE; + return g_variant_new_int32 (milliseconds); +} + +static gboolean +mailer_prefs_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 GVariant * +mailer_prefs_map_color_to_string (const GValue *value, + const GVariantType *expected_type, + gpointer user_data) +{ + GVariant *variant; + const GdkColor *color; + + color = g_value_get_boxed (value); + if (color == NULL) { + variant = g_variant_new_string (""); + } else { + gchar *string; + + /* Encode the color manually because CSS styles expect + * color codes as #rrggbb, whereas gdk_color_to_string() + * returns color codes as #rrrrggggbbbb. */ + string = g_strdup_printf ( + "#%02x%02x%02x", + (gint) color->red * 256 / 65536, + (gint) color->green * 256 / 65536, + (gint) color->blue * 256 / 65536); + variant = g_variant_new_string (string); + g_free (string); + } + + return variant; } enum { @@ -687,19 +731,51 @@ emmp_empty_junk_init (EMMailerPrefs *prefs, } static void -http_images_changed (GtkWidget *widget, - EMMailerPrefs *prefs) +image_loading_policy_always_cb (GtkToggleButton *toggle_button) +{ + if (gtk_toggle_button_get_active (toggle_button)) { + GSettings *settings; + + settings = g_settings_new ("org.gnome.evolution.mail"); + + g_settings_set_enum ( + settings, "image-loading-policy", + E_MAIL_IMAGE_LOADING_POLICY_ALWAYS); + + g_object_unref (settings); + } +} + +static void +image_loading_policy_sometimes_cb (GtkToggleButton *toggle_button) { - EMailImageLoadingPolicy policy; + if (gtk_toggle_button_get_active (toggle_button)) { + GSettings *settings; + + settings = g_settings_new ("org.gnome.evolution.mail"); - if (gtk_toggle_button_get_active (prefs->images_always)) - policy = E_MAIL_IMAGE_LOADING_POLICY_ALWAYS; - else if (gtk_toggle_button_get_active (prefs->images_sometimes)) - policy = E_MAIL_IMAGE_LOADING_POLICY_SOMETIMES; - else - policy = E_MAIL_IMAGE_LOADING_POLICY_NEVER; + g_settings_set_enum ( + settings, "image-loading-policy", + E_MAIL_IMAGE_LOADING_POLICY_SOMETIMES); - g_settings_set_int (prefs->settings, "load-http-images", policy); + g_object_unref (settings); + } +} + +static void +image_loading_policy_never_cb (GtkToggleButton *toggle_button) +{ + if (gtk_toggle_button_get_active (toggle_button)) { + GSettings *settings; + + settings = g_settings_new ("org.gnome.evolution.mail"); + + g_settings_set_enum ( + settings, "image-loading-policy", + E_MAIL_IMAGE_LOADING_POLICY_NEVER); + + g_object_unref (settings); + } } static GtkWidget * @@ -750,7 +826,7 @@ em_mailer_prefs_construct (EMMailerPrefs *prefs, { GSList *header_add_list, *p; gchar **headers_config; - EShellSettings *shell_settings; + GSettings *settings; GHashTable *default_header_hash; GtkWidget *toplevel; GtkWidget *container; @@ -760,12 +836,13 @@ em_mailer_prefs_construct (EMMailerPrefs *prefs, GtkCellRenderer *renderer; GtkTreeIter iter; gboolean locked; + gboolean writable; gint val, i; EMConfig *ec; EMConfigTargetPrefs *target; GSList *l; - shell_settings = e_shell_get_shell_settings (shell); + settings = g_settings_new ("org.gnome.evolution.mail"); /* Make sure our custom widget classes are registered with * GType before we load the GtkBuilder definition file. */ @@ -791,197 +868,187 @@ em_mailer_prefs_construct (EMMailerPrefs *prefs, /* General tab */ widget = e_builder_get_widget (prefs->builder, "chkCheckMailOnStart"); - g_object_bind_property ( - shell_settings, "mail-check-on-start", + g_settings_bind ( + settings, "send-recv-on-start", widget, "active", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); + G_SETTINGS_BIND_DEFAULT); widget = e_builder_get_widget (prefs->builder, "chkCheckMailInAllOnStart"); - g_object_bind_property ( - shell_settings, "mail-check-all-on-start", + g_settings_bind ( + settings, "send-recv-all-on-start", widget, "active", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); - g_object_bind_property ( - shell_settings, "mail-check-on-start", + G_SETTINGS_BIND_DEFAULT); + g_settings_bind ( + settings, "send-recv-on-start", widget, "sensitive", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); + G_SETTINGS_BIND_GET); /* Message Display */ widget = e_builder_get_widget (prefs->builder, "chkMarkTimeout"); - g_object_bind_property ( - shell_settings, "mail-mark-seen", + g_settings_bind ( + settings, "mark-seen", widget, "active", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); + G_SETTINGS_BIND_DEFAULT); /* The "mark seen" timeout requires special transform functions * because we display the timeout value to the user in seconds * but store the settings value in milliseconds. */ widget = e_builder_get_widget (prefs->builder, "spinMarkTimeout"); - g_object_bind_property ( - shell_settings, "mail-mark-seen", - widget, "sensitive", - G_BINDING_SYNC_CREATE); - g_object_bind_property_full ( - shell_settings, "mail-mark-seen-timeout", + g_settings_bind_with_mapping ( + settings, "mark-seen-timeout", widget, "value", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE, - mark_seen_milliseconds_to_seconds, - mark_seen_seconds_to_milliseconds, + G_SETTINGS_BIND_DEFAULT, + mailer_prefs_map_milliseconds_to_seconds, + mailer_prefs_map_seconds_to_milliseconds, NULL, (GDestroyNotify) NULL); + g_settings_bind ( + settings, "mark-seen", + widget, "sensitive", + G_SETTINGS_BIND_GET); widget = e_builder_get_widget (prefs->builder, "view-check"); - g_object_bind_property ( - shell_settings, "mail-global-view-setting", + g_settings_bind ( + settings, "global-view-setting", widget, "active", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); + G_SETTINGS_BIND_DEFAULT); widget = e_charset_combo_box_new (); container = e_builder_get_widget (prefs->builder, "hboxDefaultCharset"); - gtk_label_set_mnemonic_widget (GTK_LABEL (e_builder_get_widget (prefs->builder, "lblDefaultCharset")), widget); + gtk_label_set_mnemonic_widget ( + GTK_LABEL (e_builder_get_widget ( + prefs->builder, "lblDefaultCharset")), widget); gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0); gtk_widget_show (widget); - g_object_bind_property ( - shell_settings, "mail-charset", + g_settings_bind ( + settings, "charset", widget, "charset", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); + G_SETTINGS_BIND_DEFAULT); widget = e_builder_get_widget (prefs->builder, "chkHighlightCitations"); - g_object_bind_property ( - shell_settings, "mail-mark-citations", + g_settings_bind ( + settings, "mark-citations", widget, "active", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); + G_SETTINGS_BIND_DEFAULT); widget = e_builder_get_widget (prefs->builder, "colorButtonHighlightCitations"); - g_object_bind_property ( - shell_settings, "mail-mark-citations", - widget, "sensitive", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); - g_object_bind_property_full ( - shell_settings, "mail-citation-color", + g_settings_bind_with_mapping ( + settings, "citation-color", widget, "color", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE, - e_binding_transform_string_to_color, - e_binding_transform_color_to_string, + G_SETTINGS_BIND_DEFAULT, + mailer_prefs_map_string_to_color, + mailer_prefs_map_color_to_string, NULL, (GDestroyNotify) NULL); + g_settings_bind ( + settings, "mark-citations", + widget, "sensitive", + G_SETTINGS_BIND_DEFAULT); widget = e_builder_get_widget (prefs->builder, "thread-by-subject"); - g_object_bind_property ( - shell_settings, "mail-thread-by-subject", + g_settings_bind ( + settings, "thread-subject", widget, "active", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); + G_SETTINGS_BIND_DEFAULT); /* Deleting Mail */ widget = e_builder_get_widget (prefs->builder, "chkEmptyTrashOnExit"); - g_object_bind_property ( - shell_settings, "mail-empty-trash-on-exit", + g_settings_bind ( + settings, "trash-empty-on-exit", widget, "active", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); + G_SETTINGS_BIND_DEFAULT); widget = e_builder_get_widget (prefs->builder, "comboboxEmptyTrashDays"); - g_object_bind_property ( - shell_settings, "mail-empty-trash-on-exit", + g_settings_bind ( + settings, "trash-empty-on-exit", widget, "sensitive", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); + G_SETTINGS_BIND_GET); emmp_empty_trash_init (prefs, GTK_COMBO_BOX (widget)); widget = e_builder_get_widget (prefs->builder, "chkConfirmExpunge"); - g_object_bind_property ( - shell_settings, "mail-confirm-expunge", + g_settings_bind ( + settings, "prompt-on-expunge", widget, "active", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); + G_SETTINGS_BIND_DEFAULT); /* Mail Fonts */ widget = e_builder_get_widget (prefs->builder, "radFontUseSame"); - g_object_bind_property ( - shell_settings, "mail-use-custom-fonts", + g_settings_bind ( + settings, "use-custom-font", widget, "active", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE | - G_BINDING_INVERT_BOOLEAN); + G_SETTINGS_BIND_DEFAULT | + G_SETTINGS_BIND_INVERT_BOOLEAN); widget = e_builder_get_widget (prefs->builder, "FontFixed"); - g_object_bind_property ( - shell_settings, "mail-font-monospace", + g_settings_bind ( + settings, "monospace-font", widget, "font-name", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); - g_object_bind_property ( - shell_settings, "mail-use-custom-fonts", + G_SETTINGS_BIND_DEFAULT); + g_settings_bind ( + settings, "use-custom-font", widget, "sensitive", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); + G_SETTINGS_BIND_GET); widget = e_builder_get_widget (prefs->builder, "FontVariable"); - g_object_bind_property ( - shell_settings, "mail-font-variable", + g_settings_bind ( + settings, "variable-width-font", widget, "font-name", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); - g_object_bind_property ( - shell_settings, "mail-use-custom-fonts", + G_SETTINGS_BIND_DEFAULT); + g_settings_bind ( + settings, "use-custom-font", widget, "sensitive", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); + G_SETTINGS_BIND_GET); /* HTML Mail tab */ /* Loading Images */ - locked = !g_settings_is_writable (prefs->settings, "load-http-images"); + writable = g_settings_is_writable ( + prefs->settings, "image-loading-policy"); - val = g_settings_get_int (prefs->settings, "load-http-images"); - prefs->images_never = GTK_TOGGLE_BUTTON (e_builder_get_widget (prefs->builder, "radImagesNever")); - gtk_toggle_button_set_active (prefs->images_never, val == E_MAIL_IMAGE_LOADING_POLICY_NEVER); - if (locked) - gtk_widget_set_sensitive ((GtkWidget *) prefs->images_never, FALSE); + val = g_settings_get_enum (prefs->settings, "image-loading-policy"); + widget = e_builder_get_widget ( + prefs->builder, "radImagesNever"); + gtk_toggle_button_set_active ( + GTK_TOGGLE_BUTTON (widget), + val == E_MAIL_IMAGE_LOADING_POLICY_NEVER); + gtk_widget_set_sensitive (widget, writable); - prefs->images_sometimes = GTK_TOGGLE_BUTTON (e_builder_get_widget (prefs->builder, "radImagesSometimes")); - gtk_toggle_button_set_active (prefs->images_sometimes, val == E_MAIL_IMAGE_LOADING_POLICY_SOMETIMES); - if (locked) - gtk_widget_set_sensitive ((GtkWidget *) prefs->images_sometimes, FALSE); + g_signal_connect ( + widget, "toggled", + G_CALLBACK (image_loading_policy_never_cb), NULL); - prefs->images_always = GTK_TOGGLE_BUTTON (e_builder_get_widget (prefs->builder, "radImagesAlways")); - gtk_toggle_button_set_active (prefs->images_always, val == E_MAIL_IMAGE_LOADING_POLICY_ALWAYS); - if (locked) - gtk_widget_set_sensitive ((GtkWidget *) prefs->images_always, FALSE); + widget = e_builder_get_widget ( + prefs->builder, "radImagesSometimes"); + gtk_toggle_button_set_active ( + GTK_TOGGLE_BUTTON (widget), + val == E_MAIL_IMAGE_LOADING_POLICY_SOMETIMES); + gtk_widget_set_sensitive (widget, writable); g_signal_connect ( - prefs->images_never, "toggled", - G_CALLBACK (http_images_changed), prefs); - g_signal_connect ( - prefs->images_sometimes, "toggled", - G_CALLBACK (http_images_changed), prefs); + widget, "toggled", + G_CALLBACK (image_loading_policy_sometimes_cb), NULL); + + widget = e_builder_get_widget ( + prefs->builder, "radImagesAlways"); + gtk_toggle_button_set_active ( + GTK_TOGGLE_BUTTON (widget), + val == E_MAIL_IMAGE_LOADING_POLICY_ALWAYS); + gtk_widget_set_sensitive (widget, FALSE); + g_signal_connect ( - prefs->images_always, "toggled", - G_CALLBACK (http_images_changed), prefs); + widget, "toggled", + G_CALLBACK (image_loading_policy_always_cb), NULL); widget = e_builder_get_widget (prefs->builder, "chkShowAnimatedImages"); - g_object_bind_property ( - shell_settings, "mail-show-animated-images", + g_settings_bind ( + settings, "show-animated-images", widget, "active", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); + G_SETTINGS_BIND_DEFAULT); widget = e_builder_get_widget (prefs->builder, "chkPromptWantHTML"); - g_object_bind_property ( - shell_settings, "mail-confirm-unwanted-html", + g_settings_bind ( + settings, "prompt-on-unwanted-html", widget, "active", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); + G_SETTINGS_BIND_DEFAULT); container = e_builder_get_widget (prefs->builder, "labels-alignment"); widget = e_mail_label_manager_new (); @@ -997,23 +1064,20 @@ em_mailer_prefs_construct (EMMailerPrefs *prefs, locked = !g_settings_is_writable (prefs->settings, "headers"); widget = e_builder_get_widget (prefs->builder, "photo_show"); - g_object_bind_property ( - shell_settings, "mail-show-sender-photo", + g_settings_bind ( + settings, "show-sender-photo", widget, "active", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); + G_SETTINGS_BIND_DEFAULT); widget = e_builder_get_widget (prefs->builder, "photo_local"); - g_object_bind_property ( - shell_settings, "mail-show-sender-photo", - widget, "sensitive", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); - g_object_bind_property ( - shell_settings, "mail-only-local-photos", + g_settings_bind ( + settings, "photo-local", widget, "active", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); + G_SETTINGS_BIND_DEFAULT); + g_settings_bind ( + settings, "show-sender-photo", + widget, "sensitive", + G_SETTINGS_BIND_GET); /* always de-sensitised until the user types something in the entry */ prefs->add_header = GTK_BUTTON (e_builder_get_widget (prefs->builder, "cmdHeadersAdd")); @@ -1142,33 +1206,30 @@ em_mailer_prefs_construct (EMMailerPrefs *prefs, widget = gtk_check_button_new_with_mnemonic (_("Show _original header value")); gtk_widget_show (widget); gtk_table_attach ((GtkTable *) table, widget, 0, 3, 2, 3, GTK_EXPAND | GTK_FILL, 0, 12, 0); - g_object_bind_property ( - shell_settings, "mail-show-real-date", + g_settings_bind ( + settings, "show-real-date", widget, "active", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); + G_SETTINGS_BIND_DEFAULT); /* Junk prefs */ widget = e_builder_get_widget (prefs->builder, "chkCheckIncomingMail"); - g_object_bind_property ( - shell_settings, "mail-check-for-junk", + g_settings_bind ( + settings, "junk-check-incoming", widget, "active", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); + G_SETTINGS_BIND_DEFAULT); widget = e_builder_get_widget (prefs->builder, "junk_empty_check"); - g_object_bind_property ( - shell_settings, "mail-empty-junk-on-exit", + g_settings_bind ( + settings, "junk-empty-on-exit", widget, "active", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); + G_SETTINGS_BIND_DEFAULT); widget = e_builder_get_widget (prefs->builder, "junk_empty_combobox"); emmp_empty_junk_init (prefs, GTK_COMBO_BOX (widget)); - g_object_bind_property ( - shell_settings, "mail-empty-junk-on-exit", + g_settings_bind ( + settings, "junk-empty-on-exit", widget, "sensitive", - G_BINDING_SYNC_CREATE); + G_SETTINGS_BIND_GET); widget = e_builder_get_widget (prefs->builder, "junk-module-options"); e_mail_junk_options_set_session (E_MAIL_JUNK_OPTIONS (widget), session); @@ -1211,6 +1272,8 @@ em_mailer_prefs_construct (EMMailerPrefs *prefs, e_config_set_target ((EConfig *) ec, (EConfigTarget *) target); toplevel = e_config_create_widget ((EConfig *) ec); gtk_container_add (GTK_CONTAINER (prefs), toplevel); + + g_object_unref (settings); } GtkWidget * diff --git a/modules/mail/em-mailer-prefs.h b/modules/mail/em-mailer-prefs.h index afd88afb1f..67cd1f64cb 100644 --- a/modules/mail/em-mailer-prefs.h +++ b/modules/mail/em-mailer-prefs.h @@ -67,11 +67,6 @@ struct _EMMailerPrefs { GtkFontButton *font_fixed; GtkToggleButton *font_share; - /* Loading Images */ - GtkToggleButton *images_always; - GtkToggleButton *images_sometimes; - GtkToggleButton *images_never; - GtkToggleButton *autodetect_links; /* Labels and Colours tab */ diff --git a/modules/mailto-handler/evolution-mailto-handler.c b/modules/mailto-handler/evolution-mailto-handler.c index b6f3656863..f985562487 100644 --- a/modules/mailto-handler/evolution-mailto-handler.c +++ b/modules/mailto-handler/evolution-mailto-handler.c @@ -102,8 +102,7 @@ mailto_handler_is_evolution (GAppInfo *app_info) static gboolean mailto_handler_prompt (EMailtoHandler *extension) { - EShell *shell; - EShellSettings *shell_settings; + GSettings *settings; GtkWidget *container; GtkWidget *dialog; GtkWidget *widget; @@ -111,9 +110,6 @@ mailto_handler_prompt (EMailtoHandler *extension) gchar *markup; gint response; - shell = mailto_handler_get_shell (extension); - shell_settings = e_shell_get_shell_settings (shell); - dialog = gtk_dialog_new_with_buttons ( "", NULL, 0, GTK_STOCK_NO, GTK_RESPONSE_NO, @@ -156,12 +152,16 @@ mailto_handler_prompt (EMailtoHandler *extension) gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 12); gtk_widget_show (widget); - g_object_bind_property ( - shell_settings, "mailto-handler-check", + settings = g_settings_new ("org.gnome.evolution.mail"); + + g_settings_bind ( + settings, "prompt-check-if-default-mailer", widget, "active", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE | - G_BINDING_INVERT_BOOLEAN); + G_SETTINGS_BIND_GET | + G_SETTINGS_BIND_SET | + G_SETTINGS_BIND_INVERT_BOOLEAN); + + g_object_unref (settings); /* Direct input focus away from the checkbox. */ widget = gtk_dialog_get_widget_for_response ( @@ -178,19 +178,17 @@ mailto_handler_prompt (EMailtoHandler *extension) static void mailto_handler_check (EMailtoHandler *extension) { - EShell *shell; - EShellSettings *shell_settings; + GSettings *settings; gboolean check_mailto_handler = TRUE; GAppInfo *app_info = NULL; GError *error = NULL; - shell = mailto_handler_get_shell (extension); - shell_settings = e_shell_get_shell_settings (shell); + settings = g_settings_new ("org.gnome.evolution.mail"); - g_object_get ( - shell_settings, - "mailto-handler-check", &check_mailto_handler, - NULL); + check_mailto_handler = g_settings_get_boolean ( + settings, "prompt-check-if-default-mailer"); + + g_object_unref (settings); /* Should we check the "mailto" URI handler? */ if (!check_mailto_handler) @@ -245,11 +243,6 @@ mailto_handler_constructed (GObject *object) shell = mailto_handler_get_shell (extension); - e_shell_settings_install_property_for_key ( - "mailto-handler-check", - "org.gnome.evolution.mail", - "prompt-check-if-default-mailer"); - g_signal_connect_swapped ( shell, "event::ready-to-start", G_CALLBACK (mailto_handler_check), extension); 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)-> diff --git a/modules/text-highlight/e-mail-formatter-text-highlight.c b/modules/text-highlight/e-mail-formatter-text-highlight.c index aec403c29c..f1a97b34a9 100644 --- a/modules/text-highlight/e-mail-formatter-text-highlight.c +++ b/modules/text-highlight/e-mail-formatter-text-highlight.c @@ -28,9 +28,6 @@ #include <em-format/e-mail-part-utils.h> #include <e-util/e-util.h> -#include <shell/e-shell-settings.h> -#include <shell/e-shell.h> - #include <libebackend/libebackend.h> #include <libedataserver/libedataserver.h> @@ -52,21 +49,6 @@ G_DEFINE_DYNAMIC_TYPE ( E_TYPE_MAIL_FORMATTER_EXTENSION) static gchar * -get_default_font (void) -{ - gchar *font; - GSettings *settings; - - settings = g_settings_new ("org.gnome.desktop.interface"); - - font = g_settings_get_string (settings, "monospace-font-name"); - - g_object_unref (settings); - - return font ? font : g_strdup ("monospace 10"); -} - -static gchar * get_syntax (EMailPart *part, const gchar *uri) { @@ -177,10 +159,9 @@ emfe_text_highlight_format (EMailFormatterExtension *extension, GPid pid; CamelDataWrapper *dw; gchar *font_family, *font_size, *syntax; - gboolean use_custom_font; - EShell *shell; - EShellSettings *settings; PangoFontDescription *fd; + GSettings *settings; + gchar *font = NULL; gboolean success; const gchar *argv[] = { HIGHLIGHT_COMMAND, @@ -207,30 +188,26 @@ emfe_text_highlight_format (EMailFormatterExtension *extension, return FALSE; } - shell = e_shell_get_default (); - settings = e_shell_get_shell_settings (shell); - - fd = NULL; - use_custom_font = e_shell_settings_get_boolean ( - settings, "mail-use-custom-fonts"); - if (!use_custom_font) { - gchar *font; - - font = get_default_font (); - fd = pango_font_description_from_string (font); - g_free (font); + settings = g_settings_new ("org.gnome.evolution.mail"); + if (g_settings_get_boolean (settings, "use-custom-font")) + font = g_settings_get_string ( + settings, "monospace-font"); + g_object_unref (settings); + + if (font == NULL) { + settings = g_settings_new ( + "org.gnome.desktop.interface"); + font = g_settings_get_string ( + settings, "monospace-font-name"); + g_object_unref (settings); + } - } else { - gchar *font; + if (font == NULL) + font = g_strdup ("monospace 10"); - font = e_shell_settings_get_string ( - settings, "mail-font-monospace"); - if (!font) - font = get_default_font (); + fd = pango_font_description_from_string (font); - fd = pango_font_description_from_string (font); - g_free (font); - } + g_free (font); font_family = g_strdup_printf ( "--font='%s'", |