Philipp Hörist pushed to branch win-native-notifications-aumid at gajim / gajim
Commits:
00b27bf9 by wurstsalat at 2024-07-02T23:37:52+02:00
imprv: MessageRowActions: Adjust floating offset for merged messages
Fixes #11897
- - - - -
af1098f9 by wurstsalat at 2024-07-02T22:55:27+00:00
imprv: Notifications: Register AUMID on Windows
This allows Gajim to present notifications with correct title and icon
- - - - -
4 changed files:
- + gajim/data/icons/hicolor/96x96/apps/org.gajim.Gajim.png
- gajim/gtk/conversation/rows/message.py
- gajim/gtk/conversation/rows/widgets.py
- 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/conversation/rows/message.py
=====================================
@@ -117,6 +117,10 @@ def message_id(self) -> str | None:
def has_receipt(self) -> bool:
return self._has_receipt
+ @property
+ def is_merged(self) -> bool:
+ return self._merged
+
def refresh(self, *, complete: bool = True) -> None:
original_message = app.storage.archive.get_message_with_pk(
self.orig_pk)
=====================================
gajim/gtk/conversation/rows/widgets.py
=====================================
@@ -118,8 +118,12 @@ def update(self, y_coord: int, message_row: MessageRow) ->
None:
if y_coord < self_height:
y_coord = self_height
- # Subtract 12 to let MessageRowActions 'flow' above the row
- adjusted_y_coord = y_coord - 12
+ # Subtract some space to let MessageRowActions 'flow' above the row
+ offset = 12
+ if self._message_row.is_merged:
+ offset = 24
+
+ adjusted_y_coord = y_coord - offset
if adjusted_y_coord < 0:
adjusted_y_coord = 0
=====================================
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/-/compare/2f945fe57e3d13812023044095f57b07cce05715...af1098f9f2c00cfcc9ed080809a80c6e6c3534ab
--
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/compare/2f945fe57e3d13812023044095f57b07cce05715...af1098f9f2c00cfcc9ed080809a80c6e6c3534ab
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]