Builder4/WindowLeftTree.bjs
authorAlan Knowles <alan@roojs.com>
Wed, 24 Sep 2014 05:53:35 +0000 (13:53 +0800)
committerAlan Knowles <alan@roojs.com>
Wed, 24 Sep 2014 05:53:35 +0000 (13:53 +0800)
Builder4/WindowLeftTree.vala

Builder4/WindowLeftTree.bjs
Builder4/WindowLeftTree.vala

index 4be1349..e28647c 100644 (file)
@@ -25,7 +25,7 @@
                     "listeners" : {
                         "button_press_event" : "  ( ev) => {\n    //console.log(\"button press?\");\n    if (! _this.before_node_change(null) ) {\n       return true;\n    }\n\n    \n    if (ev.type != Gdk.EventType.BUTTON_PRESS  || ev.button != 3) {\n        //print(\"click\" + ev.type);\n        return false;\n    }\n    Gtk.TreePath res;\n    if (!_this.view.el.get_path_at_pos((int)ev.x,(int)ev.y, out res, null, null, null) ) {\n        return true;\n    }\n     \n    this.el.get_selection().select_path(res);\n     \n      //if (!this.get('/LeftTreeMenu').el)  { \n      //      this.get('/LeftTreeMenu').init(); \n      //  }\n        \n     _this.LeftTreeMenu.el.set_screen(Gdk.Screen.get_default());\n     _this.LeftTreeMenu.el.show_all();\n      _this.LeftTreeMenu.el.popup(null, null, null,  3, ev.time);\n     //   print(\"click:\" + res.path.to_string());\n      return true;\n}",
                         "cursor_changed" : " ( ) => {\n\n\n     if (this.blockChanges) { // probably not needed.. \n       return  ;\n     }\n      if (!_this.before_node_change(null) ) {\n\t     this.blockChanges = true;\n\t     this.el.get_selection().unselect_all();\n\t     this.blockChanges = false;\n\t     return;\n     }\n     if (_this.model.file == null) {\n         return;\n     } \n     \n     //var render = this.get('/LeftTree').getRenderer();                \n    print(\"LEFT TREE -> view -> selection changed called\\n\");\n    \n    \n    // -- it appears that the selection is not updated.\n    \n    GLib.Timeout.add_full(GLib.Priority.DEFAULT,10 , () => {\n         \n\n            if (this.el.get_selection().count_selected_rows() < 1) {\n\n                print(\"selected rows < 1\\n\");\n                //??this.model.load( false);\n                _this.node_selected(null);\n                \n                return false ;\n            }\n                \n                //console.log('changed');\n            var s = this.el.get_selection();\n             Gtk.TreeIter iter;\n             Gtk.TreeModel mod;\n            s.get_selected(out mod, out iter);\n            \n            \n            // var val = \"\";\n            GLib.Value value;\n            _this.model.el.get_value(iter, 2, out value);\n            _this.model.activePath = mod.get_path(iter).to_string();\n            \n            var node = (JsRender.Node)value.dup_object();\n            _this.node_selected(node);\n            return false;\n      });  \n    //_this.after_node_change(node);\n\n//        _this.model.file.changed(node, \"tree\");\n   \n    //Seed.print( value.get_string());\n    return  ;\n                \n}",
-                        "drag_begin" : "( ctx)  => {\n\t//print('SOURCE: drag-begin');\n        \n        \n        //this.targetData = \"\";\n        \n        // find what is selected in our tree...\n        \n        var s = _this.view.el.get_selection();\n        if (s.count_selected_rows() < 1) {\n            return;\n        }\n        Gtk.TreeIter iter;\n        Gtk.TreeModel mod;\n        s.get_selected(out mod, out iter);\n\n        \n\n        // set some properties of the tree for use by the dropped element.\n        GLib.Value value;\n        _this.model.el.get_value(iter, 2, out value);\n        var tp = mod.get_path(iter).to_string();\n        var data = (JsRender.Node)(value.dup_object());\n        var xname = data.fqn();\n        print (\"XNAME  IS \" + xname+ \"\\n\");\n        this.dragData = tp;\n        //this.dropList = _this.model.file.palete().getDropList(xname);\n        \n        print (\"DROP LIST IS \" + string.joinv(\", \", this.dropList) + \"\\n\");\n        \n\n        // make the drag icon a picture of the node that was selected\n    \n        \n    // by default returns the path..\n    \n         \n        var pix = this.el.create_row_drag_icon ( path);\n        \n        Gtk.drag_set_icon_surface (ctx, pix) ;\n        \n        return;\n}",
+                        "drag_begin" : "( ctx)  => {\n\t//print('SOURCE: drag-begin');\n        \n        \n        //this.targetData = \"\";\n        \n        // find what is selected in our tree...\n        \n        var s = _this.view.el.get_selection();\n        if (s.count_selected_rows() < 1) {\n            return;\n        }\n        Gtk.TreeIter iter;\n        Gtk.TreeModel mod;\n        s.get_selected(out mod, out iter);\n\n        \n\n        // set some properties of the tree for use by the dropped element.\n        GLib.Value value;\n        _this.model.el.get_value(iter, 2, out value);\n        var tp = mod.get_path(iter).to_string();\n        var data = (JsRender.Node)(value.dup_object());\n        var xname = data.fqn();\n        print (\"XNAME  IS \" + xname+ \"\\n\");\n        this.dragData = tp;\n        //this.dropList = _this.model.file.palete().getDropList(xname);\n        \n        print (\"DROP LIST IS \" + string.joinv(\", \", this.dropList) + \"\\n\");\n        \n\n        // make the drag icon a picture of the node that was selected\n    \n        \n    // by default returns the path..\n       var path = _this.model.el.get_path(iter);\n\n         \n        var pix = this.el.create_row_drag_icon ( path);\n        \n        Gtk.drag_set_icon_surface (ctx, pix) ;\n        \n        return;\n}",
                         "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    // 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}",
                         "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 = node.toJsonString();\n   }   \n   \n   data.set_text(tp,tp.length);   \n    \n    \n\n    \n   //  print(\"return \" + tp);\n}",
index f29d881..391858f 100644 (file)
@@ -265,7 +265,8 @@ public class Xcls_WindowLeftTree : Object
                 
                     
                 // by default returns the path..
-                
+                   var path = _this.model.el.get_path(iter);
+            
                      
                     var pix = this.el.create_row_drag_icon ( path);