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

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

index 37dbd16..5970a32 100644 (file)
@@ -16,7 +16,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.data = data;\n    this.project = project;\n    this.name.el.set_text(\"\");\n    this.el.show_all();\n}\n",
+            "|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",
             "|xns": "Gtk",
             "items": [
                 {
index 8e5a5a6..cca0206 100644 (file)
@@ -55,10 +55,45 @@ DialogSaveModule=new XObject({
      
          
         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();
+        
+        
+        
+        
+        
     },
     items : [
         {
index 397865d..ecee0e3 100644 (file)
@@ -102,10 +102,45 @@ public class Xcls_DialogSaveModule : Object
          
              
             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();
+            
+            
+            
+            
+            
         }
 
     // skip |xns - no return type