diff options
author | fiaxh <git@mx.ax.lt> | 2017-06-11 13:59:24 +0200 |
---|---|---|
committer | fiaxh <git@mx.ax.lt> | 2017-06-11 13:59:24 +0200 |
commit | e63d59eb3450471b33a22efda6df8871818209b1 (patch) | |
tree | 11660e951bf049318f6c0eae8a60fcfbff4c029e /main/src/ui/add_conversation | |
parent | 205bd444a5ba9d119952ecddbf815f50174da8c7 (diff) | |
download | dino-e63d59eb3450471b33a22efda6df8871818209b1.tar.gz dino-e63d59eb3450471b33a22efda6df8871818209b1.zip |
Muc Invite + Kick
Diffstat (limited to 'main/src/ui/add_conversation')
-rw-r--r-- | main/src/ui/add_conversation/chat/dialog.vala | 33 | ||||
-rw-r--r-- | main/src/ui/add_conversation/chat/roster_list.vala | 28 | ||||
-rw-r--r-- | main/src/ui/add_conversation/conference/dialog.vala | 2 | ||||
-rw-r--r-- | main/src/ui/add_conversation/list_row.vala | 4 | ||||
-rw-r--r-- | main/src/ui/add_conversation/select_jid_fragment.vala | 9 |
5 files changed, 41 insertions, 35 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)); diff --git a/main/src/ui/add_conversation/conference/dialog.vala b/main/src/ui/add_conversation/conference/dialog.vala index 412fb07c..9674cef2 100644 --- a/main/src/ui/add_conversation/conference/dialog.vala +++ b/main/src/ui/add_conversation/conference/dialog.vala @@ -88,7 +88,7 @@ public class Dialog : Gtk.Dialog { private void setup_jid_add_view() { conference_list = new ConferenceList(stream_interactor); conference_list.row_activated.connect(() => { ok_button.clicked(); }); - select_fragment = new SelectJidFragment(stream_interactor, conference_list); + select_fragment = new SelectJidFragment(stream_interactor, conference_list, stream_interactor.get_accounts()); select_fragment.add_jid.connect((row) => { AddGroupchatDialog dialog = new AddGroupchatDialog(stream_interactor); dialog.set_transient_for(this); diff --git a/main/src/ui/add_conversation/list_row.vala b/main/src/ui/add_conversation/list_row.vala index b53432a6..c68fde7b 100644 --- a/main/src/ui/add_conversation/list_row.vala +++ b/main/src/ui/add_conversation/list_row.vala @@ -17,12 +17,12 @@ public class ListRow : ListBoxRow { public ListRow() {} - public ListRow.from_jid(StreamInteractor stream_interactor, Jid jid, Account account) { + public ListRow.from_jid(StreamInteractor stream_interactor, Jid jid, Account account, bool show_account) { this.jid = jid; this.account = account; string display_name = Util.get_display_name(stream_interactor, jid, account); - if (stream_interactor.get_accounts().size > 1) { + if (show_account && stream_interactor.get_accounts().size > 1) { via_label.label = @"via $(account.bare_jid)"; this.has_tooltip = true; set_tooltip_text(jid.to_string()); diff --git a/main/src/ui/add_conversation/select_jid_fragment.vala b/main/src/ui/add_conversation/select_jid_fragment.vala index d0b214b5..71314235 100644 --- a/main/src/ui/add_conversation/select_jid_fragment.vala +++ b/main/src/ui/add_conversation/select_jid_fragment.vala @@ -23,13 +23,16 @@ public class SelectJidFragment : Gtk.Box { [GtkChild] private Button edit_button; [GtkChild] private Button remove_button; + private StreamInteractor stream_interactor; private FilterableList filterable_list; + private Gee.List<Account> accounts; + private ArrayList<AddListRow> added_rows = new ArrayList<AddListRow>(); - private StreamInteractor stream_interactor; - public SelectJidFragment(StreamInteractor stream_interactor, FilterableList filterable_list) { + public SelectJidFragment(StreamInteractor stream_interactor, FilterableList filterable_list, Gee.List<Account> accounts) { this.stream_interactor = stream_interactor; this.filterable_list = filterable_list; + this.accounts = accounts; filterable_list.visible = true; filterable_list.activate_on_single_click = false; @@ -57,7 +60,7 @@ public class SelectJidFragment : Gtk.Box { filterable_list.set_filter_values(values); Jid? parsed_jid = Jid.parse(str); if (parsed_jid != null && parsed_jid.localpart != null) { - foreach (Account account in stream_interactor.get_accounts()) { + foreach (Account account in accounts) { AddListRow row = new AddListRow(stream_interactor, str, account); filterable_list.add(row); added_rows.add(row); |