Ticket #2537: 0001-use-i18n-fraction_sep-on-decimal-button.patch
File 0001-use-i18n-fraction_sep-on-decimal-button.patch, 6.6 KB (added by walter, 13 years ago) |
---|
-
calculate.py
From 447f8d662dd12f4e8592362f29caf2b4b1535707 Mon Sep 17 00:00:00 2001 From: Walter Bender <walter@sugarlabs.org> Date: Sat, 1 Jan 2011 20:37:38 -0500 Subject: [PATCH] use i18n fraction_sep on decimal button --- calculate.py | 2 +- layout.py | 89 ++++++++++------------------------------------------------ 2 files changed, 16 insertions(+), 75 deletions(-) diff --git a/calculate.py b/calculate.py index 1b89b88..e870254 100644
a b class Calculate(ShareableActivity): 335 335 ## icon_name = 'theme:stock-buddy', 336 336 ## xo_color = XoColor(self.color)) 337 337 338 self.layout = CalcLayout(self )338 self.layout = CalcLayout(self, self.ml.fraction_sep) 339 339 self.label_entry = self.layout.label_entry 340 340 self.text_entry = self.layout.text_entry 341 341 self.last_eq_sig = None -
layout.py
diff --git a/layout.py b/layout.py index d439a3a..4365b7d 100644
a b from sugar.activity import activity 9 9 from sugar.graphics.roundbox import CanvasRoundBox 10 10 from toolbars import * 11 11 12 try:13 from sugar.graphics.toolbarbox import ToolbarButton, ToolbarBox14 from sugar.activity.widgets import ActivityToolbarButton15 from sugar.activity.widgets import StopButton16 except ImportError:17 pass18 19 12 class CalcLayout: 20 13 21 14 FONT_SMALL_POINTS = 10 … … class CalcLayout: 27 20 FONT_BIGGER_POINTS = 18 28 21 FONT_BIGGER = "sans bold %d" % FONT_BIGGER_POINTS 29 22 30 def __init__(self, parent ):23 def __init__(self, parent, fraction_sep): 31 24 self._parent = parent 32 25 33 26 self._own_equations = [] … … class CalcLayout: 36 29 self._showing_all_history = True 37 30 self._var_textviews = {} 38 31 39 self.create_dialog( )32 self.create_dialog(fraction_sep) 40 33 41 34 def create_color(self, rf, gf, bf): 42 35 return gtk.gdk.Color(int(rf*0xFFFF), int(gf*0xFFFF), int(bf*0xFFFF)) 43 36 44 def create_button_data(self ):37 def create_button_data(self, fraction_sep): 45 38 """Create a list with button information. We need to do that here 46 39 because we want to include the lambda functions.""" 47 40 … … class CalcLayout: 63 56 [2, 2, 1, '3', self.col_gray2, lambda w: self._parent.add_text('3')], 64 57 65 58 [0, 3, 1, '0', self.col_gray2, lambda w: self._parent.add_text('0')], 66 [1, 3, 1, '.', self.col_gray2, lambda w: self._parent.add_text('.')],59 [1, 3, 1, fraction_sep, self.col_gray2, lambda w: self._parent.add_text(fraction_sep)], 67 60 68 61 [3, 0, 3, _('Clear'), self.col_gray1, lambda w: self._parent.clear()], 69 62 … … class CalcLayout: 77 70 [3, 3, 3, _('Enter'), self.col_gray1, lambda w: self._parent.process()], 78 71 ] 79 72 80 def create_dialog(self ):73 def create_dialog(self, fraction_sep): 81 74 """Setup most of the dialog.""" 82 75 83 76 # Toolbar 84 try: 85 toolbar_box = ToolbarBox() 86 87 activity_button = ActivityToolbarButton(self._parent) 88 toolbar_box.toolbar.insert(activity_button, 0) 89 90 def append(icon_name, label, page, position): 91 toolbar_button = ToolbarButton() 92 toolbar_button.props.page = page 93 toolbar_button.props.icon_name = icon_name 94 toolbar_button.props.label = label 95 toolbar_box.toolbar.insert(toolbar_button, position) 96 97 append('toolbar-edit', 98 _('Edit'), 99 EditToolbar(self._parent), 100 -1) 101 102 append('toolbar-algebra', 103 _('Algebra'), 104 AlgebraToolbar(self._parent), 105 -1) 106 107 append('toolbar-trigonometry', 108 _('Trigonometry'), 109 TrigonometryToolbar(self._parent), 110 -1) 111 112 append('toolbar-boolean', 113 _('Boolean'), 114 BooleanToolbar(self._parent), 115 -1) 116 117 append('toolbar-constants', 118 _('Miscellaneous'), 119 MiscToolbar(self._parent, target_toolbar=toolbar_box.toolbar), 120 5) 121 122 separator = gtk.SeparatorToolItem() 123 separator.props.draw = False 124 separator.set_expand(True) 125 separator.show() 126 toolbar_box.toolbar.insert(separator, -1) 127 128 stop = StopButton(self._parent) 129 toolbar_box.toolbar.insert(stop, -1) 130 131 toolbar_box.show_all() 132 self._parent.set_toolbar_box(toolbar_box) 133 134 except NameError: 135 # Use old toolbar design 136 toolbox = activity.ActivityToolbox(self._parent) 137 self._parent.set_toolbox(toolbox) 138 toolbox.add_toolbar(_('Edit'), EditToolbar(self._parent)) 139 toolbox.add_toolbar(_('Algebra'), AlgebraToolbar(self._parent)) 140 toolbox.add_toolbar(_('Trigonometry'), TrigonometryToolbar(self._parent)) 141 toolbox.add_toolbar(_('Boolean'), BooleanToolbar(self._parent)) 142 toolbox.add_toolbar(_('Miscellaneous'), MiscToolbar(self._parent)) 143 toolbox.show_all() 77 toolbox = activity.ActivityToolbox(self._parent) 78 self._parent.set_toolbox(toolbox) 79 toolbox.add_toolbar(_('Edit'), EditToolbar(self._parent)) 80 toolbox.add_toolbar(_('Algebra'), AlgebraToolbar(self._parent)) 81 toolbox.add_toolbar(_('Trigonometry'), TrigonometryToolbar(self._parent)) 82 toolbox.add_toolbar(_('Boolean'), BooleanToolbar(self._parent)) 83 toolbox.add_toolbar(_('Miscellaneous'), MiscToolbar(self._parent)) 84 toolbox.show_all() 144 85 145 86 # Some layout constants 146 87 self.input_font = pango.FontDescription(str='sans bold 12') … … class CalcLayout: 176 117 self.pad = gtk.Table(4, 6, True) 177 118 self.pad.set_row_spacings(6) 178 119 self.pad.set_col_spacings(6) 179 self.create_button_data( )120 self.create_button_data(fraction_sep) 180 121 self.buttons = {} 181 122 for x, y, w, cap, bgcol, cb in self.button_data: 182 123 button = self.create_button(_(cap), cb, self.col_white, bgcol, w) … … class CalcLayout: 195 136 self.minebut = TextToggleToolButton( 196 137 [_('All equations'), _('My equations')], 197 138 self._all_equations_toggle_cb, 198 _('Change view between own and all eq uations'),139 _('Change view between own and all eqauations'), 199 140 index=True) 200 141 self.varbut = TextToggleToolButton( 201 142 [_('Show history'), _('Show variables')],