aboutsummaryrefslogtreecommitdiff
path: root/main/src/ui/add_conversation/chat
diff options
context:
space:
mode:
authorfiaxh <git@mx.ax.lt>2017-06-11 13:59:24 +0200
committerfiaxh <git@mx.ax.lt>2017-06-11 13:59:24 +0200
commite63d59eb3450471b33a22efda6df8871818209b1 (patch)
tree11660e951bf049318f6c0eae8a60fcfbff4c029e /main/src/ui/add_conversation/chat
parent205bd444a5ba9d119952ecddbf815f50174da8c7 (diff)
downloaddino-e63d59eb3450471b33a22efda6df8871818209b1.tar.gz
dino-e63d59eb3450471b33a22efda6df8871818209b1.zip
Muc Invite + Kick
Diffstat (limited to 'main/src/ui/add_conversation/chat')
-rw-r--r--main/src/ui/add_conversation/chat/dialog.vala33
-rw-r--r--main/src/ui/add_conversation/chat/roster_list.vala28
2 files changed, 32 insertions, 29 deletions
diff --git a/main/src/ui/add_conversation/chat/dialog.vala b/main/src/ui/add_conversation/chat/dialog.vala
index a36731a5..ee535f09 100644
--- a/main/src/ui/add_conversation/chat/dialog.vala
+++ b/main/src/ui/add_conversation/chat/dialog.vala
@@ -8,19 +8,21 @@ namespace Dino.Ui.AddConversation.Chat {
public class Dialog : Gtk.Dialog {
- public signal void conversation_opened(Conversation conversation);
+ public signal void selected(Account account, Jid jid);
- private Button ok_button;
+ public Button ok_button;
private RosterList roster_list;
private SelectJidFragment select_jid_fragment;
private StreamInteractor stream_interactor;
+ private Gee.List<Account> accounts;
- public Dialog(StreamInteractor stream_interactor) {
+ public Dialog(StreamInteractor stream_interactor, Gee.List<Account> accounts) {
Object(use_header_bar : 1);
- this.title = _("Start Chat");
- this.modal = true;
+ modal = true;
+
this.stream_interactor = stream_interactor;
+ this.accounts = accounts;
setup_headerbar();
setup_view();
@@ -37,19 +39,22 @@ public class Dialog : Gtk.Dialog {
ok_button = new Button();
ok_button.get_style_context().add_class("suggested-action");
- ok_button.label = _("Start");
ok_button.sensitive = false;
ok_button.visible = true;
header_bar.pack_end(ok_button);
cancel_button.clicked.connect(() => { close(); });
- ok_button.clicked.connect(on_ok_button_clicked);
+ ok_button.clicked.connect(() => {
+ ListRow? selected_row = roster_list.get_selected_row() as ListRow;
+ if (selected_row != null) selected(selected_row.account, selected_row.jid);
+ close();
+ });
}
private void setup_view() {
- roster_list = new RosterList(stream_interactor);
+ roster_list = new RosterList(stream_interactor, accounts);
roster_list.row_activated.connect(() => { ok_button.clicked(); });
- select_jid_fragment = new SelectJidFragment(stream_interactor, roster_list);
+ select_jid_fragment = new SelectJidFragment(stream_interactor, roster_list, accounts);
select_jid_fragment.add_jid.connect((row) => {
AddContactDialog add_contact_dialog = new AddContactDialog(stream_interactor);
add_contact_dialog.set_transient_for(this);
@@ -67,16 +72,6 @@ public class Dialog : Gtk.Dialog {
});
get_content_area().add(select_jid_fragment);
}
-
- protected void on_ok_button_clicked() {
- ListRow? selected_row = roster_list.get_selected_row() as ListRow;
- if (selected_row != null) {
- Conversation conversation = stream_interactor.get_module(ConversationManager.IDENTITY).create_conversation(selected_row.jid, selected_row.account, Conversation.Type.CHAT);
- stream_interactor.get_module(ConversationManager.IDENTITY).start_conversation(conversation, true);
- conversation_opened(conversation);
- }
- close();
- }
}
} \ No newline at end of file
diff --git a/main/src/ui/add_conversation/chat/roster_list.vala b/main/src/ui/add_conversation/chat/roster_list.vala
index d09720d5..3c324cf6 100644
--- a/main/src/ui/add_conversation/chat/roster_list.vala
+++ b/main/src/ui/add_conversation/chat/roster_list.vala
@@ -10,27 +10,28 @@ protected class RosterList : FilterableList {
public signal void conversation_selected(Conversation? conversation);
private StreamInteractor stream_interactor;
+ private Gee.List<Account> accounts;
private HashMap<Account, HashMap<Jid, ListRow>> rows = new HashMap<Account, HashMap<Jid, ListRow>>(Account.hash_func, Account.equals_func);
- public RosterList(StreamInteractor stream_interactor) {
+ public RosterList(StreamInteractor stream_interactor, Gee.List<Account> accounts) {
this.stream_interactor = stream_interactor;
+ this.accounts = accounts;
set_filter_func(filter);
set_header_func(header);
set_sort_func(sort);
stream_interactor.get_module(RosterManager.IDENTITY).removed_roster_item.connect( (account, jid, roster_item) => {
- Idle.add(() => { on_removed_roster_item(account, jid, roster_item); return false;});});
+ if (accounts.contains(account))
+ Idle.add(() => { on_removed_roster_item(account, jid, roster_item); return false;});
+ });
stream_interactor.get_module(RosterManager.IDENTITY).updated_roster_item.connect( (account, jid, roster_item) => {
- Idle.add(() => { on_updated_roster_item(account, jid, roster_item); return false;});});
+ if (accounts.contains(account))
+ Idle.add(() => { on_updated_roster_item(account, jid, roster_item); return false;});
+ });
- foreach (Account account in stream_interactor.get_accounts()) {
- rows[account] = new HashMap<Jid, ListRow>(Jid.hash_func, Jid.equals_func);
- foreach (Roster.Item roster_item in stream_interactor.get_module(RosterManager.IDENTITY).get_roster(account)) {
- on_updated_roster_item(account, new Jid(roster_item.jid), roster_item);
- }
- }
+ foreach (Account a in accounts) fetch_roster_items(a);
}
private void on_removed_roster_item(Account account, Jid jid, Roster.Item roster_item) {
@@ -42,13 +43,20 @@ protected class RosterList : FilterableList {
private void on_updated_roster_item(Account account, Jid jid, Roster.Item roster_item) {
on_removed_roster_item(account, jid, roster_item);
- ListRow row = new ListRow.from_jid(stream_interactor, new Jid(roster_item.jid), account);
+ ListRow row = new ListRow.from_jid(stream_interactor, new Jid(roster_item.jid), account, accounts.size > 1);
rows[account][jid] = row;
add(row);
invalidate_sort();
invalidate_filter();
}
+ private void fetch_roster_items(Account account) {
+ rows[account] = new HashMap<Jid, ListRow>(Jid.hash_func, Jid.equals_func);
+ foreach (Roster.Item roster_item in stream_interactor.get_module(RosterManager.IDENTITY).get_roster(account)) {
+ on_updated_roster_item(account, new Jid(roster_item.jid), roster_item);
+ }
+ }
+
private void header(ListBoxRow row, ListBoxRow? before_row) {
if (row.get_header() == null && before_row != null) {
row.set_header(new Separator(Orientation.HORIZONTAL));