diff inkscape/firefox/content/inkscape.js @ 367:e21e9447f545

Add wizard. We still need to add the template files.
author wycc
date Sun, 15 Mar 2009 17:17:06 +0800
parents 6adb28388132
children 3d21115297ba
line wrap: on
line diff
--- a/inkscape/firefox/content/inkscape.js	Sat Mar 14 18:36:57 2009 +0800
+++ b/inkscape/firefox/content/inkscape.js	Sun Mar 15 17:17:06 2009 +0800
@@ -624,6 +624,30 @@
 	}
 }
 
+function system_open_read(fname) {
+	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 );
+		if ( file.exists() == false ) {
+			alert("File does not exist");
+		}
+		var is = Components.classes["@mozilla.org/network/file-input-stream;1"]
+						.createInstance( Components.interfaces.nsIFileInputStream );
+		is.init( file,0x01, 00004, null);
+		var sis = Components.classes["@mozilla.org/scriptableinputstream;1"]
+						.createInstance( Components.interfaces.nsIScriptableInputStream );
+		sis.init( is );
+	} catch(e) {
+		alert(fname+" does not exist");
+	}
+	return sis;
+}
 
 function system_read(fname) {
 	try {
@@ -651,6 +675,24 @@
 	}
 	return output;
 }
+function system_open_write(fname) {
+	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);
+	} catch(e) {
+		alert(fname+" does not exist");
+	}
+	return fostream;
+}
 function system_write(fname,xml) {
 	try {
 		netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
@@ -704,14 +746,23 @@
 
 }
 
+
+function onLoadProject(path)
+{
+	project_name = path;
+	var prj = system_read(project_name);
+	project_parse(prj);
+}
+
 var last_select = null;
-
+var wizard = new Wizard();
+wizard.cb = onLoadProject;
 $('#filedialog').dialog({ width:500});
 jQuery(document).ready(function() {
 		filedialog = jQuery('#filedialog');
 		filedialog.dialog({width:500,
 				   modal: true,
-			           autopen:false,
+			           autoOpen:false,
 				   title:'Please select a file'});
 		filedialog.show();
 		filedialog.html('Please select the project file<br>');