# coding: UTF8 # Copyright 2009 Thomas Jourdan # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # 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 traceback import sys import ka_debug from gettext import gettext as _ class GettingstartedController(object): """ inv: self._widget_tree is not None inv: self._controller is not None """ _getting_started_text = """Kandid is a system to evolve graphical forms and color combinations. In subsequent generations Kandid creates random images. These images are proposals. You must rank the automatically generated images. Kandid uses a simulated evolution without a fitness function. A cybernetic system has no aesthetic feeling. Your select favorite images to give them a higher chance to reproduce. Over some generation you can find 'cool' looking images. """ def __init__(self, controller, init_widget_tree): """ pre: init_widget_tree is not None """ self._controller = controller self._widget_tree = init_widget_tree def autoconnect_events(self): """Auto connect status view.""" #Create a dictionary to connect events events = { 'on_readintro' : self.on_readintro, 'on_startnew' : self.on_startnew, } self._widget_tree.signal_autoconnect(events) def localize(self): try: local = {'startLabel' : _('Getting started'), 'readintroLinkbutton' : _('Read the Introduction'), 'startnewLinkbutton' : _('Show image population'), } for key, label in local.iteritems(): self._widget_tree.get_widget(key).set_label(label) textview = self._widget_tree.get_widget('gettingstarted_textview') buf = textview.get_buffer() translated = _('getting_started') translated = translated if not translated == 'getting_started' \ else GettingstartedController._getting_started_text buf.delete(buf.get_start_iter(), buf.get_end_iter()) buf.insert(buf.get_end_iter(), translated) except: ka_debug.err('localizing page "getting started" failed [%s] [%s]' % \ (sys.exc_info()[0], sys.exc_info()[1])) traceback.print_exc(file=sys.__stderr__) def show(self): """A dummy""" pass def on_readintro(self, args): """Show introduction page. """ self._controller.on_page_show(2) #Assume into page has position 2. def on_startnew(self, args): """Show population page. """ self._controller.on_page_show(0) #Assume population page has position 0.