[Sugar-devel] [PATCH v4 sugar] Shutdown (and Logout) menuitems should activate
Aleksey Lim
alsroot at member.fsf.org
Mon Oct 18 13:25:16 EDT 2010
On Wed, Oct 06, 2010 at 04:42:41AM +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.
> ---
> src/jarabe/view/buddymenu.py | 26 ++++++++++++++++++++------
> 1 files changed, 20 insertions(+), 6 deletions(-)
>
> v1 was Reviewed-By: James Cameron <quozl at laptop.org>
> v2 was Reviewed-By: Tomeu Vizoso<tomeu at sugarlabs.org>
> v3 was Reviewed-By: James Cameron <quozl at laptop.org>
> v3->v4 : Removed redundant function calls like glib.timeout_add() and gtk.main()
>
> diff --git a/src/jarabe/view/buddymenu.py b/src/jarabe/view/buddymenu.py
> index 0ba6cc1..78cdeb4 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 glib
> +import jarabe
>
> from sugar.graphics.palette import Palette
> from sugar.graphics.menuitem import MenuItem
> @@ -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)
>
> def __reboot_activate_cb(self, menu_item):
> - session_manager = get_session_manager()
> - session_manager.reboot()
> + def shut(self, menu_item):
> + session_manager = get_session_manager()
> + session_manager.reboot()
> + window = jarabe.desktop.homewindow.get_instance()
> + window.get_window().set_cursor(gtk.gdk.Cursor(gtk.gdk.WATCH))
> + glib.idle_add(shut,self,menu_item)
>
> def __shutdown_activate_cb(self, menu_item):
> - session_manager = get_session_manager()
> - session_manager.shutdown()
> + def shut(self, menu_item):
> + session_manager = get_session_manager()
> + session_manager.reboot()
s/reboot/shutdown/
> + window = jarabe.desktop.homewindow.get_instance()
> + window.get_window().set_cursor(gtk.gdk.Cursor(gtk.gdk.WATCH))
> + glib.idle_add(shut,self,menu_item)
>
> def __controlpanel_activate_cb(self, menu_item):
> panel = ControlPanel()
> --
> 1.7.2.3
"shut" method name seems to be misusing, btw what about code:
def _quit(self, method):
journal = jarabe.desktop.homewindow.get_instance()
journal.get_window().set_cursor(gtk.gdk.Cursor(gtk.gdk.WATCH))
gobject.idle_add(method)
def __logout_activate_cb(self, menu_item):
self._quit(get_session_manager().logout)
def __reboot_activate_cb(self, menu_item):
self._quit(get_session_manager().reboot)
def __shutdown_activate_cb(self, menu_item):
self._quit(get_session_manager().shutdown)
Also, there are several places w/ redundant spaces, use sugar-lint to fix it.
>
> _______________________________________________
> Sugar-devel mailing list
> Sugar-devel at lists.sugarlabs.org
> http://lists.sugarlabs.org/listinfo/sugar-devel
>
--
Aleksey
More information about the Sugar-devel
mailing list