aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2013-06-05 00:03:24 +0800
committerMatthew Barnes <mbarnes@redhat.com>2013-06-05 01:10:02 +0800
commit5794c63f4ff48ad4abc677954fcd5e9bb578aacc (patch)
tree8fd8dcd8e6060085efa099bedf8ca0b1405f3cdd
parent046816123764f86f1b258195292abcdb7951fca3 (diff)
downloadgsoc2013-evolution-5794c63f4ff48ad4abc677954fcd5e9bb578aacc.tar
gsoc2013-evolution-5794c63f4ff48ad4abc677954fcd5e9bb578aacc.tar.gz
gsoc2013-evolution-5794c63f4ff48ad4abc677954fcd5e9bb578aacc.tar.bz2
gsoc2013-evolution-5794c63f4ff48ad4abc677954fcd5e9bb578aacc.tar.lz
gsoc2013-evolution-5794c63f4ff48ad4abc677954fcd5e9bb578aacc.tar.xz
gsoc2013-evolution-5794c63f4ff48ad4abc677954fcd5e9bb578aacc.tar.zst
gsoc2013-evolution-5794c63f4ff48ad4abc677954fcd5e9bb578aacc.zip
EMailBrowser: Add "close-on-reply-policy" property.
Mainly to avoid accessing GSettings directly from EMailBrowser. Also add a "browser-close-on-reply-policy" GSettings key that replaces "prompt-on-reply-close-browser", the difference being the new key uses an enum definition compatible with EAutomaticActionPolicy instead of a free-form string value. And finally add an ESettingsMailBrowser class to glue things together.
-rw-r--r--data/org.gnome.evolution.mail.gschema.xml.in17
-rw-r--r--mail/e-mail-browser.c90
-rw-r--r--mail/e-mail-browser.h6
-rw-r--r--modules/settings/Makefile.am2
-rw-r--r--modules/settings/e-settings-deprecated.c56
-rw-r--r--modules/settings/e-settings-mail-browser.c93
-rw-r--r--modules/settings/e-settings-mail-browser.h66
-rw-r--r--modules/settings/evolution-module-settings.c2
8 files changed, 303 insertions, 29 deletions
diff --git a/data/org.gnome.evolution.mail.gschema.xml.in b/data/org.gnome.evolution.mail.gschema.xml.in
index 65480585fd..71fff625dc 100644
--- a/data/org.gnome.evolution.mail.gschema.xml.in
+++ b/data/org.gnome.evolution.mail.gschema.xml.in
@@ -1,5 +1,12 @@
<schemalist>
+ <!-- Keep this synchronized with EAutomaticActionPolicy. -->
+ <enum id="org.gnome.evolution.mail.AutomaticActionPolicy">
+ <value nick='ask' value='0'/>
+ <value nick='always' value='1'/>
+ <value nick='never' value='2'/>
+ </enum>
+
<!-- Keep this synchronized with EMailForwardStyle. -->
<enum id="org.gnome.evolution.mail.ForwardStyle">
<value nick='attached' value='0'/>
@@ -426,10 +433,9 @@
<_summary>Prompt when replying to many recipients</_summary>
<_description>It disables/enables the repeated prompts to warn that you are sending a reply to many people.</_description>
</key>
- <key name="prompt-on-reply-close-browser" type="s">
+ <key name="browser-close-on-reply-policy" enum="org.gnome.evolution.mail.AutomaticActionPolicy">
<default>'ask'</default>
- <_summary>Asks whether to close the message window when the user forwards or replies to the message shown in the window</_summary>
- <_description>Possible values are: 'never' - to never close browser window, 'always' - to always close browser window or 'ask' - (or any other value) will ask user.</_description>
+ <_summary>Policy for automatically closing the message browser window when forwarding or replying to the displayed message.</_summary>
</key>
<key name="trash-empty-on-exit" type="b">
<default>false</default>
@@ -565,6 +571,11 @@
<_summary>(Deprecated) Load images for HTML messages over HTTP</_summary>
<_description>This key was deprecated in version 3.10 and should no longer be used. Use "image-loading-policy" instead.</_description>
</key>
+ <key name="prompt-on-reply-close-browser" type="s">
+ <default>'ask'</default>
+ <_summary>(Deprecated) Asks whether to close the message window when the user forwards or replies to the message shown in the window</_summary>
+ <_description>This key was deprecated in version 3.10 and should no longer be used. Use "browser-close-on-reply-policy" instead.</_description>
+ </key>
</schema>
diff --git a/mail/e-mail-browser.c b/mail/e-mail-browser.c
index 6e5cde86dc..030b7e4801 100644
--- a/mail/e-mail-browser.c
+++ b/mail/e-mail-browser.c
@@ -51,6 +51,7 @@ struct _EMailBrowserPrivate {
EFocusTracker *focus_tracker;
EMailFormatterMode display_mode;
+ EAutomaticActionPolicy close_on_reply_policy;
GtkWidget *main_menu;
GtkWidget *main_toolbar;
@@ -64,6 +65,7 @@ struct _EMailBrowserPrivate {
enum {
PROP_0,
PROP_BACKEND,
+ PROP_CLOSE_ON_REPLY_POLICY,
PROP_DISPLAY_MODE,
PROP_FOCUS_TRACKER,
PROP_FORWARD_STYLE,
@@ -386,6 +388,12 @@ mail_browser_set_property (GObject *object,
g_value_get_object (value));
return;
+ case PROP_CLOSE_ON_REPLY_POLICY:
+ e_mail_browser_set_close_on_reply_policy (
+ E_MAIL_BROWSER (object),
+ g_value_get_enum (value));
+ return;
+
case PROP_DISPLAY_MODE:
mail_browser_set_display_mode (
E_MAIL_BROWSER (object),
@@ -434,6 +442,13 @@ mail_browser_get_property (GObject *object,
E_MAIL_READER (object)));
return;
+ case PROP_CLOSE_ON_REPLY_POLICY:
+ g_value_set_enum (
+ value,
+ e_mail_browser_get_close_on_reply_policy (
+ E_MAIL_BROWSER (object)));
+ return;
+
case PROP_DISPLAY_MODE:
g_value_set_enum (
value,
@@ -522,7 +537,6 @@ mail_browser_constructed (GObject *object)
EShellBackend *shell_backend;
EShell *shell;
EFocusTracker *focus_tracker;
- GSettings *settings;
GtkAccelGroup *accel_group;
GtkActionGroup *action_group;
GtkAction *action;
@@ -669,17 +683,6 @@ mail_browser_constructed (GObject *object)
browser->priv->preview_pane,
TRUE, TRUE, 0);
- /* Bind GObject properties to GSettings keys. */
-
- settings = g_settings_new ("org.gnome.evolution.mail");
-
- g_settings_bind (
- settings, "show-deleted",
- reader, "show-deleted",
- G_SETTINGS_BIND_DEFAULT);
-
- g_object_unref (settings);
-
id = "org.gnome.evolution.mail.browser";
e_plugin_ui_register_manager (ui_manager, id, object);
e_plugin_ui_enable_manager (ui_manager, id);
@@ -826,9 +829,8 @@ mail_browser_composer_created (EMailReader *reader,
EMsgComposer *composer,
CamelMimeMessage *message)
{
- GSettings *settings;
- const gchar *key;
- gchar *value;
+ EMailBrowser *browser;
+ EAutomaticActionPolicy policy;
gboolean close_browser;
/* Do not prompt if there is no source message. It means
@@ -837,14 +839,12 @@ mail_browser_composer_created (EMailReader *reader,
if (message == NULL)
return;
- settings = g_settings_new ("org.gnome.evolution.mail");
-
- key = "prompt-on-reply-close-browser";
- value = g_settings_get_string (settings, key);
+ browser = E_MAIL_BROWSER (reader);
+ policy = e_mail_browser_get_close_on_reply_policy (browser);
- if (g_strcmp0 (value, "always") == 0) {
+ if (policy == E_AUTOMATIC_ACTION_POLICY_ALWAYS) {
close_browser = TRUE;
- } else if (g_strcmp0 (value, "never") == 0) {
+ } else if (policy == E_AUTOMATIC_ACTION_POLICY_NEVER) {
close_browser = FALSE;
} else {
GtkWidget *dialog;
@@ -873,14 +873,13 @@ mail_browser_composer_created (EMailReader *reader,
(response == GTK_RESPONSE_OK);
if (response == GTK_RESPONSE_OK)
- g_settings_set_string (settings, key, "always");
+ e_mail_browser_set_close_on_reply_policy (
+ browser, E_AUTOMATIC_ACTION_POLICY_ALWAYS);
else if (response == GTK_RESPONSE_CANCEL)
- g_settings_set_string (settings, key, "never");
+ e_mail_browser_set_close_on_reply_policy (
+ browser, E_AUTOMATIC_ACTION_POLICY_NEVER);
}
- g_free (value);
- g_object_unref (settings);
-
if (close_browser)
e_mail_browser_close (E_MAIL_BROWSER (reader));
}
@@ -916,6 +915,21 @@ e_mail_browser_class_init (EMailBrowserClass *class)
g_object_class_install_property (
object_class,
+ PROP_CLOSE_ON_REPLY_POLICY,
+ g_param_spec_enum (
+ "close-on-reply-policy",
+ "Close on Reply Policy",
+ "Policy for automatically closing the message "
+ "browser window when forwarding or replying to "
+ "the displayed message",
+ E_TYPE_AUTOMATIC_ACTION_POLICY,
+ E_AUTOMATIC_ACTION_POLICY_ASK,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (
+ object_class,
PROP_DISPLAY_MODE,
g_param_spec_enum (
"display-mode",
@@ -1031,6 +1045,30 @@ e_mail_browser_close (EMailBrowser *browser)
gtk_widget_destroy (GTK_WIDGET (browser));
}
+EAutomaticActionPolicy
+e_mail_browser_get_close_on_reply_policy (EMailBrowser *browser)
+{
+ g_return_val_if_fail (
+ E_IS_MAIL_BROWSER (browser),
+ E_AUTOMATIC_ACTION_POLICY_ASK);
+
+ return browser->priv->close_on_reply_policy;
+}
+
+void
+e_mail_browser_set_close_on_reply_policy (EMailBrowser *browser,
+ EAutomaticActionPolicy policy)
+{
+ g_return_if_fail (E_IS_MAIL_BROWSER (browser));
+
+ if (policy == browser->priv->close_on_reply_policy)
+ return;
+
+ browser->priv->close_on_reply_policy = policy;
+
+ g_object_notify (G_OBJECT (browser), "close-on-reply-policy");
+}
+
EMailFormatterMode
e_mail_browser_get_display_mode (EMailBrowser *browser)
{
diff --git a/mail/e-mail-browser.h b/mail/e-mail-browser.h
index fe7c6bfafd..dce6922be8 100644
--- a/mail/e-mail-browser.h
+++ b/mail/e-mail-browser.h
@@ -66,6 +66,12 @@ GtkWidget * e_mail_browser_new (EMailBackend *backend,
const gchar *message_uid,
EMailFormatterMode display_mode);
void e_mail_browser_close (EMailBrowser *browser);
+EAutomaticActionPolicy
+ e_mail_browser_get_close_on_reply_policy
+ (EMailBrowser *browser);
+void e_mail_browser_set_close_on_reply_policy
+ (EMailBrowser *browser,
+ EAutomaticActionPolicy policy);
EMailFormatterMode
e_mail_browser_get_display_mode (EMailBrowser *browser);
EFocusTracker * e_mail_browser_get_focus_tracker
diff --git a/modules/settings/Makefile.am b/modules/settings/Makefile.am
index 91ce7e3a72..7e3658f426 100644
--- a/modules/settings/Makefile.am
+++ b/modules/settings/Makefile.am
@@ -27,6 +27,8 @@ module_settings_la_SOURCES = \
e-settings-date-edit.h \
e-settings-deprecated.c \
e-settings-deprecated.h \
+ e-settings-mail-browser.c \
+ e-settings-mail-browser.h \
e-settings-mail-formatter.c \
e-settings-mail-formatter.h \
e-settings-mail-reader.c \
diff --git a/modules/settings/e-settings-deprecated.c b/modules/settings/e-settings-deprecated.c
index b42952f67c..73f8b741ad 100644
--- a/modules/settings/e-settings-deprecated.c
+++ b/modules/settings/e-settings-deprecated.c
@@ -42,6 +42,7 @@ struct _ESettingsDeprecatedPrivate {
gulong work_day_sunday_handler_id;
GSettings *mail_settings;
+ gulong browser_close_on_reply_policy_handler_id;
gulong forward_style_name_handler_id;
gulong reply_style_name_handler_id;
gulong image_loading_policy_handler_id;
@@ -174,6 +175,28 @@ settings_deprecated_work_day_sunday_cb (GSettings *settings,
}
static void
+settings_deprecated_browser_close_on_reply_policy_cb (GSettings *settings,
+ const gchar *key)
+{
+ const gchar *deprecated_key = "prompt-on-reply-close-browser";
+
+ switch (g_settings_get_enum (settings, key)) {
+ case E_AUTOMATIC_ACTION_POLICY_ALWAYS:
+ g_settings_set_string (
+ settings, deprecated_key, "always");
+ break;
+ case E_AUTOMATIC_ACTION_POLICY_NEVER:
+ g_settings_set_string (
+ settings, deprecated_key, "never");
+ break;
+ default:
+ g_settings_set_string (
+ settings, deprecated_key, "ask");
+ break;
+ }
+}
+
+static void
settings_deprecated_forward_style_name_cb (GSettings *settings,
const gchar *key)
{
@@ -280,6 +303,13 @@ settings_deprecated_dispose (GObject *object)
priv->work_day_sunday_handler_id = 0;
}
+ if (priv->browser_close_on_reply_policy_handler_id > 0) {
+ g_signal_handler_disconnect (
+ priv->mail_settings,
+ priv->browser_close_on_reply_policy_handler_id);
+ priv->browser_close_on_reply_policy_handler_id = 0;
+ }
+
if (priv->forward_style_name_handler_id > 0) {
g_signal_handler_disconnect (
priv->mail_settings,
@@ -313,6 +343,7 @@ settings_deprecated_constructed (GObject *object)
{
ESettingsDeprecatedPrivate *priv;
gulong handler_id;
+ gchar *string_value;
gint int_value;
priv = E_SETTINGS_DEPRECATED_GET_PRIVATE (object);
@@ -353,6 +384,26 @@ settings_deprecated_constructed (GObject *object)
priv->calendar_settings, "work-day-sunday",
(int_value & DEPRECATED_WORKING_DAYS_SUNDAY) != 0);
+ string_value = g_settings_get_string (
+ priv->mail_settings, "prompt-on-reply-close-browser");
+ if (g_strcmp0 (string_value, "always") == 0) {
+ g_settings_set_enum (
+ priv->mail_settings,
+ "browser-close-on-reply-policy",
+ E_AUTOMATIC_ACTION_POLICY_ALWAYS);
+ } else if (g_strcmp0 (string_value, "never") == 0) {
+ g_settings_set_enum (
+ priv->mail_settings,
+ "browser-close-on-reply-policy",
+ E_AUTOMATIC_ACTION_POLICY_NEVER);
+ } else {
+ g_settings_set_enum (
+ priv->mail_settings,
+ "browser-close-on-reply-policy",
+ E_AUTOMATIC_ACTION_POLICY_ASK);
+ }
+ g_free (string_value);
+
int_value = g_settings_get_int (
priv->mail_settings, "forward-style");
g_settings_set_enum (
@@ -438,6 +489,11 @@ settings_deprecated_constructed (GObject *object)
priv->work_day_sunday_handler_id = handler_id;
handler_id = g_signal_connect (
+ priv->mail_settings, "changed::browser-close-on-reply-policy",
+ G_CALLBACK (settings_deprecated_browser_close_on_reply_policy_cb), NULL);
+ priv->browser_close_on_reply_policy_handler_id = handler_id;
+
+ handler_id = g_signal_connect (
priv->mail_settings, "changed::forward-style-name",
G_CALLBACK (settings_deprecated_forward_style_name_cb), NULL);
priv->forward_style_name_handler_id = handler_id;
diff --git a/modules/settings/e-settings-mail-browser.c b/modules/settings/e-settings-mail-browser.c
new file mode 100644
index 0000000000..98712b9c8f
--- /dev/null
+++ b/modules/settings/e-settings-mail-browser.c
@@ -0,0 +1,93 @@
+/*
+ * e-settings-mail-browser.c
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#include "e-settings-mail-browser.h"
+
+#include <mail/e-mail-browser.h>
+
+#define E_SETTINGS_MAIL_BROWSER_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), E_TYPE_SETTINGS_MAIL_BROWSER, ESettingsMailBrowserPrivate))
+
+G_DEFINE_DYNAMIC_TYPE (
+ ESettingsMailBrowser,
+ e_settings_mail_browser,
+ E_TYPE_EXTENSION)
+
+static void
+settings_mail_browser_constructed (GObject *object)
+{
+ EExtensible *extensible;
+ GSettings *settings;
+
+ /* Chain up parent's constructed() method. */
+ G_OBJECT_CLASS (e_settings_mail_browser_parent_class)->
+ constructed (object);
+
+ extensible = e_extension_get_extensible (E_EXTENSION (object));
+
+ settings = g_settings_new ("org.gnome.evolution.mail");
+
+ /* This preference is selected directly from the mail
+ * browser window, so the binding must be bi-directional. */
+ g_settings_bind (
+ settings, "browser-close-on-reply-policy",
+ extensible, "close-on-reply-policy",
+ G_SETTINGS_BIND_GET |
+ G_SETTINGS_BIND_SET);
+
+ g_settings_bind (
+ settings, "show-deleted",
+ extensible, "show-deleted",
+ G_SETTINGS_BIND_GET);
+
+ g_object_unref (settings);
+}
+
+static void
+e_settings_mail_browser_class_init (ESettingsMailBrowserClass *class)
+{
+ GObjectClass *object_class;
+ EExtensionClass *extension_class;
+
+ object_class = G_OBJECT_CLASS (class);
+ object_class->constructed = settings_mail_browser_constructed;
+
+ extension_class = E_EXTENSION_CLASS (class);
+ extension_class->extensible_type = E_TYPE_MAIL_BROWSER;
+}
+
+static void
+e_settings_mail_browser_class_finalize (ESettingsMailBrowserClass *class)
+{
+}
+
+static void
+e_settings_mail_browser_init (ESettingsMailBrowser *extension)
+{
+}
+
+void
+e_settings_mail_browser_type_register (GTypeModule *type_module)
+{
+ /* XXX G_DEFINE_DYNAMIC_TYPE declares a static type registration
+ * function, so we have to wrap it with a public function in
+ * order to register types from a separate compilation unit. */
+ e_settings_mail_browser_register_type (type_module);
+}
+
diff --git a/modules/settings/e-settings-mail-browser.h b/modules/settings/e-settings-mail-browser.h
new file mode 100644
index 0000000000..edd5047668
--- /dev/null
+++ b/modules/settings/e-settings-mail-browser.h
@@ -0,0 +1,66 @@
+/*
+ * e-settings-mail-browser.h
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#ifndef E_SETTINGS_MAIL_BROWSER_H
+#define E_SETTINGS_MAIL_BROWSER_H
+
+#include <libebackend/libebackend.h>
+
+/* Standard GObject macros */
+#define E_TYPE_SETTINGS_MAIL_BROWSER \
+ (e_settings_mail_browser_get_type ())
+#define E_SETTINGS_MAIL_BROWSER(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), E_TYPE_SETTINGS_MAIL_BROWSER, ESettingsMailBrowser))
+#define E_SETTINGS_MAIL_BROWSER_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_CAST \
+ ((cls), E_TYPE_SETTINGS_MAIL_BROWSER, ESettingsMailBrowserClass))
+#define E_IS_SETTINGS_MAIL_BROWSER(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), E_TYPE_SETTINGS_MAIL_BROWSER))
+#define E_IS_SETTINGS_MAIL_BROWSER_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_TYPE \
+ ((cls), E_TYPE_SETTINGS_MAIL_BROWSER))
+#define E_SETTINGS_MAIL_BROWSER_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), E_TYPE_SETTINGS_MAIL_BROWSER, ESettingsMailBrowserClass))
+
+G_BEGIN_DECLS
+
+typedef struct _ESettingsMailBrowser ESettingsMailBrowser;
+typedef struct _ESettingsMailBrowserClass ESettingsMailBrowserClass;
+typedef struct _ESettingsMailBrowserPrivate ESettingsMailBrowserPrivate;
+
+struct _ESettingsMailBrowser {
+ EExtension parent;
+ ESettingsMailBrowserPrivate *priv;
+};
+
+struct _ESettingsMailBrowserClass {
+ EExtensionClass parent_class;
+};
+
+GType e_settings_mail_browser_get_type
+ (void) G_GNUC_CONST;
+void e_settings_mail_browser_type_register
+ (GTypeModule *type_module);
+
+G_END_DECLS
+
+#endif /* E_SETTINGS_MAIL_BROWSER_H */
+
diff --git a/modules/settings/evolution-module-settings.c b/modules/settings/evolution-module-settings.c
index 52d55f454b..4de90226fe 100644
--- a/modules/settings/evolution-module-settings.c
+++ b/modules/settings/evolution-module-settings.c
@@ -23,6 +23,7 @@
#include "e-settings-comp-editor.h"
#include "e-settings-date-edit.h"
#include "e-settings-deprecated.h"
+#include "e-settings-mail-browser.h"
#include "e-settings-mail-formatter.h"
#include "e-settings-mail-reader.h"
#include "e-settings-meeting-store.h"
@@ -47,6 +48,7 @@ e_module_load (GTypeModule *type_module)
e_settings_comp_editor_type_register (type_module);
e_settings_date_edit_type_register (type_module);
e_settings_deprecated_type_register (type_module);
+ e_settings_mail_browser_type_register (type_module);
e_settings_mail_formatter_type_register (type_module);
e_settings_mail_reader_type_register (type_module);
e_settings_meeting_store_type_register (type_module);