# HG changeset patch # User wycc # Date 1238905775 -28800 # Node ID 5b6230df7630e6e647ff7bd7a68725a6cf2be44e # Parent 83283a45ffbcf74661dab74919b9a98b1e5d00f6# Parent a3231496c6de612e0959bd3bbed5537f7c19b8dd mgerge diff -r a3231496c6de -r 5b6230df7630 inkscape/firefox/INSTALL --- a/inkscape/firefox/INSTALL Sat Apr 04 11:55:11 2009 +0800 +++ b/inkscape/firefox/INSTALL Sun Apr 05 12:29:35 2009 +0800 @@ -7,6 +7,8 @@ application/x-mbsvg:mbsvg: MadButterfly SVG swallow(Inkscape) : /usr/local/bin/helper_mb.py "$file" +application/x-h:h: MadButterfly SVG h program + swallow(gedit) : gedit "$file" * Install inkscape for madbutterfly * tar -C / -xzvf inkscape-mb.tgz diff -r a3231496c6de -r 5b6230df7630 inkscape/firefox/MBServer.py --- a/inkscape/firefox/MBServer.py Sat Apr 04 11:55:11 2009 +0800 +++ b/inkscape/firefox/MBServer.py Sun Apr 05 12:29:35 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') diff -r a3231496c6de -r 5b6230df7630 inkscape/firefox/content/inkscape.js --- a/inkscape/firefox/content/inkscape.js Sat Apr 04 11:55:11 2009 +0800 +++ b/inkscape/firefox/content/inkscape.js Sun Apr 05 12:29:35 2009 +0800 @@ -228,6 +228,34 @@ this.isInProgress++; } +Inkscape.prototype.changeSymbolName_cb = function(callback) +{ + var soapBody = new SOAPObject("CHANGESYMBOL"); + var v1 = new SOAPObject("v1"); + v1.attr('type','string'); + v1.val(this.v1); + soapBody.appendChild(v1); + var v2 = new SOAPObject("v2"); + v2.val(this.v2); + soapBody.appendChild(v2); + var sr = new SOAPRequest("CHANGESYMBOL", soapBody); + SOAPClient.Proxy = "http://localhost:19192/"; + SOAPClient.SendRequest(sr, function (resp,arg) {arg.refreshDocument(resp);},this); + this.inProgress--; +} + +Inkscape.prototype.changeSymbolName = function(id,newname,callback) +{ + var soapBody = new SOAPObject("START"); + this.callback = callback + var sr = new SOAPRequest("START", soapBody); + SOAPClient.Proxy = "http://localhost:19192/"; + this.v1 = id; + this.v2 = newname; + SOAPClient.SendRequest(sr,function(resp,arg) {arg.changeSymbolName_cb(resp);},this); + this.isInProgress++; +} + /* * This module is used to define a symbol for the MadButterfly. This function will search for symbol which is defined in the current select object. We will list all SVG elements * in the left side, multiple variables can be defined at one time. When any element is selected, the defined symbol will be listed in the right side. @@ -237,11 +265,23 @@ Inkscape.prototype.MakeSymbol=function() { function callback(mbsvg) { - this.loadSymbolScreen(mbsvg); + inkscape.loadSymbolScreen(mbsvg); } inkscape.fetchDocument(callback); } + +Inkscape.prototype.onChangeSymbolName=function() +{ + inkscape.changeSymbolName(inkscape.current_symbol, $('#newsymbolname').val()); + symboldialog.dialog('close') +} + +Inkscape.prototype.refreshSymbolPanel=function(node) +{ + inkscape.current_symbol = node.textContent; +} + Inkscape.prototype.loadSymbolScreen=function (mbsvg) { // Swap the left side to be the SVG element tree. var i,l; @@ -261,10 +301,12 @@ json : jsonobj }, callback : { - ondblclk : function(NODE,TREE_OBJ) { this.refreshSymbolPanel(TREE_OBJ); TREE_OBJ.toggle_branch.call(TREE_OBJ, NODE); TREE_OBJ.select_branch.call(TREE_OBJ, NODE);} + ondblclk : function(NODE,TREE_OBJ) { inkscape.refreshSymbolPanel(NODE); TREE_OBJ.toggle_branch.call(TREE_OBJ, NODE); TREE_OBJ.select_branch.call(TREE_OBJ, NODE);} } }); + var s = $('#changename'); + s.click(this.onChangeSymbolName); // Swap the right side to be the symbol editor screen. symboldialog.show(); } @@ -276,8 +318,8 @@ autoOpen:false, title:'Please select a file'}); symboldialog.hide(); - symboldialog.append("