aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main/data/add_conversation/list_row.ui55
-rw-r--r--main/data/icons/scalable/status/dino-status-offline.svg29
-rw-r--r--main/src/ui/add_conversation/list_row.vala68
-rw-r--r--main/src/ui/add_conversation/roster_list.vala18
-rw-r--r--main/src/ui/main_window.vala2
5 files changed, 98 insertions, 74 deletions
diff --git a/main/data/add_conversation/list_row.ui b/main/data/add_conversation/list_row.ui
index d829dc3a..e7dc62eb 100644
--- a/main/data/add_conversation/list_row.ui
+++ b/main/data/add_conversation/list_row.ui
@@ -1,12 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk" version="4.0"/>
- <object class="GtkGrid" id="outer_grid">
- <property name="margin-start">3</property>
- <property name="margin-end">3</property>
- <property name="margin-top">3</property>
- <property name="margin-bottom">3</property>
- <property name="column-spacing">10</property>
+ <object class="GtkBox" id="outer_box">
+ <property name="orientation">horizontal</property>
+ <property name="spacing">8</property>
+ <property name="margin-start">6</property>
+ <property name="margin-end">6</property>
+ <property name="margin-top">6</property>
+ <property name="margin-bottom">6</property>
<child>
<object class="DinoUiAvatarPicture" id="picture">
<property name="height-request">30</property>
@@ -15,43 +16,33 @@
</object>
</child>
<child>
- <object class="GtkImage" id="status_dot">
- <property name="pixel-size">10</property>
- <layout>
- <property name="column">1</property>
- <property name="row">0</property>
- </layout>
- </object>
- </child>
- <child>
- <object class="GtkGrid">
- <property name="valign">center</property>
+ <object class="GtkBox">
<property name="orientation">vertical</property>
+ <property name="valign">center</property>
<child>
- <object class="GtkLabel" id="name_label">
- <property name="max_width_chars">1</property>
- <property name="ellipsize">end</property>
- <property name="hexpand">1</property>
- <property name="xalign">0</property>
- <layout>
- <property name="column">0</property>
- <property name="row">0</property>
- </layout>
+ <object class="GtkBox">
+ <property name="orientation">horizontal</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkLabel" id="name_label">
+ <property name="ellipsize">end</property>
+ <property name="xalign">0</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkImage" id="status_dot">
+ <property name="pixel-size">8</property>
+ </object>
+ </child>
</object>
</child>
<child>
<object class="GtkLabel" id="via_label">
- <property name="max_width_chars">1</property>
<property name="ellipsize">end</property>
- <property name="hexpand">1</property>
<property name="xalign">0</property>
<attributes>
<attribute name="scale" value="0.8"></attribute>
</attributes>
- <layout>
- <property name="column">0</property>
- <property name="row">1</property>
- </layout>
</object>
</child>
</object>
diff --git a/main/data/icons/scalable/status/dino-status-offline.svg b/main/data/icons/scalable/status/dino-status-offline.svg
index 58f75de2..40874238 100644
--- a/main/data/icons/scalable/status/dino-status-offline.svg
+++ b/main/data/icons/scalable/status/dino-status-offline.svg
@@ -1,6 +1,23 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<svg width="28.222mm" height="28.222mm" version="1.1" viewBox="0 0 99.999997 99.999997" xmlns="http://www.w3.org/2000/svg">
- <g transform="translate(-62.857 -678.08)">
- <circle cx="112.86" cy="728.08" r="50" style="fill-rule:evenodd;fill:grey;"/>
- </g>
-</svg> \ No newline at end of file
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg
+ width="28mm"
+ height="28mm"
+ version="1.1"
+ viewBox="0 0 99.213383 99.213383"
+ id="svg190"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:svg="http://www.w3.org/2000/svg">
+ <defs
+ id="defs194" />
+ <g
+ transform="matrix(0.85040034,0,0,0.85040034,-46.369496,-569.55281)"
+ id="g188"
+ style="fill:#000000;fill-opacity:1;stroke:none;stroke-width:16.8493;stroke-dasharray:none;stroke-opacity:1">
+ <circle
+ cx="112.86"
+ cy="728.08002"
+ r="50"
+ style="fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#6e6e6e;stroke-width:16.85;stroke-dasharray:none;stroke-opacity:1"
+ id="circle186" />
+ </g>
+</svg>
diff --git a/main/src/ui/add_conversation/list_row.vala b/main/src/ui/add_conversation/list_row.vala
index 8e4cbb9b..c489aa13 100644
--- a/main/src/ui/add_conversation/list_row.vala
+++ b/main/src/ui/add_conversation/list_row.vala
@@ -8,18 +8,21 @@ 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");
@@ -27,35 +30,32 @@ public class ListRow : Widget {
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;
- private void set_status_dot(StreamInteractor stream_interactor, Jid jid, Account account){
Gee.List<Jid>? full_jids = stream_interactor.get_module(PresenceManager.IDENTITY).get_full_jids(jid, account);
- string presence_str = null;
- if (full_jids != null){
- int devices = 0;
- string newline_if_more_devices;
- for (int i = 0; i < full_jids.size; i++) {
- Jid full_jid = full_jids[i];
- presence_str = stream_interactor.get_module(PresenceManager.IDENTITY).get_last_show(full_jid, account);
- if(presence_str != null) devices += 1;
- newline_if_more_devices = devices > 1 ? "\r\n" : "";
- switch(presence_str){
- case "dnd": this.status_dot.set_from_icon_name("dino-status-dnd"); i = full_jids.size; break; // dnd detected = marked as dnd for all devices
- case "online": this.status_dot.set_from_icon_name("dino-status-online"); i = full_jids.size; break;
- case "away": this.status_dot.set_from_icon_name("dino-status-away"); break;
- case "xa": this.status_dot.set_from_icon_name("dino-status-away"); break;
- case "chat": this.status_dot.set_from_icon_name("dino-status-chat"); break;
- }
+ 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");
}
- 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;
@@ -72,11 +72,27 @@ 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);
+
+ 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);
+ }
}
}
diff --git a/main/src/ui/add_conversation/roster_list.vala b/main/src/ui/add_conversation/roster_list.vala
index bb338ce5..080d7f93 100644
--- a/main/src/ui/add_conversation/roster_list.vala
+++ b/main/src/ui/add_conversation/roster_list.vala
@@ -20,14 +20,14 @@ protected class RosterList {
this.stream_interactor = stream_interactor;
this.accounts = accounts;
- handler_ids += stream_interactor.get_module(RosterManager.IDENTITY).removed_roster_item.connect( (account, jid, roster_item) => {
+ handler_ids += stream_interactor.get_module(RosterManager.IDENTITY).removed_roster_item.connect( (account, jid) => {
if (accounts.contains(account)) {
- on_removed_roster_item(account, jid, roster_item);
+ remove_row(account, jid);
}
});
- handler_ids += stream_interactor.get_module(RosterManager.IDENTITY).updated_roster_item.connect( (account, jid, roster_item) => {
+ handler_ids += stream_interactor.get_module(RosterManager.IDENTITY).updated_roster_item.connect( (account, jid) => {
if (accounts.contains(account)) {
- on_updated_roster_item(account, jid, roster_item);
+ update_row(account, jid);
}
});
list_box.destroy.connect(() => {
@@ -37,16 +37,16 @@ protected class RosterList {
foreach (Account a in accounts) fetch_roster_items(a);
}
- private void on_removed_roster_item(Account account, Jid jid, Roster.Item roster_item) {
+ private void remove_row(Account account, Jid jid) {
if (rows.has_key(account) && rows[account].has_key(jid)) {
list_box.remove(rows[account][jid]);
rows[account].unset(jid);
}
}
- 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, roster_item.jid, account, accounts.size > 1);
+ private void update_row(Account account, Jid jid) {
+ remove_row(account, jid);
+ ListRow row = new ListRow.from_jid(stream_interactor, jid, account, accounts.size > 1);
ListBoxRow list_box_row = new ListBoxRow() { child=row };
rows[account][jid] = list_box_row;
list_box.append(list_box_row);
@@ -57,7 +57,7 @@ protected class RosterList {
private void fetch_roster_items(Account account) {
rows[account] = new HashMap<Jid, ListBoxRow>(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, roster_item.jid, roster_item);
+ update_row(account, roster_item.jid);
}
}
diff --git a/main/src/ui/main_window.vala b/main/src/ui/main_window.vala
index dd54052e..ce71d413 100644
--- a/main/src/ui/main_window.vala
+++ b/main/src/ui/main_window.vala
@@ -20,7 +20,7 @@ public class MainWindow : Adw.ApplicationWindow {
public ConversationTitlebar conversation_titlebar;
public Widget conversation_list_titlebar;
public Box box = new Box(Orientation.VERTICAL, 0) { orientation=Orientation.VERTICAL };
- public Adw.Leaflet leaflet;
+ private Adw.Leaflet leaflet;
public Box left_box;
public Box right_box;
public Adw.Flap search_flap;