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, 10 years ago)

e.g., use ',' on decimal button in es_UY

  • 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): 
    335335##            icon_name = 'theme:stock-buddy',
    336336##            xo_color = XoColor(self.color))     
    337337
    338         self.layout = CalcLayout(self)
     338        self.layout = CalcLayout(self, self.ml.fraction_sep)
    339339        self.label_entry = self.layout.label_entry
    340340        self.text_entry = self.layout.text_entry
    341341        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 
    99from sugar.graphics.roundbox import CanvasRoundBox
    1010from toolbars import *
    1111
    12 try:
    13     from sugar.graphics.toolbarbox import ToolbarButton, ToolbarBox
    14     from sugar.activity.widgets import ActivityToolbarButton
    15     from sugar.activity.widgets import StopButton
    16 except ImportError:
    17     pass
    18 
    1912class CalcLayout:
    2013
    2114    FONT_SMALL_POINTS = 10
    class CalcLayout: 
    2720    FONT_BIGGER_POINTS = 18
    2821    FONT_BIGGER = "sans bold %d" % FONT_BIGGER_POINTS
    2922
    30     def __init__(self, parent):
     23    def __init__(self, parent, fraction_sep):
    3124        self._parent = parent
    3225
    3326        self._own_equations = []
    class CalcLayout: 
    3629        self._showing_all_history = True
    3730        self._var_textviews = {}
    3831
    39         self.create_dialog()
     32        self.create_dialog(fraction_sep)
    4033
    4134    def create_color(self, rf, gf, bf):
    4235        return gtk.gdk.Color(int(rf*0xFFFF), int(gf*0xFFFF), int(bf*0xFFFF))
    4336
    44     def create_button_data(self):
     37    def create_button_data(self, fraction_sep):
    4538        """Create a list with button information. We need to do that here
    4639        because we want to include the lambda functions."""
    4740
    class CalcLayout: 
    6356            [2, 2, 1, '3', self.col_gray2, lambda w: self._parent.add_text('3')],
    6457     
    6558            [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)],
    6760
    6861            [3, 0, 3, _('Clear'), self.col_gray1, lambda w: self._parent.clear()],
    6962 
    class CalcLayout: 
    7770            [3, 3, 3, _('Enter'), self.col_gray1, lambda w: self._parent.process()],
    7871        ]
    7972
    80     def create_dialog(self):
     73    def create_dialog(self, fraction_sep):
    8174        """Setup most of the dialog."""
    8275
    8376# 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()
    14485
    14586# Some layout constants
    14687        self.input_font = pango.FontDescription(str='sans bold 12')
    class CalcLayout: 
    176117        self.pad = gtk.Table(4, 6, True)
    177118        self.pad.set_row_spacings(6)
    178119        self.pad.set_col_spacings(6)
    179         self.create_button_data()
     120        self.create_button_data(fraction_sep)
    180121        self.buttons = {}
    181122        for x, y, w, cap, bgcol, cb in self.button_data:
    182123            button = self.create_button(_(cap), cb, self.col_white, bgcol, w)
    class CalcLayout: 
    195136        self.minebut = TextToggleToolButton(
    196137            [_('All equations'), _('My equations')],
    197138            self._all_equations_toggle_cb,
    198             _('Change view between own and all equations'),
     139            _('Change view between own and all eqauations'),
    199140            index=True)
    200141        self.varbut = TextToggleToolButton(
    201142            [_('Show history'), _('Show variables')],