From b1e6e51c4f79f57f0a01b183ef185408fb22cc36 Mon Sep 17 00:00:00 2001 From: fiaxh Date: Thu, 9 Mar 2017 14:27:39 +0100 Subject: Fix MUC join w/o bookmark, with psw; change some event listeners key_press->key_release fixes #3 --- .../conference/add_groupchat_dialog.vala | 6 +-- .../conference/conference_details_fragment.vala | 45 +++++++++++++++++----- .../src/ui/add_conversation/conference/dialog.vala | 21 +++++----- 3 files changed, 50 insertions(+), 22 deletions(-) (limited to 'client/src/ui/add_conversation') diff --git a/client/src/ui/add_conversation/conference/add_groupchat_dialog.vala b/client/src/ui/add_conversation/conference/add_groupchat_dialog.vala index aa86958d..05589fe1 100644 --- a/client/src/ui/add_conversation/conference/add_groupchat_dialog.vala +++ b/client/src/ui/add_conversation/conference/add_groupchat_dialog.vala @@ -52,8 +52,8 @@ protected class AddGroupchatDialog : Gtk.Dialog { cancel_button.clicked.connect(() => { close(); }); ok_button.clicked.connect(on_ok_button_clicked); - jid_entry.key_press_event.connect_after(after_jid_entry_key_press); - nick_entry.key_press_event.connect(check_ok); + jid_entry.key_release_event.connect(on_jid_key_release); + nick_entry.key_release_event.connect(check_ok); } public AddGroupchatDialog.for_conference(StreamInteractor stream_interactor, Account account, Xmpp.Xep.Bookmarks.Conference conference) { @@ -69,7 +69,7 @@ protected class AddGroupchatDialog : Gtk.Dialog { alias_entry.text = conference.name; } - private bool after_jid_entry_key_press() { + private bool on_jid_key_release() { check_ok(); if (!alias_entry_changed) { Jid? parsed_jid = Jid.parse(jid_entry.text); diff --git a/client/src/ui/add_conversation/conference/conference_details_fragment.vala b/client/src/ui/add_conversation/conference/conference_details_fragment.vala index edfeab9d..324c133d 100644 --- a/client/src/ui/add_conversation/conference/conference_details_fragment.vala +++ b/client/src/ui/add_conversation/conference/conference_details_fragment.vala @@ -1,3 +1,4 @@ +using Gdk; using Gtk; using Dino.Entities; @@ -31,21 +32,21 @@ protected class ConferenceDetailsFragment : Box { } } public string jid { - get { return jid_label.label; } + get { return jid_entry.text; } set { jid_label.label = value; jid_entry.text = value; } } public string nick { - get { return nick_label.label; } + get { return nick_entry.text; } set { nick_label.label = value; nick_entry.text = value; } } public string password { - get { return password_label.label; } + get { return password_entry.text == "" ? null : password_entry.text; } set { password_label.label = value; password_entry.text = value; @@ -115,13 +116,13 @@ protected class ConferenceDetailsFragment : Box { nick_button.clicked.connect(() => { set_active_stack(nick_stack); }); password_button.clicked.connect(() => { set_active_stack(password_stack); }); - accounts_comboboxtext.changed.connect(() => { accounts_label.label = accounts_comboboxtext.get_active_text(); }); - jid_entry.key_press_event.connect(() => { jid_label.label = jid_entry.text; return false; }); - nick_entry.key_press_event.connect(() => { nick_label.label = nick_entry.text; return false; }); - password_entry.key_press_event.connect(() => { password_label.label = password_entry.text; return false; }); + accounts_comboboxtext.changed.connect(() => {accounts_label.label = accounts_comboboxtext.get_active_text(); }); + jid_entry.key_release_event.connect(on_jid_key_release_event); + nick_entry.key_release_event.connect(on_nick_key_release_event); + password_entry.key_release_event.connect(on_password_key_release_event); - jid_entry.key_press_event.connect(() => { done = true; return false; }); // just for notifying - nick_entry.key_press_event.connect(() => { done = true; return false; }); + jid_entry.key_release_event.connect(() => { done = true; return false; }); // just for notifying + nick_entry.key_release_event.connect(() => { done = true; return false; }); foreach (Account account in stream_interactor.get_accounts()) { accounts_comboboxtext.append_text(account.bare_jid.to_string()); @@ -129,12 +130,38 @@ protected class ConferenceDetailsFragment : Box { accounts_comboboxtext.set_active(0); } + public void set_editable() { + accounts_stack.set_visible_child_name("entry"); + nick_stack.set_visible_child_name("entry"); + password_stack.set_visible_child_name("entry"); + } + public void clear() { jid = ""; nick = ""; password = ""; } + private bool on_jid_key_release_event(EventKey event) { + jid_label.label = jid_entry.text; + if (event.keyval == Key.Return) jid_stack.set_visible_child_name("label"); + return false; + } + + private bool on_nick_key_release_event(EventKey event) { + nick_label.label = nick_entry.text; + if (event.keyval == Key.Return) nick_stack.set_visible_child_name("label"); + return false; + } + + private bool on_password_key_release_event(EventKey event) { + string filler = ""; + for (int i = 0; i < password_entry.text.length; i++) filler += password_entry.get_invisible_char().to_string(); + password_label.label = filler; + if (event.keyval == Key.Return) password_stack.set_visible_child_name("label"); + return false; + } + private void set_active_stack(Stack stack) { stack.set_visible_child_name("entry"); if (stack != accounts_stack) accounts_stack.set_visible_child_name("label"); diff --git a/client/src/ui/add_conversation/conference/dialog.vala b/client/src/ui/add_conversation/conference/dialog.vala index 8bf29bb4..ff548699 100644 --- a/client/src/ui/add_conversation/conference/dialog.vala +++ b/client/src/ui/add_conversation/conference/dialog.vala @@ -59,7 +59,7 @@ public class Dialog : Gtk.Dialog { cancel_button.clicked.connect(show_jid_add_view); ok_button.label = "Join"; ok_button.sensitive = details_fragment.done; - ok_button.clicked.disconnect(show_conference_details_view); + ok_button.clicked.disconnect(on_next_button_clicked); ok_button.clicked.connect(on_ok_button_clicked); select_fragment.notify["done"].disconnect(set_ok_sensitive_from_select); details_fragment.notify["done"].connect(set_ok_sensitive_from_details); @@ -131,12 +131,13 @@ public class Dialog : Gtk.Dialog { ok_button.grab_focus(); } else if (row != null) { details_fragment.jid = row.jid.to_string(); + details_fragment.set_editable(); } show_conference_details_view(); } private void on_ok_button_clicked() { - MucManager.get_instance(stream_interactor).join(details_fragment.account, new Jid(details_fragment.jid), details_fragment.nick); + MucManager.get_instance(stream_interactor).join(details_fragment.account, new Jid(details_fragment.jid), details_fragment.nick, details_fragment.password); close(); } @@ -151,14 +152,14 @@ public class Dialog : Gtk.Dialog { int difference = def_height - curr_height; Timer timer = new Timer(); Timeout.add((int) (stack.transition_duration / 30), - () => { - ulong microsec; - timer.elapsed(out microsec); - ulong millisec = microsec / 1000; - double partial = double.min(1, (double) millisec / stack.transition_duration); - resize(curr_width, (int) (curr_height + difference * partial)); - return millisec < stack.transition_duration; - }); + () => { + ulong microsec; + timer.elapsed(out microsec); + ulong millisec = microsec / 1000; + double partial = double.min(1, (double) millisec / stack.transition_duration); + resize(curr_width, (int) (curr_height + difference * partial)); + return millisec < stack.transition_duration; + }); } } -- cgit v1.2.3-70-g09d2