Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/rpms/sugar/0003-Yum-updater-notifications-integration.patch
blob: 8e2418d5fdbf79238f4b7061a9b73ac4880f9eab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
From patchwork Wed Feb 16 21:16:59 2011
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Subject: [Sugar] Yum-updater notifications integration
Date: Thu, 17 Feb 2011 02:16:59 -0000
From: Martin Abente <martin.abente.lahaye@gmail.com>
X-Patchwork-Id: 675
Message-Id: <1297891019-18618-1-git-send-email-martin.abente.lahaye@gmail.com>
To: dextrose@lists.sugarlabs.org,
	anish@sugarlabs.org
Cc: Aleksey Lim <alsroot@member.fsf.org>

From: Aleksey Lim <alsroot@member.fsf.org>

Original-code: http://wiki.sugarlabs.org/go/Dextrose/Updater
dextrose-port-by: Martin Abente <martin.abente.lahaye@gmail.com>

VERSION 2 Including silbe's robustness suggestions.

PLEASE REPLACE OLD PATCH WITH THIS ONE

---
src/jarabe/desktop/homewindow.py |   36 ++++++++++++++++++++++++++++++++++++
 1 files changed, 36 insertions(+), 0 deletions(-)

diff --git a/src/jarabe/desktop/homewindow.py b/src/jarabe/desktop/homewindow.py
index d830ed0..34184a2 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')
@@ -71,6 +80,33 @@ class HomeWindow(gtk.Window):
 
         shell.get_model().zoom_level_changed.connect(
                                      self.__zoom_level_changed_cb)
+        
+        try:
+            systembus = dbus.SystemBus()
+        except dbus.DBusException:
+            logging.error('DBus SystemBus is not available')
+        else:
+            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")