Daniel Brötzmann pushed to branch win-native-notifications-aumid at gajim /
gajim
Commits:
2f945fe5 by wurstsalat at 2024-07-02T20:56:56+02:00
imprv: Notifications: Register AUMID on Windows
This allows Gajim to present notifications with correct title and icon
- - - - -
2 changed files:
- + gajim/data/icons/hicolor/96x96/apps/org.gajim.Gajim.png
- gajim/gtk/notification.py
Changes:
=====================================
gajim/data/icons/hicolor/96x96/apps/org.gajim.Gajim.png
=====================================
Binary files /dev/null and
b/gajim/data/icons/hicolor/96x96/apps/org.gajim.Gajim.png differ
=====================================
gajim/gtk/notification.py
=====================================
@@ -58,6 +58,8 @@
from gajim.gtk.util import load_icon_surface
if sys.platform == 'win32' or TYPE_CHECKING:
+ import winreg
+
from windows_toasts import InteractableWindowsToaster
from windows_toasts import Toast
from windows_toasts import ToastActivatedEventArgs
@@ -67,6 +69,7 @@
from windows_toasts import ToastImagePosition
MIN_WINDOWS_TOASTS_WIN_VERSION = 10240
+WINDOWS_TOAST_NOTIFIER_AUMID = 'Gajim.ToastNotification'
log = logging.getLogger('gajim.gtk.notification')
@@ -285,7 +288,38 @@ def _on_destroy(self, _widget: Gtk.Window) -> None:
class WindowsToastNotification(NotificationBackend):
def __init__(self):
NotificationBackend.__init__(self)
- self._toaster = InteractableWindowsToaster(applicationText='Gajim')
+ self._register_notifier_aumid()
+
+ self._toaster = InteractableWindowsToaster(
+ applicationText='Gajim',
+ notifierAUMID=WINDOWS_TOAST_NOTIFIER_AUMID
+ )
+
+ def _register_notifier_aumid(self) -> None:
+ '''Register an AUMID for Gajim's toast notifications.
+ This allows notifications issued by Gajim to have the right icon and
title.
+ Code taken from:
https://github.com/DatGuy1/Windows-Toasts/blob/main/scripts/register_hkey_aumid.py
+ '''
+ key_path =
f'SOFTWARE\\Classes\\AppUserModelId\\{WINDOWS_TOAST_NOTIFIER_AUMID}'
+
+ image_path = (
+ Path(sys.executable).parent
+ / 'share'
+ / 'icons'
+ / 'hicolor'
+ / '96x96'
+ / 'org.gajim.Gajim.png'
+ )
+ winreg.ConnectRegistry(None, winreg.HKEY_CURRENT_USER)
+ with winreg.CreateKeyEx(winreg.HKEY_CURRENT_USER, key_path) as
master_key:
+ winreg.SetValueEx(master_key, 'DisplayName', 0, winreg.REG_SZ,
'Gajim')
+ winreg.SetValueEx(
+ master_key,
+ 'IconUri',
+ 0,
+ winreg.REG_SZ,
+ str(image_path.resolve())
+ )
def _send(self, event: events.Notification) -> None:
toast = Toast()
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/2f945fe57e3d13812023044095f57b07cce05715
--
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/2f945fe57e3d13812023044095f57b07cce05715
You're receiving this email because of your account on dev.gajim.org.
_______________________________________________
Commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]