diff options
author | Walter Bender <walter@sugarlabs.org> | 2010-06-04 23:18:35 (GMT) |
---|---|---|
committer | Walter Bender <walter@sugarlabs.org> | 2010-06-04 23:18:35 (GMT) |
commit | c5b28bdb50886988890ba2221585c1112319f427 (patch) | |
tree | 5381b472174e3e4da10c5363c60f7aa0cf169999 | |
parent | 4fc632b114344b600c8adc260b9babe0fbc715c2 (diff) |
added custom toolbar 0.86+ only
-rw-r--r-- | AbacusActivity.py | 156 | ||||
-rw-r--r-- | abacus_window.py | 16 | ||||
-rw-r--r-- | icons/new-game.svg | 63 | ||||
-rw-r--r-- | po/Abacus.pot | 26 |
4 files changed, 250 insertions, 11 deletions
diff --git a/AbacusActivity.py b/AbacusActivity.py index 9170cfc..be27e25 100644 --- a/AbacusActivity.py +++ b/AbacusActivity.py @@ -38,7 +38,7 @@ import locale import logging _logger = logging.getLogger("abacus-activity") -from abacus_window import Abacus +from abacus_window import Abacus, Custom # # Sugar activity @@ -116,6 +116,125 @@ class AbacusActivity(activity.Activity): separator = gtk.SeparatorToolItem() separator.props.draw = False + separator.set_expand(False) + separator.show() + toolbar_box.toolbar.insert(separator, -1) + + # The Customization submenu (roll your own) + custom_toolbar = gtk.Toolbar() + + self._rods_label = gtk.Label(_("Rods:")+" ") + self._rods_label.set_line_wrap(True) + self._rods_label.show() + self._rods_toolitem = gtk.ToolItem() + self._rods_toolitem.add(self._rods_label) + custom_toolbar.insert(self._rods_toolitem, -1) + self._rods_toolitem.show() + + self._rods_spin_adj = gtk.Adjustment(15, 1, 20, 1, 32, 0) + self._rods_spin = gtk.SpinButton(self._rods_spin_adj, 0, 0) + self._rods_spin_id = self._rods_spin.connect('value-changed', + self._rods_spin_cb) + self._rods_spin.set_numeric(True) + self._rods_spin.show() + self.tool_item_rods = gtk.ToolItem() + self.tool_item_rods.add(self._rods_spin) + custom_toolbar.insert(self.tool_item_rods, -1) + self.tool_item_rods.show() + + self._top_label = gtk.Label(" "+_("Top:")+" ") + self._top_label.set_line_wrap(True) + self._top_label.show() + self._top_toolitem = gtk.ToolItem() + self._top_toolitem.add(self._top_label) + custom_toolbar.insert(self._top_toolitem, -1) + self._top_toolitem.show() + + self._top_spin_adj = gtk.Adjustment(2, 0, 4, 1, 32, 0) + self._top_spin = gtk.SpinButton(self._top_spin_adj, 0, 0) + self._top_spin_id = self._top_spin.connect('value-changed', + self._top_spin_cb) + self._top_spin.set_numeric(True) + self._top_spin.show() + self.tool_item_top = gtk.ToolItem() + self.tool_item_top.add(self._top_spin) + custom_toolbar.insert(self.tool_item_top, -1) + self.tool_item_top.show() + + self._bottom_label = gtk.Label(" "+_("Bottom:")+" ") + self._bottom_label.set_line_wrap(True) + self._bottom_label.show() + self._bottom_toolitem = gtk.ToolItem() + self._bottom_toolitem.add(self._bottom_label) + custom_toolbar.insert(self._bottom_toolitem, -1) + self._bottom_toolitem.show() + + self._bottom_spin_adj = gtk.Adjustment(5, 1, 15, 1, 32, 0) + self._bottom_spin = gtk.SpinButton(self._bottom_spin_adj, 0, 0) + self._bottom_spin_id = self._bottom_spin.connect('value-changed', + self._bottom_spin_cb) + self._bottom_spin.set_numeric(True) + self._bottom_spin.show() + self.tool_item_bottom = gtk.ToolItem() + self.tool_item_bottom.add(self._bottom_spin) + custom_toolbar.insert(self.tool_item_bottom, -1) + self.tool_item_bottom.show() + + self._value_label = gtk.Label(" "+_("Factor:")+" ") + self._value_label.set_line_wrap(True) + self._value_label.show() + self._value_toolitem = gtk.ToolItem() + self._value_toolitem.add(self._value_label) + custom_toolbar.insert(self._value_toolitem, -1) + self._value_toolitem.show() + + self._value_spin_adj = gtk.Adjustment(5, 1, 20, 1, 32, 0) + self._value_spin = gtk.SpinButton(self._value_spin_adj, 0, 0) + self._value_spin_id = self._value_spin.connect('value-changed', + self._value_spin_cb) + self._value_spin.set_numeric(True) + self._value_spin.show() + self.tool_item_value = gtk.ToolItem() + self.tool_item_value.add(self._value_spin) + custom_toolbar.insert(self.tool_item_value, -1) + self.tool_item_value.show() + + self._base_label = gtk.Label(" "+_("Base:")+" ") + self._base_label.set_line_wrap(True) + self._base_label.show() + self._base_toolitem = gtk.ToolItem() + self._base_toolitem.add(self._base_label) + custom_toolbar.insert(self._base_toolitem, -1) + self._base_toolitem.show() + + self._base_spin_adj = gtk.Adjustment(10, 1, 20, 1, 32, 0) + self._base_spin = gtk.SpinButton(self._base_spin_adj, 0, 0) + self._base_spin_id = self._base_spin.connect('value-changed', + self._base_spin_cb) + self._base_spin.set_numeric(True) + self._base_spin.show() + self.tool_item_base = gtk.ToolItem() + self.tool_item_base.add(self._base_spin) + custom_toolbar.insert(self.tool_item_base, -1) + self.tool_item_base.show() + + # Custom + self._custom = ToolButton( "new-game" ) + self._custom.set_tooltip(_('Custom')) + self._custom.props.sensitive = True + self._custom.connect('clicked', self._custom_cb) + custom_toolbar.insert(self._custom, -1) + self._custom.show() + + custom_toolbar_button = ToolbarButton( + page=custom_toolbar, + icon_name='view-source') + custom_toolbar.show() + toolbar_box.toolbar.insert(custom_toolbar_button, -1) + custom_toolbar_button.show() + + separator = gtk.SeparatorToolItem() + separator.props.draw = False separator.set_expand(True) separator.show() toolbar_box.toolbar.insert(separator, -1) @@ -191,6 +310,41 @@ class AbacusActivity(activity.Activity): self.abacus.binary.hide() self.abacus.hex.hide() self.abacus.fraction.hide() + if self.abacus.custom is not None: + self.abacus.custom.hide() + + def _rods_spin_cb(self, button): + print self._rods_spin.get_value_as_int() + return + + def _top_spin_cb(self, button): + print self._top_spin.get_value_as_int() + return + + def _bottom_spin_cb(self, button): + print self._bottom_spin.get_value_as_int() + return + + def _value_spin_cb(self, button): + print self._value_spin.get_value_as_int() + return + + def _base_spin_cb(self, button): + print self._base_spin.get_value_as_int() + return + + def _custom_cb(self, button): + """ Display the custom abacus; hide the others """ + self._all_off() + self.abacus.custom = Custom(self.abacus, + self._rods_spin.get_value_as_int(), + self._top_spin.get_value_as_int(), + self._bottom_spin.get_value_as_int(), + self._value_spin.get_value_as_int(), + self._base_spin.get_value_as_int()) + self.abacus.custom.show() + self.abacus.mode = self.abacus.custom + _logger.debug("Setting mode to %s" % (self.abacus.mode.name)) def _chinese_cb(self, button): """ Display the suanpan; hide the others """ diff --git a/abacus_window.py b/abacus_window.py index 9de0271..06cb8be 100644 --- a/abacus_window.py +++ b/abacus_window.py @@ -205,6 +205,7 @@ class Abacus(): self.binary = Binary(self) self.hex = Hex(self) self.fraction = Fractions(self) + self.custom = None self.chinese.show() self.japanese.hide() @@ -562,6 +563,21 @@ class AbacusGeneric(): self.beads[i+ii].move_down() +class Custom(AbacusGeneric): + """ A custom-made abacus """ + + def __init__(self, abacus, rods, top, bottom, factor, base): + """ Specify parameters that define the abacus """ + self.abacus = abacus + self.name = 'custom' + self.num_rods = rods + self.bot_beads = bottom + self.top_beads = top + self.base = base + self.top_factor = factor + self.create() + + class Nepohualtzintzin(AbacusGeneric): """ A Mayan abacus """ diff --git a/icons/new-game.svg b/icons/new-game.svg new file mode 100644 index 0000000..8cd3576 --- /dev/null +++ b/icons/new-game.svg @@ -0,0 +1,63 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> + +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + version="1.1" + width="55" + height="55" + id="svg2" + inkscape:version="0.47pre4 r22446" + sodipodi:docname="new-game.svg"> + <metadata + id="metadata9"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + </cc:Work> + </rdf:RDF> + </metadata> + <sodipodi:namedview + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1" + objecttolerance="10" + gridtolerance="10" + guidetolerance="10" + inkscape:pageopacity="0" + inkscape:pageshadow="2" + inkscape:window-width="640" + inkscape:window-height="483" + id="namedview7" + showgrid="false" + inkscape:zoom="4.2909091" + inkscape:cx="27.5" + inkscape:cy="27.5" + inkscape:window-x="0" + inkscape:window-y="27" + inkscape:window-maximized="0" + inkscape:current-layer="svg2" /> + <defs + id="defs10"> + <inkscape:perspective + sodipodi:type="inkscape:persp3d" + inkscape:vp_x="0 : 27.5 : 1" + inkscape:vp_y="0 : 1000 : 0" + inkscape:vp_z="55 : 27.5 : 1" + inkscape:persp3d-origin="27.5 : 18.333333 : 1" + id="perspective11" /> + </defs> + <path + d="m 17,44 4,-13 -11,-8 13,0 5,-13 4,13 14,0 -11,8 4,13 -11,-8 z" + id="path6" + style="fill:none;stroke:#ffffff;stroke-width:3;stroke-linejoin:round;stroke-miterlimit:4" /> +</svg> diff --git a/po/Abacus.pot b/po/Abacus.pot index 83ed057..46021d2 100644 --- a/po/Abacus.pot +++ b/po/Abacus.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2010-05-29 20:49-0400\n" +"POT-Creation-Date: 2010-06-04 14:14-0400\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\n" @@ -25,48 +25,54 @@ msgid "Suanpan" msgstr "" #: /home/walter/Desktop/abacus/AbacusActivity.py:71 -#: /home/walter/Desktop/abacus/AbacusActivity.py:261 +#: /home/walter/Desktop/abacus/AbacusActivity.py:281 #: /home/walter/Desktop/abacus/abacus.py:53 msgid "Soroban" msgstr "" #: /home/walter/Desktop/abacus/AbacusActivity.py:79 -#: /home/walter/Desktop/abacus/AbacusActivity.py:269 +#: /home/walter/Desktop/abacus/AbacusActivity.py:289 #: /home/walter/Desktop/abacus/abacus.py:57 msgid "Schety" msgstr "" #: /home/walter/Desktop/abacus/AbacusActivity.py:87 -#: /home/walter/Desktop/abacus/AbacusActivity.py:277 +#: /home/walter/Desktop/abacus/AbacusActivity.py:297 #: /home/walter/Desktop/abacus/abacus.py:61 msgid "Nepohualtzintzin" msgstr "" #: /home/walter/Desktop/abacus/AbacusActivity.py:95 -#: /home/walter/Desktop/abacus/AbacusActivity.py:285 +#: /home/walter/Desktop/abacus/AbacusActivity.py:305 #: /home/walter/Desktop/abacus/abacus.py:64 msgid "Binary" msgstr "" #: /home/walter/Desktop/abacus/AbacusActivity.py:103 -#: /home/walter/Desktop/abacus/AbacusActivity.py:293 +#: /home/walter/Desktop/abacus/AbacusActivity.py:313 #: /home/walter/Desktop/abacus/abacus.py:67 +msgid "Hexadecimal" +msgstr "" + +#: /home/walter/Desktop/abacus/AbacusActivity.py:111 +#: /home/walter/Desktop/abacus/AbacusActivity.py:321 +#: /home/walter/Desktop/abacus/abacus.py:70 msgid "Fraction" msgstr "" -#: /home/walter/Desktop/abacus/AbacusActivity.py:117 +#: /home/walter/Desktop/abacus/AbacusActivity.py:125 msgid "<Ctrl>Q" msgstr "" -#: /home/walter/Desktop/abacus/AbacusActivity.py:130 +#: /home/walter/Desktop/abacus/AbacusActivity.py:138 msgid "Project" msgstr "" -#: /home/walter/Desktop/abacus/AbacusActivity.py:253 +#: /home/walter/Desktop/abacus/AbacusActivity.py:273 #: /home/walter/Desktop/abacus/abacus.py:49 msgid "Saunpan" msgstr "" -#: /home/walter/Desktop/abacus/abacus.py:71 +#: /home/walter/Desktop/abacus/abacus.py:74 msgid "Quit" msgstr "" |