This repository has been archived on 2023-09-06. You can view files and clone it, but cannot push or open issues/pull-requests.
yutent
/
py-gtk-notes
Archived
1
0
Fork 0
py-gtk-notes/notes/notify.py

39 lines
837 B
Python
Raw Permalink Normal View History

import gi
gi.require_version('Notify', '0.7') # gir1.2-notify-0.7
from gi.repository import Notify
class Notification():
def __init__(self, window):
Notify.init(Notify.get_app_name() or 'webapp')
self.window = window
self.notify = Notify.Notification()
def create(self, title, summary, icon, progress = 0, urgency = 0, callback = None):
self.notify.clear_actions()
self.notify.clear_hints()
self.notify.update(title, summary, icon)
if progress:
self.notify.set_hint('value', progress)
self.notify.set_urgency(urgency)
if callback:
self.notify.add_action("click", "click", self.action_callback, callback)
self.notify.show()
def action_callback(self, instance, action, callback):
if callback:
self.window.call_js(callback)
instance.close()