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

Commits:

1 changed file:

Changes:

  • gajim/gtk/notification.py
    ... ... @@ -247,11 +247,13 @@ class Linux(NotificationBackend):
    247 247
         def __init__(self):
    
    248 248
             NotificationBackend.__init__(self)
    
    249 249
             self._dbus_available: bool = False
    
    250
    -        self._daemon_capabilities = ['actions']
    
    250
    +        self._caps: list[str] = []
    
    251 251
             self._detect_dbus_caps()
    
    252
    +        log.info('Detected notification capabilities: %s', self._caps)
    
    252 253
     
    
    253 254
         def _detect_dbus_caps(self) -> None:
    
    254
    -        if app.is_flatpak():
    
    255
    +        if app.is_flatpak() or app.desktop_env == 'gnome':
    
    256
    +            self._caps = ['actions']
    
    255 257
                 self._dbus_available = True
    
    256 258
                 return
    
    257 259
     
    
    ... ... @@ -259,7 +261,7 @@ def on_proxy_ready(_source: Gio.DBusProxy,
    259 261
                                res: Gio.AsyncResult) -> None:
    
    260 262
                 try:
    
    261 263
                     proxy = Gio.DBusProxy.new_finish(res)
    
    262
    -                self._daemon_capabilities = proxy.GetCapabilities()  # type: ignore
    
    264
    +                self._caps = proxy.GetCapabilities()  # type: ignore
    
    263 265
                 except GLib.Error as error:
    
    264 266
                     log.warning('Notifications D-Bus not available: %s', error)
    
    265 267
                 else:
    
    ... ... @@ -282,8 +284,13 @@ def _send(self, event: events.Notification) -> None:
    282 284
     
    
    283 285
             notification = Gio.Notification()
    
    284 286
             if event.title is not None:
    
    285
    -            notification.set_title(GLib.markup_escape_text(event.title))
    
    286
    -        notification.set_body(GLib.markup_escape_text(event.text))
    
    287
    +            notification.set_title(event.title)
    
    288
    +
    
    289
    +        text = event.text
    
    290
    +        if 'body-markup' in self._caps:
    
    291
    +            text = GLib.markup_escape_text(event.text)
    
    292
    +
    
    293
    +        notification.set_body(text)
    
    287 294
             notification.set_priority(Gio.NotificationPriority.NORMAL)
    
    288 295
     
    
    289 296
             icon = self._make_icon(event)
    
    ... ... @@ -302,7 +309,7 @@ def _add_actions(self,
    302 309
             if event.type not in self._action_types:
    
    303 310
                 return
    
    304 311
     
    
    305
    -        if 'actions' not in self._daemon_capabilities:
    
    312
    +        if 'actions' not in self._caps:
    
    306 313
                 return
    
    307 314
     
    
    308 315
             jid = ''