Philipp Hörist pushed to branch master at gajim / gajim

Commits:

2 changed files:

Changes:

  • gajim/data/gui/popup_notification_window.ui
    ... ... @@ -32,6 +32,10 @@
    32 32
                 <property name="visible">True</property>
    
    33 33
                 <property name="can_focus">False</property>
    
    34 34
                 <property name="icon_size">6</property>
    
    35
    +            <property name="margin-start">6</property>
    
    36
    +            <property name="margin-end">6</property>
    
    37
    +            <property name="margin-top">12</property>
    
    38
    +            <property name="valign">start</property>
    
    35 39
               </object>
    
    36 40
               <packing>
    
    37 41
                 <property name="expand">False</property>
    

  • gajim/gtk/notification.py
    ... ... @@ -176,8 +176,15 @@ def __init__(self, event: events.Notification, timeout: int) -> None:
    176 176
             self.add(self._ui.eventbox)
    
    177 177
     
    
    178 178
             self._add_background_color(event)
    
    179
    -        icon_name = self._get_icon_name(event)
    
    180
    -        self._ui.image.set_from_icon_name(icon_name, Gtk.IconSize.DIALOG)
    
    179
    +
    
    180
    +        if event.type == 'incoming-message':
    
    181
    +            assert event.jid is not None
    
    182
    +            pixbuf = _get_avatar_for_notification(
    
    183
    +                event.account, event.jid)
    
    184
    +            self._ui.image.set_from_pixbuf(pixbuf)
    
    185
    +        else:
    
    186
    +            icon_name = self._get_icon_name(event)
    
    187
    +            self._ui.image.set_from_icon_name(icon_name, Gtk.IconSize.DIALOG)
    
    181 188
             self._ui.event_type_label.set_text(event.title)
    
    182 189
             self._ui.event_description_label.set_text(event.text)
    
    183 190
     
    
    ... ... @@ -191,11 +198,12 @@ def __init__(self, event: events.Notification, timeout: int) -> None:
    191 198
             self.connect('destroy', self._on_destroy)
    
    192 199
             self.show_all()
    
    193 200
     
    
    194
    -    def _get_icon_name(self, event: events.Notification) -> str:
    
    201
    +    @staticmethod
    
    202
    +    def _get_icon_name(event: events.Notification) -> str:
    
    195 203
             if event.icon_name is not None:
    
    196 204
                 return event.icon_name
    
    197 205
             icon_name = event.sub_type or event.type
    
    198
    -        return NOTIFICATION_ICONS.get(icon_name, 'mail-unread')
    
    206
    +        return NOTIFICATION_ICONS.get(icon_name, 'gajim-chat_msg_recv')
    
    199 207
     
    
    200 208
         def _add_background_color(self, event: events.Notification) -> None:
    
    201 209
             event_type = event.sub_type or event.type
    
    ... ... @@ -368,22 +376,10 @@ def _make_notification_id(self,
    368 376
     
    
    369 377
             return None
    
    370 378
     
    
    371
    -    @staticmethod
    
    372
    -    def _get_avatar_for_notification(account: str,
    
    373
    -                                     jid: Union[JID, str]) -> GdkPixbuf.Pixbuf:
    
    374
    -        scale = get_monitor_scale_factor()
    
    375
    -        size = AvatarSize.NOTIFICATION
    
    376
    -        client = app.get_client(account)
    
    377
    -        contact = client.get_module('Contacts').get_contact(jid)
    
    378
    -        avatar_surface = contact.get_avatar(size, scale)
    
    379
    -        pixbuf = Gdk.pixbuf_get_from_surface(avatar_surface, 0, 0, size, size)
    
    380
    -        assert pixbuf is not None
    
    381
    -        return pixbuf
    
    382
    -
    
    383 379
         def _make_icon(self, event: events.Notification) -> Gio.Icon:
    
    384 380
             if (event.type == 'incoming-message' and app.desktop_env == 'gnome'):
    
    385 381
                 assert event.jid is not None
    
    386
    -            return self._get_avatar_for_notification(event.account, event.jid)
    
    382
    +            return _get_avatar_for_notification(event.account, event.jid)
    
    387 383
     
    
    388 384
             if event.icon_name is not None:
    
    389 385
                 return Gio.ThemedIcon.new(event.icon_name)
    
    ... ... @@ -405,6 +401,18 @@ def _make_id(details: list[Any]) -> str:
    405 401
             return ','.join(map(str, details))
    
    406 402
     
    
    407 403
     
    
    404
    +def _get_avatar_for_notification(account: str,
    
    405
    +                                 jid: Union[JID, str]) -> GdkPixbuf.Pixbuf:
    
    406
    +    scale = get_monitor_scale_factor()
    
    407
    +    size = AvatarSize.NOTIFICATION
    
    408
    +    client = app.get_client(account)
    
    409
    +    contact = client.get_module('Contacts').get_contact(jid)
    
    410
    +    avatar_surface = contact.get_avatar(size, scale)
    
    411
    +    pixbuf = Gdk.pixbuf_get_from_surface(avatar_surface, 0, 0, size, size)
    
    412
    +    assert pixbuf is not None
    
    413
    +    return pixbuf
    
    414
    +
    
    415
    +
    
    408 416
     def get_notification_backend() -> NotificationBackend:
    
    409 417
         if sys.platform == 'win32':
    
    410 418
             return Windows()