From df3716622a37cded9e3754da77497ca6d2f2baeb Mon Sep 17 00:00:00 2001 From: fiaxh Date: Mon, 30 Sep 2019 02:11:23 +0200 Subject: Rework no-open-conversation placeholder --- main/src/ui/unified_window_controller.vala | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'main/src/ui/unified_window_controller.vala') diff --git a/main/src/ui/unified_window_controller.vala b/main/src/ui/unified_window_controller.vala index 2fd8eb0d..6ac941cc 100644 --- a/main/src/ui/unified_window_controller.vala +++ b/main/src/ui/unified_window_controller.vala @@ -43,6 +43,8 @@ public class UnifiedWindowController : Object { update_conversation_topic(subject); } }); + stream_interactor.get_module(ConversationManager.IDENTITY).conversation_deactivated.connect(check_unset_conversation); + stream_interactor.account_removed.connect(check_unset_conversation); app.plugin_registry.register_contact_titlebar_entry(new MenuEntry(stream_interactor)); app.plugin_registry.register_contact_titlebar_entry(search_menu_entry); @@ -120,7 +122,7 @@ public class UnifiedWindowController : Object { restore_window_size(); } - public void select_conversation(Conversation conversation, bool do_reset_search = true, bool default_initialize_conversation = true) { + public void select_conversation(Conversation? conversation, bool do_reset_search = true, bool default_initialize_conversation = true) { this.conversation = conversation; update_conversation_display_name(); @@ -147,6 +149,26 @@ public class UnifiedWindowController : Object { } } + private void check_unset_conversation() { + if (stream_interactor.get_module(ConversationManager.IDENTITY).get_active_conversations().size == 0) { + unset_conversation(); + } + } + + private void unset_conversation() { + this.conversation = null; + + conversation_display_name = null; + conversation_topic = null; + + foreach(var e in this.app.plugin_registry.conversation_titlebar_entries) { + Plugins.ConversationTitlebarWidget widget = e.get_widget(Plugins.WidgetType.GTK); + if (widget != null) { + widget.unset_conversation(); + } + } + } + private void update_conversation_display_name() { conversation_display_name = Util.get_conversation_display_name(stream_interactor, conversation); } -- cgit v1.2.3-70-g09d2