Builder4/WindowLeftTree.bjs
authorAlan Knowles <alan@roojs.com>
Wed, 24 Sep 2014 06:33:25 +0000 (14:33 +0800)
committerAlan Knowles <alan@roojs.com>
Wed, 24 Sep 2014 06:33:25 +0000 (14:33 +0800)
Builder4/WindowLeftTree.vala

Builder4/WindowLeftTree.bjs
Builder4/WindowLeftTree.vala

index 7b03705..76a02b3 100644 (file)
@@ -29,7 +29,7 @@
                         "drag_end" : "  (drag_context) => {\n\t//Seed.print('LEFT-TREE: drag-end');\n        this.dragData = \"\";\n        this.dropList = null;\n//        this.targetData = \"\";\n        this.highlightDropPath(\"\",0);\n//        return true;\n}",
                         "drag_motion" : " ( ctx, x, y, time)  => {\n \n    var src = Gtk.drag_get_source_widget(ctx);\n     \n   if (src != this.el) {\n   \n \n \n    // the point of this is to detect where an item could be dropped..\n        print(\"got drag motion\");\n       this.drag_in_motion = true;\n       this.drag_x = x;\n       this.drag_y = y;\n       \n            // request data that will be recieved by the recieve...              \n        Gtk.drag_get_data\n        (\n                this.el,         // will receive 'drag-data-received' signal \n                ctx,        // represents the current state of the DnD \n                Gdk.Atom.intern(\"STRING\",true),    // the target type we want \n                time            // time stamp \n        );\n        return true;\n  }    \n\n\n\n //print(\"GETTING POS\");\n    var  targetData = \"\";\n\n    Gtk.TreePath path;\n    Gtk.TreeViewDropPosition pos;\n    var isOver = _this.view.el.get_dest_row_at_pos(this.drag_x,this.drag_y, out path, out pos);\n\n    // if there are not items in the tree.. the we have to set isOver to true for anything..\n    var isEmpty = false;\n    if (_this.model.el.iter_n_children(null) < 1) {\n        print(\"got NO children?\\n\");\n        isOver = true; //??? \n        isEmpty = true;\n        pos = Gtk.TreeViewDropPosition.INTO_OR_AFTER;\n    }\n\n\n    // ------------- a drag from self..\n\n\n    //var action = Gdk.DragAction.COPY;\n        // unless we are copying!!! ctl button..\n    var action = (ctx.get_actions() & Gdk.DragAction.MOVE) > 0 ? Gdk.DragAction.MOVE : Gdk.DragAction.COPY ;\n\n\n    if (_this.model.el.iter_n_children(null) < 1) {\n        // no children.. -- asume it's ok..\n        \n        targetData = \"|%d|\".printf((int)Gtk.TreeViewDropPosition.INTO_OR_AFTER);\n           \n        this.highlightDropPath(\"\", (Gtk.TreeViewDropPosition)0);        \n        Gdk.drag_status(ctx, action ,time);\n        return true;\n        \n        // continue through to allow drop...\n\n    } \n        \n        \n\n    \n    \n    //print(\"ISOVER? \" + isOver);\n    if (!isOver) {\n  \n        Gdk.drag_status(ctx, 0 ,time);\n         this.highlightDropPath(\"\", (Gtk.TreeViewDropPosition)0);                    \n         return false;\n\n    }\n            \n    // drag node is parent of child..\n    //console.log(\"SRC TREEPATH: \" + src.treepath);\n    //console.log(\"TARGET TREEPATH: \" + data.path.to_string());\n    \n    // nned to check a  few here..\n    //Gtk.TreeViewDropPosition.INTO_OR_AFTER\n    //Gtk.TreeViewDropPosition.INTO_OR_BEFORE\n    //Gtk.TreeViewDropPosition.AFTER\n    //Gtk.TreeViewDropPosition.BEFORE\n    \n    // locally dragged items to not really use the \n    var selection_text = this.dragData;\n    \n            \n            \n    if (selection_text == null || selection_text.length < 1) {\n                //print(\"Error  - drag selection text returned NULL\");\n             Gdk.drag_status(ctx, 0 ,time);\n            this.highlightDropPath(\"\", (Gtk.TreeViewDropPosition)0);\n             return false;\n     }\n                       \n            \n            // see if we are dragging into ourself?\n    print (\"got selection text of  \" + selection_text);\n    \n    var target_path = path.to_string();\n    //print(\"target_path=\"+target_path);\n\n    // \n    if (selection_text  == target_path) {\n        print(\"self drag ?? == we should perhaps allow copy onto self..\\n\");\n                \n         Gdk.drag_status(ctx, 0 ,time);\n          this.highlightDropPath(\"\", (Gtk.TreeViewDropPosition)0);\n          return false;\n//                 -- fixme -- this is not really correct..\n\n    }\n            \n    // check that \n    //print(\"DUMPING DATA\");\n    //console.dump(data);\n    // path, pos\n    \n    //print(data.path.to_string() +' => '+  data.pos);\n    \n    // dropList is a list of xtypes that this node could be dropped on.\n    // it is set up when we start to drag..\n    \n    \n    targetData = _this.model.findDropNodeByPath( path.to_string(), this.dropList, pos);\n        \n    print(\"targetDAta: \" + targetData +\"\\n\");\n    \n    if (targetData.length < 1) {\n        //print(\"Can not find drop node path\");\n       \n        Gdk.drag_status(ctx, 0, time);\n        this.highlightDropPath(\"\", (Gtk.TreeViewDropPosition)0);\n        return false;\n    }\n    \n    var td_ar = targetData.split(\"|\");\n      \n    \n\n    Gdk.drag_status(ctx, action ,time);\n    this.highlightDropPath(td_ar[0], (Gtk.TreeViewDropPosition)int.parse(td_ar[1]));\n    return true;\n       \n       \n}",
                         "drag_data_get" : "( drag_context, data, info, time) => {\n            \n            \n                 //print(\"drag-data-get\");\n                 var s = this.el.get_selection();\n                 if (s.count_selected_rows() < 1) {\n                        data.set_text(\"\",0);     \n                         print(\"return empty string - no selection..\");\n                        return;\n                    }\n                 \n                 Gtk.TreeIter iter;\n                 Gtk.TreeModel mod;\n                 \n                 s.get_selected(out mod, out iter);\n                 \n                \n                \n                 GLib.Value value;\n                 _this.model.el.get_value(iter, 2, out value);\n                 var ndata = (JsRender.Node)(value.dup_object());\n                 var xname = ndata.fqn();\n                \n                \n                var tp = mod.get_path(iter).to_string();\n                // by default returns the path..\n                \n               if ( info != Gdk.Atom.intern(\"STRING\",true) ) {\n                    tp = ndata.toJsonString();\n               }   \n               \n               data.set_text(tp,tp.length);   \n                \n                \n            \n                \n               //  print(\"return \" + tp);\n            }",
-                        "drag_data_received" : "  (ctx, x, y, sel, info, time)  => {\n      print(\"Tree: drag-data-received\");\n\n\n        var is_drag = info == Gdk.Atom.intern(\"STRING\",true);\n    \n\n        //print(\"GETTING POS\");\n        var  targetData = \"\";\n        \n        Gtk.TreePath path;\n        Gtk.TreeViewDropPosition pos;\n        var isOver = _this.view.el.get_dest_row_at_pos(this.drag_x,this.drag_y, out path, out pos);\n        \n        // if there are not items in the tree.. the we have to set isOver to true for anything..\n        var isEmpty = false;\n        if (_this.model.el.iter_n_children(null) < 1) {\n            print(\"got NO children?\\n\");\n            isOver = true; //??? \n            isEmpty = true;\n            pos = Gtk.TreeViewDropPosition.INTO_OR_AFTER;\n        }\n        \n     \n        //console.log(\"LEFT-TREE: drag-motion\");\n        var src = Gtk.drag_get_source_widget(ctx);\n        \n        // a drag from  elsewhere...- prevent drop..\n        if (src != this.el) {\n            //print(\"drag_data_recieved from another element\");\n            \n             \n            var selection_text = sel.get_text();\n            \n            \n            if (selection_text == null || selection_text.length < 1 || !isOver) {\n                // nothing valid foudn to drop...\n                if (is_drag) {\n                    Gdk.drag_status(ctx, 0, time);\n                    this.highlightDropPath(\"\", (Gtk.TreeViewDropPosition)0);\n                    return;\n                }\n                Gtk.drag_finish (ctx, false, false, time);        // drop failed..\n                // no drop action...\n                return;            \n            \n            }\n            var dropNode = new JsRender.Node(); \n            \n            var dropNodeType  = selection_text;\n            var show_templates = true;\n            // for drop\n            if (!is_drag && dropNodeType[0] == '{') {\n                var pa = new Json.Parser();\n                pa.load_from_data(dropNodeType);\n                 \n                dropNode.loadFromJson( pa.get_root().get_object(), 2);\n                dropNodeType = dropNode.fqn();\n                show_templates = false;\n            } else {\n\n                dropNode.setFqn(selection_text);\n            }\n\n             \n            // dropList --- need to gather this ... \n            //print(\"get dropList for : %s\\n\",selection_text);            \n            var dropList = _this.model.file.palete().getDropList(dropNodeType);\n            \n            print(\"dropList: %s\\n\", string.joinv(\" , \", dropList));\n            \n            targetData = _this.model.findDropNodeByPath( isEmpty ? \"\" : path.to_string(), dropList, pos);\n                \n            print(\"targetDAta: \" + targetData +\"\\n\");\n            \n            if (targetData.length < 1) {\n             \n                // invalid drop path..\n                if (this.drag_in_motion) {\n                    Gdk.drag_status(ctx, 0, time);\n                    this.highlightDropPath(\"\", (Gtk.TreeViewDropPosition)0);\n                    return;\n                }\n                Gtk.drag_finish (ctx, false, false, time);        // drop failed..\n                // no drop action...\n                return;\n            }\n            // valid drop path..\n            \n              var td_ar = targetData.split(\"|\");\n              \n            \n            if (this.drag_in_motion) { \n                Gdk.drag_status(ctx, Gdk.DragAction.COPY ,time);\n\n                this.highlightDropPath(  td_ar[0]  , (Gtk.TreeViewDropPosition)int.parse(td_ar[1]));\n                return;\n            }\n            // continue on to allow drop..\n        \n\n            // at this point, drag is not in motion... -- as checked above... - so it's a real drop event..\n            \n\n            _this.model.dropNode(targetData, dropNode, show_templates);\n            print(\"ADD new node!!!\\n\");\n                \n            ///Xcls_DialogTemplateSelect.singleton().show( _this.model.file.palete(), node);\n            \n            Gtk.drag_finish (ctx, false, false,time);\n            \n            \n            \n            \n            \n            return;\n            \n        }\n            \n       // ------------- a drag from self..\n       \n       \n        //var action = Gdk.DragAction.COPY;\n            // unless we are copying!!! ctl button..\n        var action = (ctx.get_actions() & Gdk.DragAction.MOVE) > 0 ? Gdk.DragAction.MOVE : Gdk.DragAction.COPY ;\n        \n        \n        if (_this.model.el.iter_n_children(null) < 1) {\n            // no children.. -- asume it's ok..\n            \n            targetData = \"|%d|\".printf((int)Gtk.TreeViewDropPosition.INTO_OR_AFTER);\n            if (this.drag_in_motion) {    \n                this.highlightDropPath(\"\", (Gtk.TreeViewDropPosition)0);        \n                Gdk.drag_status(ctx, action ,time);\n                return;\n            }\n            // continue through to allow drop...\n\n        } else {\n            \n            \n\n            \n            \n            //print(\"ISOVER? \" + isOver);\n            if (!isOver) {\n                if (this.drag_in_motion) {\n                    Gdk.drag_status(ctx, 0 ,time);\n                     this.highlightDropPath(\"\", (Gtk.TreeViewDropPosition)0);                    \n                     return;\n                }\n                Gtk.drag_finish (ctx, false, false, time);        // drop failed..\n                return; // not over apoint!?! - no action on drop or motion..\n            }\n            \n            // drag node is parent of child..\n            //console.log(\"SRC TREEPATH: \" + src.treepath);\n            //console.log(\"TARGET TREEPATH: \" + data.path.to_string());\n            \n            // nned to check a  few here..\n            //Gtk.TreeViewDropPosition.INTO_OR_AFTER\n            //Gtk.TreeViewDropPosition.INTO_OR_BEFORE\n            //Gtk.TreeViewDropPosition.AFTER\n            //Gtk.TreeViewDropPosition.BEFORE\n            \n            // locally dragged items to not really use the \n            var selection_text = this.dragData;\n            \n            \n            \n            if (selection_text == null || selection_text.length < 1) {\n                //print(\"Error  - drag selection text returned NULL\");\n                if (this.drag_in_motion) {\n                     Gdk.drag_status(ctx, 0 ,time);\n                    this.highlightDropPath(\"\", (Gtk.TreeViewDropPosition)0);\n                     return;\n                 }\n                 Gtk.drag_finish (ctx, false, false, time);        // drop failed..\n                 return; /// -- fixme -- this is not really correct..\n            }                \n            \n            // see if we are dragging into ourself?\n            print (\"got selection text of  \" + selection_text);\n            \n            var target_path = path.to_string();\n            //print(\"target_path=\"+target_path);\n\n            // \n            if (selection_text  == target_path) {\n                print(\"self drag ?? == we should perhaps allow copy onto self..\\n\");\n                if (this.drag_in_motion) {\n                     Gdk.drag_status(ctx, 0 ,time);\n                      this.highlightDropPath(\"\", (Gtk.TreeViewDropPosition)0);\n                      return;\n                 }\n                 Gtk.drag_finish (ctx, false, false, time);        // drop failed..\n\n                 return; /// -- fixme -- this is not really correct..\n\n            }\n            \n            // check that \n            //print(\"DUMPING DATA\");\n            //console.dump(data);\n            // path, pos\n            \n            //print(data.path.to_string() +' => '+  data.pos);\n            \n            // dropList is a list of xtypes that this node could be dropped on.\n            // it is set up when we start to drag..\n            \n            \n            targetData = _this.model.findDropNodeByPath( path.to_string(), this.dropList, pos);\n                \n            print(\"targetDAta: \" + targetData +\"\\n\");\n            \n            if (targetData.length < 1) {\n                //print(\"Can not find drop node path\");\n                if (this.drag_in_motion) {\n                    Gdk.drag_status(ctx, 0, time);\n                    this.highlightDropPath(\"\", (Gtk.TreeViewDropPosition)0);\n                    return;\n                }\n                Gtk.drag_finish (ctx, false, false, time);        // drop failed..\n                return;\n            }\n            \n            var td_ar = targetData.split(\"|\");\n              \n            \n            if (this.drag_in_motion) { \n                Gdk.drag_status(ctx, action ,time);\n                this.highlightDropPath(td_ar[0], (Gtk.TreeViewDropPosition)int.parse(td_ar[1]));\n                return;\n            }\n            // continue on to allow drop..\n        }\n\n        // at this point, drag is not in motion... -- as checked above... - so it's a real drop event..\n\n\n         var delete_selection_data = false;\n            \n        if (ctx.get_actions() == Gdk.DragAction.ASK)  {\n            /* Ask the user to move or copy, then set the ctx action. */\n        }\n\n        if (ctx.get_actions() == Gdk.DragAction.MOVE) {\n            delete_selection_data = true;\n        }\n        \n            \n                    // drag around.. - reorder..\n        _this.model.moveNode(targetData, ctx.get_actions());\n            \n           \n            \n            \n            \n            // we can send stuff to souce here...\n\n\n    // do we always say failure, so we handle the reall drop?\n        Gtk.drag_finish (ctx, false, false,time); //delete_selection_data, time);\n       \n}",
+                        "drag_data_received" : "  (ctx, x, y, sel, info, time)  => {\n      print(\"Tree: drag-data-received\");\n\n\n        var is_drag = info == Gdk.Atom.intern(\"STRING\",true);\n    \n\n        //print(\"GETTING POS\");\n        var  targetData = \"\";\n        \n        Gtk.TreePath path;\n        Gtk.TreeViewDropPosition pos;\n        var isOver = _this.view.el.get_dest_row_at_pos(this.drag_x,this.drag_y, out path, out pos);\n        \n        // if there are not items in the tree.. the we have to set isOver to true for anything..\n        var isEmpty = false;\n        if (_this.model.el.iter_n_children(null) < 1) {\n            print(\"got NO children?\\n\");\n            isOver = true; //??? \n            isEmpty = true;\n            pos = Gtk.TreeViewDropPosition.INTO_OR_AFTER;\n        }\n        \n     \n        //console.log(\"LEFT-TREE: drag-motion\");\n        var src = Gtk.drag_get_source_widget(ctx);\n        \n        // a drag from self - this should be handled by drop and motion.\n        if (src == this.el) {\n            return;\n        }\n        //print(\"drag_data_recieved from another element\");\n        \n         \n        var selection_text = sel.get_text();\n        \n        \n        if (selection_text == null || selection_text.length < 1 || !isOver) {\n            // nothing valid foudn to drop...\n            if (is_drag) {\n                Gdk.drag_status(ctx, 0, time);\n                this.highlightDropPath(\"\", (Gtk.TreeViewDropPosition)0);\n                return;\n            }\n            Gtk.drag_finish (ctx, false, false, time);        // drop failed..\n            // no drop action...\n            return;            \n        \n        }\n        var dropNode = new JsRender.Node(); \n        \n        var dropNodeType  = selection_text;\n        var show_templates = true;\n        // for drop\n        if (!is_drag && dropNodeType[0] == '{') {\n            var pa = new Json.Parser();\n            pa.load_from_data(dropNodeType);\n             \n            dropNode.loadFromJson( pa.get_root().get_object(), 2);\n            dropNodeType = dropNode.fqn();\n            show_templates = false;\n        } else {\n\n            dropNode.setFqn(selection_text);\n        }\n\n         \n        // dropList --- need to gather this ... \n        //print(\"get dropList for : %s\\n\",selection_text);            \n        var dropList = _this.model.file.palete().getDropList(dropNodeType);\n        \n        print(\"dropList: %s\\n\", string.joinv(\" , \", dropList));\n        \n        targetData = _this.model.findDropNodeByPath( isEmpty ? \"\" : path.to_string(), dropList, pos);\n            \n        print(\"targetDAta: \" + targetData +\"\\n\");\n        \n        if (targetData.length < 1) {\n         \n            // invalid drop path..\n            if (this.drag_in_motion) {\n                Gdk.drag_status(ctx, 0, time);\n                this.highlightDropPath(\"\", (Gtk.TreeViewDropPosition)0);\n                return;\n            }\n            Gtk.drag_finish (ctx, false, false, time);        // drop failed..\n            // no drop action...\n            return;\n        }\n        // valid drop path..\n        \n          var td_ar = targetData.split(\"|\");\n          \n        \n        if (this.drag_in_motion) { \n            Gdk.drag_status(ctx, Gdk.DragAction.COPY ,time);\n\n            this.highlightDropPath(  td_ar[0]  , (Gtk.TreeViewDropPosition)int.parse(td_ar[1]));\n            return;\n        }\n        // continue on to allow drop..\n    \n\n        // at this point, drag is not in motion... -- as checked above... - so it's a real drop event..\n        \n\n        _this.model.dropNode(targetData, dropNode, show_templates);\n        print(\"ADD new node!!!\\n\");\n            \n        ///Xcls_DialogTemplateSelect.singleton().show( _this.model.file.palete(), node);\n        \n        Gtk.drag_finish (ctx, false, false,time);\n        \n        \n            \n            \n      \n}",
                         "drag_drop" : " (  ctx, x, y, time)  => {\n      //Seed.print(\"TARGET: drag-drop\");\n   \n   \n    var src = Gtk.drag_get_source_widget(ctx);\n     \n   if (src != this.el) {\n   \n    \n       \n       this.drag_in_motion = false;   \n            // request data that will be recieved by the recieve...              \n        Gtk.drag_get_data\n        (\n                this.el,         // will receive 'drag-data-received' signal \n                ctx,        // represents the current state of the DnD \n                Gdk.Atom.intern(\"application/json\",true),    // the target type we want \n                time            // time stamp \n        );\n\n         \n        // No target offered by source => error\n   \n\n         return  false;\n     }\n     \n     // handle drop around self..\n     \n                  \n            \n    //print(\"GETTING POS\");\n    var  targetData = \"\";\n    \n    Gtk.TreePath path;\n    Gtk.TreeViewDropPosition pos;\n    var isOver = _this.view.el.get_dest_row_at_pos(this.drag_x,this.drag_y, out path, out pos);\n    \n    // if there are not items in the tree.. the we have to set isOver to true for anything..\n    var isEmpty = false;\n    if (_this.model.el.iter_n_children(null) < 1) {\n        print(\"got NO children?\\n\");\n        isOver = true; //??? \n        isEmpty = true;\n        pos = Gtk.TreeViewDropPosition.INTO_OR_AFTER;\n    }\n    \n     \n     \n    //var action = Gdk.DragAction.COPY;\n        // unless we are copying!!! ctl button..\n    var action = (ctx.get_actions() & Gdk.DragAction.MOVE) > 0 ? Gdk.DragAction.MOVE : Gdk.DragAction.COPY ;\n    \n            \n    if (_this.model.el.iter_n_children(null) < 1) {\n        // no children.. -- asume it's ok..\n        \n        targetData = \"|%d|\".printf((int)Gtk.TreeViewDropPosition.INTO_OR_AFTER);\n         \n        // continue through to allow drop...\n\n    } else {\n                \n                \n    \n                \n                \n                //print(\"ISOVER? \" + isOver);\n        if (!isOver) {\n            \n            Gtk.drag_finish (ctx, false, false, time);        // drop failed..\n            return true; // not over apoint!?! - no action on drop or motion..\n        }\n                \n        // drag node is parent of child..\n        //console.log(\"SRC TREEPATH: \" + src.treepath);\n        //console.log(\"TARGET TREEPATH: \" + data.path.to_string());\n        \n        // nned to check a  few here..\n        //Gtk.TreeViewDropPosition.INTO_OR_AFTER\n        //Gtk.TreeViewDropPosition.INTO_OR_BEFORE\n        //Gtk.TreeViewDropPosition.AFTER\n        //Gtk.TreeViewDropPosition.BEFORE\n        \n        // locally dragged items to not really use the \n        var selection_text = this.dragData;\n        \n        \n        \n        if (selection_text == null || selection_text.length < 1) {\n            //print(\"Error  - drag selection text returned NULL\");\n          \n             Gtk.drag_finish (ctx, false, false, time);        // drop failed..\n             return true; /// -- fixme -- this is not really correct..\n        }                \n                \n                // see if we are dragging into ourself?\n                print (\"got selection text of  \" + selection_text);\n        \n        var target_path = path.to_string();\n        //print(\"target_path=\"+target_path);\n\n        // \n        if (selection_text  == target_path) {\n            print(\"self drag ?? == we should perhaps allow copy onto self..\\n\");\n            \n             Gtk.drag_finish (ctx, false, false, time);        // drop failed..\n\n             return true; /// -- fixme -- this is not really correct..\n\n        }\n                \n        // check that \n        //print(\"DUMPING DATA\");\n        //console.dump(data);\n        // path, pos\n        \n        //print(data.path.to_string() +' => '+  data.pos);\n        \n        // dropList is a list of xtypes that this node could be dropped on.\n        // it is set up when we start to drag..\n        \n        \n        targetData = _this.model.findDropNodeByPath( path.to_string(), this.dropList, pos);\n            \n        print(\"targetDAta: \" + targetData +\"\\n\");\n        \n        if (targetData.length < 1) {\n            //print(\"Can not find drop node path\");\n             \n            Gtk.drag_finish (ctx, false, false, time);        // drop failed..\n            return true;\n        }\n        \n        var td_ar = targetData.split(\"|\");\n                  \n                \n                \n                // continue on to allow drop..\n  }\n        // at this point, drag is not in motion... -- as checked above... - so it's a real drop event..\n\n\n     var delete_selection_data = false;\n        \n    if (ctx.get_actions() == Gdk.DragAction.ASK)  {\n        /* Ask the user to move or copy, then set the ctx action. */\n    }\n\n    if (ctx.get_actions() == Gdk.DragAction.MOVE) {\n        delete_selection_data = true;\n    }\n    \n        \n                // drag around.. - reorder..\n    _this.model.moveNode(targetData, ctx.get_actions());\n        \n       \n        \n        \n        \n        // we can send stuff to souce here...\n\n\n// do we always say failure, so we handle the reall drop?\n    Gtk.drag_finish (ctx, false, false,time); //delete_selection_data, time);\n\n    return true;\n \n \n \n \n \n \n}"
                     },
                     "# string dragData" : "",
index d8143df..46e1400 100644 (file)
@@ -498,244 +498,96 @@ public class Xcls_WindowLeftTree : Object
                     //console.log("LEFT-TREE: drag-motion");
                     var src = Gtk.drag_get_source_widget(ctx);
                     
-                    // a drag from  elsewhere...- prevent drop..
-                    if (src != this.el) {
-                        //print("drag_data_recieved from another element");
-                        
-                         
-                        var selection_text = sel.get_text();
-                        
-                        
-                        if (selection_text == null || selection_text.length < 1 || !isOver) {
-                            // nothing valid foudn to drop...
-                            if (is_drag) {
-                                Gdk.drag_status(ctx, 0, time);
-                                this.highlightDropPath("", (Gtk.TreeViewDropPosition)0);
-                                return;
-                            }
-                            Gtk.drag_finish (ctx, false, false, time);        // drop failed..
-                            // no drop action...
-                            return;            
-                        
-                        }
-                        var dropNode = new JsRender.Node(); 
-                        
-                        var dropNodeType  = selection_text;
-                        var show_templates = true;
-                        // for drop
-                        if (!is_drag && dropNodeType[0] == '{') {
-                            var pa = new Json.Parser();
-                            pa.load_from_data(dropNodeType);
-                             
-                            dropNode.loadFromJson( pa.get_root().get_object(), 2);
-                            dropNodeType = dropNode.fqn();
-                            show_templates = false;
-                        } else {
-            
-                            dropNode.setFqn(selection_text);
-                        }
-            
-                         
-                        // dropList --- need to gather this ... 
-                        //print("get dropList for : %s\n",selection_text);            
-                        var dropList = _this.model.file.palete().getDropList(dropNodeType);
-                        
-                        print("dropList: %s\n", string.joinv(" , ", dropList));
-                        
-                        targetData = _this.model.findDropNodeByPath( isEmpty ? "" : path.to_string(), dropList, pos);
-                            
-                        print("targetDAta: " + targetData +"\n");
-                        
-                        if (targetData.length < 1) {
-                         
-                            // invalid drop path..
-                            if (this.drag_in_motion) {
-                                Gdk.drag_status(ctx, 0, time);
-                                this.highlightDropPath("", (Gtk.TreeViewDropPosition)0);
-                                return;
-                            }
-                            Gtk.drag_finish (ctx, false, false, time);        // drop failed..
-                            // no drop action...
-                            return;
-                        }
-                        // valid drop path..
-                        
-                          var td_ar = targetData.split("|");
-                          
-                        
-                        if (this.drag_in_motion) { 
-                            Gdk.drag_status(ctx, Gdk.DragAction.COPY ,time);
-            
-                            this.highlightDropPath(  td_ar[0]  , (Gtk.TreeViewDropPosition)int.parse(td_ar[1]));
-                            return;
-                        }
-                        // continue on to allow drop..
-                    
-            
-                        // at this point, drag is not in motion... -- as checked above... - so it's a real drop event..
-                        
-            
-                        _this.model.dropNode(targetData, dropNode, show_templates);
-                        print("ADD new node!!!\n");
-                            
-                        ///Xcls_DialogTemplateSelect.singleton().show( _this.model.file.palete(), node);
-                        
-                        Gtk.drag_finish (ctx, false, false,time);
-                        
-                        
-                        
-                        
-                        
+                    // a drag from self - this should be handled by drop and motion.
+                    if (src == this.el) {
                         return;
-                        
                     }
-                        
-                   // ------------- a drag from self..
-                   
-                   
-                    //var action = Gdk.DragAction.COPY;
-                        // unless we are copying!!! ctl button..
-                    var action = (ctx.get_actions() & Gdk.DragAction.MOVE) > 0 ? Gdk.DragAction.MOVE : Gdk.DragAction.COPY ;
+                    //print("drag_data_recieved from another element");
                     
+                     
+                    var selection_text = sel.get_text();
                     
-                    if (_this.model.el.iter_n_children(null) < 1) {
-                        // no children.. -- asume it's ok..
-                        
-                        targetData = "|%d|".printf((int)Gtk.TreeViewDropPosition.INTO_OR_AFTER);
-                        if (this.drag_in_motion) {    
-                            this.highlightDropPath("", (Gtk.TreeViewDropPosition)0);        
-                            Gdk.drag_status(ctx, action ,time);
+                    
+                    if (selection_text == null || selection_text.length < 1 || !isOver) {
+                        // nothing valid foudn to drop...
+                        if (is_drag) {
+                            Gdk.drag_status(ctx, 0, time);
+                            this.highlightDropPath("", (Gtk.TreeViewDropPosition)0);
                             return;
                         }
-                        // continue through to allow drop...
-            
+                        Gtk.drag_finish (ctx, false, false, time);        // drop failed..
+                        // no drop action...
+                        return;            
+                    
+                    }
+                    var dropNode = new JsRender.Node(); 
+                    
+                    var dropNodeType  = selection_text;
+                    var show_templates = true;
+                    // for drop
+                    if (!is_drag && dropNodeType[0] == '{') {
+                        var pa = new Json.Parser();
+                        pa.load_from_data(dropNodeType);
+                         
+                        dropNode.loadFromJson( pa.get_root().get_object(), 2);
+                        dropNodeType = dropNode.fqn();
+                        show_templates = false;
                     } else {
-                        
-                        
             
-                        
-                        
-                        //print("ISOVER? " + isOver);
-                        if (!isOver) {
-                            if (this.drag_in_motion) {
-                                Gdk.drag_status(ctx, 0 ,time);
-                                 this.highlightDropPath("", (Gtk.TreeViewDropPosition)0);                    
-                                 return;
-                            }
-                            Gtk.drag_finish (ctx, false, false, time);        // drop failed..
-                            return; // not over apoint!?! - no action on drop or motion..
-                        }
-                        
-                        // drag node is parent of child..
-                        //console.log("SRC TREEPATH: " + src.treepath);
-                        //console.log("TARGET TREEPATH: " + data.path.to_string());
-                        
-                        // nned to check a  few here..
-                        //Gtk.TreeViewDropPosition.INTO_OR_AFTER
-                        //Gtk.TreeViewDropPosition.INTO_OR_BEFORE
-                        //Gtk.TreeViewDropPosition.AFTER
-                        //Gtk.TreeViewDropPosition.BEFORE
-                        
-                        // locally dragged items to not really use the 
-                        var selection_text = this.dragData;
-                        
-                        
-                        
-                        if (selection_text == null || selection_text.length < 1) {
-                            //print("Error  - drag selection text returned NULL");
-                            if (this.drag_in_motion) {
-                                 Gdk.drag_status(ctx, 0 ,time);
-                                this.highlightDropPath("", (Gtk.TreeViewDropPosition)0);
-                                 return;
-                             }
-                             Gtk.drag_finish (ctx, false, false, time);        // drop failed..
-                             return; /// -- fixme -- this is not really correct..
-                        }                
-                        
-                        // see if we are dragging into ourself?
-                        print ("got selection text of  " + selection_text);
-                        
-                        var target_path = path.to_string();
-                        //print("target_path="+target_path);
-            
-                        // 
-                        if (selection_text  == target_path) {
-                            print("self drag ?? == we should perhaps allow copy onto self..\n");
-                            if (this.drag_in_motion) {
-                                 Gdk.drag_status(ctx, 0 ,time);
-                                  this.highlightDropPath("", (Gtk.TreeViewDropPosition)0);
-                                  return;
-                             }
-                             Gtk.drag_finish (ctx, false, false, time);        // drop failed..
-            
-                             return; /// -- fixme -- this is not really correct..
+                        dropNode.setFqn(selection_text);
+                    }
             
-                        }
-                        
-                        // check that 
-                        //print("DUMPING DATA");
-                        //console.dump(data);
-                        // path, pos
-                        
-                        //print(data.path.to_string() +' => '+  data.pos);
-                        
-                        // dropList is a list of xtypes that this node could be dropped on.
-                        // it is set up when we start to drag..
-                        
-                        
-                        targetData = _this.model.findDropNodeByPath( path.to_string(), this.dropList, pos);
-                            
-                        print("targetDAta: " + targetData +"\n");
-                        
-                        if (targetData.length < 1) {
-                            //print("Can not find drop node path");
-                            if (this.drag_in_motion) {
-                                Gdk.drag_status(ctx, 0, time);
-                                this.highlightDropPath("", (Gtk.TreeViewDropPosition)0);
-                                return;
-                            }
-                            Gtk.drag_finish (ctx, false, false, time);        // drop failed..
-                            return;
-                        }
-                        
-                        var td_ar = targetData.split("|");
-                          
+                     
+                    // dropList --- need to gather this ... 
+                    //print("get dropList for : %s\n",selection_text);            
+                    var dropList = _this.model.file.palete().getDropList(dropNodeType);
+                    
+                    print("dropList: %s\n", string.joinv(" , ", dropList));
+                    
+                    targetData = _this.model.findDropNodeByPath( isEmpty ? "" : path.to_string(), dropList, pos);
                         
-                        if (this.drag_in_motion) { 
-                            Gdk.drag_status(ctx, action ,time);
-                            this.highlightDropPath(td_ar[0], (Gtk.TreeViewDropPosition)int.parse(td_ar[1]));
+                    print("targetDAta: " + targetData +"\n");
+                    
+                    if (targetData.length < 1) {
+                     
+                        // invalid drop path..
+                        if (this.drag_in_motion) {
+                            Gdk.drag_status(ctx, 0, time);
+                            this.highlightDropPath("", (Gtk.TreeViewDropPosition)0);
                             return;
                         }
-                        // continue on to allow drop..
+                        Gtk.drag_finish (ctx, false, false, time);        // drop failed..
+                        // no drop action...
+                        return;
                     }
+                    // valid drop path..
+                    
+                      var td_ar = targetData.split("|");
+                      
+                    
+                    if (this.drag_in_motion) { 
+                        Gdk.drag_status(ctx, Gdk.DragAction.COPY ,time);
             
-                    // at this point, drag is not in motion... -- as checked above... - so it's a real drop event..
-            
-            
-                     var delete_selection_data = false;
-                        
-                    if (ctx.get_actions() == Gdk.DragAction.ASK)  {
-                        /* Ask the user to move or copy, then set the ctx action. */
+                        this.highlightDropPath(  td_ar[0]  , (Gtk.TreeViewDropPosition)int.parse(td_ar[1]));
+                        return;
                     }
+                    // continue on to allow drop..
+                
             
-                    if (ctx.get_actions() == Gdk.DragAction.MOVE) {
-                        delete_selection_data = true;
-                    }
+                    // at this point, drag is not in motion... -- as checked above... - so it's a real drop event..
                     
+            
+                    _this.model.dropNode(targetData, dropNode, show_templates);
+                    print("ADD new node!!!\n");
                         
-                                // drag around.. - reorder..
-                    _this.model.moveNode(targetData, ctx.get_actions());
-                        
-                       
-                        
+                    ///Xcls_DialogTemplateSelect.singleton().show( _this.model.file.palete(), node);
+                    
+                    Gtk.drag_finish (ctx, false, false,time);
+                    
+                    
                         
                         
-                        // we can send stuff to souce here...
-            
-            
-                // do we always say failure, so we handle the reall drop?
-                    Gtk.drag_finish (ctx, false, false,time); //delete_selection_data, time);
-                   
+                  
             });
             this.el.drag_drop.connect( (  ctx, x, y, time)  => {
                   //Seed.print("TARGET: drag-drop");