# HG changeset patch
# User wycc
# Date 1237249864 -28800
# Node ID 3d21115297ba0bbd15658141a94af39433f1f38e
# Parent fce37d9c296f07b3cf7aef9658088b28cc438cee
Add textmenu template
diff -r fce37d9c296f -r 3d21115297ba inkscape/firefox/content/inkscape.js
--- a/inkscape/firefox/content/inkscape.js Mon Mar 16 09:00:51 2009 +0800
+++ b/inkscape/firefox/content/inkscape.js Tue Mar 17 08:31:04 2009 +0800
@@ -472,14 +472,20 @@
function project_loadScene(node)
{
var file = node.textContent;
- inkscape = new Inkscape("file://"+file);
+ if (file.substr(0,1) == '/')
+ inkscape = new Inkscape("file://"+file);
+ else
+ inkscape = new Inkscape("file://"+project_dir+'/'+file);
}
function project_loadEditor(node)
{
var file = node.textContent;
- editor = new TextEditor("file://"+file);
+ if (file.substr(0,1) == '/')
+ editor = new TextEditor("file://"+file);
+ else
+ editor = new TextEditor("file://"+project_dir+'/'+file);
}
function project_parse(xml)
@@ -689,7 +695,7 @@
.createInstance( Components.interfaces.nsIFileOutputStream );
fostream.init( file,0x02|0x8|0x20, 0666,0);
} catch(e) {
- alert(fname+" does not exist");
+ alert('can not create '+fname);
}
return fostream;
}
@@ -713,10 +719,39 @@
}
}
+function system_mkdir(path)
+{
+ 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(path);
+ if( !file.exists() || !file.isDirectory() ) { // if it doesn't exist, create
+ file.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0777);
+ }
+ } catch(e) {
+ alert('Failed to create directopry '+path+e);
+ }
+}
+
+function getPathDirectory(path)
+{
+ var s = path.lastIndexOf('/');
+ if (s == -1)
+ return '';
+ else
+ return path.substr(0,s);
+}
+
function project_loadFile()
{
prjname = $('#mbsvg').attr('value');
project_name = prjname;
+ project_dir = getPathDirectory(prjname);
var prj = system_read(prjname);
project_parse(prj);
filedialog.dialog('close');
@@ -750,6 +785,7 @@
function onLoadProject(path)
{
project_name = path;
+ project_dir = getPathDirectory(project_name);
var prj = system_read(project_name);
project_parse(prj);
}
diff -r fce37d9c296f -r 3d21115297ba inkscape/firefox/content/madbuilder.html
--- a/inkscape/firefox/content/madbuilder.html Mon Mar 16 09:00:51 2009 +0800
+++ b/inkscape/firefox/content/madbuilder.html Tue Mar 17 08:31:04 2009 +0800
@@ -77,7 +77,7 @@
Please select the type of applications.