Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWalter Bender <walter.bender@gmail.com>2012-04-12 13:33:32 (GMT)
committer Walter Bender <walter.bender@gmail.com>2012-04-12 13:33:32 (GMT)
commit6496755d71447a50af6e3f34da68b49ef49b5ad7 (patch)
treee9c0565d2326ea8c8de0e051cd72a48beefefdbd
parente668ea8a1325ce11d31a315f0fcae9ffdf57df36 (diff)
renaming activity
-rw-r--r--NutritionActivity.py111
-rw-r--r--activity/activity-nutrition.svg26
-rw-r--r--activity/activity.info8
3 files changed, 141 insertions, 4 deletions
diff --git a/NutritionActivity.py b/NutritionActivity.py
new file mode 100644
index 0000000..c1afe67
--- /dev/null
+++ b/NutritionActivity.py
@@ -0,0 +1,111 @@
+#Copyright (c) 2011,12 Walter Bender
+
+# 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.
+#
+# You should have received a copy of the GNU General Public License
+# along with this library; if not, write to the Free Software
+# Foundation, 51 Franklin Street, Suite 500 Boston, MA 02110-1335 USA
+
+
+import gtk
+
+from sugar.activity import activity
+from sugar import profile
+from sugar.graphics.toolbarbox import ToolbarBox
+from sugar.activity.widgets import ActivityToolbarButton
+from sugar.activity.widgets import StopButton
+
+from gettext import gettext as _
+
+from game import Game
+from toolbar_utils import separator_factory, radio_factory, label_factory
+
+import logging
+_logger = logging.getLogger('nutrition-activity')
+
+
+SERVICE = 'org.sugarlabs.NutritionActivity'
+IFACE = SERVICE
+LABELS = [_('Match the food to its name.'),
+ _('How many calories are there?'),
+ _('How much should you eat?')]
+
+
+class NutritionActivity(activity.Activity):
+ """ Simple nutrition game based on GCompris ImageID """
+
+ def __init__(self, handle):
+ """ Initialize the toolbars and the game board """
+ super(NutritionActivity, self).__init__(handle)
+
+ self.path = activity.get_bundle_path()
+
+ self._setup_toolbars()
+
+ # Create a canvas
+ canvas = gtk.DrawingArea()
+ canvas.set_size_request(gtk.gdk.screen_width(), \
+ gtk.gdk.screen_height())
+ self.set_canvas(canvas)
+ canvas.show()
+ self.show_all()
+
+ self._game = Game(canvas, parent=self, path=self.path)
+ self._game.new_game()
+
+ def _setup_toolbars(self):
+ """ Setup the toolbars. """
+
+ self.max_participants = 1 # No collaboration
+
+ toolbox = ToolbarBox()
+
+ # Activity toolbar
+ activity_button = ActivityToolbarButton(self)
+
+ toolbox.toolbar.insert(activity_button, 0)
+ activity_button.show()
+
+ self.set_toolbar_box(toolbox)
+ toolbox.show()
+ self.toolbar = toolbox.toolbar
+
+ self.beginner_button = radio_factory(
+ 'beginner',
+ toolbox.toolbar,
+ self._level_cb,
+ cb_arg=0,
+ tooltip=_(LABELS[0]),
+ group=None)
+ self.intermediate_button = radio_factory(
+ 'intermediate',
+ toolbox.toolbar,
+ self._level_cb,
+ cb_arg=1,
+ tooltip=_(LABELS[1]),
+ group=self.beginner_button)
+ self.expert_button = radio_factory(
+ 'expert',
+ toolbox.toolbar,
+ self._level_cb,
+ cb_arg=2,
+ tooltip=_(LABELS[2]),
+ group=self.beginner_button)
+
+ separator_factory(toolbox.toolbar, False, True)
+ self._label = label_factory(toolbox.toolbar, LABELS[0])
+
+ separator_factory(toolbox.toolbar, True, False)
+ stop_button = StopButton(self)
+ stop_button.props.accelerator = '<Ctrl>q'
+ toolbox.toolbar.insert(stop_button, -1)
+ stop_button.show()
+
+ def _level_cb(self, button, level):
+ ''' Switch between levels '''
+ self._game.level = level
+ self._label.set_text(LABELS[level])
+ self._game.new_game()
diff --git a/activity/activity-nutrition.svg b/activity/activity-nutrition.svg
new file mode 100644
index 0000000..2e235a5
--- /dev/null
+++ b/activity/activity-nutrition.svg
@@ -0,0 +1,26 @@
+<?xml version="1.0" ?><!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd' [
+ <!ENTITY stroke_color "#000">
+ <!ENTITY fill_color "#eee">
+]><svg height="55px" viewBox="0 0 55 55" width="55px" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" stroke-linecap="round" stroke-linejoin="round" stroke-width="3.5" stroke="&stroke_color;" fill="&fill_color;">
+ <g
+ transform="matrix(0.15517161,0,0,0.15517161,0.5476181,0.67353225)"
+ id="g3793"
+ style="stroke-width:7.73337317;stroke-miterlimit:4;stroke-dasharray:none">
+ <path
+ d="m 12.492955,169.42623 c 25.131531,-12.0997 90.578215,-9.41548 121.769345,-10.65574 35.7774,-1.42262 74.27633,-1.53204 103.45863,-22.27907 17.47887,-12.42653 49.56887,-47.453631 57.49199,-77.033651 3.98997,-14.896083 -1.62928,-24.252959 -5.37685,-39.211867 -5.14351,-20.53101132 20.52399,-19.25153267 30.09941,-16.540888 8.60686,2.4364619 -3.58452,20.898015 -2.70683,25.445215 2.97854,15.431491 2.48825,29.169798 6.70578,35.849771 3.88508,6.153427 15.28106,6.64746 17.70444,15.622279 9.55187,35.374641 -10.40811,80.200091 -30.90164,110.574731 -21.02806,31.16688 -78.24059,55.29145 -123.55758,63.16279 C 168.60762,257.58566 60.238798,247.85106 39.426229,234.42623 31.67892,229.42895 18.578606,212.81151 10.196434,203.16326 1.9604627,193.6833 1.1781426,174.8738 12.492955,169.42623 z"
+ id="path2987"
+ style="fill:&fill_color;;fill-opacity:1;stroke:&stroke_color;;stroke-width:7.73337317;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
+ <path
+ d="m 289.21856,18.560959 c 1.40774,3.272105 11.33615,0.540011 14.74048,-0.508292 5.88758,-1.812975 16.98934,-3.62167 15.75708,-9.6575619 -0.92505,-4.5311003 -13.89293,-5.472511 -18.29853,-4.0663417 -5.59369,1.7853818 -14.51954,8.8384826 -12.19903,14.2321956 z"
+ id="path3759"
+ style="fill:&stroke_color;;fill-opacity:1;stroke:&stroke_color;;stroke-width:7.73337317;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
+ <path
+ d="m 14.232196,183.2478 c -0.550401,4.44234 -2.357001,13.09359 -6.6078052,11.69073 -7.8629093,-2.59494 -5.2085859,-24.05314 3.0497562,-24.65219 4.468577,-0.32415 4.108942,8.51514 3.558049,12.96146 z"
+ id="path3757"
+ style="fill:&stroke_color;;fill-opacity:1;stroke:&stroke_color;;stroke-width:7.73337317;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
+ <path
+ d="m 12.492955,169.42623 c 25.131531,-12.0997 90.578215,-9.41548 121.769345,-10.65574 35.7774,-1.42262 74.27633,-1.53204 103.45863,-22.27907 17.47887,-12.42653 49.56887,-47.453629 57.49199,-77.033649 3.98997,-14.89608 -1.62928,-24.25296 -5.37685,-39.21187 -5.14351,-20.53100972 20.52399,-19.25152972 30.09941,-16.5408897 8.60686,2.43647 -3.58452,20.8980197 -2.70683,25.4452197 2.97854,15.43149 2.48825,29.1698 6.70578,35.84977 3.88508,6.15343 15.28106,6.64746 17.70444,15.62228 9.55187,35.374639 -10.40811,80.200089 -30.90164,110.574729 -21.02806,31.16688 -78.24059,55.29145 -123.55758,63.16279 C 168.60762,257.58566 60.238798,247.85106 39.426229,234.42623 31.67892,229.42895 18.578606,212.81151 10.196434,203.16326 1.9604625,193.6833 1.1781425,174.8738 12.492955,169.42623 z"
+ id="path2987-2"
+ style="fill:none;stroke:&stroke_color;;stroke-width:7.73337317;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
+ </g>
+</svg>
diff --git a/activity/activity.info b/activity/activity.info
index f937348..d4c3303 100644
--- a/activity/activity.info
+++ b/activity/activity.info
@@ -1,8 +1,8 @@
[Activity]
-name = ImageID
+name = Nutrition
activity_version = 1
license = GPLv3
-bundle_id = org.sugarlabs.ImageIDActivity
-exec = sugar-activity ImageIDActivity.ImageIDActivity
-icon = activity-imageid
+bundle_id = org.sugarlabs.NutritionActivity
+exec = sugar-activity NutritionActivity.NutritionActivity
+icon = activity-nutrition
show_launcher = yes