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

Builder4/DialogSaveModule.bjs
Builder4/DialogSaveModule.js
Builder4/DialogSaveModule.vala [new file with mode: 0644]

index 968e3d3..f33eb31 100644 (file)
@@ -1,10 +1,59 @@
 {
-    "id": "file-gtk-28",
+    "id": "file-gtk-5",
     "name": "DialogSaveModule",
     "parent": "",
     "title": false,
     "path": "/home/alan/gitlive/app.Builder.js/Builder4/DialogSaveModule.bjs",
-    "items": false,
+    "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.show(\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            \"Template Nane must contain only letters and spaces. \"\n        );\n         return;\n    }\n    _this.palete.saveTemplate(name, _this.data);\n    // now we save it..\n    this.el.hide();\n    \n}"
+            },
+            ".JsRender.Node:data": "",
+            ".Palete.Palete:palete": "",
+            "default_height": 200,
+            "default_width": 400,
+            "xtype": "Dialog",
+            "|modal": "true",
+            "|static void:show": " (Gtk.Window parent, Palete.Palete palete, JsRender.Node data) {\n \n    \n \n     var t =DialogSaveTemplate;\n    if (t == null) {\n       t =   new Xcls_DialogSaveTemplate();\n    }\n    t.el.set_transient_for(parent);\n    t.data = data;\n    t.palete = palete;\n    t.name.el.set_text(\"\");\n    t.el.show_all();\n}\n",
+            "|xns": "Gtk",
+            "items": [
+                {
+                    "xtype": "HBox",
+                    "|pack": " get_content_area().add\n\n",
+                    "|xns": "Gtk",
+                    "items": [
+                        {
+                            "label": "Name",
+                            "pack": "add",
+                            "xtype": "Label",
+                            "|xns": "Gtk",
+                            "listeners": {}
+                        },
+                        {
+                            "id": "name",
+                            "pack": "add",
+                            "xtype": "Entry",
+                            "|xns": "Gtk"
+                        }
+                    ]
+                },
+                {
+                    "label": "Cancel",
+                    "pack": "add_action_widget,0",
+                    "xtype": "Button",
+                    "|xns": "Gtk"
+                },
+                {
+                    "label": "OK",
+                    "pack": "add_action_widget,1",
+                    "xtype": "Button",
+                    "|xns": "Gtk"
+                }
+            ]
+        }
+    ],
     "permname": "",
     "modOrder": ""
 }
\ No newline at end of file
index c227083..2c05ce6 100644 (file)
@@ -1 +1,94 @@
-0
\ No newline at end of file
+Gtk = imports.gi.Gtk;
+Gdk = imports.gi.Gdk;
+Pango = imports.gi.Pango;
+GLib = imports.gi.GLib;
+Gio = imports.gi.Gio;
+GObject = imports.gi.GObject;
+GtkSource = imports.gi.GtkSource;
+WebKit = imports.gi.WebKit;
+Vte = imports.gi.Vte;
+console = imports.console;
+XObject = imports.XObject.XObject;
+DialogSaveModule=new XObject({
+    xtype: Gtk.Dialog,
+    listeners : {
+        delete_event : (self, event) => {
+            this.el.hide();
+            return true;
+            
+        },
+        response : (self, response_id) => {
+        
+            if (response_id < 1) {
+                this.el.hide();
+                 return;
+            }
+            var name = _this.name.el.get_text();
+            if (name.length < 1) {
+                StandardErrorDialog.show(
+                    "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(
+                    "Template Nane must contain only letters and spaces. "
+                );
+                 return;
+            }
+            _this.palete.saveTemplate(name, _this.data);
+            // now we save it..
+            this.el.hide();
+            
+        }
+    },
+    default_height : 200,
+    default_width : 400,
+    modal : true,
+    'static void:show' : (Gtk.Window parent, Palete.Palete palete, JsRender.Node data) {
+     
+        
+     
+         var t =DialogSaveTemplate;
+        if (t == null) {
+           t =   new Xcls_DialogSaveTemplate();
+        }
+        t.el.set_transient_for(parent);
+        t.data = data;
+        t.palete = palete;
+        t.name.el.set_text("");
+        t.el.show_all();
+    },
+    items : [
+        {
+            xtype: Gtk.HBox,
+            pack : get_content_area().add,
+            items : [
+                {
+                    xtype: Gtk.Label,
+                    label : "Name",
+                    pack : "add"
+                },
+                {
+                    xtype: Gtk.Entry,
+                    id : "name",
+                    pack : "add"
+                }
+            ]
+        },
+        {
+            xtype: Gtk.Button,
+            label : "Cancel",
+            pack : "add_action_widget,0"
+        },
+        {
+            xtype: Gtk.Button,
+            label : "OK",
+            pack : "add_action_widget,1"
+        }
+    ]
+});
+DialogSaveModule.init();
+XObject.cache['/DialogSaveModule'] = DialogSaveModule;
diff --git a/Builder4/DialogSaveModule.vala b/Builder4/DialogSaveModule.vala
new file mode 100644 (file)
index 0000000..8c12e64
--- /dev/null
@@ -0,0 +1,239 @@
+/* -- to compile
+valac  --pkg gio-2.0  --pkg posix  --pkg gtk+-3.0 --pkg libnotify --pkg gtksourceview-3.0  --pkg  libwnck-3.0 \
+    /tmp/DialogSaveModule.vala  -o /tmp/DialogSaveModule
+*/
+
+
+/* -- to test class
+static int main (string[] args) {
+    Gtk.init (ref args);
+    new Xcls_DialogSaveModule();
+    DialogSaveModule.show_all();
+     Gtk.main ();
+    return 0;
+}
+*/
+
+
+public static Xcls_DialogSaveModule  DialogSaveModule;
+
+public class Xcls_DialogSaveModule : Object 
+{
+    public Gtk.Dialog el;
+    private Xcls_DialogSaveModule  _this;
+
+    public static Xcls_DialogSaveModule singleton()
+    {
+        if (DialogSaveModule == null) {
+            DialogSaveModule= new Xcls_DialogSaveModule();
+        }
+        return DialogSaveModule;
+    }
+    public Xcls_name name;
+
+        // my vars
+    public JsRender.Node data;
+    public Palete.Palete palete;
+
+        // ctor 
+    public Xcls_DialogSaveModule()
+    {
+        _this = this;
+        this.el = new Gtk.Dialog();
+
+        // my vars
+
+        // set gobject values
+        this.el.default_height = 200;
+        this.el.default_width = 400;
+        this.el.modal = true;
+        var child_0 = new Xcls_HBox2( _this );
+        child_0.ref();
+        this.el. get_content_area().add
+
+ (  child_0.el  );
+        var child_1 = new Xcls_Button5( _this );
+        child_1.ref();
+        this.el.add_action_widget (  child_1.el , 0 );
+        var child_2 = new Xcls_Button6( _this );
+        child_2.ref();
+        this.el.add_action_widget (  child_2.el , 1 );
+
+        // listeners 
+        this.el.delete_event.connect(  (self, event) => {
+            this.el.hide();
+            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.show(
+                    "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(
+                    "Template Nane must contain only letters and spaces. "
+                );
+                 return;
+            }
+            _this.palete.saveTemplate(name, _this.data);
+            // now we save it..
+            this.el.hide();
+            
+        } );
+    }
+
+    // userdefined functions 
+    public static void show (Gtk.Window parent, Palete.Palete palete, JsRender.Node data) {
+         
+            
+         
+             var t =DialogSaveTemplate;
+            if (t == null) {
+               t =   new Xcls_DialogSaveTemplate();
+            }
+            t.el.set_transient_for(parent);
+            t.data = data;
+            t.palete = palete;
+            t.name.el.set_text("");
+            t.el.show_all();
+        }
+
+    // skip |xns - no return type
+    public class Xcls_HBox2 : Object 
+    {
+        public Gtk.HBox el;
+        private Xcls_DialogSaveModule  _this;
+
+
+            // my vars
+
+            // ctor 
+        public Xcls_HBox2(Xcls_DialogSaveModule _owner )
+        {
+            _this = _owner;
+            this.el = new Gtk.HBox( true, 0 );
+
+            // my vars
+
+            // set gobject values
+            var child_0 = new Xcls_Label3( _this );
+            child_0.ref();
+            this.el.add (  child_0.el  );
+            var child_1 = new Xcls_name( _this );
+            child_1.ref();
+            this.el.add (  child_1.el  );
+        }
+
+        // userdefined functions 
+
+        // skip |xns - no return type
+    }
+    public class Xcls_Label3 : Object 
+    {
+        public Gtk.Label el;
+        private Xcls_DialogSaveModule  _this;
+
+
+            // my vars
+
+            // ctor 
+        public Xcls_Label3(Xcls_DialogSaveModule _owner )
+        {
+            _this = _owner;
+            this.el = new Gtk.Label( "Name" );
+
+            // my vars
+
+            // set gobject values
+
+            // listeners 
+        }
+
+        // userdefined functions 
+
+        // skip |xns - no return type
+    }
+    public class Xcls_name : Object 
+    {
+        public Gtk.Entry el;
+        private Xcls_DialogSaveModule  _this;
+
+
+            // my vars
+
+            // ctor 
+        public Xcls_name(Xcls_DialogSaveModule _owner )
+        {
+            _this = _owner;
+            _this.name = this;
+            this.el = new Gtk.Entry();
+
+            // my vars
+
+            // set gobject values
+        }
+
+        // userdefined functions 
+
+        // skip |xns - no return type
+    }
+    public class Xcls_Button5 : Object 
+    {
+        public Gtk.Button el;
+        private Xcls_DialogSaveModule  _this;
+
+
+            // my vars
+
+            // ctor 
+        public Xcls_Button5(Xcls_DialogSaveModule _owner )
+        {
+            _this = _owner;
+            this.el = new Gtk.Button();
+
+            // my vars
+
+            // set gobject values
+            this.el.label = "Cancel";
+        }
+
+        // userdefined functions 
+
+        // skip |xns - no return type
+    }
+    public class Xcls_Button6 : Object 
+    {
+        public Gtk.Button el;
+        private Xcls_DialogSaveModule  _this;
+
+
+            // my vars
+
+            // ctor 
+        public Xcls_Button6(Xcls_DialogSaveModule _owner )
+        {
+            _this = _owner;
+            this.el = new Gtk.Button();
+
+            // my vars
+
+            // set gobject values
+            this.el.label = "OK";
+        }
+
+        // userdefined functions 
+
+        // skip |xns - no return type
+    }
+}