src/Builder4/Editor.bjs
authorAlan Knowles <alan@roojs.com>
Thu, 21 May 2015 06:55:28 +0000 (14:55 +0800)
committerAlan Knowles <alan@roojs.com>
Thu, 21 May 2015 06:55:28 +0000 (14:55 +0800)
src/Builder4/Editor.vala

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

index f459b8b..9d0976c 100644 (file)
@@ -15,7 +15,7 @@
    "# int pos_root_y" : "",
    "# string ptype" : "\"\"",
    "bool expand" : true,
-   "| void showPlainFile" : "(string fname)\n{\n    this.ptype = \"\";\n    this.key  = \"\";\n    this.node = null;\n    this.file = null;\n    string str;\n    GLib.FileUtils.get_contents(fname, out str);\n    \n    this.view.load(str);\n    this.key_edit.el.text = \"\";    \n\n}",
+   "| void showPlainFile" : "(string fname)\n{\n    this.ptype = \"\";\n    this.key  = \"\";\n    this.node = null;\n    this.file = null;\n    string str;\n    try {\n        GLib.FileUtils.get_contents(fname, out str);\n    } catch (Error e) {\n        str = \"\";\n    }\n    \n    this.view.load(str);\n    this.key_edit.el.text = \"\";    \n\n}",
    "# string key" : "\"\"",
    "* pack" : "add",
    "xtype" : "Box",
index 6fd6cc8..4ba1fd1 100644 (file)
@@ -110,7 +110,11 @@ public class Editor : Object
         this.node = null;
         this.file = null;
         string str;
-        GLib.FileUtils.get_contents(fname, out str);
+        try {
+            GLib.FileUtils.get_contents(fname, out str);
+        } catch (Error e) {
+            str = "";
+        }
         
         this.view.load(str);
         this.key_edit.el.text = "";