From fefa28c4ef90eadb473d787a9c24d7ed890dbc4d Mon Sep 17 00:00:00 2001 From: bobufa Date: Mon, 26 Mar 2018 20:23:04 +0000 Subject: [PATCH] Prefill nick with local alias when joining a non-bookmarked MUC fixes #223 --- .../add_conference_dialog.vala | 1 - .../conference_details_fragment.vala | 31 +++++++++---------- main/src/ui/application.vala | 1 - 3 files changed, 15 insertions(+), 18 deletions(-) diff --git a/main/src/ui/add_conversation/add_conference_dialog.vala b/main/src/ui/add_conversation/add_conference_dialog.vala index f6597505..5c5b458c 100644 --- a/main/src/ui/add_conversation/add_conference_dialog.vala +++ b/main/src/ui/add_conversation/add_conference_dialog.vala @@ -130,7 +130,6 @@ public class AddConferenceDialog : Gtk.Dialog { } else if (row != null) { details_fragment.account = row.account; details_fragment.jid = row.jid.to_string(); - details_fragment.set_editable(); } show_conference_details_view(); } diff --git a/main/src/ui/add_conversation/conference_details_fragment.vala b/main/src/ui/add_conversation/conference_details_fragment.vala index 964bb059..945f743a 100644 --- a/main/src/ui/add_conversation/conference_details_fragment.vala +++ b/main/src/ui/add_conversation/conference_details_fragment.vala @@ -23,6 +23,10 @@ protected class ConferenceDetailsFragment : Box { set { accounts_label.label = value.bare_jid.to_string(); account_combobox.selected = value; + if (nick == null && value.alias != null) { + nick = value.alias; + } + accounts_stack.set_visible_child_name("label"); } } public string jid { @@ -30,6 +34,7 @@ protected class ConferenceDetailsFragment : Box { set { jid_label.label = value; jid_entry.text = value; + jid_stack.set_visible_child_name("label"); } } public string? nick { @@ -37,6 +42,7 @@ protected class ConferenceDetailsFragment : Box { set { nick_label.label = value ?? ""; nick_entry.text = value ?? ""; + nick_stack.set_visible_child_name("label"); } } public string? password { @@ -44,6 +50,7 @@ protected class ConferenceDetailsFragment : Box { set { password_label.label = value; password_entry.text = value; + nick_stack.set_visible_child_name("label"); } } @@ -81,11 +88,6 @@ protected class ConferenceDetailsFragment : Box { account_combobox.initialize(stream_interactor); - accounts_stack.set_visible_child_name("label"); - jid_stack.set_visible_child_name("label"); - nick_stack.set_visible_child_name("label"); - password_stack.set_visible_child_name("label"); - accounts_button.clicked.connect(() => { set_active_stack(accounts_stack); }); jid_button.clicked.connect(() => { set_active_stack(jid_stack); }); nick_button.clicked.connect(() => { set_active_stack(nick_stack); }); @@ -106,18 +108,8 @@ protected class ConferenceDetailsFragment : Box { ok_button.label = _("Joining…"); ok_button.sensitive = false; }); - } - public void set_editable() { - nick_stack.set_visible_child_name("entry"); - password_stack.set_visible_child_name("entry"); - } - - public void reset_editable() { - jid_stack.set_visible_child_name("label"); - accounts_stack.set_visible_child_name("label"); - nick_stack.set_visible_child_name("label"); - password_stack.set_visible_child_name("label"); + clear(); } public void clear() { @@ -130,6 +122,13 @@ protected class ConferenceDetailsFragment : Box { reset_editable(); } + public void reset_editable() { + jid_stack.set_visible_child_name("entry"); + accounts_stack.set_visible_child_name("entry"); + nick_stack.set_visible_child_name("entry"); + password_stack.set_visible_child_name("entry"); + } + private void on_enter_error(Account account, Jid jid, Xmpp.Xep.Muc.MucEnterError error) { ok_button.label = _("Join"); ok_button.sensitive = true; diff --git a/main/src/ui/application.vala b/main/src/ui/application.vala index 81cb184a..22d6d93d 100644 --- a/main/src/ui/application.vala +++ b/main/src/ui/application.vala @@ -47,7 +47,6 @@ public class Dino.Ui.Application : Gtk.Application, Dino.Application { ok_button.get_style_context().add_class("suggested-action"); ConferenceDetailsFragment conference_fragment = new ConferenceDetailsFragment(stream_interactor, ok_button); conference_fragment.jid = jid; - conference_fragment.set_editable(); Box content_area = dialog.get_content_area(); content_area.add(conference_fragment); dialog.response.connect((response_id) => {