# HG changeset patch # User wycc # Date 1291060656 -28800 # Node ID 292fbb86d8f36ff073a13bb77fb3b6f5ee1f9b1e # Parent eb371902086699406b8f3a8fb06c7ef02419a9e4# Parent 09c1ef31884f7027f8d9aec66cb12a4244d219b7 Merge from the HEAD diff -r 09c1ef31884f -r 292fbb86d8f3 nodejs/examples/mce/epg.js --- a/nodejs/examples/mce/epg.js Sun Nov 28 13:19:57 2010 +0800 +++ b/nodejs/examples/mce/epg.js Tue Nov 30 03:57:36 2010 +0800 @@ -146,13 +146,42 @@ EPG.prototype.onLoad = function(res) { cats = res['ProgramCat']; this.pend = cats.length; + this.maincat = cats; for (i in cats) { c = cats[i]; httpGetFile(c['ProgramPIC'],'cat'+i+'.png',this); } } +EPG.prototype.getList=function(item,func) { + var epgsrv = http.createClient(8080, '211.23.50.144'); + var cmd = '{"Protocol":"EPG-CSP","Command":"SearchRequest","ProgramSub":"'+item.Category+'"}'; + var headers={ + 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', + 'Host':'211.23.50.144:8080', + 'User-Agent':'MadButterfly', + 'Content-Type':'application/x-www-form-urlencoded' + }; + headers['Content-Length'] = cmd.length; + var request = epgsrv.request('POST', '/IPTV_EPG/EPGService.do?timestamp='+new Date().getTime(),headers); + var self = this; + sys.puts("aaaa"); + var js = ''; + request.write(cmd); + request.end(); + request.on('response', function(res) { + sys.puts("connected"); + res.on('data',function (data) { + js = js + data; + }); + res.on('end', function () { + res = JSON.parse(js); + sys.puts("parsed"); + func(); + }); + }); +} EPG.prototype.onInitDone=function() { if (this.loadCallback) this.loadCallback(); diff -r 09c1ef31884f -r 292fbb86d8f3 nodejs/examples/mce/main.svg --- a/nodejs/examples/mce/main.svg Sun Nov 28 13:19:57 2010 +0800 +++ b/nodejs/examples/mce/main.svg Tue Nov 30 03:57:36 2010 +0800 @@ -56,10 +56,10 @@ inkscape:pageopacity="0.0" inkscape:pageshadow="2" inkscape:zoom="0.35" - inkscape:cx="574.12471" + inkscape:cx="206.98185" inkscape:cy="483.73232" inkscape:document-units="px" - inkscape:current-layer="Layer 1s1841" + inkscape:current-layer="Layer 1s235" showgrid="false" inkscape:window-width="1680" inkscape:window-height="976" @@ -109,7 +109,7 @@ + style="display:none"> diff -r 09c1ef31884f -r 292fbb86d8f3 nodejs/examples/mce/mainmenu.js --- a/nodejs/examples/mce/mainmenu.js Sun Nov 28 13:19:57 2010 +0800 +++ b/nodejs/examples/mce/mainmenu.js Tue Nov 30 03:57:36 2010 +0800 @@ -16,6 +16,7 @@ var self = this; var epg = new EPG.EPG(); epg.registerInitDone(function() { self.init();}); + app.epg = epg; //self.init(); } MainMenu.prototype.init=function() @@ -127,12 +128,15 @@ MainMenu.prototype.key_enter=function() { + var self = this; var target = this.items[this.item]; - var sx = 500 - target.center.x; - var sy = 220 - target.center.y; - var an = new animate.shift(this.app,target,sx,sy); - var self = this; - animate.run([an],0,2.5,function() {self.changePage();}); + var an = new animate.scale(this.app, target, 1/1.1, 1/1.5); + animate.run([an], 0, 0.3,function() { + var sx = 259 - target.center.x; + var sy = 355 - target.center.y; + var an1 = new animate.shift(self.app,target,sx,sy); + animate.run([an1],0,1,function() {self.changePage(self.item);}); + }); for(i=0;i this.item) { @@ -149,8 +153,11 @@ } } -MainMenu.prototype.changePage=function() { +MainMenu.prototype.onNextPage=function() { this.app.changeScene(2); } +MainMenu.prototype.changePage=function(item) { + this.epg.getList(item,self.onNextPage()); +} exports.MainMenu=MainMenu; diff -r 09c1ef31884f -r 292fbb86d8f3 pyink/MBScene.py --- a/pyink/MBScene.py Sun Nov 28 13:19:57 2010 +0800 +++ b/pyink/MBScene.py Tue Nov 30 03:57:36 2010 +0800 @@ -3,11 +3,13 @@ # vim: sw=4:ts=8:sts=4 import pygtk import gtk +import glib from copy import deepcopy from lxml import etree import random import traceback import time +import pybInkscape # Please refer to # http://www.assembla.com/wiki/show/MadButterfly/Inkscape_extention @@ -55,7 +57,32 @@ _scenes = '{http://madbutterfly.sourceforge.net/DTD/madbutterfly.dtd}scenes' _scene = '{http://madbutterfly.sourceforge.net/DTD/madbutterfly.dtd}scene' - +class LayerAttributeWatcher(pybInkscape.PYNodeObserver): + def __init__(self,ui): + self.ui = ui + def notifyChildAdded(self,node,child,prev): + pass + def notifyChildRemoved(self,node,child,prev): + pass + def notifyChildOrderChanged(self,node,child,prev): + pass + def notifyContentChanged(self,node,old_content,new_content): + pass + def notifyAttributeChanged(self,node, name, old_value, new_value): + self.ui.updateUI() +class LayerAddRemoveWatcher(pybInkscape.PYNodeObserver): + def __init__(self,ui): + self.ui = ui + def notifyChildAdded(self,node,child,prev): + self.ui.updateUI() + def notifyChildRemoved(self,node,child,prev): + self.ui.updateUI() + def notifyChildOrderChanged(self,node,child,prev): + self.ui.updateUI() + def notifyContentChanged(self,node,old_content,new_content): + self.ui.updateUI() + def notifyAttributeChanged(self,node, name, old_value, new_value): + self.ui.updateUI() class MBScene(): def __init__(self,desktop,win): self.desktop = desktop @@ -63,6 +90,8 @@ self.layers = [] self.layers.append(Layer(None)) self.scenemap = None + self.top = None + self.last_update = None pass def confirm(self,msg): @@ -156,13 +185,17 @@ self.scenemap = None doc = self.desktop.doc().root() + #obs = pybInkscape.PYNodeObserver() + obs = LayerAddRemoveWatcher(self) + doc.repr.addObserver(obs) for node in doc.childList(): if node.repr.name() == 'svg:metadata': self.parseMetadata(node) pass elif node.repr.name() == 'svg:g': oldscene = None - #print layer.attrib.get("id") + obs = LayerAttributeWatcher(self) + node.repr.addObserver(obs) lyobj = Layer(node) self.layers.append(lyobj) lyobj.current_scene = [] @@ -465,7 +498,10 @@ def _update_framelines(self): for frameline in self._framelines: layer = frameline.layer - frameline.label.set_text(frameline.node.label()) + if frameline.node.label()==None: + frameline.label.set_text('???') + else: + frameline.label.set_text(frameline.node.label()) for scene in layer.scenes: frameline.add_keyframe(scene.start-1,scene.node.repr) if scene.start != scene.end: @@ -530,19 +566,24 @@ gtk.main_quit() pass - + def updateUI(self): + if self.last_update!= None: + glib.source_remove(self.last_update) + self.last_update = glib.timeout_add(300,self.show) def show(self): self.OK = True self.parseScene() self._create_framelines() self._update_framelines() - vbox = gtk.VBox(False,0) - self.desktop.getToplevel().child.child.pack_end(vbox,expand=False) - self.window = vbox + if self.top == None: + self.top = gtk.VBox(False,0) + self.desktop.getToplevel().child.child.pack_end(self.top,expand=False) + else: + self.top.remove(self.startWindow) vbox = gtk.VBox(False,0) - self.window.pack_start(vbox,expand=False) + self.startWindow = vbox + self.top.pack_start(vbox,expand=False) vbox.pack_start(self.scrollwin,expand=False) - self.vbox = vbox hbox=gtk.HBox(False,0) self.addButtons(hbox) vbox.pack_start(hbox,expand=False) @@ -551,6 +592,7 @@ # self.window.connect("destroy", gtk.main_quit) # self.window.set_position(gtk.WIN_POS_MOUSE) - self.window.show_all() - pass + self.top.show_all() + self.last_update = None + return False pass