diff --git a/main/data/add_conversation/list_row.ui b/main/data/add_conversation/list_row.ui index b8a97174..e7dc62eb 100644 --- a/main/data/add_conversation/list_row.ui +++ b/main/data/add_conversation/list_row.ui @@ -1,12 +1,13 @@ - - 3 - 3 - 3 - 3 - 10 + + horizontal + 8 + 6 + 6 + 6 + 6 30 @@ -15,34 +16,33 @@ - - center + vertical + center - - 1 - end - 1 - 0 - - 0 - 0 - + + horizontal + 6 + + + end + 0 + + + + + 8 + + - 1 end - 1 0 - - 0 - 1 - diff --git a/main/src/ui/add_conversation/conference_list.vala b/main/src/ui/add_conversation/conference_list.vala index 0b630ae4..bf6191fa 100644 --- a/main/src/ui/add_conversation/conference_list.vala +++ b/main/src/ui/add_conversation/conference_list.vala @@ -103,6 +103,7 @@ internal class ConferenceListRow : ListRow { this.account = account; this.bookmark = bookmark; + status_dot.visible = false; name_label.label = bookmark.name != null && bookmark.name != "" ? bookmark.name : bookmark.jid.to_string(); if (stream_interactor.get_accounts().size > 1) { via_label.label = "via " + account.bare_jid.to_string(); diff --git a/main/src/ui/add_conversation/list_row.vala b/main/src/ui/add_conversation/list_row.vala index c5e344d0..1f15fff3 100644 --- a/main/src/ui/add_conversation/list_row.vala +++ b/main/src/ui/add_conversation/list_row.vala @@ -8,27 +8,69 @@ namespace Dino.Ui { public class ListRow : Widget { - public Grid outer_grid; + public Box outer_box; public AvatarPicture picture; public Label name_label; + public Image status_dot; public Label via_label; + public string? status_str; public Jid? jid; public Account? account; construct { Builder builder = new Builder.from_resource("/im/dino/Dino/add_conversation/list_row.ui"); - outer_grid = (Grid) builder.get_object("outer_grid"); + outer_box = (Box) builder.get_object("outer_box"); picture = (AvatarPicture) builder.get_object("picture"); name_label = (Label) builder.get_object("name_label"); + status_dot = (Image) builder.get_object("status_dot"); via_label = (Label) builder.get_object("via_label"); + this.layout_manager = new BinLayout(); - outer_grid.set_parent(this); + outer_box.set_parent(this); } public ListRow() {} + private void set_status_dot(StreamInteractor stream_interactor, Jid jid, Account account){ + Gee.List? full_jids = stream_interactor.get_module(PresenceManager.IDENTITY).get_full_jids(jid, account); + string presences = ""; + if (full_jids != null) { + for (int i = 0; i < full_jids.size; i++) { + Jid full_jid = full_jids[i]; + string presence = stream_interactor.get_module(PresenceManager.IDENTITY).get_last_show(full_jid, account); + presences += presence + " "; + } + } else presences = null; + + if (presences == null) { + status_dot.set_from_icon_name("dino-status-offline"); + return; + } + // Do not disturb > Interested in Chatting > Online > Away = Extended Away + if(presences.contains(Presence.Stanza.SHOW_DND)) { + status_dot.set_from_icon_name("dino-status-dnd"); + return; + } + + if(presences.contains(Presence.Stanza.SHOW_CHAT)) { + status_dot.set_from_icon_name("dino-status-chat"); + return; + } + + if(presences.contains(Presence.Stanza.SHOW_ONLINE)) { + status_dot.set_from_icon_name("dino-status-online"); + return; + } + + if(presences.contains(Presence.Stanza.SHOW_AWAY) || presences.contains(Presence.Stanza.SHOW_XA)) { + status_dot.set_from_icon_name("dino-status-away"); + return; + } + + } + public ListRow.from_jid(StreamInteractor stream_interactor, Jid jid, Account account, bool show_account) { this.jid = jid; this.account = account; @@ -46,10 +88,11 @@ public class ListRow : Widget { } name_label.label = display_name; picture.model = new ViewModel.CompatAvatarPictureModel(stream_interactor).set_conversation(conv); + set_status_dot(stream_interactor, jid, account); } public override void dispose() { - outer_grid.unparent(); + outer_box.unparent(); } }