2 This kind of works - however there are issues with embedding gladeui that do not seem fixable.
3 - rendering is borked for windows - they detach for some reason.
4 - selecting stuff and drag etc. would probably be complicated...
8 public class JsRender.NodeToGlade : Object {
14 public NodeToGlade( Project.Gtk project, Node node, Xml.Node* parent)
18 this.project = project;
23 public static string mungeFile(JsRender file)
25 if (file.tree == null) {
29 var n = new NodeToGlade( (Project.Gtk) file.project, file.tree, null);
31 ///n.toValaName(file.tree);
34 GLib.debug("top cls %s / xlcs %s\n ",file.tree.xvala_cls,file.tree.xvala_cls);
35 //n.cls = file.tree.xvala_cls;
36 //n.xcls = file.tree.xvala_xcls;
42 public string munge ( )
46 var doc = this.mungeNode ();
49 doc->dump_memory_format (out ret, out len, true);
56 public Xml.Doc* mungeChild( Node cnode , Xml.Node* cdom)
58 var x = new NodeToGlade(this.project, cnode, cdom);
61 public static Xml.Ns* ns = null;
64 public Xml.Node* create_element(string n)
66 if (NodeToGlade.ns == null) {
67 Xml.Ns* ns = new Xml.Ns (null, "", "");
68 ns->type = Xml.ElementType.ELEMENT_NODE;
70 Xml.Node* nn = new Xml.Node (ns, n);
75 public Xml.Doc* mungeNode()
79 if (this.parent == null) {
81 doc = new Xml.Doc("1.0");
83 var inf = this.create_element("interface");
84 doc->set_root_element(inf);
85 var req = this.create_element("requires");
86 req->set_prop("lib", "gtk+");
87 req->set_prop("version", "4.1");
91 doc = this.parent->doc;
93 var cls = this.node.fqn().replace(".", "");
95 var gdata = Palete.Gir.factoryFqn(this.project, this.node.fqn());
96 if (gdata == null || !gdata.inherits.contains("Gtk.Buildable")) {
99 if (gdata.inherits.contains("Gtk.Native")&& !is_top) {
105 if (gdata.fqn() == ("Gtk.ListStore")) {
109 // should really use GXml...
110 var obj = this.create_element("object");
111 //var id = this.node.uid();
112 var skip_props = false;
113 if (gdata.inherits.contains("Gtk.Native")) {
115 obj->set_prop("class", "GtkFrame");
119 obj->set_prop("class", cls);
121 obj->set_prop("id", "w" + this.node.oid.to_string());
122 this.parent->add_child(obj);
124 var props = Palete.Gir.factoryFqn(this.project, this.node.fqn()).props;
127 var pviter = props.map_iterator();
128 while (!skip_props && pviter.next()) {
130 //GLib.debug ("Check: " +cls + "::(" + pviter.get_value().propertyof + ")" + pviter.get_key() + " " );
132 // skip items we have already handled..
133 if (!this.node.has(pviter.get_key())) {
136 var k = pviter.get_key();
137 var prop = props.get(k);
138 var val = this.node.get(pviter.get_key()).strip();
139 // for Enums - we change it to lowercase, and remove all the previous bits.. hopefully might work.
140 if (prop.type.contains(".") && val.contains(".")) {
141 var typ = Palete.Gir.factoryFqn(this.project, prop.type);
142 if (typ.nodetype == "Enum") {
143 var bits = val.split(".");
144 val = bits[bits.length-1].down();
151 var domprop = this.create_element("property");
152 domprop->set_prop("name", k);
156 domprop->add_child(new Xml.Node.text(val));
157 obj->add_child(domprop);
165 pack = this.packString();
172 var items = this.node.readItems();
173 for (var i = 0; i < items.size; i++ ) {
174 var cn = items.get(i);
175 var child = this.create_element("child");
176 if (cls == "GtkWindow" && cn.fqn() == "Gtk.HeaderBar") {
177 child->set_prop("type", "titlebar");
181 this.mungeChild(cn, child);
182 if (child->child_element_count() < 1) {
185 obj->add_child(child);