# HG changeset patch # User wycc # Date 1237020157 -28800 # Node ID 6adb283881326aa298bbe75be05966eb55d360c1 # Parent a373b4743e63af465f43ba9105cb19ab1de203e4 Add capability to add new scene and source into the project Add Save button to save the project. diff -r a373b4743e63 -r 6adb28388132 inkscape/firefox/content/inkscape.js --- a/inkscape/firefox/content/inkscape.js Sat Mar 14 15:35:51 2009 +0800 +++ b/inkscape/firefox/content/inkscape.js Sat Mar 14 16:42:37 2009 +0800 @@ -375,17 +375,22 @@ function onButtonClick(obj) { - if (inkscape.isInProgress != 0) return; var id = obj.getAttribute('id'); if (id == 'Jump') { + if (inkscape.isInProgress != 0) return; if (currentScene != 0) inkscape.gotoScene(currentScene); } else if (id == 'InsertKey') { + if (inkscape.isInProgress != 0) return; inkscape.insertKey(currentScene); } else if (id == 'ExtendScene') { + if (inkscape.isInProgress != 0) return; inkscape.extendScene(currentScene); } else if (id == 'DeleteScene') { + if (inkscape.isInProgress != 0) return; inkscape.deleteScene(currentScene); + } else if (id == 'Save') { + project_save(); } else { alert(id+' has not been implemented yet'); } @@ -520,6 +525,7 @@ } var tree = $.tree_create(); + project_tree = tree; tree.init($("#filelist"), { data: { type: "json", @@ -596,10 +602,18 @@ function onTree_addSceneFile(node,treeobj) { - //treeobj.create(false,treeobj.selected,"xxx",null,"newscene"); openFileDialog(project_addScene,treeobj); } +function project_addSource(file,treeobj) +{ + treeobj.create(false,treeobj.selected,file); +} + +function onTree_addSourceFile(node,treeobj) +{ + openFileDialog(project_addSource,treeobj); +} function onTree_openFile(node,treeobj) { @@ -637,15 +651,59 @@ } return output; } +function system_write(fname,xml) { + try { + netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); + } catch (e) { + alert("Permission to read file was denied."); + } + var file = Components.classes["@mozilla.org/file/local;1"] + .createInstance(Components.interfaces.nsILocalFile); + try { + file.initWithPath( fname ); + var fostream = Components.classes["@mozilla.org/network/file-output-stream;1"] + .createInstance( Components.interfaces.nsIFileOutputStream ); + fostream.init( file,0x02|0x8|0x20, 0666,0); + fostream.write( xml,xml.length ); + fostream.close(); + } catch(e) { + alert(fname+" does not exist"); + } +} function project_loadFile() { prjname = $('#mbsvg').attr('value'); + project_name = prjname; var prj = system_read(prjname); project_parse(prj); filedialog.dialog('close'); } + +function project_save() +{ + var i; + + var xml = "\n"; + var scenes = $('#scenes'); + var sources = $('#sources'); + var list = project_tree.getJSON(scenes); + var len = list.children.length; + + for(i=0;i\n"; + } + list = project_tree.getJSON(sources); + len = list.children.length; + for(i=0;i\n"; + } + xml = xml + "\n"; + system_write(project_name,xml); + +} + var last_select = null; $('#filedialog').dialog({ width:500}); diff -r a373b4743e63 -r 6adb28388132 inkscape/firefox/content/madbuilder.html --- a/inkscape/firefox/content/madbuilder.html Sat Mar 14 15:35:51 2009 +0800 +++ b/inkscape/firefox/content/madbuilder.html Sat Mar 14 16:42:37 2009 +0800 @@ -62,6 +62,7 @@ make Button Edit Animation Test + Save