diff options
author | fiaxh <git@lightrise.org> | 2023-01-11 19:54:02 +0100 |
---|---|---|
committer | fiaxh <git@lightrise.org> | 2023-01-11 19:54:02 +0100 |
commit | 75500dc767f2cf657c0fbb5d2a4d4557183ed2e9 (patch) | |
tree | 87f67a933f0459f966932531b427944bb9f67a1f /main/src/ui/conversation_selector | |
parent | cb3b19b01deb8460627578b885339e7528411f6f (diff) | |
download | dino-75500dc767f2cf657c0fbb5d2a4d4557183ed2e9.tar.gz dino-75500dc767f2cf657c0fbb5d2a4d4557183ed2e9.zip |
Support pinning of conversations (locally)
fixes #290
fixes #1330
Diffstat (limited to 'main/src/ui/conversation_selector')
-rw-r--r-- | main/src/ui/conversation_selector/conversation_selector.vala | 8 | ||||
-rw-r--r-- | main/src/ui/conversation_selector/conversation_selector_row.vala | 13 |
2 files changed, 18 insertions, 3 deletions
diff --git a/main/src/ui/conversation_selector/conversation_selector.vala b/main/src/ui/conversation_selector/conversation_selector.vala index 609e1be1..8a4506f3 100644 --- a/main/src/ui/conversation_selector/conversation_selector.vala +++ b/main/src/ui/conversation_selector/conversation_selector.vala @@ -75,6 +75,8 @@ public class ConversationSelector : Widget { private void add_conversation(Conversation conversation) { ConversationSelectorRow row; if (!rows.has_key(conversation)) { + conversation.notify["pinned"].connect(list_box.invalidate_sort); + row = new ConversationSelectorRow(stream_interactor, conversation); rows[conversation] = row; list_box.append(row); @@ -119,6 +121,8 @@ public class ConversationSelector : Widget { private async void remove_conversation(Conversation conversation) { select_fallback_conversation(conversation); if (rows.has_key(conversation)) { + conversation.notify["pinned"].disconnect(list_box.invalidate_sort); + yield rows[conversation].colapse(); list_box.remove(rows[conversation]); rows.unset(conversation); @@ -149,6 +153,10 @@ public class ConversationSelector : Widget { if (cr1 != null && cr2 != null) { Conversation c1 = cr1.conversation; Conversation c2 = cr2.conversation; + + int pin_comp = c2.pinned - c1.pinned; + if (pin_comp != 0) return pin_comp; + if (c1.last_active == null) return -1; if (c2.last_active == null) return 1; int comp = c2.last_active.compare(c1.last_active); diff --git a/main/src/ui/conversation_selector/conversation_selector_row.vala b/main/src/ui/conversation_selector/conversation_selector_row.vala index bd2b0747..8355b104 100644 --- a/main/src/ui/conversation_selector/conversation_selector_row.vala +++ b/main/src/ui/conversation_selector/conversation_selector_row.vala @@ -21,7 +21,8 @@ public class ConversationSelectorRow : ListBoxRow { [GtkChild] protected unowned Button x_button; [GtkChild] protected unowned Revealer time_revealer; [GtkChild] protected unowned Revealer xbutton_revealer; - [GtkChild] protected unowned Revealer unread_count_revealer; + [GtkChild] protected unowned Revealer top_row_revealer; + [GtkChild] protected unowned Image pinned_image; [GtkChild] public unowned Revealer main_revealer; public Conversation conversation { get; private set; } @@ -102,8 +103,10 @@ public class ConversationSelectorRow : ListBoxRow { }); image.set_conversation(stream_interactor, conversation); conversation.notify["read-up-to-item"].connect(() => update_read()); + conversation.notify["pinned"].connect(() => { update_pinned_icon(); }); update_name_label(); + update_pinned_icon(); content_item_received(); } @@ -135,6 +138,10 @@ public class ConversationSelectorRow : ListBoxRow { name_label.label = Util.get_conversation_display_name(stream_interactor, conversation); } + private void update_pinned_icon() { + pinned_image.visible = conversation.pinned != 0; + } + protected void update_time_label(DateTime? new_time = null) { if (last_content_item != null) { time_label.visible = true; @@ -252,11 +259,11 @@ public class ConversationSelectorRow : ListBoxRow { StateFlags curr_flags = get_state_flags(); if ((curr_flags & StateFlags.PRELIGHT) != 0) { time_revealer.set_reveal_child(false); - unread_count_revealer.set_reveal_child(false); + top_row_revealer.set_reveal_child(false); xbutton_revealer.set_reveal_child(true); } else { time_revealer.set_reveal_child(true); - unread_count_revealer.set_reveal_child(true); + top_row_revealer.set_reveal_child(true); xbutton_revealer.set_reveal_child(false); } } |