From 8f0325177c33a37906df234b1023c2343fa25a21 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andr=C3=A9=20Apitzsch?= <git@apitzsch.eu>
Date: Sat, 11 Jun 2022 14:25:43 +0200
Subject: [PATCH] fix: Flatpak: Fix display of tray icon using libappindicator

Appindicator cannot access custom icons in flatpak. That's why the status is limited to
* online state (gajim icon) and
* new message state

Fixes: #10869
---
 flatpak/org.gajim.Gajim.Devel.yaml | 2 ++
 flatpak/org.gajim.Gajim.yaml       | 2 ++
 gajim/gtk/status_icon.py           | 5 ++++-
 3 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/flatpak/org.gajim.Gajim.Devel.yaml b/flatpak/org.gajim.Gajim.Devel.yaml
index b7d0249bf8..32e5274909 100644
--- a/flatpak/org.gajim.Gajim.Devel.yaml
+++ b/flatpak/org.gajim.Gajim.Devel.yaml
@@ -26,6 +26,8 @@ finish-args:
   - --talk-name=org.kde.kwalletd5
   # Notifications
   - --talk-name=org.freedesktop.Notifications
+  # tray/status icon
+  - --talk-name=org.kde.StatusNotifierWatcher
   # GnuPG
   - --filesystem=~/.gnupg
   # camera access
diff --git a/flatpak/org.gajim.Gajim.yaml b/flatpak/org.gajim.Gajim.yaml
index 93d38ad2ed..448a7c7652 100644
--- a/flatpak/org.gajim.Gajim.yaml
+++ b/flatpak/org.gajim.Gajim.yaml
@@ -19,6 +19,8 @@ finish-args:
   - --talk-name=org.kde.kwalletd5
   # Notifications
   - --talk-name=org.freedesktop.Notifications
+  # tray/status icon
+  - --talk-name=org.kde.StatusNotifierWatcher
   # GnuPG
   - --filesystem=~/.gnupg
   # camera access
diff --git a/gajim/gtk/status_icon.py b/gajim/gtk/status_icon.py
index 077bfcd07b..d32afca7a7 100644
--- a/gajim/gtk/status_icon.py
+++ b/gajim/gtk/status_icon.py
@@ -298,7 +298,7 @@ def __init__(self) -> None:
 
         self._status_icon = appindicator.Indicator.new(
             'Gajim',
-            'dcraven-online',
+            'org.gajim.Gajim',
             appindicator.IndicatorCategory.COMMUNICATIONS)
         self._status_icon.set_icon_theme_path(str(configpaths.get('ICONS')))
         self._status_icon.set_status(appindicator.IndicatorStatus.ACTIVE)
@@ -320,6 +320,9 @@ def update_state(self, init: bool = False) -> None:
             self._status_icon.set_icon_full(icon_name, _('Pending Event'))
             return
 
+        if app.is_flatpak():
+            return
+
         show = get_global_show()
         icon_name = get_icon_name(show)
         self._status_icon.set_icon_full(icon_name, show)
-- 
GitLab