Welcome to mirror list, hosted at ThFree Co, Russian Federation.

dev.gajim.org/gajim/gajim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornicoco <nicoco@nicoco.fr>2023-10-04 00:20:53 +0300
committernicoco <nicoco@nicoco.fr>2023-10-12 10:27:06 +0300
commit0efdbac7fa5994700ba316bf397bfce7b2d1ef58 (patch)
treee9269b2b3af1b9af823b192315bf313bbf22bf93
parentb1c5209d091bae96782394fb9f8b264fe8dde843 (diff)
feat: Hint that a contact is a bot in the chat banner
-rw-r--r--gajim/common/modules/contacts.py15
-rw-r--r--gajim/data/gui/chat_banner.ui17
-rw-r--r--gajim/data/icons/hicolor/16x16/devices/lucide-bot-symbolic.symbolic.pngbin0 -> 339 bytes
-rw-r--r--gajim/data/icons/hicolor/32x32/devices/lucide-bot-symbolic.symbolic.pngbin0 -> 616 bytes
-rw-r--r--gajim/data/icons/hicolor/48x48/devices/lucide-bot-symbolic.symbolic.pngbin0 -> 818 bytes
-rw-r--r--gajim/data/icons/hicolor/scalable/devices/lucide-bot-symbolic.svg91
-rw-r--r--gajim/gtk/builder.pyi1
-rw-r--r--gajim/gtk/chat_banner.py10
8 files changed, 132 insertions, 2 deletions
diff --git a/gajim/common/modules/contacts.py b/gajim/common/modules/contacts.py
index 89b5c618e..9e3b9212f 100644
--- a/gajim/common/modules/contacts.py
+++ b/gajim/common/modules/contacts.py
@@ -637,6 +637,15 @@ class BareContact(CommonContact):
def type_string(self) -> str:
return 'chat'
+ @property
+ def is_bot(self) -> bool:
+ disco_info = app.storage.cache.get_last_disco_info(self._jid)
+
+ if disco_info is not None and disco_info.has_identity('client', 'bot'):
+ return True
+
+ return any(r.is_bot for r in self.iter_resources())
+
class ResourceContact(CommonContact):
def __init__(self, logger: LogAdapter, jid: JID, account: str) -> None:
@@ -676,6 +685,12 @@ class ResourceContact(CommonContact):
identity in disco_info.identities)
@property
+ def is_bot(self):
+ disco_info = app.storage.cache.get_last_disco_info(self._jid)
+ return (disco_info is not None
+ and disco_info.has_identity('client', 'bot'))
+
+ @property
def is_available(self) -> bool:
return self._presence.available
diff --git a/gajim/data/gui/chat_banner.ui b/gajim/data/gui/chat_banner.ui
index 783862fe7..41dddfbeb 100644
--- a/gajim/data/gui/chat_banner.ui
+++ b/gajim/data/gui/chat_banner.ui
@@ -333,6 +333,21 @@
</packing>
</child>
<child>
+ <object class="GtkImage" id="robot_image">
+ <property name="can-focus">False</property>
+ <property name="no-show-all">True</property>
+ <property name="tooltip-text" translatable="yes">This contact is a bot</property>
+ <property name="halign">start</property>
+ <property name="margin-end">4</property>
+ <property name="icon-name">lucide-bot-symbolic</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
<object class="GtkLabel" id="description_label">
<property name="visible">True</property>
<property name="can-focus">False</property>
@@ -347,7 +362,7 @@
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
- <property name="position">1</property>
+ <property name="position">2</property>
</packing>
</child>
</object>
diff --git a/gajim/data/icons/hicolor/16x16/devices/lucide-bot-symbolic.symbolic.png b/gajim/data/icons/hicolor/16x16/devices/lucide-bot-symbolic.symbolic.png
new file mode 100644
index 000000000..59f05d6bd
--- /dev/null
+++ b/gajim/data/icons/hicolor/16x16/devices/lucide-bot-symbolic.symbolic.png
Binary files differ
diff --git a/gajim/data/icons/hicolor/32x32/devices/lucide-bot-symbolic.symbolic.png b/gajim/data/icons/hicolor/32x32/devices/lucide-bot-symbolic.symbolic.png
new file mode 100644
index 000000000..962e61a5e
--- /dev/null
+++ b/gajim/data/icons/hicolor/32x32/devices/lucide-bot-symbolic.symbolic.png
Binary files differ
diff --git a/gajim/data/icons/hicolor/48x48/devices/lucide-bot-symbolic.symbolic.png b/gajim/data/icons/hicolor/48x48/devices/lucide-bot-symbolic.symbolic.png
new file mode 100644
index 000000000..a8a19b2b5
--- /dev/null
+++ b/gajim/data/icons/hicolor/48x48/devices/lucide-bot-symbolic.symbolic.png
Binary files differ
diff --git a/gajim/data/icons/hicolor/scalable/devices/lucide-bot-symbolic.svg b/gajim/data/icons/hicolor/scalable/devices/lucide-bot-symbolic.svg
new file mode 100644
index 000000000..0578e98d6
--- /dev/null
+++ b/gajim/data/icons/hicolor/scalable/devices/lucide-bot-symbolic.svg
@@ -0,0 +1,91 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg
+ width="16"
+ height="16"
+ viewBox="0 0 16 16"
+ stroke="currentColor"
+ style="fill:none;stroke:#000000;stroke-width:1.36;stroke-linecap:round;stroke-linejoin:round"
+ class="fg"
+ version="1.1"
+ id="svg14"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:svg="http://www.w3.org/2000/svg">
+ <defs
+ id="defs18" />
+ <path
+ class="fg"
+ d="m 2.5203023,6.6300753 c 0,-0.7589381 0.610986,-1.3699245 1.369924,-1.3699245"
+ id="path11158"
+ />
+ <path
+ class="fg"
+ d="M 2.5203023,12.109773 V 6.6300753"
+ id="path11156"
+ />
+ <path
+ class="fg"
+ d="m 3.8902263,13.479698 c -0.758938,0 -1.369924,-0.610987 -1.369924,-1.369925"
+ id="path11154"
+ />
+ <path
+ class="fg"
+ d="M 12.109774,13.479698 H 3.8902263"
+ id="path11152"
+ />
+ <path
+ class="fg"
+ d="m 13.479698,12.109773 c 0,0.758938 -0.610986,1.369925 -1.369924,1.369925"
+ id="path11150"
+ />
+ <path
+ class="fg"
+ d="M 13.479698,6.6300753 V 12.109773"
+ id="path11148"
+ />
+ <path
+ class="fg"
+ d="m 12.109774,5.2601508 c 0.758938,0 1.369924,0.6109864 1.369924,1.3699245"
+ id="path11146"
+ />
+ <path
+ class="fg"
+ d="M 3.8902263,5.2601508 H 12.109774"
+ id="rect2"
+ />
+ <path
+ class="fg"
+ d="M 8,2.5203017 H 5.2601509"
+ id="path398"
+ />
+ <path
+ class="fg"
+ d="M 8,5.2601508 V 2.5203017"
+ id="path4"
+ />
+ <path
+ class="fg"
+ d="m 1.1503773,9.3699244 h 1.369925"
+ id="path6"
+ />
+ <path
+ class="fg"
+ d="m 13.479698,9.3699244 h 1.369925"
+ id="path8"
+ />
+ <path
+ class="fg"
+ d="M 10.054887,8.6849621 V 10.054886"
+ id="path10"
+ />
+ <path
+ class="fg"
+ d="M 5.9451131,8.6849621 V 10.054886"
+ id="path12"
+ />
+</svg>
+<!-- bot from the lucide icon set, edited with inkscape to be GTK3-compatible
+NB: this SVG version is somehow not completely good because it does not respect
+light/dark theme. The PNG versions created with gtk-encode-symbolic-svg seem
+OK though.
+-->
+
diff --git a/gajim/gtk/builder.pyi b/gajim/gtk/builder.pyi
index 3cac99713..2631d1bbd 100644
--- a/gajim/gtk/builder.pyi
+++ b/gajim/gtk/builder.pyi
@@ -201,6 +201,7 @@ class ChatBannerBuilder(Builder):
share_menu_button: Gtk.MenuButton
name_label: Gtk.Label
phone_image: Gtk.Image
+ robot_image: Gtk.Image
description_label: Gtk.Label
additional_items_box: Gtk.Box
visitor_box: Gtk.Box
diff --git a/gajim/gtk/chat_banner.py b/gajim/gtk/chat_banner.py
index 2fa7bf014..40d1a23db 100644
--- a/gajim/gtk/chat_banner.py
+++ b/gajim/gtk/chat_banner.py
@@ -99,6 +99,7 @@ class ChatBanner(Gtk.Box, EventHelper):
self._set_chat_menu(contact)
self._update_phone_image()
+ self._update_robot_image()
self._update_roster_button()
self._update_avatar()
self._update_visitor_button()
@@ -186,8 +187,8 @@ class ChatBanner(Gtk.Box, EventHelper):
_contact: types.BareContact,
_signal_name: str
) -> None:
-
self._update_avatar()
+ self._update_robot_image()
def _on_muc_state_changed(self,
contact: GroupchatContact,
@@ -257,6 +258,13 @@ class ChatBanner(Gtk.Box, EventHelper):
self._ui.phone_image.set_visible(
self._contact in self._last_message_from_phone)
+ def _update_robot_image(self) -> None:
+ if isinstance(self._contact, BareContact):
+ self._ui.robot_image.set_visible(self._contact.is_gateway
+ or self._contact.is_bot)
+ else:
+ self._ui.robot_image.set_visible(False)
+
def _update_roster_button(self) -> None:
self._ui.toggle_roster_button.set_visible(
isinstance(self._contact, GroupchatContact))