Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTony Anderson <tony_anderson@usa.net>2009-08-14 15:12:23 (GMT)
committer Tony Anderson <tony_anderson@usa.net>2009-08-14 15:12:23 (GMT)
commita0b743e044fd6e535d7eeb0f6019d52c7323dd1c (patch)
tree28c7549f3d04c8aebd20f26d0f1b5b9c2c5cbcec
parenta9c66189f458d883bb940f11d744d00d0aa89683 (diff)
more development
-rwxr-xr-xactivity/activity-smile.svg84
-rwxr-xr-xactivity/activity.info2
-rwxr-xr-xicons/ooops.pngbin0 -> 177089 bytes
-rw-r--r--[-rwxr-xr-x]smile.py200
4 files changed, 202 insertions, 84 deletions
diff --git a/activity/activity-smile.svg b/activity/activity-smile.svg
new file mode 100755
index 0000000..494ebfb
--- /dev/null
+++ b/activity/activity-smile.svg
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://web.resource.org/cc/"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="50"
+ height="50"
+ id="svg2"
+ sodipodi:version="0.32"
+ inkscape:version="0.45.1"
+ sodipodi:docname="activity-gui.svg"
+ sodipodi:docbase="/home/tony/Documents/Activities/GUIActivity.activity/activity"
+ inkscape:output_extension="org.inkscape.output.svg.inkscape">
+ <metadata
+ id="metadata9">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <defs
+ id="defs7" />
+ <sodipodi:namedview
+ inkscape:window-height="627"
+ inkscape:window-width="910"
+ inkscape:pageshadow="2"
+ inkscape:pageopacity="0.0"
+ guidetolerance="10.0"
+ gridtolerance="10.0"
+ objecttolerance="10.0"
+ borderopacity="1.0"
+ bordercolor="#666666"
+ pagecolor="#ffffff"
+ id="base"
+ inkscape:zoom="8.14"
+ inkscape:cx="25"
+ inkscape:cy="25"
+ inkscape:window-x="0"
+ inkscape:window-y="25"
+ inkscape:current-layer="svg2" />
+ <rect
+ x="0.26289925"
+ y="2.3513515"
+ width="48"
+ height="48"
+ style="fill:#ffffff;stroke:#000000;stroke-width:2"
+ id="rect4" />
+ <text
+ xml:space="preserve"
+ style="font-size:8px;font-style:normal;font-weight:normal;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ x="8.7223587"
+ y="12.776413"
+ id="text2161"><tspan
+ sodipodi:role="line"
+ id="tspan2163"
+ x="8.7223587"
+ y="12.776413" /></text>
+ <text
+ xml:space="preserve"
+ style="font-size:14px;font-style:normal;font-weight:normal;text-align:start;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ x="10.687961"
+ y="3.6855037"
+ id="text2165"><tspan
+ sodipodi:role="line"
+ x="10.687961"
+ y="3.6855037"
+ id="tspan2169"></tspan><tspan
+ sodipodi:role="line"
+ x="10.687961"
+ y="21.185504"
+ id="tspan2162">Smi </tspan><tspan
+ sodipodi:role="line"
+ x="10.687961"
+ y="38.685504"
+ id="tspan2327">le </tspan></text>
+</svg>
diff --git a/activity/activity.info b/activity/activity.info
index f9378a0..c199c2f 100755
--- a/activity/activity.info
+++ b/activity/activity.info
@@ -3,7 +3,7 @@ name = Smile
service_name = org.laptop.SmileActivity
class = smile.SmileActivity
exec = sugar-activity smile.SmileActivity
-icon = activity-Smile
+icon = activity-smile
activity_version = 1
show_launcher = yes
mime_types = application/x-smile; application/zip
diff --git a/icons/ooops.png b/icons/ooops.png
new file mode 100755
index 0000000..c03e392
--- /dev/null
+++ b/icons/ooops.png
Binary files differ
diff --git a/smile.py b/smile.py
index 1c2bad0..8f94a35 100755..100644
--- a/smile.py
+++ b/smile.py
@@ -1,83 +1,102 @@
-# -*- mode:python; tab-width:4; indent-tabs-mode:t; -*-
-
-# smile.py
-#
-# activity implementation of ambulant
-#
-# 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 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+#!/usr/bin/env python
+
+# test ambulantglue
+
+import os, sys, time
+
+import pygtk
+pygtk.require('2.0')
+import gtk
from sugar.activity import activity
from sugar.datastore import datastore
from sugar.graphics.toolbutton import ToolButton
-from sugar.graphics.menuitem import MenuItem
-
import ambulantglue
-
-import sys, os, time, datetime
-import subprocess
-import gtk
+from path import path
import zipfile
import subprocess
-from path import path
-
+BASE = path("/media/0BF7-0F5D") / 'sandbox'
DATASTORE = '/home/olpc/.sugar/default/datastore/store'
DATAPATH = path(activity.get_activity_root()) / "data"
BUNDLEPATH = DATAPATH / 'bundle'
SELECTTOOLBAR = 1
+class SmileyActivity(activity.Activity):
-class SmileActivity(activity.Activity):
-
- def destroy(self, widgets, params):
- self.exit = True
-
- def flush_events(self):
- while gtk.events_pending():
- gtk.main_iteration()
-
- def __init__(self, handle):
+ def __init__ (self, handle):
activity.Activity.__init__(self, handle)
- self.set_title("Smile")
- self.exit = False
+ self.set_title("Smiley")
self.connect("destroy", self.destroy)
- self.connect("delete_event", self.destroy)
- self.chooser = Smxoview(self)
+ self.exit = False
+ #setup chooser screen
+ box = gtk.VBox(homogeneous=False)
+ self.chooser = Smxoview(self.on_activated)
+ self.chooser.show()
+ lbl = gtk.Label("Chooserscreen")
+ lbl.show()
+ box.pack_start(lbl, False, False, 0)
+ box.pack_start(self.chooser, True, True, 0)
+ self.chooserscreen = box
# Create the standard activity toolbox; add our toolbar
- # Create our toolbar
- selectTB = SelectToolBar(self.chooser)
- toolbox = activity.ActivityToolbox(self)
- toolbox.add_toolbar("Select", selectTB)
- self.set_toolbox(toolbox)
- toolbox.show()
- self.toolbox = toolbox
+ self.entry = gtk.Entry()
+ self.entry.connect("activate", self.set_smil)
+ self.entry.show()
+ selectTB = SelectToolBar(self.chooser, self.play_cb, self.entry, self.choosebundle, self.destroy)
+ self.toolbox = activity.ActivityToolbox(self)
+ self.toolbox.add_toolbar("Select", selectTB)
# Open with slideshow toolbar
- toolbox.set_current_toolbar(SELECTTOOLBAR)
- self.child.pack_start(self.chooser, True, True, 0)
- # Set up ambulant drawing area
- self.ambulant_widget = gtk.DrawingArea()
- self.child.pack_start(self.ambulant_widget, True, True, 0)
+ self.toolbox.set_current_toolbar(SELECTTOOLBAR)
+ self.toolbox.show()
+ self.set_toolbox(self.toolbox)
+ # layout the player screen
+ box = gtk.VBox()
+ lbl = gtk.Label("Playerscreen")
+ lbl.show()
+ box.pack_start(lbl, False, False, 0)
+ self.scrn = gtk.DrawingArea()
+ box.pack_start(self.scrn, True, True, 0)
+ self.playerscreen = box
+ self.screenbox = gtk.VBox()
+ self.set_canvas(self.screenbox)
self.show_all()
-
+ self.current_screen = None
#set up bundle folder
subprocess.call("mkdir -p " + BUNDLEPATH, shell=True)
subprocess.call("rm -rf " + BUNDLEPATH + '/*', shell=True)
+ def flush_events(self):
+ while gtk.events_pending():
+ gtk.main_iteration()
+
+ def destroy(self):
+ self.exit = True
+
+ def start(self):
while self.exit == False:
self.flush_events()
+ def play_cb(self, widget):
+ self.player.play()
+ self.destroy()
+
+ def choosebundle(self, widget, source, pth):
+ treeview = self.chooser.get_treeView()
+ treeview.set_model(self.chooser.set_store(source, pth))
+ treeview.show()
+ if not self.current_screen == None:
+ self.screenbox.remove(self.current_screen)
+ self.current_screen = self.chooserscreen
+ self.current_screen.show()
+ self.screenbox.pack_start(self.current_screen, True, True)
+ print 'choosebundle done'
+
+ def set_smil(self, widget):
+ print self.entry.get_text()
+ pth = BASE / self.entry.get_text()
+ print 'pth=', pth
+ self.start_smil(pth)
+
def read_file(self, file_path):
print 'read_file:', file_path
z = zipfile.ZipFile(file_path, "r")
@@ -100,13 +119,32 @@ class SmileActivity(activity.Activity):
f.close()
print 'smil=', tcc
#play smil document
- self.player = ambulantglue.Glue(self.doc, self.ambulant_widget)
- print 'player ready'
- self.playbutton.show()
+ self.start_smil(BUNDLEPATH / self.doc)
+
+ def start_smil(self, pth):
+ if not self.current_screen == None:
+ self.screenbox.remove(self.current_screen)
+ self.current_screen = self.playerscreen
+ self.playerscreen.show()
+ self.screenbox.pack_start(self.current_screen, True, True)
+ self.player = ambulantglue.Glue(pth , self.scrn)
+ self.start()
+
+ def on_activated(self, widget, row, col):
+ print 'smxo on_activated'
+ model = widget.get_model()
+ print 'row', model[row][0], model[row][1], model[row][2]
+ title = model[row][1]
+ timestamp = model[row][2]
+ object = datastore.get(model[row][0])
+ fn = object.file_path
+ print 'object filename', path(fn).exists(), fn
+ #open slideshow, set Navigation toolbar current
+ self.read_file(fn)
class SelectToolBar(gtk.Toolbar):
- def __init__(self, chooser):
+ def __init__(self, chooser, play_cb, entry, choosebundle, destroy):
gtk.Toolbar.__init__(self)
self.chooser = chooser
@@ -122,46 +160,56 @@ class SelectToolBar(gtk.Toolbar):
self.journalbtn = ToolButton('activity-journal')
self.journalbtn.set_tooltip("Choose bundle")
- self.journalbtn.connect('clicked', self.choosebundle, ds_mounts[journal]['id'], DATASTORE)
+ self.journalbtn.connect('clicked', choosebundle, ds_mounts[journal]['id'], DATASTORE)
self.insert(self.journalbtn, -1)
self.journalbtn.show()
-
+
#show pendrive button only if pendrive is mounted
if pendrive > -1:
self.pendrivebutton = ToolButton('media-flash-usb')
self.pendrivebutton.set_tooltip("Choose bundle")
- self.pendrivebutton.connect('clicked', self.choosebundle, ds_mounts[pendrive]['id'], ds_mounts[pendrive]['title'])
+ self.pendrivebutton.connect('clicked', choosebundle, ds_mounts[pendrive]['id'], ds_mounts[pendrive]['title'])
self.insert(self.pendrivebutton, -1)
self.pendrivebutton.show()
self.show()
self.playbutton = ToolButton('gtk-media-play')
- self.playbutton.connect('clicked', self.play)
+ self.playbutton.connect('clicked', play_cb)
self.playbutton.show()
self.insert(self.playbutton, -1)
+ self.toolitem = gtk.ToolItem()
+ self.toolitem.set_expand(True)
+ self.toolitem.show()
+ self.toolitem.add(entry)
+ self.insert(self.toolitem, -1)
+
+ self.quitbutton = ToolButton('ooops')
+ self.quitbutton.connect('clicked', destroy)
+ self.quitbutton.show()
+ self.insert(self.quitbutton, -1)
+
def choosebundle(self, widget, source, pth):
treeview = self.chooser.get_treeView()
treeview.set_model(self.chooser.set_store(source, pth))
print 'choosebundle done'
- def play(self):
- print 'play'
- self.player(play)
-
class Smxoview(gtk.VBox):
- def __init__(self, activity):
+ def __init__(self, on_activated):
print 'smxoview init'
gtk.VBox.__init__(self)
- self.activity = activity
+ lbl = gtk.Label("smxoview")
+ lbl.show()
+ self.pack_start(lbl, False, False, 0)
sw = gtk.ScrolledWindow()
sw.set_shadow_type(gtk.SHADOW_ETCHED_IN)
sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
self.treeView = gtk.TreeView()
- self.treeView.connect("row-activated", self.on_activated)
+ self.treeView.connect("row-activated", on_activated)
self.treeView.set_rules_hint(True)
sw.add(self.treeView)
self.create_columns(self.treeView)
+ sw.show()
self.pack_start(sw, True, True, 0)
def create_columns(self, treeView):
@@ -197,17 +245,3 @@ class Smxoview(gtk.VBox):
f.destroy()
print 'return smxo store', len(store)
return store
-
- def on_activated(self, widget, row, col):
- print 'smxo on_activated'
- model = widget.get_model()
- print 'row', model[row][0], model[row][1], model[row][2]
- title = model[row][1]
- timestamp = model[row][2]
- object = datastore.get(model[row][0])
- fn = object.file_path
- print 'object filename', path(fn).exists(), fn
- #open slideshow, set Navigation toolbar current
- self.activity.read_file(fn)
- for object in ds_objects:
- object.destroy()