diff inkscape/firefox/MBServer.py @ 381:29145d2affdb

Add function to change the name of the symbol
author wycc
date Sun, 05 Apr 2009 12:28:36 +0800
parents 7d244a85dd68
children
line wrap: on
line diff
--- a/inkscape/firefox/MBServer.py	Sat Apr 04 06:16:27 2009 +0800
+++ b/inkscape/firefox/MBServer.py	Sun Apr 05 12:28:36 2009 +0800
@@ -242,6 +242,20 @@
 		if len(layer.scene) > 0 and nth > layer.scene[len(layer.scene)-1].end:
 			layer.scene[len(layer.scene)-1].end = nth
 
+	def findNodeById(self,root,id):
+		for n in root:
+			if n.attrib.get('id') == id:
+				return n
+			nn = self.findNodeById(n,id)
+			if nn is not None:
+				return nn
+		return None
+	def changeSymbol(self,id,newname):
+		node = self.findNodeById(self.document.getroot(),id)
+		if node is not None:
+			node.set('mbname',newname);
+
+
 	def setCurrentScene(self,nth):
 		self.current = nth
 		for layer in self.layer:
@@ -481,6 +495,12 @@
 			return etree.tostring(newdoc)
 		except:
 			return traceback.format_exc()
+	def soap_CHANGESYMBOL(self,id,newname):
+		try:
+			self.target.changeSymbol(id,newname)
+			return "OK"
+		except:
+			return traceback.format_exc()
 import os
 os.chdir('/usr/local/share/inkscape/extensions')