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 ",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) {
106 case "Adw": // works if you call adw.init() in main!
114 if (gdata.fqn() == ("Gtk.ListStore")) {
118 // should really use GXml...
119 var obj = this.create_element("object");
120 //var id = this.node.uid();
121 var skip_props = false;
122 if (gdata.inherits.contains("Gtk.Native")) {
124 obj->set_prop("class", "GtkFrame");
128 obj->set_prop("class", cls);
130 obj->set_prop("id", "w" + this.node.oid.to_string());
131 this.parent->add_child(obj);
133 var props = Palete.Gir.factoryFqn(this.project, this.node.fqn()).props;
136 var pviter = props.map_iterator();
137 while (!skip_props && pviter.next()) {
139 //GLib.debug ("Check: " +cls + "::(" + pviter.get_value().propertyof + ")" + pviter.get_key() + " " );
141 // skip items we have already handled..
142 if (!this.node.has(pviter.get_key())) {
145 var k = pviter.get_key();
146 var prop = props.get(k);
147 var val = this.node.get(pviter.get_key()).strip();
148 // for Enums - we change it to lowercase, and remove all the previous bits.. hopefully might work.
149 if (prop.type.contains(".") && val.contains(".")) {
150 var typ = Palete.Gir.factoryFqn(this.project, prop.type);
151 if (typ.nodetype == "Enum") {
152 var bits = val.split(".");
153 val = bits[bits.length-1].down();
157 // value for model seems to cause problems...(it's ok as a property?)
163 var domprop = this.create_element("property");
164 domprop->set_prop("name", k);
168 domprop->add_child(new Xml.Node.text(val));
169 obj->add_child(domprop);
177 pack = this.packString();
184 var items = this.node.readItems();
185 for (var i = 0; i < items.size; i++ ) {
186 var cn = items.get(i);
187 var child = this.create_element("child");
188 if (cls == "GtkWindow" && cn.fqn() == "Gtk.HeaderBar") {
189 child->set_prop("type", "titlebar");
193 this.mungeChild(cn, child);
194 if (child->child_element_count() < 1) {
197 obj->add_child(child);