Commit f9c25591 authored by Nico's avatar Nico
Browse files

Show online status of contacts in contact list

Using the icons from the Android client:
https://code.briarproject.org/briar/briar/-/blob/release-1.2.9/briar-android/src/main/res/drawable/contact_connected.xml

Fixes #19.
parent ef677383
Pipeline #4635 passed with stage
in 4 minutes and 13 seconds
......@@ -4,6 +4,9 @@
image: debian:buster-backports
variables:
GIT_SUBMODULE_STRATEGY: recursive
before_script:
- apt update && apt install --no-install-recommends -y gir1.2-gtk-3.0 python3-gi python3-pip python3-setuptools
- apt install --no-install-recommends -y -t buster-backports libhandy-0.0-dev
......
......@@ -162,6 +162,7 @@ class MainWindowContainer(Container):
for signal in self._signals:
APP().api.socket_listener.disconnect(signal)
# pylint: disable=no-member
def _load_content(self):
self._contacts = Contacts(APP().api)
self._load_contacts()
......@@ -172,6 +173,9 @@ class MainWindowContainer(Container):
signal_id = socket_listener.connect("ConversationMessageReceivedEvent",
self._refresh_contacts_async)
self._signals.append(signal_id)
callback = self._refresh_contact_state
signal_ids = self._contacts.watch_connections(callback)
self._signals.extend(signal_ids)
def _load_contacts(self):
self.contacts_list = self._contacts.get()
......@@ -190,6 +194,10 @@ class MainWindowContainer(Container):
def _refresh_contacts_async(self, message):
GLib.idle_add(self._refresh_contacts)
# pylint: disable=unused-argument
def _refresh_contact_state(self, contact_id, connected):
self._refresh_contacts_async(None)
def _refresh_contacts(self):
self._save_selected_row()
self._clear_contact_list()
......
......@@ -17,10 +17,13 @@ class ContactRowWidget(Gtk.ListBoxRow):
def _setup_view(self, contact):
name = ContactRowWidget._get_contact_name(contact)
contact_label = ContactRowWidget._create_contact_label(name)
connected = contact["connected"]
contact_state = ContactRowWidget._create_contact_state(connected)
contact_box = ContactRowWidget._create_contact_box()
contact_event_box = Gtk.EventBox().new()
contact_box.pack_start(contact_label, True, True, 0)
contact_box.pack_end(contact_state, False, False, 0)
contact_event_box.add(contact_box)
self.add(contact_event_box)
......@@ -42,6 +45,15 @@ class ContactRowWidget(Gtk.ListBoxRow):
contact_label.set_ellipsize(Pango.EllipsizeMode.END)
return contact_label
@staticmethod
def _create_contact_state(connected):
file_name = "contact_disconnected"
if connected is True:
file_name = "contact_connected"
contact_state = Gtk.Image.new_from_icon_name(file_name,
Gtk.IconSize.MENU)
return contact_state
@staticmethod
def _create_contact_box():
contact_box = Gtk.Box.new(Gtk.Orientation.HORIZONTAL, 5)
......
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
id="vector"
opacity="0.56">
<path
id="path"
d="M 12 2 C 6.48 2 2 6.48 2 12 C 2 17.52 6.48 22 12 22 C 17.52 22 22 17.52 22 12 C 22 6.48 17.52 2 12 2 Z M 12 20 C 7.58 20 4 16.42 4 12 C 4 7.58 7.58 4 12 4 C 16.42 4 20 7.58 20 12 C 20 16.42 16.42 20 12 20 Z"
fill="#000000"/>
<path
id="path_1"
d="M 0 0 L 24 0 L 24 24 L 0 24 Z"
fill="none"/>
<path
id="path_2"
d="M 10.897 19.95 C 6.551 19.349 3.431 15.215 4.063 10.896 C 4.555 7.531 7.095 4.824 10.394 4.147 C 14.257 3.355 18.17 5.543 19.524 9.253 C 20.07 10.749 20.162 12.461 19.777 13.976 C 19.546 14.886 18.811 16.339 18.207 17.077 C 16.49 19.178 13.581 20.322 10.897 19.95 Z"
fill="#82c91e"
stroke-width="0.76779664"
stroke-linecap="round"
stroke-linejoin="round"/>
<path
id="path_3"
d="M 10.897 19.95 C 6.551 19.349 3.431 15.215 4.063 10.896 C 4.555 7.531 7.095 4.824 10.394 4.147 C 14.257 3.355 18.17 5.543 19.524 9.253 C 20.07 10.749 20.162 12.461 19.777 13.976 C 19.546 14.886 18.811 16.339 18.207 17.077 C 16.49 19.178 13.581 20.322 10.897 19.95 Z"
fill="#82c91e"
stroke="#ffffff"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"/>
<path
id="path_4"
d="M 10.897 19.95 C 6.551 19.349 3.431 15.215 4.063 10.896 C 4.555 7.531 7.095 4.824 10.394 4.147 C 14.257 3.355 18.17 5.543 19.524 9.253 C 20.07 10.749 20.162 12.461 19.777 13.976 C 19.546 14.886 18.811 16.339 18.207 17.077 C 16.49 19.178 13.581 20.322 10.897 19.95 Z"
fill="#2e3d4f"
stroke="#ffffff"
stroke-width="1"
stroke-linecap="round"
stroke-linejoin="round"/>
<path
id="path_5"
d="M 10.897 19.95 C 6.551 19.349 3.431 15.215 4.063 10.896 C 4.555 7.531 7.095 4.824 10.394 4.147 C 14.257 3.355 18.17 5.543 19.524 9.253 C 20.07 10.749 20.162 12.461 19.777 13.976 C 19.546 14.886 18.811 16.339 18.207 17.077 C 16.49 19.178 13.581 20.322 10.897 19.95 Z"
fill="#2e3d4f"
stroke="#ffffff"
stroke-width="1"
stroke-linecap="round"
stroke-linejoin="round"/>
<path
id="path_6"
d="M 12 2 C 6.48 2 2 6.48 2 12 C 2 17.52 6.48 22 12 22 C 17.52 22 22 17.52 22 12 C 22 6.48 17.52 2 12 2 Z M 12 20 C 7.58 20 4 16.42 4 12 C 4 7.58 7.58 4 12 4 C 16.42 4 20 7.58 20 12 C 20 16.42 16.42 20 12 20 Z"
fill="#000000"/>
<path
id="path_7"
d="M 12 2 C 6.48 2 2 6.48 2 12 C 2 17.52 6.48 22 12 22 C 17.52 22 22 17.52 22 12 C 22 6.48 17.52 2 12 2 Z M 12 20 C 7.58 20 4 16.42 4 12 C 4 7.58 7.58 4 12 4 C 16.42 4 20 7.58 20 12 C 20 16.42 16.42 20 12 20 Z"
fill="#000000"/>
<path
id="path_8"
d="M 0 0 L 24 0 L 24 24 L 0 24 Z"
fill="none"/>
<path
id="path_9"
d="M 10.897 19.95 C 6.551 19.349 3.431 15.215 4.063 10.896 C 4.555 7.531 7.095 4.824 10.394 4.147 C 14.257 3.355 18.17 5.543 19.524 9.253 C 20.07 10.749 20.162 12.461 19.777 13.976 C 19.546 14.886 18.811 16.339 18.207 17.077 C 16.49 19.178 13.581 20.322 10.897 19.95 Z"
fill="#82c91e"
stroke-width="0.76779664"
stroke-linecap="round"
stroke-linejoin="round"/>
</svg>
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
id="vector"
opacity="0.56">
<path
id="path"
d="M 12 2 C 6.48 2 2 6.48 2 12 C 2 17.52 6.48 22 12 22 C 17.52 22 22 17.52 22 12 C 22 6.48 17.52 2 12 2 Z M 12 20 C 7.58 20 4 16.42 4 12 C 4 7.58 7.58 4 12 4 C 16.42 4 20 7.58 20 12 C 20 16.42 16.42 20 12 20 Z"
fill="#000000"/>
</svg>
Subproject commit d737307b0a61638aedd778ba6d27ce275fcf3aaa
Subproject commit 8969b057730f5ac9d6f061cc68fcbf69ecc2ceb1
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment