3 * Code to convert node tree to Vala...
5 * usage : x = (new JsRender.NodeToVala(node)).munge();
9 * pack - can we come up with a replacement?
10 - parent.child == child_widget -- actually uses getters and effectively does 'add'?
14 * args -- vala constructor args (should really only be used at top level - we did use it for clutter originally(
15 * ctor -- different ctor argument
24 public class JsRender.NodeToVala : Object {
32 string cls; // node fqn()
39 Gee.ArrayList<string> ignoreList;
40 Gee.ArrayList<string> ignoreWrappedList;
41 Gee.ArrayList<string> myvars;
42 Gee.ArrayList<Node> vitems; // top level items
48 * ctor - just initializes things
49 * - wraps a render node
51 public NodeToVala( JsRender file, Node node, int depth, NodeToVala? parent)
57 if (file.name.contains(".")) { // namespaced..
58 this.inpad = string.nfill(depth > 0 ? 2 : 1, '\t');
60 this.inpad = string.nfill(depth > 0 ? 1 : 0, '\t');
62 this.pad = this.inpad + "\t";
63 this.ipad = this.inpad + "\t\t";
64 this.cls = node.xvala_cls;
65 this.xcls = node.xvala_xcls;
66 if (depth == 0 && this.xcls.contains(".")) {
67 var ar = this.xcls.split(".");
68 this.xcls = ar[ar.length-1];
73 this.cur_line = parent == null ? 0 : parent.cur_line;
76 this.top = parent == null ? this : parent.top;
77 this.ignoreList = new Gee.ArrayList<string>();
78 this.ignoreWrappedList = new Gee.ArrayList<string>();
79 this.myvars = new Gee.ArrayList<string>();
80 this.vitems = new Gee.ArrayList<Node>();
83 // initialize line data..
84 node.line_start = this.cur_line;
85 node.line_end = this.cur_line;
86 node.lines = new Gee.ArrayList<int>();
87 node.line_map = new Gee.HashMap<int,string>();
89 node.node_lines = new Gee.ArrayList<int>();
90 node.node_lines_map = new Gee.HashMap<int,Node>();
96 string toValaNS(Node item)
98 var ns = item.get("xns") ;
99 //if (ns == "GtkSource") { technically on Gtk3?
100 // return "Gtk.Source";
104 public void toValaName(Node item, int depth =0)
108 var ns = this.toValaNS(item) ;
109 var cls = ns + item.get("xtype");
112 item.xvala_cls = cls;
115 string id = item.get("id").length > 0 ?
116 item.get("id") : "%s%d".printf(item.get("xtype"), this.vcnt);
121 if (id[0] == '*' || id[0] == '+') {
122 item.xvala_xcls = "Xcls_" + id.substring(1);
124 item.xvala_xcls = "Xcls_" + id;
130 this.vitems.add(item);
132 // setting id on top level class changes it classname..
133 // oddly enough we havent really thought about namespacing here.
135 } else if (!item.props.has_key("id")) {
136 // use the file name..
137 item.xvala_xcls = this.file.file_without_namespace;
139 item.xvala_id = this.file.file_without_namespace;
144 if (item.readItems().size < 1) {
147 for(var i =0;i<item.readItems().size;i++) {
148 this.toValaName(item.readItems().get(i), depth+1);
153 * Main entry point to convert a file into a string..
155 public static string mungeFile(JsRender file)
157 if (file.tree == null) {
161 var n = new NodeToVala(file, file.tree, 0, null);
165 n.toValaName(file.tree);
168 GLib.debug("top cls %s / xlcs %s\n ",file.tree.xvala_cls,file.tree.xvala_cls);
169 n.cls = file.tree.xvala_cls;
170 n.xcls = file.tree.xvala_xcls;
175 int child_count = 1; // used to number the children.
176 public string munge ( )
178 //return this.mungeToString(this.node);
179 this.child_count = 1;
183 this.ignore("xtype");
186 this.namespaceHeader();
190 this.addTopProperties();
192 this.addPlusProperties();
195 this.addWrappedCtor(); // var this.el = new XXXXX()
197 this.addInitMyVars();
198 this.addWrappedProperties();
200 this.addAutoShow(); // autoshow menuitems
205 this.addUserMethods();
207 this.namespaceFooter();
213 public string mungeChild( Node cnode)
215 var x = new NodeToVala(this.file, cnode, this.depth+1, this);
218 public void addLine(string str= "")
221 if (str.contains("\n")) {
222 this.addMultiLine(str);
226 if (BuilderApplication.opt_bjs_compile != null) {
227 this.ret += "/*%d*/ ".printf(this.cur_line) + str + "\n";
229 this.ret += str + "\n";
232 public void addMultiLine(string str= "")
235 this.cur_line += str.split("\n").length;
236 //this.ret += "/*%d*/ ".printf(l) + str + "\n";
237 this.ret += str + "\n";
240 public void namespaceHeader()
242 if (this.depth > 0 || this.file.file_namespace == "") {
245 this.addLine("namespace " + this.file.file_namespace);
249 public void namespaceFooter()
251 if (this.depth > 0 || this.file.file_namespace == "") {
257 public void globalVars()
259 if (this.depth > 0) {
262 // Global Vars..??? when did this get removed..?
263 //this.ret += this.inpad + "public static " + this.xcls + " " + this.node.xvala_id+ ";\n\n";
265 this.addLine(this.inpad + "static " + this.xcls + " _" + this.node.xvala_id+ ";");
274 // class xxx { WrappedGtk el; }
275 this.node.line_start = this.cur_line;
277 this.top.node.setNodeLine(this.cur_line, this.node);
279 this.addLine(this.inpad + "public class " + this.xcls + " : Object");
280 this.addLine(this.inpad + "{");
283 this.addLine(this.pad + "public " + this.cls + " el;");
285 this.addLine(this.pad + "private " + this.top.xcls + " _this;");
297 this.addLine(pad + "public static " + xcls + " singleton()");
298 this.addLine(this.pad + "{");
299 this.addLine(this.ipad + "if (_" + this.node.xvala_id + " == null) {");
300 this.addLine(this.ipad + " _" + this.node.xvala_id + "= new "+ this.xcls + "();"); // what about args?
301 this.addLine(this.ipad + "}");
302 this.addLine(this.ipad + "return _" + this.node.xvala_id +";");
303 this.addLine(this.pad + "}");
307 * when ID is used... on an element, it registeres a property on the top level...
308 * so that _this.ID always works..
311 void addTopProperties()
313 if (this.depth > 0) {
316 // properties - global..??
318 var iter = this.vitems.list_iterator();
323 if (!n.props.has_key("id") || n.xvala_id.length < 0) {
327 if (n.xvala_id[0] == '*') {
330 if (n.xvala_id[0] == '+') {
333 this.addLine(this.pad + "public " + n.xvala_xcls + " " + n.xvala_id + ";");
339 * create properties that are not 'part of the wrapped element.
346 GLib.debug("callinged addMhyVars");
349 this.addLine(this.ipad + "// my vars (def)");
353 var cls = Palete.Gir.factoryFqn((Project.Gtk) this.file.project, this.node.fqn());
356 GLib.debug("Gir factory failed to find class %s", this.node.fqn());
363 var iter = this.node.props.map_iterator();
364 while (iter.next()) {
366 var prop = iter.get_value();
368 if (this.shouldIgnore(prop.name)) {
372 // user defined method
373 if (prop.ptype == NodePropType.METHOD) {
376 if (prop.ptype == NodePropType.SPECIAL) {
380 if (prop.ptype == NodePropType.SIGNAL) {
381 this.node.setLine(this.cur_line, "p", prop.name);
382 this.addLine(this.pad + "public signal " + prop.rtype + " " + prop.name + " " + prop.val + ";");
384 this.ignore(prop.name);
388 GLib.debug("Got myvars: %s", prop.name.strip());
390 if (prop.rtype.strip().length < 1) {
394 // is it a class property...
395 if (cls != null && cls.props.has_key(prop.name) && prop.ptype != NodePropType.USER) {
399 this.myvars.add(prop.name);
400 prop.start_line = this.cur_line;
402 this.node.setLine(this.cur_line, "p", prop.name);
404 this.addLine(this.pad + "public " + prop.rtype + " " + prop.name + ";"); // definer - does not include value.
407 prop.end_line = this.cur_line;
408 this.ignore(prop.name);
414 // if id of child is '+' then it's a property of this..
415 void addPlusProperties()
417 if (this.node.readItems().size < 1) {
420 var iter = this.node.readItems().list_iterator();
421 while (iter.next()) {
424 if (ci.xvala_id[0] != '+') {
425 continue; // skip generation of children?
429 this.addLine(this.pad + "public " + ci.xvala_xcls + " " + ci.xvala_id.substring(1) + ";");
435 * add the constructor definition..
447 this.addLine(this.pad + "// ctor");
449 if (this.node.has("* args")) {
450 // not sure what this is supposed to be ding..
452 cargs_str = this.node.get("* args");
453 //var ar = this.node.get("* args");.split(",");
454 //for (var ari =0; ari < ar.length; ari++) {
455 // cargs += (ar[ari].trim().split(" ").pop();
459 if (this.depth < 1) {
461 // top level - does not pass the top level element..
462 this.addLine(this.pad + "public " + this.xcls + "(" + cargs_str +")");
463 this.addLine(this.pad + "{");
465 if (cargs_str.length > 0) {
466 cargs_str = ", " + cargs_str;
468 // for sub classes = we passs the top level as _owner
469 this.addLine(this.pad + "public " + this.xcls + "(" + this.top.xcls + " _owner " + cargs_str + ")");
470 this.addLine(this.pad + "{");
476 * make sure _this is defined..
482 this.addLine( this.ipad + "_this = this;");
485 // for non top level = _this point to owner, and _this.ID is set
487 this.addLine( this.ipad + "_this = _owner;");
489 if (this.node.props.has_key("id")
491 this.node.xvala_id != ""
493 this.node.xvala_id[0] != '*'
495 this.node.xvala_id[0] != '+'
497 this.addLine( this.ipad + "_this." + node.xvala_id + " = this;");
504 * Initialize this.el to point to the wrapped element.
509 void addWrappedCtor()
512 // this may need to look up properties to fill in the arguments..
513 // introspection does not workk..... - as things like gtkmessagedialog
515 if (cls == 'Gtk.Table') {
517 var methods = this.palete.getPropertiesFor(cls, 'methods');
519 print(JSON.stringify(this.palete.proplist[cls], null,4));
524 // ctor can still override.
525 if (this.node.has("* ctor")) {
526 this.node.setLine(this.cur_line, "p", "* ctor");
527 this.addLine(this.ipad + "this.el = " + this.node.get("* ctor")+ ";");
531 this.node.setLine(this.cur_line, "p", "* xtype");;
533 // is the wrapped element a struct?
535 var ncls = Palete.Gir.factoryFqn((Project.Gtk) this.file.project, this.node.fqn());
536 if (ncls != null && ncls.nodetype == "Struct") {
537 // we can use regular setters to apply the values.
538 this.addLine(this.ipad + "this.el = " + this.node.fqn() + "();");
546 switch(this.node.fqn()) {
548 // FIXME -- these are all GTK3 - can be removed when I get rid of them..
550 var is_entry = this.node.has("has_entry") && this.node.get_prop("has_entry").val.down() == "true";
552 break; // regular ctor.
554 this.ignoreWrapped("has_entry");
555 ctor = ".with_entry";
559 case "Gtk.ListStore":
560 case "Gtk.TreeStore":
562 // not sure if this works.. otherwise we have to go with varargs and count + vals...
563 if (this.node.has("* types")) {
564 args_str = this.node.get_prop("* types").val;
566 if (this.node.has("n_columns") && this.node.has("columns")) { // old value?
567 args_str = " { " + this.node.get_prop("columns").val + " } ";
568 this.ignoreWrapped("columns");
569 this.ignoreWrapped("n_columns");
572 this.addLine(this.ipad + "this.el = new " + this.node.fqn() + ".newv( " + args_str + " );");
576 case "Gtk.LinkButton": // args filled with values.
577 if (this.node.has("label")) {
578 ctor = ".with_label";
585 var default_ctor = Palete.Gir.factoryFqn((Project.Gtk) this.file.project, this.node.fqn() + ctor);
588 // use the default ctor - with arguments (from properties)
590 if (default_ctor != null && default_ctor.paramset != null && default_ctor.paramset.params.size > 0) {
592 foreach(var param in default_ctor.paramset.params) {
595 GLib.debug("building CTOR ARGS: %s, %s", n, param.is_varargs ? "VARARGS": "");
596 if (n == "___") { // for some reason our varargs are converted to '___' ...
600 if (this.node.has(n)) { // node does not have a value
602 this.ignoreWrapped(n);
605 var v = this.node.get(n);
607 if (param.type == "string") {
608 v = "\"" + v.escape("") + "\"";
610 if (v == "TRUE" || v == "FALSE") {
618 var propnode = this.node.findProp(n);
619 if (propnode != null) {
622 var pname = this.addPropSet(propnode, propnode.has("id") ? propnode.get_prop("id").val : "");
623 args += (pname + ".el") ;
624 if (!propnode.has("id")) {
625 this.addLine(this.ipad + pname +".ref();");
630 this.ignoreWrapped(n);
639 if (param.type.contains("int")) {
643 if (param.type.contains("float")) {
647 if (param.type.contains("bool")) {
648 args += "true"; // always default to true?
651 // any other types???
661 this.node.setLine(this.cur_line, "p", "* xtype");
662 this.addLine(this.ipad + "this.el = new " + this.node.fqn() + "( "+ string.joinv(", ",args) + " );") ;
666 // default ctor with no params..
667 if (default_ctor != null && ctor != ".new" ) {
668 this.node.setLine(this.cur_line, "p", "* xtype");
670 this.addLine(this.ipad + "this.el = new " + this.node.fqn() + ctor + "( );") ;
675 this.addLine(this.ipad + "this.el = new " + this.node.fqn() + "(" + args_str + ");");
681 public static Gee.ArrayList<string> menuitem_children = null;
685 if (menuitem_children == null) {
686 menuitem_children = new Gee.ArrayList<string>();
687 menuitem_children.add("Gtk.MenuItem");
688 var gir = this.file.project.palete.getClass("Gtk.MenuItem");
690 foreach(var impl in gir.implementations) {
691 menuitem_children.add(impl);
696 if (menuitem_children.contains(this.node.fqn())) {
697 this.addLine(this.ipad + "this.el.show();");
704 //var meths = this.palete.getPropertiesFor(item['|xns'] + '.' + item.xtype, 'methods');
705 //print(JSON.stringify(meths,null,4));Seed.quit();
709 // initialize.. my vars..
711 this.addLine( this.ipad + "// my vars (dec)");
713 var iter = this.myvars.list_iterator();
719 var prop = this.node.props.get(k);
721 var v = prop.val.strip();
726 // at this point start using
728 if (v == "FALSE" || v == "TRUE") {
731 //FIXME -- check for raw string.. "string XXXX"
733 // if it's a string...
735 prop.start_line = this.cur_line;
736 this.addLine(this.ipad + "this." + prop.name + " = " + v +";");
737 prop.end_line = this.cur_line;
745 void addWrappedProperties()
747 var cls = Palete.Gir.factoryFqn((Project.Gtk) this.file.project, this.node.fqn());
749 GLib.debug("Skipping wrapped properties - could not find class %s" , this.node.fqn());
752 // what are the properties of this class???
754 this.addLine(this.ipad + "// set gobject values");
757 var iter = cls.props.map_iterator();
758 while (iter.next()) {
759 var p = iter.get_key();
760 //print("Check Write %s\n", p);
761 if (!this.node.has(p)) {
764 if (this.shouldIgnoreWrapped(p)) {
771 var prop = this.node.get_prop(p);
774 // user defined properties.
775 if (prop.ptype == NodePropType.USER) {
781 var is_raw = prop.ptype == NodePropType.RAW;
783 // what's the type.. - if it's a string.. then we quote it..
784 if (iter.get_value().type == "string" && !is_raw) {
785 v = "\"" + v.escape("") + "\"";
787 if (v == "TRUE" || v == "FALSE") {
790 if (iter.get_value().type == "float" && v[v.length-1] != 'f') {
794 prop.start_line = this.cur_line;
795 this.addLine("%sthis.el.%s = %s;".printf(ipad,p,v)); // // %s, iter.get_value().type);
796 prop.end_line = this.cur_line;
804 * pack the children into the parent.
806 * if the child's id starts with '*' then it is not packed...
807 * - this allows you to define children and add them manually..
813 if (this.node.readItems().size < 1) {
816 this.pane_number = 0;
817 var cols = this.node.has("* columns") ? int.max(1, int.parse(this.node.get_prop("* columns").val)) : 1;
822 foreach(var child in this.node.readItems()) {
827 if (child.xvala_id[0] == '*') {
828 continue; // skip generation of children?
831 // probably added in ctor..
832 if (child.has("* prop") && this.shouldIgnoreWrapped(child.get_prop("* prop").val)) {
835 // create the element..
837 // this is only needed if it does not have an ID???
838 var childname = this.addPropSet(child, child.has("id") ? child.get_prop("id").val : "") ;
840 if (child.has("* prop")) {
843 // fixme special packing!??!?!
844 if (child.get_prop("* prop").val.contains("[]")) {
845 // currently these 'child props
846 // used for label[] on Notebook
847 // used for button[] on Dialog?
850 this.packChild(child, childname, 0, 0, child.get_prop("* prop").val); /// fixme - this is a bit speciall...
856 this.ignoreWrapped(child.get_prop("* prop").val);
858 this.addLine(ipad + "this.el." + child.get_prop("* prop").val + " = " + childname + ".el;");
861 if (!child.has("id")) {
862 this.addLine(this.ipad + childname +".ref();");
864 this.packChild(child, childname, cols, colpos);
866 if (child.has("colspan")) {
867 colpos += int.parse(child.get_prop("colspan").val);
873 // this.{id - without the '+'} = the element...
879 string addPropSet(Node child, string child_name)
884 if (child.has("* args")) {
886 var ar = child.get_prop("* args").val.split(",");
887 for (var ari = 0 ; ari < ar.length; ari++ ) {
888 var arg = ar[ari].split(" ");
889 xargs += "," + arg[arg.length -1];
893 var childname = "child_" + "%d".printf(this.child_count++);
895 if (child_name == "") {
896 prefix = "var " + childname + " = ";
899 this.addLine(this.ipad + prefix + "new " + child.xvala_xcls + "( _this " + xargs + ");" );
901 // add a ref... (if 'id' is not set... to a '+' ?? what does that mean? - fake ids?
902 // remove '+' support as I cant remember what it does!!!
903 //if (child.xvala_id.length < 1 ) {
904 // this.addLine(this.ipad + childname +".ref();"); // we need to reference increase unnamed children...
906 //if (child.xvala_id[0] == '+') {
907 // this.addLine(this.ipad + "this." + child.xvala_id.substring(1) + " = " + childname+ ";");
912 return child_name == "" ? childname : ("_this." + child_name);
918 void packChild(Node child, string childname, int cols, int colpos, string propname= "")
921 GLib.debug("packChild %s=>%s", this.node.fqn(), child.fqn());
922 // forcing no packing? - true or false? -should we just accept false?
923 if (child.has("* pack") && child.get("* pack").down() == "false") {
924 return; // force no packing
926 if (child.has("* pack") && child.get("* pack").down() == "true") {
927 return; // force no packing
930 // BC really - don't want to support this anymore.
931 if (child.has("* pack")) {
933 string[] packing = { "add" };
934 if (child.has("* pack")) {
935 packing = child.get("* pack").split(",");
938 var pack = packing[0];
939 this.addLine(this.ipad + "this.el." + pack.strip() + " ( " + childname + ".el " +
940 (packing.length > 1 ?
941 (", " + string.joinv(",", packing).substring(pack.length+1))
947 var childcls = this.file.project.palete.getClass(child.fqn()); // very trusting..
948 if (childcls == null) {
952 var is_event = childcls.inherits.contains("Gtk.EventController") || childcls.implements.contains("Gtk.EventController");
954 this.addLine(this.ipad + "this.el.add_controller( %s.el );".printf(childname) );
959 switch (this.node.fqn()) {
965 var x = child.has("x") ? child.get_prop("x").val : "0";
966 var y = child.has("y") ? child.get_prop("y").val : "0";
967 this.addLine(this.ipad + "this.el.put( %s.el, %s, %s );".printf(childname,x,y) );
973 var named = child.has("stack_name") ? child.get_prop("stack_name").val.escape() : "";
974 var title = child.has("stack_title") ? child.get_prop("stack_title").val.escape() : "";
975 if (title.length > 0) {
976 this.addLine(this.ipad + "this.el.add_titled( %s.el, \"%s\", \"%s\" );".printf(childname,named,title));
978 this.addLine(this.ipad + "this.el.add_named( %s.el, \"%s\" );".printf(childname,named));
982 case "Gtk.Notebook": // use label
983 var label = child.has("notebook_label") ? child.get_prop("notebook_label").val.escape() : "";
984 this.addLine(this.ipad + "this.el.append_page( %s.el, new Gtk.Label(\"%s\"));".printf(childname, label));
988 case "Gtk.TreeView": // adding TreeViewColumns
989 this.addLine(this.ipad + "this.el.append_column( " + childname + ".el );");
992 case "Gtk.TreeViewColumn": //adding Renderers - I think these are all proprerties of the renderer used...
993 if (child.has("markup_column") && int.parse(child.get_prop("markup_column").val) > -1) {
994 this.addLine(this.ipad + "this.el.add_attribute( %s.el, \"markup\", %s );".printf(childname, child.get_prop("markup_column").val));
996 if (child.has("text_column") && int.parse(child.get_prop("text_column").val) > -1) {
997 this.addLine(this.ipad + "this.el.add_attribute( %s.el, \"text\", %s );".printf(childname, child.get_prop("text_column").val));
999 if (child.has("pixbuf_column") && int.parse(child.get_prop("pixbuf_column").val) > -1) {
1000 this.addLine(this.ipad + "this.el.add_attribute( %s.el, \"pixbuf\", %s );".printf(childname, child.get_prop("pixbuf_column").val));
1002 if (child.has("pixbuf_column") && int.parse(child.get_prop("active_column").val) > -1) {
1003 this.addLine(this.ipad + "this.el.add_attribute( %s.el, \"active\", %s );".printf(childname, child.get_prop("active_column").val));
1005 if (child.has("background_column") && int.parse(child.get_prop("background_column").val) > -1) {
1006 this.addLine(this.ipad + "this.el.add_attribute( %s.el, \"background-rgba\", %s );".printf(childname, child.get_prop("background_column").val));
1008 this.addLine(this.ipad + "this.el.add( " + childname + ".el );");
1013 if (propname == "buttons[]") {
1014 var resp_id = int.parse(childname.replace("child_", ""));
1015 if (child.has("* response_id")) {
1016 resp_id = int.parse(child.get_prop("* response_id").val);
1018 this.addLine(this.ipad + "this.el.add_action_widget( %s.el, %d);".printf(childname,resp_id) );
1023 this.addLine(this.ipad + "this.el.get_content_area().add( " + childname + ".el );");
1031 // known working with GTK4 !
1032 case "Gtk.HeaderBar": // it could be end... - not sure how to hanle that other than overriding the pack method?
1033 this.addLine(this.ipad + "this.el.pack_start( "+ childname + ".el );");
1037 this.addLine(this.ipad + "this.el.append_item( "+ childname + ".el );");
1042 switch(this.pane_number) {
1044 this.addLine(this.ipad + "this.el.pack_start( %s.el );".printf(childname));
1047 this.addLine(this.ipad + "this.el.pack_end( %s.el );".printf(childname));
1055 case "Gtk.ColumnView":
1056 this.addLine(this.ipad + "this.el.append_column( "+ childname + ".el );");
1060 var x = "%d".printf(colpos % cols);
1061 var y = "%d".printf(( colpos - (colpos % cols) ) / cols);
1062 var w = child.has("colspan") ? child.get_prop("colspan").val : "1";
1064 this.addLine(this.ipad + "this.el.attach( %s.el, %s, %s, %s, %s );".printf(childname ,x,y, w, h) );
1068 // gtk4 uses append!!!! - gtk3 - uses add..
1069 this.addLine(this.ipad + "this.el.append( "+ childname + ".el );");
1078 // fixme GtkDialog?!? buttons[]
1080 // fixme ... add case "Gtk.RadioButton": // group_id ??
1088 if (!this.node.has("* init")) {
1092 this.addLine(ipad + "// init method");
1094 this.node.setLine(this.cur_line, "p", "init");
1096 var init = this.node.get_prop("* init");
1097 init.start_line = this.cur_line;
1098 this.addMultiLine(ipad + this.padMultiline(ipad, init.val) );
1099 init.end_line = this.cur_line;
1103 if (this.node.listeners.size < 1) {
1108 this.addLine(ipad + "//listeners");
1112 var iter = this.node.listeners.map_iterator();
1113 while (iter.next()) {
1114 var k = iter.get_key();
1115 var prop = iter.get_value();
1118 prop.start_line = this.cur_line;
1119 this.node.setLine(this.cur_line, "l", k);
1120 this.addMultiLine(this.ipad + "this.el." + k + ".connect( " +
1121 this.padMultiline(this.ipad,v) +");");
1122 prop.end_line = this.cur_line;
1129 this.addLine(this.pad + "}");
1134 * Standardize this crap...
1136 * standard properties (use to set)
1137 * If they are long values show the dialog..
1140 * bool is_xxx :: can show a pulldown.. (true/false)
1142 * $ string html = string with value interpolated eg. baseURL + ".."
1143 * Clutter.ActorAlign x_align (typed) -- shows pulldowns if type is ENUM?
1144 * $ untypedvalue = javascript untyped value...
1145 * _ string html ... = translatable..
1148 * object properties (not part of the GOjbect being wrapped?
1149 * # Gee.ArrayList<Xcls_fileitem> fileitems
1154 * methods -- always text editor..
1162 * * init -- big string?
1164 * event handlers (listeners)
1169 * +XXXX -- indicates it's a instance property / not glob...
1170 * *XXXX -- skip writing glob property (used as classes that can be created...)
1175 void addUserMethods()
1178 this.addLine(this.pad + "// user defined functions");
1180 // user defined functions...
1181 var iter = this.node.props.map_iterator();
1182 while(iter.next()) {
1183 var prop = iter.get_value();
1184 if (this.shouldIgnore(prop.name)) {
1187 // HOW TO DETERIME if its a method?
1188 if (prop.ptype != NodePropType.METHOD) {
1189 //strbuilder("\n" + pad + "// skip " + k + " - not pipe \n");
1193 // function in the format of {type} (args) { .... }
1197 prop.start_line = this.cur_line;
1198 this.node.setLine(this.cur_line, "p", prop.name);
1199 this.addMultiLine(this.pad + "public " + prop.rtype + " " + prop.name + " " + this.padMultiline(this.pad, prop.val));;
1200 prop.end_line = this.cur_line;
1207 this.node.line_end = this.cur_line;
1208 this.node.sortLines();
1211 if (this.depth > 0) {
1212 this.addLine(this.inpad + "}");
1215 var iter = this.node.readItems().list_iterator();
1217 while (iter.next()) {
1218 this.addMultiLine(this.mungeChild(iter.get()));
1221 if (this.depth < 1) {
1222 this.addLine(this.inpad + "}");
1227 string padMultiline(string pad, string str)
1229 var ar = str.strip().split("\n");
1230 return string.joinv("\n" + pad , ar);
1233 void ignore(string i) {
1234 this.ignoreList.add(i);
1237 void ignoreWrapped(string i) {
1238 this.ignoreWrappedList.add(i);
1241 bool shouldIgnore(string i)
1243 return ignoreList.contains(i);
1245 bool shouldIgnoreWrapped(string i)
1247 return ignoreWrappedList.contains(i);