src/Builder4/Editor.bjs
authorAlan Knowles <alan@roojs.com>
Thu, 21 May 2015 07:12:16 +0000 (15:12 +0800)
committerAlan Knowles <alan@roojs.com>
Thu, 21 May 2015 07:12:16 +0000 (15:12 +0800)
src/Builder4/Editor.vala

src/Builder4/Editor.bjs
src/Builder4/Editor.vala

index b1d2879..78200e7 100644 (file)
@@ -15,7 +15,7 @@
    "# int pos_root_y" : "",
    "# string ptype" : "\"\"",
    "# string fname" : "\"\"",
-   "| void showPlainFile" : "() {\n\n}\n",
+   "| void showPlainFile" : "(string fname)\n{\n    this.ptype = \"\";\n    this.key  = \"\";\n    this.node = null;\n    this.file = null;\n    this.fname = fname;\n    string str;\n    try {\n        GLib.FileUtils.get_contents(fname, out str);\n    } catch (Error e) {\n        str = \"\"; // a tad dangerios... - perhaps we should block editing...\n    }\n    \n    this.view.load(str);\n    this.key_edit.el.text = \"\";    \n\n}",
    "# string key" : "\"\"",
    "* pack" : "add",
    "xtype" : "Box",
index 0c86156..9aeef65 100644 (file)
@@ -104,7 +104,22 @@ public class Editor : Object
         return true;
     
     }
-    public void showPlainFile () {
+    public void showPlainFile (string fname)
+    {
+        this.ptype = "";
+        this.key  = "";
+        this.node = null;
+        this.file = null;
+        this.fname = fname;
+        string str;
+        try {
+            GLib.FileUtils.get_contents(fname, out str);
+        } catch (Error e) {
+            str = ""; // a tad dangerios... - perhaps we should block editing...
+        }
+        
+        this.view.load(str);
+        this.key_edit.el.text = "";    
     
     }
     public   void show (JsRender.JsRender file, JsRender.Node node, string ptype, string key)