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 |
22 | 22 | from sugar3.activity.widgets import ActivityToolbarButton |
23 | 23 | from sugar3.activity.widgets import StopButton |
24 | 24 | from sugar3.graphics.toolbarbox import ToolbarButton |
| 25 | from sugar3.graphics.toolbutton import ToolButton |
25 | 26 | from sugar3.graphics.alert import NotifyAlert |
26 | 27 | from sugar3.graphics import style |
27 | 28 | |
… |
… |
class AbacusActivity(activity.Activity): |
185 | 186 | cb_arg='custom', |
186 | 187 | tooltip=NAMES['custom'], group=self.decimal) |
187 | 188 | |
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 | |
192 | 197 | self._palette = preferences_button.get_palette() |
193 | 198 | button_box = Gtk.VBox() |
194 | 199 | # TRANS: Number of rods on the abacus |
… |
… |
class AbacusActivity(activity.Activity): |
207 | 212 | self._base_spin = add_spinner_and_label( |
208 | 213 | 10, 1, (MAX_TOP + 1) * MAX_BOT, _('Base:'), self._base_spin_cb, |
209 | 214 | 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) |
212 | 219 | |
213 | 220 | separator_factory(custom_toolbar, False, False) |
214 | 221 | |
… |
… |
class AbacusActivity(activity.Activity): |
288 | 295 | self.abacus.mode.set_value(self.metadata['value']) |
289 | 296 | self.abacus.mode.label(self.abacus.generate_label()) |
290 | 297 | |
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 | | |
300 | 298 | def _radio_cb(self, button, abacus): |
301 | 299 | self._select_abacus(abacus) |
302 | 300 | |