aboutsummaryrefslogtreecommitdiff
path: root/main/src/ui/add_conversation/conference/conference_list.vala
diff options
context:
space:
mode:
authorfiaxh <git@mx.ax.lt>2017-10-28 22:02:32 +0200
committerfiaxh <git@mx.ax.lt>2017-10-31 15:41:45 +0100
commitd9b91206c0291fa8aa58df572292784a4f8ff878 (patch)
tree09721f9fdffbb87ec8ab25fd1c44a7bc535fffab /main/src/ui/add_conversation/conference/conference_list.vala
parent7e83529afcd0ccfff5c65c99e4427bd6cf3f82ac (diff)
downloaddino-d9b91206c0291fa8aa58df572292784a4f8ff878.tar.gz
dino-d9b91206c0291fa8aa58df572292784a4f8ff878.zip
Keep MUC join dialog open until joined, show errors
Diffstat (limited to 'main/src/ui/add_conversation/conference/conference_list.vala')
-rw-r--r--main/src/ui/add_conversation/conference/conference_list.vala103
1 files changed, 0 insertions, 103 deletions
diff --git a/main/src/ui/add_conversation/conference/conference_list.vala b/main/src/ui/add_conversation/conference/conference_list.vala
deleted file mode 100644
index 1f4abfa3..00000000
--- a/main/src/ui/add_conversation/conference/conference_list.vala
+++ /dev/null
@@ -1,103 +0,0 @@
-using Gee;
-using Gtk;
-
-using Xmpp;
-using Dino.Entities;
-
-namespace Dino.Ui.AddConversation.Conference {
-
-protected class ConferenceList : FilterableList {
-
- public signal void conversation_selected(Conversation? conversation);
-
- private StreamInteractor stream_interactor;
- private HashMap<Account, Gee.List<Xep.Bookmarks.Conference>> lists = new HashMap<Account, Gee.List<Xep.Bookmarks.Conference>>();
-
- public ConferenceList(StreamInteractor stream_interactor) {
- this.stream_interactor = stream_interactor;
-
- set_filter_func(filter);
- set_header_func(header);
- set_sort_func(sort);
-
- stream_interactor.get_module(MucManager.IDENTITY).bookmarks_updated.connect((account, conferences) => {
- Idle.add(() => {
- lists[account] = conferences;
- refresh_conferences();
- return false;
- });
- });
-
- foreach (Account account in stream_interactor.get_accounts()) {
- stream_interactor.get_module(MucManager.IDENTITY).get_bookmarks(account, (stream, conferences) => { on_conference_bookmarks_received(stream, account, conferences); });
- }
- }
-
- public void refresh_conferences() {
- @foreach((widget) => { remove(widget); });
- foreach (Account account in lists.keys) {
- foreach (Xep.Bookmarks.Conference conference in lists[account]) {
- add(new ConferenceListRow(stream_interactor, conference, account));
- }
- }
- }
-
- private void on_conference_bookmarks_received(Core.XmppStream stream, Account account, Gee.List<Xep.Bookmarks.Conference> conferences) {
- Idle.add(() => {
- lists[account] = conferences;
- refresh_conferences();
- return false;
- });
- }
-
- private void header(ListBoxRow row, ListBoxRow? before_row) {
- if (row.get_header() == null && before_row != null) {
- row.set_header(new Separator(Orientation.HORIZONTAL));
- }
- }
-
- private bool filter(ListBoxRow r) {
- if (r.get_type().is_a(typeof(ListRow))) {
- ListRow row = r as ListRow;
- if (filter_values != null) {
- foreach (string filter in filter_values) {
- if (!(row.name_label.label.down().contains(filter.down()) ||
- row.jid.to_string().down().contains(filter.down()))) {
- return false;
- }
- }
- }
- }
- return true;
- }
-
- public override int sort(ListBoxRow row1, ListBoxRow row2) {
- ListRow c1 = (row1 as ListRow);
- ListRow c2 = (row2 as ListRow);
- return c1.name_label.label.collate(c2.name_label.label);
- }
-}
-
-internal class ConferenceListRow : ListRow {
-
- public Xep.Bookmarks.Conference bookmark;
-
- public ConferenceListRow(StreamInteractor stream_interactor, Xep.Bookmarks.Conference bookmark, Account account) {
- this.jid = new Jid(bookmark.jid);
- this.account = account;
- this.bookmark = bookmark;
-
- name_label.label = bookmark.name ?? bookmark.jid;
- if (stream_interactor.get_accounts().size > 1) {
- via_label.label = "via " + account.bare_jid.to_string();
- } else if (bookmark.name != null && bookmark.name != bookmark.jid) {
- via_label.label = bookmark.jid;
- } else {
- via_label.visible = false;
- }
-
- image.set_from_pixbuf((new AvatarGenerator(35, 35)).set_stateless(true).draw_jid(stream_interactor, jid, account));
- }
-}
-
-}