Daniel Brötzmann pushed to branch mainwindow at gajim / gajim
Commits: b390c7d7 by wurstsalat at 2021-03-23T23:01:46+01:00 NotificationManager: Improve display
- - - - -
3 changed files:
- gajim/data/gui/account_page.ui - gajim/data/style/gajim.css - gajim/gtk/notification_manager.py
Changes:
===================================== gajim/data/gui/account_page.ui ===================================== @@ -120,7 +120,6 @@ <object class="GtkBox" id="account_box"> <property name="visible">True</property> <property name="can-focus">False</property> - <property name="halign">center</property> <property name="hexpand">True</property> <property name="orientation">vertical</property> <property name="spacing">18</property> @@ -235,6 +234,7 @@ <object class="GtkLabel"> <property name="visible">True</property> <property name="can-focus">False</property> + <property name="margin-top">6</property> <property name="label" translatable="yes">Notifications</property> <style> <class name="bold16"/>
===================================== gajim/data/style/gajim.css ===================================== @@ -157,6 +157,13 @@ .roster treeview { padding: 0 3px; } +/* Notification listbox */ +.notification-listbox { + background: transparent; +} +.notification-listbox row { + padding: 6px; +}
/*Middle Grid*/ .middle-grid > scrolledwindow { background: transparent; }
===================================== gajim/gtk/notification_manager.py ===================================== @@ -18,6 +18,7 @@ from gi.repository import Pango
from gajim.common import app +from gajim.common.const import AvatarSize from gajim.common.i18n import _
from gajim.gui_menu_builder import get_subscription_menu @@ -32,10 +33,12 @@ def __init__(self, account): self._account = account self._client = app.get_client(account)
- self.set_size_request(400, 200) + self.set_vexpand(True)
self._listbox = Gtk.ListBox() self._listbox.set_selection_mode(Gtk.SelectionMode.NONE) + self._listbox.set_halign(Gtk.Align.CENTER) + self._listbox.get_style_context().add_class('notification-listbox') self._set_placeholder()
self.add(self._listbox) @@ -165,7 +168,6 @@ def __init__(self, account, jid): self._account = account self._client = app.get_client(account) self.jid = jid - self.get_style_context().add_class('padding-6')
self.grid = Gtk.Grid(column_spacing=12) self.add(self.grid) @@ -179,15 +181,21 @@ def _generate_label(): label.set_max_width_chars(30) return label
+ def _generate_avatar_image(self, jid): + contact = self._client.get_module('Contacts').get_contact(jid) + surface = contact.get_avatar( + AvatarSize.ROSTER, self.get_scale_factor(), add_show=False) + image = Gtk.Image.new_from_surface(surface) + image.set_valign(Gtk.Align.CENTER) + return image +
class SubscriptionRequestRow(NotificationRow): def __init__(self, account, jid, text, user_nick=None): NotificationRow.__init__(self, account, jid) self.type = 'subscribe'
- image = Gtk.Image.new_from_icon_name( - 'avatar-default-symbolic', Gtk.IconSize.DND) - image.set_valign(Gtk.Align.CENTER) + image = self._generate_avatar_image(jid) self.grid.attach(image, 1, 1, 1, 2)
if user_nick is not None: @@ -232,9 +240,7 @@ def __init__(self, account, jid): NotificationRow.__init__(self, account, jid) self.type = 'unsubscribed'
- image = Gtk.Image.new_from_icon_name( - 'avatar-default-symbolic', Gtk.IconSize.DND) - image.set_valign(Gtk.Align.CENTER) + image = self._generate_avatar_image(jid) self.grid.attach(image, 1, 1, 1, 2)
contact = self._client.get_module('Contacts').get_contact(jid) @@ -244,7 +250,7 @@ def __init__(self, account, jid): nick_label.set_markup(nick_markup) self.grid.attach(nick_label, 2, 1, 1, 1)
- message_text = _('Stopped sharing their status') + message_text = _('Stopped sharing their status with you') text_label = self._generate_label() text_label.set_text(message_text) text_label.set_tooltip_text(message_text) @@ -279,9 +285,7 @@ def __init__(self, account, event):
self._event = event
- image = Gtk.Image.new_from_icon_name( - 'system-users-symbolic', Gtk.IconSize.DND) - image.set_valign(Gtk.Align.CENTER) + image = self._generate_avatar_image(event.from_) self.grid.attach(image, 1, 1, 1, 2)
title_label = self._generate_label() @@ -331,9 +335,7 @@ def __init__(self, account, event): NotificationRow.__init__(self, account, event.muc) self.type = 'invitation-declined'
- image = Gtk.Image.new_from_icon_name( - 'system-users-symbolic', Gtk.IconSize.DND) - image.set_valign(Gtk.Align.CENTER) + image = self._generate_avatar_image(event.from_) self.grid.attach(image, 1, 1, 1, 2)
title_label = self._generate_label()
View it on GitLab: https://dev.gajim.org/gajim/gajim/-/commit/b390c7d7c04f702972d415244df19af0e...