From 420f73b64979f4a695c780f080c8873229260f27 Mon Sep 17 00:00:00 2001 From: Antoine van Gelder Date: Mon, 29 Oct 2007 09:21:06 +0000 Subject: JokeMachine-3.xo * Feature: Put alerts up when joke submitted and approved over mesh * Feature: Put alert up advising patience when joining a shared jokebook * Feature: Made Lesson Plans button work * Feature: Safe fallback for builds without sugar.alert * Feature: Hooked LanguageCombo up * i18n: Created (a rough!) Afrikaans translation * Fixed: Prepended Cover on preview * Fixed: Don't hardcode JokeEditor delete button position * Fixed: On read jokebook & empty -> "Edit My Jokes" -> Go to edit my jokes tab * Updated :Mesh code for dbus tubes changes --- diff --git a/JokeMachine.wpr b/JokeMachine.wpr deleted file mode 100644 index c806ff4..0000000 --- a/JokeMachine.wpr +++ /dev/null @@ -1,1088 +0,0 @@ -#!wing -#!version=3.0 -################################################################## -# Wing IDE project file # -################################################################## -[project attributes] -proj.directory-list = [{'dirloc': loc('persistence'), - 'excludes': (), - 'filter': '*', - 'include_hidden': 0, - 'recursive': 1, - 'watch_for_changes': 1}, - {'dirloc': loc('.'), - 'excludes': (), - 'filter': '*', - 'include_hidden': 0, - 'recursive': 1, - 'watch_for_changes': 1}] -proj.file-list = [loc('activity/activity-jokemachine.svg'), - loc('activity/activity.info'), - loc('globals.py'), - loc('i18n.py'), - loc('i18n_misc_strings.py'), - loc('images/GameLogoCharacter.png'), - loc('JokeMachineActivity.py'), - loc('lessons/Introduction/default.abw'), - loc('lessons/Lesson 1/default.abw'), - loc('lessons/Lesson 2/default.abw'), - loc('lessons/Lesson 3/default.abw'), - loc('lessons/Lesson 4/default.abw'), - loc('locale/af.po'), - loc('locale/de_DE/activity.linfo'), - loc('locale/org.worldwideworkshop.jokemachine.pot'), - loc('locale/org.worldwideworkshop.poll.pot'), - loc('locale/zh_CN/activity.linfo'), - loc('MANIFEST'), - loc('NEWS'), - loc('pages/choose.py'), - loc('pages/cover.py'), - loc('pages/frame.py'), - loc('pages/joke.py'), - loc('pages/page.py'), - loc('pages/submit.py'), - loc('pages/theme.py'), - loc('pages/__init__.py'), - loc('setup.py'), - loc('unit/persistence.py')] -proj.file-type = 'normal' -[user attributes] -debug.err-values = {None: {}} -debug.var-col-widths = [0.39499036608863197, - 0.60500963391136797] -edit.show-tab-force-warning = 0 -guimgr.overall-gui-state = {'windowing-policy': 'combined-window', - 'windows': [{'name': 'oQxUmNpVfpJewBNvtbSPVPBdPA'\ - 'TKgEGJ', - 'size-state': '', - 'type': 'dock', - 'view': {'area': 'tall', - 'current_pages': [0, - 2], - 'notebook_display': 'normal', - 'notebook_percent': 0.22585551330798478, - 'override_title': None, - 'pagelist': [('debug-stack', - 'tall', - 1, - None), - ('indent', - 'tall', - 2, - {}), - ('project', - 'tall', - 0, - {'tree-state': {'tree-states': {'deep': {'col'\ - 'umn-widths': [1.0], - 'expanded-nodes': [(0,)], - 'selected-nodes': [], - 'top-node': (0,)}}, - 'tree-style': 'deep'}}), - ('source-assistant', - 'tall', - 2, - {'docstring-during-complete': 0, - 'wrap-lines': True}), - ('browser', - 'tall', - 0, - {'all_tree_states': {u'By Module': {'column-w'\ - 'idths': [1.0], - 'expanded-nodes': [], - 'selected-nodes': [[('generic attribute', - loc('globals.py'), - '')]], - 'top-node': [('generic attribute', - loc('globals.py'), - '')]}, - loc('JokeMachineActivity.py'): {'column-widths': [1.0], - 'expanded-nodes': [], - 'selected-nodes': [], - 'top-node': [('class def', - loc('JokeMachineActivity.py'), - 'JokeMachineActivity')]}, - loc('MANIFEST'): {'column-widths': [1.0], - 'expanded-nodes': [], - 'selected-nodes': [], - 'top-node': None}, - loc('TODO'): {'column-widths': [1.0], - 'expanded-nodes': [], - 'selected-nodes': [], - 'top-node': None}, - loc('globals.py'): {'column-widths': [1.0], - 'expanded-nodes': [], - 'selected-nodes': [], - 'top-node': [('generic attribute', - loc('globals.py'), - 'Globals')]}, - loc('gui/canvasimage.py'): {'column-widths': [1.0], - 'expanded-nodes': [], - 'selected-nodes': [], - 'top-node': None}, - loc('gui/canvaslistbox.py'): {'column-widths': [1.0], - 'expanded-nodes': [], - 'selected-nodes': [], - 'top-node': [('class def', - loc('gui/canvaslistbox.py'), - 'CanvasListBox')]}, - loc('gui/frame.py'): {'column-widths': [1.0], - 'expanded-nodes': [[('class def', - loc('gui/frame.py'), - 'Frame')]], - 'selected-nodes': [], - 'top-node': [('class def', - loc('gui/frame.py'), - 'Frame')]}, - loc('gui/page.py'): {'column-widths': [1.0], - 'expanded-nodes': [[('class def', - loc('gui/page.py'), - 'Page')]], - 'selected-nodes': [[('class def', - loc('gui/page.py'), - 'Page')]], - 'top-node': [('class def', - loc('gui/page.py'), - 'Page')]}, - loc('gui/theme.py'): {'column-widths': [1.0], - 'expanded-nodes': [], - 'selected-nodes': [], - 'top-node': [('generic attribute', - loc('gui/theme.py'), - 'BORDER_WIDTH')]}, - loc('pages/choose.py'): {'column-widths': [1.0], - 'expanded-nodes': [], - 'selected-nodes': [], - 'top-node': [('class def', - loc('pages/choose.py'), - 'Choose')]}, - loc('pages/cover.py'): {'column-widths': [1.0], - 'expanded-nodes': [], - 'selected-nodes': [], - 'top-node': [('class def', - loc('pages/cover.py'), - 'Cover')]}, - loc('pages/edit.py'): {'column-widths': [1.0], - 'expanded-nodes': [[('class def', - loc('pages/edit.py'), - 'Edit')], - [('class def', - loc('pages/edit.py'), - 'EditInfo')], - [('class def', - loc('pages/edit.py'), - 'EditJokes')], - [('class def', - loc('pages/edit.py'), - 'EditReview')], - [('class def', - loc('pages/edit.py'), - 'PageSelector')]], - 'selected-nodes': [], - 'top-node': [('class def', - loc('pages/edit.py'), - 'Edit')]}, - loc('pages/joke.py'): {'column-widths': [1.0], - 'expanded-nodes': [], - 'selected-nodes': [], - 'top-node': [('class def', - loc('pages/joke.py'), - 'Joke')]}, - loc('pages/preview.py'): {'column-widths': [1.0], - 'expanded-nodes': [], - 'selected-nodes': [], - 'top-node': [('class def', - loc('pages/preview.py'), - 'Preview')]}, - loc('pages/submit.py'): {'column-widths': [1.0], - 'expanded-nodes': [], - 'selected-nodes': [], - 'top-node': [('class def', - loc('pages/submit.py'), - 'JokeEditor')]}, - loc('persistence/joke.py'): {'column-widths': [1.0], - 'expanded-nodes': [], - 'selected-nodes': [], - 'top-node': [('class def', - loc('persistence/joke.py'), - 'Joke')]}, - loc('persistence/jokebook.py'): {'column-widths': [1.0], - 'expanded-nodes': [], - 'selected-nodes': [], - 'top-node': [('class def', - loc('persistence/jokebook.py'), - 'Jokebook')]}, - loc('persistence/jokemachinestate.py'): {'column-widths': [1.0], - 'expanded-nodes': [], - 'selected-nodes': [], - 'top-node': [('class def', - loc('persistence/jokemachinestate.py'), - 'JokeMachineState')]}, - loc('setup.py'): {'column-widths': [1.0], - 'expanded-nodes': [], - 'selected-nodes': [], - 'top-node': None}, - loc('unit/test_persistence.py'): {'column-widths': [1.0], - 'expanded-nodes': [], - 'selected-nodes': [], - 'top-node': [('function def', - loc('unit/test_persistence.py'), - 'dump')]}, - loc('../poll-builder/poll.py'): {'column-widths': [1.0], - 'expanded-nodes': [], - 'selected-nodes': [], - 'top-node': [('generic attribute', - loc('../poll-builder/poll.py'), - 'COLOR_BG_BUTTONS')]}, - u'All Classes': {'column-widths': [1.0], - 'expanded-nodes': [], - 'selected-nodes': [None], - 'top-node': None}, - loc('unit/unit.py'): {'column-widths': [1.0], - 'expanded-nodes': [], - 'selected-nodes': [], - 'top-node': [('generic attribute', - loc('unit/unit.py'), - 'bar')]}, - loc('util/decorators.py'): {'column-widths': [1.0], - 'expanded-nodes': [], - 'selected-nodes': [], - 'top-node': [('generic attribute', - loc('util/decorators.py'), - 'DecoratorWithArgs')]}, - loc('util/persistence.py'): {'column-widths': [1.0], - 'expanded-nodes': [], - 'selected-nodes': [], - 'top-node': [('class def', - loc('util/persistence.py'), - 'Persistent')]}}, - 'browse_mode': u'Current Module', - 'follow-selection': 0, - 'sort_mode': 'Alphabetically', - 'visibility_options': {u'Derived Classes': 0, - u'Imported': 0, - u'Inherited': 0, - u'Modules': 1}}), - ('templating#02EFWRQK9X23', - 'tall', - 0, - {'tree-states': {u'/home/antoine/.wingide3/templates': [], - u'/opt/wing/scripts/templates': []}})], - 'primary_view_state': {'area': 'wide', - 'current_pages': [3, - 3], - 'notebook_display': 'normal', - 'notebook_percent': 0.30000000000000004, - 'override_title': None, - 'pagelist': [('bookmarks', - 'wide', - 1, - None), - ('debug-breakpoints', - 'wide', - 0, - None), - ('debug-io', - 'wide', - 1, - {'attrib-starts': [], - 'first-line': 0, - 'sel-line': 0, - 'sel-line-start': 0, - 'selection_end': 0, - 'selection_start': 0}), - ('debug-probe', - 'wide', - 2, - {'attrib-starts': [], - 'first-line': 0, - 'sel-line': 0, - 'sel-line-start': 0, - 'selection_end': 4, - 'selection_start': 4}), - ('debug-exceptions', - 'wide', - 0, - None), - ('debug-modules', - 'wide', - 1, - {}), - ('python-shell', - 'wide', - 2, - {'attrib-starts': [], - 'first-line': 0, - 'sel-line': 3, - 'sel-line-start': 148, - 'selection_end': 152, - 'selection_start': 152}), - ('interactive-search', - 'wide', - 0, - {'fScope': {'fFileSetName': u'All Source Files', - 'fLocation': None, - 'fRecursive': True, - 'fType': 'current-file'}, - 'fSearchSpec': {'fEndPos': None, - 'fIncludeLinenos': True, - 'fInterpretBackslashes': False, - 'fMatchCase': 1, - 'fOmitBinary': True, - 'fRegexFlags': 44, - 'fReplaceText': u'self.__is_initiator', - 'fReverse': False, - 'fSearchText': u'width', - 'fStartPos': 0, - 'fStyle': 'text', - 'fWholeWords': False, - 'fWrap': True}, - 'fUIOptions': {'fAutoBackground': True, - 'fFilePrefix': 'short-file', - 'fFindAfterReplace': True, - 'fInSelection': False, - 'fIncremental': True, - 'fReplaceOnDisk': False, - 'fShowFirstMatch': False, - 'fShowLineno': True, - 'fShowReplaceWidgets': 1}, - 'replace-entry-expanded': False, - 'search-entry-expanded': False}), - ('batch-search', - 'wide', - 0, - {'fScope': {'fFileSetName': u'All Source Files', - 'fLocation': None, - 'fRecursive': True, - 'fType': 'project-files'}, - 'fSearchSpec': {'fEndPos': None, - 'fIncludeLinenos': True, - 'fInterpretBackslashes': False, - 'fMatchCase': False, - 'fOmitBinary': True, - 'fRegexFlags': 46, - 'fReplaceText': u'', - 'fReverse': False, - 'fSearchText': u'.png', - 'fStartPos': 0, - 'fStyle': 'text', - 'fWholeWords': False, - 'fWrap': True}, - 'fUIOptions': {'fAutoBackground': True, - 'fFilePrefix': 'short-file', - 'fFindAfterReplace': True, - 'fInSelection': False, - 'fIncremental': True, - 'fReplaceOnDisk': False, - 'fShowFirstMatch': False, - 'fShowLineno': True, - 'fShowReplaceWidgets': False}, - 'replace-entry-expanded': False, - 'search-entry-expanded': False}), - ('debug-data', - 'wide', - 0, - {}), - ('debug-watch', - 'wide', - 1, - {'node-states': [('eval', - ''), - ('eval', - ''), - ('eval', - '')], - 'tree-state': {'column-widths': [0.39468690702087289, - 0.60531309297912717], - 'expanded-nodes': [], - 'selected-nodes': [(2,)], - 'top-node': (0,)}})], - 'primary_view_state': {'editor_states': {'bookmarks': ([(loc('pages/choose.py'), - {'attrib-starts': [], - 'first-line': 13, - 'sel-line': 33, - 'sel-line-start': 1020, - 'selection_end': 1062, - 'selection_start': 1062}, - 1193494144.0174799), - (loc('gui/canvaslistbox.py'), - {'attrib-starts': [('CanvasListBox', - 25), - ('CanvasListBox.__init__', - 26)], - 'first-line': 0, - 'sel-line': 47, - 'sel-line-start': 1638, - 'selection_end': 1657, - 'selection_start': 1657}, - 1193494144.2723279), - (loc('pages/choose.py'), - {'attrib-starts': [('Choose', - 35), - ('Choose.__make_column_div', - 118)], - 'first-line': 62, - 'sel-line': 127, - 'sel-line-start': 4655, - 'selection_end': 4655, - 'selection_start': 4655}, - 1193494156.910459), - (loc('TODO'), - {'attrib-starts': [], - 'first-line': 37, - 'sel-line': 58, - 'sel-line-start': 1754, - 'selection_end': 1775, - 'selection_start': 1769}, - 1193563665.842417), - (loc('TODO'), - {'attrib-starts': [], - 'first-line': 37, - 'sel-line': 59, - 'sel-line-start': 1782, - 'selection_end': 1825, - 'selection_start': 1819}, - 1193563667.4626391), - (loc('globals.py'), - {'attrib-starts': [('__globals', - 28), - ('__globals.__init__', - 32)], - 'first-line': 13, - 'sel-line': 34, - 'sel-line-start': 1122, - 'selection_end': 1150, - 'selection_start': 1150}, - 1193563670.4271569), - (loc('i18n.py'), - {'attrib-starts': [('gather_other_translations', - 164)], - 'first-line': 133, - 'sel-line': 166, - 'sel-line-start': 5557, - 'selection_end': 5619, - 'selection_start': 5619}, - 1193563682.206208), - (loc('persistence/joke.py'), - {'attrib-starts': [('Joke', - 18), - ('Joke.test_data', - 78)], - 'first-line': 50, - 'sel-line': 79, - 'sel-line-start': 2386, - 'selection_end': 2391, - 'selection_start': 2391}, - 1193563696.6672399), - (loc('persistence/jokemachinestate.py'), - {'attrib-starts': [('JokeMachineState', - 20), - ('JokeMachineState.test_data', - 57)], - 'first-line': 38, - 'sel-line': 69, - 'sel-line-start': 2153, - 'selection_end': 2160, - 'selection_start': 2160}, - 1193563709.7158151), - (loc('gui/page.py'), - {'attrib-starts': [('Page', - 47), - ('Page.make_audiobox', - 82)], - 'first-line': 63, - 'sel-line': 84, - 'sel-line-start': 2487, - 'selection_end': 2540, - 'selection_start': 2540}, - 1193563715.156831), - (loc('persistence/jokemachinestate.py'), - {'attrib-starts': [('JokeMachineState', - 20), - ('JokeMachineState.test_data', - 57)], - 'first-line': 38, - 'sel-line': 69, - 'sel-line-start': 2153, - 'selection_end': 2184, - 'selection_start': 2178}, - 1193563726.00191), - (loc('gui/page.py'), - {'attrib-starts': [('Page', - 47), - ('Page.make_audiobox', - 82)], - 'first-line': 68, - 'sel-line': 89, - 'sel-line-start': 2679, - 'selection_end': 2705, - 'selection_start': 2699}, - 1193563726.9944689), - (loc('gui/theme.py'), - {'attrib-starts': [], - 'first-line': 103, - 'sel-line': 112, - 'sel-line-start': 3697, - 'selection_end': 3709, - 'selection_start': 3697}, - 1193563731.5031071), - (loc('gui/page.py'), - {'attrib-starts': [('Page', - 47), - ('Page.make_audiobox', - 82)], - 'first-line': 63, - 'sel-line': 84, - 'sel-line-start': 2487, - 'selection_end': 2548, - 'selection_start': 2548}, - 1193563805.340421), - (loc('globals.py'), - {'attrib-starts': [], - 'first-line': 0, - 'sel-line': 0, - 'sel-line-start': 0, - 'selection_end': 0, - 'selection_start': 0}, - 1193563815.940026), - (loc('gui/theme.py'), - {'attrib-starts': [], - 'first-line': 107, - 'sel-line': 110, - 'sel-line-start': 3611, - 'selection_end': 3611, - 'selection_start': 3611}, - 1193563828.094069), - (loc('persistence/joke.py'), - {'attrib-starts': [('Joke', - 18), - ('Joke.test_data', - 78)], - 'first-line': 50, - 'sel-line': 79, - 'sel-line-start': 2386, - 'selection_end': 2429, - 'selection_start': 2425}, - 1193563838.396673), - (loc('globals.py'), - {'attrib-starts': [('__globals', - 28), - ('__globals.__init__', - 32)], - 'first-line': 13, - 'sel-line': 34, - 'sel-line-start': 1122, - 'selection_end': 1172, - 'selection_start': 1168}, - 1193563842.62817), - (loc('gui/theme.py'), - {'attrib-starts': [], - 'first-line': 89, - 'sel-line': 110, - 'sel-line-start': 3611, - 'selection_end': 3646, - 'selection_start': 3642}, - 1193563845.760396), - [loc('gui/theme.py'), - {'attrib-starts': [], - 'first-line': 89, - 'sel-line': 110, - 'sel-line-start': 3611, - 'selection_end': 3646, - 'selection_start': 3642}, - 1193563846.4001839]], - 19), - 'current-loc': loc('gui/theme.py'), - 'editor-states': {loc('TODO'): {'attrib-starts': [], - 'first-line': 37, - 'sel-line': 59, - 'sel-line-start': 1782, - 'selection_end': 1825, - 'selection_start': 1819}, - loc('globals.py'): {'attrib-starts': [('__globals', - 28), - ('__globals.__init__', - 32)], - 'first-line': 13, - 'sel-line': 34, - 'sel-line-start': 1122, - 'selection_end': 1172, - 'selection_start': 1168}, - loc('gui/canvaslistbox.py'): {'attrib-starts': [(''\ - 'CanvasListBox', - 25), - ('CanvasListBox.__init__', - 26)], - 'first-line': 0, - 'sel-line': 47, - 'sel-line-start': 1638, - 'selection_end': 1657, - 'selection_start': 1657}, - loc('gui/page.py'): {'attrib-starts': [('Page', - 47), - ('Page.make_audiobox', - 82)], - 'first-line': 63, - 'sel-line': 84, - 'sel-line-start': 2487, - 'selection_end': 2548, - 'selection_start': 2548}, - loc('gui/theme.py'): {'attrib-starts': [], - 'first-line': 89, - 'sel-line': 103, - 'sel-line-start': 3392, - 'selection_end': 3440, - 'selection_start': 3440}, - loc('i18n.py'): {'attrib-starts': [('gather_other_'\ - 'translations', - 164)], - 'first-line': 133, - 'sel-line': 166, - 'sel-line-start': 5557, - 'selection_end': 5619, - 'selection_start': 5619}, - loc('pages/choose.py'): {'attrib-starts': [('Choos'\ - 'e', - 35), - ('Choose.__make_column_div', - 118)], - 'first-line': 62, - 'sel-line': 127, - 'sel-line-start': 4655, - 'selection_end': 4655, - 'selection_start': 4655}, - loc('persistence/joke.py'): {'attrib-starts': [('J'\ - 'oke', - 18), - ('Joke.test_data', - 78)], - 'first-line': 50, - 'sel-line': 79, - 'sel-line-start': 2386, - 'selection_end': 2429, - 'selection_start': 2425}, - loc('persistence/jokemachinestate.py'): {'attrib-s'\ - 'tarts': [('JokeMachineState', - 20), - ('JokeMachineState.test_data', - 57)], - 'first-line': 38, - 'sel-line': 69, - 'sel-line-start': 2153, - 'selection_end': 2184, - 'selection_start': 2178}}, - 'has-focus': True}, - 'open_files': [u'TODO', - u'gui/canvaslistbox.py', - u'pages/choose.py', - u'i18n.py', - u'persistence/jokemachinestate.py', - u'gui/page.py', - u'persistence/joke.py', - u'globals.py', - u'gui/theme.py']}, - 'split_percents': {0: 0.5}, - 'splits': 2, - 'tab_location': 'top', - 'user_data': {}}, - 'split_percents': {0: 0.70063694267515919}, - 'splits': 2, - 'tab_location': 'right', - 'user_data': {}}, - 'window-alloc': (0, - 0, - 1320, - 1120)}]} -guimgr.recent-documents = [loc('gui/theme.py'), - loc('globals.py'), - loc('persistence/joke.py'), - loc('gui/page.py'), - loc('persistence/jokemachinestate.py'), - loc('i18n.py'), - loc('TODO'), - loc('pages/choose.py')] -guimgr.visual-state = {loc('JokeMachineActivity.py'): {'attrib-starts': [('J'\ - 'okeMachineActivity', - 49), - ('JokeMachineActivity.write_file', - 345)], - 'first-line': 296, - 'sel-line': 352, - 'sel-line-start': 12664, - 'selection_end': 12669, - 'selection_start': 12669}, - loc('MANIFEST'): {'attrib-starts': [], - 'first-line': 0, - 'sel-line': 23, - 'sel-line-start': 497, - 'selection_end': 515, - 'selection_start': 515}, - loc('TODO'): {'attrib-starts': [], - 'first-line': 0, - 'sel-line': 23, - 'sel-line-start': 478, - 'selection_end': 605, - 'selection_start': 605}, - loc('activity/activity.info'): {'attrib-starts': [], - 'first-line': 0, - 'sel-line': 2, - 'sel-line-start': 31, - 'selection_end': 87, - 'selection_start': 46}, - loc('activitysession.py'): {'attrib-starts': [('JokeM'\ - 'achineSession', - 15)], - 'first-line': 0, - 'sel-line': 15, - 'sel-line-start': 704, - 'selection_end': 704, - 'selection_start': 704}, - loc('globals.py'): {'attrib-starts': [('__globals', - 28), - ('__globals.set_activity_instance', - 46)], - 'first-line': 63, - 'sel-line': 47, - 'sel-line-start': 1440, - 'selection_end': 1499, - 'selection_start': 1499}, - loc('gui/canvasimage.py'): {'attrib-starts': [], - 'first-line': 0, - 'sel-line': 0, - 'sel-line-start': 0, - 'selection_end': 0, - 'selection_start': 0}, - loc('gui/canvaslistbox.py'): {'attrib-starts': [], - 'first-line': 16, - 'sel-line': 24, - 'sel-line-start': 808, - 'selection_end': 833, - 'selection_start': 833}, - loc('gui/frame.py'): {'attrib-starts': [('Frame', - 33), - ('Frame.__do_clicked_make', - 196)], - 'first-line': 128, - 'sel-line': 204, - 'sel-line-start': 6738, - 'selection_end': 6739, - 'selection_start': 6739}, - loc('gui/lessonplanwidget.py'): {'attrib-starts': [(''\ - 'LessonPlanWidget', - 21), - ('LessonPlanWidget.__init__', - 23)], - 'first-line': 10, - 'sel-line': 36, - 'sel-line-start': 1355, - 'selection_end': 1355, - 'selection_start': 1355}, - loc('gui/page.py'): {'attrib-starts': [('Page', - 47), - ('Page.make_imagebox', - 121)], - 'first-line': 40, - 'sel-line': 126, - 'sel-line-start': 4355, - 'selection_end': 4359, - 'selection_start': 4359}, - loc('gui/theme.py'): {'attrib-starts': [], - 'first-line': 60, - 'sel-line': 78, - 'sel-line-start': 2547, - 'selection_end': 2564, - 'selection_start': 2564}, - loc('i18n.py'): {'attrib-starts': [('LanguageComboBox', - 113), - ('LanguageComboBox.install', - 141)], - 'first-line': 103, - 'sel-line': 152, - 'sel-line-start': 5130, - 'selection_end': 5134, - 'selection_start': 5134}, - loc('locale/org.worldwideworkshop.jokemachine.pot'): {''\ - 'attrib-starts': [], - 'first-line': 0, - 'sel-line': 0, - 'sel-line-start': 0, - 'selection_end': 9, - 'selection_start': 9}, - loc('mesh/activitysession.py'): {'attrib-starts': [(''\ - 'JokeMachineSession', - 33), - ('JokeMachineSession.broadcast_joke_cb', - 167)], - 'first-line': 173, - 'sel-line': 190, - 'sel-line-start': 7053, - 'selection_end': 7061, - 'selection_start': 7061}, - loc('ontology/joke.py'): {'attrib-starts': [], - 'first-line': 0, - 'sel-line': 0, - 'sel-line-start': 0, - 'selection_end': 0, - 'selection_start': 0}, - loc('ontology/jokebook.py'): {'attrib-starts': [], - 'first-line': 0, - 'sel-line': 0, - 'sel-line-start': 0, - 'selection_end': 0, - 'selection_start': 0}, - loc('pages/choose.py'): {'attrib-starts': [], - 'first-line': 0, - 'sel-line': 21, - 'sel-line-start': 767, - 'selection_end': 767, - 'selection_start': 767}, - loc('pages/cover.py'): {'attrib-starts': [('Cover', - 30), - ('Cover.__init__', - 32)], - 'first-line': 0, - 'sel-line': 36, - 'sel-line-start': 989, - 'selection_end': 1033, - 'selection_start': 1033}, - loc('pages/edit.py'): {'attrib-starts': [('PageSelect'\ - 'or', - 39), - ('PageSelector.page', - 94), - ('PageSelector.page.set', - 96)], - 'first-line': 75, - 'sel-line': 98, - 'sel-line-start': 3984, - 'selection_end': 4012, - 'selection_start': 4012}, - loc('pages/frame.py'): {'attrib-starts': [], - 'first-line': 0, - 'sel-line': 0, - 'sel-line-start': 0, - 'selection_end': 702, - 'selection_start': 0}, - loc('pages/joke.py'): {'attrib-starts': [('Joke', - 89), - ('Joke.__do_clicked_answer', - 129)], - 'first-line': 31, - 'sel-line': 149, - 'sel-line-start': 5951, - 'selection_end': 5958, - 'selection_start': 5958}, - loc('pages/page.py'): {'attrib-starts': [('Page', - 10), - ('Page._make_textbox', - 22)], - 'first-line': 0, - 'sel-line': 33, - 'sel-line-start': 818, - 'selection_end': 865, - 'selection_start': 865}, - loc('pages/preview.py'): {'attrib-starts': [('Preview', - 33), - ('Preview.__init__', - 35)], - 'first-line': 6, - 'sel-line': 48, - 'sel-line-start': 1537, - 'selection_end': 1607, - 'selection_start': 1607}, - loc('pages/submit.py'): {'attrib-starts': [('Submit', - 80), - ('Submit.__do_clicked_submit', - 119)], - 'first-line': 61, - 'sel-line': 127, - 'sel-line-start': 4870, - 'selection_end': 4870, - 'selection_start': 4870}, - loc('pages/theme.py'): {'attrib-starts': [], - 'first-line': 36, - 'sel-line': 64, - 'sel-line-start': 2219, - 'selection_end': 2255, - 'selection_start': 2255}, - loc('persistence/joke'): {'attrib-starts': [], - 'first-line': 0, - 'sel-line': 0, - 'sel-line-start': 0, - 'selection_end': 0, - 'selection_start': 0}, - loc('persistence/joke.py'): {'attrib-starts': [('Joke', - 18), - ('Joke.test_data', - 78)], - 'first-line': 44, - 'sel-line': 93, - 'sel-line-start': 2703, - 'selection_end': 2705, - 'selection_start': 2705}, - loc('persistence/jokebook.py'): {'attrib-starts': [(''\ - 'Jokebook', - 18), - ('Jokebook.sound_blob', - 53)], - 'first-line': 0, - 'sel-line': 54, - 'sel-line-start': 1702, - 'selection_end': 1731, - 'selection_start': 1731}, - loc('persistence/jokemachine.py'): {'attrib-starts': [(''\ - 'JokeMachineState', - 18)], - 'first-line': 0, - 'sel-line': 18, - 'sel-line-start': 766, - 'selection_end': 788, - 'selection_start': 788}, - loc('persistence/jokemachinestate.py'): {'attrib-star'\ - 'ts': [('JokeMachineState', - 20), - ('JokeMachineState.jokebook', - 50)], - 'first-line': 16, - 'sel-line': 55, - 'sel-line-start': 1793, - 'selection_end': 1793, - 'selection_start': 1793}, - loc('persistence/unit.py'): {'attrib-starts': [], - 'first-line': 0, - 'sel-line': 0, - 'sel-line-start': 0, - 'selection_end': 0, - 'selection_start': 0}, - loc('setup.py'): {'attrib-starts': [], - 'first-line': 0, - 'sel-line': 5, - 'sel-line-start': 127, - 'selection_end': 176, - 'selection_start': 176}, - loc('unit/persistence.py'): {'attrib-starts': [], - 'first-line': 0, - 'sel-line': 0, - 'sel-line-start': 0, - 'selection_end': 0, - 'selection_start': 0}, - loc('unit/test_persistence.py'): {'attrib-starts': [(''\ - 'dump', - 22)], - 'first-line': 0, - 'sel-line': 38, - 'sel-line-start': 1186, - 'selection_end': 1207, - 'selection_start': 1207}, - loc('unit/unit.py'): {'attrib-starts': [], - 'first-line': 0, - 'sel-line': 18, - 'sel-line-start': 725, - 'selection_end': 758, - 'selection_start': 725}, - loc('util/audioplayer.py'): {'attrib-starts': [('Audi'\ - 'oPlayer', - 24), - ('AudioPlayer.raw', - 44), - ('AudioPlayer.raw.set', - 53)], - 'first-line': 50, - 'sel-line': 55, - 'sel-line-start': 1580, - 'selection_end': 1604, - 'selection_start': 1604}, - loc('util/decorators.py'): {'attrib-starts': [], - 'first-line': 0, - 'sel-line': 19, - 'sel-line-start': 895, - 'selection_end': 895, - 'selection_start': 895}, - loc('util/journalpickler.py'): {'attrib-starts': [('J'\ - 'ournalPickler', - 18), - ('JournalPickler.dumps', - 33)], - 'first-line': 0, - 'sel-line': 36, - 'sel-line-start': 1316, - 'selection_end': 1334, - 'selection_start': 1334}, - loc('util/persistence.py'): {'attrib-starts': [('_is_'\ - 'persistent', - 73)], - 'first-line': 0, - 'sel-line': 78, - 'sel-line-start': 2866, - 'selection_end': 2898, - 'selection_start': 2898}, - loc('../poll-builder/poll.py'): {'attrib-starts': [(''\ - 'PollBuilder', - 141), - ('PollBuilder._select_canvas', - 294)], - 'first-line': 326, - 'sel-line': 359, - 'sel-line-start': 12121, - 'selection_end': 12389, - 'selection_start': 12121}, - loc('../../../../../../opt/wing/resources/builtin-pi-files/2.5/__builtin__.pi'): {''\ - 'attrib-starts': [], - 'first-line': 1049, - 'sel-line': 1076, - 'sel-line-start': 33540, - 'selection_end': 33548, - 'selection_start': 33540}, - loc('unknown: #1'): {'attrib-starts': [], - 'first-line': 0, - 'sel-line': 0, - 'sel-line-start': 0, - 'selection_end': 4, - 'selection_start': 4}, - loc('unknown: #2'): {'attrib-starts': [], - 'first-line': 0, - 'sel-line': 0, - 'sel-line-start': 0, - 'selection_end': 0, - 'selection_start': 0}, - loc('unknown: #3'): {'attrib-starts': [], - 'first-line': 0, - 'sel-line': 0, - 'sel-line-start': 0, - 'selection_end': 4, - 'selection_start': 4}, - loc('unknown: #4'): {'attrib-starts': [], - 'first-line': 0, - 'sel-line': 0, - 'sel-line-start': 0, - 'selection_end': 0, - 'selection_start': 0}} -search.replace-history = [u'self.__is_initiator', - u'state_pickle', - u'__telepathy_connection', - u'./JokeMachine.activity/', - u'RoundBox', - u'self.__tab', - u'joke_box', - u'__do_clicked_tab', - u'jokebuilder'] -search.search-history = [u'.png', - u'audio.', - u'images', - u'TODO', - u'do_child', - u'__page_', - u'page_class', - u'refresh', - u'self.__is_initiating', - u'is_shared', - u'__telepathy_initiating', - u'is_joining', - u'True', - u'border=1', - u'Add Joke', - u'logging', - u'pickle', - u'Trying', - u'SESSION', - u'IFACE'] diff --git a/JokeMachineActivity.py b/JokeMachineActivity.py index 60c2450..f04b804 100644 --- a/JokeMachineActivity.py +++ b/JokeMachineActivity.py @@ -18,6 +18,8 @@ import logging import gtk from gettext import gettext as _ +import gettext +import locale import hippo from sugar.activity import activity @@ -57,9 +59,34 @@ class JokeMachineActivity(activity.Activity): in our world collapse with giggles of helpless laughter! """ + # TODO: Handle <= Build# 622 gracefully + try: + def alert(self, title, text=None): + '''Show an alert above the activity.''' + from sugar.graphics.alert import NotifyAlert + alert = NotifyAlert(timeout=10) + alert.props.title = title + alert.props.msg = text + self.add_alert(alert) + alert.connect('response', self.__alert_cancel_cb) + alert.show() + def __alert_cancel_cb(self, alert, response_id): + '''Callback for alert events''' + self.remove_alert(alert) + except ImportError: + def alert(self, title, text=None): + pass + def __init__(self, handle): activity.Activity.__init__(self, handle) + # TODO - clean - install gettext + #os.chdir(Globals.pwd) # required for i18n.py to work + #gettext.install('JokeMachine', './locale', unicode=True) + #presLan_af = gettext.translation("JokeMachine", os.path.join(Globals.pwd, 'locale'), languages=['af']) + #presLan_af.install() + #locale.setlocale(locale.LC_ALL, 'af') + # customize theme gtkrc = os.path.join(Globals.pwd, 'resources/gtkrc') if os.path.exists(gtkrc): @@ -74,8 +101,6 @@ class JokeMachineActivity(activity.Activity): logging.debug("Starting the Joke Machine activity") - os.chdir(Globals.pwd) # required for i18n.py to work TODO -> You're not initting i8n properly dude! - # toolbox self.__toolbox = activity.ActivityToolbox(self) self.set_toolbox(self.__toolbox) @@ -103,13 +128,14 @@ class JokeMachineActivity(activity.Activity): owner = self.__presence_service.get_owner() Globals.set_owner(owner) - self.__session = None # ???? self.poll_session + self.__session = None # JokeMachineSession self.connect('shared', self.__do_activity_shared) # Check if we're joining another instance self.__is_initiator = True if self._shared_activity is not None: + self.alert(_('Joke Machine'), _('Please wait a moment for your buddy\'s Jokebooks to show up')) self.__is_initiator = False logging.debug('shared: %s' % self._shared_activity.props.joined) # We are joining the activity @@ -150,11 +176,9 @@ class JokeMachineActivity(activity.Activity): channel = telepathy.client.Channel(bus_name, channel_path) htype, handle = channel.GetHandle() if htype == telepathy.HANDLE_TYPE_ROOM: - # TODO - this log message throws an exception - #logging.debug('Found our room: it has handle# %d %s', - # handle, - # self.__telepathy_connection.InspectHandles(htype, [handle][0])) - logging.debug('Found our room: it has handle# %d' % handle) + logging.debug('Found our room: it has handle# %d %s', + handle, + self.__telepathy_connection.InspectHandles(htype, [handle])[0]) room = handle ctype = channel.GetChannelType() if ctype == telepathy.CHANNEL_TYPE_TUBES: @@ -170,14 +194,20 @@ class JokeMachineActivity(activity.Activity): if text_chan is None: logging.debug('Presence service did not create a text channel') return - - # Make sure we have a Tubes channel - PS doesn't yet provide one if tubes_chan is None: - logging.debug('Did not find our Tubes channel, requesting one...') + logging.debug('Presence service did not create a tubes channel') + # okay - we're going to try requesting one because this always fails on + # build# <= 622 + logging.debug('TODO - DEPRECATE: TRYING TO REQUEST A TUBES CHANNEL') tubes_chan = self.__telepathy_connection.request_channel(telepathy.CHANNEL_TYPE_TUBES, telepathy.HANDLE_TYPE_ROOM, room, True) + if tubes_chan is None: + logging.debug('TODO - DEPRECATE: FAILED TO REQUEST A TUBES CHANNEL - QUITTING') + return + logging.debug('TODO - DEPRECATE: MANAGED TO REQUEST A TUBES CHANNEL') + self.tubes_chan = tubes_chan self.text_chan = text_chan @@ -239,7 +269,7 @@ class JokeMachineActivity(activity.Activity): logging.debug('non-CS handle %u belongs to itself', handle) assert handle != 0 - name, path = self.__presence_service.get_preferred_connection() # TODO - make sure this does not cause bugs + name, path = self.__presence_service.get_preferred_connection() return self.__presence_service.get_buddy_by_telepathy_handle(name, path, @@ -259,7 +289,7 @@ class JokeMachineActivity(activity.Activity): logging.debug('The activity was shared') self.__telepathy_initiating = True - self.__setup() # TODO - more civilized name + self.__setup() for buddy in self._shared_activity.get_joined_buddies(): logging.debug('Buddy %s is already in the activity' % buddy.props.nick) @@ -316,18 +346,24 @@ class JokeMachineActivity(activity.Activity): return page + #def alert(self, title, text=None): + #'''Show an alert above the activity.''' + #alert = NotifyAlert(timeout=10) + #alert.props.title = title + #alert.props.msg = text + #self.add_alert(alert) + #alert.connect('response', self.__alert_cancel_cb) + #alert.show() + + + #def __alert_cancel_cb(self, alert, response_id): + #'''Callback for alert events''' + #self.remove_alert(alert) + def read_file(self, file_path): '''Callback to resume activity state from Journal''' logging.debug('Reading file from datastore via Journal: %s' % file_path) - - # TODO - double check -> if I'm a shared activity, don't restore me - # TODO - this doesn't work here - not initted yet - #if not self.is_initiator: - # logging.debug('joining a shared activity - dont restore') - # return - - # read activity state from Journal f = open(file_path, 'r') pickle = f.read() if len(pickle) == 0: @@ -342,19 +378,11 @@ class JokeMachineActivity(activity.Activity): Globals.set_activity_state(activity_state) - def write_file(self, file_path): '''Callback to persist activity state to Journal''' - # TODO - double check -> if I'm a shared activity, don't persist me - # TODO - this doesn't work here - not initted yet - #if not self.is_initiator: - # logging.debug('joining a shared activity - dont persist') - # return - if len(Globals.JokeMachineState.jokebooks) != 0: logging.debug('Writing file to datastore via Journal: %s' % file_path) - # write activity state to journal f = open(file_path, 'w') pickle = Globals.JokeMachineState.dumps() f.write(pickle) @@ -363,7 +391,6 @@ class JokeMachineActivity(activity.Activity): logging.debug('nothing to persist') - def close(self): '''Called on activity close''' logging.info('Exiting Activity. Performing cleanup...') diff --git a/MANIFEST b/MANIFEST index cea6795..9baeaa2 100644 --- a/MANIFEST +++ b/MANIFEST @@ -1,7 +1,6 @@ ./JokeMachineActivity.py -./TODO ./globals.py -./gtkrc +./resources/gtkrc ./gui/__init__.py ./gui/canvaslistbox.py ./gui/frame.py @@ -18,7 +17,9 @@ ./lessons/Lesson 2/default.abw ./lessons/Lesson 3/default.abw ./lessons/Lesson 4/default.abw -./locale/jokemachine.pot +./locale/JokeMachine.pot +./locale/af/LC_MESSAGES/JokeMachine.mo +./locale/af/LC_MESSAGES/JokeMachine.po ./mesh/__init__.py ./mesh/activitysession.py ./pages/__init__.py diff --git a/NEWS b/NEWS index 1cabbd8..e7d782f 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,28 @@ +JokeMachine-3.xo + + * Feature: Put alerts up when joke submitted and approved over mesh + * Feature: Put alert up advising patience when joining a shared jokebook + * Feature: Made Lesson Plans button work + * Feature: Safe fallback for builds without sugar.alert + * Feature: Hooked LanguageCombo up + * i18n: Created (a rough!) Afrikaans translation + * Fixed: Prepended Cover on preview + * Fixed: Don't hardcode JokeEditor delete button position + * Fixed: On read jokebook & empty -> "Edit My Jokes" -> Go to edit my jokes tab + * Updated :Mesh code for dbus tubes changes + + -- Antoine van Gelder Mon, 29 Oct 2007 + + JokeMachine-2.xo - * Initial Import - + * Feature: Initial Import w/ basic mesh support + * Feature: Adapt UI depending on whether you are sharing or joining + * Feature: Broadcast accepted submissions back to buddies + * Feature: Select a sound to play on Joke punchlines + * Fixed: Rename Jokebook Info -> Edit Jokebook Cover + * Fixed: Preview mode shows make jokebook button - it shouldn't + * Fixed: Submit a Joke button -> only for buddies + * Fixed: Deprecated theme_widget() in favor of a custom gtkrc + -- Antoine van Gelder Sun, 28 Oct 2007 diff --git a/TODO b/TODO index cdaf90a..0685638 100644 --- a/TODO +++ b/TODO @@ -1,121 +1,28 @@ -!!!! AIMING FOR OCTOBER 30 !!!! - - * Check in code & Trac component WAITING - * Mesh - * Bugs - * i18n - * Sample Data - * Memory - * Lesson Plans - - * Sound WORKABLE - ** check tempdir against a vmware img - - -= Current = - -* Bugs -** Choose -> Delete not work - - -* Mesh -** Put text: Downloading... or somesuch when joining activity -** After submitted joke has been approved broadcast it back to participants so that it appears in their version of the jokebook DONE -** Do we want all changes in state initiator side broadcast ? A lot of work to do it... -** is_visible flag on jokes and jokebooks ? -** Do we want the initiator to see the jokes of folk who join ? Could be nice... could be confusing... -** Share icons getting left behind -** What's this with activities getting journalled as shared - and then not being visible when resumed ? -** Make mesh work! DONE -** Detect whether am sharer or sharee DONE -** Remove the crapload of UI functions if sharee DONE - = To Do = -* Mesh -** Make mesh work! - - -* Check in code & Trac component WAITING -** My domains are either gone or down - wait a few hours, if not back up then - do the big txfer else do the big txfer THIS WEEK !! :-( - +* Figure out why only alerts are being translated +* Double check that all strings are gettexted +* Use hippo.PACK_EXPAND to get rid of hardcoded sizes +* Get a fix on memory useage +* Create and set activity_version property for persistence.JokeMachineState.version +* Split unit.py out into separate test cases +* Refactor Page.make_* infrastructure -* GUI -** Not going back to read jokebooks from edit mode on build 613 ? -** Preview mode shows make jokebook button - shouldn't -** Prepend Cover on preview -** Submit a Joke button -> only for foreigners -** On read jokebook & empty -> "Edit My Jokes" -> Go to edit my jokes tab -** Jokebook Info -> Edit Jokebook Cover DONE -** Refactor Page.make_* infrastructure -*** Factor out CanvasText's and replace with a better make_text -*** Add a make_button as well -*** Refactor Page.make_imagebox & ObjectChooser code - it's squishy! -** Fix gtkrc for non-default frame states - - -* Multimedia - Images/Audio +* Things waiting for the journal to settle ** Filter ObjectChooser to only list images/audio -> https://dev.laptop.org/ticket/3060 -** Select a sound to play on Joke punchlines DONE -*** NOTE writing out sound_blob to temp file for now before handing to gstreamer -** fold image/image_blob into a single property? -** fold sound/sound_blob into a single property? - - -* Persistence -** Build# 613 - keep/save problems ? -** Some sample jokes -** Restore last known state of activity instead of starting from scratch when not started from Journal - YES -*** Chat to eben -** Create and set activity_version property for persistence.JokeMachineState.version -** Don't persist if there are no jokebooks -** Can we point to datastore objects rather than having to copy them into our - own datastructures - has disadvantage that deleting an object from the - datastore that's in use will delete it from the joke - also creates problems - when sharing... - - -* Memory -** If memory should become a problem... write pickle restored from journal out - to disk and extend Persistence interface to feed from disk rather than RAM - - -* i18n -** Do a test translation into Afrikaans -** Make language selection button work -** Double check that all strings are gettexted - - -* Lesson Plans -** Make Lesson Plans button work - - -* Unit Tests -** Split unit.py out into separate test cases - +** Create sample Jokebooks in the journal on bundle installation +** Fold image/image_blob into a single property +** Fold sound/sound_blob into a single property +** Bring up the last Jokebooks instead of starting from scratch when started from the frame +** Don't persist if there are no jokebooks = Known Problems = -* Sugar Versions -** Vanishing controls on Build 542.3 running on B2 hardware - bring up & hide developer terminal to reset -** gtk.TextViews have borders on Build 557 which shouldn't be there -** These problems are all fixed on Build >600 and sugar-jhbuild - -* Audio -** Audio b0rk3d on B2 Hardware w/ build 542.3 - -* Edit Jokebook -> Review Jokes -** Present&working, but no way to submit jokes to it as mesh code is still coming up :-) -** If you want to see some sample data with waiting submissions edit persistence/jokemachinestate.py -> test_data() -> num_jokebooks = a number bigger than zero - -* Bugs -** Activity Icon not being set to theme colors -** Language selection button not theming as it should DONE -*** We can also lose theme_widget seeing as we're using a custom gtkrc now - +* i18n is only translating alerts at the moment for some strange reason +* AudioPlayer dumps files into /tmp which may be problematic for security system +* Deprecating theme_widget() for custom gtkrc fixes language combo but there are now faint hints of Irish in the activity frame :) diff --git a/activity/activity.info b/activity/activity.info index f6b9c24..8537fc9 100644 --- a/activity/activity.info +++ b/activity/activity.info @@ -4,6 +4,6 @@ bundle_id = org.worldwideworkshop.JokeMachineActivity service_name = org.worldwideworkshop.JokeMachineActivity class = JokeMachineActivity.JokeMachineActivity icon = activity-jokemachine -activity_version = 1 +activity_version = 3 host_version = 1 show_launcher = 1 diff --git a/gui/frame.py b/gui/frame.py index fcbd0de..7da5540 100644 --- a/gui/frame.py +++ b/gui/frame.py @@ -30,6 +30,7 @@ import pages.choose import pages.edit from persistence.jokebook import Jokebook +from gui.lessonplanwidget import LessonPlanWidget class Frame(hippo.Canvas): @@ -49,28 +50,25 @@ class Frame(hippo.Canvas): # Page Container ########################################################### # Holds: The currently open UI page - self.__container = hippo.CanvasBox( - border=theme.BORDER_WIDTH, - border_color=theme.COLOR_FRAME.get_int(), - background_color=theme.COLOR_BACKGROUND.get_int(), - spacing=4, - padding_top=20, - padding_left=40, - padding_right=40, - padding_bottom=20, - orientation=hippo.ORIENTATION_VERTICAL) + self.__container = hippo.CanvasBox(border=theme.BORDER_WIDTH, + border_color=theme.COLOR_FRAME.get_int(), + background_color=theme.COLOR_BACKGROUND.get_int(), + spacing=4, + padding_top=20, + padding_left=40, + padding_right=40, + padding_bottom=20, + orientation=hippo.ORIENTATION_VERTICAL) self.__root.append(self.__container, hippo.PACK_EXPAND) - self.__page = hippo.CanvasBox( - box_height=theme.PAGE_HEIGHT, # TODO -> Pull width/height from theme - and make sure all - # children pull their sizes relative to this box - background_color=theme.COLOR_PAGE.get_int(), - border=4, - border_color=theme.COLOR_PAGE_BORDER.get_int(), - spacing=8, - padding=20, - xalign=hippo.ALIGNMENT_CENTER, - orientation=hippo.ORIENTATION_VERTICAL) + self.__page = hippo.CanvasBox(box_height=theme.PAGE_HEIGHT, + background_color=theme.COLOR_PAGE.get_int(), + border=4, + border_color=theme.COLOR_PAGE_BORDER.get_int(), + spacing=8, + padding=20, + xalign=hippo.ALIGNMENT_CENTER, + orientation=hippo.ORIENTATION_VERTICAL) self.__container.append(self.__page) self.__page_class = None @@ -92,37 +90,38 @@ class Frame(hippo.Canvas): ret.append(hippo.CanvasWidget(widget=logo)) # language selection box - language = hippo.CanvasWidget( - background_color=theme.COLOR_BACKGROUND.get_int(), - border_top=theme.BORDER_WIDTH, - border_left=theme.BORDER_WIDTH, - border_color=theme.COLOR_FRAME.get_int(), - padding_top=12, - padding_bottom=12, - padding_left=100, - padding_right=100, - yalign=hippo.ALIGNMENT_CENTER, - orientation=hippo.ORIENTATION_VERTICAL) + language = hippo.CanvasWidget(background_color=theme.COLOR_BACKGROUND.get_int(), + border_top=theme.BORDER_WIDTH, + border_left=theme.BORDER_WIDTH, + border_color=theme.COLOR_FRAME.get_int(), + padding_top=12, + padding_bottom=12, + padding_left=100, + padding_right=100, + yalign=hippo.ALIGNMENT_CENTER, + orientation=hippo.ORIENTATION_VERTICAL) button = LanguageComboBox() button.install() + button.set_name('fubar') language.props.widget = button - button.set_name('Fubar') ret.append(language, hippo.PACK_EXPAND) # lesson plans - lesson_plans = hippo.CanvasWidget( - background_color=theme.COLOR_BACKGROUND.get_int(), - border_top=theme.BORDER_WIDTH, - border_left=theme.BORDER_WIDTH, - border_right=theme.BORDER_WIDTH, - border_color=theme.COLOR_FRAME.get_int(), - padding_top=12, - padding_bottom=12, - padding_left=30, - padding_right=30, - yalign=hippo.ALIGNMENT_CENTER, - orientation=hippo.ORIENTATION_VERTICAL) + lesson_plans = hippo.CanvasWidget(background_color=theme.COLOR_BACKGROUND.get_int(), + border_top=theme.BORDER_WIDTH, + border_left=theme.BORDER_WIDTH, + border_right=theme.BORDER_WIDTH, + border_color=theme.COLOR_FRAME.get_int(), + padding_top=12, + padding_bottom=12, + padding_left=30, + padding_right=30, + yalign=hippo.ALIGNMENT_CENTER, + orientation=hippo.ORIENTATION_VERTICAL) button = gtk.Button(_('Lesson Plans')) + button.set_size_request(200, -1) + button.active = False + button.connect('clicked', self.__do_clicked_lessonplans) lesson_plans.props.widget = theme.theme_widget(button) ret.append(lesson_plans, hippo.PACK_EXPAND) @@ -202,4 +201,27 @@ class Frame(hippo.Canvas): jokebook.owner = Globals.nickname Globals.JokeMachineState.jokebooks.append(jokebook) Globals.JokeMachineActivity.set_page(pages.edit.Edit, jokebook) - \ No newline at end of file + + + def __do_clicked_lessonplans(self, button): + if button.active: + button.set_label(_('Lesson Plans')) + button.active = False + Globals.JokeMachineActivity.set_page(pages.choose.Choose) + else: + button.set_label(_('Close Lessons')) + button.active = True + widget_box = hippo.CanvasBox(border=0, + border_color=theme.COLOR_BLUE.get_int()) + widget_box.append(hippo.CanvasText(text= _('Lesson Plans:'), + xalign=hippo.ALIGNMENT_START, + padding=10, + font_desc=theme.FONT_BODY.get_pango_desc())) + lesson_plans = LessonPlanWidget(Globals.pwd) + lesson_plans.set_size_request(1050, 500) + widget_box.append(hippo.CanvasWidget(widget=lesson_plans, + border=0, + border_color=theme.COLOR_DARK_GREEN.get_int())) + self.page = widget_box + self.__button_read.set_visible(False) + self.__button_make.set_visible(False) diff --git a/gui/lessonplanwidget.py b/gui/lessonplanwidget.py index b9a1a62..5b6e021 100644 --- a/gui/lessonplanwidget.py +++ b/gui/lessonplanwidget.py @@ -13,8 +13,10 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # +import os import locale import gtk +import logging from abiword import Canvas as AbiCanvas @@ -42,6 +44,10 @@ class LessonPlanWidget(gtk.Notebook): lesson -- string, name of lesson """ code, encoding = locale.getdefaultlocale() + logging.debug('Locale code: %r' % code) + if code is None or encoding is None: + locale.setlocale(locale.LC_ALL, 'en_US') + code, encoding = locale.getlocale() canvas = AbiCanvas() canvas.show() files = map(lambda x: os.path.join(path, '%s.abw' % x), @@ -57,3 +63,5 @@ class LessonPlanWidget(gtk.Notebook): canvas.zoom_width() canvas.set_show_margin(False) self.append_page(canvas, gtk.Label(name)) + + diff --git a/gui/page.py b/gui/page.py index 54dd596..74ac506 100644 --- a/gui/page.py +++ b/gui/page.py @@ -73,7 +73,7 @@ class Page(hippo.CanvasBox): list_row = RoundBox() list_row.props.border = 0 # properties not being set properly by constructor list_row.props.padding = theme.DEFAULT_PADDING - list_row.props.padding_right=0 + #list_row.props.padding_right=0 list_row.props.background_color = self.color_listrow if contents is not None: list_row.append(contents) diff --git a/i18n.py b/i18n.py index ce26f5c..aaf42c8 100644 --- a/i18n.py +++ b/i18n.py @@ -27,8 +27,7 @@ import os import gettext import locale - -from gui import theme +import logging import gtk, gobject @@ -43,6 +42,7 @@ lang_name_mapping = { 'cs':(None, _('Czech'),'czech_republic'), 'da':(None, _('Danish'),'denmark'), 'nl':(None, _('Dutch'), 'netherlands'), + 'af':(None, _('Afrikaans'), 'south_africa'), 'en':('English', _('English'),'united_states'), 'en_gb':('English', _('English - Great Britain'),'united_kingdom'), 'en_us':('English', _('English - U.S.'),'united_states'), @@ -72,16 +72,12 @@ class LangDetails (object): self.image = image def guess_translation (self, fallback=False): - locale_dir = os.path.join(os.getcwd(), 'locale') - domain = 'jokemachine' - self.gnutranslation = gettext.translation(domain, locale_dir, [self.code], fallback=fallback) + self.gnutranslation = gettext.translation('JokeMachine', './locale', [self.code], fallback=fallback) def install (self): self.gnutranslation.install() def matches (self, code, exact=True): - if code is None or self.code is None: - return False if exact: return code.lower() == self.code.lower() return code.split('_')[0].lower() == self.country_code.lower() @@ -99,7 +95,7 @@ def get_lang_details (lang): return LangDetails(lang, mapping[0], mapping[2]) def list_available_translations (): - rv = [get_lang_details('en'), get_lang_details('fr'), get_lang_details('es')] + rv = [get_lang_details('en')] rv[0].guess_translation(True) for i,x in enumerate([x for x in os.listdir('locale') if os.path.isdir('locale/' + x) and not x.startswith('.')]): try: @@ -109,6 +105,7 @@ def list_available_translations (): rv.append(details) except: raise + pass return rv class LanguageComboBox (gtk.ComboBox): @@ -117,9 +114,6 @@ class LanguageComboBox (gtk.ComboBox): gtk.ComboBox.__init__(self, liststore) self.cell = gtk.CellRendererText() - #self.cell.props.background_gdk = theme.COLOR_DARK_GREEN.get_gdk_color() - #self.cell.props.background_set = True - self.pack_start(self.cell, True) self.add_attribute(self.cell, 'text', 0) @@ -127,23 +121,26 @@ class LanguageComboBox (gtk.ComboBox): for i,x in enumerate(self.translations): liststore.insert(i+1, (gettext.gettext(x.name), )) self.connect('changed', self.install) - - self.set_title('MaMaLanguageComboBox') - def modify_bg (self, state, color): - # AVG - cell.props.background not cell.background - cell.props.background = '#027F01' - self.cell.props.background_gdk = color - self.cell.props.background_set = True - #setattr(self.cell, 'background-gdk',color) - #setattr(self.cell, 'background-set',True) + setattr(self.cell, 'background-gdk',color) + setattr(self.cell, 'background-set',True) def install (self, *args): if self.get_active() > -1: - self.translations[self.get_active()].install() + translation = self.translations[self.get_active()] + logging.debug('i18n - Installing locale: %r %r - %r', + translation.code, + translation.country_code, + translation.name) + translation.install() else: code, encoding = locale.getdefaultlocale() + logging.debug('Locale code: %r' % code) + if code is None: + locale.setlocale(locale.LC_ALL, 'en_US') + code, encoding = locale.getlocale() + # Try to find the exact translation for i,t in enumerate(self.translations): if t.matches(code): @@ -164,7 +161,7 @@ class LanguageComboBox (gtk.ComboBox): ### def gather_other_translations (): from glob import glob - entries = filter(lambda x: os.path.isdir(x), glob('resources/*')) + entries = filter(lambda x: os.path.isdir(x), glob('images/*')) entries.extend(filter(lambda x: os.path.isdir(x), glob('lessons/*'))) entries = map(lambda x: os.path.basename(x), entries) f = file('i18n_misc_strings.py', 'w') @@ -173,4 +170,4 @@ def gather_other_translations (): f.close() if __name__ == '__main__': - gather_other_translations() + gather_other_translations() \ No newline at end of file diff --git a/locale/jokemachine.pot b/locale/JokeMachine.pot index 6129dcc..93dcf91 100644 --- a/locale/jokemachine.pot +++ b/locale/JokeMachine.pot @@ -1,113 +1,159 @@ # SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR ORGANIZATION +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. # FIRST AUTHOR , YEAR. # +#, fuzzy msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" -"POT-Creation-Date: 2007-10-14 03:05+SAST\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2007-10-29 05:52+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=CHARSET\n" -"Content-Transfer-Encoding: ENCODING\n" -"Generated-By: pygettext.py 1.5\n" +"Content-Transfer-Encoding: 8bit\n" +#: activity/activity.info:2 JokeMachineActivity.py:123 +#: mesh/activitysession.py:165 mesh/activitysession.py:205 +msgid "Joke Machine" +msgstr "" -#: i18n.py:39 -msgid "Chinese (simplified)" +#: JokeMachineActivity.py:123 +msgid "Please wait a moment for your buddy's Jokebooks to show up" +msgstr "" + +#: gui/frame.py:121 gui/frame.py:208 +msgid "Lesson Plans" +msgstr "" + +#: gui/frame.py:139 +msgid "Read Jokebooks" +msgstr "" + +#: gui/frame.py:143 +msgid "Make Jokebook" +msgstr "" + +#: gui/frame.py:212 +msgid "Close Lessons" +msgstr "" + +#: gui/frame.py:216 +msgid "Lesson Plans:" +msgstr "" + +#: gui/page.py:99 +msgid "Click to choose a sound" +msgstr "" + +#: gui/page.py:294 +msgid "Choose image" +msgstr "" + +#: gui/page.py:322 +msgid "Choose Sound" msgstr "" #: i18n.py:40 -msgid "Chinese (traditional)" +msgid "Chinese (simplified)" msgstr "" #: i18n.py:41 -msgid "Czech" +msgid "Chinese (traditional)" msgstr "" #: i18n.py:42 -msgid "Danish" +msgid "Czech" msgstr "" #: i18n.py:43 -msgid "Dutch" +msgid "Danish" msgstr "" #: i18n.py:44 -msgid "English" +msgid "Dutch" msgstr "" #: i18n.py:45 -msgid "English - Great Britain" +msgid "Afrikaans" msgstr "" #: i18n.py:46 -msgid "English - U.S." +msgid "English" msgstr "" #: i18n.py:47 -msgid "Finnish" +msgid "English - Great Britain" msgstr "" #: i18n.py:48 -msgid "French" +msgid "English - U.S." msgstr "" #: i18n.py:49 -msgid "German" +msgid "Finnish" msgstr "" #: i18n.py:50 -msgid "Hungarian" +msgid "French" msgstr "" #: i18n.py:51 -msgid "Italian" +msgid "German" msgstr "" #: i18n.py:52 -msgid "Japanese" +msgid "Hungarian" msgstr "" #: i18n.py:53 -msgid "Korean" +msgid "Italian" msgstr "" #: i18n.py:54 -msgid "Norwegian" +msgid "Japanese" msgstr "" #: i18n.py:55 -msgid "Polish" +msgid "Korean" msgstr "" #: i18n.py:56 -msgid "Portuguese" +msgid "Norwegian" msgstr "" #: i18n.py:57 -msgid "Portuguese - Brazilian" +msgid "Polish" msgstr "" #: i18n.py:58 -msgid "Russian" +msgid "Portuguese" msgstr "" #: i18n.py:59 -msgid "Slovak" +msgid "Portuguese - Brazilian" msgstr "" #: i18n.py:60 -msgid "Spanish" +msgid "Russian" msgstr "" #: i18n.py:61 -msgid "Swedish" +msgid "Slovak" msgstr "" #: i18n.py:62 +msgid "Spanish" +msgstr "" + +#: i18n.py:63 +msgid "Swedish" +msgstr "" + +#: i18n.py:64 msgid "Turkish" msgstr "" @@ -131,119 +177,130 @@ msgstr "" msgid "Introduction" msgstr "" -#: gui/frame.py:117 -msgid "Lesson Plans" +#: mesh/activitysession.py:164 +msgid " submitted a joke to " msgstr "" -#: gui/frame.py:131 -msgid "Read Jokebooks" +#: mesh/activitysession.py:203 +msgid " accepted a joke submitted to " msgstr "" -#: gui/frame.py:134 -msgid "Make Jokebook" +#: mesh/activitysession.py:204 +msgid " by " msgstr "" -#: gui/page.py:70 -msgid "Choose image" +#: pages/choose.py:42 +msgid "Choose a Jokebook to read:" msgstr "" -#: pages/choose.py:95 +#: pages/choose.py:65 +msgid "Are you sure you want to delete your " +msgstr "" + +#: pages/choose.py:68 +msgid "jokebook ?" +msgstr "" + +#: pages/choose.py:110 pages/preview.py:62 msgid "Edit" msgstr "" -#: pages/choose.py:100 +#: pages/choose.py:114 pages/edit.py:178 msgid "Delete" msgstr "" -#: pages/cover.py:37 -msgid "Jokes started by" +#: pages/cover.py:37 pages/preview.py:44 +msgid "started by" msgstr "" #: pages/cover.py:49 msgid "Open" msgstr "" -#: pages/edit.py:53 -msgid "Jokebook Info" +#: pages/edit.py:57 +msgid "Edit Jokebook Cover" msgstr "" -#: pages/edit.py:63 +#: pages/edit.py:67 msgid "Edit My Jokes" msgstr "" -#: pages/edit.py:73 +#: pages/edit.py:77 msgid "Review Submitted Jokes" msgstr "" -#: pages/edit.py:121 +#: pages/edit.py:123 msgid "Preview" msgstr "" -#: pages/edit.py:146 +#: pages/edit.py:149 msgid "Title of Jokebook:" msgstr "" -#: pages/edit.py:147 +#: pages/edit.py:153 msgid "Sound Effect:" msgstr "" -#: pages/edit.py:170 -msgid "Add Joke" -msgstr "" - -#: pages/edit.py:200 -msgid "Status:" +#: pages/edit.py:190 +msgid "Add New Joke" msgstr "" -#: pages/edit.py:207 -msgid "Approved" +#: pages/edit.py:201 +msgid "Are you sure you want to delete this joke ?" msgstr "" -#: pages/edit.py:210 -msgid "Rejected" +#: pages/edit.py:242 +msgid "Reject" msgstr "" -#: pages/edit.py:213 -msgid "Not Reviewed" +#: pages/edit.py:249 +msgid "Accept" msgstr "" -#: pages/joke.py:53 +#: pages/joke.py:56 msgid "Joke" msgstr "" -#: pages/joke.py:56 +#: pages/joke.py:59 msgid "By" msgstr "" -#: pages/joke.py:66 pages/submit.py:67 +#: pages/joke.py:69 pages/submit.py:63 msgid "Question" msgstr "" -#: pages/joke.py:75 pages/joke.py:105 pages/submit.py:75 +#: pages/joke.py:78 pages/joke.py:123 pages/submit.py:71 msgid "Answer" msgstr "" -#: pages/joke.py:126 -msgid "Next" +#: pages/joke.py:97 +msgid "This Jokebook is empty" msgstr "" -#: pages/joke.py:131 +#: pages/joke.py:99 pages/joke.py:156 msgid "Submit a Joke" msgstr "" -#: pages/submit.py:96 +#: pages/joke.py:104 +msgid "Add Jokes" +msgstr "" + +#: pages/joke.py:150 +msgid "Next" +msgstr "" + +#: pages/submit.py:93 msgid "Submission For:" msgstr "" -#: pages/submit.py:97 +#: pages/submit.py:94 msgid "Your Name:" msgstr "" -#: pages/submit.py:108 +#: pages/submit.py:105 msgid "Submit" msgstr "" -#: pages/submit.py:111 +#: pages/submit.py:108 msgid "Back" msgstr "" - diff --git a/locale/af/LC_MESSAGES/JokeMachine.mo b/locale/af/LC_MESSAGES/JokeMachine.mo new file mode 100644 index 0000000..7fac1bc --- /dev/null +++ b/locale/af/LC_MESSAGES/JokeMachine.mo Binary files differ diff --git a/locale/af/LC_MESSAGES/JokeMachine.po b/locale/af/LC_MESSAGES/JokeMachine.po new file mode 100644 index 0000000..3682935 --- /dev/null +++ b/locale/af/LC_MESSAGES/JokeMachine.po @@ -0,0 +1,305 @@ +# Afrikaans translations for PACKAGE package. +# Copyright (C) 2007 THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# , 2007. +# +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2007-10-29 05:52+0200\n" +"PO-Revision-Date: 2007-10-29 05:53+0200\n" +"Last-Translator: \n" +"Language-Team: Afrikaans\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=ASCII\n" +"Content-Transfer-Encoding: 8bit\n" + +#: activity/activity.info:2 JokeMachineActivity.py:123 +#: mesh/activitysession.py:165 mesh/activitysession.py:205 +msgid "Joke Machine" +msgstr "Grap Masjien" + +#: JokeMachineActivity.py:123 +msgid "Please wait a moment for your buddy's Jokebooks to show up" +msgstr "Wag asseblief 'n oomblik vir jou maaitjie se grap boek" + +#: gui/frame.py:121 gui/frame.py:208 +msgid "Lesson Plans" +msgstr "Les Planne" + +#: gui/frame.py:139 +msgid "Read Jokebooks" +msgstr "Lees Grapboeke" + +#: gui/frame.py:143 +msgid "Make Jokebook" +msgstr "Maak Grapboek" + +#: gui/frame.py:212 +msgid "Close Lessons" +msgstr "Maak Lesse Toe" + +#: gui/frame.py:216 +msgid "Lesson Plans:" +msgstr "Les Planne:" + +#: gui/page.py:99 +msgid "Click to choose a sound" +msgstr "Klik om n klank te kies" + +#: gui/page.py:294 +msgid "Choose image" +msgstr "Kies n prentjie" + +#: gui/page.py:322 +msgid "Choose Sound" +msgstr "Kies n klank" + +#: i18n.py:40 +msgid "Chinese (simplified)" +msgstr "" + +#: i18n.py:41 +msgid "Chinese (traditional)" +msgstr "" + +#: i18n.py:42 +msgid "Czech" +msgstr "" + +#: i18n.py:43 +msgid "Danish" +msgstr "" + +#: i18n.py:44 +msgid "Dutch" +msgstr "" + +#: i18n.py:45 +msgid "Afrikaans" +msgstr "" + +#: i18n.py:46 +msgid "English" +msgstr "" + +#: i18n.py:47 +msgid "English - Great Britain" +msgstr "" + +#: i18n.py:48 +msgid "English - U.S." +msgstr "" + +#: i18n.py:49 +msgid "Finnish" +msgstr "" + +#: i18n.py:50 +msgid "French" +msgstr "" + +#: i18n.py:51 +msgid "German" +msgstr "" + +#: i18n.py:52 +msgid "Hungarian" +msgstr "" + +#: i18n.py:53 +msgid "Italian" +msgstr "" + +#: i18n.py:54 +msgid "Japanese" +msgstr "" + +#: i18n.py:55 +msgid "Korean" +msgstr "" + +#: i18n.py:56 +msgid "Norwegian" +msgstr "" + +#: i18n.py:57 +msgid "Polish" +msgstr "" + +#: i18n.py:58 +msgid "Portuguese" +msgstr "" + +#: i18n.py:59 +msgid "Portuguese - Brazilian" +msgstr "" + +#: i18n.py:60 +msgid "Russian" +msgstr "" + +#: i18n.py:61 +msgid "Slovak" +msgstr "" + +#: i18n.py:62 +msgid "Spanish" +msgstr "" + +#: i18n.py:63 +msgid "Swedish" +msgstr "" + +#: i18n.py:64 +msgid "Turkish" +msgstr "" + +#: i18n_misc_strings.py:1 +msgid "Lesson 1" +msgstr "Les 1" + +#: i18n_misc_strings.py:2 +msgid "Lesson 2" +msgstr "Les 2" + +#: i18n_misc_strings.py:3 +msgid "Lesson 3" +msgstr "Les 3" + +#: i18n_misc_strings.py:4 +msgid "Lesson 4" +msgstr "Les 4" + +#: i18n_misc_strings.py:5 +msgid "Introduction" +msgstr "Introduksie" + +#: mesh/activitysession.py:164 +msgid " submitted a joke to " +msgstr " het 'n grappie gestuur aan " + +#: mesh/activitysession.py:203 +msgid " accepted a joke submitted to " +msgstr " het 'n grappie antvaar vir " + +#: mesh/activitysession.py:204 +msgid " by " +msgstr " deur " + +#: pages/choose.py:42 +msgid "Choose a Jokebook to read:" +msgstr "Kies 'n Grapboek om te lees:" + +#: pages/choose.py:65 +msgid "Are you sure you want to delete your " +msgstr "Is jy seker jy wil jou " + +#: pages/choose.py:68 +msgid "grapboek uitvee ?" +msgstr "" + +#: pages/choose.py:110 pages/preview.py:62 +msgid "Edit" +msgstr "Redigeer" + +#: pages/choose.py:114 pages/edit.py:178 +msgid "Delete" +msgstr "Vee uit" + +#: pages/cover.py:37 pages/preview.py:44 +msgid "started by" +msgstr "begin deur" + +#: pages/cover.py:49 +msgid "Open" +msgstr "Maak oop" + +#: pages/edit.py:57 +msgid "Edit Jokebook Cover" +msgstr "Redigeer Grapboek " + +#: pages/edit.py:67 +msgid "Edit My Jokes" +msgstr "Redigeer Grap" + +#: pages/edit.py:77 +msgid "Review Submitted Jokes" +msgstr "Redigeer verwysings" + +#: pages/edit.py:123 +msgid "Preview" +msgstr "Voorkyk" + +#: pages/edit.py:149 +msgid "Title of Jokebook:" +msgstr "Naam van Grapboek:" + +#: pages/edit.py:153 +msgid "Sound Effect:" +msgstr "Klank:" + +#: pages/edit.py:190 +msgid "Add New Joke" +msgstr "Voeg nuwe grap by" + +#: pages/edit.py:201 +msgid "Are you sure you want to delete this joke ?" +msgstr "Is jy seker jy wil hierdie grap uit vee ?" + +#: pages/edit.py:242 +msgid "Reject" +msgstr "Nie Aanvaar" + +#: pages/edit.py:249 +msgid "Accept" +msgstr "Aanvaar" + +#: pages/joke.py:56 +msgid "Joke" +msgstr "Grap" + +#: pages/joke.py:59 +msgid "By" +msgstr "By" + +#: pages/joke.py:69 pages/submit.py:63 +msgid "Question" +msgstr "Vraag" + +#: pages/joke.py:78 pages/joke.py:123 pages/submit.py:71 +msgid "Answer" +msgstr "Antwoord" + +#: pages/joke.py:97 +msgid "This Jokebook is empty" +msgstr "Hierdie Grapboek is leeg" + +#: pages/joke.py:99 pages/joke.py:156 +msgid "Submit a Joke" +msgstr "Stuur 'n Grappie" + +#: pages/joke.py:104 +msgid "Add Jokes" +msgstr "Voeg grap by" + +#: pages/joke.py:150 +msgid "Next" +msgstr "Volgende" + +#: pages/submit.py:93 +msgid "Submission For:" +msgstr "Verwysing vir:" + +#: pages/submit.py:94 +msgid "Your Name:" +msgstr "Jou Naam:" + +#: pages/submit.py:105 +msgid "Submit" +msgstr "Verwys" + +#: pages/submit.py:108 +msgid "Back" +msgstr "Terug" diff --git a/mesh/activitysession.py b/mesh/activitysession.py index 6c2b51b..b7dfb89 100644 --- a/mesh/activitysession.py +++ b/mesh/activitysession.py @@ -25,9 +25,9 @@ from globals import Globals from persistence.jokemachinestate import JokeMachineState from persistence.joke import Joke -MESH_SERVICE = 'org.worldwideworkshop.JokeMachine' +MESH_SERVICE = 'org.worldwideworkshop.olpc.JokeMachine' MESH_IFACE = MESH_SERVICE -MESH_PATH = '/org/worldwideworkshop/JokeMachine' +MESH_PATH = '/org/worldwideworkshop/olpc/JokeMachine' @@ -146,7 +146,9 @@ class JokeMachineSession(ExportedGObject): logging.debug('JokeMachineSession.submit_cb() -> empty joke_pickle - doing nothing') return joke = Joke.loads(joke_pickle) - logging.debug('%s submitted a joke to my jokebook# %d with text: %s and answer %s', joke.joker, jokebook_id, joke.text, joke.answer) + if joke is None: + logging.error('JokeMachineSession.submit_cb -> could not unpickle joke') + return # 2. get the jokebook it belongs to jokebook = Globals.JokeMachineState.jokebook(jokebook_id) @@ -155,17 +157,20 @@ class JokeMachineSession(ExportedGObject): return # 3. add it to submissions in the appropriate jokebook + logging.debug('%s submitted a joke to my jokebook# %d with text: %s and answer %s', joke.joker, jokebook_id, joke.text, joke.answer) jokebook.submissions.append(joke) - # 4. TODO - show some kind of alert - ask on #sugar + # 4. alert the owner + message = str(joke.joker) + _(' submitted a joke to ') + str(jokebook.title) + Globals.JokeMachineActivity.alert(_('Joke Machine'), message) # e -> I am the initiator, I've just accepted a submission, tell everyone! - @signal (dbus_interface=MESH_IFACE, signature='us') - def BroadcastJoke(self, jokebook_id, joke_pickle): + @signal (dbus_interface=MESH_IFACE, signature='uss') + def BroadcastJoke(self, jokebook_id, joke_pickle, sender_nick): '''broadcast newly accepted submission back to the mesh''' - def broadcast_joke_cb(self, jokebook_id, joke_pickle, sender): + def broadcast_joke_cb(self, jokebook_id, joke_pickle, sender_nick, sender): '''handle a BroadCast Joke by creating a new joke in the local store''' if sender == self.my_bus_name: # Ignore my own signal @@ -179,7 +184,9 @@ class JokeMachineSession(ExportedGObject): logging.debug('JokeMachineSession.broadcast_joke_cb() -> empty joke_pickle - doing nothing') return joke = Joke.loads(joke_pickle) - logging.debug('%s broadcast a joke to my jokebook# %d with text: %s and answer %s', joke.joker, jokebook_id, joke.text, joke.answer) + if joke is None: + logging.error('JokeMachineSession.broadcast_joke_cb -> could not unpickle joke') + return # 2. get the jokebook it belongs to jokebook = Globals.JokeMachineState.jokebook(jokebook_id) @@ -188,10 +195,14 @@ class JokeMachineSession(ExportedGObject): return # 3. add it to jokes in the appropriate jokebook + logging.debug('%s broadcast a joke to my jokebook# %d with text: %s and answer %s', joke.joker, jokebook_id, joke.text, joke.answer) jokebook.jokes.append(joke) + # 4. TODO - show some kind of alert - ask on #sugar - + message = str(sender_nick) + _(' accepted a joke submitted to ') + \ + str(jokebook.title) + _(' by ') + str(joke.joker) + Globals.JokeMachineActivity.alert(_('Joke Machine'), message) # ############################################################################ diff --git a/pages/choose.py b/pages/choose.py index c115f94..fee1e48 100644 --- a/pages/choose.py +++ b/pages/choose.py @@ -39,11 +39,10 @@ class Choose(Page): Page.__init__(self) # page title - self.append(hippo.CanvasText( - text= 'Choose a Jokebook to read:', - xalign=hippo.ALIGNMENT_START, - padding=10, - font_desc=theme.FONT_BODY.get_pango_desc())) + self.append(hippo.CanvasText(text= _('Choose a Jokebook to read:'), + xalign=hippo.ALIGNMENT_START, + padding=10, + font_desc=theme.FONT_BODY.get_pango_desc())) # list of Jokebooks allow_edit = Globals.JokeMachineActivity.is_initiator @@ -63,12 +62,15 @@ class Choose(Page): def __do_clicked_delete(self, button, jokebook): + message = _('Are you sure you want to delete your ') + if jokebook.title is not None: + message += '\'' + jokebook.title + '\' ' + message += _('jokebook ?') confirm = gtk.MessageDialog(Globals.JokeMachineActivity, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_QUESTION, gtk.BUTTONS_YES_NO, - _('Are you sure you want to delete your') + \ - ' \'' + jokebook.title + '\' ' + _('jokebook ?')) + message) response = confirm.run() confirm.hide() confirm.destroy() diff --git a/pages/edit.py b/pages/edit.py index b213655..a2ad0c0 100644 --- a/pages/edit.py +++ b/pages/edit.py @@ -132,7 +132,7 @@ class Edit(Page): def do_tab_clicked(self, page_class): print page_class self.__page_selector.page = page_class(self.__jokebook, self) - + return self.__page_selector.page class EditInfo(Page): # TODO -> gui.Page should follow this pattern rather @@ -143,6 +143,8 @@ class EditInfo(Page): # TODO -> gui.Page should follow this pattern rather spacing=20, box_height=theme.TABS_HEIGHT) + self.__parent = parent + # page title self.append(self.make_field(_('Title of Jokebook:'), 250, jokebook, 'title', 300, True)) #field = self.make_field(_('Sound Effect:'), 250, None, '', 300, False) @@ -167,34 +169,31 @@ class EditJokes(Page): def __init__(self, jokebook, parent): Page.__init__(self) + self.__parent = parent + # list of jokes jokes_div = CanvasListBox(800, theme.TABS_HEIGHT) jokes_div.props.border=0 for joke in jokebook.jokes: - list_row = self.make_listrow(JokeEditor(joke)) button = gtk.Button(' ' + _('Delete') + ' ') - button.connect('clicked', self.__do_clicked_delete, jokebook, joke, parent) + button.connect('clicked', self.__do_clicked_delete, jokebook, joke) + list_row = self.make_listrow(JokeEditor(joke)) list_row.append(hippo.CanvasWidget(widget=theme.theme_widget(button), - border_color=theme.COLOR_RED.get_int(), - border=0, - padding_top=10, - padding_bottom=10, - padding_left=85)) - #xalign=hippo.ALIGNMENT_END)) + padding=5), + hippo.PACK_END) jokes_div.append(list_row) self.append(jokes_div) # new joke button buttons = hippo.CanvasBox(orientation=hippo.ORIENTATION_HORIZONTAL, xalign=hippo.ALIGNMENT_START) - button = gtk.Button(_('Add New Joke')) - button.connect('clicked', self.__do_clicked_add_joke, jokebook, parent) + button.connect('clicked', self.do_clicked_add_joke, jokebook) buttons.append(hippo.CanvasWidget(widget=theme.theme_widget(button))) jokes_div.append(buttons) - def __do_clicked_delete(self, button, jokebook, joke, parent): + def __do_clicked_delete(self, button, jokebook, joke): confirm = gtk.MessageDialog(Globals.JokeMachineActivity, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_QUESTION, @@ -207,10 +206,10 @@ class EditJokes(Page): if response == gtk.RESPONSE_YES: logging.debug('Deleting joke: %s' % joke.id) jokebook.jokes.remove(joke) - parent.do_tab_clicked(EditJokes) + self.__parent.do_tab_clicked(EditJokes) - def __do_clicked_add_joke(self, button, jokebook, parent): + def do_clicked_add_joke(self, button, jokebook): # create a new joke joke = persistence.joke.Joke() joke.id = jokebook.next_joke_id @@ -219,7 +218,7 @@ class EditJokes(Page): jokebook.jokes.append(joke) # reload tab - parent.do_tab_clicked(EditJokes) + self.__parent.do_tab_clicked(EditJokes) @@ -227,6 +226,8 @@ class EditReview(Page): def __init__(self, jokebook, parent): Page.__init__(self) + self.__parent = parent + jokes_div = CanvasListBox(800, theme.TABS_HEIGHT) jokes_div.props.border=0 for joke in jokebook.submissions: @@ -239,14 +240,14 @@ class EditReview(Page): padding=10) button = gtk.Button(' ' + _('Reject') + ' ') - button.connect('clicked', self.__do_clicked_reject, jokebook, joke, parent) + button.connect('clicked', self.__do_clicked_reject, jokebook, joke) buttons.append(hippo.CanvasWidget(widget=theme.theme_widget(button), border_color=theme.COLOR_RED.get_int(), border=0, xalign=hippo.ALIGNMENT_CENTER)) button = gtk.Button(' ' + _('Accept') + ' ') - button.connect('clicked', self.__do_clicked_accept, jokebook, joke, parent) + button.connect('clicked', self.__do_clicked_accept, jokebook, joke) buttons.append(hippo.CanvasWidget(widget=theme.theme_widget(button), border_color=theme.COLOR_RED.get_int(), border=0, @@ -282,22 +283,18 @@ class EditReview(Page): self.append(jokes_div) - def __do_clicked_accept(self, button, jokebook, joke, parent): + def __do_clicked_accept(self, button, jokebook, joke): jokebook.jokes.append(joke) jokebook.submissions.remove(joke) - parent.do_tab_clicked(EditReview) - - if not Globals.JokeMachineActivity.is_shared: - return - - # broadcast submission onto the mesh - logging.debug('Broadcasting joke to mesh') - pickle = joke.dumps() - Globals.JokeMachineActivity.tube.BroadcastJoke(jokebook.id, pickle) - logging.debug('Broadcasted joke to mesh') - + self.__parent.do_tab_clicked(EditReview) + if Globals.JokeMachineActivity.is_shared: + # broadcast submission onto the mesh + logging.debug('Broadcasting joke to mesh') + pickle = joke.dumps() + Globals.JokeMachineActivity.tube.BroadcastJoke(jokebook.id, pickle, Globals.nickname) + logging.debug('Broadcasted joke to mesh') - def __do_clicked_reject(self, button, jokebook, joke, parent): + def __do_clicked_reject(self, button, jokebook, joke): jokebook.submissions.remove(joke) - parent.do_tab_clicked(EditReview) + self.__parent.do_tab_clicked(EditReview) diff --git a/pages/joke.py b/pages/joke.py index fedd50e..43d0764 100644 --- a/pages/joke.py +++ b/pages/joke.py @@ -100,6 +100,11 @@ class Joke(Page): button.connect('clicked', self.__do_clicked_submit, jokebook, joke_id) self.append(hippo.CanvasWidget(widget=theme.theme_widget(button), padding_top=20)) + else: + button = gtk.Button(_('Add Jokes')) + button.connect('clicked', self.__do_clicked_add, jokebook, joke_id) + self.append(hippo.CanvasWidget(widget=theme.theme_widget(button), + padding_top=20)) return # the joke box @@ -152,7 +157,12 @@ class Joke(Page): button.connect('clicked', self.__do_clicked_submit, jokebook, joke_id) self.navigation_box.append(hippo.CanvasWidget(widget=theme.theme_widget(button), padding_top=20)) + + def __do_clicked_add(self, button, jokebook, joke_id): + page = Globals.JokeMachineActivity.set_page(pages.edit.Edit, jokebook) + tab = page.do_tab_clicked(pages.edit.EditJokes) + tab.do_clicked_add_joke(None, jokebook) def __do_clicked_submit(self, button, jokebook, joke_id): Globals.JokeMachineActivity.set_page(pages.submit.Submit, jokebook, joke_id) diff --git a/pages/preview.py b/pages/preview.py index de5bc3a..66e1811 100644 --- a/pages/preview.py +++ b/pages/preview.py @@ -37,6 +37,21 @@ class Preview(Page): Page.__init__(self, xalign=hippo.ALIGNMENT_CENTER) preview_box = CanvasListBox(1028, theme.PREVIEW_HEIGHT) # TODO - really shouldn't be hardcoded + + # cover + cover = self.make_listrow() + cover.props.orientation=hippo.ORIENTATION_VERTICAL + cover.append(hippo.CanvasText(text='"' + jokebook.title + '" ' + _('started by') + ' ' + jokebook.owner, + xalign=hippo.ALIGNMENT_CENTER, + padding_top=10, + font_desc=theme.FONT_BODY_BOLD.get_pango_desc())) + cover.append(hippo.CanvasBox(box_height=theme.SPACER_VERTICAL)) + cover_picture = self.make_imagebox(jokebook, 'image', 640, 480, False) + cover.append(cover_picture) + cover.append(hippo.CanvasBox(box_height=theme.SPACER_VERTICAL)) + preview_box.append(cover) + + # jokes for joke in jokebook.jokes: list_row = self.make_listrow(JokeViewer(joke, jokebook.title)) preview_box.append(list_row) diff --git a/persistence/joke.py b/persistence/joke.py index 8523593..0af66b8 100644 --- a/persistence/joke.py +++ b/persistence/joke.py @@ -67,14 +67,6 @@ class Joke(object): '''the country of the author''' def get(self): return self.__joker_country def set(self, value): self.__joker_country = value - - @PersistentProperty - def show(): - '''should this joke be visible to others''' - def default(self): return False - def get(self): return self.__show - def set(self, value): self.__show = value - def test_data(self): #self.image = 'resources/knockknock.png' @@ -86,7 +78,6 @@ Alex who?''' self.joker = 'hummingbird' self.joker_location = 'Cape Town' self.joker_country = 'South Africa' - self.show = True return self diff --git a/persistence/jokebook.py b/persistence/jokebook.py index acadf04..48c7297 100644 --- a/persistence/jokebook.py +++ b/persistence/jokebook.py @@ -73,8 +73,14 @@ class Jokebook(object): '''jokes submitted to this jokebook pending approval''' def default(self): return [] def get(self): return self.__submissions - + @PersistentProperty + def show(): + '''should this jokebook be visible to others''' + def default(self): return False + def get(self): return self.__show + def set(self, value): self.__show = value + # TODO - this should really be transparent @property def next_joke_id(self): diff --git a/persistence/jokemachinestate.py b/persistence/jokemachinestate.py index 3d591cf..ae5d303 100644 --- a/persistence/jokemachinestate.py +++ b/persistence/jokemachinestate.py @@ -40,24 +40,23 @@ class JokeMachineState(object): def default(self): return 1 # TODO - pull from activity/activity.info def get(self): return self.__version - @property def next_jokebook_id(self): if len(self.jokebooks) == 0: return 1 return max([jokebook.id for jokebook in self.jokebooks]) + 1 - def jokebook(self, id): + '''returns the jokebook specified by id''' for jokebook in self.jokebooks: if jokebook.id == id: return jokebook logging.error('Could not find jokebook with id %d' % d) return None + def test_data(self): self.id = 1 - # add some jokebooks with jokes num_jokebooks = 0 num_jokes = 2 @@ -77,6 +76,5 @@ class JokeMachineState(object): joke.id = joke_id jokebook.submissions.append(joke) self.jokebooks.append(jokebook) - return self \ No newline at end of file diff --git a/resources/gtkrc b/resources/gtkrc index 78cf7fd..76e4bbc 100644 --- a/resources/gtkrc +++ b/resources/gtkrc @@ -14,14 +14,25 @@ style "mamacombo" bg[ACTIVE] = "#026002" } -style "fixshare" +style "mamanotebook" { + fg[NORMAL] = "#FFFFFF" + fg[ACTIVE] = "#FFFFFF" + fg[PRELIGHT] = "#FFFFFF" + bg[NORMAL] = "#027F01" + bg[ACTIVE] = "#026002" +} + +style "fixframe" +{ bg[NORMAL] = "#808080" } widget "*GtkButton*" style "mamabutton" widget_class "**" style "mamacombo" -widget "*ComboBox*" style "fixshare" +widget_class "*" style "mamanotebook" +widget "*ComboBox*" style "fixframe" + -- cgit v0.9.1