aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mail/e-mail-browser.c23
-rw-r--r--mail/message-list.c27
-rw-r--r--mail/message-list.h2
3 files changed, 51 insertions, 1 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 88a711085b..453e261574 100644
--- a/mail/message-list.c
+++ b/mail/message-list.c
@@ -3851,6 +3851,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 4431f8658c..a817047cc6 100644
--- a/mail/message-list.h
+++ b/mail/message-list.h
@@ -202,7 +202,7 @@ void message_list_invert_selection (MessageList *message_list);
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);
void message_list_set_threaded (MessageList *message_list,
gboolean threaded);
void message_list_set_threaded_expand_all