changeset 384:7cbb364fd273

Show the old name in the input line Select the first object automatically.
author wycc
date Sun, 05 Apr 2009 17:00:28 +0800
parents 5b6230df7630
children 28e822aa84e5 f3e6ac47752c
files inkscape/firefox/content/inkscape.js
diffstat 1 files changed, 21 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/inkscape/firefox/content/inkscape.js	Sun Apr 05 12:29:35 2009 +0800
+++ b/inkscape/firefox/content/inkscape.js	Sun Apr 05 17:00:28 2009 +0800
@@ -279,7 +279,11 @@
 
 Inkscape.prototype.refreshSymbolPanel=function(node)
 {
+	var reg = new RegExp('(.*)\\((.*)\\)');
+	var m = reg.exec(node.textContent);
+	var val = m[2];
 	inkscape.current_symbol = node.textContent;
+	$('#newsymbolname').val(val);
 }
 
 Inkscape.prototype.loadSymbolScreen=function (mbsvg) {
@@ -287,11 +291,18 @@
 	var i,l;
 
 	symboldialog.dialog('open');
+	this.mbsvg = mbsvg;
 	l = mbsvg.selected_objects.length;
 	var jsonobj = []
 	for(i=0;i<l;i++) {
 		// Add symbol into the tree
-		var obj = { attributes: {id: 'sym'+i}, data : mbsvg.selected_objects[i]};
+		var name = mbsvg.findSymbolName(mbsvg.selected_objects[i]);
+		var title=mbsvg.selected_objects[i]+"("+name+")";
+		var obj = { attributes: {id: 'sym'+i}, data : title};
+		if (i == 0) {
+			this.current_symbol = mbsvg.selected_objects[i];
+			$('#newsymbolname').val(name);
+		}
 		jsonobj.push(obj);
 	}
   	this.symboltree = $.tree_create();
@@ -301,7 +312,7 @@
 		json : jsonobj
 	    },
 	    callback : {
-	        ondblclk : function(NODE,TREE_OBJ) { inkscape.refreshSymbolPanel(NODE); TREE_OBJ.toggle_branch.call(TREE_OBJ, NODE); TREE_OBJ.select_branch.call(TREE_OBJ, NODE);}
+	        ondblclk : function(NODE,TREE_OBJ) { inkscape.refreshSymbolPanel(NODE);}
 	    }
 
   	});
@@ -319,7 +330,7 @@
 				   title:'Please select a file'});
 		symboldialog.hide();
 		symboldialog.append("<div id='symbollist'/>");
-		symboldialog.append("<div id='symbol'><input type='text' id='newsymbolname'> <input type='submit' id='changename'></div> ");
+		symboldialog.append("<div id='symbol'><input type='text' id='newsymbolname'> <input type='submit' value='change' id='changename'></div> ");
 		});
 
 function MBSVG(file)
@@ -446,6 +457,13 @@
 }
 
 
+MBSVG.prototype.findSymbolName=function(id)
+{
+	var obj = this.doc.getElementById(id);
+	var name = obj.getAttribute('mbname');
+	return name;
+
+}
 
 /**
  *    UI for madbuilder.html to build the scene editor