-public class JsRender.Node : GLib.Object {
+public class JsRender.Node : GLib.Object
+{
public static int uid_count = 0;
private Gee.ArrayList<Node> items; // child items..
public GLib.ListStore childstore; // must be kept in sync with items
public GLib.ListStore? propstore; // must be kept in sync with items
- public string xvala_cls;
- public string xvala_xcls; // 'Xcls_' + id;
- public string xvala_id; // item id or ""
+ public string xvala_cls; // set by node to vala
+ public string xvala_xcls; // 'Xcls_' + id; // set by nodetoVala
+ public string xvala_id; // item id or "" // set by nodetovala
// line markers..
public int line_start;
public Gee.HashMap<int,string> line_map; // store of l:xxx or p:.... // fixme - not needed as we can store line numbers in props now.
public Gee.ArrayList<int> node_lines;
public Gee.HashMap<int,Node> node_lines_map; // store of l:xxx or p:....
+ public JsRender? file = null;
+
+ public string node_pad = "";
private int _updated_count = 0;
public int updated_count {
}
set {
this.nodeTitleProp = ""; // ?? should trigger set?
- this.iconFilename = "";
- this. _updated_count = value;
+ this.iconResourceName = "";
+ this._updated_count = value;
+
+
+ //GLib.debug("Update Node %d p%d - rev %d", this.oid, this.parent != null ? this.parent.oid : -1, value);
+ if (this.parent != null) {
+ this.parent.updated_count++; // will recurse up.
+ } else {
+ if (this.file != null) {
+ this.file.updateUndo();
+ }
+ }
}
} // changes to this trigger updates on the tree..
-
+
+ public string as_source = "";
+ public int as_source_version = -1;
+ public int as_source_start_line = -1;
+
+
+
+ //public signal void version_changed();
+
public Node()
{
this.items = new Gee.ArrayList<Node>();
}
+ public bool has_parent(Node n)
+ {
+ if (this.parent == null) {
+ return false;
+ }
+ if (this.parent.oid == n.oid) {
+ return true;
+ }
+
+
+ return this.parent.has_parent(n);
+ }
+
+
public Gee.ArrayList<Node> readItems()
{
return this.items; // note should not modify add/remove from this directly..
+
//GLib.debug("setLine %d, %s", line, type + ":" + prop);
}
public void sortLines() {
for(var i= 0; i < this.propstore.get_n_items();i++) {
var p = (NodeProp) this.propstore.get_item(i);
- GLib.debug("prop %s lines %d -> %d", p.name, p.start_line, p.end_line);
+ //GLib.debug("prop %s lines %d -> %d", p.name, p.start_line, p.end_line);
if (p.start_line > line) {
continue;
}
owned get { return this.fqn(); }
private set {}
}
-
+ public string NS { // for sorting
+ owned get { return this.props.has_key("xns") ? this.props.get("xns").val : ""; }
+ private set {}
+ }
public string fqn()
{
if (!this.hasXnsType ()) {
if ( this.parent.childstore.find(this, out pos)) {
this.parent.childstore.remove(pos);
}
-
+ this.parent.updated_count++;
this.parent.items = nlist;
this.parent = null;
case PROP:
case RAW: // should they be the same?
- props += "\n\t" + GLib.Markup.escape_text(prop.rtype) +
+ props += "\n\t" + (prop.rtype != null && prop.rtype.length > 0 ? GLib.Markup.escape_text(prop.rtype) : "") +
" <b>" + GLib.Markup.escape_text(i) +"</b> : " +
- GLib.Markup.escape_text(val.split("\n")[0]);
+ (val.length > 0 ? GLib.Markup.escape_text(val.split("\n")[0]) : "");
break;
-
-
+
case METHOD :
- funcs += "\n\t" + GLib.Markup.escape_text(prop.rtype) +
+ funcs += "\n\t" + (prop.rtype != null && prop.rtype.length > 0 ? GLib.Markup.escape_text(prop.rtype) : "") +
" <b>" + GLib.Markup.escape_text(i) +"</b> : " +
- GLib.Markup.escape_text(val.split("\n")[0]);
+ (val.length > 0 ? GLib.Markup.escape_text(val.split("\n")[0]) : "");
break;
case USER : // user defined.
uprops += "\n\t<b>" +
GLib.Markup.escape_text(i) +"</b> : " +
- GLib.Markup.escape_text(val.split("\n")[0]);
+ (val.length > 0 ? GLib.Markup.escape_text(val.split("\n")[0]) : "");
break;
case SPECIAL : // * prop| args | ctor | init
spec += "\n\t<b>" +
GLib.Markup.escape_text(i) +"</b> : " +
- GLib.Markup.escape_text(val.split("\n")[0]);
+ (val.length > 0 ? GLib.Markup.escape_text(val.split("\n")[0]) : "");
break;
case LISTENER : return ""; // always raw...
}
// used by trees to display icons?
// needs more thought?!?
- public string iconFilename {
+ public string iconResourceName {
set {
// NOOp ??? should
}
var clsb = clsname.split(".");
var sub = clsb.length > 1 ? clsb[1].down() : "";
- var fn = "/usr/share/glade/pixmaps/hicolor/16x16/actions/widget-gtk-" + sub + ".png";
+ var fn = "/glade-icons/widget-gtk-" + sub + ".png";
//if (FileUtils.test (fn, FileTest.IS_REGULAR)) {
return fn;
//}
public void insertChild(int pos, Node child)
{
+ child.parent = this;
this.items.insert(pos, child);
this.childstore.insert(pos, child);
- child.parent = this;
+
}
public void appendChild(Node child)
{
+ child.parent = this;
this.items.add( child);
this.childstore.append(child);
- child.parent = this;
+
}
- public void loadProps(GLib.ListStore model)
+ public void loadProps(GLib.ListStore model, Project.Project project)
{
// fixme sorting?? - no need to loop twice .. just use sorting.!
this.propstore = model;
for(var i = 0; i < oldstore.n_items; i++ ) {
var it = (NodeProp) oldstore.get_item(i);
+ it.update_is_valid_ptype(project);
model.append(it);
}
public void add_prop(NodeProp prop)
{
- if (this.has_prop_key(prop)) {
- GLib.error("duplicate key - can not add - call has_prop_key first");
+ if (this.has_prop_key(prop) && !prop.to_index_key().has_suffix("[]")) {
+ GLib.warning("duplicate key' %s'- can not add - call has_prop_key first", prop.to_index_key());
+ return;
}
prop.parent = this;
this.propstore.append(prop);