resources/RooUsage.txt
[app.Builder.js] / src / Builder4 / WindowLeftTree.vala
index 84c353c..983284b 100644 (file)
@@ -18,9 +18,9 @@ public class Xcls_WindowLeftTree : Object
     public Xcls_LeftTreeMenu LeftTreeMenu;
 
         // my vars (def)
-    public signal bool before_node_change (JsRender.Node? node);
+    public signal bool before_node_change ();
     public signal void changed ();
-    public signal void node_selected (JsRender.Node? node);
+    public signal void node_selected (JsRender.Node? node, string source);
     public Xcls_MainWindow main_window;
 
     // ctor
@@ -77,9 +77,10 @@ public class Xcls_WindowLeftTree : Object
 
             // my vars (def)
         public string dragData;
-        public string[] dropList;
         public int drag_x;
+        public string[] dropList;
         public int drag_y;
+        public string lastEventSource;
         public bool drag_in_motion;
         public bool blockChanges;
 
@@ -91,6 +92,7 @@ public class Xcls_WindowLeftTree : Object
             this.el = new Gtk.TreeView();
 
             // my vars (dec)
+            this.lastEventSource = "";
             this.blockChanges = false;
 
             // set gobject values
@@ -149,9 +151,12 @@ public class Xcls_WindowLeftTree : Object
             //listeners
             this.el.button_press_event.connect( ( ev) => {
                 //console.log("button press?");
-                if (! _this.before_node_change(null) ) {
+                this.lastEventSource = "tree";
+                if (! _this.before_node_change() ) {
+                
                    return true;
                 }
+                
             
                 
                 if (ev.type != Gdk.EventType.BUTTON_PRESS  || ev.button != 3) {
@@ -175,13 +180,57 @@ public class Xcls_WindowLeftTree : Object
                  //   print("click:" + res.path.to_string());
                   return true;
             });
+            this.el.drag_begin.connect( ( ctx)  => {
+               //print('SOURCE: drag-begin');
+                    
+                    
+                    //this.targetData = "";
+                    
+                    // find what is selected in our tree...
+                    
+                    var s = _this.view.el.get_selection();
+                    if (s.count_selected_rows() < 1) {
+                        return;
+                    }
+                    Gtk.TreeIter iter;
+                    Gtk.TreeModel mod;
+                    s.get_selected(out mod, out iter);
+            
+                    
+            
+                    // set some properties of the tree for use by the dropped element.
+                    GLib.Value value;
+                    _this.model.el.get_value(iter, 2, out value);
+                    var tp = mod.get_path(iter).to_string();
+                    var data = (JsRender.Node)(value.dup_object());
+                    var xname = data.fqn();
+                    print ("XNAME  IS " + xname+ "\n");
+                    this.dragData = tp;
+                    this.dropList = _this.main_window.windowstate.file.palete().getDropList(xname);
+                    
+                    print ("DROP LIST IS " + string.joinv(", ", this.dropList) + "\n");
+                    
+            
+                    // make the drag icon a picture of the node that was selected
+                
+                    
+                // by default returns the path..
+                   var path = _this.model.el.get_path(iter);
+            
+                     
+                    var pix = this.el.create_row_drag_icon ( path);
+                    
+                    Gtk.drag_set_icon_surface (ctx, pix) ;
+                    
+                    return;
+            });
             this.el.cursor_changed.connect( ( ) => {
             
             
                  if (this.blockChanges) { // probably not needed.. 
                    return  ;
                  }
-                  if (!_this.before_node_change(null) ) {
+                  if (!_this.before_node_change( ) ) {
                     this.blockChanges = true;
                     this.el.get_selection().unselect_all();
                     this.blockChanges = false;
@@ -204,7 +253,7 @@ public class Xcls_WindowLeftTree : Object
             
                             print("selected rows < 1\n");
                             //??this.model.load( false);
-                            _this.node_selected(null);
+                            _this.node_selected(null, this.lastEventSource);
                             
                             return false ;
                         }
@@ -222,7 +271,7 @@ public class Xcls_WindowLeftTree : Object
                         _this.model.activePath = mod.get_path(iter).to_string();
                         
                         var node = (JsRender.Node)value.dup_object();
-                        _this.node_selected(node);
+                        _this.node_selected(node, this.lastEventSource);
                         while (Gtk.events_pending()) {
                             Gtk.main_iteration();
                        }
@@ -249,50 +298,6 @@ public class Xcls_WindowLeftTree : Object
                 return  ;
                             
             });
-            this.el.drag_begin.connect( ( ctx)  => {
-               //print('SOURCE: drag-begin');
-                    
-                    
-                    //this.targetData = "";
-                    
-                    // find what is selected in our tree...
-                    
-                    var s = _this.view.el.get_selection();
-                    if (s.count_selected_rows() < 1) {
-                        return;
-                    }
-                    Gtk.TreeIter iter;
-                    Gtk.TreeModel mod;
-                    s.get_selected(out mod, out iter);
-            
-                    
-            
-                    // set some properties of the tree for use by the dropped element.
-                    GLib.Value value;
-                    _this.model.el.get_value(iter, 2, out value);
-                    var tp = mod.get_path(iter).to_string();
-                    var data = (JsRender.Node)(value.dup_object());
-                    var xname = data.fqn();
-                    print ("XNAME  IS " + xname+ "\n");
-                    this.dragData = tp;
-                    this.dropList = _this.main_window.windowstate.file.palete().getDropList(xname);
-                    
-                    print ("DROP LIST IS " + string.joinv(", ", this.dropList) + "\n");
-                    
-            
-                    // make the drag icon a picture of the node that was selected
-                
-                    
-                // by default returns the path..
-                   var path = _this.model.el.get_path(iter);
-            
-                     
-                    var pix = this.el.create_row_drag_icon ( path);
-                    
-                    Gtk.drag_set_icon_surface (ctx, pix) ;
-                    
-                    return;
-            });
             this.el.drag_end.connect( (drag_context) => {
                //Seed.print('LEFT-TREE: drag-end');
                     this.dragData = "";
@@ -825,7 +830,16 @@ public class Xcls_WindowLeftTree : Object
                  }
                      
         }
-        public           void selectNode (string treepath_str) {
+        public void setCursor (string treepath, string sourceEvent)   {
+               this.lastEventSource = sourceEvent;
+               //this.blockChanges = true; << block changes prevents loading of 'node data' and firing of node_selected..
+            this.el.set_cursor(new Gtk.TreePath.from_string(treepath), null, false); 
+            // fire node_selected..
+            //this.blockChanges = false;
+               this.lastEventSource = "";
+        }
+        public           void selectNode (string treepath_str, string source) {
+               this.lastEventSource = source;
             //this.selection.select_path(new  Gtk.TreePath.from_string( treepath_str));
              var tp = new Gtk.TreePath.from_string(treepath_str);
              
@@ -1568,7 +1582,7 @@ public class Xcls_WindowLeftTree : Object
                     _this.model.el.remove(ref citer);
                 }
                 _this.changed();
-                _this.node_selected(node);
+                _this.node_selected(node, "tree");
                  
                 
             });