src/JsRender/NodeToValaExtended.vala
authorAlan Knowles <alan@roojs.com>
Sat, 27 Jan 2024 08:44:31 +0000 (16:44 +0800)
committerAlan Knowles <alan@roojs.com>
Sat, 27 Jan 2024 08:44:31 +0000 (16:44 +0800)
src/JsRender/NodeToValaExtended.vala

index 00e7627..7ab181a 100644 (file)
@@ -53,9 +53,8 @@ public class  JsRender.NodeToValaExtended : NodeToVala {
                
                // skip '+' properties?? not sure where they are used.
                this.addValaCtor();
-               //this.addUnderThis();
-               this.addWrappedCtor();  // var this.el = new XXXXX()
-
+                
                this.addInitMyVars();
                this.addWrappedProperties();
                this.addChildren();
@@ -237,4 +236,63 @@ public class  JsRender.NodeToValaExtended : NodeToVala {
 
        }
        
+       protected overide void addWrappedProperties()
+       {
+               var cls = Palete.Gir.factoryFqn((Project.Gtk) this.file.project, this.node.fqn());
+               if (cls == null) {
+                       GLib.debug("Skipping wrapped properties - could not find class  %s" , this.node.fqn());
+                       return;
+               }
+                       // what are the properties of this class???
+               this.addLine();
+               this.addLine(this.ipad + "// set gobject values (not done in  Object()");
+               
+
+               var iter = cls.props.map_iterator();
+               while (iter.next()) {
+                       var p = iter.get_key();
+                       //print("Check Write %s\n", p);
+                       if (!this.node.has(p)) {
+                               continue;
+                       }
+                       if (this.shouldIgnoreWrapped(p)) {
+                               continue;
+                       }
+                       
+                       this.ignore(p);
+
+
+                       var prop = this.node.get_prop(p);
+                       var v = prop.val;
+                       
+                       // user defined properties.
+                       if (prop.ptype == NodePropType.USER) {
+                               continue;
+                       }
+                               
+
+                       
+                       var is_raw = prop.ptype == NodePropType.RAW;
+                       
+                       // what's the type.. - if it's a string.. then we quote it..
+                       if (iter.get_value().type == "string" && !is_raw) {
+                                v = "\"" +  v.escape("") + "\"";
+                       }
+                       if (v == "TRUE" || v == "FALSE") {
+                               v = v.down();
+                       }
+                       if (iter.get_value().type == "float" && v[v.length-1] != 'f') {
+                               v += "f";
+                       }
+                       
+                       prop.start_line = this.cur_line;
+                       this.addLine("%sthis.el.%s = %s;".printf(ipad,p,v)); // // %s,  iter.get_value().type);
+                       prop.end_line = this.cur_line;          
+                          // got a property..
+                          
+
+               }
+               
+       }
+       
 }