Builder/Provider/GtkUsage.txt
[app.Builder.js] / Sample / Editor.bjs
index 6429ecb..28a6784 100644 (file)
@@ -1,5 +1,5 @@
 {
-    "id": "file-gtk-13",
+    "id": "file-gtk-10",
     "name": "Editor",
     "parent": "",
     "title": false,
@@ -7,8 +7,7 @@
     "items": [
         {
             "listeners": {
-                "destroy_event": "function (self, event) {\n    if (!this.get('/Editor.buffer').checkSyntax) {\n        // no hiding with errors.\n        return true;\n    }\n    this.el.hide();\n    return true;\n}",
-                "delete_event": "function (self, event) {\n      this.el.hide();\n    return true;\n}",
+                "delete_event": "function (self, event) {\n    if (!this.get('/Editor.RightEditor').save()) {\n        // no hiding with errors.\n        return true;\n    }\n    this.el.hide();\n    this.get('/Editor').activePath = false;\n    return true;\n}",
                 "configure_event": "function (self, object) {\n    this.pos = this.el.get_position();\n\n\n    return false;\n}",
                 "show": "function (self) {\n    if (this.pos) {\n        this.el.set_uposition(this.pos.root_x,this.pos.root_y);\n    }\n}"
             },
@@ -17,6 +16,7 @@
             "title": "Application Builder - Editor",
             "width_request": 500,
             "xtype": "Window",
+            "|save": "function (self, event) {\n    if (!this.get('/Editor.RightEditor').save()) {\n        // no hiding with errors.\n        return true;\n    }\n    this.get('/Editor').activePath = false;\n    this.el.hide();\n    return true;\n}",
             "|init": "function() {\n    XObject.prototype.init.call(this);\n   // this.show_all();\n}\n",
             "|xns": "Gtk",
             "items": [
@@ -45,7 +45,7 @@
                             "id": "RightEditor",
                             "pack": "add",
                             "xtype": "ScrolledWindow",
-                            "|save": "function() {\n     var str = this.get('/Editor.buffer').toString();\n\n     this.get('/LeftPanel.model').changed(  str , false);\n     this.get('/Editor').dirty = false;\n     this.get('/Editor.save_button').el.sensitive = false;\n}\n",
+                            "|save": "function() {\n    // make sure we have an active path..\n     if (!this.get('/Editor').activePath) {\n        return true;\n     }\n     \n     var str = this.get('/Editor.buffer').toString();\n     if (!this.get('/Editor.buffer').checkSyntax()) {\n         this.get('/StandardErrorDialog').show(\"Fix errors in code and save..\"); \n         return false;\n     }\n     \n     this.get('/LeftPanel.model').changed(  str , false);\n     this.get('/Editor').dirty = false;\n     this.get('/Editor.save_button').el.sensitive = false;\n     return true;\n}\n",
                             "|xns": "Gtk",
                             "items": [
                                 {
@@ -71,7 +71,7 @@
                                             "id": "buffer",
                                             "pack": "set_buffer",
                                             "xtype": "Buffer",
-                                            "|checkSyntax": "function() {\n    var str = this.toString();\n    var res = '';\n    try {\n      //  print('var res = ' + str);\n        Seed.check_syntax('var res = ' + str);\n        \n        this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({\n            red: 0xFFFF, green: 0xFFFF , blue : 0xFFFF\n           }));\n        \n        return true;\n    } catch (e) {\n        \n        this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({\n            red: 0xFFFF, green: 0xCCCC , blue : 0xCCCC\n           }));\n        print(\"SYNTAX ERROR IN EDITOR\");   \n        print(e);\n        // print(str);\n        //console.dump(e);\n        return false;\n    }\n}\n",
+                                            "|checkSyntax": "function() {\n    var str = this.toString();\n    var res = '';\n    try {\n      //  print('var res = ' + str);\n        Seed.check_syntax('var res = ' + str);\n        \n       \n    } catch (e) {\n        \n        this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({\n            red: 0xFFFF, green: 0xCCCC , blue : 0xCCCC\n           }));\n        print(\"SYNTAX ERROR IN EDITOR\");   \n        print(e);\n        // print(str);\n        //console.dump(e);\n        return false;\n    }\n     this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({\n        red: 0xFFFF, green: 0xFFFF , blue : 0xFFFF\n       }));\n    \n    return true;\n}\n",
                                             "|toString": "function() {\n    \n    var s = new Gtk.TextIter();\n    var e = new Gtk.TextIter();\n    this.el.get_start_iter(s);\n    this.el.get_end_iter(e);\n    var ret = this.el.get_text(s,e,true);\n    //print(\"TO STRING? \" + ret);\n    return ret;\n}\n",
                                             "|xns": "GtkSource"
                                         }
@@ -84,5 +84,6 @@
             ]
         }
     ],
-    "permname": ""
+    "permname": "",
+    "modOrder": ""
 }
\ No newline at end of file