diff options
author | fiaxh <git@lightrise.org> | 2019-12-21 19:19:28 +0100 |
---|---|---|
committer | fiaxh <git@lightrise.org> | 2019-12-21 19:19:28 +0100 |
commit | 9ef4dddfdc40f515be6c780bf9fa089111590a74 (patch) | |
tree | 9173e13bc471d6c15fe5a1f1948ad61b7d4b8912 /main/src | |
parent | 9565140f01cf95c42bc91aab21130bd1d06b0156 (diff) | |
download | dino-9ef4dddfdc40f515be6c780bf9fa089111590a74.tar.gz dino-9ef4dddfdc40f515be6c780bf9fa089111590a74.zip |
Fix+improve conversation selection when joining channel or starting MUC PM
Diffstat (limited to 'main/src')
-rw-r--r-- | main/src/ui/add_conversation/add_conference_dialog.vala | 2 | ||||
-rw-r--r-- | main/src/ui/add_conversation/conference_details_fragment.vala | 6 | ||||
-rw-r--r-- | main/src/ui/application.vala | 15 | ||||
-rw-r--r-- | main/src/ui/conversation_list_titlebar.vala | 2 | ||||
-rw-r--r-- | main/src/ui/conversation_list_titlebar_csd.vala | 2 | ||||
-rw-r--r-- | main/src/ui/occupant_menu/view.vala | 3 | ||||
-rw-r--r-- | main/src/ui/unified_window.vala | 8 | ||||
-rw-r--r-- | main/src/ui/unified_window_controller.vala | 2 |
8 files changed, 15 insertions, 25 deletions
diff --git a/main/src/ui/add_conversation/add_conference_dialog.vala b/main/src/ui/add_conversation/add_conference_dialog.vala index ce88faec..ecafc9cc 100644 --- a/main/src/ui/add_conversation/add_conference_dialog.vala +++ b/main/src/ui/add_conversation/add_conference_dialog.vala @@ -9,8 +9,6 @@ namespace Dino.Ui { public class AddConferenceDialog : Gtk.Dialog { - public signal void conversation_opened(Conversation conversation); - private Stack stack = new Stack(); private Button cancel_button; private Button ok_button; diff --git a/main/src/ui/add_conversation/conference_details_fragment.vala b/main/src/ui/add_conversation/conference_details_fragment.vala index d2ce75ab..38232633 100644 --- a/main/src/ui/add_conversation/conference_details_fragment.vala +++ b/main/src/ui/add_conversation/conference_details_fragment.vala @@ -146,11 +146,15 @@ protected class ConferenceDetailsFragment : Box { ok_button.label = _("Joining…"); ok_button.sensitive = false; - Muc.JoinResult? join_result = yield stream_interactor.get_module(MucManager.IDENTITY).join(account, new Jid(jid), nick, password); + Jid parsed_jid = new Jid(jid); + Muc.JoinResult? join_result = yield stream_interactor.get_module(MucManager.IDENTITY).join(account, parsed_jid, nick, password); ok_button.label = _("Join"); ok_button.sensitive = true; if (join_result == null || join_result.nick != null) { + Conversation conversation = stream_interactor.get_module(ConversationManager.IDENTITY).create_conversation(parsed_jid, account, Conversation.Type.GROUPCHAT); + Application app = GLib.Application.get_default() as Application; + app.controller.select_conversation(conversation); joined(); return; } diff --git a/main/src/ui/application.vala b/main/src/ui/application.vala index 42f4d6d5..c8db09da 100644 --- a/main/src/ui/application.vala +++ b/main/src/ui/application.vala @@ -7,7 +7,7 @@ using Xmpp; public class Dino.Ui.Application : Gtk.Application, Dino.Application { private Notifications notifications; private UnifiedWindow window; - private UnifiedWindowController controller; + public UnifiedWindowController controller; public Database db { get; set; } public Dino.Entities.Settings settings { get; set; } @@ -41,7 +41,7 @@ public class Dino.Ui.Application : Gtk.Application, Dino.Application { controller.set_window(window); if ((get_flags() & ApplicationFlags.IS_SERVICE) == ApplicationFlags.IS_SERVICE) window.delete_event.connect(window.hide_on_delete); - notifications.conversation_selected.connect((conversation) => window.on_conversation_selected(conversation)); + notifications.conversation_selected.connect((conversation) => controller.select_conversation(conversation)); } window.present(); }); @@ -57,13 +57,13 @@ public class Dino.Ui.Application : Gtk.Application, Dino.Application { if (accounts.size == 1) { Conversation conversation = stream_interactor.get_module(ConversationManager.IDENTITY).create_conversation(new Jid(jid), accounts[0], Conversation.Type.CHAT); stream_interactor.get_module(ConversationManager.IDENTITY).start_conversation(conversation); - window.on_conversation_selected(conversation); + controller.select_conversation(conversation); } else { AddChatDialog dialog = new AddChatDialog(stream_interactor, stream_interactor.get_accounts()); dialog.set_filter(jid); dialog.set_transient_for(window); dialog.added.connect((conversation) => { - window.on_conversation_selected(conversation); + controller.select_conversation(conversation); }); dialog.present(); } @@ -92,7 +92,7 @@ public class Dino.Ui.Application : Gtk.Application, Dino.Application { SimpleAction open_conversation_action = new SimpleAction("open-conversation", VariantType.INT32); open_conversation_action.activate.connect((variant) => { Conversation? conversation = stream_interactor.get_module(ConversationManager.IDENTITY).get_conversation_by_id(variant.get_int32()); - if (conversation != null) window.on_conversation_selected(conversation); + if (conversation != null) controller.select_conversation(conversation); window.present(); }); add_action(open_conversation_action); @@ -109,9 +109,7 @@ public class Dino.Ui.Application : Gtk.Application, Dino.Application { contacts_action.activate.connect(() => { AddChatDialog add_chat_dialog = new AddChatDialog(stream_interactor, stream_interactor.get_accounts()); add_chat_dialog.set_transient_for(window); - add_chat_dialog.added.connect((conversation) => { - window.on_conversation_selected(conversation); - }); + add_chat_dialog.added.connect((conversation) => controller.select_conversation(conversation)); add_chat_dialog.present(); }); add_action(contacts_action); @@ -121,7 +119,6 @@ public class Dino.Ui.Application : Gtk.Application, Dino.Application { conference_action.activate.connect(() => { AddConferenceDialog add_conference_dialog = new AddConferenceDialog(stream_interactor); add_conference_dialog.set_transient_for(window); - add_conference_dialog.conversation_opened.connect(conversation => controller.select_conversation(conversation)); add_conference_dialog.present(); }); add_action(conference_action); diff --git a/main/src/ui/conversation_list_titlebar.vala b/main/src/ui/conversation_list_titlebar.vala index abce2a6c..ee9ff6bf 100644 --- a/main/src/ui/conversation_list_titlebar.vala +++ b/main/src/ui/conversation_list_titlebar.vala @@ -7,8 +7,6 @@ namespace Dino.Ui { [GtkTemplate (ui = "/im/dino/Dino/conversation_list_titlebar.ui")] public class ConversationListTitlebar : Gtk.Box { - public signal void conversation_opened(Conversation conversation); - [GtkChild] private MenuButton add_button; [GtkChild] private MenuButton menu_button; diff --git a/main/src/ui/conversation_list_titlebar_csd.vala b/main/src/ui/conversation_list_titlebar_csd.vala index 85ff4867..33ff6d43 100644 --- a/main/src/ui/conversation_list_titlebar_csd.vala +++ b/main/src/ui/conversation_list_titlebar_csd.vala @@ -7,8 +7,6 @@ namespace Dino.Ui { [GtkTemplate (ui = "/im/dino/Dino/conversation_list_titlebar_csd.ui")] public class ConversationListTitlebarCsd : Gtk.HeaderBar { - public signal void conversation_opened(Conversation conversation); - [GtkChild] private MenuButton add_button; [GtkChild] private MenuButton menu_button; diff --git a/main/src/ui/occupant_menu/view.vala b/main/src/ui/occupant_menu/view.vala index defc2e1c..663e7505 100644 --- a/main/src/ui/occupant_menu/view.vala +++ b/main/src/ui/occupant_menu/view.vala @@ -107,6 +107,9 @@ public class View : Popover { Conversation conversation = stream_interactor.get_module(ConversationManager.IDENTITY).create_conversation(list_row.jid, list_row.conversation.account, Conversation.Type.GROUPCHAT_PM); stream_interactor.get_module(ConversationManager.IDENTITY).start_conversation(conversation); + + Application app = GLib.Application.get_default() as Application; + app.controller.select_conversation(conversation); } private void kick_button_clicked() { diff --git a/main/src/ui/unified_window.vala b/main/src/ui/unified_window.vala index 9313ee10..7cecceb5 100644 --- a/main/src/ui/unified_window.vala +++ b/main/src/ui/unified_window.vala @@ -36,7 +36,6 @@ public class UnifiedWindow : Gtk.Window { private Stack right_stack; private StreamInteractor stream_interactor; - private Conversation? conversation; private Database db; private Config config; @@ -67,13 +66,6 @@ public class UnifiedWindow : Gtk.Window { check_stack(); } - public void on_conversation_selected(Conversation conversation, bool do_reset_search = true, bool default_initialize_conversation = true) { - if (this.conversation == null || !this.conversation.equals(conversation)) { - this.conversation = conversation; - conversation_selected(conversation); - } - } - private void setup_unified() { Builder builder = new Builder.from_resource("/im/dino/Dino/unified_main_content.ui"); paned = (Paned) builder.get_object("paned"); diff --git a/main/src/ui/unified_window_controller.vala b/main/src/ui/unified_window_controller.vala index 0e37130b..9e41aff8 100644 --- a/main/src/ui/unified_window_controller.vala +++ b/main/src/ui/unified_window_controller.vala @@ -136,7 +136,7 @@ public class UnifiedWindowController : Object { stream_interactor.get_module(ChatInteraction.IDENTITY).on_conversation_selected(conversation); conversation.active = true; // only for conversation_selected - window.conversation_selector.on_conversation_selected(conversation); // only for conversation_opened + window.conversation_selector.on_conversation_selected(conversation); // In case selection was not via ConversationSelector if (do_reset_search) { reset_search_entry(); |