[geary/wip/730682-refine-convo-list: 33/37] Remove last uses of ConversationListView, remove it from MainWindow.
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/wip/730682-refine-convo-list: 33/37] Remove last uses of ConversationListView, remove it from MainWindow.
- Date: Mon, 11 Dec 2017 21:15:22 +0000 (UTC)
commit 325d5bbe669e8a5f8f407d6249442420600380ea
Author: Michael James Gratton <mike vee net>
Date: Mon Dec 11 19:21:32 2017 +1100
Remove last uses of ConversationListView, remove it from MainWindow.
src/client/application/geary-controller.vala | 49 +++++-------------
src/client/components/main-window.vala | 4 --
.../conversation-list/conversation-list.vala | 53 ++++++++++++++------
.../conversation-viewer/conversation-viewer.vala | 12 ++--
4 files changed, 57 insertions(+), 61 deletions(-)
---
diff --git a/src/client/application/geary-controller.vala b/src/client/application/geary-controller.vala
index 361487d..e3667c5 100644
--- a/src/client/application/geary-controller.vala
+++ b/src/client/application/geary-controller.vala
@@ -223,7 +223,6 @@ public class GearyController : Geary.BaseObject {
Geary.Engine.instance.untrusted_host.connect(on_untrusted_host);
// Connect to various UI signals.
- main_window.conversation_list_view.mark_conversations.connect(on_mark_conversations);
main_window.folder_list.folder_selected.connect(on_folder_selected);
main_window.folder_list.copy_conversation.connect(on_copy_conversation);
main_window.folder_list.move_conversation.connect(on_move_conversation);
@@ -251,7 +250,7 @@ public class GearyController : Geary.BaseObject {
// This is fired after the accounts are ready.
Geary.Engine.instance.opened.connect(on_engine_opened);
- this.main_window.conversation_list_view.grab_focus();
+ this.main_window.conversation_list.grab_focus();
// instantiate here to ensure that Config is initialized and ready
this.autostart_manager = new AutostartManager(this.application);
@@ -293,7 +292,6 @@ public class GearyController : Geary.BaseObject {
Geary.Engine.instance.untrusted_host.disconnect(on_untrusted_host);
// Disconnect from various UI signals.
- main_window.conversation_list_view.mark_conversations.disconnect(on_mark_conversations);
main_window.folder_list.folder_selected.disconnect(on_folder_selected);
main_window.folder_list.copy_conversation.disconnect(on_copy_conversation);
main_window.folder_list.move_conversation.disconnect(on_move_conversation);
@@ -1225,8 +1223,6 @@ public class GearyController : Geary.BaseObject {
debug("Folder %s selected", folder != null ? folder.to_string() : "(null)");
if (folder == null) {
this.current_folder = null;
- main_window.conversation_list_view.set_model(null);
- main_window.main_toolbar.folder = null;
folder_selected(null);
} else if (folder != this.current_folder) {
this.main_window.conversation_viewer.show_loading();
@@ -1360,9 +1356,9 @@ public class GearyController : Geary.BaseObject {
main_window.folder_list.select_folder(folder);
Geary.App.Conversation? conversation = current_conversations.get_conversation_for_email(email.id);
if (conversation != null)
- main_window.conversation_list_view.select_conversation(conversation);
+ main_window.conversation_list.select_conversation(conversation);
}
-
+
private void on_indicator_activated_application(uint32 timestamp) {
// When the app is started hidden, show_all() never gets
// called, do so here to prevent an empty window appearing.
@@ -1573,17 +1569,7 @@ public class GearyController : Geary.BaseObject {
return add_to;
}
-
- private Gee.Collection<Geary.EmailIdentifier> get_conversation_collection_email_ids(
- Gee.Collection<Geary.App.Conversation> conversations, bool latest_sent_only) {
- Gee.ArrayList<Geary.EmailIdentifier> ret = new Gee.ArrayList<Geary.EmailIdentifier>();
-
- foreach(Geary.App.Conversation c in conversations)
- get_conversation_email_ids(c, latest_sent_only, ret);
-
- return ret;
- }
-
+
private Gee.ArrayList<Geary.EmailIdentifier> get_selected_email_ids(bool latest_sent_only) {
Gee.ArrayList<Geary.EmailIdentifier> ids = new Gee.ArrayList<Geary.EmailIdentifier>();
foreach (Geary.App.Conversation conversation in this.main_window.get_selected_conversations())
@@ -1642,10 +1628,10 @@ public class GearyController : Geary.BaseObject {
// if conversation list is at top of display, don't display
// and don't display if main window has top-level focus
return folder != current_folder
- || main_window.conversation_list_view.vadjustment.value != 0.0
+ || main_window.conversation_list.get_adjustment().value != 0.0
|| !main_window.has_toplevel_focus;
}
-
+
// Clears messages if conditions are true: anything in should_notify_new_messages() is
// false and the supplied visible messages are visible in the conversation list view
internal void clear_new_messages(string caller, Gee.Set<Geary.App.Conversation>? supplied) {
@@ -1654,7 +1640,7 @@ public class GearyController : Geary.BaseObject {
return;
Gee.Set<Geary.App.Conversation> visible =
- supplied ?? main_window.conversation_list_view.get_visible_conversations();
+ supplied ?? main_window.conversation_list.get_visible_conversations();
foreach (Geary.App.Conversation conversation in visible) {
if (new_messages_monitor.are_any_new_messages(current_folder, conversation.get_email_ids())) {
@@ -1665,14 +1651,7 @@ public class GearyController : Geary.BaseObject {
}
}
}
-
- private void on_mark_conversations(Gee.Collection<Geary.App.Conversation> conversations,
- Geary.EmailFlags? flags_to_add, Geary.EmailFlags? flags_to_remove,
- bool latest_only = false) {
- mark_email(get_conversation_collection_email_ids(conversations, latest_only),
- flags_to_add, flags_to_remove);
- }
-
+
private void on_conversation_viewer_mark_emails(Gee.Collection<Geary.EmailIdentifier> emails,
Geary.EmailFlags? flags_to_add, Geary.EmailFlags? flags_to_remove) {
mark_email(emails, flags_to_add, flags_to_remove);
@@ -1773,7 +1752,7 @@ public class GearyController : Geary.BaseObject {
if (ids.size == 0)
return;
- this.main_window.conversation_list_view.set_changing_selection(true);
+ this.main_window.conversation_list.set_changing_selection(true);
Geary.FolderSupport.Move? supports_move = current_folder as Geary.FolderSupport.Move;
if (supports_move != null)
@@ -1781,7 +1760,7 @@ public class GearyController : Geary.BaseObject {
supports_move, ids, destination.path, cancellable_folder,
(obj, ret) => {
move_conversation_async.end(ret);
- this.main_window.conversation_list_view.set_changing_selection(false);
+ this.main_window.conversation_list.set_changing_selection(false);
});
}
@@ -2340,7 +2319,7 @@ public class GearyController : Geary.BaseObject {
last_deleted_conversation = selected_conversations.size > 0
? Geary.traverse<Geary.App.Conversation>(selected_conversations).first() : null;
- this.main_window.conversation_list_view.set_changing_selection(true);
+ this.main_window.conversation_list.set_changing_selection(true);
Gee.List<Geary.EmailIdentifier> ids = get_selected_email_ids(false);
if (archive) {
@@ -2396,9 +2375,9 @@ public class GearyController : Geary.BaseObject {
} catch (Error e) {
debug("Unable to archive/trash/delete messages: %s", e.message);
}
- this.main_window.conversation_list_view.set_changing_selection(false);
+ this.main_window.conversation_list.set_changing_selection(false);
}
-
+
private void save_revokable(Geary.Revokable? new_revokable, string? description) {
// disconnect old revokable & blindly commit it
if (revokable != null) {
@@ -2478,7 +2457,7 @@ public class GearyController : Geary.BaseObject {
}
private void on_conversation_list() {
- this.main_window.conversation_list_view.grab_focus();
+ this.main_window.conversation_list.grab_focus();
}
private void on_sent(Geary.RFC822.Message rfc822) {
diff --git a/src/client/components/main-window.vala b/src/client/components/main-window.vala
index 827664a..f5978fe 100644
--- a/src/client/components/main-window.vala
+++ b/src/client/components/main-window.vala
@@ -24,7 +24,6 @@ public class MainWindow : Gtk.ApplicationWindow {
public FolderList.Tree folder_list { get; private set; default = new FolderList.Tree(); }
public MainToolbar main_toolbar { get; private set; }
public SearchBar search_bar { get; private set; default = new SearchBar(); }
- public ConversationListView conversation_list_view { get; private set; }
public ConversationList conversation_list { get; private set; }
public ConversationViewer conversation_viewer { get; private set; default = new ConversationViewer(); }
public StatusBar status_bar { get; private set; default = new StatusBar(); }
@@ -195,9 +194,6 @@ public class MainWindow : Gtk.ApplicationWindow {
}
private void setup_layout(Configuration config) {
- // ConversationListView
- this.conversation_list_view = new ConversationListView(this);
- // Toolbar
this.main_toolbar = new MainToolbar(config);
this.main_toolbar.bind_property("search-open", this.search_bar, "search-mode-enabled",
BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL);
diff --git a/src/client/conversation-list/conversation-list.vala
b/src/client/conversation-list/conversation-list.vala
index 5565319..3bdbf45 100644
--- a/src/client/conversation-list/conversation-list.vala
+++ b/src/client/conversation-list/conversation-list.vala
@@ -51,16 +51,7 @@ public class ConversationList : Gtk.ListBox {
uint activated = row.get_index();
this.conversation_activated(this.model.get_conversation(activated));
});
- this.selected_rows_changed.connect(() => {
- Gee.HashSet<Geary.App.Conversation> new_selection =
- new Gee.HashSet<Geary.App.Conversation>();
- foreach (Gtk.ListBoxRow row in get_selected_rows()) {
- uint selected = row.get_index();
- new_selection.add(this.model.get_conversation(selected));
- }
- this.conversation_selection_changed(new_selection);
- });
-
+ this.selected_rows_changed.connect(on_selection_changed);
this.show.connect(on_show);
}
@@ -90,6 +81,38 @@ public class ConversationList : Gtk.ListBox {
);
}
+ public void select_conversation(Geary.App.Conversation target) {
+ // XXX Implement me
+ }
+
+ public void select_conversations(Gee.Set<Geary.App.Conversation> targets) {
+ // XXX Implement me
+ }
+
+ public Gee.Set<Geary.App.Conversation> get_selected_conversations() {
+ Gee.HashSet<Geary.App.Conversation> selection =
+ new Gee.HashSet<Geary.App.Conversation>();
+ foreach (Gtk.ListBoxRow row in get_selected_rows()) {
+ uint selected = row.get_index();
+ selection.add(this.model.get_conversation(selected));
+ }
+ return selection;
+ }
+
+ internal Gee.Set<Geary.App.Conversation> get_visible_conversations() {
+ Gee.HashSet<Geary.App.Conversation> visible = new Gee.HashSet<Geary.App.Conversation>();
+ // XXX Implement me
+ return visible;
+ }
+
+ internal void set_changing_selection(bool changing) {
+ if (changing) {
+ this.selected_rows_changed.disconnect(on_selection_changed);
+ } else {
+ this.selected_rows_changed.connect(on_selection_changed);
+ }
+ }
+
private void schedule_visible_conversations_changed() {
this.update_visible_scheduled = Geary.Scheduler.on_idle(
() => {
@@ -98,12 +121,6 @@ public class ConversationList : Gtk.ListBox {
});
}
- private Gee.Set<Geary.App.Conversation> get_visible_conversations() {
- Gee.HashSet<Geary.App.Conversation> visible = new Gee.HashSet<Geary.App.Conversation>();
- // XXX
- return visible;
- }
-
private void update_visible_conversations() {
Gee.Set<Geary.App.Conversation> visible_now = get_visible_conversations();
if (this.visible_conversations == null ||
@@ -119,6 +136,10 @@ public class ConversationList : Gtk.ListBox {
get_adjustment().value_changed.connect(on_adjustment_value_changed);
}
+ private void on_selection_changed() {
+ this.conversation_selection_changed(get_selected_conversations());
+ }
+
private void on_adjustment_value_changed() {
Gtk.Adjustment? adjustment = get_adjustment();
if (this.enable_load_more && adjustment != null) {
diff --git a/src/client/conversation-viewer/conversation-viewer.vala
b/src/client/conversation-viewer/conversation-viewer.vala
index 387197b..e0a4215 100644
--- a/src/client/conversation-viewer/conversation-viewer.vala
+++ b/src/client/conversation-viewer/conversation-viewer.vala
@@ -111,16 +111,16 @@ public class ConversationViewer : Gtk.Stack {
// XXX move the ConversationListView management code into
// GearyController or somewhere more appropriate
- ConversationListView conversation_list_view =
- ((MainWindow) GearyApplication.instance.controller.main_window).conversation_list_view;
- Gee.Set<Geary.App.Conversation>? prev_selection =
conversation_list_view.get_selected_conversations();
- conversation_list_view.get_selection().unselect_all();
+ ConversationList conversation_list =
+ ((MainWindow) GearyApplication.instance.controller.main_window).conversation_list;
+ Gee.Set<Geary.App.Conversation>? prev_selection = conversation_list.get_selected_conversations();
+ conversation_list.unselect_all();
box.vanished.connect((box) => {
set_visible_child(this.conversation_page);
if (prev_selection.is_empty) {
- conversation_list_view.conversations_selected(prev_selection);
+ conversation_list.conversation_selection_changed(prev_selection);
} else {
- conversation_list_view.select_conversations(prev_selection);
+ conversation_list.select_conversations(prev_selection);
}
});
this.composer_page.add(box);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]