[Dextrose] [PATCH sugar] Show busy cursor during session shutdown

Aleksey Lim alsroot at activitycentral.org
Thu Feb 17 05:24:38 EST 2011


git-send-email got something wrong, it is intended to
http://lists.sugarlabs.org/archive/dextrose/2011-February/001098.html

On Thu, Feb 17, 2011 at 10:14:33AM +0000, Aleksey Lim wrote:
> From: Sascha Silbe <silbe at activitycentral.com>
> 
> 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>
> Co-Authored-By: Anurag Chowdhury <anurag at seeta.in>
> Signed-off-by: Sascha Silbe <sascha-pgp at silbe.org>
> Reviewed-by: James Cameron <quozl at laptop.org>
> ---
>  src/jarabe/desktop/homewindow.py |   14 ++++++++++++++
>  src/jarabe/view/buddymenu.py     |   14 ++++++++------
>  2 files changed, 22 insertions(+), 6 deletions(-)
> 
> diff --git a/src/jarabe/desktop/homewindow.py b/src/jarabe/desktop/homewindow.py
> index 6f33455..17ff315 100644
> --- a/src/jarabe/desktop/homewindow.py
> +++ b/src/jarabe/desktop/homewindow.py
> @@ -16,6 +16,7 @@
>  
>  import logging
>  
> +import gobject
>  import gtk
>  import dbus
>  from gettext import gettext as _
> @@ -215,6 +216,19 @@ class HomeWindow(gtk.Window):
>      def get_home_box(self):
>          return self._home_box
>  
> +    def busy_during_delayed_action(self, action):
> +        """Use busy cursor during execution of action, scheduled via idle_add.
> +        """
> +        def action_wrapper(old_cursor):
> +            try:
> +                action()
> +            finally:
> +                self.get_window().set_cursor(old_cursor)
> +
> +        old_cursor = self.get_window().get_cursor()
> +        self.get_window().set_cursor(gtk.gdk.Cursor(gtk.gdk.WATCH))
> +        gobject.idle_add(action_wrapper, old_cursor)
> +
>  _instance = None
>  
>  def get_instance():
> diff --git a/src/jarabe/view/buddymenu.py b/src/jarabe/view/buddymenu.py
> index 5592eee..31d4ad3 100644
> --- a/src/jarabe/view/buddymenu.py
> +++ b/src/jarabe/view/buddymenu.py
> @@ -28,6 +28,7 @@ from jarabe.model import shell
>  from jarabe.model import friends
>  from jarabe.model.session import get_session_manager
>  from jarabe.controlpanel.gui import ControlPanel
> +import jarabe.desktop.homewindow
>  
>  class BuddyMenu(Palette):
>      def __init__(self, buddy):
> @@ -103,17 +104,18 @@ class BuddyMenu(Palette):
>          self.menu.append(item)
>          item.show()
>  
> +    def _quit(self, action):
> +        home_window = jarabe.desktop.homewindow.get_instance()
> +        home_window.busy_during_delayed_action(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.3.4
> 
> _______________________________________________
> Dextrose mailing list
> Dextrose at lists.sugarlabs.org
> http://lists.sugarlabs.org/listinfo/dextrose
> 

-- 
Aleksey


More information about the Dextrose mailing list