Builder4/DialogSaveModule.bjs
authorAlan Knowles <alan@roojs.com>
Tue, 2 Sep 2014 09:39:03 +0000 (17:39 +0800)
committerAlan Knowles <alan@roojs.com>
Tue, 2 Sep 2014 09:39:03 +0000 (17:39 +0800)
Builder4/DialogSaveModule.js
Builder4/DialogSaveModule.vala

Builder4/DialogSaveModule.bjs
Builder4/DialogSaveModule.js
Builder4/DialogSaveModule.vala

index 5970a32..dd14b04 100644 (file)
@@ -7,8 +7,7 @@
     "items": [
         {
             "listeners": {
-                "delete_event": " (self, event) => {\n    this.el.hide();\n    return true;\n    \n}",
-                "response": "(self, response_id) => {\n\n    if (response_id < 1) {\n        this.el.hide();\n         return;\n    }\n    var name = _this.name.el.get_text();\n    if (name.length < 1) {\n        StandardErrorDialog.singleton().show(\n            (Gtk.Window) _this.el,\n            \"You must give the template a name. \"\n        );\n        return;\n    }\n    if (!Regex.match_simple (\"^[A-Za-z\\.]+$\", name) || \n        !Regex.match_simple (\"^[A-Za-z\\.]+$\", name) )\n    {\n        StandardErrorDialog.show(\n            (Gtk.Window) _this.el,\n\n            \"Template Nane must contain only letters dots\"\n        );\n         return;\n    }\n    \n    _this.project.createFile(name, _this.data);\n    // now we save it..\n    this.el.hide();\n    \n}"
+                "delete_event": " (self, event) => {\n    this.el.hide();\n    return true;\n    \n}"
             },
             ".JsRender.Node:data": "",
             ".Project.Project:project": "",
@@ -16,7 +15,7 @@
             "default_width": 400,
             "xtype": "Dialog",
             "|modal": "true",
-            "|void:show": " (Gtk.Window parent, Project.Project project, JsRender.Node data) {\n \n     \n    this.el.set_transient_for(parent);\n    this.el.modal = true;\n    \n    this.data = data;\n    this.project = project;\n    this.name.el.set_text(\"\");\n    this.el.show_all();\n    \n    var response_id = this.el.run();\n    if (response_id < 1) {\n        this.el.hide();\n         return;\n    }\n    var name = _this.name.el.get_text();\n    if (name.length < 1) {\n        StandardErrorDialog.singleton().show(\n            (Gtk.Window) _this.el,\n            \"You must give the template a name. \"\n        );\n        return;\n    }\n    if (!Regex.match_simple (\"^[A-Za-z\\.]+$\", name) || \n        !Regex.match_simple (\"^[A-Za-z\\.]+$\", name) )\n    {\n        StandardErrorDialog.show(\n            (Gtk.Window) _this.el,\n\n            \"Template Nane must contain only letters dots\"\n        );\n         return;\n    }\n    \n    _this.project.createFile(name, _this.data);\n    // now we save it..\n    this.el.hide();\n    \n    \n    \n    \n    \n}\n",
+            "|string:show": " (Gtk.Window parent, Project.Project project, JsRender.Node data) {\n \n     \n    this.el.set_transient_for(parent);\n    this.el.modal = true;\n    \n    this.data = data;\n    this.project = project;\n    this.name.el.set_text(\"\");\n    this.el.show_all();\n    \n    while (true) {\n        var response_id = this.el.run();\n        if (response_id < 1) {\n            this.el.hide();\n             return;\n        }\n        \n        var name = _this.name.el.get_text();\n        if (name.length < 1) {\n            StandardErrorDialog.singleton().show(\n                (Gtk.Window) _this.el,\n                \"You must give the template a name. \"\n            );\n            continue;\n        }\n        if (!Regex.match_simple (\"^[A-Za-z\\.]+$\", name) || \n            !Regex.match_simple (\"^[A-Za-z\\.]+$\", name) )\n        {\n            StandardErrorDialog.show(\n                (Gtk.Window) _this.el,\n\n                \"Template Nane must contain only letters dots\"\n            );\n            continue\n        }\n        break;\n    }\n    _this.project.createFile(name, _this.data);\n    // now we save it..\n    this.el.hide();\n    \n    return name;\n    \n    \n    \n}\n",
             "|xns": "Gtk",
             "items": [
                 {
index cca0206..e7d11fb 100644 (file)
@@ -16,81 +16,54 @@ DialogSaveModule=new XObject({
             this.el.hide();
             return true;
             
-        },
-        response : (self, response_id) => {
+        }
+    },
+    default_height : 200,
+    default_width : 400,
+    modal : true,
+    'string:show' : (Gtk.Window parent, Project.Project project, JsRender.Node data) {
+     
+         
+        this.el.set_transient_for(parent);
+        this.el.modal = true;
+        
+        this.data = data;
+        this.project = project;
+        this.name.el.set_text("");
+        this.el.show_all();
         
+        while (true) {
+            var response_id = this.el.run();
             if (response_id < 1) {
                 this.el.hide();
                  return;
             }
+            
             var name = _this.name.el.get_text();
             if (name.length < 1) {
                 StandardErrorDialog.singleton().show(
                     (Gtk.Window) _this.el,
                     "You must give the template a name. "
                 );
-                return;
+                continue;
             }
             if (!Regex.match_simple ("^[A-Za-z\.]+$", name) || 
                 !Regex.match_simple ("^[A-Za-z\.]+$", name) )
             {
                 StandardErrorDialog.show(
                     (Gtk.Window) _this.el,
-        
+    
                     "Template Nane must contain only letters dots"
                 );
-                 return;
+                continue
             }
-            
-            _this.project.createFile(name, _this.data);
-            // now we save it..
-            this.el.hide();
-            
+            break;
         }
-    },
-    default_height : 200,
-    default_width : 400,
-    modal : true,
-    'void:show' : (Gtk.Window parent, Project.Project project, JsRender.Node data) {
-     
-         
-        this.el.set_transient_for(parent);
-        this.el.modal = true;
-        
-        this.data = data;
-        this.project = project;
-        this.name.el.set_text("");
-        this.el.show_all();
-        
-        var response_id = this.el.run();
-        if (response_id < 1) {
-            this.el.hide();
-             return;
-        }
-        var name = _this.name.el.get_text();
-        if (name.length < 1) {
-            StandardErrorDialog.singleton().show(
-                (Gtk.Window) _this.el,
-                "You must give the template a name. "
-            );
-            return;
-        }
-        if (!Regex.match_simple ("^[A-Za-z\.]+$", name) || 
-            !Regex.match_simple ("^[A-Za-z\.]+$", name) )
-        {
-            StandardErrorDialog.show(
-                (Gtk.Window) _this.el,
-    
-                "Template Nane must contain only letters dots"
-            );
-             return;
-        }
-        
         _this.project.createFile(name, _this.data);
         // now we save it..
         this.el.hide();
         
-        
+        return name;
         
         
         
index ecee0e3..ab89d7b 100644 (file)
@@ -65,40 +65,10 @@ public class Xcls_DialogSaveModule : Object
             return true;
             
         } );
-        this.el.response.connect( (self, response_id) => {
-        
-            if (response_id < 1) {
-                this.el.hide();
-                 return;
-            }
-            var name = _this.name.el.get_text();
-            if (name.length < 1) {
-                StandardErrorDialog.singleton().show(
-                    (Gtk.Window) _this.el,
-                    "You must give the template a name. "
-                );
-                return;
-            }
-            if (!Regex.match_simple ("^[A-Za-z\.]+$", name) || 
-                !Regex.match_simple ("^[A-Za-z\.]+$", name) )
-            {
-                StandardErrorDialog.show(
-                    (Gtk.Window) _this.el,
-        
-                    "Template Nane must contain only letters dots"
-                );
-                 return;
-            }
-            
-            _this.project.createFile(name, _this.data);
-            // now we save it..
-            this.el.hide();
-            
-        } );
     }
 
     // userdefined functions 
-    public void show (Gtk.Window parent, Project.Project project, JsRender.Node data) {
+    public string show (Gtk.Window parent, Project.Project project, JsRender.Node data) {
          
              
             this.el.set_transient_for(parent);
@@ -109,35 +79,38 @@ public class Xcls_DialogSaveModule : Object
             this.name.el.set_text("");
             this.el.show_all();
             
-            var response_id = this.el.run();
-            if (response_id < 1) {
-                this.el.hide();
-                 return;
-            }
-            var name = _this.name.el.get_text();
-            if (name.length < 1) {
-                StandardErrorDialog.singleton().show(
-                    (Gtk.Window) _this.el,
-                    "You must give the template a name. "
-                );
-                return;
-            }
-            if (!Regex.match_simple ("^[A-Za-z\.]+$", name) || 
-                !Regex.match_simple ("^[A-Za-z\.]+$", name) )
-            {
-                StandardErrorDialog.show(
-                    (Gtk.Window) _this.el,
+            while (true) {
+                var response_id = this.el.run();
+                if (response_id < 1) {
+                    this.el.hide();
+                     return;
+                }
+                
+                var name = _this.name.el.get_text();
+                if (name.length < 1) {
+                    StandardErrorDialog.singleton().show(
+                        (Gtk.Window) _this.el,
+                        "You must give the template a name. "
+                    );
+                    continue;
+                }
+                if (!Regex.match_simple ("^[A-Za-z\.]+$", name) || 
+                    !Regex.match_simple ("^[A-Za-z\.]+$", name) )
+                {
+                    StandardErrorDialog.show(
+                        (Gtk.Window) _this.el,
         
-                    "Template Nane must contain only letters dots"
-                );
-                 return;
+                        "Template Nane must contain only letters dots"
+                    );
+                    continue
+                }
+                break;
             }
-            
             _this.project.createFile(name, _this.data);
             // now we save it..
             this.el.hide();
             
-            
+            return name;