[Dextrose] [PATCH] Yum-updater notifications integration
Martin Abente
martin.abente.lahaye at gmail.com
Mon Dec 20 14:56:59 EST 2010
From: Aleksey Lim <alsroot at member.fsf.org>
Original-code: http://wiki.sugarlabs.org/go/Dextrose/Updater
dextrose-port-by: Martin Abente <martin.abente.lahaye at gmail.com>
---
src/jarabe/desktop/homewindow.py | 32 ++++++++++++++++++++++++++++++++
1 files changed, 32 insertions(+), 0 deletions(-)
diff --git a/src/jarabe/desktop/homewindow.py b/src/jarabe/desktop/homewindow.py
index d830ed0..bd5daf7 100644
--- a/src/jarabe/desktop/homewindow.py
+++ b/src/jarabe/desktop/homewindow.py
@@ -17,6 +17,8 @@
import logging
import gtk
+import dbus
+from gettext import gettext as _
from sugar.graphics import style
from sugar.graphics import palettegroup
@@ -27,12 +29,19 @@ from jarabe.desktop.groupbox import GroupBox
from jarabe.desktop.transitionbox import TransitionBox
from jarabe.model.shell import ShellModel
from jarabe.model import shell
+from jarabe.model import notifications
_HOME_PAGE = 0
_GROUP_PAGE = 1
_MESH_PAGE = 2
_TRANSITION_PAGE = 3
+_DBUS_SYSTEM_IFACE = 'org.sugarlabs.system'
+_DBUS_SYSTEM_PATH = '/org/sugarlabs/system'
+_SYSTEM_REBOOT_ID = -1
+_SYSTEM_RELOGIN_ID = -2
+_SYSTEM_TIMEOUT = 5
+
class HomeWindow(gtk.Window):
def __init__(self):
logging.debug('STARTUP: Loading the desktop window')
@@ -72,6 +81,29 @@ class HomeWindow(gtk.Window):
shell.get_model().zoom_level_changed.connect(
self.__zoom_level_changed_cb)
+ systembus = dbus.SystemBus()
+ systembus.add_signal_receiver(self.__reboot_cb, 'Reboot',
+ _DBUS_SYSTEM_IFACE)
+ systembus.add_signal_receiver(self.__relogin_cb, 'Relogin',
+ _DBUS_SYSTEM_IFACE)
+
+ def _system_alert(self, replaces_id, app_icon, message):
+ service = notifications.get_service()
+ service.notification_received.send(self,app_name='system',
+ replaces_id=replaces_id, app_icon=app_icon,
+ summary=_('System alert'), body=message,
+ actions=[], hints={})
+
+ def __reboot_cb(self):
+ self._system_alert(_SYSTEM_REBOOT_ID, 'system-restart',
+ _('Please, reboot your computer to take into account ' \
+ 'new updates'))
+
+ def __relogin_cb(self):
+ self._system_alert(_SYSTEM_RELOGIN_ID, 'system-logout',
+ _('Please, restart Sugar to take into account ' \
+ 'new updates'))
+
def _deactivate_view(self, level):
group = palettegroup.get_group("default")
group.popdown()
--
1.7.1
More information about the Dextrose
mailing list