[Sugar-devel] [PATCH v3 sugar] Shutdown (and Logout) menu items should activate the buzzy cursor (or provide some other visual feedback, perhaps dimming/locking the UI from use).

Anurag Chowdhury anurag at seeta.in
Tue Sep 28 14:56:38 EDT 2010


We changed the cursor in homewindow to a busy cursor when the shutdown menu is activated and used glib.idle_add( ) to break out of the infinite gtk.main() loop to shutdown the system when the processor is idle and untill that time it will show a busy cursor ,hence letting the user know the validity of the shutdown process going on in the backend.
---
 src/jarabe/view/buddymenu.py |   42 ++++++++++++++++++++++++++++++++++--------
 1 files changed, 34 insertions(+), 8 deletions(-)

v1 was Reviewed-By: James Cameron <quozl at laptop.org>
v2 was Reviewed-By: Tomeu Vizoso<tomeu at sugarlabs.org>
v2->v3 Added detailed description for the bug solution

diff --git a/src/jarabe/view/buddymenu.py b/src/jarabe/view/buddymenu.py
index 0ba6cc1..7135d9e 100644
--- a/src/jarabe/view/buddymenu.py
+++ b/src/jarabe/view/buddymenu.py
@@ -21,6 +21,8 @@ from gettext import gettext as _
 import gtk
 import gconf
 import dbus
+import jarabe
+import glib
 
 from sugar.graphics.palette import Palette
 from sugar.graphics.menuitem import MenuItem
@@ -98,16 +100,40 @@ class BuddyMenu(Palette):
         item.show()
 
     def __logout_activate_cb(self, menu_item):
-        session_manager = get_session_manager()
-        session_manager.logout()
+        def update_cur(window):
+            window.get_window().set_cursor(gtk.gdk.Cursor(gtk.gdk.WATCH))
+            return False     
+        def shut(self, menu_item):
+            session_manager = get_session_manager()
+            session_manager.logout()
+        window = jarabe.desktop.homewindow.get_instance()
+        glib.timeout_add(3, update_cur, window)              
+        glib.idle_add(shut,self,menu_item)
+        gtk.main()
 
     def __reboot_activate_cb(self, menu_item):
-        session_manager = get_session_manager()
-        session_manager.reboot()
-
-    def __shutdown_activate_cb(self, menu_item):
-        session_manager = get_session_manager()
-        session_manager.shutdown()
+        def update_cur(window):
+            window.get_window().set_cursor(gtk.gdk.Cursor(gtk.gdk.WATCH))
+            return False     
+        def shut(self, menu_item):
+            session_manager = get_session_manager()
+            session_manager.reboot()
+        window = jarabe.desktop.homewindow.get_instance()
+        glib.timeout_add(3, update_cur, window)              
+        glib.idle_add(shut,self,menu_item)
+        gtk.main()
+    
+    def __shutdown_activate_cb(self, menu_item):    
+        def update_cur(window):
+            window.get_window().set_cursor(gtk.gdk.Cursor(gtk.gdk.WATCH))
+            return False     
+        def shut(self, menu_item):
+            session_manager = get_session_manager()
+            session_manager.shutdown()
+        window = jarabe.desktop.homewindow.get_instance()
+        glib.timeout_add(3, update_cur, window)              
+        glib.idle_add(shut,self,menu_item)
+        gtk.main()
 
     def __controlpanel_activate_cb(self, menu_item):
         panel = ControlPanel()
-- 
1.7.2.3



More information about the Sugar-devel mailing list