[evolution] Bug 794832 - Option to close window on deletion, not open next mail
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution] Bug 794832 - Option to close window on deletion, not open next mail
- Date: Tue, 3 Apr 2018 15:10:55 +0000 (UTC)
commit ed93c95b28735e34f99b0785e3ca7b36ca11661c
Author: Milan Crha <mcrha redhat com>
Date: Tue Apr 3 17:12:14 2018 +0200
Bug 794832 - Option to close window on deletion, not open next mail
data/org.gnome.evolution.mail.gschema.xml.in | 4 ++
src/mail/e-mail-browser.c | 67 +++++++++++++++++++++++-
src/mail/e-mail-browser.h | 5 ++
src/mail/e-mail-reader.c | 26 +++++++++-
src/mail/e-mail-reader.h | 6 ++-
src/modules/settings/e-settings-mail-browser.c | 5 ++
6 files changed, 109 insertions(+), 4 deletions(-)
---
diff --git a/data/org.gnome.evolution.mail.gschema.xml.in b/data/org.gnome.evolution.mail.gschema.xml.in
index c64ddd3..9400ec8 100644
--- a/data/org.gnome.evolution.mail.gschema.xml.in
+++ b/data/org.gnome.evolution.mail.gschema.xml.in
@@ -774,6 +774,10 @@
<default>true</default>
<_summary>Whether set “body” in mailto: URI as Preformatted paragraph style. If set to “false”, then
Normal paragraph style will be used.</_summary>
</key>
+ <key name="browser-close-on-delete-or-junk" type="b">
+ <default>false</default>
+ <_summary>Close the message browser window when the selected message is deleted or marked as
Junk.</_summary>
+ </key>
<!-- The following keys are deprecated. -->
<key name="forward-style" type="i">
diff --git a/src/mail/e-mail-browser.c b/src/mail/e-mail-browser.c
index 5c7dba8..48b9ac0 100644
--- a/src/mail/e-mail-browser.c
+++ b/src/mail/e-mail-browser.c
@@ -61,6 +61,7 @@ struct _EMailBrowserPrivate {
guint show_deleted : 1;
guint show_junk : 1;
+ guint close_on_delete_or_junk : 1;
};
enum {
@@ -76,7 +77,8 @@ enum {
PROP_SHOW_DELETED,
PROP_SHOW_JUNK,
PROP_UI_MANAGER,
- PROP_DELETE_SELECTS_PREVIOUS
+ PROP_DELETE_SELECTS_PREVIOUS,
+ PROP_CLOSE_ON_DELETE_OR_JUNK
};
/* This is too trivial to put in a file.
@@ -474,6 +476,12 @@ mail_browser_set_property (GObject *object,
E_MAIL_READER (object),
g_value_get_boolean (value));
return;
+
+ case PROP_CLOSE_ON_DELETE_OR_JUNK:
+ e_mail_browser_set_close_on_delete_or_junk (
+ E_MAIL_BROWSER (object),
+ g_value_get_boolean (value));
+ return;
}
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -569,6 +577,13 @@ mail_browser_get_property (GObject *object,
e_mail_reader_get_delete_selects_previous (
E_MAIL_READER (object)));
return;
+
+ case PROP_CLOSE_ON_DELETE_OR_JUNK:
+ g_value_set_boolean (
+ value,
+ e_mail_browser_get_close_on_delete_or_junk (
+ E_MAIL_BROWSER (object)));
+ return;
}
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -968,6 +983,21 @@ mail_browser_composer_created (EMailReader *reader,
}
}
+static gboolean
+mail_browser_close_on_delete_or_junk (EMailReader *reader)
+{
+ g_return_val_if_fail (E_IS_MAIL_BROWSER (reader), FALSE);
+
+ if (!e_mail_browser_get_close_on_delete_or_junk (E_MAIL_BROWSER (reader)))
+ return FALSE;
+
+ g_idle_add_full (
+ G_PRIORITY_HIGH_IDLE,
+ close_on_idle_cb, reader, NULL);
+
+ return TRUE;
+}
+
static void
e_mail_browser_class_init (EMailBrowserClass *class)
{
@@ -1098,6 +1128,18 @@ e_mail_browser_class_init (EMailBrowserClass *class)
GTK_TYPE_UI_MANAGER,
G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_CLOSE_ON_DELETE_OR_JUNK,
+ g_param_spec_boolean (
+ "close-on-delete-or-junk",
+ "Close On Delete Or Junk",
+ "Close on message delete or when marked as Junk",
+ FALSE,
+ G_PARAM_CONSTRUCT |
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_STRINGS));
}
static void
@@ -1113,6 +1155,7 @@ e_mail_browser_reader_init (EMailReaderInterface *iface)
iface->get_window = mail_browser_get_window;
iface->set_message = mail_browser_set_message;
iface->composer_created = mail_browser_composer_created;
+ iface->close_on_delete_or_junk = mail_browser_close_on_delete_or_junk;
}
static void
@@ -1274,3 +1317,25 @@ e_mail_browser_get_ui_manager (EMailBrowser *browser)
return browser->priv->ui_manager;
}
+
+gboolean
+e_mail_browser_get_close_on_delete_or_junk (EMailBrowser *browser)
+{
+ g_return_val_if_fail (E_IS_MAIL_BROWSER (browser), FALSE);
+
+ return browser->priv->close_on_delete_or_junk;
+}
+
+void
+e_mail_browser_set_close_on_delete_or_junk (EMailBrowser *browser,
+ gboolean close_on_delete_or_junk)
+{
+ g_return_if_fail (E_IS_MAIL_BROWSER (browser));
+
+ if ((browser->priv->close_on_delete_or_junk ? 1 : 0) == (close_on_delete_or_junk ? 1 : 0))
+ return;
+
+ browser->priv->close_on_delete_or_junk = close_on_delete_or_junk;
+
+ g_object_notify (G_OBJECT (browser), "close-on-delete-or-junk");
+}
diff --git a/src/mail/e-mail-browser.h b/src/mail/e-mail-browser.h
index b0e5edd..a03be10 100644
--- a/src/mail/e-mail-browser.h
+++ b/src/mail/e-mail-browser.h
@@ -82,6 +82,11 @@ gboolean e_mail_browser_get_show_junk (EMailBrowser *browser);
void e_mail_browser_set_show_junk (EMailBrowser *browser,
gboolean show_junk);
GtkUIManager * e_mail_browser_get_ui_manager (EMailBrowser *browser);
+gboolean e_mail_browser_get_close_on_delete_or_junk
+ (EMailBrowser *browser);
+void e_mail_browser_set_close_on_delete_or_junk
+ (EMailBrowser *browser,
+ gboolean close_on_delete_or_junk);
G_END_DECLS
diff --git a/src/mail/e-mail-reader.c b/src/mail/e-mail-reader.c
index 429e1e9..aa372ab 100644
--- a/src/mail/e-mail-reader.c
+++ b/src/mail/e-mail-reader.c
@@ -560,7 +560,8 @@ action_mail_delete_cb (GtkAction *action,
/* FIXME Verify all selected messages are deletable.
* But handle it by disabling this action. */
- if (e_mail_reader_mark_selected (reader, mask, set) != 0) {
+ if (e_mail_reader_mark_selected (reader, mask, set) != 0 &&
+ !e_mail_reader_close_on_delete_or_junk (reader)) {
if (e_mail_reader_get_delete_selects_previous (reader))
e_mail_reader_select_previous_message (reader, FALSE);
else
@@ -839,7 +840,8 @@ action_mail_mark_junk_cb (GtkAction *action,
CAMEL_MESSAGE_JUNK |
CAMEL_MESSAGE_JUNK_LEARN;
- if (e_mail_reader_mark_selected (reader, mask, set) != 0) {
+ if (e_mail_reader_mark_selected (reader, mask, set) != 0 &&
+ !e_mail_reader_close_on_delete_or_junk (reader)) {
if (e_mail_reader_get_delete_selects_previous (reader))
e_mail_reader_select_previous_message (reader, TRUE);
else
@@ -4221,6 +4223,12 @@ mail_reader_update_actions (EMailReader *reader,
gtk_action_set_sensitive (action, sensitive);
}
+static gboolean
+mail_reader_close_on_delete_or_junk (EMailReader *reader)
+{
+ return FALSE;
+}
+
static void
mail_reader_init_charset_actions (EMailReader *reader,
GtkActionGroup *action_group)
@@ -4265,6 +4273,7 @@ e_mail_reader_default_init (EMailReaderInterface *iface)
iface->message_seen = mail_reader_message_seen;
iface->show_search_bar = mail_reader_show_search_bar;
iface->update_actions = mail_reader_update_actions;
+ iface->close_on_delete_or_junk = mail_reader_close_on_delete_or_junk;
g_object_interface_install_property (
iface,
@@ -5179,6 +5188,19 @@ e_mail_reader_get_window (EMailReader *reader)
return iface->get_window (reader);
}
+gboolean
+e_mail_reader_close_on_delete_or_junk (EMailReader *reader)
+{
+ EMailReaderInterface *iface;
+
+ g_return_val_if_fail (E_IS_MAIL_READER (reader), FALSE);
+
+ iface = E_MAIL_READER_GET_INTERFACE (reader);
+
+ return iface->close_on_delete_or_junk != NULL &&
+ iface->close_on_delete_or_junk (reader);
+}
+
CamelFolder *
e_mail_reader_ref_folder (EMailReader *reader)
{
diff --git a/src/mail/e-mail-reader.h b/src/mail/e-mail-reader.h
index e1878b6..9934ac5 100644
--- a/src/mail/e-mail-reader.h
+++ b/src/mail/e-mail-reader.h
@@ -133,9 +133,11 @@ struct _EMailReaderInterface {
void (*show_search_bar) (EMailReader *reader);
void (*update_actions) (EMailReader *reader,
guint32 state);
+ gboolean (*close_on_delete_or_junk)
+ (EMailReader *reader);
/* Padding for future expansion */
- gpointer reserved[4];
+ gpointer reserved[3];
};
GType e_mail_reader_get_type (void);
@@ -166,6 +168,8 @@ GPtrArray * e_mail_reader_get_selected_uids (EMailReader *reader);
GPtrArray * e_mail_reader_get_selected_uids_with_collapsed_threads
(EMailReader *reader);
GtkWindow * e_mail_reader_get_window (EMailReader *reader);
+gboolean e_mail_reader_close_on_delete_or_junk
+ (EMailReader *reader);
CamelFolder * e_mail_reader_ref_folder (EMailReader *reader);
void e_mail_reader_set_folder (EMailReader *reader,
CamelFolder *folder);
diff --git a/src/modules/settings/e-settings-mail-browser.c b/src/modules/settings/e-settings-mail-browser.c
index ef65f21..3c137c0 100644
--- a/src/modules/settings/e-settings-mail-browser.c
+++ b/src/modules/settings/e-settings-mail-browser.c
@@ -59,6 +59,11 @@ settings_mail_browser_constructed (GObject *object)
extensible, "show-junk",
G_SETTINGS_BIND_GET);
+ g_settings_bind (
+ settings, "browser-close-on-delete-or-junk",
+ extensible, "close-on-delete-or-junk",
+ G_SETTINGS_BIND_GET);
+
g_object_unref (settings);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]