roundabout,
created on Wednesday, 24 September 2025, 15:23:11 (1758727391),
received on Wednesday, 24 September 2025, 15:23:14 (1758727394)
Author identity: Vlad <vlad.muntoiu@gmail.com>
c2554b1609b50adb1b423ed4c688b17c4c43543f
applets/notifier/__init__.py
@@ -78,6 +78,9 @@ class NotificationsService:
<arg type="i" name="expire_timeout" direction="in"/>
<arg type="u" name="id" direction="out"/>
</method>
<method name="CloseNotification">
<arg type="u" name="id" direction="in"/>
</method>
</interface>
</node>
"""
@@ -96,9 +99,15 @@ class NotificationsService:
def Notify(self, *args):
notification_id = self._next_id
self._next_id += 1
self.applet.push_notification(*args)
self.applet.push_notification(*args, notification_id)
return notification_id
def CloseNotification(self, notification_id):
if notification_id in self.applet.notifications_by_id:
self.applet.notification_list.remove(self.applet.notifications_by_id[notification_id])
self.applet.notification_count_label.set_text(locale.format_string('%d', self.applet.notification_count - 1))
self.applet.notification_count -= 1
class BriefNotification(Gtk.Box):
def __init__(self, app_name, replaces_id, app_icon, summary, body, actions, hints, expire_timeout):
@@ -177,11 +186,12 @@ class NotifierApplet(panorama_panel.Applet):
# TODO: support the other parameters; add a popover with a history
self.append(self.button)
self.notifications_by_id = {}
self.service = NotificationsService(self)
bus = SessionBus()
self.publishing = bus.publish("org.freedesktop.Notifications", self.service)
def push_notification(self, app_name, replaces_id, app_icon, summary, body, actions, hints, expire_timeout):
def push_notification(self, app_name, replaces_id, app_icon, summary, body, actions, hints, expire_timeout, notification_id):
new_child = BriefNotification(app_name, replaces_id, app_icon, summary, body, actions, hints, expire_timeout)
new_child.image.set_pixel_size(self.icon_size)
self.stack.add_child(new_child)
@@ -204,7 +214,9 @@ class NotifierApplet(panorama_panel.Applet):
expire_timeout = 2500
GLib.timeout_add(expire_timeout, remove_notification)
self.notification_list.append(DetailedNotification(app_name, replaces_id, app_icon, summary, body, actions, hints, expire_timeout))
notification_info = DetailedNotification(app_name, replaces_id, app_icon, summary, body, actions, hints, expire_timeout)
self.notifications_by_id[notification_id] = notification_info
self.notification_list.append(notification_info)
self.notification_count_label.set_text(locale.format_string('%d', self.notification_count + 1))
self.notification_count += 1
# TODO: notify that it was closed