[Sugar-devel] [PATCH v5 sugar] Shutdown(and Logout) menuitems should activate

Anurag Chowdhury anurag at seeta.in
Tue Oct 19 14:22:34 EDT 2010


Show a busy cursor when shutdown, logout, or reboot options are
selected.  Defer the selected action to an idle task so that the cursor
change is flushed to the display.

Co-Authored-By:James Cameron <quozl at laptop.org>
Co-Authored-By:Aleksey Lim <alsroot at member.fsf.org>

---
 src/jarabe/view/buddymenu.py |   18 ++++++++++++------
 1 files changed, 12 insertions(+), 6 deletions(-)

v1->v2: Corrected the window of operation
v2->v3: Added the busycursor in the desktop window
v3->v4: Removed redundant function calls like glib.timeout_add()
v4->v5: Opimised the code by removing repetitive redundant code snips.
Reviewed-By: James Cameron <quozl at laptop.org>

diff --git a/src/jarabe/view/buddymenu.py b/src/jarabe/view/buddymenu.py
index 0ba6cc1..2f3b1e0 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 gobject
+import jarabe

 from sugar.graphics.palette import Palette
 from sugar.graphics.menuitem import MenuItem
@@ -31,7 +33,9 @@ from jarabe.model import friends
 from jarabe.model.session import get_session_manager
 from jarabe.controlpanel.gui import ControlPanel

+
 class BuddyMenu(Palette):
+
     def __init__(self, buddy):
         self._buddy = buddy

@@ -97,17 +101,19 @@ class BuddyMenu(Palette):
         self.menu.append(item)
         item.show()

+    def _quit(self, action):
+        journal = jarabe.desktop.homewindow.get_instance()
+        journal.get_window().set_cursor(gtk.gdk.Cursor(gtk.gdk.WATCH))
+        gobject.idle_add(action)
+
     def __logout_activate_cb(self, menu_item):
-        session_manager = get_session_manager()
-        session_manager.logout()
+        self._quit(get_session_manager().logout)

     def __reboot_activate_cb(self, menu_item):
-        session_manager = get_session_manager()
-        session_manager.reboot()
+        self._quit(get_session_manager().reboot)

     def __shutdown_activate_cb(self, menu_item):
-        session_manager = get_session_manager()
-        session_manager.shutdown()
+        self._quit(get_session_manager().shutdown)

     def __controlpanel_activate_cb(self, menu_item):
         panel = ControlPanel()
--
1.7.2.3



More information about the Sugar-devel mailing list