[Sugar-devel] closing an activity immediately

tom.staubitz at fhtw-berlin.de tom.staubitz at fhtw-berlin.de
Thu Feb 10 02:14:08 EST 2011


On Feb 9, 2011, at 7:55 PM, Erik Blankinship wrote:

> If I wanted to stop an activity as soon as it was initiated, how would I do that?  The code below hangs with a grey screen.
> 
> Why would I want to do this?  I am trying to understand how the sugar code base works.  This seems like a good exercise for understanding how sugar activities start and stop.

Actually this would be a great feature in my opinion. 
To me it happened often enough that an activity got started accidentally while dragging 
and dropping images from the journal to a USB Stick, for example.
Being able to stop it immediately would be a great user experience.
FWIW, the Mac offers this behavior as well. Applications can be "Force Quit" during start up.


> Yes, this would be a bad user experience.
> 
> class NotTodayActivity( activity.Activity ):
> 
>     def __init__( self, handle ):
>         activity.Activity.__init__( self, handle )
> 
>         self._auto_shut_down = False
>         if not self.should_this_activity_run_today( ):
>             self._auto_shut_down = True
>             logger.debug( "goin' down" )
>             self.close( )
>             return
>     
>    def write_file( self, file_path ):
>         logger.debug( "write_file..." )
>         if self._auto_shut_down:
>              return
> 
>    def should_this_activity_run_today( self ):
>         #todo: details go here
>         return False
> 
> _______________________________________________
> Sugar-devel mailing list
> Sugar-devel at lists.sugarlabs.org
> http://lists.sugarlabs.org/listinfo/sugar-devel






More information about the Sugar-devel mailing list