src/Builder4/WindowState.vala
authorAlan Knowles <alan@roojs.com>
Wed, 18 Feb 2015 06:15:29 +0000 (14:15 +0800)
committerAlan Knowles <alan@roojs.com>
Wed, 18 Feb 2015 06:15:29 +0000 (14:15 +0800)
src/Builder4/WindowState.vala

index 38cfcd6..9c33487 100644 (file)
@@ -7,9 +7,19 @@
 public class WindowState : Object 
 {
     public MainWindow win;
-    
 
-    
+    public enum State {
+       OBJECT,
+    };
+
+    public State state;
+       
+    public Xcls_WindowLeftTree left_tree;
+
+    left_props
+    code_editor
+    rightpalete
+       
         // my vars (def)
 
     // ctor 
@@ -22,9 +32,91 @@ public class WindowState : Object
     }
 
 
+    // left tree
+
+    public void leftTreeInit()
+    {
+        
+       this.left_tree = new Xcls_WindowLeftTree();
+       this.left_tree.ref();
+       this.left_tree.main_window = _this.win;
+       
+       this.win.tree.el.pack_start(this.left_tree.el,true, true,0);
+       this.left_tree.el.show_all();
+       
+       this.left_tree.before_node_change.connect(() => {
+           return this.leftTreeBeforeChange();
+
+       });
+
+       this.left_tree.node_selected.connect((sel) => {
+       
+           print("node_selected called %s\n", (sel == null) ? "NULL" : "a value");
+       
+           if (sel == null) {
+               this.left_props.el.hide();
+           } 
+           this.left_props.el.show();
+           this.left_props.load(this.left_tree.getActiveFile(), sel);
+           switch (this.state) {
+               case State.OBJECT: 
+                     
+                    if (sel == null) {
+                       this.rightpalete.clear();
+                       break;
+                   }
+                   this.rightpalete.load(this.left_tree.getActiveFile().palete(), sel.fqn());
+                   break;
+                    
+                   
+              case "addprop":
+                   if (sel == null) {
+                       this.add_props.clear();
+                       break;
+                   }
+                   this.add_props.show(this.left_tree.getActiveFile().palete(), "props", sel.fqn());
+                   break;
+                   
+              case "addlistener":
+                   if (sel == null) {
+                       this.add_props.clear();
+                       break;
+                   }
+                   this.add_props.show(_this.left_tree.getActiveFile().palete(), "signals", sel.fqn());
+                   break;
+
+              case "codeedit":
+                  
+                   this.hideCodeEdit();
+                   break;
+                  
+                                   
+           }
+           return  ;
+             
+       });
+
+    }
+
+    public bool leftTreeBeforeChange(sel)
+    {
+           if (this.state != "codeedit") {
+               this.left_props.finish_editing();
+               return true;
+           }
+           if (!this.code_editor.saveContents()) {
+               return false;
+           }
+           return false;
+    }
+    public void leftTreeNodeSelected()
+    {
+
+
+    }
     // -----------  properties
     // listener uses the properties 
-    public propsInit()
+    public void propsInit()
     {
        // Add properties
            this.win.add_props  = new Xcls_WindowAddProp();
@@ -39,8 +131,9 @@ public class WindowState : Object
            _this.win.add_props.select.connect( (key,type,skel, etype) => {
                this.win.left_props.addProp(etype, key, skel, type);
            });
+       
     }
-    public propsShow()
+    public void propsShow()
     {
 
     }