X-Git-Url: http://git.roojs.org/?a=blobdiff_plain;f=src%2FJsRender%2FJsRender.vala;h=db19fe2c8511e674528026d130b295da8670705f;hb=HEAD;hp=a8421356444ba127735381dc94f7070df6707118;hpb=b6f1f05f269ad9d22ce75f6a60cd1f3cf793011e;p=app.Builder.js diff --git a/src/JsRender/JsRender.vala b/src/JsRender/JsRender.vala index a84213564..db19fe2c8 100644 --- a/src/JsRender/JsRender.vala +++ b/src/JsRender/JsRender.vala @@ -27,6 +27,7 @@ namespace JsRender { public string permname; public string language; + public string content_type; public string modOrder; public string xtype; public uint64 webkit_page_id; // set by webkit view - used to extract extension/etc.. @@ -40,6 +41,8 @@ namespace JsRender { public bool hasParent; + public bool loaded; + public Gee.HashMap transStrings; // map of md5 -> string. @@ -68,8 +71,10 @@ namespace JsRender { this.permname = ""; this.modOrder = ""; this.language = ""; + this.content_type = ""; this.build_module = ""; - print("JsRender.cto() - reset transStrings\n"); + this.loaded = false; + //print("JsRender.cto() - reset transStrings\n"); this.transStrings = new Gee.HashMap (); // should use basename reallly... @@ -80,7 +85,7 @@ namespace JsRender { Regex regex = new Regex ("\\.(bjs|js)$"); this.name = ar.length > 0 ? regex.replace(ar[ar.length-1],ar[ar.length-1].length, 0 , "") : ""; - } catch (Error e) { + } catch (GLib.Error e) { this.name = "???"; } this.fullname = (this.parent.length > 0 ? (this.parent + ".") : "" ) + this.name; @@ -89,7 +94,7 @@ namespace JsRender { } - public void renameTo(string name) + public void renameTo(string name) throws Error { if (this.xtype == "PlainFile") { return; @@ -111,7 +116,7 @@ namespace JsRender { // not sure why xt is needed... -> project contains xtype.. - public static JsRender factory(string xt, Project.Project project, string path) + public static JsRender factory(string xt, Project.Project project, string path) throws Error { switch (xt) { @@ -123,7 +128,7 @@ namespace JsRender { return new PlainFile(project, path); } throw new Error.INVALID_FORMAT("JsRender Factory called with xtype=%s", xt); - return null; + //return null; } public string toJsonString() @@ -164,8 +169,12 @@ namespace JsRender { var m5 = GLib.Checksum.compute_for_string(GLib.ChecksumType.MD5,this.path); var dir = GLib.Environment.get_home_dir() + "/.Builder/icons"; - if (!FileUtils.test(dir, FileTest.IS_DIR)) { - File.new_for_path(dir).make_directory(); + try { + if (!FileUtils.test(dir, FileTest.IS_DIR)) { + File.new_for_path(dir).make_directory(); + } + } catch (GLib.Error e) { + // eakk.. what to do here... } var fname = dir + "/" + m5 + ".png"; @@ -187,9 +196,12 @@ namespace JsRender { public void saveBJS() { - if (this.xtype == "PlainFile") { - return; - } + if (!this.loaded) { + return; + } + if (this.xtype == "PlainFile") { + return; + } var generator = new Json.Generator (); generator.indent = 1; generator.pretty = true; @@ -292,7 +304,7 @@ namespace JsRender { public Palete.Palete palete() { // error on plainfile? - return Palete.factory(this.xtype); + return Palete.factory(this.project.xtype); } @@ -323,32 +335,7 @@ namespace JsRender { } - /** - * - * munge JSON tree into Javascript code. - * - * NOTE - needs a deep copy of original tree, before starting.. - * - so that it does not modify current.. - * - * FIXME: + or / prefixes to properties hide it from renderer. - * FIXME: '*props' - not supported by this.. ?? - upto rendering code.. - * FIXME: needs to understand what properties might be translatable (eg. double quotes) - * - * @arg {object} obj the object or array to munge.. - * @arg {boolean} isListener - is the array being sent a listener.. - * @arg {string} pad - the padding to indent with. - */ - public string mungeToString(string pad) - { - if (this.tree == null) { - return ""; - } - var x = new NodeToJs(this.tree, this.doubleStringProps, pad); - return x.munge(); - - - } public Node? lineToNode(int line) { if (this.tree == null) { @@ -363,6 +350,7 @@ namespace JsRender { public abstract void save(); public abstract void saveHTML(string html); public abstract string toSource() ; + public abstract string toSourceCode() ; // used by commandline tester.. public abstract void setSource(string str); public abstract string toSourcePreview() ; public abstract void removeFiles() ;