[evolution/gnome-2-30] Bug #374533 - Read window stays open after last email is deleted
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/gnome-2-30] Bug #374533 - Read window stays open after last email is deleted
- Date: Thu, 1 Apr 2010 12:04:51 +0000 (UTC)
commit 21981b4515c3a0509b8bbf852fccd7c684e8e634
Author: Milan Crha <mcrha redhat com>
Date: Thu Apr 1 14:03:34 2010 +0200
Bug #374533 - Read window stays open after last email is deleted
mail/e-mail-browser.c | 23 +++++++++++++++++++++++
mail/message-list.c | 27 +++++++++++++++++++++++++++
mail/message-list.h | 1 +
3 files changed, 51 insertions(+), 0 deletions(-)
---
diff --git a/mail/e-mail-browser.c b/mail/e-mail-browser.c
index 96f168f..26d3a87 100644
--- a/mail/e-mail-browser.c
+++ b/mail/e-mail-browser.c
@@ -267,6 +267,25 @@ mail_browser_message_selected_cb (EMailBrowser *browser,
}
static gboolean
+close_on_idle_cb (gpointer browser)
+{
+ e_mail_browser_close (browser);
+ return FALSE;
+}
+
+static void
+mail_browser_message_list_built_cb (EMailBrowser *browser, MessageList *message_list)
+{
+ g_return_if_fail (browser != NULL);
+ g_return_if_fail (E_IS_MAIL_BROWSER (browser));
+ g_return_if_fail (message_list != NULL);
+ g_return_if_fail (IS_MESSAGE_LIST (message_list));
+
+ if (!message_list_count (message_list))
+ g_idle_add (close_on_idle_cb, browser);
+}
+
+static gboolean
mail_browser_popup_event_cb (EMailBrowser *browser,
GdkEventButton *event,
const gchar *uri)
@@ -487,6 +506,10 @@ mail_browser_constructed (GObject *object)
G_CALLBACK (mail_browser_message_selected_cb), object);
g_signal_connect_swapped (
+ priv->message_list, "message-list-built",
+ G_CALLBACK (mail_browser_message_list_built_cb), object);
+
+ g_signal_connect_swapped (
web_view, "popup-event",
G_CALLBACK (mail_browser_popup_event_cb), object);
diff --git a/mail/message-list.c b/mail/message-list.c
index 6526950..25116ba 100644
--- a/mail/message-list.c
+++ b/mail/message-list.c
@@ -3873,6 +3873,33 @@ message_list_set_selected(MessageList *ml, GPtrArray *uids)
g_ptr_array_free(paths, TRUE);
}
+struct ml_count_data {
+ MessageList *ml;
+ guint count;
+};
+
+static void
+ml_getcount_cb (ETreePath path, gpointer user_data)
+{
+ struct ml_count_data *data = user_data;
+
+ if (!e_tree_model_node_is_root (data->ml->model, path))
+ data->count++;
+}
+
+guint
+message_list_count (MessageList *message_list)
+{
+ struct ml_count_data data = { message_list, 0 };
+
+ g_return_val_if_fail (message_list != NULL, 0);
+ g_return_val_if_fail (IS_MESSAGE_LIST (message_list), 0);
+
+ e_tree_path_foreach (E_TREE (message_list), ml_getcount_cb, &data);
+
+ return data.count;
+}
+
void
message_list_freeze(MessageList *ml)
{
diff --git a/mail/message-list.h b/mail/message-list.h
index c7efc5d..4b7e4da 100644
--- a/mail/message-list.h
+++ b/mail/message-list.h
@@ -218,6 +218,7 @@ void message_list_copy (MessageList *message_list,
gboolean cut);
void message_list_paste (MessageList *message_list);
guint message_list_length (MessageList *message_list);
+guint message_list_count (MessageList *message_list);
guint message_list_hidden (MessageList *message_list);
void message_list_hide_add (MessageList *message_list,
const gchar *expr,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]