Fix #8087 - notebookpage - glade view should ignore if not tab and child
[roobuilder] / src / JsRender / Node.vala
index 497c435..def3074 100644 (file)
@@ -89,7 +89,8 @@
 
 
 
-public class JsRender.Node : GLib.Object {
+public class JsRender.Node : GLib.Object 
+{
        
 
        public static int uid_count = 0;
@@ -99,9 +100,9 @@ public class JsRender.Node : GLib.Object {
        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;
@@ -110,6 +111,9 @@ public class JsRender.Node : GLib.Object {
        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 { 
@@ -118,15 +122,30 @@ public class JsRender.Node : GLib.Object {
                }
                set  {
                        this.nodeTitleProp = ""; // ?? should trigger set?
-                       this.iconFilename = "";
+                       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++;
+                               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>();
@@ -148,6 +167,20 @@ public class JsRender.Node : GLib.Object {
                
        }
        
+       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..
@@ -209,6 +242,7 @@ public class JsRender.Node : GLib.Object {
                
                
                
+               
                //GLib.debug("setLine %d, %s", line, type + ":" + prop);
        }
        public void sortLines() {
@@ -272,7 +306,7 @@ public class JsRender.Node : GLib.Object {
                
                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;
                        }
@@ -345,7 +379,10 @@ public class JsRender.Node : GLib.Object {
                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 ()) {
@@ -421,7 +458,7 @@ public class JsRender.Node : GLib.Object {
                if ( this.parent.childstore.find(this, out pos)) {
                        this.parent.childstore.remove(pos);
                } 
-               
+               this.parent.updated_count++;
                this.parent.items = nlist;
                this.parent = null;
 
@@ -732,31 +769,30 @@ public class JsRender.Node : GLib.Object {
                                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...
@@ -894,7 +930,7 @@ public class JsRender.Node : GLib.Object {
        }
        // used by trees to display icons?
        // needs more thought?!?
-       public string iconFilename { 
+       public string iconResourceName { 
                set {
                        // NOOp ??? should 
                }
@@ -903,7 +939,7 @@ public class JsRender.Node : GLib.Object {
     
                        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;
                        //}
@@ -924,15 +960,17 @@ public class JsRender.Node : GLib.Object {
        
        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;
+
        }
        
        
@@ -953,7 +991,7 @@ public class JsRender.Node : GLib.Object {
 
        
        
-       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.!
@@ -961,6 +999,7 @@ public class JsRender.Node : GLib.Object {
                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);
                        
                }