Builder3/Window.js
[app.Builder.js] / Sample / Editor.js
index 82a6037..6bad275 100644 (file)
@@ -8,21 +8,19 @@ GtkSource = imports.gi.GtkSource;
 WebKit = imports.gi.WebKit;
 Vte = imports.gi.Vte;
 GtkClutter = imports.gi.GtkClutter;
+Gdl = imports.gi.Gdl;
 console = imports.console;
 XObject = imports.XObject.XObject;
 Editor=new XObject({
     xtype: Gtk.Window,
     listeners : {
-        destroy_event : function (self, event) {
-            if (!this.get('/Editor.buffer').checkSyntax) {
+        delete_event : function (self, event) {
+            if (!this.get('/Editor.RightEditor').save()) {
                 // no hiding with errors.
                 return true;
             }
             this.el.hide();
-            return true;
-        },
-        delete_event : function (self, event) {
-              this.el.hide();
+            this.get('/Editor').activePath = false;
             return true;
         },
         configure_event : function (self, object) {
@@ -41,6 +39,15 @@ Editor=new XObject({
     id : "EditorWindow",
     title : "Application Builder - Editor",
     width_request : 500,
+    save : function (self, event) {
+        if (!this.get('/Editor.RightEditor').save()) {
+            // no hiding with errors.
+            return true;
+        }
+        this.get('/Editor').activePath = false;
+        this.el.hide();
+        return true;
+    },
     init : function() {
         XObject.prototype.init.call(this);
        // this.show_all();
@@ -72,6 +79,11 @@ Editor=new XObject({
                     id : "RightEditor",
                     pack : "add",
                     save : function() {
+                        // make sure we have an active path..
+                         if (!this.get('/Editor').activePath) {
+                            return true;
+                         }
+                         
                          var str = this.get('/Editor.buffer').toString();
                          if (!this.get('/Editor.buffer').checkSyntax()) {
                              this.get('/StandardErrorDialog').show("Fix errors in code and save..");