Test.GtkWriter.vala.c
[app.Builder.js] / Builder4 / DialogNewComponent.vala
index 6b57edf..2b30a10 100644 (file)
@@ -17,11 +17,11 @@ static int main (string[] args) {
 
 public static Xcls_DialogNewComponent  DialogNewComponent;
 
-private static Xcls_DialogNewComponent  _this;
-
 public class Xcls_DialogNewComponent
 {
     public Gtk.Dialog el;
+    private static Xcls_DialogNewComponent  _this;
+
     public Xcls_name name;
     public Xcls_title title;
     public Xcls_region region;
@@ -30,6 +30,9 @@ public class Xcls_DialogNewComponent
     public Xcls_modOrder modOrder;
 
         // my vars
+    public JsRender.JsRender file;
+    public Project.Project project;
+    public signal void success(Project.Project pr, JsRender.JsRender file);
 
         // ctor 
     public Xcls_DialogNewComponent()
@@ -54,53 +57,60 @@ public class Xcls_DialogNewComponent
         this.el.add_action_widget (  child_2.el , 1 );
 
         // listeners 
-        this.el.delete_event.connect( function (self, event) => {
+        this.el.delete_event.connect( (self, event) => {
             this.el.hide();
-            return true;
-        } );
-        this.el.response.connect( function (self, response_id) => {
+            return true;   
+        }
+          );
+        this.el.response.connect(  (self, response_id) =>  { 
+          
                if (response_id < 1) { // cancel!
                     this.el.hide();
                     return;
                 }
         
-                if (DialogNewComponent.name.el.get_text().length  < 1) {
+                if (_this.name.el.get_text().length  < 1) {
                     StandardErrorDialog.show(
-                        "You haDe to set Project name "
+                        "You have to set Project name "
                     );
                      
                     return;
                 }
-                var isNew = this.file.name.length ? false : true;
+                // what does this do?
                 
-                if (this.file.name.length && this.file.name != this.get('name').el.get_text()) {
-                    this.get('/StandardErrorDialog').show(
+                var isNew = _this.file.name.length  > 0 ? false : true;
+                
+                if (_this.file.name.length > 0 && this.file.name != _this.name.el.get_text()) {
+                    StandardErrorDialog.show(
                         "Sorry changing names does not work yet. "
                     );
                      
                     return;
                 }
-                for (var i in this.def) {
-                    this.file[i] =  this.get(i).el.get_text();
-                }
-               
+        
+                // FIXME - this may be more complicated...
+                //for (var i in this.def) {
+                //    this.file[i] =  this.get(i).el.get_text();
+                //}
+        
                 if (!isNew) {
-                    this.file.save();
+                    _this.file.save();
                     this.el.hide();
                     return;
                 }
-               
+        
             
-               var dir ='';
-                for (var i in this.project.paths) {
-                       dir = i;
-                       break;
-               }
+               var dir = _this.project.firstPath();
+               //FIXME...
+                //for (var i in this.project.paths) {
+               //      dir = i;
+               //      break;
+               //}
         
          
                 
                 // what about .js ?
-                 if (GLib.file_test (GLib.dir + '/' + this.file.name + '.bjs', GLib.FileTest.EXISTS)) {
+                if (GLib.FileUtils.test(_this.file.name + ".bjs", GLib.FileTest.EXISTS)) {
                     StandardErrorDialog.show(
                         "That file already exists"
                     ); 
@@ -110,18 +120,23 @@ public class Xcls_DialogNewComponent
                 
                 
                 //var tmpl = this.project.loadFileOnly(DialogNewComponent.get('template').getValue());
-                
-                var _this = this;
-                var nf = _this.project.create(dir + '/' + this.file.name + '.bjs');
-                for (var i in this.file) {
-                    nf[i] = this.file[i];
-                }
-                if (this.get('/DialogNewComponent').success) {
-                    this.get('/DialogNewComponent').success(_this.project, nf);
+                 
+                var nf = _this.project.create(dir + "/" + _this.file.name + ".bjs");
+                //for (var i in this.file) {
+                //    nf[i] = this.file[i];
+                //}
+                _this.success(_this.project, nf);
+                /*
+        
+                -- fixme -- needs to be a signal..
+                if (DialogNewComponent.success != null) {
+                    DialogNewComponent.success(_this.project, nf);
                 }
+                */
         } );
-        this.el.show.connect( function (self) => {
+        this.el.show.connect( (self)  => {
           this.el.show_all();
+          
         } );
     }
 
@@ -129,6 +144,12 @@ public class Xcls_DialogNewComponent
 
     // skip listeners - not pipe 
 
+    // skip .JsRender.JsRender:file - already used 
+
+    // skip .Project.Project:project - already used 
+
+    // skip .signal:void:success - already used 
+
     // skip default_height - already used 
 
     // skip default_width - already used 
@@ -142,10 +163,37 @@ public class Xcls_DialogNewComponent
     // skip |deletable - already used 
 
     // skip |modal - already used 
+    public void show(JsRender.JsRender c) 
+        {
+            this.project = c.project;
+            
+            //if (!this.el) {
+                //this.init();
+             //}
+            
+            _this.name.el.set_text(c.name);
+            _this.title.el.set_text(c.title);
+            _this.parent.el.set_text(c.parent);    
+            _this.region.el.set_text(c.region);
+            _this.modOrder.el.set_text(c.modOrder);
+             _this.permname.el.set_text(c.permname);
+            
+            if (c.path.length > 0) {
+                this.el.set_title("Edit File Details - " + c.name);
+            } else {
+                this.el.set_title("Create New File");
+            }
+             
+            _this.file = c;
+            //console.log('show all');
+            this.el.show_all();
+            
+            //this.success = c.success;
+            
+            
+        }
 
-    // skip |show - could not find seperator
-
-    // skip |xns - could not find seperator
+    // skip |xns - no return type
 
     // skip items - not pipe 
 
@@ -174,7 +222,7 @@ public class Xcls_DialogNewComponent
 
         // userdefined functions 
 
-        // skip |xns - could not find seperator
+        // skip |xns - no return type
 
         // skip xtype - not pipe 
 
@@ -197,14 +245,11 @@ public class Xcls_DialogNewComponent
             // ctor 
         public Xcls_Table3()
         {
-            this.el = new Gtk.Table();
+            this.el = new Gtk.Table( 3, 2, false );
 
             // my vars
 
             // set gobject values
-            this.el.homogeneous = false;
-            this.el.n_columns = 2;
-            this.el.n_rows = 3;
             var child_0 = new Xcls_Label4();
             this.el.add (  child_0.el  );
             var child_1 = new Xcls_name();
@@ -243,7 +288,7 @@ public class Xcls_DialogNewComponent
 
         // skip |homogeneous - already used 
 
-        // skip |xns - could not find seperator
+        // skip |xns - no return type
 
         // skip items - not pipe 
 
@@ -262,14 +307,13 @@ public class Xcls_DialogNewComponent
             // ctor 
         public Xcls_Label4()
         {
-            this.el = new Gtk.Label();
+            this.el = new Gtk.Label( "Component Name" );
 
             // my vars
 
             // set gobject values
             this.el.justify = Gtk.Justification.RIGHT;
-            this.el.label = "Component Name";
-            this.el.xalign = 0.9;
+            this.el.xalign = 0.9f;
         }
 
         // userdefined functions 
@@ -286,7 +330,7 @@ public class Xcls_DialogNewComponent
 
         // skip |justify - already used 
 
-        // skip |xns - could not find seperator
+        // skip |xns - no return type
 
         // skip xvala_cls - not pipe 
 
@@ -322,7 +366,7 @@ public class Xcls_DialogNewComponent
 
         // skip |visible - already used 
 
-        // skip |xns - could not find seperator
+        // skip |xns - no return type
 
         // skip xvala_cls - not pipe 
 
@@ -339,15 +383,14 @@ public class Xcls_DialogNewComponent
             // ctor 
         public Xcls_Label6()
         {
-            this.el = new Gtk.Label();
+            this.el = new Gtk.Label( "Title" );
 
             // my vars
 
             // set gobject values
             this.el.justify = Gtk.Justification.RIGHT;
-            this.el.label = "Title";
             this.el.visible = true;
-            this.el.xalign = 0.9;
+            this.el.xalign = 0.9f;
         }
 
         // userdefined functions 
@@ -366,7 +409,7 @@ public class Xcls_DialogNewComponent
 
         // skip |visible - already used 
 
-        // skip |xns - could not find seperator
+        // skip |xns - no return type
 
         // skip xvala_cls - not pipe 
 
@@ -402,7 +445,7 @@ public class Xcls_DialogNewComponent
 
         // skip |visible - already used 
 
-        // skip |xns - could not find seperator
+        // skip |xns - no return type
 
         // skip xvala_cls - not pipe 
 
@@ -419,16 +462,15 @@ public class Xcls_DialogNewComponent
             // ctor 
         public Xcls_Label8()
         {
-            this.el = new Gtk.Label();
+            this.el = new Gtk.Label( "Region" );
 
             // my vars
 
             // set gobject values
             this.el.justify = Gtk.Justification.RIGHT;
-            this.el.label = "Region";
             this.el.tooltip_text = "center, north, south, east, west";
             this.el.visible = true;
-            this.el.xalign = 0.9;
+            this.el.xalign = 0.9f;
         }
 
         // userdefined functions 
@@ -449,7 +491,7 @@ public class Xcls_DialogNewComponent
 
         // skip |visible - already used 
 
-        // skip |xns - could not find seperator
+        // skip |xns - no return type
 
         // skip xvala_cls - not pipe 
 
@@ -485,7 +527,7 @@ public class Xcls_DialogNewComponent
 
         // skip |visible - already used 
 
-        // skip |xns - could not find seperator
+        // skip |xns - no return type
 
         // skip xvala_cls - not pipe 
 
@@ -502,15 +544,14 @@ public class Xcls_DialogNewComponent
             // ctor 
         public Xcls_Label10()
         {
-            this.el = new Gtk.Label();
+            this.el = new Gtk.Label( "Parent Name" );
 
             // my vars
 
             // set gobject values
             this.el.justify = Gtk.Justification.RIGHT;
-            this.el.label = "Parent Name";
             this.el.visible = true;
-            this.el.xalign = 0.9;
+            this.el.xalign = 0.9f;
         }
 
         // userdefined functions 
@@ -529,7 +570,7 @@ public class Xcls_DialogNewComponent
 
         // skip |visible - already used 
 
-        // skip |xns - could not find seperator
+        // skip |xns - no return type
 
         // skip xvala_cls - not pipe 
 
@@ -565,7 +606,7 @@ public class Xcls_DialogNewComponent
 
         // skip |visible - already used 
 
-        // skip |xns - could not find seperator
+        // skip |xns - no return type
 
         // skip xvala_cls - not pipe 
 
@@ -582,15 +623,14 @@ public class Xcls_DialogNewComponent
             // ctor 
         public Xcls_Label12()
         {
-            this.el = new Gtk.Label();
+            this.el = new Gtk.Label( "Permission Name" );
 
             // my vars
 
             // set gobject values
             this.el.justify = Gtk.Justification.RIGHT;
-            this.el.label = "Permission Name";
             this.el.visible = true;
-            this.el.xalign = 0.9;
+            this.el.xalign = 0.9f;
         }
 
         // userdefined functions 
@@ -609,7 +649,7 @@ public class Xcls_DialogNewComponent
 
         // skip |visible - already used 
 
-        // skip |xns - could not find seperator
+        // skip |xns - no return type
 
         // skip xvala_cls - not pipe 
 
@@ -645,7 +685,7 @@ public class Xcls_DialogNewComponent
 
         // skip |visible - already used 
 
-        // skip |xns - could not find seperator
+        // skip |xns - no return type
 
         // skip xvala_cls - not pipe 
 
@@ -662,15 +702,14 @@ public class Xcls_DialogNewComponent
             // ctor 
         public Xcls_Label14()
         {
-            this.el = new Gtk.Label();
+            this.el = new Gtk.Label( "Order (for tabs)" );
 
             // my vars
 
             // set gobject values
             this.el.justify = Gtk.Justification.RIGHT;
-            this.el.label = "Order (for tabs)";
             this.el.visible = true;
-            this.el.xalign = 0.9;
+            this.el.xalign = 0.9f;
         }
 
         // userdefined functions 
@@ -689,7 +728,7 @@ public class Xcls_DialogNewComponent
 
         // skip |visible - already used 
 
-        // skip |xns - could not find seperator
+        // skip |xns - no return type
 
         // skip xvala_cls - not pipe 
 
@@ -725,7 +764,7 @@ public class Xcls_DialogNewComponent
 
         // skip |visible - already used 
 
-        // skip |xns - could not find seperator
+        // skip |xns - no return type
 
         // skip xvala_cls - not pipe 
 
@@ -752,7 +791,7 @@ public class Xcls_DialogNewComponent
 
         // userdefined functions 
 
-        // skip |xns - could not find seperator
+        // skip |xns - no return type
 
         // skip xtype - not pipe 
 
@@ -785,7 +824,7 @@ public class Xcls_DialogNewComponent
 
         // userdefined functions 
 
-        // skip |xns - could not find seperator
+        // skip |xns - no return type
 
         // skip xtype - not pipe