diff options
author | Huang Peng <shawn.p.huang@gmail.com> | 2008-10-06 14:47:06 +0800 |
---|---|---|
committer | Huang Peng <shawn.p.huang@gmail.com> | 2008-10-06 14:47:06 +0800 |
commit | 61c603838a15b01011093090065ed33116cdda13 (patch) | |
tree | 926251ac4ae87f09ec1b13ee737bfae6313a4e67 /ui/gtk/notifications.py | |
parent | d4bb8eb1c6c36e43a5a9504717aeb64832c66538 (diff) | |
download | ibus-61c603838a15b01011093090065ed33116cdda13.tar.gz ibus-61c603838a15b01011093090065ed33116cdda13.tar.xz ibus-61c603838a15b01011093090065ed33116cdda13.zip |
WIP.
Diffstat (limited to 'ui/gtk/notifications.py')
-rw-r--r-- | ui/gtk/notifications.py | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/ui/gtk/notifications.py b/ui/gtk/notifications.py index 37f0ecf..6f77df0 100644 --- a/ui/gtk/notifications.py +++ b/ui/gtk/notifications.py @@ -41,25 +41,41 @@ class Notifications(ibus.NotificationsBase): self.__dbus = dbus.SessionBus() self.__notifications = self.__dbus.get_object( "org.freedesktop.Notifications", "/org/freedesktop/Notifications") + self.__notifications.connect_to_signal("NotificationClosed", + self.__notification_closed_cb, + dbus_interface="org.freedesktop.Notifications") + self.__notifications.connect_to_signal("ActionInvoked", + self.__action_invoked_cb, + dbus_interface="org.freedesktop.Notifications") + self.__ids = set([]) + def notify(self, replaces_id, app_icon, summary, body, actions, expire_timeout): + if app_icon == "": + app_icon = "ibus" hints = dbus.Dictionary(signature="sv") - hints["desktop-entry"] = "ibus" - hints["x"] = 0 - hints["y"] = 0 - return self.__notifications.Notify("ibus", - replaces_id, + id = self.__notifications.Notify("ibus", + dbus.UInt32(replaces_id), app_icon, summary, body, actions, hints, expire_timeout) + self.__ids.add(id) + return id def close_notification(self, id): return self.__notifications.CloseNotifications(id) - def notification_closed(self, id, reason): - self.__proxy.NotificationClosed(id, reason) + def __notification_closed_cb(self, id, reason): + if id in self.__ids: + self.notification_closed(id, reason) + + def __action_invoked_cb(self, id, action_key): + if id in self.__ids: + self.action_invoked(id, action_key) - def action_invoked(self, id, action_key): - self.__proxy.ActionInvoked(id, action_key) +if __name__ == "__main__": + notify = Notifications(ibus.Bus()) + notify.notify(0, "", "Hello Summary", "Hello Body", ["NoAgain", "Do not show me again"], 5000) + ibus.main() |