aboutsummaryrefslogtreecommitdiffstats
path: root/modules
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 /modules
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.
Diffstat (limited to 'modules')
-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
5 files changed, 219 insertions, 0 deletions
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);