diff options
author | Thomas Jourdan <b.vehikel@googlemail.com> | 2009-12-06 21:43:25 (GMT) |
---|---|---|
committer | Thomas Jourdan <b.vehikel@googlemail.com> | 2009-12-06 21:43:25 (GMT) |
commit | f5ba3b40da10c79508b2e43e9a99b3db78ba4d5b (patch) | |
tree | eea5b34fd415991e608a9c18f34fa529433415c8 /ka_widget.py | |
parent | 6b79c336ecf1e3c4704c470daf29d2cf2ad8cbef (diff) |
preparing ka_widget for Pootle
Diffstat (limited to 'ka_widget.py')
-rw-r--r-- | ka_widget.py | 58 |
1 files changed, 44 insertions, 14 deletions
diff --git a/ka_widget.py b/ka_widget.py index e70a977..e1db2aa 100644 --- a/ka_widget.py +++ b/ka_widget.py @@ -14,9 +14,11 @@ # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - import gtk import gtk.glade +from gettext import gettext as _ +import ka_controller +import ka_debug class KandidWidget(object): """ @@ -29,31 +31,59 @@ class KandidWidget(object): self._widget_tree = gtk.glade.XML("kandid.glade") # Get Window - window1 = self._widget_tree.get_widget('window1') + kandidWindow = self._widget_tree.get_widget('kandidWindow') # Get Windows child - window1_child = window1.get_child() + kandidWindow_child = kandidWindow.get_child() # Remove the widget's parent - if window1_child.parent: - window1_child.parent.remove(window1_child) + if kandidWindow_child.parent: + kandidWindow_child.parent.remove(kandidWindow_child) # self.widget will be attached to the Activity # This can be any GTK widget except a window - main_view.pack_start(window1_child) + main_view.pack_start(kandidWindow_child) + self._localizeGUI() # Display everything - window1_child.show() + kandidWindow_child.show() main_view.show() -# try: -# ka_debug.info('set_canvas(self._main_view) [%s]' % (self._main_view)) -# self.set_canvas(self._main_view) -# except: -# traceback.print_exc(file=sys.__stderr__) -# ka_debug.err('failed sugar 0.86 set_canvas [%s] [%s] [%s]' % \ -# (sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2])) + def getWidget_tree(self): return self._widget_tree + + def _localizeGUI(self): + local = {'breedGenerationButton' : _('Breed'), + 'randomGenerationButton' : _('Random'), + 'flurryLabel' : _('Flurry rate:'), + 'introLabel' : _('Introduction'), + 'populationLabel' : _('Population'), + } + for key, label in local.iteritems(): + self._widget_tree.get_widget(key).set_label(label) + ka_debug.info('localize "%s" to "%s"' % (key, label)) + + for cell_index in range(ka_controller.POPULATION_CAPACITY): + local = {'favorite_menuitem_#' : _('My favorite'), + 'awfull_menuitem_#' : _('Awful bore'), + 'publishprotozoon_menuitem_#' : _('Publish to my friends'), + } + self._set_localized_child_text(local, cell_index) + + for cell_index in range(ka_controller.INCOMMING_CAPACITY): + local = {'accept_menuitem_#' : _('Accept protozoon'), + 'decline_menuitem_#' : _('Decline protozoon'), + } + self._set_localized_child_text(local, cell_index) + + def _set_localized_child_text(self, local, cell_index): + strix = str(cell_index) + for key, label in local.iteritems(): + ikey = key if cell_index < 0 else key.replace('#', strix) + self._widget_tree.get_widget(ikey).get_child().set_text(label) + ka_debug.info('localize "%s" to "%s"' % (ikey, label)) + + widget_tree = property(getWidget_tree) |