aboutsummaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorfiaxh <git@mx.ax.lt>2017-03-09 14:27:39 +0100
committerfiaxh <git@mx.ax.lt>2017-03-09 14:27:39 +0100
commitb1e6e51c4f79f57f0a01b183ef185408fb22cc36 (patch)
treee7b7a3a85169abbed3852b93ee6d7a90a0e17039 /client
parent811e252de19c2a8735c24b05c7ebae9328168096 (diff)
downloaddino-b1e6e51c4f79f57f0a01b183ef185408fb22cc36.tar.gz
dino-b1e6e51c4f79f57f0a01b183ef185408fb22cc36.zip
Fix MUC join w/o bookmark, with psw; change some event listeners key_press->key_release
fixes #3
Diffstat (limited to 'client')
-rw-r--r--client/src/service/muc_manager.vala4
-rw-r--r--client/src/ui/add_conversation/conference/add_groupchat_dialog.vala6
-rw-r--r--client/src/ui/add_conversation/conference/conference_details_fragment.vala45
-rw-r--r--client/src/ui/add_conversation/conference/dialog.vala21
-rw-r--r--client/src/ui/conversation_list_titlebar.vala4
-rw-r--r--client/src/ui/conversation_selector/view.vala4
-rw-r--r--client/src/ui/manage_accounts/dialog.vala20
7 files changed, 66 insertions, 38 deletions
diff --git a/client/src/service/muc_manager.vala b/client/src/service/muc_manager.vala
index ead09306..8f6339a5 100644
--- a/client/src/service/muc_manager.vala
+++ b/client/src/service/muc_manager.vala
@@ -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) {
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;
+ });
}
}
diff --git a/client/src/ui/conversation_list_titlebar.vala b/client/src/ui/conversation_list_titlebar.vala
index 4e465532..4bcc9c71 100644
--- a/client/src/ui/conversation_list_titlebar.vala
+++ b/client/src/ui/conversation_list_titlebar.vala
@@ -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();
});
diff --git a/client/src/ui/conversation_selector/view.vala b/client/src/ui/conversation_selector/view.vala
index 72e8bbec..c551d258 100644
--- a/client/src/ui/conversation_selector/view.vala
+++ b/client/src/ui/conversation_selector/view.vala
@@ -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);
diff --git a/client/src/ui/manage_accounts/dialog.vala b/client/src/ui/manage_accounts/dialog.vala
index d3695019..4f3ade45 100644
--- a/client/src/ui/manage_accounts/dialog.vala
+++ b/client/src/ui/manage_accounts/dialog.vala
@@ -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;
+ 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) {
- 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;
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;
+ account.alias = alias_entry.text;
+ alias_label.label = alias_entry.text;
if (event.keyval == Key.Return) {
- account.alias = alias_entry.text;
- alias_label.label = alias_entry.text;
alias_stack.set_visible_child_name("label");
}
return false;