Skip to content

Commit 74155ce

Browse files
committed
When running inside a Snap set app ID for Unity Launcher integration separately
Inside the snap package the app ID is always "{snap}_{part}.desktop", in our case picard_picard.desktop.
1 parent 335f1f0 commit 74155ce

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

picard/ui/statusindicator/unity.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#
33
# Picard, the next-generation MusicBrainz tagger
44
#
5-
# Copyright (C) 2019-2023 Philipp Wolfer
5+
# Copyright (C) 2019-2023, 2026 Philipp Wolfer
66
# Copyright (C) 2020 Julius Michaelis
77
# Copyright (C) 2020-2021, 2023-2024 Laurent Monin
88
# Copyright (C) 2021 Gabriel Ferreira
@@ -20,6 +20,8 @@
2020
# You should have received a copy of the GNU General Public License
2121
# along with this program; if not, see <https://www.gnu.org/licenses/>.
2222

23+
import os
24+
2325
from PyQt6.QtCore import (
2426
QObject,
2527
pyqtClassInfo,
@@ -30,17 +32,19 @@
3032
QDBusConnection,
3133
QDBusMessage,
3234
)
35+
from PyQt6.QtWidgets import QMainWindow
3336

3437
from picard import PICARD_DESKTOP_NAME
3538

3639
from . import AbstractProgressStatusIndicator
3740

3841

3942
DBUS_INTERFACE = 'com.canonical.Unity.LauncherEntry'
43+
APP_ID = PICARD_DESKTOP_NAME if not os.getenv('SNAP') else 'picard_picard.desktop'
4044

4145

4246
class UnityLauncherEntryService(QObject):
43-
def __init__(self, bus, app_id):
47+
def __init__(self, bus: QDBusConnection, app_id: str):
4448
super().__init__()
4549
self._bus = bus
4650
self._app_uri = 'application://' + app_id
@@ -61,7 +65,7 @@ def current_progress(self):
6165
def is_available(self):
6266
return self._available
6367

64-
def update(self, progress, visible=True):
68+
def update(self, progress: float, visible: bool = True) -> None:
6569
self._progress = progress
6670
self._visible = visible
6771
# Automatic forwarding of Qt signals does not work in this case
@@ -101,10 +105,10 @@ def query(self):
101105

102106

103107
class UnityLauncherEntryStatusIndicator(AbstractProgressStatusIndicator):
104-
def __init__(self, window):
108+
def __init__(self, window: QMainWindow):
105109
super().__init__()
106110
bus = QDBusConnection.sessionBus()
107-
self._service = UnityLauncherEntryService(bus, PICARD_DESKTOP_NAME)
111+
self._service = UnityLauncherEntryService(bus, APP_ID)
108112

109113
@property
110114
def is_available(self):

0 commit comments

Comments
 (0)