[Sugar-devel] [PATCH v4 sugar] Shutdown (and Logout) menuitems should activate
James Cameron
quozl at laptop.org
Mon Oct 18 02:45:36 EDT 2010
On Mon, Oct 18, 2010 at 06:36:16AM +0530, Anurag Chowdhury wrote:
> We changed the cursor in home window to a busy cursor when the shutdown menu
> is activated and used glib.idle_add( ) to call the shut funtion when pygtk is
> idle to shutdown or logout the sugar session properly , hence letting the user
> know the validity of the shutdown process going on in the backend.
s/ , /, /
s/know the/know the
s/( )/()
s/funtion/function
The commit message is quite verbose. That may be a side effect of
review comments.
Here's a suggested rewrite:
"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."
> --- a/src/jarabe/view/buddymenu.py
> +++ b/src/jarabe/view/buddymenu.py
> @@ -98,16 +100,28 @@ class BuddyMenu(Palette):
> item.show()
>
> def __logout_activate_cb(self, menu_item):
> - session_manager = get_session_manager()
> - session_manager.logout()
> + def shut(self, menu_item):
> + session_manager = get_session_manager()
> + session_manager.logout()
> + window = jarabe.desktop.homewindow.get_instance()
> + window.get_window().set_cursor(gtk.gdk.Cursor(gtk.gdk.WATCH))
> + glib.idle_add(shut,self,menu_item)
shut did not need self.
The rest of Sugar uses gobject.idle_add rather than glib.idle_add ...
does this fix work correctly if you use gobject.idle_add? If not, then
I think we (as a team) need to understand why the glib.idle_add worked
correctly where gobject.idle_add did not.
The code is repetitive, as I've said before, but I think I'm not getting
my point across, so I'll rewrite it for you in order to demonstrate.
This is untested. It locates the session manager function to be called,
and passes it to the idle task.
diff --git a/src/jarabe/view/buddymenu.py b/src/jarabe/view/buddymenu.py
index 0ba6cc1..df03630 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
@@ -97,17 +99,26 @@ class BuddyMenu(Palette):
self.menu.append(item)
item.show()
+ def _defer_session_manager(self, action):
+ window = jarabe.desktop.homewindow.get_instance().get_window()
+ window.set_cursor(gtk.gdk.Cursor(gtk.gdk.WATCH))
+ gobject.idle_add(self.__session_manager_idle, action)
+
+ def __session_manager_idle(self, action):
+ action()
+ return False
+
def __logout_activate_cb(self, menu_item):
session_manager = get_session_manager()
- session_manager.logout()
+ self._defer_session_manager(session_manager.logout)
def __reboot_activate_cb(self, menu_item):
session_manager = get_session_manager()
- session_manager.reboot()
+ self._defer_session_manager(session_manager.reboot)
def __shutdown_activate_cb(self, menu_item):
session_manager = get_session_manager()
- session_manager.shutdown()
+ self._defer_session_manager(session_manager.shutdown)
def __controlpanel_activate_cb(self, menu_item):
panel = ControlPanel()
--
James Cameron
http://quozl.linux.org.au/
More information about the Sugar-devel
mailing list