Fix MUC join w/o bookmark, with psw; change some event listeners key_press->key_release
fixes #3
This commit is contained in:
parent
811e252de1
commit
b1e6e51c4f
|
@ -26,9 +26,9 @@ public class MucManager : StreamInteractionModule, Object {
|
|||
MessageManager.get_instance(stream_interactor).pre_message_received.connect(on_pre_message_received);
|
||||
}
|
||||
|
||||
public void join(Account account, Jid jid, string nick) {
|
||||
public void join(Account account, Jid jid, string nick, string? password = null) {
|
||||
Core.XmppStream stream = stream_interactor.get_stream(account);
|
||||
if (stream != null) Xep.Muc.Module.get_module(stream).enter(stream, jid.bare_jid.to_string(), nick, null, new MucEnterListenerImpl(this, jid, nick, account));
|
||||
if (stream != null) Xep.Muc.Module.get_module(stream).enter(stream, jid.bare_jid.to_string(), nick, password, new MucEnterListenerImpl(this, jid, nick, account));
|
||||
}
|
||||
|
||||
public void part(Account account, Jid jid) {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
@ -116,12 +117,12 @@ protected class ConferenceDetailsFragment : Box {
|
|||
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; });
|
||||
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");
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ public class Dino.Ui.ConversationListTitlebar : Gtk.HeaderBar {
|
|||
SimpleAction contacts_action = new SimpleAction("add_chat", null);
|
||||
contacts_action.activate.connect(() => {
|
||||
AddConversation.Chat.Dialog add_chat_dialog = new AddConversation.Chat.Dialog(stream_interactor);
|
||||
add_chat_dialog.set_transient_for((ApplicationWindow) get_toplevel());
|
||||
add_chat_dialog.set_transient_for((Window) get_toplevel());
|
||||
add_chat_dialog.conversation_opened.connect((conversation) => conversation_opened(conversation));
|
||||
add_chat_dialog.show();
|
||||
});
|
||||
|
@ -33,7 +33,7 @@ public class Dino.Ui.ConversationListTitlebar : Gtk.HeaderBar {
|
|||
SimpleAction conference_action = new SimpleAction("add_conference", null);
|
||||
conference_action.activate.connect(() => {
|
||||
AddConversation.Conference.Dialog add_conference_dialog = new AddConversation.Conference.Dialog(stream_interactor);
|
||||
add_conference_dialog.set_transient_for((ApplicationWindow) get_toplevel());
|
||||
add_conference_dialog.set_transient_for((Window) get_toplevel());
|
||||
add_conference_dialog.conversation_opened.connect((conversation) => conversation_opened(conversation));
|
||||
add_conference_dialog.show();
|
||||
});
|
||||
|
|
|
@ -22,7 +22,7 @@ public class View : Grid {
|
|||
public View(StreamInteractor stream_interactor) {
|
||||
conversation_list = new List(stream_interactor);
|
||||
scrolled.add(conversation_list);
|
||||
search_entry.key_press_event.connect(search_key_press_event);
|
||||
search_entry.key_release_event.connect(search_key_release_event);
|
||||
search_entry.search_changed.connect(search_changed);
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,7 @@ public class View : Grid {
|
|||
refilter();
|
||||
}
|
||||
|
||||
private bool search_key_press_event(EventKey event) {
|
||||
private bool search_key_release_event(EventKey event) {
|
||||
conversation_list.select_row(conversation_list.get_row_at_y(0));
|
||||
if (event.keyval == Key.Down) {
|
||||
ConversationRow? row = (ConversationRow) conversation_list.get_row_at_index(0);
|
||||
|
|
|
@ -69,8 +69,8 @@ public class Dialog : Gtk.Window {
|
|||
add_button.clicked.connect(add_button_clicked);
|
||||
no_accounts_add.clicked.connect(add_button_clicked);
|
||||
remove_button.clicked.connect(remove_button_clicked);
|
||||
password_entry.key_press_event.connect(on_password_entry_key_press_event);
|
||||
alias_entry.key_press_event.connect(on_alias_entry_key_press_event);
|
||||
password_entry.key_release_event.connect(on_password_key_release_event);
|
||||
alias_entry.key_release_event.connect(on_alias_key_release_event);
|
||||
image_button.clicked.connect(on_image_button_clicked);
|
||||
|
||||
main_stack.set_visible_child_name("no_accounts");
|
||||
|
@ -188,23 +188,23 @@ public class Dialog : Gtk.Window {
|
|||
return false;
|
||||
}
|
||||
|
||||
private bool on_password_entry_key_press_event(EventKey event) {
|
||||
private bool on_password_key_release_event(EventKey event) {
|
||||
Account account = (account_list.get_selected_row() as AccountRow).account;
|
||||
if (event.keyval == Key.Return) {
|
||||
account.password = password_entry.text;
|
||||
string filler = "";
|
||||
for (int i = 0; i < account.password.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 bool on_alias_entry_key_press_event(EventKey event) {
|
||||
private bool on_alias_key_release_event(EventKey event) {
|
||||
Account account = (account_list.get_selected_row() as AccountRow).account;
|
||||
if (event.keyval == Key.Return) {
|
||||
account.alias = alias_entry.text;
|
||||
alias_label.label = alias_entry.text;
|
||||
if (event.keyval == Key.Return) {
|
||||
alias_stack.set_visible_child_name("label");
|
||||
}
|
||||
return false;
|
||||
|
|
Loading…
Reference in a new issue