#1986 LOW Trial-3: Add a "Reboot" option to the user's context menu in Home view

Zarro Boogs per Child bugtracker at laptop.org
Sun Aug 5 04:34:41 EDT 2007


#1986: Add a "Reboot" option to the user's context menu in Home view
--------------------------+-------------------------------------------------
  Reporter:  jfuhrer      |       Owner:  edsiper
      Type:  enhancement  |      Status:  new    
  Priority:  low          |   Milestone:  Trial-3
 Component:  sugar        |     Version:         
Resolution:               |    Keywords:  review+
  Verified:  0            |  
--------------------------+-------------------------------------------------
Changes (by marco):

  * keywords:  review? => review+

Comment:

 {{{
 +    STATE_REBOOT = 3
 }}}

 Not necessary to introduce a new state here. Let's just use STATE_SHUTDOWN
 for reboot too.

 {{{
      def enable_palette(self):
 -        palette = Palette(profile.get_nick_name())
 +        self.set_tooltip(profile.get_nick_name())

 -        shutdown_menu_item = gtk.MenuItem(_('Shutdown'))
 -        shutdown_menu_item.connect('activate',
 self._shutdown_activate_cb)
 -        palette.append_menu_item(shutdown_menu_item)
 -        shutdown_menu_item.show()
 +        self._mgr = self._get_dbus_powermanagement_interface()
 +        self._add_palette_item(_('Shutdown'), self._shutdown_activate_cb)
 +        self._add_palette_item(_('Reboot'), self._reboot_activate_cb)

 -        self.set_palette(palette)
 +    def _add_palette_item(self, label, callback):
 +        item = gtk.MenuItem(label)
 +        item.connect('activate', callback)
 +        self.get_palette().append_menu_item(item)
 +        item.show()
 }}}

 I don't like the set_tooltip/get_palette thing. The previous code was
 doing the right thing. Just add the other item using a similar approach.
 The fact that you felt the need to add an helper is an indication that the
 Palette API might need some love, we need to review it for Trial-3.

 Also please move the self._mgr initialization to __init__. (but see below)

 {{{
 +    def _get_dbus_powermanagement_interface(self):
 }}}

 I'd say to use lazy initialization here, since shutdown/reboot will be
 used infrequently. So set self._power_manager to None in __init__, rename
 this method to _get_power_manager() and do something like:

 {{{
     if self._power_manager is None:
         ...
         self._power_manager = ...
     return self._power_manager
 }}}

-- 
Ticket URL: <http://dev.laptop.org/ticket/1986#comment:6>
One Laptop Per Child <http://laptop.org/>



More information about the Bugs mailing list