diff --git a/src/client/conversation-list/conversation-list-store.vala b/src/client/conversation-list/conversation-list-store.vala index 7c3bc692..8ba37b31 100644 --- a/src/client/conversation-list/conversation-list-store.vala +++ b/src/client/conversation-list/conversation-list-store.vala @@ -90,9 +90,8 @@ public class ConversationListStore : Gtk.ListStore { private bool loading_local_only = true; private Geary.Nonblocking.Mutex refresh_mutex = new Geary.Nonblocking.Mutex(); private uint update_id = 0; - - public signal void conversations_added_began(); - public signal void conversations_added_finished(); + + public signal void conversations_added(bool start); public signal void conversations_removed(bool start); public ConversationListStore(Geary.App.ConversationMonitor conversations) { @@ -415,7 +414,7 @@ public class ConversationListStore : Gtk.ListStore { if (conversations.size == 0) return; - conversations_added_began(); + conversations_added(true); debug("Adding %d conversations.", conversations.size); int added = 0; @@ -425,7 +424,7 @@ public class ConversationListStore : Gtk.ListStore { } debug("Added %d/%d conversations.", added, conversations.size); - conversations_added_finished(); + conversations_added(false); } private void on_conversations_removed(Gee.Collection conversations) { diff --git a/src/client/conversation-list/conversation-list-view.vala b/src/client/conversation-list/conversation-list-view.vala index 20366eae..fdacaa1e 100644 --- a/src/client/conversation-list/conversation-list-view.vala +++ b/src/client/conversation-list/conversation-list-view.vala @@ -78,12 +78,7 @@ public class ConversationListView : Gtk.TreeView { public new void set_model(ConversationListStore? new_store) { ConversationListStore? old_store = get_model(); if (old_store != null) { - old_store.conversations_added_finished.disconnect( - on_conversations_added_finished - ); - old_store.conversations_added_began.disconnect( - on_conversations_added_began - ); + old_store.conversations_added.disconnect(on_conversations_added); old_store.conversations_removed.disconnect(on_conversations_removed); old_store.row_inserted.disconnect(on_rows_changed); old_store.rows_reordered.disconnect(on_rows_changed); @@ -98,13 +93,8 @@ public class ConversationListView : Gtk.TreeView { new_store.row_changed.connect(on_rows_changed); new_store.row_deleted.connect(on_rows_changed); new_store.row_deleted.connect(on_row_deleted); - new_store.conversations_added_began.connect( - on_conversations_added_began - ); - new_store.conversations_added_finished.connect( - on_conversations_added_finished - ); new_store.conversations_removed.connect(on_conversations_removed); + new_store.conversations_added.connect(on_conversations_added); } // Disconnect the selection handler since we don't want to @@ -174,27 +164,23 @@ public class ConversationListView : Gtk.TreeView { } } - private void on_conversations_added_began() { + private void on_conversations_added(bool start) { Gtk.Adjustment? adjustment = get_adjustment(); - // If we were at the top, we want to stay there after conversations are added. - reset_adjustment = adjustment != null && adjustment.get_value() == 0; - } - - private void on_conversations_added_finished() { - if (!reset_adjustment) - return; - - // Pump the loop to make sure the new conversations are taking up space - // in the window. Without this, setting the adjustment here is a no-op - // because as far as it's concerned, it's already at the top. - while (Gtk.events_pending()) - Gtk.main_iteration(); - - Gtk.Adjustment? adjustment = get_adjustment(); - if (adjustment == null) - return; - - adjustment.set_value(0); + if (start) { + // If we were at the top, we want to stay there after + // conversations are added. + this.reset_adjustment = adjustment != null && adjustment.get_value() == 0; + } else if (this.reset_adjustment && adjustment != null) { + // Pump the loop to make sure the new conversations are + // taking up space in the window. Without this, setting + // the adjustment here is a no-op because as far as it's + // concerned, it's already at the top. + while (Gtk.events_pending()) + Gtk.main_iteration(); + + adjustment.set_value(0); + } + this.reset_adjustment = false; } private void on_conversations_removed(bool start) { @@ -405,7 +391,7 @@ public class ConversationListView : Gtk.TreeView { // doing the same things (in particular, I/O) multiple times private void do_selection_changed() { Gee.HashSet new_selection = - new Gee.HashSet(); + new Gee.HashSet(); List paths = get_all_selected_paths(); if (paths.length() != 0) { // Conversations are selected, so collect them and