X-Git-Url: http://git.roojs.org/?a=blobdiff_plain;f=src%2FJsRender%2FPlainFile.vala;h=69872879e17045d7ebda6b9aedebf6db5d9aed7b;hb=HEAD;hp=ebe01e65f134cdd7edc0c0efe3b5bf2e19004ec5;hpb=a54006054add5065aeeadff33ab4e93a91b50401;p=app.Builder.js diff --git a/src/JsRender/PlainFile.vala b/src/JsRender/PlainFile.vala index ebe01e65f..69872879e 100644 --- a/src/JsRender/PlainFile.vala +++ b/src/JsRender/PlainFile.vala @@ -12,7 +12,7 @@ namespace JsRender { - int gid = 1; + int plid = 1; public class PlainFile : JsRender @@ -24,14 +24,33 @@ namespace JsRender { base( project, path); this.xtype = "PlainFile"; - + // if the file does not exist... + if (GLib.FileUtils.test(path, GLib.FileTest.EXISTS)) { + var f = File.new_for_path (path) ; + var info = f.query_info ("standard::*", 0); + var ct = info.get_content_type(); + this.content_type = ct; + } else { + this.content_type = "text/plain"; // hopefully.. +// var ar = path.split("."); + // var ext = ar[ar.length -1]; // hopefully not fail... + + // switch(ext) { + // case "vala"; + this.loaded = true; + + + } + + this.language = ""; + // fixme... - this.language = "vala"; + - this.contents = ""; + this.contents = ""; // super?!?! - this.id = "file-plain-%d".printf(gid++); + this.id = "file-plain-%d".printf(plid++); //console.dump(this); // various loader methods.. @@ -56,36 +75,56 @@ namespace JsRender { }, */ - public override void removeFiles() { - if (FileUtils.test(this.pat, FileTest.EXISTS)) { - GLib.FileUtils.remove(this.pat); - } - + public override void removeFiles() { + if (FileUtils.test(this.path, FileTest.EXISTS)) { + GLib.FileUtils.remove(this.path); } - - public override void loadItems() throws GLib.Error // : function(cb, sync) == original was async. - { - return; - } - + + } + + public override void loadItems() throws GLib.Error // : function(cb, sync) == original was async. + { + if (this.loaded) { + return; + } + GLib.FileUtils.get_contents(this.path, out this.contents); + this.loaded = true; + } + public override string toSourcePreview() { - return ""; + return ""; + } + public override void setSource(string str) { + this.contents = str; } - public override string toSource() { - return ""; + return this.contents; + + + + } + public override string toSourceCode() + { + return this.contents; } - public override void save() { + if (!this.loaded) { + print("Ignoring Save - as file was never loaded?\n"); + return; + } + try { + this.writeFile(this.path, this.contents); + } catch (GLib.Error e) { + // error ??? + } - this.saveVala(); } // ignore these calls. public override void saveHTML ( string html ) {} @@ -98,56 +137,11 @@ namespace JsRender { * why is this not save...??? * */ - - void saveJS() - { - - var fn = GLib.Path.get_dirname(this.path) + "/" + this.name + ".js"; - print("WRITE :%s\n " , fn); - this.writeFile(fn, this.toSource()); - - } - - void saveVala() - { - if (this.tree == null) { - return; - } - var fn = GLib.Path.get_dirname(this.path) + "/" + this.name + ".vala"; - print("WRITE :%s\n " , fn); - this.writeFile(fn, NodeToVala.mungeFile(this)); - - - } - /* - valaCompileCmd : function() - { - - var fn = '/tmp/' + this.name + '.vala'; - print("WRITE : " + fn); - File.write(fn, this.toVala(true)); - - - - return ["valac", - "--pkg", "gio-2.0", - "--pkg" , "posix" , - "--pkg" , "gtk+-3.0", - "--pkg", "libnotify", - "--pkg", "gtksourceview-3.0", - "--pkg", "libwnck-3.0", - fn , "-o", "/tmp/" + this.name]; - - - - - }, - */ - + string getHelpUrl(string cls) { - return "http://devel.akbkhome.com/seed/" + cls + ".html"; + return ""; } public override void findTransStrings(Node? node ) {