aboutsummaryrefslogtreecommitdiff
path: root/main/src/ui/add_conversation/chat
diff options
context:
space:
mode:
authorfiaxh <git@mx.ax.lt>2017-03-22 23:55:19 +0100
committerfiaxh <git@mx.ax.lt>2017-03-23 15:43:20 +0100
commit492baaf0845fee2495b9d181cd9fd50403eb61f8 (patch)
tree2d40fdcc5b86dfc1429fb660b2cfbc65b8a8f96b /main/src/ui/add_conversation/chat
parentfa78573b052693b29350bdd0f7eaf74dc6571e4a (diff)
downloaddino-492baaf0845fee2495b9d181cd9fd50403eb61f8.tar.gz
dino-492baaf0845fee2495b9d181cd9fd50403eb61f8.zip
Add back on subscription request
Diffstat (limited to 'main/src/ui/add_conversation/chat')
-rw-r--r--main/src/ui/add_conversation/chat/add_contact_dialog.vala30
1 files changed, 16 insertions, 14 deletions
diff --git a/main/src/ui/add_conversation/chat/add_contact_dialog.vala b/main/src/ui/add_conversation/chat/add_contact_dialog.vala
index 88bfe2be..f07f9659 100644
--- a/main/src/ui/add_conversation/chat/add_contact_dialog.vala
+++ b/main/src/ui/add_conversation/chat/add_contact_dialog.vala
@@ -8,7 +8,17 @@ namespace Dino.Ui.AddConversation.Chat {
[GtkTemplate (ui = "/org/dino-im/add_conversation/add_contact_dialog.ui")]
protected class AddContactDialog : Gtk.Dialog {
- [GtkChild] private ComboBoxText accounts_comboboxtext;
+ public Account? account {
+ get { return account_combobox.selected; }
+ set { account_combobox.selected = value; }
+ }
+
+ public string jid {
+ get { return jid_entry.text; }
+ set { jid_entry.text = value; }
+ }
+
+ [GtkChild] private AccountComboBox account_combobox;
[GtkChild] private Button ok_button;
[GtkChild] private Button cancel_button;
[GtkChild] private Entry jid_entry;
@@ -20,11 +30,7 @@ protected class AddContactDialog : Gtk.Dialog {
public AddContactDialog(StreamInteractor stream_interactor) {
Object(use_header_bar : 1);
this.stream_interactor = stream_interactor;
-
- foreach (Account account in stream_interactor.get_accounts()) {
- accounts_comboboxtext.append_text(account.bare_jid.to_string());
- }
- accounts_comboboxtext.set_active(0);
+ account_combobox.initialize(stream_interactor);
cancel_button.clicked.connect(() => { close(); });
ok_button.clicked.connect(on_ok_button_clicked);
@@ -33,14 +39,7 @@ protected class AddContactDialog : Gtk.Dialog {
private void on_ok_button_clicked() {
string? alias = alias_entry.text == "" ? null : alias_entry.text;
- Account? account = null;
Jid jid = new Jid(jid_entry.text);
- foreach (Account account2 in stream_interactor.get_accounts()) {
- print(account2.bare_jid.to_string() + "\n");
- if (accounts_comboboxtext.get_active_text() == account2.bare_jid.to_string()) {
- account = account2;
- }
- }
stream_interactor.get_module(RosterManager.IDENTITY).add_jid(account, jid, alias);
if (subscribe_checkbutton.active) {
stream_interactor.get_module(PresenceManager.IDENTITY).request_subscription(account, jid);
@@ -50,7 +49,10 @@ protected class AddContactDialog : Gtk.Dialog {
private void on_jid_entry_changed() {
Jid parsed_jid = Jid.parse(jid_entry.text);
- ok_button.set_sensitive(parsed_jid != null && parsed_jid.resourcepart == null);
+ bool sensitive = parsed_jid != null && parsed_jid.resourcepart == null &&
+ stream_interactor.get_module(RosterManager.IDENTITY).get_roster_item(account, parsed_jid) == null;
+ ok_button.set_sensitive(sensitive);
}
}
+
} \ No newline at end of file