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";
64 this.node.node_pad = this.inpad;
65 this.ipad = this.inpad + "\t\t";
66 this.cls = node.xvala_cls;
67 this.xcls = node.xvala_xcls;
68 if (depth == 0 && this.xcls.contains(".")) {
69 var ar = this.xcls.split(".");
70 this.xcls = ar[ar.length-1];
75 this.cur_line = parent == null ? 0 : parent.cur_line;
78 this.top = parent == null ? this : parent.top;
79 this.ignoreList = new Gee.ArrayList<string>();
80 this.ignoreWrappedList = new Gee.ArrayList<string>();
81 this.myvars = new Gee.ArrayList<string>();
82 this.vitems = new Gee.ArrayList<Node>();
85 // initialize line data..
86 node.line_start = this.cur_line;
87 node.line_end = this.cur_line;
88 node.lines = new Gee.ArrayList<int>();
89 node.line_map = new Gee.HashMap<int,string>();
91 node.node_lines = new Gee.ArrayList<int>();
92 node.node_lines_map = new Gee.HashMap<int,Node>();
98 string toValaNS(Node item)
100 var ns = item.get("xns") ;
101 //if (ns == "GtkSource") { technically on Gtk3?
102 // return "Gtk.Source";
106 public void toValaName(Node item, int depth =0)
110 var ns = this.toValaNS(item) ;
111 var cls = ns + item.get("xtype");
114 item.xvala_cls = cls;
117 string id = item.get("id").length > 0 ?
118 item.get("id") : "%s%d".printf(item.get("xtype"), this.vcnt);
123 if (id[0] == '*' || id[0] == '+') {
124 item.xvala_xcls = "Xcls_" + id.substring(1);
126 item.xvala_xcls = "Xcls_" + id;
132 this.vitems.add(item);
134 // setting id on top level class changes it classname..
135 // oddly enough we havent really thought about namespacing here.
137 } else if (!item.props.has_key("id")) {
138 // use the file name..
139 item.xvala_xcls = this.file.file_without_namespace;
141 item.xvala_id = this.file.file_without_namespace;
146 if (item.readItems().size < 1) {
149 for(var i =0;i<item.readItems().size;i++) {
150 this.toValaName(item.readItems().get(i), depth+1);
155 * Main entry point to convert a file into a string..
157 public static string mungeFile(JsRender file)
159 if (file.tree == null) {
163 var n = new NodeToVala(file, file.tree, 0, null);
167 n.toValaName(file.tree);
170 GLib.debug("top cls %s / xlcs %s\n ",file.tree.xvala_cls,file.tree.xvala_cls);
171 n.cls = file.tree.xvala_cls;
172 n.xcls = file.tree.xvala_xcls;
177 int child_count = 1; // used to number the children.
178 public string munge ( )
180 //return this.mungeToString(this.node);
181 this.child_count = 1;
185 this.ignore("xtype");
188 this.namespaceHeader();
192 this.addTopProperties();
194 this.addPlusProperties();
197 this.addWrappedCtor(); // var this.el = new XXXXX()
199 this.addInitMyVars();
200 this.addWrappedProperties();
202 this.addAutoShow(); // autoshow menuitems
207 this.addUserMethods();
209 this.namespaceFooter();
215 public string mungeChild( Node cnode)
217 var x = new NodeToVala(this.file, cnode, this.depth+1, this);
220 public void addLine(string str= "")
223 if (str.contains("\n")) {
224 this.addMultiLine(str);
228 if (BuilderApplication.opt_bjs_compile != null) {
229 this.ret += "/*%d*/ ".printf(this.cur_line) + str + "\n";
231 this.ret += str + "\n";
234 public void addMultiLine(string str= "")
237 this.cur_line += str.split("\n").length;
238 //this.ret += "/*%d*/ ".printf(l) + str + "\n";
239 this.ret += str + "\n";
242 public void namespaceHeader()
244 if (this.depth > 0 || this.file.file_namespace == "") {
247 this.addLine("namespace " + this.file.file_namespace);
251 public void namespaceFooter()
253 if (this.depth > 0 || this.file.file_namespace == "") {
259 public void globalVars()
261 if (this.depth > 0) {
264 // Global Vars..??? when did this get removed..?
265 //this.ret += this.inpad + "public static " + this.xcls + " " + this.node.xvala_id+ ";\n\n";
267 this.addLine(this.inpad + "static " + this.xcls + " _" + this.node.xvala_id+ ";");
276 // class xxx { WrappedGtk el; }
277 this.node.line_start = this.cur_line;
279 this.top.node.setNodeLine(this.cur_line, this.node);
281 this.addLine(this.inpad + "public class " + this.xcls + " : Object");
282 this.addLine(this.inpad + "{");
285 this.addLine(this.pad + "public " + this.cls + " el;");
287 this.addLine(this.pad + "private " + this.top.xcls + " _this;");
299 this.addLine(pad + "public static " + xcls + " singleton()");
300 this.addLine(this.pad + "{");
301 this.addLine(this.ipad + "if (_" + this.node.xvala_id + " == null) {");
302 this.addLine(this.ipad + " _" + this.node.xvala_id + "= new "+ this.xcls + "();"); // what about args?
303 this.addLine(this.ipad + "}");
304 this.addLine(this.ipad + "return _" + this.node.xvala_id +";");
305 this.addLine(this.pad + "}");
309 * when ID is used... on an element, it registeres a property on the top level...
310 * so that _this.ID always works..
313 void addTopProperties()
315 if (this.depth > 0) {
318 // properties - global..??
320 var iter = this.vitems.list_iterator();
325 if (!n.props.has_key("id") || n.xvala_id.length < 0) {
329 if (n.xvala_id[0] == '*') {
332 if (n.xvala_id[0] == '+') {
335 this.addLine(this.pad + "public " + n.xvala_xcls + " " + n.xvala_id + ";");
341 * create properties that are not 'part of the wrapped element.
348 GLib.debug("callinged addMhyVars");
351 this.addLine(this.ipad + "// my vars (def)");
355 var cls = Palete.Gir.factoryFqn((Project.Gtk) this.file.project, this.node.fqn());
358 GLib.debug("Gir factory failed to find class %s", this.node.fqn());
365 var iter = this.node.props.map_iterator();
366 while (iter.next()) {
368 var prop = iter.get_value();
370 if (this.shouldIgnore(prop.name)) {
374 // user defined method
375 if (prop.ptype == NodePropType.METHOD) {
378 if (prop.ptype == NodePropType.SPECIAL) {
382 if (prop.ptype == NodePropType.SIGNAL) {
383 this.node.setLine(this.cur_line, "p", prop.name);
384 this.addLine(this.pad + "public signal " + prop.rtype + " " + prop.name + " " + prop.val + ";");
386 this.ignore(prop.name);
390 GLib.debug("Got myvars: %s", prop.name.strip());
392 if (prop.rtype.strip().length < 1) {
396 // is it a class property...
397 if (cls != null && cls.props.has_key(prop.name) && prop.ptype != NodePropType.USER) {
401 this.myvars.add(prop.name);
402 prop.start_line = this.cur_line;
404 this.node.setLine(this.cur_line, "p", prop.name);
406 this.addLine(this.pad + "public " + prop.rtype + " " + prop.name + ";"); // definer - does not include value.
409 prop.end_line = this.cur_line;
410 this.ignore(prop.name);
416 // if id of child is '+' then it's a property of this..
417 void addPlusProperties()
419 if (this.node.readItems().size < 1) {
422 var iter = this.node.readItems().list_iterator();
423 while (iter.next()) {
426 if (ci.xvala_id[0] != '+') {
427 continue; // skip generation of children?
431 this.addLine(this.pad + "public " + ci.xvala_xcls + " " + ci.xvala_id.substring(1) + ";");
437 * add the constructor definition..
449 this.addLine(this.pad + "// ctor");
451 if (this.node.has("* args")) {
452 // not sure what this is supposed to be ding..
454 cargs_str = this.node.get("* args");
455 //var ar = this.node.get("* args");.split(",");
456 //for (var ari =0; ari < ar.length; ari++) {
457 // cargs += (ar[ari].trim().split(" ").pop();
461 if (this.depth < 1) {
463 // top level - does not pass the top level element..
464 this.addLine(this.pad + "public " + this.xcls + "(" + cargs_str +")");
465 this.addLine(this.pad + "{");
467 if (cargs_str.length > 0) {
468 cargs_str = ", " + cargs_str;
470 // for sub classes = we passs the top level as _owner
471 this.addLine(this.pad + "public " + this.xcls + "(" + this.top.xcls + " _owner " + cargs_str + ")");
472 this.addLine(this.pad + "{");
478 * make sure _this is defined..
484 this.addLine( this.ipad + "_this = this;");
487 // for non top level = _this point to owner, and _this.ID is set
489 this.addLine( this.ipad + "_this = _owner;");
491 if (this.node.props.has_key("id")
493 this.node.xvala_id != ""
495 this.node.xvala_id[0] != '*'
497 this.node.xvala_id[0] != '+'
499 this.addLine( this.ipad + "_this." + node.xvala_id + " = this;");
506 * Initialize this.el to point to the wrapped element.
511 void addWrappedCtor()
514 // this may need to look up properties to fill in the arguments..
515 // introspection does not workk..... - as things like gtkmessagedialog
517 if (cls == 'Gtk.Table') {
519 var methods = this.palete.getPropertiesFor(cls, 'methods');
521 print(JSON.stringify(this.palete.proplist[cls], null,4));
526 // ctor can still override.
527 if (this.node.has("* ctor")) {
528 this.node.setLine(this.cur_line, "p", "* ctor");
529 this.addLine(this.ipad + "this.el = " + this.node.get("* ctor")+ ";");
533 this.node.setLine(this.cur_line, "p", "* xtype");;
535 // is the wrapped element a struct?
537 var ncls = Palete.Gir.factoryFqn((Project.Gtk) this.file.project, this.node.fqn());
538 if (ncls != null && ncls.nodetype == "Struct") {
539 // we can use regular setters to apply the values.
540 this.addLine(this.ipad + "this.el = " + this.node.fqn() + "();");
548 switch(this.node.fqn()) {
550 // FIXME -- these are all GTK3 - can be removed when I get rid of them..
552 var is_entry = this.node.has("has_entry") && this.node.get_prop("has_entry").val.down() == "true";
554 break; // regular ctor.
556 this.ignoreWrapped("has_entry");
557 ctor = ".with_entry";
561 case "Gtk.ListStore":
562 case "Gtk.TreeStore":
564 // not sure if this works.. otherwise we have to go with varargs and count + vals...
565 if (this.node.has("* types")) {
566 args_str = this.node.get_prop("* types").val;
568 if (this.node.has("n_columns") && this.node.has("columns")) { // old value?
569 args_str = " { " + this.node.get_prop("columns").val + " } ";
570 this.ignoreWrapped("columns");
571 this.ignoreWrapped("n_columns");
574 this.addLine(this.ipad + "this.el = new " + this.node.fqn() + ".newv( " + args_str + " );");
578 case "Gtk.LinkButton": // args filled with values.
579 if (this.node.has("label")) {
580 ctor = ".with_label";
587 var default_ctor = Palete.Gir.factoryFqn((Project.Gtk) this.file.project, this.node.fqn() + ctor);
590 // use the default ctor - with arguments (from properties)
592 if (default_ctor != null && default_ctor.paramset != null && default_ctor.paramset.params.size > 0) {
594 foreach(var param in default_ctor.paramset.params) {
597 GLib.debug("building CTOR ARGS: %s, %s", n, param.is_varargs ? "VARARGS": "");
598 if (n == "___") { // for some reason our varargs are converted to '___' ...
602 if (this.node.has(n)) { // node does not have a value
604 this.ignoreWrapped(n);
607 var v = this.node.get(n);
609 if (param.type == "string") {
610 v = "\"" + v.escape("") + "\"";
612 if (v == "TRUE" || v == "FALSE") {
620 var propnode = this.node.findProp(n);
621 if (propnode != null) {
624 var pname = this.addPropSet(propnode, propnode.has("id") ? propnode.get_prop("id").val : "");
625 args += (pname + ".el") ;
626 if (!propnode.has("id")) {
627 this.addLine(this.ipad + pname +".ref();");
632 this.ignoreWrapped(n);
641 if (param.type.contains("int")) {
645 if (param.type.contains("float")) {
649 if (param.type.contains("bool")) {
650 args += "true"; // always default to true?
653 // any other types???
663 this.node.setLine(this.cur_line, "p", "* xtype");
664 this.addLine(this.ipad + "this.el = new " + this.node.fqn() + "( "+ string.joinv(", ",args) + " );") ;
668 // default ctor with no params..
669 if (default_ctor != null && ctor != ".new" ) {
670 this.node.setLine(this.cur_line, "p", "* xtype");
672 this.addLine(this.ipad + "this.el = new " + this.node.fqn() + ctor + "( );") ;
677 this.addLine(this.ipad + "this.el = new " + this.node.fqn() + "(" + args_str + ");");
683 public static Gee.ArrayList<string> menuitem_children = null;
687 if (menuitem_children == null) {
688 menuitem_children = new Gee.ArrayList<string>();
689 menuitem_children.add("Gtk.MenuItem");
690 var gir = this.file.project.palete.getClass("Gtk.MenuItem");
692 foreach(var impl in gir.implementations) {
693 menuitem_children.add(impl);
698 if (menuitem_children.contains(this.node.fqn())) {
699 this.addLine(this.ipad + "this.el.show();");
706 //var meths = this.palete.getPropertiesFor(item['|xns'] + '.' + item.xtype, 'methods');
707 //print(JSON.stringify(meths,null,4));Seed.quit();
711 // initialize.. my vars..
713 this.addLine( this.ipad + "// my vars (dec)");
715 var iter = this.myvars.list_iterator();
721 var prop = this.node.props.get(k);
723 var v = prop.val.strip();
728 // at this point start using
730 if (v == "FALSE" || v == "TRUE") {
733 //FIXME -- check for raw string.. "string XXXX"
735 // if it's a string...
737 prop.start_line = this.cur_line;
738 this.addLine(this.ipad + "this." + prop.name + " = " + v +";");
739 prop.end_line = this.cur_line;
747 void addWrappedProperties()
749 var cls = Palete.Gir.factoryFqn((Project.Gtk) this.file.project, this.node.fqn());
751 GLib.debug("Skipping wrapped properties - could not find class %s" , this.node.fqn());
754 // what are the properties of this class???
756 this.addLine(this.ipad + "// set gobject values");
759 var iter = cls.props.map_iterator();
760 while (iter.next()) {
761 var p = iter.get_key();
762 //print("Check Write %s\n", p);
763 if (!this.node.has(p)) {
766 if (this.shouldIgnoreWrapped(p)) {
773 var prop = this.node.get_prop(p);
776 // user defined properties.
777 if (prop.ptype == NodePropType.USER) {
783 var is_raw = prop.ptype == NodePropType.RAW;
785 // what's the type.. - if it's a string.. then we quote it..
786 if (iter.get_value().type == "string" && !is_raw) {
787 v = "\"" + v.escape("") + "\"";
789 if (v == "TRUE" || v == "FALSE") {
792 if (iter.get_value().type == "float" && v[v.length-1] != 'f') {
796 prop.start_line = this.cur_line;
797 this.addLine("%sthis.el.%s = %s;".printf(ipad,p,v)); // // %s, iter.get_value().type);
798 prop.end_line = this.cur_line;
806 * pack the children into the parent.
808 * if the child's id starts with '*' then it is not packed...
809 * - this allows you to define children and add them manually..
815 if (this.node.readItems().size < 1) {
818 this.pane_number = 0;
819 var cols = this.node.has("* columns") ? int.max(1, int.parse(this.node.get_prop("* columns").val)) : 1;
824 foreach(var child in this.node.readItems()) {
829 if (child.xvala_id[0] == '*') {
830 continue; // skip generation of children?
833 // probably added in ctor..
834 if (child.has("* prop") && this.shouldIgnoreWrapped(child.get_prop("* prop").val)) {
837 // create the element..
839 // this is only needed if it does not have an ID???
840 var childname = this.addPropSet(child, child.has("id") ? child.get_prop("id").val : "") ;
842 if (child.has("* prop")) {
845 // fixme special packing!??!?!
846 if (child.get_prop("* prop").val.contains("[]")) {
847 // currently these 'child props
848 // used for label[] on Notebook
849 // used for button[] on Dialog?
852 this.packChild(child, childname, 0, 0, child.get_prop("* prop").val); /// fixme - this is a bit speciall...
858 this.ignoreWrapped(child.get_prop("* prop").val);
860 this.addLine(ipad + "this.el." + child.get_prop("* prop").val + " = " + childname + ".el;");
863 if (!child.has("id")) {
864 this.addLine(this.ipad + childname +".ref();");
866 this.packChild(child, childname, cols, colpos);
868 if (child.has("colspan")) {
869 colpos += int.parse(child.get_prop("colspan").val);
875 // this.{id - without the '+'} = the element...
881 string addPropSet(Node child, string child_name)
886 if (child.has("* args")) {
888 var ar = child.get_prop("* args").val.split(",");
889 for (var ari = 0 ; ari < ar.length; ari++ ) {
890 var arg = ar[ari].split(" ");
891 xargs += "," + arg[arg.length -1];
895 var childname = "child_" + "%d".printf(this.child_count++);
897 if (child_name == "") {
898 prefix = "var " + childname + " = ";
901 this.addLine(this.ipad + prefix + "new " + child.xvala_xcls + "( _this " + xargs + ");" );
903 // add a ref... (if 'id' is not set... to a '+' ?? what does that mean? - fake ids?
904 // remove '+' support as I cant remember what it does!!!
905 //if (child.xvala_id.length < 1 ) {
906 // this.addLine(this.ipad + childname +".ref();"); // we need to reference increase unnamed children...
908 //if (child.xvala_id[0] == '+') {
909 // this.addLine(this.ipad + "this." + child.xvala_id.substring(1) + " = " + childname+ ";");
914 return child_name == "" ? childname : ("_this." + child_name);
920 void packChild(Node child, string childname, int cols, int colpos, string propname= "")
923 GLib.debug("packChild %s=>%s", this.node.fqn(), child.fqn());
924 // forcing no packing? - true or false? -should we just accept false?
925 if (child.has("* pack") && child.get("* pack").down() == "false") {
926 return; // force no packing
928 if (child.has("* pack") && child.get("* pack").down() == "true") {
929 return; // force no packing
932 // BC really - don't want to support this anymore.
933 if (child.has("* pack")) {
935 string[] packing = { "add" };
936 if (child.has("* pack")) {
937 packing = child.get("* pack").split(",");
940 var pack = packing[0];
941 this.addLine(this.ipad + "this.el." + pack.strip() + " ( " + childname + ".el " +
942 (packing.length > 1 ?
943 (", " + string.joinv(",", packing).substring(pack.length+1))
949 var childcls = this.file.project.palete.getClass(child.fqn()); // very trusting..
950 if (childcls == null) {
954 var is_event = childcls.inherits.contains("Gtk.EventController") || childcls.implements.contains("Gtk.EventController");
956 this.addLine(this.ipad + "this.el.add_controller( %s.el );".printf(childname) );
961 switch (this.node.fqn()) {
967 var x = child.has("x") ? child.get_prop("x").val : "0";
968 var y = child.has("y") ? child.get_prop("y").val : "0";
969 this.addLine(this.ipad + "this.el.put( %s.el, %s, %s );".printf(childname,x,y) );
975 var named = child.has("stack_name") ? child.get_prop("stack_name").val.escape() : "";
976 var title = child.has("stack_title") ? child.get_prop("stack_title").val.escape() : "";
977 if (title.length > 0) {
978 this.addLine(this.ipad + "this.el.add_titled( %s.el, \"%s\", \"%s\" );".printf(childname,named,title));
980 this.addLine(this.ipad + "this.el.add_named( %s.el, \"%s\" );".printf(childname,named));
984 case "Gtk.Notebook": // use label
985 var label = child.has("notebook_label") ? child.get_prop("notebook_label").val.escape() : "";
986 this.addLine(this.ipad + "this.el.append_page( %s.el, new Gtk.Label(\"%s\"));".printf(childname, label));
990 case "Gtk.TreeView": // adding TreeViewColumns
991 this.addLine(this.ipad + "this.el.append_column( " + childname + ".el );");
994 case "Gtk.TreeViewColumn": //adding Renderers - I think these are all proprerties of the renderer used...
995 if (child.has("markup_column") && int.parse(child.get_prop("markup_column").val) > -1) {
996 this.addLine(this.ipad + "this.el.add_attribute( %s.el, \"markup\", %s );".printf(childname, child.get_prop("markup_column").val));
998 if (child.has("text_column") && int.parse(child.get_prop("text_column").val) > -1) {
999 this.addLine(this.ipad + "this.el.add_attribute( %s.el, \"text\", %s );".printf(childname, child.get_prop("text_column").val));
1001 if (child.has("pixbuf_column") && int.parse(child.get_prop("pixbuf_column").val) > -1) {
1002 this.addLine(this.ipad + "this.el.add_attribute( %s.el, \"pixbuf\", %s );".printf(childname, child.get_prop("pixbuf_column").val));
1004 if (child.has("pixbuf_column") && int.parse(child.get_prop("active_column").val) > -1) {
1005 this.addLine(this.ipad + "this.el.add_attribute( %s.el, \"active\", %s );".printf(childname, child.get_prop("active_column").val));
1007 if (child.has("background_column") && int.parse(child.get_prop("background_column").val) > -1) {
1008 this.addLine(this.ipad + "this.el.add_attribute( %s.el, \"background-rgba\", %s );".printf(childname, child.get_prop("background_column").val));
1010 this.addLine(this.ipad + "this.el.add( " + childname + ".el );");
1015 if (propname == "buttons[]") {
1016 var resp_id = int.parse(childname.replace("child_", ""));
1017 if (child.has("* response_id")) {
1018 resp_id = int.parse(child.get_prop("* response_id").val);
1020 this.addLine(this.ipad + "this.el.add_action_widget( %s.el, %d);".printf(childname,resp_id) );
1025 this.addLine(this.ipad + "this.el.get_content_area().add( " + childname + ".el );");
1033 // known working with GTK4 !
1034 case "Gtk.HeaderBar": // it could be end... - not sure how to hanle that other than overriding the pack method?
1035 this.addLine(this.ipad + "this.el.pack_start( "+ childname + ".el );");
1039 this.addLine(this.ipad + "this.el.append_item( "+ childname + ".el );");
1044 switch(this.pane_number) {
1046 this.addLine(this.ipad + "this.el.pack_start( %s.el );".printf(childname));
1049 this.addLine(this.ipad + "this.el.pack_end( %s.el );".printf(childname));
1057 case "Gtk.ColumnView":
1058 this.addLine(this.ipad + "this.el.append_column( "+ childname + ".el );");
1062 var x = "%d".printf(colpos % cols);
1063 var y = "%d".printf(( colpos - (colpos % cols) ) / cols);
1064 var w = child.has("colspan") ? child.get_prop("colspan").val : "1";
1066 this.addLine(this.ipad + "this.el.attach( %s.el, %s, %s, %s, %s );".printf(childname ,x,y, w, h) );
1070 // gtk4 uses append!!!! - gtk3 - uses add..
1071 this.addLine(this.ipad + "this.el.append( "+ childname + ".el );");
1080 // fixme GtkDialog?!? buttons[]
1082 // fixme ... add case "Gtk.RadioButton": // group_id ??
1090 if (!this.node.has("* init")) {
1094 this.addLine(ipad + "// init method");
1096 this.node.setLine(this.cur_line, "p", "init");
1098 var init = this.node.get_prop("* init");
1099 init.start_line = this.cur_line;
1100 this.addMultiLine(ipad + this.padMultiline(ipad, init.val) );
1101 init.end_line = this.cur_line;
1105 if (this.node.listeners.size < 1) {
1110 this.addLine(ipad + "//listeners");
1114 var iter = this.node.listeners.map_iterator();
1115 while (iter.next()) {
1116 var k = iter.get_key();
1117 var prop = iter.get_value();
1120 prop.start_line = this.cur_line;
1121 this.node.setLine(this.cur_line, "l", k);
1122 this.addMultiLine(this.ipad + "this.el." + k + ".connect( " +
1123 this.padMultiline(this.ipad,v) +");");
1124 prop.end_line = this.cur_line;
1131 this.addLine(this.pad + "}");
1136 * Standardize this crap...
1138 * standard properties (use to set)
1139 * If they are long values show the dialog..
1142 * bool is_xxx :: can show a pulldown.. (true/false)
1144 * $ string html = string with value interpolated eg. baseURL + ".."
1145 * Clutter.ActorAlign x_align (typed) -- shows pulldowns if type is ENUM?
1146 * $ untypedvalue = javascript untyped value...
1147 * _ string html ... = translatable..
1150 * object properties (not part of the GOjbect being wrapped?
1151 * # Gee.ArrayList<Xcls_fileitem> fileitems
1156 * methods -- always text editor..
1164 * * init -- big string?
1166 * event handlers (listeners)
1171 * +XXXX -- indicates it's a instance property / not glob...
1172 * *XXXX -- skip writing glob property (used as classes that can be created...)
1177 void addUserMethods()
1180 this.addLine(this.pad + "// user defined functions");
1182 // user defined functions...
1183 var iter = this.node.props.map_iterator();
1184 while(iter.next()) {
1185 var prop = iter.get_value();
1186 if (this.shouldIgnore(prop.name)) {
1189 // HOW TO DETERIME if its a method?
1190 if (prop.ptype != NodePropType.METHOD) {
1191 //strbuilder("\n" + pad + "// skip " + k + " - not pipe \n");
1195 // function in the format of {type} (args) { .... }
1199 prop.start_line = this.cur_line;
1200 this.node.setLine(this.cur_line, "p", prop.name);
1201 this.addMultiLine(this.pad + "public " + prop.rtype + " " + prop.name + " " + this.padMultiline(this.pad, prop.val));;
1202 prop.end_line = this.cur_line;
1209 this.node.line_end = this.cur_line;
1210 this.node.sortLines();
1213 if (this.depth > 0) {
1214 this.addLine(this.inpad + "}");
1217 var iter = this.node.readItems().list_iterator();
1219 while (iter.next()) {
1220 this.addMultiLine(this.mungeChild(iter.get()));
1223 if (this.depth < 1) {
1224 this.addLine(this.inpad + "}");
1229 string padMultiline(string pad, string str)
1231 var ar = str.strip().split("\n");
1232 return string.joinv("\n" + pad , ar);
1235 void ignore(string i) {
1236 this.ignoreList.add(i);
1239 void ignoreWrapped(string i) {
1240 this.ignoreWrappedList.add(i);
1243 bool shouldIgnore(string i)
1245 return ignoreList.contains(i);
1247 bool shouldIgnoreWrapped(string i)
1249 return ignoreWrappedList.contains(i);