aboutsummaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorfiaxh <git@lightrise.org>2020-03-29 20:23:47 +0200
committerfiaxh <git@lightrise.org>2020-03-29 20:24:39 +0200
commit12cd56612dd6edd056e2cd8aae59ea3ae8f05d1e (patch)
tree1da6667e85128aad0c2992b3c2b490f42defce6f /main
parent853dfa2d6f0d1300b096f0c6a12ca179208f5287 (diff)
downloaddino-12cd56612dd6edd056e2cd8aae59ea3ae8f05d1e.tar.gz
dino-12cd56612dd6edd056e2cd8aae59ea3ae8f05d1e.zip
Store entity identity info, use it in conversation list tooltips
Diffstat (limited to 'main')
-rw-r--r--main/CMakeLists.txt6
-rw-r--r--main/data/conversation_row.ui (renamed from main/data/conversation_selector/conversation_row.ui)0
-rw-r--r--main/data/conversation_selector/chat_row_tooltip.ui22
-rw-r--r--main/data/icons/dino-device-desktop-symbolic.svg5
-rw-r--r--main/data/icons/dino-device-phone-symbolic.svg6
-rw-r--r--main/src/ui/conversation_selector/conversation_selector_row.vala90
6 files changed, 72 insertions, 57 deletions
diff --git a/main/CMakeLists.txt b/main/CMakeLists.txt
index 5f5b7831..5dc69dcb 100644
--- a/main/CMakeLists.txt
+++ b/main/CMakeLists.txt
@@ -28,6 +28,9 @@ set(RESOURCE_LIST
icons/im.dino.Dino-symbolic.svg
icons/dino-tick-symbolic.svg
+ icons/dino-device-desktop-symbolic.svg
+ icons/dino-device-phone-symbolic.svg
+
icons/dino-file-document-symbolic.svg
icons/dino-file-download-symbolic.svg
icons/dino-file-image-symbolic.svg
@@ -45,11 +48,10 @@ set(RESOURCE_LIST
contact_details_dialog.ui
conversation_list_titlebar.ui
conversation_list_titlebar_csd.ui
+ conversation_row.ui
conversation_view.ui
emojichooser.ui
global_search.ui
- conversation_selector/chat_row_tooltip.ui
- conversation_selector/conversation_row.ui
conversation_content_view/image_toolbar.ui
conversation_content_view/item_metadata_header.ui
conversation_content_view/view.ui
diff --git a/main/data/conversation_selector/conversation_row.ui b/main/data/conversation_row.ui
index 7772c907..7772c907 100644
--- a/main/data/conversation_selector/conversation_row.ui
+++ b/main/data/conversation_row.ui
diff --git a/main/data/conversation_selector/chat_row_tooltip.ui b/main/data/conversation_selector/chat_row_tooltip.ui
deleted file mode 100644
index 6596cd62..00000000
--- a/main/data/conversation_selector/chat_row_tooltip.ui
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<interface>
- <object class="GtkBox" id="main_box">
- <property name="orientation">vertical</property>
- <property name="visible">True</property>
- <child>
- <object class="GtkLabel" id="jid_label">
- <property name="xalign">0</property>
- <property name="visible">True</property>
- <attributes>
- <attribute name="weight" value="PANGO_WEIGHT_BOLD"/>
- </attributes>
- </object>
- </child>
- <child>
- <object class="GtkBox" id="inner_box">
- <property name="orientation">vertical</property>
- <property name="visible">True</property>
- </object>
- </child>
- </object>
-</interface>
diff --git a/main/data/icons/dino-device-desktop-symbolic.svg b/main/data/icons/dino-device-desktop-symbolic.svg
new file mode 100644
index 00000000..4e4e02ab
--- /dev/null
+++ b/main/data/icons/dino-device-desktop-symbolic.svg
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<svg version="1.1" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
+ <path d="m3 4h18a1 1 0 0 1 1 1v11a1 1 0 0 1-1 1h1l2 3v1h-24v-1l2-3h1a1 1 0 0 1-1-1v-11a1 1 0 0 1 1-1m1 2v9h16v-9h-16z"/>
+ <rect x="4" y="6" width="16" height="9" opacity=".3" stroke-linecap="round" stroke-width="1.8898"/>
+</svg>
diff --git a/main/data/icons/dino-device-phone-symbolic.svg b/main/data/icons/dino-device-phone-symbolic.svg
new file mode 100644
index 00000000..64a69e17
--- /dev/null
+++ b/main/data/icons/dino-device-phone-symbolic.svg
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<svg version="1.1" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
+ <path d="M17.25,18H6.75V4H17.25M14,21H10V20H14M16,1H8A3,3 0 0,0 5,4V20A3,3 0 0,0 8,23H16A3,3 0 0,0 19,20V4A3,3 0 0,0 16,1Z"/>
+ <rect x="6.75" y="4" width="10.5" height="14" fill="#030202" opacity=".3" stroke-linecap="round" stroke-width="1.8898"/>
+ <rect x="10" y="20" width="4" height="1" fill="#070504" opacity=".3" stroke-linecap="round" stroke-width="1.8898"/>
+</svg>
diff --git a/main/src/ui/conversation_selector/conversation_selector_row.vala b/main/src/ui/conversation_selector/conversation_selector_row.vala
index 80257a6d..6234e9c8 100644
--- a/main/src/ui/conversation_selector/conversation_selector_row.vala
+++ b/main/src/ui/conversation_selector/conversation_selector_row.vala
@@ -9,7 +9,7 @@ using Xmpp;
namespace Dino.Ui {
-[GtkTemplate (ui = "/im/dino/Dino/conversation_selector/conversation_row.ui")]
+[GtkTemplate (ui = "/im/dino/Dino/conversation_row.ui")]
public class ConversationSelectorRow : ListBoxRow {
[GtkChild] protected AvatarImage image;
@@ -217,29 +217,6 @@ public class ConversationSelectorRow : ListBoxRow {
message_label.label = message_label.label;
}
- protected Box get_fulljid_box(Jid full_jid) {
- Box box = new Box(Orientation.HORIZONTAL, 5) { visible=true };
-
- Show show = stream_interactor.get_module(PresenceManager.IDENTITY).get_last_show(full_jid, conversation.account);
- Image image = new Image() { visible=true };
- if (show.as == Show.AWAY) {
- image.set_from_icon_name("dino-status-away", IconSize.SMALL_TOOLBAR);
- } else if (show.as == Show.XA || show.as == Show.DND) {
- image.set_from_icon_name("dino-status-dnd", IconSize.SMALL_TOOLBAR);
- } else if (show.as == Show.CHAT) {
- image.set_from_icon_name("dino-status-chat", IconSize.SMALL_TOOLBAR);
- } else {
- image.set_from_icon_name("dino-status-online", IconSize.SMALL_TOOLBAR);
- }
- box.add(image);
-
- Label resource = new Label(full_jid.resourcepart) { visible=true };
- resource.xalign = 0;
- box.add(resource);
- box.show_all();
- return box;
- }
-
public override void state_flags_changed(StateFlags flags) {
StateFlags curr_flags = get_state_flags();
if ((curr_flags & StateFlags.PRELIGHT) != 0) {
@@ -251,21 +228,68 @@ public class ConversationSelectorRow : ListBoxRow {
}
}
+ private static Regex dino_resource_regex = /^dino\.[a-f0-9]{8}$/;
+
private Widget generate_tooltip() {
- Builder builder = new Builder.from_resource("/im/dino/Dino/conversation_selector/chat_row_tooltip.ui");
- Box main_box = builder.get_object("main_box") as Box;
- Box inner_box = builder.get_object("inner_box") as Box;
- Label jid_label = builder.get_object("jid_label") as Label;
+ Grid grid = new Grid() { row_spacing=5, column_homogeneous=false, column_spacing=2, margin_start=5, margin_end=5, margin_top=2, margin_bottom=2, visible=true };
- jid_label.label = conversation.counterpart.to_string();
+ Label label = new Label(conversation.counterpart.to_string()) { valign=Align.START, xalign=0, visible=true };
+ label.attributes = new AttrList();
+ label.attributes.insert(attr_weight_new(Weight.BOLD));
+
+ grid.attach(label, 0, 0, 2, 1);
Gee.List<Jid>? full_jids = stream_interactor.get_module(PresenceManager.IDENTITY).get_full_jids(conversation.counterpart, conversation.account);
- if (full_jids != null) {
- for (int i = 0; i < full_jids.size; i++) {
- inner_box.add(get_fulljid_box(full_jids[i]));
+ if (full_jids == null) return grid;
+
+ for (int i = 0; i < full_jids.size; i++) {
+ Jid full_jid = full_jids[i];
+ Show show = stream_interactor.get_module(PresenceManager.IDENTITY).get_last_show(full_jid, conversation.account);
+ Xep.ServiceDiscovery.Identity? identity = stream_interactor.get_module(EntityInfo.IDENTITY).get_identity(conversation.account, full_jid);
+
+ Image image = new Image() { hexpand=false, valign=Align.START, visible=true };
+ grid.attach(image, 0, i + 1, 1, 1);
+ if (identity != null && identity.type_ == Xep.ServiceDiscovery.Identity.TYPE_PHONE || identity.type_ == Xep.ServiceDiscovery.Identity.TYPE_TABLET) {
+ image.set_from_icon_name("dino-device-phone-symbolic", IconSize.SMALL_TOOLBAR);
+ } else {
+ image.set_from_icon_name("dino-device-desktop-symbolic", IconSize.SMALL_TOOLBAR);
}
+
+ if (show.as == Show.AWAY) {
+ Util.force_color(image, "#FF9800");
+ } else if (show.as == Show.XA || show.as == Show.DND) {
+ Util.force_color(image, "#FF5722");
+ } else {
+ Util.force_color(image, "#4CAF50");
+ }
+
+ string? status = null;
+ if (show.as == Show.AWAY) {
+ status = "away";
+ } else if (show.as == Show.XA) {
+ status = "not available";
+ } else if (show.as == Show.DND) {
+ status = "do not disturb";
+ }
+
+ var sb = new StringBuilder();
+ if (identity.name != null) {
+ sb.append(identity.name);
+ } else if (dino_resource_regex.match(full_jid.resourcepart)) {
+ sb.append("Dino");
+ } else {
+ sb.append(full_jid.resourcepart);
+ }
+ if (status != null) {
+ sb.append(" <i>(");
+ sb.append(status);
+ sb.append(")</i>");
+ }
+
+ Label resource = new Label(sb.str) { use_markup=true, hexpand=true, xalign=0, visible=true };
+ grid.attach(resource, 1, i + 1, 1, 1);
}
- return main_box;
+ return grid;
}
private static string get_relative_time(DateTime datetime) {