Possibly fixed issue 99 and issue 108 by setting up an external handler function. Moved Opera references to seperate file and reprocessed thinker.li's patch to also use a use separate file

git-svn-id: http://svg-edit.googlecode.com/svn/trunk@468 eee81c28-f429-11dd-99c0-75d572ba1ddd
This commit is contained in:
Alexis Deveria
2009-08-25 16:35:57 +00:00
parent c6df21abfc
commit baf9f75982
9 changed files with 150 additions and 74 deletions

View File

@@ -0,0 +1,8 @@
#!/bin/sh
DST="content/editor"
if [ -e "${DST}" ]; then
rm -rf "${DST}"
fi
cp -R ../editor content/
SVNS=`find content/editor -name '.svn'`
rm -rf ${SVNS}

View File

@@ -1,2 +1,2 @@
content SVG-edit content/
overlay chrome://browser/content/browser.xul chrome://SVG-edit/content/SVG-edit-overlay.xul
content SVG-edit content/
overlay chrome://browser/content/browser.xul chrome://SVG-edit/content/SVG-edit-overlay.xul

View File

@@ -1,7 +1,6 @@
function start_svg_edit() {
var url = "chrome://SVG-edit/content/editor/svg-editor.html";
var browser = document.getElementById("content");
window.openDialog(url, "SVG Editor",
"width=1024,height=700,menubar=no,toolbar=no");
"width=1024,height=700,menubar=no,toolbar=no");
}

View File

@@ -0,0 +1,55 @@
// Note: This JavaScript file must be included as the last script on the main HTML editor page to override the open/close handlers
$(function() {
if(!window.Components) return;
function moz_file_picker(readflag) {
var fp = window.Components.classes["@mozilla.org/filepicker;1"].
createInstance(Components.interfaces.nsIFilePicker);
if(readflag)
fp.init(window, "Pick a SVG file", fp.modeOpen);
else
fp.init(window, "Pick a SVG file", fp.modeSave);
fp.defaultExtension = "*.svg";
fp.show();
return fp.file;
}
svgCanvas.setCustomHandlers({
'open':function() {
try {
netscape.security.PrivilegeManager.
enablePrivilege("UniversalXPConnect");
var file = moz_file_picker(true);
if(!file)
return(null);
var inputStream = Components.classes["@mozilla.org/network/file-input-stream;1"].createInstance(Components.interfaces.nsIFileInputStream);
inputStream.init(file, 0x01, 00004, null);
var sInputStream = Components.classes["@mozilla.org/scriptableinputstream;1"].createInstance(Components.interfaces.nsIScriptableInputStream);
sInputStream.init(inputStream);
canvas.setSvgString(sInputStream.
read(sInputStream.available()));
} catch(e) {
console.log("Exception while attempting to load" + e);
}
},
'save':function(svg) {
try {
var file = moz_file_picker(false);
if(!file)
return;
if (!file.exists())
file.create(0, 0664);
var out = Components.classes["@mozilla.org/network/file-output-stream;1"].createInstance(Components.interfaces.nsIFileOutputStream);
out.init(file, 0x20 | 0x02, 00004,null);
out.write(str, str.length);
out.flush();
out.close();
} catch(e) {
alert(e);
}
}
});
});

View File

@@ -0,0 +1,4 @@
#!/bin/sh
./build.sh
zip -r ../svg-edit.xpi *