diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2013-06-05 00:03:24 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2013-06-05 01:10:02 +0800 |
commit | 5794c63f4ff48ad4abc677954fcd5e9bb578aacc (patch) | |
tree | 8fd8dcd8e6060085efa099bedf8ca0b1405f3cdd /mail | |
parent | 046816123764f86f1b258195292abcdb7951fca3 (diff) | |
download | gsoc2013-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 'mail')
-rw-r--r-- | mail/e-mail-browser.c | 90 | ||||
-rw-r--r-- | mail/e-mail-browser.h | 6 |
2 files changed, 70 insertions, 26 deletions
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 |