From 83adf75c3246615de5ba9a3e8785b8054f117882 Mon Sep 17 00:00:00 2001 From: nicoco Date: Thu, 28 Sep 2023 02:27:28 +0200 Subject: feat: StartChat: Show roster groups References: https://dev.gajim.org/gajim/gajim/-/issues/11625 --- gajim/data/style/gajim.css | 12 ++++++++++++ gajim/gtk/start_chat.py | 7 +++++++ gajim/gtk/util.py | 17 +++++++++++++++++ 3 files changed, 36 insertions(+) diff --git a/gajim/data/style/gajim.css b/gajim/data/style/gajim.css index 7a7cd7705..afe2f8cfc 100644 --- a/gajim/data/style/gajim.css +++ b/gajim/data/style/gajim.css @@ -224,6 +224,18 @@ infobar.error > revealer > box { font-weight: lighter; } +.group { + color: rgb(242, 242, 242); + padding-left: 6px; + padding-right: 6px; + padding-top: 2px; + padding-bottom: 2px; + border-radius: 4px; + font-size: 80%; + font-weight: bold; + background-color: rgb(128, 128, 128); +} + .link-button { min-height: 0px; } .floating-overlay-box { diff --git a/gajim/gtk/start_chat.py b/gajim/gtk/start_chat.py index 37dc8e4db..abdbc3a0f 100644 --- a/gajim/gtk/start_chat.py +++ b/gajim/gtk/start_chat.py @@ -59,6 +59,7 @@ from gajim.gtk.tooltips import ContactTooltip from gajim.gtk.util import AccountBadge from gajim.gtk.util import GajimPopover from gajim.gtk.util import get_icon_name +from gajim.gtk.util import GroupBadge from gajim.gtk.util import IdleBadge ContactT = BareContact | GroupchatContact @@ -819,6 +820,12 @@ class ContactRow(Gtk.ListBoxRow): idle_badge = IdleBadge(idle) name_box.add(idle_badge) + if contact and not contact.is_groupchat and not contact.is_pm_contact: + groups = contact.groups + for group in groups: + account_badge = GroupBadge(group) + name_box.add(account_badge) + box.add(name_box) if contact and not contact.is_groupchat and (status := contact.status): diff --git a/gajim/gtk/util.py b/gajim/gtk/util.py index 5ce5c1d2f..22e9b2a51 100644 --- a/gajim/gtk/util.py +++ b/gajim/gtk/util.py @@ -796,6 +796,23 @@ def wrap_with_event_box(klass: Any) -> Any: return klass_wrapper +class GroupBadge(Gtk.Label): + def __init__(self, group: str) -> None: + Gtk.Label.__init__( + self, + ellipsize=Pango.EllipsizeMode.END, + no_show_all=True, + halign=Gtk.Align.END, + valign=Gtk.Align.START, + hexpand=True, + tooltip_text=group, + ) + self.set_size_request(50, -1) + self.get_style_context().add_class('group') + self.set_text(group) + self.show() + + class IdleBadge(Gtk.Label): def __init__(self, idle: datetime | None = None) -> None: Gtk.Label.__init__( -- cgit v1.2.3