diff options
author | Tony Anderson <tony_anderson@usa.net> | 2009-09-02 06:03:19 (GMT) |
---|---|---|
committer | Tony Anderson <tony_anderson@usa.net> | 2009-09-02 06:03:19 (GMT) |
commit | 3f047e2955c9913bed091da5878b9a99e8e8117b (patch) | |
tree | 6b21ea90cfff2c8e35bffad6ca6b93b21540a414 | |
parent | 2ed5da66f4357e85a06f6bab2b88718ac71885fe (diff) |
version 1
-rw-r--r-- | activity/activity-smile.svg | 60 | ||||
-rwxr-xr-x | activity/activity.info | 4 | ||||
-rwxr-xr-x | ambulantglue.py | 2 | ||||
-rwxr-xr-x | icons/gtk-media-pause.svg | 9 | ||||
-rwxr-xr-x | icons/gtk-media-stop.svg | 6 | ||||
-rwxr-xr-x | smile.py | 138 |
6 files changed, 158 insertions, 61 deletions
diff --git a/activity/activity-smile.svg b/activity/activity-smile.svg index 0049daa..51d0cd1 100644 --- a/activity/activity-smile.svg +++ b/activity/activity-smile.svg @@ -1,33 +1,29 @@ -<?xml version="1.0" standalone="no"?> -<!DOCTYPE svg> -<svg version="1.1" baseProfile="full" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMidYMid meet" zoomAndPan="magnify" - id="Test File" - viewBox="-21 -21 42 42" - width="800" - height="800"> +<?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 "#666666"> + <!ENTITY fill_color "#ffffff"> +]><svg enable-background="new 0 0 55 55" height="55px" id="Layer_1" version="1.1" viewBox="0 0 55 55" width="55px" x="0px" xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" y="0px"><g display="block" id="activity-log"> -<defs> -<radialGradient id="shine" - cx=".2" cy=".2" r=".5" fx=".2" fy=".2"> - <stop offset="0" stop-color="white" stop-opacity=".7"/> - <stop offset="1" stop-color="white" stop-opacity="0"/> -</radialGradient> -<radialGradient id="grad" - cx=".5" cy=".5" r=".5" > - <stop offset="0" stop-color="yellow"/> - <stop offset=".75" stop-color="yellow"/> - <stop offset=".95" stop-color="#ee0"/> - <stop offset="1" stop-color="#e8e800"/> -</radialGradient> - -</defs> - -<circle r="20" stroke="black" stroke-width=".15" fill="url(#grad)"/> -<circle r="20" fill="url(#shine)"/> -<g id="right"> - <ellipse rx="2.5" ry="4" cx="-6" cy="-7" fill="black"/> - <path fill="none" stroke="black" stroke-width=".5" stroke-linecap="round" d="M 10.6,2.7 a 4,4,0 0,0 4,3"/> -</g> -<use xlink:href="#right" transform="scale(-1,1)"/> -<path fill="none" stroke="black" stroke-width=".75" d="M -12,5 A 13.5,13.5,0 0,0 12,5 A 13,13,0 0,1 -12,5"/> -</svg> + <g display="inline"> + <circle cx = "27.5" cy="27.5" r="20" stroke="&stroke_color;" stroke-width="3.5" fill="none"/> + <ellipse rx="2.5" ry="4" cx="21.5" cy="20.5" fill="&fill_color;" stroke="&stroke_color;"/> + <ellipse rx="2.5" ry="4" cx="34.5" cy="20.5" fill="&fill_color;" stroke="&stroke_color;" /> + <g id="g2400" + transform="translate(-0.7793522,0.111336)"> + <path + d="M 18.041397,30.748483 C 17.622292,32.638415 16.131067,33.937849 14.452127,33.876128" + id="path8" + style="fill:&fill_color;stroke:&stroke_color;stroke-width:3.5;stroke-linecap:round" + /> + <path + d="M 39.779075,30.431706 C 40.218029,32.502521 41.779879,33.926322 43.538335,33.858694" + id="path12" + style="fill:&fill_color;stroke:&stroke_color;stroke-width:3.5;stroke-linecap:round" + /> + <path + d="M 16.840193,32.781486 C 24.632708,40.614294 32.984702,40.614294 40.777217,32.781486 C 33.140565,40.387633 24.965356,40.387633 17.328703,32.781486" + id="path14" + style="fill:black;stroke:&stroke_color;stroke-width:3.5" + /> + </g> + </g> +</g></svg> diff --git a/activity/activity.info b/activity/activity.info index aae8509..d152492 100755 --- a/activity/activity.info +++ b/activity/activity.info @@ -4,6 +4,6 @@ service_name = org.laptop.SmileActivity class = smile.SmileActivity exec = sugar-activity smile.SmileActivity icon = activity-smile -activity_version = 2 +activity_version = 1 show_launcher = yes -mime_types = application/x-smile; image/png; image/jpeg; image/svg+xml; image/gif; image/tiff/; image/bmp +mime_types = application/x-smile; application/zip;image/png; image/jpeg; image/svg+xml; image/gif; image/tiff; image/bmp; audio/mp4; application/ogg; audio/mpeg; audio/x-wav; audio/x-ms-wma; video/mpeg; video/quicktime; video/x-ms-wmv; video/x-msvideo; video/mp4; video/ogg; video/x-flv; text/plain diff --git a/ambulantglue.py b/ambulantglue.py index 476f4e3..9fb6547 100755 --- a/ambulantglue.py +++ b/ambulantglue.py @@ -28,7 +28,7 @@ class Glue(ambulant.gui_player, ambulant.factories): # print 'parse the document' self.document = ambulant.create_from_file(self, filename) - print 'doc' + print 'doc', filename player = ambulant.create_smil2_player(self.document, self, None) print 'initialize player', type(player) player.initialize() diff --git a/icons/gtk-media-pause.svg b/icons/gtk-media-pause.svg new file mode 100755 index 0000000..aa4a585 --- /dev/null +++ b/icons/gtk-media-pause.svg @@ -0,0 +1,9 @@ +<?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 "#010101"> + <!ENTITY fill_color "#FFFFFF"> +]><svg enable-background="new 0 0 55 55" height="55px" version="1.1" viewBox="0 0 55 55" width="55px" x="0px" xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" y="0px"><g display="block" id="media-playback-pause"> + <g display="inline"> + <path d="M27.499,0C12.311,0,0,12.313,0,27.5C0,42.688,12.311,55,27.499,55C42.686,55,55,42.688,55,27.5 C55,12.313,42.686,0,27.499,0z M27.497,52.646c-13.826,0-25.033-11.209-25.035-25.033C2.463,13.787,13.67,2.577,27.497,2.574 c13.826,0.003,25.035,11.213,25.039,25.038C52.531,41.437,41.322,52.646,27.497,52.646z" fill="&fill_color;"/> + <path d="M27.496,5C15.068,5,4.997,15.076,4.997,27.5c0,12.427,10.071,22.5,22.499,22.5 c12.428,0,22.5-10.073,22.5-22.5C49.996,15.076,39.924,5,27.496,5z M25.938,35.443h-5.801V19.741h5.801V35.443z M34.855,35.443 h-5.803V19.741h5.803V35.443z" fill="&fill_color;"/> + </g> +</g></svg>
\ No newline at end of file diff --git a/icons/gtk-media-stop.svg b/icons/gtk-media-stop.svg new file mode 100755 index 0000000..4779fd5 --- /dev/null +++ b/icons/gtk-media-stop.svg @@ -0,0 +1,6 @@ +<?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 "#010101"> + <!ENTITY fill_color "#FFFFFF"> +]><svg enable-background="new 0 0 55 55" height="55px" version="1.1" viewBox="0 0 55 55" width="55px" x="0px" xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" y="0px"><g display="block" id="media-playback-stop"> + <path d="M27.498,5C15.07,5,5,15.075,5,27.499C5,39.924,15.07,50,27.498,50S50,39.924,50,27.499 C50,15.075,39.926,5,27.498,5z M35.349,35.44h-15.7V19.739h15.7V35.44z" display="inline" fill="&fill_color;"/> +</g></svg>
\ No newline at end of file @@ -35,6 +35,7 @@ class SmileActivity(activity.Activity): activity.Activity.__init__(self, handle) self.set_title("Smile") self.connect("destroy", self.set_exit) + self.readflag = False self.exit = False #setup chooser screen box = gtk.VBox(homogeneous=False) @@ -62,31 +63,77 @@ class SmileActivity(activity.Activity): lbl.show() box.pack_start(lbl, False, False, 0) self.scrn = gtk.DrawingArea() + self.scrn.show() box.pack_start(self.scrn, True, True, 0) self.playerscreen = box self.playerscreen.show_all() - self.set_canvas(self.playerscreen) + self.current_screen = self.playerscreen + self.screenbox = gtk.VBox() + self.screenbox.pack_start(self.current_screen, True, True, 0) + self.screenbox.show_all() + print 'set_canvas' + self.doc = 'no doc' + self.set_canvas(self.screenbox) + print 'canvas_set', self.doc def flush_events(self): while gtk.events_pending(): - gtk.main_iteration() + gtk.main_iteration(False) - def set_exit(self): - self.exit = True + def set_exit(self, widget): + #self.exit = True + print 'set_exit', widget def start(self): + return while self.exit == False: self.flush_events() + def start_smil(self, pth): + print 'start smil' + self.set_screen(self.playerscreen) + print 'playerscreen set' + self.player = ambulantglue.Glue(pth , self.scrn) + self.update_buttons(None) + print 'self.player', type(self.player) + + def set_screen(self, screen): + if not self.current_screen == screen: + self.screenbox.remove(self.current_screen) + self.current_screen = screen + self.current_screen.show_all() + self.screenbox.pack_start(self.current_screen, True, True, 0) + + def update_buttons(self, b): + if self.player: + self.playbutton.set_sensitive(self.player.is_play_enabled()) + self.pausebutton.set_sensitive(self.player.is_pause_enabled()) + self.stopbutton.set_sensitive(self.player.is_stop_enabled()) + else: + self.playbutton.set_sensitive(False) + self.pausebutton.set_sensitive(False) + self.stopbutton.set_sensitive(False) + print 'update_buttons', self.playbutton.is_sensitive(), self.pausebutton.is_sensitive(), self.stopbutton.is_sensitive() + def play_cb(self, widget): - self.player.play() - self.destroy() + #self.start_smil(BUNDLEPATH / self.doc) + #print 'smil started in play_cb', self.doc + print 'play_cb' + if self.player: + self.player.play() + self.update_buttons(None) def pause_cb(self, widget): - self.player.pause() + print 'pause_cb' + if self.player: + self.player.pause() + self.update_buttons(None) def stop_cb(self, widget): - self.player.stop() + print 'stop_cb' + if self.player: + self.player.stop() + self.update_buttons(None) def activate_cb(self, widget): #ignore @@ -96,19 +143,26 @@ class SmileActivity(activity.Activity): treeview = self.chooser.get_treeView() treeview.set_model(self.chooser.set_store(source, pth)) treeview.show() - self.set_canvas(self.chooserscreen) - self.chooserscreen.show_all() + self.set_screen(self.chooserscreen) print 'choosebundle done' def read_file(self, file_path): - print 'read_file:', file_path + print 'read_file:', file_path, self.readflag + if self.readflag: + print 'read_file called twice' + else: + self.readflag = True filepath = path(file_path) + pos = file_path.find('(') + pos1 = file_path[pos:].find(')') + filepath = path(file_path[:pos] + file_path[pos+pos1+1:]) + print 'filepath', path(file_path).name, filepath.name #set up bundle folder d = BUNDLEPATH if not d.exists: d.mkdir() else: - for f in d.files('*.py'): + for f in d.files(): f.remove() #move smil file and content to BUNDLEPATH if filepath.ext == '.png': @@ -199,7 +253,7 @@ class SmileActivity(activity.Activity): src = filepath dst = BUNDLEPATH / 'audio.wma' path.copy(src, dst) - elif filepath.ext == '.mpg': + elif filepath.ext == '.mpg' or filepath.ext == '.mpeg': self.doc = 'videompg.smil' src = SMILPATH / self.doc dst = BUNDLEPATH @@ -231,7 +285,7 @@ class SmileActivity(activity.Activity): src = filepath dst = BUNDLEPATH / 'video.avi' path.copy(src, dst) - elif filepath.ext == '.ogg': + elif filepath.ext == '.ogv': self.doc = 'videoogg.smil' src = SMILPATH / self.doc dst = BUNDLEPATH @@ -247,6 +301,30 @@ class SmileActivity(activity.Activity): src = filepath dst = BUNDLEPATH / 'video.mp4' path.copy(src, dst) + elif filepath.ext == '.flv': + self.doc = 'videoflv.smil' + src = SMILPATH / self.doc + dst = BUNDLEPATH + path.copy(src, dst) + src = filepath + dst = BUNDLEPATH / 'video.flv' + path.copy(src, dst) + elif filepath.ext == ".txt": + self.doc = 'text.smil' + src = SMILPATH / 'textpln.smil' + f = open(src, 'r') + skeleton = f.read() + f.close() + f = open(filepath, 'r') + txt = f.read() + f.close() + pos1 = skeleton.find('*****') + pos2 = skeleton[pos1+5:].find('*****') + tsmil = skeleton[:pos1] + txt + skeleton[pos1+pos2+9:] + dst = BUNDLEPATH / 'text.smil' + f = open(dst, 'w') + f.write(tsmil) + f.close() elif filepath.ext == '.smxo': z = zipfile.ZipFile(file_path, "r") for i in z.infolist(): @@ -271,15 +349,12 @@ class SmileActivity(activity.Activity): print 'unknown extension', filepath.ext, filepath #play smil document self.entry.set_text(self.doc) + print 'ready to play', self.doc + self.start() self.start_smil(BUNDLEPATH / self.doc) + print 'flush events started, calling play_cb' self.play_cb(self.doc) - def start_smil(self, pth): - self.set_canvas(self.playerscreen) - self.playerscreen.show() - self.player = ambulantglue.Glue(pth , self.scrn) - self.start() - def on_activated(self, widget, row, col): print 'smxo on_activated' model = widget.get_model() @@ -289,10 +364,12 @@ class SmileActivity(activity.Activity): timestamp = model[row][3] object = datastore.get(model[row][0]) object.destroy() - fn = object.file_path - print 'object filename', path(fn).exists(), fn + fn = path(object.file_path) + print 'object filename', fn.exists(), fn #open slideshow, set Navigation toolbar current - self.read_file(path(fn)) + print 'on_activated calling read_file', fn.name + self.read_file(fn) + print 'on_activated file read' class SelectToolBar(gtk.Toolbar): @@ -301,7 +378,6 @@ class SelectToolBar(gtk.Toolbar): self.chooser = activity.chooser entry = activity.entry choosebundle = activity.choosebundle - set_exit = activity.set_exit #get mount points ds_mounts = datastore.mounts() @@ -343,6 +419,10 @@ class SelectToolBar(gtk.Toolbar): self.stopbutton.show() self.insert(self.stopbutton, -1) + activity.stopbutton = self.stopbutton + activity.pausebutton = self.pausebutton + activity.playbutton = self.playbutton + self.toolitem = gtk.ToolItem() self.toolitem.set_expand(True) self.toolitem.show() @@ -397,6 +477,7 @@ class Smxoview(gtk.VBox): #get objects from the local datastore media_list = [] media_list.append('application/x-smile') + media_list.append('application/zip') media_list.append('image/png') media_list.append('image/jpeg') media_list.append('image/svg+xml') @@ -404,7 +485,10 @@ class Smxoview(gtk.VBox): media_list.append('image/gif') media_list.append('image/tiff') media_list.append('audio/mp4') + media_list.append('video/x-flv') media_list.append('application/ogg') + media_list.append('audio/ogg') + media_list.append('video/ogg') media_list.append('audio/mpeg') media_list.append('audio/x-wav') media_list.append('audio/x-ms-wma') @@ -413,13 +497,15 @@ class Smxoview(gtk.VBox): media_list.append('video/x-ms-wmv') media_list.append('video/x-msvideo') media_list.append('video/mp4') + media_list.append('text/plain') ds_objects, num_objects = datastore.find({'mountpoints':[mountpoint], 'mime_type': media_list}) for f in ds_objects: object = f.object_id title = f.metadata['title'] mime_type = f.metadata['mime_type'] - date = f.metadata['mtime'].replace('T',' ') - store.append([object, title, mime_type, date]) + date = f.metadata['mtime'].replace('T',' ') + if not mime_type == 'application/zip' or path(f).ext == '.smxo': + store.append([object, title, mime_type, date]) f.destroy() print 'return smxo store', len(store) return store |