diff options
author | Huang Peng <shawn.p.huang@gmail.com> | 2008-10-06 15:00:01 +0800 |
---|---|---|
committer | Huang Peng <shawn.p.huang@gmail.com> | 2008-10-06 15:00:01 +0800 |
commit | 59a0435b1a8fbb2e2f80bfe79057cbd5eb3da815 (patch) | |
tree | 796a01d6ffe1ea3cc4a31892fed7d2535fa22873 /ui/gtk/notifications.py | |
parent | 61c603838a15b01011093090065ed33116cdda13 (diff) | |
download | ibus-59a0435b1a8fbb2e2f80bfe79057cbd5eb3da815.tar.gz ibus-59a0435b1a8fbb2e2f80bfe79057cbd5eb3da815.tar.xz ibus-59a0435b1a8fbb2e2f80bfe79057cbd5eb3da815.zip |
WIP.
Diffstat (limited to 'ui/gtk/notifications.py')
-rw-r--r-- | ui/gtk/notifications.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/ui/gtk/notifications.py b/ui/gtk/notifications.py index 6f77df0..a0fa233 100644 --- a/ui/gtk/notifications.py +++ b/ui/gtk/notifications.py @@ -38,6 +38,7 @@ class Notifications(ibus.NotificationsBase): def __init__ (self, bus): super(Notifications, self).__init__(bus) self.__bus = bus + self.__bus.request_name(ibus.IBUS_NOTIFICATIONS_NAME, 0) self.__dbus = dbus.SessionBus() self.__notifications = self.__dbus.get_object( "org.freedesktop.Notifications", "/org/freedesktop/Notifications") @@ -48,11 +49,19 @@ class Notifications(ibus.NotificationsBase): self.__action_invoked_cb, dbus_interface="org.freedesktop.Notifications") self.__ids = set([]) + self.__status_icons = None + + def set_status_icon(self, status_icon): + self.__status_icon = status_icon def notify(self, replaces_id, app_icon, summary, body, actions, expire_timeout): if app_icon == "": app_icon = "ibus" hints = dbus.Dictionary(signature="sv") + if self.__status_icon != None: + rect = self.__status_icon.get_geometry()[1] + hints["x"] = rect.x + rect.width / 2 + hints["y"] = rect.y + rect.height / 2 id = self.__notifications.Notify("ibus", dbus.UInt32(replaces_id), app_icon, @@ -76,6 +85,11 @@ class Notifications(ibus.NotificationsBase): self.action_invoked(id, action_key) if __name__ == "__main__": + import gtk + icon = gtk.StatusIcon() + icon.set_visible(True) notify = Notifications(ibus.Bus()) + notify.set_status_icon(icon) + while ibus.main_iteration(): pass notify.notify(0, "", "Hello Summary", "Hello Body", ["NoAgain", "Do not show me again"], 5000) ibus.main() |