Ticket #4008: 0001-Use-the-new-lockable-button-for-the-custom-abacus-Pa.patch

File 0001-Use-the-new-lockable-button-for-the-custom-abacus-Pa.patch, 3.0 KB (added by erikos, 11 years ago)

Patch for Abacus to the new lockable button for the custom abacus Palette

  • AbacusActivity.py

    From 1d6dceaef961e5e43bdabce5a518430e33c2a28c Mon Sep 17 00:00:00 2001
    From: Gonzalo Odiard <gonzalo@laptop.org>
    Date: Fri, 23 Nov 2012 10:47:55 +0100
    Subject: [PATCH] Use the new lockable button for the custom abacus Palette
    
    This is based on the lockable Palette support
    in the toolkit that landed in 6064fb30cc3cca24d2c68c588bcf3de5a047f584
    ---
     AbacusActivity.py | 28 +++++++++++++---------------
     1 file changed, 13 insertions(+), 15 deletions(-)
    
    diff --git a/AbacusActivity.py b/AbacusActivity.py
    index 269736d..d5f3119 100644
    a b from sugar3.graphics.toolbarbox import ToolbarBox 
    2222from sugar3.activity.widgets import ActivityToolbarButton
    2323from sugar3.activity.widgets import StopButton
    2424from sugar3.graphics.toolbarbox import ToolbarButton
     25from sugar3.graphics.toolbutton import ToolButton
    2526from sugar3.graphics.alert import NotifyAlert
    2627from sugar3.graphics import style
    2728
    class AbacusActivity(activity.Activity): 
    185186                                    cb_arg='custom',
    186187                                    tooltip=NAMES['custom'], group=self.decimal)
    187188
    188         preferences_button = button_factory(
    189             'preferences-system', custom_toolbar, self._preferences_palette_cb,
    190             tooltip=_('Custom'))
    191                
     189        preferences_button = ToolButton('preferences-system')
     190        preferences_button.set_tooltip(_('Custom'))
     191        custom_toolbar.insert(preferences_button, -1)
     192        preferences_button.palette_invoker.props.toggle_palette = True
     193        preferences_button.palette_invoker.props.lock_palette = True
     194        preferences_button.props.hide_tooltip_on_click = False
     195        preferences_button.show()
     196
    192197        self._palette = preferences_button.get_palette()
    193198        button_box = Gtk.VBox()
    194199        # TRANS: Number of rods on the abacus
    class AbacusActivity(activity.Activity): 
    207212        self._base_spin = add_spinner_and_label(
    208213            10, 1, (MAX_TOP + 1) * MAX_BOT, _('Base:'), self._base_spin_cb,
    209214            button_box)
    210         button_box.show_all()
    211         self._palette.set_content(button_box)
     215        hbox = Gtk.HBox()
     216        hbox.pack_start(button_box, True, True, style.DEFAULT_SPACING)
     217        hbox.show_all()
     218        self._palette.set_content(hbox)
    212219
    213220        separator_factory(custom_toolbar, False, False)
    214221
    class AbacusActivity(activity.Activity): 
    288295                self.abacus.mode.set_value(self.metadata['value'])
    289296                self.abacus.mode.label(self.abacus.generate_label())
    290297
    291     def _preferences_palette_cb(self, button):
    292         if self._palette:
    293             if not self._palette.is_up():
    294                 self._palette.popup(immediate=True,
    295                                     state=self._palette.SECONDARY)
    296             else:
    297                 self._palette.popdown(immediate=True)
    298             return
    299 
    300298    def _radio_cb(self, button, abacus):
    301299        self._select_abacus(abacus)
    302300