comparison pyink/MBScene.py @ 1099:5ba2cab1d505

Add name editor to edit the inkscape:label withgout using the object property editor. This is more Flash-like operation.
author wycc
date Sun, 05 Dec 2010 08:16:54 +0800
parents 52d8bf5d12b4
children 214e1f628d63
comparison
equal deleted inserted replaced
1098:cb4a2ffdf9e8 1099:5ba2cab1d505
90 self.layers = [] 90 self.layers = []
91 self.layers.append(Layer(None)) 91 self.layers.append(Layer(None))
92 self.scenemap = None 92 self.scenemap = None
93 self.top = None 93 self.top = None
94 self.last_update = None 94 self.last_update = None
95 pass 95 self.startPolling()
96 self.last_select = None
97 pass
98
99 def startPolling(self):
100 objs = self.desktop.selection.list()
101 if len(objs) != 1:
102 glib.timeout_add(500,self.startPolling)
103 try:
104 self.nameEditor.set_text('')
105 except:
106 traceback.print_exc()
107 pass
108 return
109 o = objs[0]
110 if o == self.last_select:
111 glib.timeout_add(500,self.startPolling)
112 return
113 self.last_select = o
114 try:
115 self.nameEditor.set_text(o.repr.attribute("inkscape:label"))
116 except:
117 self.nameEditor.set_text('')
118 pass
119 glib.timeout_add(500,self.startPolling)
96 120
97 def confirm(self,msg): 121 def confirm(self,msg):
98 vbox = gtk.VBox() 122 vbox = gtk.VBox()
99 vbox.pack_start(gtk.Label(msg)) 123 vbox.pack_start(gtk.Label(msg))
100 self.button = gtk.Button('OK') 124 self.button = gtk.Button('OK')
609 633
610 def doExtendScene(self,w): 634 def doExtendScene(self,w):
611 self.extendScene() 635 self.extendScene()
612 #self.grid.show_all() 636 #self.grid.show_all()
613 pass 637 pass
638 def changeObjectLabel(self,w):
639 o = self.desktop.selection.list()[0]
640 o.repr.setAttribute("inkscape:label", self.nameEditor.get_text(), True)
641 def addNameEditor(self,hbox):
642 self.nameEditor = gtk.Entry(max=40)
643 hbox.pack_start(self.nameEditor,expand=False,fill=False)
644 self.editDone = gtk.Button('Set')
645 hbox.pack_start(self.editDone,expand=False,fill=False)
646 self.editDone.connect('clicked', self.changeObjectLabel)
614 647
615 def addButtons(self,hbox): 648 def addButtons(self,hbox):
616 #btn = gtk.Button('Edit') 649 #btn = gtk.Button('Edit')
617 #btn.connect('clicked', self.doEditScene) 650 #btn.connect('clicked', self.doEditScene)
618 #hbox.pack_start(btn,expand=False,fill=False) 651 #hbox.pack_start(btn,expand=False,fill=False)
626 btn.connect('clicked', self.doExtendScene) 659 btn.connect('clicked', self.doExtendScene)
627 hbox.pack_start(btn,expand=False,fill=False) 660 hbox.pack_start(btn,expand=False,fill=False)
628 btn=gtk.Button('Duplicate Key') 661 btn=gtk.Button('Duplicate Key')
629 btn.connect('clicked', self.doDuplicateKeyScene) 662 btn.connect('clicked', self.doDuplicateKeyScene)
630 hbox.pack_start(btn,expand=False,fill=False) 663 hbox.pack_start(btn,expand=False,fill=False)
664 self.addNameEditor(hbox)
631 pass 665 pass
632 666
633 def onQuit(self, event): 667 def onQuit(self, event):
634 self.OK = False 668 self.OK = False
635 gtk.main_quit() 669 gtk.main_quit()