From 492baaf0845fee2495b9d181cd9fd50403eb61f8 Mon Sep 17 00:00:00 2001 From: fiaxh Date: Wed, 22 Mar 2017 23:55:19 +0100 Subject: Add back on subscription request --- .../conference/add_groupchat_dialog.vala | 17 +++--------- .../conference/conference_details_fragment.vala | 30 ++++++++++------------ .../src/ui/add_conversation/conference/dialog.vala | 6 +++-- 3 files changed, 21 insertions(+), 32 deletions(-) (limited to 'main/src/ui/add_conversation/conference') diff --git a/main/src/ui/add_conversation/conference/add_groupchat_dialog.vala b/main/src/ui/add_conversation/conference/add_groupchat_dialog.vala index c097ef06..96d44000 100644 --- a/main/src/ui/add_conversation/conference/add_groupchat_dialog.vala +++ b/main/src/ui/add_conversation/conference/add_groupchat_dialog.vala @@ -9,7 +9,7 @@ namespace Dino.Ui.AddConversation.Conference { protected class AddGroupchatDialog : Gtk.Dialog { [GtkChild] private Stack accounts_stack; - [GtkChild] private ComboBoxText accounts_comboboxtext; + [GtkChild] private AccountComboBox account_combobox; [GtkChild] private Label account_label; [GtkChild] private Button ok_button; [GtkChild] private Button cancel_button; @@ -28,10 +28,7 @@ protected class AddGroupchatDialog : Gtk.Dialog { ok_button.label = "Add"; ok_button.get_style_context().add_class("suggested-action"); // TODO why doesn't it work in XML accounts_stack.set_visible_child_name("combobox"); - 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); @@ -69,20 +66,14 @@ protected class AddGroupchatDialog : Gtk.Dialog { } private void on_ok_button_clicked() { - Account? account = null; - foreach (Account account2 in stream_interactor.get_accounts()) { - if (accounts_comboboxtext.get_active_text() == account2.bare_jid.to_string()) { - account = account2; - } - } Xmpp.Xep.Bookmarks.Conference conference = new Xmpp.Xep.Bookmarks.Conference(jid_entry.text); conference.nick = nick_entry.text; conference.name = alias_entry.text; conference.autojoin = autojoin_checkbutton.active; if (edit_confrence == null) { - stream_interactor.get_module(MucManager.IDENTITY).add_bookmark(account, conference); + stream_interactor.get_module(MucManager.IDENTITY).add_bookmark(account_combobox.selected, conference); } else { - stream_interactor.get_module(MucManager.IDENTITY).replace_bookmark(account, edit_confrence, conference); + stream_interactor.get_module(MucManager.IDENTITY).replace_bookmark(account_combobox.selected, edit_confrence, conference); } close(); } diff --git a/main/src/ui/add_conversation/conference/conference_details_fragment.vala b/main/src/ui/add_conversation/conference/conference_details_fragment.vala index d42c79bd..fe57e6da 100644 --- a/main/src/ui/add_conversation/conference/conference_details_fragment.vala +++ b/main/src/ui/add_conversation/conference/conference_details_fragment.vala @@ -18,17 +18,10 @@ protected class ConferenceDetailsFragment : Box { } public Account account { - owned get { - foreach (Account account in stream_interactor.get_accounts()) { - if (accounts_comboboxtext.get_active_text() == account.bare_jid.to_string()) { - return account; - } - } - return null; - } + owned get { return account_combobox.selected; } set { accounts_label.label = value.bare_jid.to_string(); - accounts_comboboxtext.set_active_id(value.bare_jid.to_string()); + account_combobox.selected = value; } } public string jid { @@ -56,7 +49,7 @@ protected class ConferenceDetailsFragment : Box { [GtkChild] private Stack accounts_stack; [GtkChild] private Button accounts_button; [GtkChild] private Label accounts_label; - [GtkChild] private ComboBoxText accounts_comboboxtext; + [GtkChild] private AccountComboBox account_combobox; [GtkChild] private Stack jid_stack; [GtkChild] private Button jid_button; @@ -77,6 +70,7 @@ protected class ConferenceDetailsFragment : Box { public ConferenceDetailsFragment(StreamInteractor stream_interactor) { this.stream_interactor = stream_interactor; + account_combobox.initialize(stream_interactor); accounts_stack.set_visible_child_name("label"); jid_stack.set_visible_child_name("label"); @@ -88,30 +82,32 @@ 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(); }); + account_combobox.changed.connect(() => { accounts_label.label = account_combobox.selected.bare_jid.to_string(); }); 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_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()); - } - 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 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"); + } + public void clear() { jid = ""; nick = ""; password = ""; + reset_editable(); } private bool on_jid_key_release_event(EventKey event) { diff --git a/main/src/ui/add_conversation/conference/dialog.vala b/main/src/ui/add_conversation/conference/dialog.vala index bfb25888..d766a5a8 100644 --- a/main/src/ui/add_conversation/conference/dialog.vala +++ b/main/src/ui/add_conversation/conference/dialog.vala @@ -38,7 +38,7 @@ public class Dialog : Gtk.Dialog { } private void show_jid_add_view() { - cancel_button.remove(cancel_image); + if (cancel_image.get_parent() != null) cancel_button.remove(cancel_image); cancel_button.add(cancel_label); cancel_button.clicked.disconnect(show_jid_add_view); cancel_button.clicked.connect(close); @@ -53,7 +53,7 @@ public class Dialog : Gtk.Dialog { } private void show_conference_details_view() { - cancel_button.remove(cancel_label); + if (cancel_label.get_parent() != null) cancel_button.remove(cancel_label); cancel_button.add(cancel_image); cancel_button.clicked.disconnect(close); cancel_button.clicked.connect(show_jid_add_view); @@ -125,11 +125,13 @@ public class Dialog : Gtk.Dialog { ListRow? row = conference_list.get_selected_row() as ListRow; ConferenceListRow? conference_row = conference_list.get_selected_row() as ConferenceListRow; if (conference_row != null) { + details_fragment.account = conference_row.account; details_fragment.jid = conference_row.bookmark.jid; details_fragment.nick = conference_row.bookmark.nick; if (conference_row.bookmark.password != null) details_fragment.password = conference_row.bookmark.password; ok_button.grab_focus(); } else if (row != null) { + details_fragment.account = row.account; details_fragment.jid = row.jid.to_string(); details_fragment.set_editable(); } -- cgit v1.2.3-70-g09d2