sync
[app.Builder.js] / src / Builder4 / WindowLeftTree.vala
index cda0318..be697e1 100644 (file)
@@ -77,8 +77,8 @@ public class Xcls_WindowLeftTree : Object
 
             // my vars (def)
         public string dragData;
-        public int drag_x;
         public string[] dropList;
+        public int drag_x;
         public int drag_y;
         public bool drag_in_motion;
         public bool blockChanges;
@@ -174,50 +174,6 @@ 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.model.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( ( ) => {
             
             
@@ -266,6 +222,22 @@ public class Xcls_WindowLeftTree : Object
                         
                         var node = (JsRender.Node)value.dup_object();
                         _this.node_selected(node);
+                        while (Gtk.events_pending()) {
+                            Gtk.main_iteration();
+                        }
+                        var cp = mod.get_path(iter);
+                        Gtk.TreePath sp, ep;
+                        this.el.get_visible_range(out sp, out ep);
+                        // if sp is before cp then retuns 1.
+                        // if cp is before ep then retuns 1.
+                        if (cp.compare(sp) >= 0 && ep.compare(cp) >=1) {
+                            return false;
+                        }
+                        
+                         
+                        
+                        this.el.scroll_to_cell(new Gtk.TreePath.from_string(_this.model.activePath), null, true, 0.1f,0.0f);
+                        
                         return false;
                   });  
                 //_this.after_node_change(node);
@@ -276,6 +248,50 @@ 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.model.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 = "";
@@ -1232,18 +1248,18 @@ public class Xcls_WindowLeftTree : Object
                 // we only need to show the template if it's come from else where?
                  if (show_templates) {
                  
-                    if (this.template_select == null) {
-                        this.template_select = new DialogTemplateSelect();
-                     }
+                     var ts = _this.main_window.windowstate.template_select;
                  
-                     var node = this.template_select.show(
-                          (Gtk.Window) _this.el.get_toplevel (),
+                     var new_node = ts.show(
+                          _this.main_window, // (Gtk.Window) _this.el.get_toplevel (),
                               this.file.palete(),
-                           node);
+                            node,
+                            this.file.project);
                            
-                     if (node == null) {
+                     if (new_node == null) {
                          return; // do not add?
                      }
+                     node = new_node;
                 }        
                 
                  //print("pos is %d  \n".printf(pos));