diff options
author | Nostalghia <b.vehikel@googlemail.com> | 2011-01-29 14:30:15 (GMT) |
---|---|---|
committer | Nostalghia <b.vehikel@googlemail.com> | 2011-01-29 14:30:15 (GMT) |
commit | b577b4444860caf261c755f216e7d65aa48f4adb (patch) | |
tree | 81550de26dfb4059685c3e33f5d6d6cf78db192b | |
parent | fde14815c4295a61a745f7883617fd18f4b694b5 (diff) |
The user can select different sizes for exported images.
Bug fixing to be compatible with Sugar 0.90.
-rw-r--r-- | MANIFEST | 2 | ||||
-rw-r--r-- | activity.py | 69 | ||||
-rw-r--r-- | ep_page_gettingstarted.py | 35 | ||||
-rw-r--r-- | ep_page_intro.py | 29 | ||||
-rw-r--r-- | ep_page_population.py | 5 | ||||
-rw-r--r-- | ep_page_status.py | 42 | ||||
-rw-r--r-- | ka_html_page.py | 2 | ||||
-rw-r--r-- | ka_importer.py | 16 | ||||
-rw-r--r-- | ka_preference.py | 109 | ||||
-rw-r--r-- | ka_widget.py | 31 | ||||
-rw-r--r-- | kandidtube.py | 17 | ||||
-rw-r--r-- | model_population.py | 1 | ||||
-rw-r--r-- | po/Kandid.pot | 44 | ||||
-rw-r--r-- | test_model.py | 6 | ||||
-rw-r--r-- | test_preference.py | 55 | ||||
-rw-r--r-- | test_status.py | 2 | ||||
-rw-r--r-- | test_suite.py | 2 |
17 files changed, 360 insertions, 107 deletions
@@ -102,6 +102,7 @@ intro/button_breed-colormap.png intro/evolved-population-colormap.png intro/fitnes-slider-colormap.png intro/incoming-protozoon-colormap.png +intro/kandid-teaser.jpg intro/neighborhood-colormap.png intro/publish-protozoon-colormap.png intro/random-population-colormap.png @@ -165,6 +166,7 @@ ka_factory.py ka_html_page.py ka_importer.py ka_incoming.py +ka_preference.py ka_status.py ka_task.py ka_utils.py diff --git a/activity.py b/activity.py index 3304162..143ef6f 100644 --- a/activity.py +++ b/activity.py @@ -112,15 +112,15 @@ class KandidActivity(activity.Activity): try: self.connect('shared', self._on_shared) self.connect('joined', self._on_joined) - - ka_debug.info('searching buddies') - buddies = self.pservice.get_buddies() - for buddy in buddies: - ka_debug.info(' buddy nick: %s' % buddy.get_property('nick')) - ka_debug.info(' activity: %s' - % buddy.get_property('current-activity')) - ka_debug.info(' owner: %s' % buddy.get_property('owner')) - found_buddies |= set([buddy.get_property('nick')]) +# pservice.get_buddies() is deprecated +# ka_debug.info('searching buddies') +# buddies = self.pservice.get_buddies() +# for buddy in buddies: +# ka_debug.info(' buddy nick: %s' % buddy.get_property('nick')) +# ka_debug.info(' activity: %s' +# % buddy.get_property('current-activity')) +# ka_debug.info(' owner: %s' % buddy.get_property('owner')) +# found_buddies |= set([buddy.get_property('nick')]) except: ka_debug.err('start collaboration failed [%s] [%s]' % \ (sys.exc_info()[0], sys.exc_info()[1])) @@ -266,7 +266,7 @@ class KandidActivity(activity.Activity): tube_conn, self._get_my_id(), self.initiating, - self._get_buddy) + self.get_buddy_by_handle) def _on_buddy_joined (self, joined_activity, buddy): """Called when a buddy joins the shared activity. @@ -288,32 +288,39 @@ class KandidActivity(activity.Activity): """Get my channel ID and nick.""" group = self.text_chan[telepathy.CHANNEL_INTERFACE_GROUP] my_csh = group.GetSelfHandle() - my_buddy = self._get_buddy(my_csh) + my_buddy = self.get_buddy_by_handle(my_csh) my_nick = my_buddy.props.nick if my_buddy is not None else '?' ka_debug.info('I am %s, my handle in that group is %u' % \ (my_nick, my_csh)) return my_nick, my_csh - def _get_buddy(self, cs_handle): + def get_buddy_by_handle(self, cs_handle): """Get a Buddy from a channel specific handle.""" - ka_debug.info('Trying to find owner of handle %u...' % cs_handle) - group = self.text_chan[telepathy.CHANNEL_INTERFACE_GROUP] - my_csh = group.GetSelfHandle() - ka_debug.info('My handle in that group is %u' % my_csh) - if my_csh == cs_handle: - handle = self.telepathy_conn.GetSelfHandle() - ka_debug.info('CS handle %u belongs to me, %u' % \ - (cs_handle, handle)) - elif group.GetGroupFlags() & telepathy.CHANNEL_GROUP_FLAG_CHANNEL_SPECIFIC_HANDLES: - handle = group.GetHandleOwners([cs_handle])[0] - ka_debug.info('CS handle %u belongs to %u' % \ - (cs_handle, handle)) - else: - handle = cs_handle - ka_debug.info('non-CS handle %u belongs to itself' % handle) - #TODO: deal with failure to get the handle owner + try: + ka_debug.info('Trying to find owner of handle %u...' % cs_handle) + group = self.text_chan[telepathy.CHANNEL_INTERFACE_GROUP] + my_csh = group.GetSelfHandle() + ka_debug.info('My handle in that group is %u' % my_csh) + if my_csh == cs_handle: + handle = self.telepathy_conn.GetSelfHandle() + ka_debug.info('CS handle %u belongs to me, %u' % \ + (cs_handle, handle)) + elif group.GetGroupFlags() & telepathy.CHANNEL_GROUP_FLAG_CHANNEL_SPECIFIC_HANDLES: + handle = group.GetHandleOwners([cs_handle])[0] + ka_debug.info('CS handle %u belongs to %u' % \ + (cs_handle, handle)) + else: + handle = cs_handle + ka_debug.info('non-CS handle %u belongs to itself' % handle) + #TODO: deal with failure to get the handle owner + + return self.pservice.get_buddy_by_telepathy_handle( + self.telepathy_conn.service_name, + self.telepathy_conn.object_path, handle) + except: + ka_debug.err('buddy added failed [%s] [%s]' % \ + (sys.exc_info()[0], sys.exc_info()[1])) + traceback.print_exc(file=sys.__stderr__) + return None - return self.pservice.get_buddy_by_telepathy_handle( - self.telepathy_conn.service_name, - self.telepathy_conn.object_path, handle) diff --git a/ep_page_gettingstarted.py b/ep_page_gettingstarted.py index 86d2c3c..ab0b473 100644 --- a/ep_page_gettingstarted.py +++ b/ep_page_gettingstarted.py @@ -22,6 +22,7 @@ import sys import gtk import ka_debug +import ka_widget class GettingstartedController(object): """ @@ -29,9 +30,11 @@ class GettingstartedController(object): 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. + _getting_started_text = """Getting started with Kandid: -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. +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 these automatically generated images. + +Kandid uses a simulated evolution without a fitness function. A cybernetic system has no aesthetic feeling. You select favorite images to give them a higher chance to reproduce. Over some generation you can find 'cool' looking images. """ def __init__(self, controller, widget_list, activity_root, started_anew): @@ -51,7 +54,23 @@ Kandid uses a simulated evolution without a fitness function. A cybernetic syste """ """ page = gtk.HBox() self._widget_list.remember('startHpaned', page) + teaserBox = gtk.VBox() + teaserBox.set_border_width(30) + try: + image_file = ka_widget.KandidWidget.get_introimage_path() \ + + 'kandid-teaser.jpg' + image = gtk.Image() + image.set_from_file(image_file) + teaserBox.pack_start(image, expand=False, fill=False) + except: + ka_debug.err('locating intro image failed [%s] [%s]' % \ + (sys.exc_info()[0], sys.exc_info()[1])) + traceback.print_exc(file=sys.__stderr__) + page.pack_start(teaserBox, expand=False, fill=False) + + textBox = gtk.VBox() + textBox.set_border_width(30) scrolled_window = gtk.ScrolledWindow(hadjustment=None, vadjustment=None) self._widget_list.remember('start_scrolledwindow', scrolled_window) scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) @@ -59,10 +78,14 @@ Kandid uses a simulated evolution without a fitness function. A cybernetic syste self._widget_list.remember('gettingstarted_textview', textview) textview.set_wrap_mode(gtk.WRAP_WORD) textview.set_editable(False) + textview.set_left_margin(10) + textview.set_right_margin(10) scrolled_window.add(textview) - page.pack_start(scrolled_window, expand=True, fill=True) - + textBox.pack_start(scrolled_window, expand=True, fill=True) + page.pack_start(textBox, expand=True, fill=True) + controlBox = gtk.VBox() + controlBox.set_border_width(30) readintroLinkbutton = gtk.LinkButton('') readintroLinkbutton.set_label(_('Read the Introduction')) self._widget_list.remember('readintroLinkbutton', readintroLinkbutton) @@ -72,7 +95,7 @@ Kandid uses a simulated evolution without a fitness function. A cybernetic syste startnewLinkbutton.set_label(_('Show image population')) self._widget_list.remember('startnewLinkbutton', startnewLinkbutton) controlBox.pack_start(startnewLinkbutton, expand=False, fill=False) - page.pack_start(controlBox, expand=True, fill=True) + page.pack_start(controlBox, expand=False, fill=False) return page, gtk.Label(_('Getting started')) @@ -91,6 +114,8 @@ Kandid uses a simulated evolution without a fitness function. A cybernetic syste 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(), '\n') +#!! buf.insert(buf.get_end_iter(), '\n') buf.insert(buf.get_end_iter(), translated) except: ka_debug.err('localizing page "getting started" failed [%s] [%s]' % \ diff --git a/ep_page_intro.py b/ep_page_intro.py index 0a0f47f..e6243fe 100644 --- a/ep_page_intro.py +++ b/ep_page_intro.py @@ -17,45 +17,24 @@ from gettext import gettext as _ -import os import gtk import ka_debug import ka_widget import ka_html_page -import ka_extensionpoint + class IntroController(ka_html_page.HtmlPage): """ """ - @staticmethod - def get_localized_path(locale, territory): - """Try to read intro.html from LOCALE folder. - Default input file is locale/en/intro.html""" - bundle_path = ka_extensionpoint.get_bundle_path() - file_path = os.path.join(bundle_path, - 'locale', - locale + '_' + territory, - 'intro.html') - if not os.path.isfile(file_path): - file_path = os.path.join(bundle_path, - 'locale', - locale, - 'intro.html') - if not os.path.isfile(file_path): - file_path = os.path.join(bundle_path, - 'locale', - 'en', - 'intro.html') - return file_path - def __init__(self, controller, widget_list, activity_root, started_anew): """ pre: widget_list is not None """ - locale, territory = ka_widget.KandidWidget.get_localization() - file_uri = 'file://' + IntroController.get_localized_path(locale, territory) + file_uri = 'file://' \ + + ka_widget.KandidWidget.get_localized_path() \ + + 'intro.html' super(IntroController, self).__init__(controller, file_uri, 'intro_scrolledwindow', diff --git a/ep_page_population.py b/ep_page_population.py index b38553c..e48069b 100644 --- a/ep_page_population.py +++ b/ep_page_population.py @@ -31,6 +31,7 @@ import model_history import kandidtube import ka_status import ka_incoming +import ka_preference POPULATION_CAPACITY = 12 @@ -501,7 +502,9 @@ class PopulationController(object): exporter = ka_extensionpoint.create('exporter_png', self.model.protozoans[pix], self._activity_root) - exporter.export(480, 480) + preference = ka_preference.Preference.instance() + export_size = preference.get(ka_preference.EXPORT_SIZE) + exporter.export(*export_size) def on_zoomprotozoon_activate(self, *args): """Publish single protozoon to all other buddies. diff --git a/ep_page_status.py b/ep_page_status.py index 1622b04..171988a 100644 --- a/ep_page_status.py +++ b/ep_page_status.py @@ -23,6 +23,7 @@ import gobject import ka_debug import ka_status +import ka_preference class StatusController(object): """ @@ -46,7 +47,31 @@ class StatusController(object): def create_gui(self): """ """ - page = gtk.HBox() + page = gtk.VBox() + + param_panel = gtk.HBox() + param_panel.set_border_width(10) + label1 = gtk.Label(_('Size of the exported image in pixels: ')) + param_panel.pack_start(label1, expand=False, fill=False) + cb = gtk.combo_box_new_text() + cb.connect("changed", self.on_changed) + cb.append_text('200 * 200') + cb.append_text('400 * 400') + cb.append_text('600 * 600') + cb.append_text('1000 * 1000') + preference = ka_preference.Preference.instance() + export_size = preference.get(ka_preference.EXPORT_SIZE) + if export_size[0] == 400: + cb.set_active(1) + elif export_size[0] == 600: + cb.set_active(2) + elif export_size[0] == 1000: + cb.set_active(3) + else: + cb.set_active(0) + param_panel.pack_start(cb, expand=False, fill=False) + page.pack_start(param_panel, expand=False, fill=True) + self._widget_list.remember('statusPage', page) scrolled_window = gtk.ScrolledWindow(hadjustment=None, vadjustment=None) textview = gtk.TextView() @@ -54,6 +79,7 @@ class StatusController(object): textview.set_editable(False) scrolled_window.add(textview) page.pack_start(scrolled_window, expand=True, fill=True) + return page, gtk.Label(_('Status')) def autoconnect_events(self): @@ -103,3 +129,17 @@ class StatusController(object): self._visible = False # ka_debug.info('on_notebook_switch_page %s %s' % (self._visible, args[2])) + def on_changed(self, widget): + index = widget.get_active() + ka_debug.info('on_changed %d' % (index)) + preference = ka_preference.Preference.instance() + if index == 0: + preference.set(ka_preference.EXPORT_SIZE, (200, 200)) + elif index == 1: + preference.set(ka_preference.EXPORT_SIZE, (400, 400)) + elif index == 2: + preference.set(ka_preference.EXPORT_SIZE, (600, 600)) + elif index == 3: + preference.set(ka_preference.EXPORT_SIZE, (1000, 1000)) + preference.store() + diff --git a/ka_html_page.py b/ka_html_page.py index f376867..2c8f3a4 100644 --- a/ka_html_page.py +++ b/ka_html_page.py @@ -82,7 +82,7 @@ class HtmlPage(object): """Insert HTML view.""" if self._htmlview is not None: intro_scrolled = self._widget_list.get_widget(self._parent_widget) - intro_scrolled.add(self._htmlview) + intro_scrolled.add_with_viewport(self._htmlview) def set_uri(self, uri): """ """ diff --git a/ka_importer.py b/ka_importer.py index 9bb1ff5..1ee657a 100644 --- a/ka_importer.py +++ b/ka_importer.py @@ -63,17 +63,23 @@ def _populate(): _populated = True _populate_theme_list(get_import_path()) -def get_import_path(): +def get_data_path(): """ post: os.path.exists(__return__) """ - import_path = ka_debug.DEBUG_PROFILE_PATH # default path for debugging + data_path = ka_debug.DEBUG_PROFILE_PATH # default path for debugging if 'SUGAR_BUNDLE_PATH' in os.environ: import sugar.env ka_debug.info('profile_path ' + sugar.env.get_profile_path()) - import_path = sugar.env.get_profile_path() - import_path = os.path.join(import_path, - 'net.sourceforge.kandid/data/collection') + data_path = sugar.env.get_profile_path() + data_path = os.path.join(data_path, 'net.sourceforge.kandid/data/') + return data_path + +def get_import_path(): + """ + post: os.path.exists(__return__) + """ + import_path = os.path.join(get_data_path(), 'collection') if not os.path.exists(import_path): try: os.makedirs(import_path) diff --git a/ka_preference.py b/ka_preference.py new file mode 100644 index 0000000..de5d795 --- /dev/null +++ b/ka_preference.py @@ -0,0 +1,109 @@ +# coding: UTF-8 +# Copyright 2009, 2010 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 ka_debug +import ka_importer +import os +import sys +import traceback + +EXPORT_SIZE = 'export_size' + +class Preference(object): + """ + inv: self._preference_dict is not None + """ + _preference = None + + def __init__(self): + """ + """ + self._dirty_flag = False + self._first_get = False + self._preference_dict = {} + + @staticmethod + def instance(): + if Preference._preference is None: + Preference._preference = Preference() + return Preference._preference + + def set(self, topic, value): + """ + pre: topic is not None + pre: value is not None + """ + self._dirty_flag = True + self._preference_dict[topic] = value + + def get(self, topic): + """ + pre: topic is not None + """ + if not self._first_get: + self._default() + self.recall(); + self._first_get = True + return self._preference_dict[topic] if topic in self._preference_dict \ + else None + + def isDirty(self): + return self._dirty_flag + + def _file_name(self): + target_path = ka_importer.get_data_path() + return os.path.join(target_path, 'user_prefereces') + + def _default(self): + self._preference_dict = {EXPORT_SIZE: (400, 400)} + + def store(self): + """Write textual content to the file system. + """ + if self._dirty_flag: + out_file = None + fn = '' + try: + fn = self._file_name() + out_file = open(fn, 'w') + out_file.write(repr(self._preference_dict)) + self._dirty_flag = False + except: + ka_debug.err('failed writing [%s] [%s] [%s]' % \ + (fn, sys.exc_info()[0], sys.exc_info()[1])) + traceback.print_exc(file=sys.__stderr__) + finally: + if out_file: + out_file.close() + + def recall(self): + """ + """ + in_file = None + fn = '' + try: + fn = self._file_name() + if os.path.exists(fn): + in_file = open(fn, 'r') + self._preference_dict = eval(in_file.read()) + except: + ka_debug.err('failed reading [%s] [%s] [%s]' % \ + (fn, sys.exc_info()[0], sys.exc_info()[1])) + traceback.print_exc(file=sys.__stderr__) + finally: + if in_file: + in_file.close() diff --git a/ka_widget.py b/ka_widget.py index 1567ffe..b7c2361 100644 --- a/ka_widget.py +++ b/ka_widget.py @@ -19,6 +19,7 @@ import gtk import os import ka_debug +import ka_extensionpoint class WidgetList(): """ """ @@ -90,3 +91,33 @@ class KandidWidget(object): break ka_debug.info('languages: %s "%s" "%s"' % (languages, locale, territory)) return locale, territory + + @staticmethod + def get_localized_path(): + """Try to find the LOCALE folder. Default folder is locale/en/""" + locale, territory = KandidWidget.get_localization() + bundle_path = ka_extensionpoint.get_bundle_path() + path_to_file = os.path.join(bundle_path, + 'locale', + locale + '_' + territory, + '') + if not os.path.isfile(path_to_file): + path_to_file = os.path.join(bundle_path, + 'locale', + locale, + '') + if not os.path.isfile(path_to_file): + path_to_file = os.path.join(bundle_path, + 'locale', + 'en', + '') + return path_to_file + + @staticmethod + def get_introimage_path(): + """Try to locate the intro folder""" + bundle_path = ka_extensionpoint.get_bundle_path() + path_to_file = os.path.join(bundle_path, + 'intro', + '') + return path_to_file diff --git a/kandidtube.py b/kandidtube.py index b442421..a57291e 100644 --- a/kandidtube.py +++ b/kandidtube.py @@ -15,8 +15,6 @@ # 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 hashlib import base64 @@ -44,7 +42,7 @@ class KandidTube(ExportedGObject): self._tube = tube self._my_id = my_id self._is_initiator = is_initiator - self._get_buddy = get_buddy # Converts handle to Buddy object + self.get_buddy_by_handle = get_buddy # Converts handle to Buddy object self._entered = False # Have we set up the tube? self._participating_buddies = set([]) self._status = ka_status.Status.instance() @@ -57,22 +55,15 @@ class KandidTube(ExportedGObject): ka_debug.info('Tube: Removed participants: %r' % removed) for handle, bus_name in added: ka_debug.info('participant add: [%s] [%s] ' % (handle, bus_name)) - buddy = self._get_buddy(handle) + buddy = self.get_buddy_by_handle(handle) if buddy is not None: ka_debug.info('Tube: Handle %u (Buddy [%s]) was added' % \ (handle, buddy.props.nick)) self._participating_buddies |= set([buddy.props.nick]) for handle in removed: - nickname = '?' - buddy = None - try: - buddy = self._get_buddy(handle) - nickname = buddy.props.nick - except: - ka_debug.err('get buddy failed [%s] [%s]' % \ - (sys.exc_info()[0], sys.exc_info()[1])) - traceback.print_exc(file=sys.__stderr__) + buddy = self.get_buddy_by_handle(handle) if buddy is not None: + nickname = buddy.props.nick ka_debug.info('Buddy [%s] was removed' % nickname) self._participating_buddies -= set([nickname]) self._status.set(ka_status.TOPIC_COLLABORATION, diff --git a/model_population.py b/model_population.py index 207c240..8852dc7 100644 --- a/model_population.py +++ b/model_population.py @@ -235,6 +235,7 @@ class KandidModel(object): poor = protoz for new_at, protoz in enumerate(self.protozoans): if protoz is poor: + #TODO history, forget former protozoans[new_at] self.protozoans[new_at] = new_one self.fitness[new_at] = 5.0 return new_at diff --git a/po/Kandid.pot b/po/Kandid.pot index d327e41..caeb54f 100644 --- a/po/Kandid.pot +++ b/po/Kandid.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2010-07-25 19:18+0200\n" +"POT-Creation-Date: 2011-01-29 15:13+0100\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" @@ -20,7 +20,11 @@ msgstr "" msgid "Kandid" msgstr "" -#: /home/strom/minimal/activities/Kandid.activity/ep_page_status.py:57 +#: /home/strom/minimal/activities/Kandid.activity/ep_page_status.py:54 +msgid "Size of the exported image in pixels: " +msgstr "" + +#: /home/strom/minimal/activities/Kandid.activity/ep_page_status.py:83 msgid "Status" msgstr "" @@ -121,19 +125,19 @@ msgstr "" msgid "Compositing used right node as a mask surface." msgstr "" -#: /home/strom/minimal/activities/Kandid.activity/ep_page_gettingstarted.py:67 +#: /home/strom/minimal/activities/Kandid.activity/ep_page_gettingstarted.py:90 msgid "Read the Introduction" msgstr "" -#: /home/strom/minimal/activities/Kandid.activity/ep_page_gettingstarted.py:72 +#: /home/strom/minimal/activities/Kandid.activity/ep_page_gettingstarted.py:95 msgid "Show image population" msgstr "" -#: /home/strom/minimal/activities/Kandid.activity/ep_page_gettingstarted.py:77 +#: /home/strom/minimal/activities/Kandid.activity/ep_page_gettingstarted.py:100 msgid "Getting started" msgstr "" -#: /home/strom/minimal/activities/Kandid.activity/ep_page_gettingstarted.py:90 +#: /home/strom/minimal/activities/Kandid.activity/ep_page_gettingstarted.py:113 msgid "getting_started" msgstr "" @@ -172,7 +176,7 @@ msgstr "" #: /home/strom/minimal/activities/Kandid.activity/ka_incoming.py:84 #: /home/strom/minimal/activities/Kandid.activity/ep_page_zoom.py:56 -#: /home/strom/minimal/activities/Kandid.activity/ep_page_population.py:156 +#: /home/strom/minimal/activities/Kandid.activity/ep_page_population.py:157 msgid "Zoom" msgstr "" @@ -295,55 +299,55 @@ msgstr "" msgid "Complementary color scheme" msgstr "" -#: /home/strom/minimal/activities/Kandid.activity/ep_page_population.py:67 +#: /home/strom/minimal/activities/Kandid.activity/ep_page_population.py:68 msgid "Breed" msgstr "" -#: /home/strom/minimal/activities/Kandid.activity/ep_page_population.py:71 +#: /home/strom/minimal/activities/Kandid.activity/ep_page_population.py:72 msgid "Flurry rate:" msgstr "" -#: /home/strom/minimal/activities/Kandid.activity/ep_page_population.py:83 +#: /home/strom/minimal/activities/Kandid.activity/ep_page_population.py:84 msgid "Random" msgstr "" -#: /home/strom/minimal/activities/Kandid.activity/ep_page_population.py:141 +#: /home/strom/minimal/activities/Kandid.activity/ep_page_population.py:142 msgid "Population" msgstr "" -#: /home/strom/minimal/activities/Kandid.activity/ep_page_population.py:148 +#: /home/strom/minimal/activities/Kandid.activity/ep_page_population.py:149 msgid "My favorite" msgstr "" -#: /home/strom/minimal/activities/Kandid.activity/ep_page_population.py:152 +#: /home/strom/minimal/activities/Kandid.activity/ep_page_population.py:153 msgid "Awful bore" msgstr "" -#: /home/strom/minimal/activities/Kandid.activity/ep_page_population.py:161 +#: /home/strom/minimal/activities/Kandid.activity/ep_page_population.py:162 msgid "Publish to my friends" msgstr "" -#: /home/strom/minimal/activities/Kandid.activity/ep_page_population.py:164 +#: /home/strom/minimal/activities/Kandid.activity/ep_page_population.py:165 msgid "Send image to journal" msgstr "" -#: /home/strom/minimal/activities/Kandid.activity/ep_page_population.py:167 +#: /home/strom/minimal/activities/Kandid.activity/ep_page_population.py:168 msgid "Send" msgstr "" -#: /home/strom/minimal/activities/Kandid.activity/ep_page_population.py:172 +#: /home/strom/minimal/activities/Kandid.activity/ep_page_population.py:173 msgid "Explain details" msgstr "" -#: /home/strom/minimal/activities/Kandid.activity/ep_page_population.py:175 +#: /home/strom/minimal/activities/Kandid.activity/ep_page_population.py:176 msgid "Show ancestors" msgstr "" -#: /home/strom/minimal/activities/Kandid.activity/ep_page_population.py:178 +#: /home/strom/minimal/activities/Kandid.activity/ep_page_population.py:179 msgid "Explain" msgstr "" -#: /home/strom/minimal/activities/Kandid.activity/ep_page_intro.py:77 +#: /home/strom/minimal/activities/Kandid.activity/ep_page_intro.py:56 msgid "Introduction" msgstr "" diff --git a/test_model.py b/test_model.py index ee42b1f..dfc0fbc 100644 --- a/test_model.py +++ b/test_model.py @@ -39,7 +39,6 @@ import exon_color import exon_buzzword import exon_direction import exon_position -import ep_page_intro import test_enumerator @@ -482,10 +481,9 @@ class TestKandidModel(unittest.TestCase): self.assertTrue(lc in string.ascii_lowercase) for tc in territory: self.assertTrue(tc in string.ascii_uppercase) - file_path = ep_page_intro.IntroController.get_localized_path(locale, - territory) + file_path = ka_widget.KandidWidget.get_localized_path() self.assertTrue(file_path.endswith('/Kandid.activity/locale/' - + locale + '/intro.html')) + + locale + '/')) def test_enumerator_explain(self): self.assertEqual(0, test_enumerator.explain()) diff --git a/test_preference.py b/test_preference.py new file mode 100644 index 0000000..785aec9 --- /dev/null +++ b/test_preference.py @@ -0,0 +1,55 @@ +# coding: UTF-8 +# Copyright 2009, 2010 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 unittest +import ka_preference + +class TestKandidPreference(unittest.TestCase): + + def setUp(self): + pass + + def tearDown(self): + pass + + def test_status(self): + preference = ka_preference.Preference.instance() + default_size = preference.get(ka_preference.EXPORT_SIZE) + self.assertEqual(2, len(default_size)) + self.assertEqual(400, default_size[0]) + self.assertEqual(400, default_size[1]) + + preference.set(ka_preference.EXPORT_SIZE, (123, 456) ) + self.assertTrue(preference.isDirty()) + a_size = preference.get(ka_preference.EXPORT_SIZE) + self.assertEqual(123, a_size[0]) + self.assertEqual(456, a_size[1]) + + def test_save_preference(self): + preference = ka_preference.Preference.instance() + preference.set(ka_preference.EXPORT_SIZE, (312, 624) ) + preference.store() + self.assertFalse(preference.isDirty()) + + preference.set(ka_preference.EXPORT_SIZE, (111, 222) ) + preference.recall() + a_size = preference.get(ka_preference.EXPORT_SIZE) + self.assertEqual(312, a_size[0]) + self.assertEqual(624, a_size[1]) + + preference.set(ka_preference.EXPORT_SIZE, (400, 400) ) + preference.store() diff --git a/test_status.py b/test_status.py index 6db3b33..71b17de 100644 --- a/test_status.py +++ b/test_status.py @@ -34,7 +34,7 @@ class TestKandidStatus(unittest.TestCase): self.assertTrue(status.isDirty()) status.set(ka_status.TOPIC_COLLABORATION, ka_status.SUB_BUDDIES_JOINED, '2') - self.assertTrue(status.recall().find('Running: Kandid, release v8, DoB activated') >= 0) + self.assertTrue(status.recall().find('Running: Kandid, release v9, DoB activated') >= 0) self.assertFalse(status.isDirty()) def test_os_status(self): diff --git a/test_suite.py b/test_suite.py index 9169ce2..36b1989 100644 --- a/test_suite.py +++ b/test_suite.py @@ -26,6 +26,7 @@ import test_exporter import test_model import test_layer import test_pages +import test_preference ka_debug.info('starting TestSuite') ka_debug.err('testing error message channel.') @@ -36,6 +37,7 @@ alltests = unittest.TestSuite((\ unittest.makeSuite(test_layer.TestKandidLayer), \ unittest.makeSuite(test_exporter.TestKandidExporter), \ unittest.makeSuite(test_status.TestKandidStatus), \ + unittest.makeSuite(test_preference.TestKandidPreference), \ unittest.makeSuite(test_history.TestKandidHistory), \ unittest.makeSuite(test_model.TestKandidModel), \ )) |