diff options
author | Milan Crha <mcrha@redhat.com> | 2010-04-01 20:03:34 +0800 |
---|---|---|
committer | Milan Crha <mcrha@redhat.com> | 2010-04-01 20:03:34 +0800 |
commit | 21981b4515c3a0509b8bbf852fccd7c684e8e634 (patch) | |
tree | b929e971758b546e1f0a38bf4ebae55b7f37687b /mail | |
parent | 7e567893e6de45650b0f425b37b2dc4e86fad701 (diff) | |
download | gsoc2013-evolution-21981b4515c3a0509b8bbf852fccd7c684e8e634.tar.gz gsoc2013-evolution-21981b4515c3a0509b8bbf852fccd7c684e8e634.tar.zst gsoc2013-evolution-21981b4515c3a0509b8bbf852fccd7c684e8e634.zip |
Bug #374533 - Read window stays open after last email is deleted
Diffstat (limited to 'mail')
-rw-r--r-- | mail/e-mail-browser.c | 23 | ||||
-rw-r--r-- | mail/message-list.c | 27 | ||||
-rw-r--r-- | 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 96f168fec9..26d3a876f1 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 652695065f..25116ba682 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 c7efc5dc14..4b7e4da1dc 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, |