[geary/wip/730682-refine-convo-list: 12/12] Very incomplete visible conversations implementation.



commit ff21b9feaee04aaf5fd7f9275338661bb3781e95
Author: Michael James Gratton <mike vee net>
Date:   Sun Oct 15 21:15:41 2017 +1030

    Very incomplete visible conversations implementation.

 src/client/application/geary-controller.vala       |   10 +-----
 src/client/components/main-window.vala             |    5 +++
 .../conversation-list/conversation-list.vala       |   32 ++++++++++++++++++++
 3 files changed, 39 insertions(+), 8 deletions(-)
---
diff --git a/src/client/application/geary-controller.vala b/src/client/application/geary-controller.vala
index 2423abe..8d46078 100644
--- a/src/client/application/geary-controller.vala
+++ b/src/client/application/geary-controller.vala
@@ -227,7 +227,6 @@ public class GearyController : Geary.BaseObject {
         
         // Connect to various UI signals.
         main_window.conversation_list_view.mark_conversations.connect(on_mark_conversations);
-        
main_window.conversation_list_view.visible_conversations_changed.connect(on_visible_conversations_changed);
         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);
@@ -298,7 +297,6 @@ public class GearyController : Geary.BaseObject {
 
         // Disconnect from various UI signals.
         main_window.conversation_list_view.mark_conversations.disconnect(on_mark_conversations);
-        
main_window.conversation_list_view.visible_conversations_changed.disconnect(on_visible_conversations_changed);
         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);
@@ -1740,11 +1738,7 @@ public class GearyController : Geary.BaseObject {
             actions.get_action(ACTION_MARK_AS_SPAM).label = MARK_AS_SPAM_LABEL;
         }
     }
-    
-    private void on_visible_conversations_changed(Gee.Set<Geary.App.Conversation> visible) {
-        clear_new_messages("on_visible_conversations_changed", visible);
-    }
-    
+
     private bool should_notify_new_messages(Geary.Folder folder) {
         // A monitored folder must be selected to squelch notifications;
         // if conversation list is at top of display, don't display
@@ -1756,7 +1750,7 @@ public class GearyController : Geary.BaseObject {
     
     // 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
-    private void clear_new_messages(string caller, Gee.Set<Geary.App.Conversation>? supplied) {
+    internal void clear_new_messages(string caller, Gee.Set<Geary.App.Conversation>? supplied) {
         if (current_folder == null || !new_messages_monitor.get_folders().contains(current_folder)
             || should_notify_new_messages(current_folder))
             return;
diff --git a/src/client/components/main-window.vala b/src/client/components/main-window.vala
index 2ffcef1..15f7b80 100644
--- a/src/client/components/main-window.vala
+++ b/src/client/components/main-window.vala
@@ -65,6 +65,7 @@ public class MainWindow : Gtk.ApplicationWindow {
         this.conversation_list = new ConversationList(application.config);
         this.conversation_list.conversation_selection_changed.connect(on_conversation_selection_changed);
         this.conversation_list.conversation_activated.connect(on_conversation_activated);
+        this.conversation_list.visible_conversations_changed.connect(on_visible_conversations_changed);
 
         this.conversation_list.load_more.connect(on_load_more);
         load_config(application.config);
@@ -537,6 +538,10 @@ public class MainWindow : Gtk.ApplicationWindow {
         }
     }
 
+    void on_visible_conversations_changed(Gee.Set<Geary.App.Conversation> visible) {
+        this.application.controller.clear_new_messages("on_visible_conversations_changed", visible);
+    }
+
     [GtkCallback]
     private bool on_key_release_event(Gdk.EventKey event) {
         check_shift_event(event);
diff --git a/src/client/conversation-list/conversation-list.vala 
b/src/client/conversation-list/conversation-list.vala
index a5bb3bc..9dbb608 100644
--- a/src/client/conversation-list/conversation-list.vala
+++ b/src/client/conversation-list/conversation-list.vala
@@ -14,11 +14,14 @@ public class ConversationList : Gtk.ListBox {
 
     private const string CLASS = "geary-conversation-list";
 
+
     /** Underlying model for this list */
     public ConversationListModel? model { get; private set; default=null; }
 
     private Configuration config;
 
+    private Gee.Set<Geary.App.Conversation>? visible_conversations = null;
+    private Geary.Scheduler.Scheduled? update_visible_scheduled = null;
     private bool enable_load_more = true;
     private bool reset_adjustment = false;
     private double adj_last_upper = -1.0;
@@ -30,6 +33,9 @@ public class ConversationList : Gtk.ListBox {
     /** Fired when a user activates a row in the list. */
     public signal void conversation_activated(Geary.App.Conversation activated);
 
+    /** Fired the visible conversations in the widget change. */
+    public signal void visible_conversations_changed(Gee.Set<Geary.App.Conversation> visible);
+
     /** Fired when additional conversations are required. */
     public virtual signal void load_more() {
         this.enable_load_more = false;
@@ -84,6 +90,30 @@ public class ConversationList : Gtk.ListBox {
         );
     }
 
+    private void schedule_visible_conversations_changed() {
+        this.update_visible_scheduled = Geary.Scheduler.on_idle(
+            () => {
+                update_visible_conversations();
+                return Source.REMOVE; // one-shot
+            });
+    }
+
+    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 ||
+            Geary.Collection.are_sets_equal<Geary.App.Conversation>(
+                this.visible_conversations, visible_now)) {
+            this.visible_conversations = visible_now;
+            this.visible_conversations_changed(visible_now.read_only_view);
+        }
+    }
+
     private void on_show() {
         // Wait until we're visible to set this signal up.
         get_adjustment().value_changed.connect(on_adjustment_value_changed);
@@ -101,6 +131,8 @@ public class ConversationList : Gtk.ListBox {
                 load_more();
                 this.adj_last_upper = upper;
             }
+
+            schedule_visible_conversations_changed();
         }
     }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]