aboutsummaryrefslogtreecommitdiff
path: root/main/src/ui/add_conversation
diff options
context:
space:
mode:
authoreerielili <lionel@les-miquelots.net>2024-08-25 13:32:38 +0000
committerGitHub <noreply@github.com>2024-08-25 13:32:38 +0000
commit45755727db79a2935376d24e7bde7eadb0f2f7ca (patch)
tree73715da99c9d980079df6f2d561822364655e04d /main/src/ui/add_conversation
parent62cdea3a5e701c04f3a7fd9d6b5f48e28fef1f72 (diff)
parent51252f74c94c17d56aa75534652bdc5d43a504cb (diff)
downloaddino-45755727db79a2935376d24e7bde7eadb0f2f7ca.tar.gz
dino-45755727db79a2935376d24e7bde7eadb0f2f7ca.zip
Merge branch 'master' into add-yourselfadd-yourself
Diffstat (limited to 'main/src/ui/add_conversation')
-rw-r--r--main/src/ui/add_conversation/add_conference_dialog.vala2
-rw-r--r--main/src/ui/add_conversation/conference_list.vala1
-rw-r--r--main/src/ui/add_conversation/list_row.vala57
3 files changed, 52 insertions, 8 deletions
diff --git a/main/src/ui/add_conversation/add_conference_dialog.vala b/main/src/ui/add_conversation/add_conference_dialog.vala
index 551f6713..eac55ffc 100644
--- a/main/src/ui/add_conversation/add_conference_dialog.vala
+++ b/main/src/ui/add_conversation/add_conference_dialog.vala
@@ -165,7 +165,7 @@ public class AddConferenceDialog : Gtk.Dialog {
details_fragment.clear();
ListRow? row = conference_list_box.get_selected_row() != null ? conference_list_box.get_selected_row().get_child() as ListRow : null;
- ConferenceListRow? conference_row = conference_list_box.get_selected_row() != null ? conference_list_box.get_selected_row() as ConferenceListRow : null;
+ ConferenceListRow? conference_row = conference_list_box.get_selected_row() != null ? conference_list_box.get_selected_row().get_child() as ConferenceListRow : null;
if (conference_row != null) {
details_fragment.account = conference_row.account;
details_fragment.jid = conference_row.bookmark.jid.to_string();
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..c489aa13 100644
--- a/main/src/ui/add_conversation/list_row.vala
+++ b/main/src/ui/add_conversation/list_row.vala
@@ -8,28 +8,54 @@ 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 Jid? jid;
- public Account? account;
+ public StreamInteractor stream_interactor;
+ public Jid jid;
+ public Account account;
+
+ private ulong[] handler_ids = new ulong[0];
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){
+ status_dot.visible = stream_interactor.connection_manager.get_state(account) == ConnectionManager.ConnectionState.CONNECTED;
+
+ Gee.List<Jid>? full_jids = stream_interactor.get_module(PresenceManager.IDENTITY).get_full_jids(jid, account);
+ if (full_jids != null) {
+ var statuses = new ArrayList<string>();
+ foreach (var full_jid in full_jids) {
+ statuses.add(stream_interactor.get_module(PresenceManager.IDENTITY).get_last_show(full_jid, account));
+ }
+
+ if (statuses.contains(Xmpp.Presence.Stanza.SHOW_DND)) status_dot.set_from_icon_name("dino-status-dnd");
+ else if (statuses.contains(Xmpp.Presence.Stanza.SHOW_CHAT)) status_dot.set_from_icon_name("dino-status-chat");
+ else if (statuses.contains(Xmpp.Presence.Stanza.SHOW_ONLINE)) status_dot.set_from_icon_name("dino-status-online");
+ else if (statuses.contains(Xmpp.Presence.Stanza.SHOW_AWAY)) status_dot.set_from_icon_name("dino-status-away");
+ else if (statuses.contains(Xmpp.Presence.Stanza.SHOW_XA)) status_dot.set_from_icon_name("dino-status-away");
+ else status_dot.set_from_icon_name("dino-status-offline");
+ } else {
+ status_dot.set_from_icon_name("dino-status-offline");
+ }
+ }
public ListRow.from_jid(StreamInteractor stream_interactor, Jid jid, Account account, bool show_account) {
+ this.stream_interactor = stream_interactor;
this.jid = jid;
this.account = account;
@@ -46,10 +72,27 @@ public class ListRow : Widget {
}
name_label.label = display_name;
picture.model = new ViewModel.CompatAvatarPictureModel(stream_interactor).set_conversation(conv);
+
+ handler_ids += stream_interactor.get_module(PresenceManager.IDENTITY).show_received.connect((jid, account) => {
+ if (account.equals(this.account) && jid.equals_bare(this.jid)) {
+ set_status_dot(stream_interactor);
+ }
+ });
+ handler_ids += stream_interactor.get_module(PresenceManager.IDENTITY).received_offline_presence.connect((jid, account) => {
+ if (account.equals(this.account) && jid.equals_bare(this.jid)) {
+ set_status_dot(stream_interactor);
+ }
+ });
+
+ set_status_dot(stream_interactor);
}
public override void dispose() {
- outer_grid.unparent();
+ outer_box.unparent();
+
+ foreach (var handler_id in handler_ids) {
+ stream_interactor.get_module(PresenceManager.IDENTITY).disconnect(handler_id);
+ }
}
}