Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Schampijer <simon@schampijer.de>2007-06-28 10:39:43 (GMT)
committer Simon Schampijer <simon@schampijer.de>2007-06-28 10:39:43 (GMT)
commita560c46d0cc56516e30bf756c1d47ea52857ee13 (patch)
tree42e99cea56d678ddedea7a15b28cf0b091d2380d
parent96e2e6fe317f3a031296ef2c2e44f038ba188c29 (diff)
Commit before the split.
-rw-r--r--buddiespanel.py127
-rw-r--r--games/drumgit/drumgit.mson9
-rw-r--r--games/guitar/guitar.mson35
-rw-r--r--games/guitar/images/drumkit10_b.jpgbin0 -> 16416 bytes
-rw-r--r--games/guitar/images/drumkit11_b.jpgbin0 -> 16488 bytes
-rw-r--r--games/guitar/images/drumkit12_b.jpgbin0 -> 16755 bytes
-rw-r--r--games/guitar/images/drumkit1_b.jpgbin0 -> 17279 bytes
-rw-r--r--games/guitar/images/drumkit2_b.jpgbin0 -> 17257 bytes
-rw-r--r--games/guitar/images/drumkit3_b.jpgbin0 -> 17294 bytes
-rw-r--r--games/guitar/images/drumkit4_b.jpgbin0 -> 17157 bytes
-rw-r--r--games/guitar/images/drumkit5_b.jpgbin0 -> 17248 bytes
-rw-r--r--games/guitar/images/drumkit6_b.jpgbin0 -> 17376 bytes
-rw-r--r--games/guitar/images/drumkit7_b.jpgbin0 -> 17223 bytes
-rw-r--r--games/guitar/images/drumkit8_b.jpgbin0 -> 17257 bytes
-rw-r--r--games/guitar/images/drumkit9_b.jpgbin0 -> 16014 bytes
-rw-r--r--games/guitar/images/guitar10_2.jpgbin0 -> 14457 bytes
-rw-r--r--games/guitar/images/guitar11_2.jpgbin0 -> 14497 bytes
-rw-r--r--games/guitar/images/guitar12_2.jpgbin0 -> 14590 bytes
-rw-r--r--games/guitar/images/guitar1_2.jpgbin0 -> 13943 bytes
-rw-r--r--games/guitar/images/guitar2_2.jpgbin0 -> 13949 bytes
-rw-r--r--games/guitar/images/guitar3_2.jpgbin0 -> 13925 bytes
-rw-r--r--games/guitar/images/guitar4_2.jpgbin0 -> 13922 bytes
-rw-r--r--games/guitar/images/guitar5_2.jpgbin0 -> 13943 bytes
-rw-r--r--games/guitar/images/guitar6_2.jpgbin0 -> 14468 bytes
-rw-r--r--games/guitar/images/guitar7_2.jpgbin0 -> 13909 bytes
-rw-r--r--games/guitar/images/guitar8_2.jpgbin0 -> 13930 bytes
-rw-r--r--games/guitar/images/guitar9_2.jpgbin0 -> 14525 bytes
-rw-r--r--games/guitar/images/reference18
-rw-r--r--games/guitar/sounds/beat10.aiffbin0 -> 175948 bytes
-rw-r--r--games/guitar/sounds/beat14.aiffbin0 -> 240880 bytes
-rw-r--r--games/guitar/sounds/beat16.aiffbin0 -> 264554 bytes
-rw-r--r--games/guitar/sounds/beat17.aiffbin0 -> 198606 bytes
-rw-r--r--games/guitar/sounds/beat1_a.aiffbin0 -> 220588 bytes
-rw-r--r--games/guitar/sounds/beat1_b.aiffbin0 -> 220588 bytes
-rw-r--r--games/guitar/sounds/beat1_c.aiffbin0 -> 220588 bytes
-rw-r--r--games/guitar/sounds/beat2.aiffbin0 -> 165126 bytes
-rw-r--r--games/guitar/sounds/beat3.aiffbin0 -> 221942 bytes
-rw-r--r--games/guitar/sounds/beat4.aiffbin0 -> 152274 bytes
-rw-r--r--games/guitar/sounds/beat6_2.aiffbin0 -> 174932 bytes
-rw-r--r--games/guitar/sounds/beat8.aiffbin0 -> 198268 bytes
-rw-r--r--games/guitar/sounds/bending_a.aiffbin0 -> 220588 bytes
-rw-r--r--games/guitar/sounds/bending_b.aiffbin0 -> 220588 bytes
-rw-r--r--games/guitar/sounds/flashcomp2a.aiffbin0 -> 220588 bytes
-rw-r--r--games/guitar/sounds/flashcomp2b.aiffbin0 -> 176624 bytes
-rw-r--r--games/guitar/sounds/flasholet4.aiffbin0 -> 219724 bytes
-rw-r--r--games/guitar/sounds/gedaempft.aiffbin0 -> 94268 bytes
-rw-r--r--games/guitar/sounds/git_hit1.aiffbin0 -> 215250 bytes
-rw-r--r--games/guitar/sounds/git_hit4.aiffbin0 -> 222862 bytes
-rw-r--r--games/guitar/sounds/guitcello.aiffbin0 -> 265230 bytes
-rw-r--r--games/guitar/sounds/jimi1.aiffbin0 -> 66136 bytes
-rw-r--r--games/guitar/sounds/jimi4.aiffbin0 -> 65112 bytes
-rw-r--r--games/guitar/sounds/ungedaempft.aiffbin0 -> 183376 bytes
-rw-r--r--images/black.pngbin0 -> 276 bytes
-rw-r--r--memosono.dtd14
-rwxr-xr-xmemosonoactivity.py263
-rw-r--r--model.py89
-rw-r--r--playpoints.py73
-rw-r--r--playtile.py69
-rw-r--r--playview.py72
-rw-r--r--selectentry.py (renamed from gameobject.py)6
-rw-r--r--selectview.py (renamed from gameselectview.py)31
-rw-r--r--toolbar.py380
62 files changed, 741 insertions, 445 deletions
diff --git a/buddiespanel.py b/buddiespanel.py
new file mode 100644
index 0000000..50c85d6
--- /dev/null
+++ b/buddiespanel.py
@@ -0,0 +1,127 @@
+import gtk
+import hippo
+from sugar.graphics.canvasicon import CanvasIcon
+from sugar.graphics.xocolor import XoColor
+from sugar.graphics import color
+from sugar.graphics import font
+
+class BuddiesPanel(hippo.CanvasBox):
+ def __init__(self):
+ hippo.CanvasBox.__init__(self, spacing=4, padding=5,
+ orientation=hippo.ORIENTATION_VERTICAL)
+
+ self.players_box = hippo.CanvasBox(spacing=4, padding=5,
+ orientation=hippo.ORIENTATION_VERTICAL)
+
+ self.watchers_box = hippo.CanvasBox(spacing=4, padding=5,
+ orientation=hippo.ORIENTATION_VERTICAL)
+
+ self.append(self.players_box)
+ self.append(hippo.CanvasWidget(widget=gtk.HSeparator()))
+ self.append(self.watchers_box, hippo.PACK_EXPAND)
+
+ self.players = {}
+ self.watchers = {}
+
+ def _create_buddy_vbox (self, buddy):
+ buddy_color = buddy.props.color
+ if not buddy_color:
+ buddy_color = "#000000,#ffffff"
+
+ icon = CanvasIcon(
+ icon_name='theme:stock-buddy',
+ xo_color=XoColor(buddy_color))
+
+ nick = buddy.props.nick
+ if not nick:
+ nick = ""
+ name = hippo.CanvasText(text=nick, color=color.WHITE.get_int())
+
+ vbox = hippo.CanvasBox(padding=5)
+ vbox.append(icon)
+ vbox.append(name)
+
+ return vbox
+
+ def add_watcher(self, buddy):
+ op = buddy.object_path()
+ if self.watchers.get(op) is not None:
+ return
+ # if the watcher is also a player, don't add them
+ if self.players.get(op) is not None:
+ return
+
+ vbox = self._create_buddy_vbox (buddy)
+
+ self.watchers_box.append(vbox)
+
+ self.watchers[op] = vbox
+
+ def add_player(self, buddy):
+ op = buddy.object_path()
+ if self.players.get(op) is not None:
+ return
+ # if the player is also a watcher, drop them from the watchers
+ widget = self.watchers.pop(op, None)
+ if widget is not None:
+ self.watchers_box.remove(widget)
+
+ assert len(self.players) < 2
+
+ hbox = hippo.CanvasBox(spacing=4, padding=5,
+ orientation=hippo.ORIENTATION_HORIZONTAL)
+
+ vbox = self._create_buddy_vbox(buddy)
+ hbox.append(vbox)
+
+ count_font = font.DEFAULT_BOLD.get_pango_desc()
+ count_font.set_size(30000)
+ count = hippo.CanvasText(text="0", color=color.WHITE.get_int(),
+ font_desc=count_font)
+ hbox.append(count)
+
+ self.players_box.append(hbox)
+
+ self.players[op] = hbox
+
+ def set_is_playing(self, buddy):
+ op = buddy.object_path()
+ for player, hbox in self.players.items():
+ vbox = hbox.get_children()[0]
+ icon, name = vbox.get_children()
+ if player == op:
+ name.props.font_desc = font.DEFAULT_BOLD.get_pango_desc()
+ else:
+ name.props.font_desc = font.DEFAULT.get_pango_desc()
+
+ def set_count(self, buddy, val):
+ hbox = self.players.get(buddy.object_path())
+ if hbox is None:
+ return
+
+ count = hbox.get_children()[1]
+ count.props.text = str(val)
+
+ def remove_watcher(self, buddy):
+ op = buddy.object_path()
+ widget = self.watchers[op]
+ if widget is None:
+ return
+
+ self.watchers_box.remove(widget)
+ del self.watchers[op]
+
+ # removing someone from the game entirely should also remove them
+ # from the players
+ self.remove_player(buddy)
+
+ def remove_player(self, buddy):
+ op = buddy.object_path()
+ widget = self.players.get(op)
+ if widget is None:
+ return
+
+ self.players_box.remove(widget)
+ del self.players[op]
+
+ self.add_watcher(buddy)
diff --git a/games/drumgit/drumgit.mson b/games/drumgit/drumgit.mson
index a006e87..d5b4cfc 100644
--- a/games/drumgit/drumgit.mson
+++ b/games/drumgit/drumgit.mson
@@ -1,3 +1,11 @@
+<?xml version="1.0"?>
+<memosono name="drumgit">
+ <pair id="1" mother="guitar12_2.jpg" child="guitar12_2.jpg" color="12345" />
+ <pair id="2" mother="drumkit2_b.jpg" child="drumkit2_b.jpg" color="234567" />
+ <pair id="3" mother="guitar8_2.jpg" child="guitar8_2.jpg" color="23456767" />
+</memosono>
+
+<!--
drumkit1_b.jpg beat1_a.aiff
drumkit2_b.jpg beat1_b.aiff
drumkit3_b.jpg beat1_c.aiff
@@ -22,3 +30,4 @@ guitar9_2.jpg git_hit4.aiff
guitar10_2.jpg guitcello.aiff
guitar11_2.jpg flasholet4.aiff
guitar12_2.jpg jimi1.aiff
+--> \ No newline at end of file
diff --git a/games/guitar/guitar.mson b/games/guitar/guitar.mson
new file mode 100644
index 0000000..0db5d9b
--- /dev/null
+++ b/games/guitar/guitar.mson
@@ -0,0 +1,35 @@
+<?xml version="1.0"?>
+<memosono name="guitar">
+ <pair id="1" mother="drumkit9_b.jpg" child="drumkit9_b.jpg" color="12345" />
+ <pair id="2" mother="drumkit5_b.jpg" child="drumkit5_b.jpg" color="234567" />
+ <pair id="3" mother="drumkit8_b.jpg" child="drumkit10_b.jpg" color="23456767" />
+ <pair id="4" mother="drumkit1_b.jpg" child="drumkit1_b.jpg" color="23456767" />
+ <pair id="5" mother="drumkit2_b.jpg" child="drumkit2_b.jpg" color="23456767" />
+</memosono>
+
+<!--
+drumkit1_b.jpg beat1_a.aiff
+drumkit2_b.jpg beat1_b.aiff
+drumkit3_b.jpg beat1_c.aiff
+drumkit4_b.jpg beat8.aiff
+drumkit5_b.jpg beat2.aiff
+drumkit6_b.jpg beat3.aiff
+drumkit7_b.jpg beat4.aiff
+drumkit8_b.jpg beat14.aiff
+drumkit9_b.jpg beat6_2.aiff
+drumkit10_b.jpg beat16.aiff
+drumkit11_b.jpg beat17.aiff
+drumkit12_b.jpg beat10.aiff
+guitar1_2.jpg bending_a.aiff
+guitar2_2.jpg bending_b.aiff
+guitar3_2.jpg flashcomp2a.aiff
+guitar4_2.jpg flashcomp2b.aiff
+guitar5_2.jpg gedaempft.aiff
+guitar6_2.jpg ungedaempft.aiff
+guitar7_2.jpg jimi4.aiff
+guitar8_2.jpg git_hit1.aiff
+guitar9_2.jpg git_hit4.aiff
+guitar10_2.jpg guitcello.aiff
+guitar11_2.jpg flasholet4.aiff
+guitar12_2.jpg jimi1.aiff
+--> \ No newline at end of file
diff --git a/games/guitar/images/drumkit10_b.jpg b/games/guitar/images/drumkit10_b.jpg
new file mode 100644
index 0000000..9288d4c
--- /dev/null
+++ b/games/guitar/images/drumkit10_b.jpg
Binary files differ
diff --git a/games/guitar/images/drumkit11_b.jpg b/games/guitar/images/drumkit11_b.jpg
new file mode 100644
index 0000000..cd169ce
--- /dev/null
+++ b/games/guitar/images/drumkit11_b.jpg
Binary files differ
diff --git a/games/guitar/images/drumkit12_b.jpg b/games/guitar/images/drumkit12_b.jpg
new file mode 100644
index 0000000..f10ade8
--- /dev/null
+++ b/games/guitar/images/drumkit12_b.jpg
Binary files differ
diff --git a/games/guitar/images/drumkit1_b.jpg b/games/guitar/images/drumkit1_b.jpg
new file mode 100644
index 0000000..98ab27d
--- /dev/null
+++ b/games/guitar/images/drumkit1_b.jpg
Binary files differ
diff --git a/games/guitar/images/drumkit2_b.jpg b/games/guitar/images/drumkit2_b.jpg
new file mode 100644
index 0000000..e1a7fc7
--- /dev/null
+++ b/games/guitar/images/drumkit2_b.jpg
Binary files differ
diff --git a/games/guitar/images/drumkit3_b.jpg b/games/guitar/images/drumkit3_b.jpg
new file mode 100644
index 0000000..3a75f41
--- /dev/null
+++ b/games/guitar/images/drumkit3_b.jpg
Binary files differ
diff --git a/games/guitar/images/drumkit4_b.jpg b/games/guitar/images/drumkit4_b.jpg
new file mode 100644
index 0000000..a4c5b97
--- /dev/null
+++ b/games/guitar/images/drumkit4_b.jpg
Binary files differ
diff --git a/games/guitar/images/drumkit5_b.jpg b/games/guitar/images/drumkit5_b.jpg
new file mode 100644
index 0000000..063ef59
--- /dev/null
+++ b/games/guitar/images/drumkit5_b.jpg
Binary files differ
diff --git a/games/guitar/images/drumkit6_b.jpg b/games/guitar/images/drumkit6_b.jpg
new file mode 100644
index 0000000..991edd8
--- /dev/null
+++ b/games/guitar/images/drumkit6_b.jpg
Binary files differ
diff --git a/games/guitar/images/drumkit7_b.jpg b/games/guitar/images/drumkit7_b.jpg
new file mode 100644
index 0000000..4f993e7
--- /dev/null
+++ b/games/guitar/images/drumkit7_b.jpg
Binary files differ
diff --git a/games/guitar/images/drumkit8_b.jpg b/games/guitar/images/drumkit8_b.jpg
new file mode 100644
index 0000000..dfdd67c
--- /dev/null
+++ b/games/guitar/images/drumkit8_b.jpg
Binary files differ
diff --git a/games/guitar/images/drumkit9_b.jpg b/games/guitar/images/drumkit9_b.jpg
new file mode 100644
index 0000000..16197e4
--- /dev/null
+++ b/games/guitar/images/drumkit9_b.jpg
Binary files differ
diff --git a/games/guitar/images/guitar10_2.jpg b/games/guitar/images/guitar10_2.jpg
new file mode 100644
index 0000000..cc1f29b
--- /dev/null
+++ b/games/guitar/images/guitar10_2.jpg
Binary files differ
diff --git a/games/guitar/images/guitar11_2.jpg b/games/guitar/images/guitar11_2.jpg
new file mode 100644
index 0000000..a738ef2
--- /dev/null
+++ b/games/guitar/images/guitar11_2.jpg
Binary files differ
diff --git a/games/guitar/images/guitar12_2.jpg b/games/guitar/images/guitar12_2.jpg
new file mode 100644
index 0000000..2998cfe
--- /dev/null
+++ b/games/guitar/images/guitar12_2.jpg
Binary files differ
diff --git a/games/guitar/images/guitar1_2.jpg b/games/guitar/images/guitar1_2.jpg
new file mode 100644
index 0000000..89dbd7c
--- /dev/null
+++ b/games/guitar/images/guitar1_2.jpg
Binary files differ
diff --git a/games/guitar/images/guitar2_2.jpg b/games/guitar/images/guitar2_2.jpg
new file mode 100644
index 0000000..6766232
--- /dev/null
+++ b/games/guitar/images/guitar2_2.jpg
Binary files differ
diff --git a/games/guitar/images/guitar3_2.jpg b/games/guitar/images/guitar3_2.jpg
new file mode 100644
index 0000000..3cf7431
--- /dev/null
+++ b/games/guitar/images/guitar3_2.jpg
Binary files differ
diff --git a/games/guitar/images/guitar4_2.jpg b/games/guitar/images/guitar4_2.jpg
new file mode 100644
index 0000000..ea12232
--- /dev/null
+++ b/games/guitar/images/guitar4_2.jpg
Binary files differ
diff --git a/games/guitar/images/guitar5_2.jpg b/games/guitar/images/guitar5_2.jpg
new file mode 100644
index 0000000..a5cec0d
--- /dev/null
+++ b/games/guitar/images/guitar5_2.jpg
Binary files differ
diff --git a/games/guitar/images/guitar6_2.jpg b/games/guitar/images/guitar6_2.jpg
new file mode 100644
index 0000000..6212245
--- /dev/null
+++ b/games/guitar/images/guitar6_2.jpg
Binary files differ
diff --git a/games/guitar/images/guitar7_2.jpg b/games/guitar/images/guitar7_2.jpg
new file mode 100644
index 0000000..356a90f
--- /dev/null
+++ b/games/guitar/images/guitar7_2.jpg
Binary files differ
diff --git a/games/guitar/images/guitar8_2.jpg b/games/guitar/images/guitar8_2.jpg
new file mode 100644
index 0000000..2b33f99
--- /dev/null
+++ b/games/guitar/images/guitar8_2.jpg
Binary files differ
diff --git a/games/guitar/images/guitar9_2.jpg b/games/guitar/images/guitar9_2.jpg
new file mode 100644
index 0000000..691423d
--- /dev/null
+++ b/games/guitar/images/guitar9_2.jpg
Binary files differ
diff --git a/games/guitar/images/reference b/games/guitar/images/reference
new file mode 100644
index 0000000..79ce4c4
--- /dev/null
+++ b/games/guitar/images/reference
@@ -0,0 +1,18 @@
+The guitar pictures are distributed under the Creative Commons Attribution ShareAlike 2.0 Germany License since they derive of the following work:
+
+guitar:
+ creator: Martin Moeller
+ name: Classical_Guitar_two_views
+ licence: Creative Commons Attribution ShareAlike 2.0 Germany License
+ (http://creativecommons.org/licenses/by-sa/2.0/de/)
+ link: http://de.wikipedia.org/wiki/Bild:Classical_Guitar_two_views.jpg
+
+
+The drumkit pictures are distributed under the GNU Free Documentation License since they derive of the following work:
+
+drumkit:
+ creator: Clngre
+ name: Illustration of a drum kit for "drum kit component"
+ licence: GNU-Lizenz für freie Dokumentation
+ (http://commons.wikimedia.org/wiki/Commons:GNU_Free_Documentation_License)
+ found at: http://de.wikipedia.org/wiki/Bild:Drum_kit_illustration_template.png \ No newline at end of file
diff --git a/games/guitar/sounds/beat10.aiff b/games/guitar/sounds/beat10.aiff
new file mode 100644
index 0000000..7a86e46
--- /dev/null
+++ b/games/guitar/sounds/beat10.aiff
Binary files differ
diff --git a/games/guitar/sounds/beat14.aiff b/games/guitar/sounds/beat14.aiff
new file mode 100644
index 0000000..ae530e2
--- /dev/null
+++ b/games/guitar/sounds/beat14.aiff
Binary files differ
diff --git a/games/guitar/sounds/beat16.aiff b/games/guitar/sounds/beat16.aiff
new file mode 100644
index 0000000..9bd9474
--- /dev/null
+++ b/games/guitar/sounds/beat16.aiff
Binary files differ
diff --git a/games/guitar/sounds/beat17.aiff b/games/guitar/sounds/beat17.aiff
new file mode 100644
index 0000000..92990b4
--- /dev/null
+++ b/games/guitar/sounds/beat17.aiff
Binary files differ
diff --git a/games/guitar/sounds/beat1_a.aiff b/games/guitar/sounds/beat1_a.aiff
new file mode 100644
index 0000000..654ba5f
--- /dev/null
+++ b/games/guitar/sounds/beat1_a.aiff
Binary files differ
diff --git a/games/guitar/sounds/beat1_b.aiff b/games/guitar/sounds/beat1_b.aiff
new file mode 100644
index 0000000..a8328e9
--- /dev/null
+++ b/games/guitar/sounds/beat1_b.aiff
Binary files differ
diff --git a/games/guitar/sounds/beat1_c.aiff b/games/guitar/sounds/beat1_c.aiff
new file mode 100644
index 0000000..776bb23
--- /dev/null
+++ b/games/guitar/sounds/beat1_c.aiff
Binary files differ
diff --git a/games/guitar/sounds/beat2.aiff b/games/guitar/sounds/beat2.aiff
new file mode 100644
index 0000000..33069d4
--- /dev/null
+++ b/games/guitar/sounds/beat2.aiff
Binary files differ
diff --git a/games/guitar/sounds/beat3.aiff b/games/guitar/sounds/beat3.aiff
new file mode 100644
index 0000000..3c22de6
--- /dev/null
+++ b/games/guitar/sounds/beat3.aiff
Binary files differ
diff --git a/games/guitar/sounds/beat4.aiff b/games/guitar/sounds/beat4.aiff
new file mode 100644
index 0000000..1c2fe08
--- /dev/null
+++ b/games/guitar/sounds/beat4.aiff
Binary files differ
diff --git a/games/guitar/sounds/beat6_2.aiff b/games/guitar/sounds/beat6_2.aiff
new file mode 100644
index 0000000..911e630
--- /dev/null
+++ b/games/guitar/sounds/beat6_2.aiff
Binary files differ
diff --git a/games/guitar/sounds/beat8.aiff b/games/guitar/sounds/beat8.aiff
new file mode 100644
index 0000000..fa85017
--- /dev/null
+++ b/games/guitar/sounds/beat8.aiff
Binary files differ
diff --git a/games/guitar/sounds/bending_a.aiff b/games/guitar/sounds/bending_a.aiff
new file mode 100644
index 0000000..661c67f
--- /dev/null
+++ b/games/guitar/sounds/bending_a.aiff
Binary files differ
diff --git a/games/guitar/sounds/bending_b.aiff b/games/guitar/sounds/bending_b.aiff
new file mode 100644
index 0000000..ddbfb97
--- /dev/null
+++ b/games/guitar/sounds/bending_b.aiff
Binary files differ
diff --git a/games/guitar/sounds/flashcomp2a.aiff b/games/guitar/sounds/flashcomp2a.aiff
new file mode 100644
index 0000000..3b5f284
--- /dev/null
+++ b/games/guitar/sounds/flashcomp2a.aiff
Binary files differ
diff --git a/games/guitar/sounds/flashcomp2b.aiff b/games/guitar/sounds/flashcomp2b.aiff
new file mode 100644
index 0000000..0d7d14d
--- /dev/null
+++ b/games/guitar/sounds/flashcomp2b.aiff
Binary files differ
diff --git a/games/guitar/sounds/flasholet4.aiff b/games/guitar/sounds/flasholet4.aiff
new file mode 100644
index 0000000..0c4d56e
--- /dev/null
+++ b/games/guitar/sounds/flasholet4.aiff
Binary files differ
diff --git a/games/guitar/sounds/gedaempft.aiff b/games/guitar/sounds/gedaempft.aiff
new file mode 100644
index 0000000..0ede22e
--- /dev/null
+++ b/games/guitar/sounds/gedaempft.aiff
Binary files differ
diff --git a/games/guitar/sounds/git_hit1.aiff b/games/guitar/sounds/git_hit1.aiff
new file mode 100644
index 0000000..ac7a33e
--- /dev/null
+++ b/games/guitar/sounds/git_hit1.aiff
Binary files differ
diff --git a/games/guitar/sounds/git_hit4.aiff b/games/guitar/sounds/git_hit4.aiff
new file mode 100644
index 0000000..528d843
--- /dev/null
+++ b/games/guitar/sounds/git_hit4.aiff
Binary files differ
diff --git a/games/guitar/sounds/guitcello.aiff b/games/guitar/sounds/guitcello.aiff
new file mode 100644
index 0000000..0d5c90b
--- /dev/null
+++ b/games/guitar/sounds/guitcello.aiff
Binary files differ
diff --git a/games/guitar/sounds/jimi1.aiff b/games/guitar/sounds/jimi1.aiff
new file mode 100644
index 0000000..94c50e4
--- /dev/null
+++ b/games/guitar/sounds/jimi1.aiff
Binary files differ
diff --git a/games/guitar/sounds/jimi4.aiff b/games/guitar/sounds/jimi4.aiff
new file mode 100644
index 0000000..a70611a
--- /dev/null
+++ b/games/guitar/sounds/jimi4.aiff
Binary files differ
diff --git a/games/guitar/sounds/ungedaempft.aiff b/games/guitar/sounds/ungedaempft.aiff
new file mode 100644
index 0000000..d9e5d7c
--- /dev/null
+++ b/games/guitar/sounds/ungedaempft.aiff
Binary files differ
diff --git a/images/black.png b/images/black.png
new file mode 100644
index 0000000..987b088
--- /dev/null
+++ b/images/black.png
Binary files differ
diff --git a/memosono.dtd b/memosono.dtd
new file mode 100644
index 0000000..bd46b94
--- /dev/null
+++ b/memosono.dtd
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<!ELEMENT memosono (#PCDATA|pair)*>
+<!ATTLIST memosono
+ name CDATA #REQUIRED
+>
+
+<!ELEMENT pair (#PCDATA)* >
+<!ATTLIST pair
+ id CDATA #REQUIRED
+ mother CDATA #REQUIRED
+ child CDATA #REQUIRED
+ color CDATA #REQUIRED
+>
diff --git a/memosonoactivity.py b/memosonoactivity.py
index 1998cdf..ffb3610 100755
--- a/memosonoactivity.py
+++ b/memosonoactivity.py
@@ -20,107 +20,216 @@
from gettext import gettext as _
import gobject
-import gtk, pygtk
+import gtk
import os
-import socket
import logging
-import random
-import copy
-import time
-import errno
-import gc
+import dbus
+import telepathy
+import telepathy.client
from sugar.activity.activity import Activity
from sugar.activity.activity import ActivityToolbox
-
-from toolbar import ImageToolbar
+from sugar.presence import presenceservice
from osc.oscapi import OscApi
from csound.csoundserver import CsoundServer
-from gameselectview import GameSelectView
+from selectview import SelectView
+from playview import PlayView
+from toolbar import PlayToolbar
+from model import Game
+
class MemosonoActivity(Activity):
def __init__(self, handle):
Activity.__init__(self, handle)
self.set_title ("Memosono")
+ self.sv = None
+ self.pv = None
toolbox = ActivityToolbox(self)
self.set_toolbox(toolbox)
toolbox.show()
- #toolbox._notebook.connect('select-page', self._select_page)
toolbox._notebook.connect('switch-page', self._switch_page)
- self.image_toolbar = ImageToolbar(toolbox)
- toolbox.add_toolbar(_('Play'), self.image_toolbar)
- self.image_toolbar.show()
-
- self.gs = GameSelectView(['drumgit','summer'])
- self.gs.connect('entry-selected', self._entry_selected_cb)
- self.set_canvas(self.gs)
- self.gs.show()
-
- self.play = GameSelectView(['play', 'play'])
+ self.play_toolbar = PlayToolbar(self)
+ toolbox.add_toolbar(_('Play'), self.play_toolbar)
+ self.play_toolbar.show()
- '''
- # create our main abiword canvas
- self.abiword_canvas = Canvas()
- self.abiword_canvas.connect("can-undo", self._can_undo_cb)
- self.abiword_canvas.connect("can-redo", self._can_redo_cb)
- self.abiword_canvas.connect('text-selected', self._selection_cb)
- self.abiword_canvas.connect('image-selected', self._selection_cb)
- self.abiword_canvas.connect('selection-cleared', self._selection_cleared_cb)
-
- self._edit_toolbar = EditToolbar()
-
- self._edit_toolbar.undo.set_sensitive(False)
- self._edit_toolbar.undo.connect('clicked', self._undo_cb)
-
- self._edit_toolbar.redo.set_sensitive(False)
- self._edit_toolbar.redo.connect('clicked', self._redo_cb)
-
- self._edit_toolbar.copy.connect('clicked', self._copy_cb)
- self._edit_toolbar.paste.connect('clicked', self._paste_cb)
-
- toolbox.add_toolbar(_('Edit'), self._edit_toolbar)
- self._edit_toolbar.show()
-
- text_toolbar = TextToolbar(toolbox, self.abiword_canvas)
- toolbox.add_toolbar(_('Text'), text_toolbar)
- text_toolbar.show()
-
- image_toolbar = ImageToolbar(toolbox, self.abiword_canvas)
- toolbox.add_toolbar(_('Image'), image_toolbar)
- image_toolbar.show()
-
- table_toolbar = TableToolbar(toolbox, self.abiword_canvas)
- toolbox.add_toolbar(_('Table'), table_toolbar)
- table_toolbar.show()
-
- view_toolbar = ViewToolbar(self.abiword_canvas)
- toolbox.add_toolbar(_('View'), view_toolbar)
- view_toolbar.show()
-
- self.set_canvas(self.abiword_canvas)
- self.abiword_canvas.show()
-
- self.abiword_canvas.connect_after('map', self._map_cb)
- '''
-
+ self.games = {}
+
+ os.path.walk(os.path.join(os.path.dirname(__file__), 'games'), self._find_games, None)
+
+ gamelist = self.games.keys()
+ gamelist.sort()
+ logging.debug(gamelist)
+ self.pv = PlayView(None, self.games[gamelist[0]].pairs)
+ self.pv.show()
+ self.sv = SelectView(gamelist)
+ self.sv.connect('entry-selected', self._entry_selected_cb)
+ self.sv.show()
+
+ self.pservice = presenceservice.get_instance()
+ self.owner = self.pservice.get_owner()
+
+ bus = dbus.Bus()
+ name, path = self.pservice.get_preferred_connection()
+ self.tp_conn_name = name
+ self.tp_conn_path = path
+ self.conn = telepathy.client.Connection(name, path)
+ self.initiating = None
+ self.game = None
+
+ self.connect('shared', self._shared_cb)
+
+ if self._shared_activity:
+ # we are joining the activity
+ self.buddies_panel.add_watcher(owner)
+ self.connect('joined', self._joined_cb)
+ self._shared_activity.connect('buddy-joined', self._buddy_joined_cb)
+ self._shared_activity.connect('buddy-left', self._buddy_left_cb)
+ if self.get_shared():
+ # oh, OK, we've already joined
+ self._joined_cb()
+ else:
+ # we are creating the activity
+ self.pv.buddies_panel .add_player(self.owner)
+
+
+ def _shared_cb(self, activity):
+ logging.debug('My Memosono activity was shared')
+ self.initiating = True
+ self._setup()
+
+ for buddy in self._shared_activity.get_joined_buddies():
+ self.pv.buddies_panel.add_watcher(buddy)
+
+ self._shared_activity.connect('buddy-joined', self._buddy_joined_cb)
+ self._shared_activity.connect('buddy-left', self._buddy_left_cb)
+
+ logging.debug('This is my activity: making a tube...')
+ id = self.tubes_chan[telepathy.CHANNEL_TYPE_TUBES].OfferTube(
+ telepathy.TUBE_TYPE_DBUS, 'org.fredektop.Telepathy.Tube.Memosono', {})
+ logging.debug('Tube address: %s', self.tubes_chan[telepathy.CHANNEL_TYPE_TUBES].GetDBusServerAddress(id))
+ logging.debug('Waiting for another player to join')
+
+ # FIXME: presence service should be tubes-aware and give us more help
+ # with this
+ def _setup(self):
+ if self._shared_activity is None:
+ logging.error('Failed to share or join activity')
+ return
+
+ bus_name, conn_path, channel_paths = self._shared_activity.get_channels()
+
+ # Work out what our room is called and whether we have Tubes already
+ room = None
+ tubes_chan = None
+ text_chan = None
+ for channel_path in channel_paths:
+ channel = telepathy.client.Channel(bus_name, channel_path)
+ htype, handle = channel.GetHandle()
+ if htype == telepathy.HANDLE_TYPE_ROOM:
+ logging.debug('Found our room: it has handle#%d "%s"',
+ handle, self.conn.InspectHandles(htype, [handle])[0])
+ room = handle
+ ctype = channel.GetChannelType()
+ if ctype == telepathy.CHANNEL_TYPE_TUBES:
+ logging.debug('Found our Tubes channel at %s', channel_path)
+ tubes_chan = channel
+ elif ctype == telepathy.CHANNEL_TYPE_TEXT:
+ logging.debug('Found our Text channel at %s', channel_path)
+ text_chan = channel
+
+ if room is None:
+ logging.error("Presence service didn't create a room")
+ return
+ if text_chan is None:
+ logging.error("Presence service didn't 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("Didn't find our Tubes channel, requesting one...")
+ tubes_chan = self.conn.request_channel(telepathy.CHANNEL_TYPE_TUBES,
+ telepathy.HANDLE_TYPE_ROOM, room, True)
+
+ self.tubes_chan = tubes_chan
+ self.text_chan = text_chan
+
+ tubes_chan[telepathy.CHANNEL_TYPE_TUBES].connect_to_signal('NewTube',
+ self._new_tube_cb)
+
+ def _list_tubes_reply_cb(self, tubes):
+ for tube_info in tubes:
+ self._new_tube_cb(*tube_info)
+
+ def _list_tubes_error_cb(self, e):
+ logging.error('ListTubes() failed: %s', e)
+
+ def _joined_cb(self, activity):
+ if self.game is not None:
+ return
+
+ if not self._shared_activity:
+ return
+
+ for buddy in self._shared_activity.get_joined_buddies():
+ self.pv.buddies_panel.add_watcher(buddy)
+
+ logging.debug('Joined an existing Connect game')
+ logging.debug('Joined a game. Waiting for my turn...')
+ self.initiating = False
+ self._setup()
+
+ logging.debug('This is not my activity: waiting for a tube...')
+ self.tubes_chan[telepathy.CHANNEL_TYPE_TUBES].ListTubes(
+ reply_handler=self._list_tubes_reply_cb,
+ error_handler=self._list_tubes_error_cb)
+
+ def _new_tube_cb(self, id, initiator, type, service, params, state):
+ logging.debug('New tube: ID=%d initator=%d type=%d service=%s '
+ 'params=%r state=%d', id, initiator, type, service,
+ params, state)
+
+ if (self.game is None and type == telepathy.TUBE_TYPE_DBUS and
+ service == 'org.fredektop.Telepathy.Tube.Memosono'):
+ if state == telepathy.TUBE_STATE_LOCAL_PENDING:
+ self.tubes_chan[telepathy.CHANNEL_TYPE_TUBES].AcceptTube(id)
+
+ tube_conn = TubeConnection(self.conn,
+ self.tubes_chan[telepathy.CHANNEL_TYPE_TUBES],
+ id, group_iface=self.text_chan[telepathy.CHANNEL_INTERFACE_GROUP])
+ self.game = ConnectGame(tube_conn, self.grid, self.initiating,
+ self.pv.buddies_panel, self.info_panel, self.owner,
+ self._get_buddy, self)
+
+ def _buddy_joined_cb (self, activity, buddy):
+ logging.debug('buddy joined')
+ self.pv.buddies_panel.add_watcher(buddy)
+
+ def _buddy_left_cb (self, activity, buddy):
+ logging.debug('buddy left')
+ self.pv.buddies_panel.remove_watcher(buddy)
+
+
+ def _find_games(self, arg, dirname, names):
+ for name in names:
+ if name.endswith('.mson'):
+ game = Game(dirname, os.path.dirname(__file__))
+ game.read(name)
+ self.games[name.split('.mson')[0]] = game
+
def _entry_selected_cb(self, list_view, entry):
- self.set_canvas(self.play)
- self.play.show()
-
- #def _select_page(self, notebook, move_focus, user_param1 ):
- #print '+++++ select page'
+ self.pv = PlayView(None, self.games[entry.name].pairs)
+ self.pv.show()
def _switch_page(self, notebook, page, page_num, user_param1=None):
+ if page_num == 1:
+ self.set_canvas(self.pv)
+ elif page_num == 0:
+ if self.sv != None:
+ self.set_canvas(self.sv)
- print '+++++ switch page %s'%str(page_num)
-
- # def get_nth_page(page_num)
- # page_num : the index of a page in the notebook
- # Returns : the child widget, or None if page_num is out of bounds.
-
def _cleanup_cb(self, data=None):
pass
#self.controler.oscapi.send(('127.0.0.1', 6783), "/CSOUND/quit", [])
diff --git a/model.py b/model.py
new file mode 100644
index 0000000..723e27c
--- /dev/null
+++ b/model.py
@@ -0,0 +1,89 @@
+import libxml2
+import os
+import logging
+
+class Game(object):
+ def __init__(self, gamepath, dtdpath, name='noname'):
+ self.name = name
+ self.pairs = {}
+ self.gamepath = gamepath
+ self.dtdpath = dtdpath
+
+ try:
+ self.dtd = libxml2.parseDTD(None, os.path.join(self.dtdpath, 'memosono.dtd'))
+ except libxml2.parserError, e:
+ logging.error('No memosono.dtd found ' +str(e))
+ self.dtd = None
+ self.ctxt = libxml2.newValidCtxt()
+
+ def read(self, filename):
+ try:
+ doc = libxml2.parseFile(os.path.join(self.gamepath, filename))
+ if doc.validateDtd(self.ctxt, self.dtd):
+
+ # get the requested nodes
+ xpa = doc.xpathNewContext()
+ res = xpa.xpathEval("//*")
+
+ # write their content to the data structure
+ for elem in res:
+ attributes = elem.get_properties()
+ pair = []
+ idpair = ''
+ for attribute in attributes:
+ if(attribute.name == 'text'):
+ pass
+ if(attribute.name == 'id'):
+ idpair = attribute.content
+ if(attribute.name == 'mother'):
+ pair.append(attribute.content)
+ if(attribute.name == 'child'):
+ pair.append(attribute.content)
+ if(attribute.name == 'color'):
+ pair.append(int(attribute.content))
+ if( elem.name == 'memosono' ):
+ self.name = attribute.content
+ if( elem.name != 'memosono' ):
+ self.pairs[idpair] = pair
+ xpa.xpathFreeContext()
+ else:
+ logging.error('Error in validation of the file')
+ doc.freeDoc()
+ except libxml2.parserError, e:
+ logging.error('Error parsing file ' +str(e))
+
+ def save(self, filename):
+ doc = libxml2.newDoc("1.0")
+ root = doc.newChild(None, "memosono", None)
+ root.setProp("name", self.name)
+ for key in self.pairs:
+
+ elem = root.newChild(None, "pair", None)
+ elem.setProp("id", key)
+ elem.setProp("mother", self.pairs[key][0])
+ elem.setProp("child", self.pairs[key][1])
+ elem.setProp("color", self.pairs[key][2])
+
+ if doc.validateDtd(self.ctxt, self.dtd):
+ doc.saveFormatFile(filename, 1)
+ doc.freeDoc()
+
+if __name__ == '__main__':
+
+ print "[Read game from file] "
+ game = Game()
+ game.read('memosono.xml')
+ print " name=" + game.name
+ print " pairs=%s" %game.pairs
+
+ elemkey = '0'
+ if game.pairs.has_key(elemkey):
+ del game.pairs[elemkey]
+
+ game.pairs['2'] = ['frettchen.jpg', 'frettchen.wav']
+
+ print "[Write game to file] "
+ game.save('memosono.xml')
+
+
+
diff --git a/playpoints.py b/playpoints.py
new file mode 100644
index 0000000..84f1b3b
--- /dev/null
+++ b/playpoints.py
@@ -0,0 +1,73 @@
+import gtk
+import hippo
+import math
+import os
+
+from sugar.graphics import font
+from sugar.graphics import units
+
+class PlayPoints(hippo.CanvasBox, hippo.CanvasItem):
+ __gtype_name__ = 'PlayPoints'
+ _BORDER_DEFAULT = units.points_to_pixels(1.0)
+
+ def __init__(self, name, **kargs):
+ hippo.CanvasBox.__init__(self, **kargs)
+
+ self.image = os.path.join(os.path.dirname(__file__), 'images/black.png')
+
+ self._radius = units.points_to_pixels(5)
+ self.props.border_color = 3520189183
+ self.props.background_color = 3520189183
+ self.props.orientation = hippo.ORIENTATION_VERTICAL
+ self.props.border = self._BORDER_DEFAULT
+ self.props.border_left = self._radius
+ self.props.border_right = self._radius
+
+ self.append(self._build_title_box())
+ playername = hippo.CanvasText(text=name,
+ xalign=hippo.ALIGNMENT_START,
+ font_desc=font.DEFAULT_BOLD.get_pango_desc(),
+ size_mode=hippo.CANVAS_SIZE_ELLIPSIZE_END)
+ self.append(playername)
+
+ def do_paint_background(self, cr, damaged_box):
+ [width, height] = self.get_allocation()
+
+ x = self._BORDER_DEFAULT / 2
+ y = self._BORDER_DEFAULT / 2
+ width -= self._BORDER_DEFAULT
+ height -= self._BORDER_DEFAULT
+
+ cr.move_to(x + self._radius, y);
+ cr.arc(x + width - self._radius, y + self._radius,
+ self._radius, math.pi * 1.5, math.pi * 2);
+ cr.arc(x + width - self._radius, x + height - self._radius,
+ self._radius, 0, math.pi * 0.5);
+ cr.arc(x + self._radius, y + height - self._radius,
+ self._radius, math.pi * 0.5, math.pi);
+ cr.arc(x + self._radius, y + self._radius, self._radius,
+ math.pi, math.pi * 1.5);
+
+ hippo.cairo_set_source_rgba32(cr, self.props.background_color)
+ cr.fill()
+
+ def _build_title_box(self):
+ hbox = hippo.CanvasBox(orientation=hippo.ORIENTATION_HORIZONTAL)
+ hbox.props.spacing = units.points_to_pixels(5)
+ hbox.props.padding_top = units.points_to_pixels(5)
+ hbox.props.padding_bottom = units.points_to_pixels(5)
+
+ self.img_widget = gtk.Image()
+ img_pixbuf = gtk.gdk.pixbuf_new_from_file(self.image)
+ self.pixbuf = img_pixbuf.scale_simple(100, 100, gtk.gdk.INTERP_BILINEAR)
+ self.img_widget.set_from_pixbuf(self.pixbuf)
+
+ canvas_widget = hippo.CanvasWidget()
+ canvas_widget.props.widget = self.img_widget
+ self.img_widget.show()
+ hbox.append(canvas_widget)
+
+ return hbox
+
+
+
diff --git a/playtile.py b/playtile.py
new file mode 100644
index 0000000..fd56e4d
--- /dev/null
+++ b/playtile.py
@@ -0,0 +1,69 @@
+import gtk
+import hippo
+import math
+import os
+
+from sugar.graphics import font
+from sugar.graphics import units
+
+class PlayTile(hippo.CanvasBox, hippo.CanvasItem):
+ __gtype_name__ = 'PlayTile'
+ _BORDER_DEFAULT = units.points_to_pixels(1.0)
+
+ def __init__(self, num, **kargs):
+ hippo.CanvasBox.__init__(self, **kargs)
+
+ self.num = num
+ self.image = os.path.join(os.path.dirname(__file__), 'images/black.png')
+
+ self._radius = units.points_to_pixels(5)
+ self.props.border_color = 100
+ self.props.background_color = 100
+ self.props.orientation = hippo.ORIENTATION_VERTICAL
+ self.props.border = self._BORDER_DEFAULT
+ self.props.border_left = self._radius
+ self.props.border_right = self._radius
+
+ self.append(self._build_title_box())
+
+
+ def do_paint_background(self, cr, damaged_box):
+ [width, height] = self.get_allocation()
+
+ x = self._BORDER_DEFAULT / 2
+ y = self._BORDER_DEFAULT / 2
+ width -= self._BORDER_DEFAULT
+ height -= self._BORDER_DEFAULT
+
+ cr.move_to(x + self._radius, y);
+ cr.arc(x + width - self._radius, y + self._radius,
+ self._radius, math.pi * 1.5, math.pi * 2);
+ cr.arc(x + width - self._radius, x + height - self._radius,
+ self._radius, 0, math.pi * 0.5);
+ cr.arc(x + self._radius, y + height - self._radius,
+ self._radius, math.pi * 0.5, math.pi);
+ cr.arc(x + self._radius, y + self._radius, self._radius,
+ math.pi, math.pi * 1.5);
+
+ hippo.cairo_set_source_rgba32(cr, self.props.background_color)
+ cr.fill()
+
+ def _build_title_box(self):
+ hbox = hippo.CanvasBox(orientation=hippo.ORIENTATION_HORIZONTAL)
+ hbox.props.spacing = units.points_to_pixels(5)
+ hbox.props.padding_top = units.points_to_pixels(5)
+ hbox.props.padding_bottom = units.points_to_pixels(5)
+
+ self.img_widget = gtk.Image()
+ self.img_pixbuf = gtk.gdk.pixbuf_new_from_file(self.image)
+ self.img_widget.set_from_pixbuf(self.img_pixbuf)
+
+ canvas_widget = hippo.CanvasWidget()
+ canvas_widget.props.widget = self.img_widget
+ self.img_widget.show()
+ hbox.append(canvas_widget)
+
+ return hbox
+
+
+
diff --git a/playview.py b/playview.py
new file mode 100644
index 0000000..ef3cf96
--- /dev/null
+++ b/playview.py
@@ -0,0 +1,72 @@
+import hippo
+import os
+import cairo
+import gtk
+
+from sugar.graphics import color
+from sugar.graphics import font
+
+from playtile import PlayTile
+from playpoints import PlayPoints
+from buddiespanel import BuddiesPanel
+
+class PlayView(hippo.Canvas):
+ def __init__(self, oscapi, pairs):
+ hippo.Canvas.__init__(self)
+
+ root = hippo.CanvasBox()
+ root.props.orientation = hippo.ORIENTATION_HORIZONTAL
+
+ tilebox = hippo.CanvasBox()
+ tilebox.props.orientation = hippo.ORIENTATION_VERTICAL
+ root.append(tilebox)
+
+ self.buddies_panel = BuddiesPanel()
+ root.append(self.buddies_panel)
+
+ '''
+ pointsbox = hippo.CanvasBox()
+ pointsbox.props.orientation = hippo.ORIENTATION_VERTICAL
+ root.append(pointsbox)
+
+ point = PlayPoints('erwin')
+ pointsbox.append(point)
+ point = PlayPoints('richard')
+ pointsbox.append(point)
+ '''
+
+ self.oscapi = oscapi
+ self.tiles = []
+ self.turn = 0
+
+ tile_num = 0
+ numtiles = len(pairs)*2
+ while tile_num < numtiles:
+ if tile_num == 0 or ((tile_num)%4) == 0:
+ box = hippo.CanvasBox()
+ box.props.orientation = hippo.ORIENTATION_HORIZONTAL
+ tilebox.append(box)
+
+ tile = PlayTile(tile_num)
+ tile.connect('button-press-event', self._button_press_cb, tile.num)
+ self.tiles.append(tile)
+ box.append(tile)
+
+ tile_num+=1
+
+ self.set_root(root)
+ self.show()
+
+ def _button_press_cb(self, tile, event, data=None):
+ if self.turn:
+ self.oscapi.send(('127.0.0.1', 40000), "/MEMOSONO/tile/chosen", [data])
+ else:
+ print 'it is not your turn'
+
+ def flip(self, tile_num, obj, color):
+ tile = self.tiles[tile_num]
+ tile.img_pixbuf = gtk.gdk.pixbuf_new_from_file(obj)
+ tile.img_widget.set_from_pixbuf(tile.img_pixbuf)
+ tile.props.background_color = color
+ tile.emit_paint_needed(0, 0, -1, -1)
+
diff --git a/gameobject.py b/selectentry.py
index 74c9f0f..475ae82 100644
--- a/gameobject.py
+++ b/selectentry.py
@@ -12,19 +12,21 @@ from sugar.graphics import color
from sugar.graphics import units
-class GameObject(Frame):
+class SelectEntry(Frame):
_DATE_COL_WIDTH = units.points_to_pixels(150)
_BUDDIES_COL_WIDTH = units.points_to_pixels(60)
def __init__(self, name):
Frame.__init__(self)
+ self.name = name
self.props.box_height = units.grid_to_pixels(1)
self.props.spacing = units.points_to_pixels(5)
self.props.border_color = color.FRAME_BORDER.get_int()
self.props.background_color = color.FRAME_BORDER.get_int()
+ logging.debug('FRAME_COLOR %s'%color.FRAME_BORDER.get_int())
- title = hippo.CanvasText(text=name,
+ title = hippo.CanvasText(text=self.name,
xalign=hippo.ALIGNMENT_START,
font_desc=font.DEFAULT_BOLD.get_pango_desc(),
size_mode=hippo.CANVAS_SIZE_ELLIPSIZE_END)
diff --git a/gameselectview.py b/selectview.py
index 6330b21..3975363 100644
--- a/gameselectview.py
+++ b/selectview.py
@@ -5,18 +5,20 @@ import gtk
from sugar.graphics import color
-from gameobject import GameObject
+from selectentry import SelectEntry
-class GameSelectView(gtk.ScrolledWindow):
- __gtype_name__ = 'GameSelectView'
+class SelectView(gtk.ScrolledWindow):
+ __gtype_name__ = 'SelectView'
__gsignals__ = {
'entry-selected': (gobject.SIGNAL_RUN_FIRST,
gobject.TYPE_NONE,
([object]))
}
-
- def __init__(self, name):
+
+ _SELECTED = 1000000
+ _UNSELECTED = 3520189183
+ def __init__(self, names):
gtk.ScrolledWindow.__init__(self)
root = hippo.CanvasBox()
@@ -30,23 +32,22 @@ class GameSelectView(gtk.ScrolledWindow):
self.turn = 0
self.current = 0
- tile_num = 0
- numtiles = 2
- while tile_num < numtiles:
-
- entry = GameObject(name[tile_num])
+ for name in names:
+ entry = SelectEntry(name)
entry.connect('button-press-event', self._button_press_cb)
root.append(entry)
- self.current = entry
- tile_num+=1
-
+ if name == names[0]:
+ self.current = entry
+ entry.props.background_color = self._SELECTED
+ entry.emit_paint_needed(0, 0, -1, -1)
+
canvas.show()
def _button_press_cb(self, entry, event, data=None):
- entry.props.background_color = 1000
+ entry.props.background_color = self._SELECTED
entry.emit_paint_needed(0, 0, -1, -1)
- self.current.props.background_color = 1000000
+ self.current.props.background_color = self._UNSELECTED
self.current.emit_paint_needed(0, 0, -1, -1)
self.current = entry
self.emit('entry-selected', entry)
diff --git a/toolbar.py b/toolbar.py
index 2eaa68f..1e79185 100644
--- a/toolbar.py
+++ b/toolbar.py
@@ -1,6 +1,4 @@
-# Copyright (C) 2006, Martin Sevior
-# Copyright (C) 2006-2007, Marc Maurer <uwog@uwog.net>
-# Copyright (C) 2007, One Laptop Per Child
+# Copyright (C) 2007, Simon Schampijer
#
# 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
@@ -15,104 +13,47 @@
# 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
+
from gettext import gettext as _
import logging
-import abiword
import gtk
-from sugar.graphics.toolbutton import ToolButton
-from sugar.graphics.toggletoolbutton import ToggleToolButton
from sugar.graphics.combobox import ComboBox
+from sugar.graphics.toolbutton import ToolButton
-#ick
-TOOLBAR_ACTIVITY = 0
-TOOLBAR_EDIT = 1
-TOOLBAR_TEXT = 2
-TOOLBAR_IMAGE = 3
-TOOLBAR_TABLE = 4
-TOOLBAR_VIEW = 5
-
-class TextToolbar(gtk.Toolbar):
- _ACTION_ALIGNMENT_LEFT = 0
- _ACTION_ALIGNMENT_CENTER = 1
- _ACTION_ALIGNMENT_RIGHT = 2
-
- def __init__(self, toolbox, abiword_canvas):
- self._colorseldlg = None
+class PlayToolbar(gtk.Toolbar):
+ def __init__(self, activity):
gtk.Toolbar.__init__(self)
- self._toolbox = toolbox
- self._abiword_canvas = abiword_canvas
-
- self._bold = ToggleToolButton('format-text-bold')
- self._bold_id = self._bold.connect('clicked', self._bold_cb)
- self._abiword_canvas.connect('bold', self._isBold_cb)
- self.insert(self._bold, -1)
- self._bold.show()
+ self._activity = activity
- self._italic = ToggleToolButton('format-text-italic')
- self._italic_id = self._italic.connect('clicked', self._italic_cb)
- self._abiword_canvas.connect('italic', self._isItalic_cb)
- self.insert(self._italic, -1)
- self._italic.show()
-
- self._underline = ToggleToolButton('format-text-underline')
- self._underline_id = self._underline.connect('clicked', self._underline_cb)
- self._abiword_canvas.connect('underline', self._isUnderline_cb)
- self.insert(self._underline, -1)
- self._underline.show()
-
- self._text_color = ToolButton('')
- self._text_color_id = self._text_color.connect('clicked', self._text_color_cb)
-# self._abiword_canvas.connect('text-color', self._isUnderline_cb)
- self.insert(self._text_color, -1)
- self._text_color.show()
-
- separator = gtk.SeparatorToolItem()
- separator.set_draw(True)
- self.insert(separator, -1)
-
- self._font_size_combo = ComboBox()
- self._font_sizes = ['8', '9', '10', '11', '12', '14', '16', '20', '22', '24', '26', '28', '36', '48', '72'];
- self._font_size_changed_id = self._font_size_combo.connect('changed', self._font_size_changed_cb)
- for i, s in enumerate(self._font_sizes):
- self._font_size_combo.append_item(i, s, None)
- if s == '12':
- self._font_size_combo.set_active(i)
- self._add_widget(self._font_size_combo)
-
- self._font_combo = ComboBox()
- self._fonts = sorted(self._abiword_canvas.get_font_names())
- self._fonts_changed_id = self._font_combo.connect('changed', self._font_changed_cb)
- for i, f in enumerate(self._fonts):
- self._font_combo.append_item(i, f, None)
- if f == 'Times New Roman':
- self._font_combo.set_active(i)
- self._add_widget(self._font_combo)
+ self._image = ToolButton('go-previous')
+ self._image_id = self._image.connect('clicked', self._back_cb)
+ self.insert(self._image, -1)
+ self._image.show()
separator = gtk.SeparatorToolItem()
separator.set_draw(True)
self.insert(separator, -1)
- separator.show()
- self._alignment = ComboBox()
- self._alignment.append_item(self._ACTION_ALIGNMENT_LEFT, None,
- 'format-justify-left')
- self._alignment.append_item(self._ACTION_ALIGNMENT_CENTER, None,
- 'format-justify-center')
- self._alignment.append_item(self._ACTION_ALIGNMENT_RIGHT, None,
- 'format-justify-right')
- self._alignment_changed_id = self._alignment.connect('changed',
- self._alignment_changed_cb)
- self._add_widget(self._alignment)
+ self._num_players_combo = ComboBox()
+ self._num_players = ['1', '2', '3', '4', '5', '6', '7', '8']
+ self._num_players_combo.connect('changed', self._num_players_changed_cb)
+ for i, s in enumerate(self._num_players):
+ self._num_players_combo.append_item(i, s, None)
+ if s == '1':
+ self._num_players_combo.set_active(i)
+ self._add_widget(self._num_players_combo)
- self._abiword_canvas.connect('left-align', self._isLeftAlign_cb)
- self._abiword_canvas.connect('center-align', self._isCenterAlign_cb)
- self._abiword_canvas.connect('right-align', self._isRightAlign_cb)
+ #self.close = ToolButton('window-close')
+ #self.close.connect('clicked', self._close_clicked_cb)
+ #self.insert(self.close, -1)
+ #self.close.show()
- self._abiword_canvas.connect('text-selected', self._text_selected_cb)
+ #def _close_clicked_cb(self, button):
+ # self._activity.close()
def _add_widget(self, widget, expand=False):
tool_item = gtk.ToolItem()
@@ -123,273 +64,10 @@ class TextToolbar(gtk.Toolbar):
self.insert(tool_item, -1)
tool_item.show()
-
- def setToggleButtonState(self,button,b,id):
- button.handler_block(id)
- button.set_active(b)
- button.handler_unblock(id)
-
- def _bold_cb(self, button):
- self._abiword_canvas.toggle_bold()
-
- def _isBold_cb(self, abi, b):
- print 'isBold',b
- self.setToggleButtonState(self._bold,b,self._bold_id)
-
- def _italic_cb(self, button):
- self._abiword_canvas.toggle_italic()
-
- def _isItalic_cb(self, abi, b):
- print 'isItalic',b
- self.setToggleButtonState(self._italic, b, self._italic_id)
-
- def _underline_cb(self, button):
- self._abiword_canvas.toggle_underline()
-
- def _isUnderline_cb(self, abi, b):
- print 'isUnderline',b
- self.setToggleButtonState(self._underline, b, self._underline_id)
-
- def _text_color_cb(self, button):
- if self._colorseldlg == None:
- self._colorseldlg = gtk.ColorSelectionDialog(_('Select text color'))
- response = self._colorseldlg.run()
- if response == gtk.RESPONSE_OK:
- newcolor = self._colorseldlg.colorsel.get_current_color()
- self._abiword_canvas.set_text_color(newcolor.red // 256.0, newcolor.green // 256.0, newcolor.blue // 256.0)
- self._colorseldlg.hide()
-
- def _font_changed_cb(self, combobox):
- if self._font_combo.get_active() != -1:
- print 'Setting font name:',self._fonts[self._font_combo.get_active()]
- self._abiword_canvas.set_font_name(self._fonts[self._font_combo.get_active()])
-
- def _font_size_changed_cb(self, combobox):
- if self._font_size_combo.get_active() != -1:
- print 'Setting font size:',self._font_sizes[self._font_size_combo.get_active()]
- self._abiword_canvas.set_font_size(self._font_sizes[self._font_size_combo.get_active()])
-
- def _alignment_changed_cb(self, combobox):
- if self._alignment.get_active() == self._ACTION_ALIGNMENT_LEFT:
- self._abiword_canvas.align_left()
- elif self._alignment.get_active() == self._ACTION_ALIGNMENT_CENTER:
- self._abiword_canvas.align_center()
- elif self._alignment.get_active() == self._ACTION_ALIGNMENT_RIGHT:
- self._abiword_canvas.align_right()
- else:
- raise ValueError, 'Unknown option in alignment combobox.'
-
- def _update_alignment_icon(self, index):
- self._alignment.handler_block(self._alignment_changed_id)
- try:
- self._alignment.set_active(index)
- finally:
- self._alignment.handler_unblock(self._alignment_changed_id)
-
- def _isLeftAlign_cb(self, abi, b):
- if b:
- self._update_alignment_icon(self._ACTION_ALIGNMENT_LEFT)
-
- def _isCenterAlign_cb(self, abi, b):
- if b:
- self._update_alignment_icon(self._ACTION_ALIGNMENT_CENTER)
-
- def _isRightAlign_cb(self, abi, b):
- if b:
- self._update_alignment_icon(self._ACTION_ALIGNMENT_RIGHT)
-
- def _text_selected_cb(self, abi, b):
- print 'text selected',b
- if b:
- self._toolbox.set_current_toolbar(TOOLBAR_TEXT)
- self._abiword_canvas.grab_focus() # hack: bad toolbox, bad!
-
-class ImageToolbar(gtk.Toolbar):
- def __init__(self, toolbox): #, abiword_canvas):
- gtk.Toolbar.__init__(self)
-
- self._toolbox = toolbox
- #self._abiword_canvas = abiword_canvas
-
- self._image = ToolButton('insert-image')
- self._image_id = self._image.connect('clicked', self._image_cb)
- self.insert(self._image, -1)
- self._image.show()
-
- #self._abiword_canvas.connect('image-selected', self._image_selected_cb)
- def _image_cb(self, button):
- self._abiword_canvas.invoke_cmd('fileInsertGraphic', '', 0, 0)
-
- def _image_selected_cb(self, abi, b):
- print 'imageSelected',b
- if b:
- self._toolbox.set_current_toolbar(TOOLBAR_IMAGE)
- self._abiword_canvas.grab_focus() # hack: bad toolbox, bad!
-
-class TableToolbar(gtk.Toolbar):
- def __init__(self, toolbox, abiword_canvas):
- gtk.Toolbar.__init__(self)
-
- self._toolbox = toolbox
- self._abiword_canvas = abiword_canvas
-
- self._table = abiword.TableCreator()
- self._table.set_labels(_('Table'), _('Cancel'))
- self._table_id = self._table.connect('selected', self._table_cb)
- self._table.show()
- tool_item = gtk.ToolItem()
- tool_item.add(self._table)
- self.insert(tool_item, -1)
- tool_item.show()
-
- self._table_rows_after = ToolButton('insert-row')
- self._table_rows_after_id = self._table_rows_after.connect('clicked', self._table_rows_after_cb)
- self.insert(self._table_rows_after, -1)
- self._table_rows_after.show()
-
- self._table_delete_rows = ToolButton('remove-row')
- self._table_delete_rows_id = self._table_delete_rows.connect('clicked', self._table_delete_rows_cb)
- self.insert(self._table_delete_rows, -1)
- self._table_delete_rows.show()
-
- self._table_cols_after = ToolButton('insert-col')
- self._table_cols_after_id = self._table_cols_after.connect('clicked', self._table_cols_after_cb)
- self.insert(self._table_cols_after, -1)
- self._table_cols_after.show()
-
- self._table_delete_cols = ToolButton('remove-col')
- self._table_delete_cols_id = self._table_delete_cols.connect('clicked', self._table_delete_cols_cb)
- self.insert(self._table_delete_cols, -1)
- self._table_delete_cols.show()
-
- self._abiword_canvas.connect('table-state', self._isTable_cb)
-
- def _table_cb(self, abi, rows, cols):
- self._abiword_canvas.insert_table(rows,cols)
-
- def _table_rows_after_cb(self, button):
- self._abiword_canvas.invoke_cmd('insertRowsAfter', '', 0, 0)
-
- def _table_delete_rows_cb(self, button):
- self._abiword_canvas.invoke_cmd('deleteRows', '', 0, 0)
-
- def _table_cols_after_cb(self, button):
- self._abiword_canvas.invoke_cmd('insertColsAfter', '', 0, 0)
-
- def _table_delete_cols_cb(self, button):
- self._abiword_canvas.invoke_cmd('deleteColumns', '', 0, 0)
-
- def _isTable_cb(self, abi, b):
- self._table_rows_after.set_sensitive(b)
- self._table_delete_rows.set_sensitive(b)
- self._table_cols_after.set_sensitive(b)
- self._table_delete_cols.set_sensitive(b)
- if b:
- self._toolbox.set_current_toolbar(TOOLBAR_TABLE)
- self._abiword_canvas.grab_focus() # hack: bad toolbox, bad!
-
-class ViewToolbar(gtk.Toolbar):
- def __init__(self, abiword_canvas):
- gtk.Toolbar.__init__(self)
-
- self._abiword_canvas = abiword_canvas
-
- # we can't use abiword_canvas.get_zoom_percentage() yet, as the frame is
- # not fully initialized
- self._zoom_percentage = 0;
-
- self._zoom_in = ToolButton('stock-zoom-in')
- self._zoom_in_id = self._zoom_in.connect('clicked', self._zoom_in_cb)
- self.insert(self._zoom_in, -1)
- self._zoom_in.show()
-
- self._zoom_out = ToolButton('stock-zoom-out')
- self._zoom_out_id = self._zoom_out.connect('clicked', self._zoom_out_cb)
- self.insert(self._zoom_out, -1)
- self._zoom_out.show()
-
- # TODO: fix the initial value
- self._zoom_spin_adj = gtk.Adjustment(0, 25, 400, 25, 50, 0)
- self._zoom_spin = gtk.SpinButton(self._zoom_spin_adj, 0, 0)
- self._zoom_spin_id = self._zoom_spin.connect('value-changed', self._zoom_spin_cb)
- self._zoom_spin.set_numeric(True)
- self._zoom_spin.show()
- tool_item_zoom = gtk.ToolItem()
- tool_item_zoom.add(self._zoom_spin)
- self.insert(tool_item_zoom, -1)
- tool_item_zoom.show()
-
- zoom_perc_label = gtk.Label(_("%"))
- zoom_perc_label.show()
- tool_item_zoom_perc_label = gtk.ToolItem()
- tool_item_zoom_perc_label.add(zoom_perc_label)
- self.insert(tool_item_zoom_perc_label, -1)
- tool_item_zoom_perc_label.show()
-
- separator = gtk.SeparatorToolItem()
- separator.set_draw(True)
- separator.show()
- self.insert(separator, -1)
-
- page_label = gtk.Label(_("Page:"))
- page_label.show()
- tool_item_page_label = gtk.ToolItem()
- tool_item_page_label.add(page_label)
- self.insert(tool_item_page_label, -1)
- tool_item_page_label.show()
-
- self._page_spin_adj = gtk.Adjustment(0, 1, 0, 1, 1, 0)
- self._page_spin = gtk.SpinButton(self._page_spin_adj, 0, 0)
- self._page_spin_id = self._page_spin.connect('value-changed', self._page_spin_cb)
- self._page_spin.set_numeric(True)
- self._page_spin.show()
- tool_item_page = gtk.ToolItem()
- tool_item_page.add(self._page_spin)
- self.insert(tool_item_page, -1)
- tool_item_page.show()
-
- self._abiword_canvas.connect("page-count", self._page_count_cb)
- self._abiword_canvas.connect("current-page", self._current_page_cb)
-
- def set_zoom_percentage(self, zoom):
- self._zoom_percentage = zoom
- #print 'new zoom percentage:',self._zoom_percentage
- self._abiword_canvas.set_zoom_percentage(self._zoom_percentage)
- # update out spinner TODO: should be handled by a callback from the abicanvas
- self._zoom_spin.set_value(zoom)
-
- def _zoom_in_cb(self, button):
- if self._zoom_percentage == 0:
- self._zoom_percentage = self._abiword_canvas.get_zoom_percentage()
- if self._zoom_percentage <= 375:
- self.set_zoom_percentage(self._zoom_percentage + 25)
-
- def _zoom_out_cb(self, button):
- if self._zoom_percentage == 0:
- self._zoom_percentage = self._abiword_canvas.get_zoom_percentage()
- if self._zoom_percentage >= 50:
- self.set_zoom_percentage(self._zoom_percentage - 25)
-
- def _zoom_spin_cb(self, button):
- self._zoom_percentage = self._zoom_spin.get_value_as_int()
- self._abiword_canvas.set_zoom_percentage(self._zoom_percentage)
-
- def _page_spin_cb(self, button):
- print "page spin"
- self._page_num = self._page_spin.get_value_as_int()
-# TODO
-
- def _page_count_cb(self, canvas, count):
- print "page count:",count
- current_page = canvas.get_current_page_num()
- self._page_spin_adj.set_all(current_page, 1, count, 1, 1, 0)
-
- def _current_page_cb(self, canvas, num):
- print "current page:",num
- self._page_spin.handler_block(self._page_spin_id)
- try:
- self._page_spin.set_value(num)
- finally:
- self._page_spin.handler_unblock(self._page_spin_id)
+ def _num_players_changed_cb(self, num_players_combo):
+ logging.debug('num_players=' + self._num_players[self._num_players_combo.get_active()] )
+
+ def _back_cb(self, button):
+ pass