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) {
102 // what namespaces are supported
103 switch(this.node.NS) {
113 if (gdata.fqn() == ("Gtk.ListStore")) {
117 // should really use GXml...
118 var obj = this.create_element("object");
119 //var id = this.node.uid();
120 var skip_props = false;
121 if (gdata.inherits.contains("Gtk.Native")) {
123 obj->set_prop("class", "GtkFrame");
127 obj->set_prop("class", cls);
129 obj->set_prop("id", "w" + this.node.oid.to_string());
130 this.parent->add_child(obj);
132 var props = Palete.Gir.factoryFqn(this.project, this.node.fqn()).props;
135 var pviter = props.map_iterator();
136 while (!skip_props && pviter.next()) {
138 //GLib.debug ("Check: " +cls + "::(" + pviter.get_value().propertyof + ")" + pviter.get_key() + " " );
140 // skip items we have already handled..
141 if (!this.node.has(pviter.get_key())) {
144 var k = pviter.get_key();
145 var prop = props.get(k);
146 var val = this.node.get(pviter.get_key()).strip();
147 // for Enums - we change it to lowercase, and remove all the previous bits.. hopefully might work.
148 if (prop.type.contains(".") && val.contains(".")) {
149 var typ = Palete.Gir.factoryFqn(this.project, prop.type);
150 if (typ.nodetype == "Enum") {
151 var bits = val.split(".");
152 val = bits[bits.length-1].down();
159 var domprop = this.create_element("property");
160 domprop->set_prop("name", k);
164 domprop->add_child(new Xml.Node.text(val));
165 obj->add_child(domprop);
173 pack = this.packString();
180 var items = this.node.readItems();
181 for (var i = 0; i < items.size; i++ ) {
182 var cn = items.get(i);
183 var child = this.create_element("child");
184 if (cls == "GtkWindow" && cn.fqn() == "Gtk.HeaderBar") {
185 child->set_prop("type", "titlebar");
189 this.mungeChild(cn, child);
190 if (child->child_element_count() < 1) {
193 obj->add_child(child);