2 "build_module" : "builder",
5 "# Xcls_MainWindow main_window" : "null",
8 "@ bool before_node_change" : "()",
9 "@ void changed" : "()",
10 "@ void node_selected" : "(JsRender.Node? node, string source)",
11 "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
12 "id" : "WindowLeftTree",
17 "bool always_show_image" : true,
18 "bool hexpand" : true,
22 "* pack" : "set_image",
23 "utf8 icon_name" : "list-add",
32 " \t_this.main_window.windowstate.showAddObject(this.el);",
37 "string label" : "Add Child Element",
43 " this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);",
48 "Gtk.ShadowType shadow_type" : "Gtk.ShadowType.IN",
51 "# bool blockChanges" : false,
52 "# bool drag_in_motion" : "",
55 "# string dragData" : "",
56 "# string[] dropList" : "",
57 "$ enable_tree_lines" : true,
58 "$ string lastEventSource" : "\"\"",
62 " var description = new Pango.FontDescription();",
63 " description.set_size(8000);",
64 " this.el.override_font(description);",
66 " var selection = this.el.get_selection();",
67 " selection.set_mode( Gtk.SelectionMode.SINGLE);",
70 " // is this really needed??",
72 " this.selection.signal['changed'].connect(function() {",
73 "\t _this.get('/LeftTree.view').listeners.cursor_changed.apply(",
74 "\t _this.get('/LeftTree.view'), [ _this.get('/LeftTree.view'), '']",
78 " Gtk.drag_source_set (",
79 "\t this.el, /* widget will be drag-able */",
80 "\t Gdk.ModifierType.BUTTON1_MASK, /* modifier that will start a drag */",
81 "\t BuilderApplication.targetList, /* lists of target to support */",
82 "\t Gdk.DragAction.COPY | Gdk.DragAction.MOVE | Gdk.DragAction.LINK /* what to do with data after dropped */",
86 " //Gtk.drag_source_add_text_targets(this.el); ",
90 " this.el, /* widget that will accept a drop */",
91 " Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,",
92 " BuilderApplication.targetList, /* lists of target to support */",
93 " Gdk.DragAction.COPY | Gdk.DragAction.MOVE | Gdk.DragAction.LINK /* what to do with data after dropped */",
96 " //Gtk.drag_dest_set_target_list(this.el, Builder.Application.targetList);",
97 " //Gtk.drag_dest_add_text_targets(this.el);",
102 "bool button_is_pressed" : false,
103 "bool expand" : true,
104 "bool key_is_pressed" : false,
105 "gboolean headers_visible" : true,
109 "# DialogTemplateSelect template_select" : "null",
110 "# string activePath" : "\"\"",
111 "$ columns" : "typeof(string),typeof(string),typeof(Object),typeof(Gdk.Pixbuf)",
114 " var s = this.get('/LeftTree.view').selection;",
115 " print (\"LIST ALL TYPES: \" + s.count_selected_rows() );",
117 " if (s.count_selected_rows() > 0) {",
118 " var iter = new Gtk.TreeIter(); ",
119 " s.get_selected(this.el, iter);",
121 " // set some properties of the tree for use by the dropped element.",
122 " var value = new GObject.Value('');",
123 " this.el.get_value(iter, 2, value);",
124 " var data = JSON.parse(value.value);",
127 " var xname = this.get('/LeftTree.model').file.guessName(data);",
128 " console.log('selected:' + xname);",
129 " if (xname.length) {",
130 " return [ xname ];",
132 " return []; // could not find it..",
137 " var _this = this;",
138 " function addall(li)",
140 " li.forEach(function(el) {",
141 " // this is specific to roo!!!?",
142 " if (!el) { // skip empty?",
145 " var fullpath = _this.file.guessName(el);",
146 " if (fullpath.length && ret.indexOf(fullpath) < 0) {",
147 " ret.push(fullpath);",
151 " if (el.items && el.items.length) {",
152 " addall(el.items);",
160 " addall([this.currentTree]);",
162 " // only if we have nothing, should we add '*top'",
163 " if (!ret.length) {",
164 " ret = [ '*top' ];",
166 " //console.log('all types in tree');",
167 " //console.dump(ret);",
176 "print(\"model initialized\");",
180 "* pack" : "set_model",
181 "currentTree" : false,
184 "xtype" : "TreeStore",
185 "| JsRender.Node pathToNode" : [
189 " Gtk.TreeIter iter;",
190 " _this.model.el.get_iter_from_string(out iter, path);",
192 " GLib.Value value;",
193 " _this.model.el.get_value(iter, 2, out value);",
195 " return (JsRender.Node)value.dup_object();",
199 "| string findDropNode" : [
200 " (string treepath_str, string[] targets) {",
202 " // this is used by the dragdrop code in the roo version AFAIR..",
204 " //var path = treepath_str.replace(/^builder-/, '');",
205 " // treemap is depreciated... - should really check if model has any entries..",
207 " if (this.el.iter_n_children(null) < 1) {",
208 " //print(\"NO KEYS\");",
209 " return \"|%d\".printf((int)Gtk.TreeViewDropPosition.INTO_OR_AFTER);",
211 " //print(\"FIND treepath: \" + path);",
212 " //console.dump(this.treemap);",
214 " //if (!treepath_str.match(/^builder-/)) {",
215 " // return []; // nothing!",
217 " if (targets.length > 0 && targets[0] == \"*\") {",
218 " return treepath_str;",
220 " return this.findDropNodeByPath(treepath_str,targets, -1);",
224 "| string findDropNodeByPath" : [
225 " (string treepath_str, string[] targets, int in_pref = -1) {",
227 " var path = treepath_str; // dupe it..",
230 " // pref : 3 = ontop - 0 = after, 1 = before",
231 " int pref = in_pref < 0 ? Gtk.TreeViewDropPosition.INTO_OR_AFTER : in_pref;",
235 " //console.dump(this.treemap);",
237 " print(\"findDropNodeByPath : got path length %d / %s\\n\", path.length, path);",
239 " if (path.length == 0) {",
240 " // top drop. // just return empty..",
241 " return \"|%d\".printf((int)pref) ;",
246 " while (path.length > 0) {",
248 " if (path.length == treepath_str.length && pref != Gtk.TreeViewDropPosition.INTO_OR_AFTER) {",
249 " if (path.last_index_of(\":\") < 0 ) {",
252 " path = path.substring(0, path.last_index_of(\":\"));",
253 " last = treepath_str;",
254 " print(\"DROP before or after : using %s\\n\",path);",
258 " //print(\"LOOKING FOR PATH: \" + path);",
259 " var node_data = this.pathToNode(path);",
261 " if (node_data == null) {",
262 " print(\"node not found\");",
266 " var xname = node_data.fqn();",
267 " var match = \"\";",
270 " for (var i =0; i < targets.length; i++) {",
271 " var tg = targets[i];",
272 " if ((tg == xname) ) {",
276 " // if target is \"xxxx:name\"",
277 " if (tg.contains(xname +\":\")) {",
279 " var ar = tg.split(\":\");",
285 " if (match.length > 0) {",
286 " if (last.length > 0) { // pref is after/before..",
287 " // then it's after last",
288 " //if (pref > 1) {",
291 " return last + \"|%d\".printf((int)pref) + \"|\" + prop;",
295 " // we need to add prop - as :store -> needs to bee added when dropping onto.",
296 " return path + \"|%d\".printf( (int) Gtk.TreeViewDropPosition.INTO_OR_AFTER) + \"|\" + prop;",
299 " last = \"\" + path;",
300 " var par = path.split(\":\");",
301 " string [] ppar = {};",
302 " for (var i = 0; i < par.length-1; i++) {",
306 " path = string.joinv(\":\", ppar);",
317 "| string treePathFromNode" : [
318 "(JsRender.Node node) {",
319 " // iterate through the tree and find the node",
322 " this.el.foreach((mod, pth, iter) => {",
323 " // get the node..",
326 " GLib.Value value;",
327 " _this.model.el.get_value(iter, 2, out value);",
331 " var n = (JsRender.Node)value;",
333 " print(\"compare %s to %s\\n\", n.fqn(), node.fqn());",
335 " ret = pth.to_string();",
345 "| void deleteSelected" : [
348 " print(\"DELETE SELECTED?\");",
349 " //_this.view.blockChanges = true;",
350 " print(\"GET SELECTION?\");",
352 " var s = _this.view.el.get_selection();",
354 " print(\"GET SELECTED?\");",
355 " Gtk.TreeIter iter;",
356 " Gtk.TreeModel mod;",
359 " if (!s.get_selected(out mod, out iter)) {",
360 " return; // nothing seleted..",
365 " this.activePath= \"\"; ",
366 " print(\"GET vnode value?\");",
368 " GLib.Value value;",
369 " this.el.get_value(iter, 2, out value);",
370 " var data = (JsRender.Node)(value.get_object());",
371 " print(\"removing node from Render\\n\");",
372 " if (data.parent == null) {",
373 " _this.main_window.windowstate.file.tree = null;",
377 " print(\"removing node from Tree\\n\"); ",
378 " s.unselect_all();",
379 " this.el.remove(ref iter);",
389 " this.activePath= \"\"; // again!?!? ",
390 " //this.changed(null,true);",
394 " _this.view.blockChanges = false;",
398 "| void dropNode" : [
399 "(string target_data_str, JsRender.Node node, bool show_templates) {",
400 "// print(\"drop Node\");",
401 " // console.dump(node);",
402 " // console.dump(target_data);",
404 " \t\t//target_data_str",
405 " \t\t// {parent}|{pos}|{prop}",
408 " // 0 = before , 1=after 2/3 onto",
410 " \t\tGLib.debug(\"dropNode %s\", target_data_str);",
412 " var target_data= target_data_str.split(\"|\");",
414 " var parent_str = target_data[0].length > 0 ? target_data[0] : \"\";",
415 " var pos = target_data.length > 1 ? int.parse(target_data[1]) : 2; // ontop..",
418 " Gtk.TreePath tree_path = parent_str.length > 0 ? new Gtk.TreePath.from_string( parent_str ) : null;",
422 " //print(\"add \" + tp + \"@\" + target_data[1] );",
424 " JsRender.Node parentNode = null;",
426 " Gtk.TreeIter iter_after;",
427 " Gtk.TreeIter iter_par ;",
429 " \t// this appears to be done in drag_ddata_recieved as well.",
430 " if (target_data.length == 3 && target_data[2].length > 0) {",
431 "\t node.set_prop(new JsRender.NodeProp.special(\"prop\", target_data[2]));",
435 " Gtk.TreePath expand_parent = null;",
437 " // we only need to show the template if it's come from else where?",
438 " if (show_templates) {",
440 " var ts = _this.main_window.windowstate.template_select;",
442 " var new_node = ts.show(",
443 " _this.main_window, // (Gtk.Window) _this.el.get_toplevel (),",
444 " _this.main_window.windowstate.file.palete(),",
446 " _this.main_window.windowstate.project);",
448 " if (new_node == null) {",
449 " return; // do not add?",
454 " //print(\"pos is %d \\n\".printf(pos));",
456 " Gtk.TreeIter n_iter; ",
458 " if ( parent_str.length < 1) {",
459 " this.el.append(out n_iter, null); // drop at top level..",
460 " node.parent = null;",
461 " _this.main_window.windowstate.file.tree = node;",
464 " } else if (pos < 2) {",
465 " //print(target_data[1] > 0 ? 'insert_after' : 'insert_before');",
467 " this.el.get_iter(out iter_after, tree_path ); ",
468 " this.el.iter_parent(out iter_par, iter_after);",
469 " expand_parent = this.el.get_path(iter_par);",
472 " // not sure why all the 'dup_object()' stuff? did it crash before?",
473 " GLib.Value value;",
474 " this.el.get_value( iter_par, 2, out value);",
475 " parentNode = (JsRender.Node)value.dup_object();",
478 " this.el.get_value( iter_after, 2, out value);",
479 " var relNode = (JsRender.Node)value.dup_object();",
483 " this.el.insert_after(out n_iter, iter_par , iter_after);",
484 " var ix = parentNode.items.index_of(relNode);",
485 " parentNode.items.insert(ix+1, node);",
488 " this.el.insert_before(out n_iter, iter_par , iter_after);",
489 " var ix = parentNode.items.index_of(relNode);",
490 " parentNode.items.insert(ix, node);",
493 " node.parent = parentNode;",
498 " // print(\"appending to \" + parent_str);",
499 " this.el.get_iter(out iter_par, tree_path);",
500 " this.el.append(out n_iter, iter_par );",
501 " expand_parent = this.el.get_path(iter_par);",
503 " GLib.Value value;",
504 " this.el.get_value( iter_par, 2, out value);",
505 " parentNode = (JsRender.Node)value.dup_object();",
506 " node.parent = parentNode;",
507 " parentNode.items.add(node);",
513 " // work out what kind of packing to use.. -- should be in ",
516 " //_this.main_window.windowstate.file.palete().fillPack(node,parentNode);",
517 " _this.main_window.windowstate.file.palete().on_child_added(parentNode,node);",
521 " // add the node...",
523 " this.el.set(n_iter, 0, node.nodeTitle(), 1, node.nodeTip(), -1 );",
524 " var o = GLib.Value(typeof(Object));",
525 " o.set_object((Object)node);",
527 " this.el.set_value(n_iter, 2, o);",
532 "// load children - if it has any..",
534 " if (node.items.size > 0) {",
535 " this.load(node.items, n_iter);",
536 " _this.view.el.expand_row(this.el.get_path(n_iter), true);",
537 " } else if (expand_parent != null && !_this.view.el.is_row_expanded(expand_parent)) {",
538 " _this.view.el.expand_row(expand_parent,true);",
541 " //if (tp != null && (node.items.length() > 0 || pos > 1)) {",
542 " // _this.view.el.expand_row(this.el.get_path(iter_par), true);",
544 " // wee need to get the empty proptypes from somewhere..",
546 " //var olditer = this.activeIter;",
547 " this.activePath = this.el.get_path(n_iter).to_string();",
550 " // pretend button was pressed, so that we can trigger select node...",
551 " _this.view.button_is_pressed = true;",
552 " _this.view.lastEventSource = \"\";",
553 " _this.view.el.set_cursor(this.el.get_path(n_iter), null, false);",
554 " _this.view.button_is_pressed = false;",
563 "(Gee.ArrayList<JsRender.Node> tr, Gtk.TreeIter? iter) ",
565 " Gtk.TreeIter citer;",
566 " //this.insert(citer,iter,0);",
567 " var ic = Gtk.IconTheme.get_default();",
568 " var pixdef = ic.load_icon(\"emblem-new\", 16,0);",
570 " for(var i =0 ; i < tr.size; i++) {",
571 " if (iter != null) {",
572 " this.el.insert(out citer,iter,-1); // why not append?",
574 " this.el.append(out citer,null);",
577 " this.el.set(citer, 0, tr.get(i).nodeTitle(),",
578 " 1, tr.get(i).nodeTip(), -1",
580 " var o = GLib.Value(typeof(Object));",
581 " o.set_object((Object)tr.get(i));",
583 " this.el.set_value(citer, 2, o);",
585 " var clsname = tr.get(i).fqn();",
587 " var clsb = clsname.split(\".\");",
588 " var sub = clsb.length > 1 ? clsb[1].down() : \"\";",
590 " var pix = pixdef;",
591 " var fn = \"/usr/share/glade/pixmaps/hicolor/16x16/actions/widget-gtk-\" + sub + \".png\";",
592 " if (FileUtils.test (fn, FileTest.IS_REGULAR)) {",
593 "\t pix = new Gdk.Pixbuf.from_file (fn);",
597 " this.el.set_value(citer, 3, pix );",
603 " if (tr.get(i).items.size > 0) {",
604 " this.load(tr.get(i).items, citer);",
612 "| void loadFile" : [
613 "(JsRender.JsRender f) {",
614 " //console.dump(f);",
616 " _this.main_window.windowstate.leftTreeNodeSelected(null, \"\");",
618 " _this.main_window.windowstate.file = f;",
621 " if (f.tree == null) {",
623 "\t f.loadItems( );",
624 " } catch (Error e) {",
628 " // if it's still null?",
629 " if (f.tree == null) {",
633 " var o = new Gee.ArrayList<JsRender.Node>();",
635 " this.load(o,null);",
637 " _this.view.el.expand_all();",
639 " if (f.tree.items.size < 1) {",
642 " //this.get('/Window.leftvpaned').el.set_position(80);",
643 " // select first...",
644 " _this.view.el.set_cursor( ",
645 " new Gtk.TreePath.from_string(\"0\"), null, false);",
649 " //this.get('/Window.leftvpaned').el.set_position(200);",
658 "| void moveNode" : [
659 "(string target_data, Gdk.DragAction action) ",
662 " /// target_data = \"path|pos\");",
665 " //print(\"MOVE NODE\");",
666 " // console.dump(target_data);",
667 " Gtk.TreeIter old_iter;",
668 " Gtk.TreeModel mod;",
670 " var s = _this.view.el.get_selection();",
671 " s.get_selected(out mod , out old_iter);",
672 " mod.get_path(old_iter);",
674 " var node = this.pathToNode(mod.get_path(old_iter).to_string());",
675 " //console.dump(node);",
676 " if (node == null) {",
677 " print(\"moveNode: ERROR - node is null?\");",
682 " // needs to drop first, otherwise the target_data ",
683 " // treepath will be invalid.",
686 " if ((action & Gdk.DragAction.MOVE) > 0) {",
687 " print(\"REMOVING OLD NODE : \" + target_data + \"\\n\");",
689 " this.dropNode(target_data, node, false);",
690 " this.el.remove(ref old_iter);",
695 " print(\"DROPPING NODE // copy: \" + target_data + \"\\n\");",
696 " node = node.deepClone();",
697 " this.dropNode(target_data, node, false);",
700 " this.activePath= \"\";",
701 " //this.updateNode(false,true);",
705 "| void updateSelected" : [
709 " var s = _this.view.el.get_selection();",
711 " Gtk.TreeIter iter;",
712 " Gtk.TreeModel mod;",
716 " if (!s.get_selected(out mod, out iter)) {",
717 " return; // nothing seleted..",
720 " GLib.Value value;",
721 " this.el.get_value(iter, 2, out value);",
722 " var node = (JsRender.Node)(value.get_object());",
724 " this.el.set(iter, 0, node.nodeTitle(),",
725 " 1, node.nodeTip(), -1",
734 " this.el.add_attribute(_this.renderer.el , \"markup\", 0 );",
735 " this.el.add_attribute(_this.iconrender.el , \"pixbuf\", 3 );",
738 "* pack" : "append_column",
742 "* pack" : "pack_start,true",
744 "xtype" : "CellRendererPixbuf"
748 "* pack" : "pack_start,true",
750 "xtype" : "CellRendererText"
753 "utf8 title" : "test",
754 "xtype" : "TreeViewColumn"
758 "button_press_event" : [
760 " //console.log(\"button press?\");",
761 " this.button_is_pressed = true;",
762 " print(\"BUTTON DOWN\\n\");",
764 " this.lastEventSource = \"tree\";",
765 " if (! _this.before_node_change() ) {",
772 " if (ev.type != Gdk.EventType.BUTTON_PRESS || ev.button != 3) {",
773 " //print(\"click\" + ev.type);",
776 " Gtk.TreePath res;",
777 " if (!_this.view.el.get_path_at_pos((int)ev.x,(int)ev.y, out res, null, null, null) ) {",
782 " _this.main_window.windowstate.leftTreeBeforeChange();",
786 " this.el.get_selection().select_path(res);",
788 " //if (!this.get('/LeftTreeMenu').el) { ",
789 " // this.get('/LeftTreeMenu').init(); ",
792 " _this.LeftTreeMenu.el.set_screen(Gdk.Screen.get_default());",
793 " _this.LeftTreeMenu.el.show_all();",
794 " _this.LeftTreeMenu.el.popup(null, null, null, 3, ev.time);",
795 " // print(\"click:\" + res.path.to_string());",
799 "button_release_event" : [
801 " this.button_is_pressed = false;",
807 " print(\"LEFT TREE Cursor Changed\\n\");",
808 "\tif (!this.button_is_pressed && !this.key_is_pressed) {",
809 "\t\t// then event was started by some other action",
810 "\t\t// which should manually trigger all the events..",
811 "\t\tprint(\"SKIPPING select - no button or key pressed\\n\");",
816 " if (this.blockChanges) { // probably not needed.. ",
817 "\t\tprint(\"SKIPPING select - blockchanges set..\\n\"); ",
820 " if (!_this.before_node_change( ) ) {",
821 "\t this.blockChanges = true;",
822 "\t this.el.get_selection().unselect_all();",
823 "\t this.blockChanges = false;",
827 " if (_this.main_window.windowstate.file == null) {",
828 " \t\tprint(\"SKIPPING select windowstate file is not set...\\n\"); ",
832 " //var render = this.get('/LeftTree').getRenderer(); ",
833 " print(\"LEFT TREE -> view -> selection changed called\\n\");",
836 " // -- it appears that the selection is not updated.",
838 " GLib.Timeout.add_full(GLib.Priority.DEFAULT,10 , () => {",
839 " print(\"LEFT TREE -> view -> selection changed TIMEOUT CALLED\\n\");",
841 " if (this.el.get_selection().count_selected_rows() < 1) {",
843 " print(\"selected rows < 1\\n\");",
844 " //??this.model.load( false);",
845 " _this.node_selected(null, this.lastEventSource);",
850 " //console.log('changed');",
851 " var s = this.el.get_selection();",
852 " Gtk.TreeIter iter;",
853 " Gtk.TreeModel mod;",
854 " s.get_selected(out mod, out iter);",
857 " // var val = \"\";",
858 " GLib.Value value;",
859 " _this.model.el.get_value(iter, 2, out value);",
860 " _this.model.activePath = mod.get_path(iter).to_string();",
862 " var node = (JsRender.Node)value.dup_object();",
863 " print (\"calling left_tree.node_selected\\n\");",
864 " _this.node_selected(node, this.lastEventSource);",
865 " while (Gtk.events_pending()) {",
866 " Gtk.main_iteration();",
868 " var cp = mod.get_path(iter);",
869 " Gtk.TreePath sp, ep;",
870 " this.el.get_visible_range(out sp, out ep);",
871 " // if sp is before cp then retuns 1.",
872 " // if cp is before ep then retuns 1.",
873 " if (cp.compare(sp) >= 0 && ep.compare(cp) >=1) {",
879 " this.el.scroll_to_cell(new Gtk.TreePath.from_string(_this.model.activePath), null, true, 0.1f,0.0f);",
883 " //_this.after_node_change(node);",
885 "// _this.model.file.changed(node, \"tree\");",
887 " //Seed.print( value.get_string());",
894 "\t//print('SOURCE: drag-begin');",
897 " //this.targetData = \"\";",
899 " // find what is selected in our tree...",
901 " var s = _this.view.el.get_selection();",
902 " if (s.count_selected_rows() < 1) {",
905 " Gtk.TreeIter iter;",
906 " Gtk.TreeModel mod;",
907 " s.get_selected(out mod, out iter);",
911 " // set some properties of the tree for use by the dropped element.",
912 " GLib.Value value;",
913 " _this.model.el.get_value(iter, 2, out value);",
914 " var tp = mod.get_path(iter).to_string();",
915 " var data = (JsRender.Node)(value.dup_object());",
916 " var xname = data.fqn();",
917 " print (\"XNAME IS \" + xname+ \"\\n\");",
918 " this.dragData = tp;",
919 " this.dropList = _this.main_window.windowstate.file.palete().getDropList(xname);",
921 " print (\"DROP LIST IS \" + string.joinv(\", \", this.dropList) + \"\\n\");",
924 " // make the drag icon a picture of the node that was selected",
927 " // by default returns the path..",
928 " var path = _this.model.el.get_path(iter);",
931 " var pix = this.el.create_row_drag_icon ( path);",
933 " Gtk.drag_set_icon_surface (ctx, pix) ;",
939 "( drag_context, data, info, time) => {",
942 "\t//print(\"drag-data-get\");",
943 "\tvar s = this.el.get_selection();",
944 "\tif (s.count_selected_rows() < 1) {",
945 "\t\tdata.set_text(\"\",0); ",
946 "\t\t print(\"return empty string - no selection..\");",
950 "\tGtk.TreeIter iter;",
951 "\tGtk.TreeModel mod;",
953 "\ts.get_selected(out mod, out iter);",
957 "\tGLib.Value value;",
958 "\t_this.model.el.get_value(iter, 2, out value);",
959 "\tvar ndata = (JsRender.Node)(value.dup_object());",
963 "\tvar tp = mod.get_path(iter).to_string();",
964 "\t// by default returns the path..",
966 "\tif ( info != Gdk.Atom.intern(\"STRING\",true) ) {",
967 "\t\ttp = ndata.toJsonString();",
970 "\t//data.set_text(tp,tp.length); ",
972 "\tdata.set (data.get_target (), 8, (uchar[]) tp.to_utf8 ());",
975 "\t// print(\"return \" + tp);",
978 "drag_data_received" : [
979 "\t(ctx, x, y, sel, info, time) => {",
981 "\t// THIS CODE ONLY RELATES TO drag or drop of \"NEW\" elements or \"FROM another tree..\"",
984 "\t// print(\"Tree: drag-data-received\\n\");",
985 "\tvar selection_text = (string)sel.get_data();",
986 "\t//print(\"selection_text= %s\\n\",selection_text);",
988 "\tvar is_drag = this.drag_in_motion;",
992 "\tGLib.debug(\"Is Drag %s\\n\", is_drag ? \"Y\": \"N\");",
993 "\tvar targetData = \"\";",
995 "\tGtk.TreePath path;",
996 "\tGtk.TreeViewDropPosition pos;",
997 "\tvar isOver = _this.view.el.get_dest_row_at_pos(this.drag_x,this.drag_y, out path, out pos);",
999 "\t// if there are not items in the tree.. the we have to set isOver to true for anything..",
1000 "\tvar isEmpty = false;",
1001 "\tif (_this.model.el.iter_n_children(null) < 1) {",
1002 "\t\tGLib.debug(\"got NO children?\\n\");",
1003 "\t\tisOver = true; //??? ",
1004 "\t\tisEmpty = true;",
1005 "\t\tpos = Gtk.TreeViewDropPosition.INTO_OR_AFTER;",
1009 "\t//console.log(\"LEFT-TREE: drag-motion\");",
1010 "\tvar src = Gtk.drag_get_source_widget(ctx);",
1012 "\t// a drag from self - this should be handled by drop and motion.",
1013 "\tif (src == this.el) {",
1014 "\t\tGLib.debug(\"Source == this element should not happen.. ? \\n\");",
1017 "\t//print(\"drag_data_recieved from another element\");",
1022 "\tif (selection_text == null || selection_text.length < 1 || !isOver) {",
1023 "\t\t// nothing valid foudn to drop...",
1024 "\t\t GLib.debug(\"empty sel text or not over\");",
1025 "\t\tif (is_drag) {",
1026 "\t\t Gdk.drag_status(ctx, 0, time);",
1027 "\t\t this.highlightDropPath(\"\", (Gtk.TreeViewDropPosition)0);",
1030 "\t\tGtk.drag_finish (ctx, false, false, time); // drop failed..",
1031 "\t\t// no drop action...",
1035 "\tvar dropNode = new JsRender.Node(); ",
1037 "\tvar dropNodeType = selection_text;",
1038 "\tvar show_templates = true;",
1040 "\tif (dropNodeType[0] == '{') {",
1041 "\t\tvar pa = new Json.Parser();",
1043 "\t\t pa.load_from_data(dropNodeType);",
1044 "\t\t} catch (Error e) {",
1045 "\t\t Gtk.drag_finish (ctx, false, false, time); // drop failed..",
1046 "\t\t // no drop action...",
1050 "\t\tdropNode.loadFromJson( pa.get_root().get_object(), 2);",
1051 "\t\tdropNodeType = dropNode.fqn();",
1052 "\t\tshow_templates = false;",
1056 "\t\t// drop with property.",
1057 "\t\tif (selection_text.contains(\":\")) {",
1058 "\t\t\tvar bits = selection_text.split(\":\");",
1059 "\t\t dropNode.setFqn(bits[0]);",
1060 "\t\t dropNode.set_prop(new JsRender.NodeProp.special(\"prop\", bits[1]));",
1065 "\t\t dropNode.setFqn(selection_text);",
1070 "\t// dropList --- need to gather this ... ",
1071 "\tGLib.debug(\"get dropList for : %s\\n\",dropNodeType); ",
1072 "\tvar dropList = _this.main_window.windowstate.file.palete().getDropList(dropNodeType);",
1074 "\tGLib.debug(\"dropList: %s\\n\", string.joinv(\" , \", dropList));",
1076 "\t// if drag action is link ... then we can drop it anywahere...",
1077 "\t if ((ctx.get_actions() & Gdk.DragAction.LINK) > 0) {",
1078 "\t\t // if path is null?? dragging into an empty tree?",
1079 "\t\t targetData = (path == null ? \"\" : path.to_string()) + \"|%d\".printf((int)pos);",
1083 "\t\ttargetData = _this.model.findDropNodeByPath( isEmpty ? \"\" : path.to_string(), dropList, pos);",
1088 "\tGLib.debug(\"targetDAta: %s\", targetData );",
1090 "\tif (targetData.length < 1) {",
1092 "\t\t// invalid drop path..",
1093 "\t\tif (this.drag_in_motion) {",
1094 "\t\t Gdk.drag_status(ctx, 0, time);",
1095 "\t\t this.highlightDropPath(\"\", (Gtk.TreeViewDropPosition)0);",
1098 "\t\tGtk.drag_finish (ctx, false, false, time); // drop failed..",
1099 "\t\t// no drop action...",
1105 "\t var td_ar = targetData.split(\"|\");",
1108 "\tif (this.drag_in_motion) { ",
1109 "\t\tGdk.drag_status(ctx, Gdk.DragAction.COPY ,time);",
1111 "\t\tthis.highlightDropPath( td_ar[0] , (Gtk.TreeViewDropPosition)int.parse(td_ar[1]));",
1114 "\t// continue on to allow drop..",
1117 "\t// at this point, drag is not in motion... -- as checked above... - so it's a real drop event..",
1119 "\t// {parent}|{pos}|{prop}",
1122 " _this.model.dropNode(targetData, dropNode, show_templates);",
1124 "\tGLib.debug(\"ADD new node!!!\\n\");",
1126 "\t///Xcls_DialogTemplateSelect.singleton().show( _this.model.file.palete(), node);",
1128 "\tGtk.drag_finish (ctx, false, false,time);",
1137 " ( ctx, x, y, time) => {",
1138 " //Seed.print(\"TARGET: drag-drop\");",
1141 " var src = Gtk.drag_get_source_widget(ctx);",
1143 " if (src != this.el) {",
1147 " this.drag_in_motion = false; ",
1148 " // request data that will be recieved by the recieve... ",
1149 " Gtk.drag_get_data",
1151 " this.el, // will receive 'drag-data-received' signal ",
1152 " ctx, // represents the current state of the DnD ",
1153 " Gdk.Atom.intern(\"application/json\",true), // the target type we want ",
1154 " time // time stamp ",
1158 " // No target offered by source => error",
1164 " // handle drop around self..",
1168 " //print(\"GETTING POS\");",
1169 " var targetData = \"\";",
1171 " Gtk.TreePath path;",
1172 " Gtk.TreeViewDropPosition pos;",
1173 " var isOver = _this.view.el.get_dest_row_at_pos(this.drag_x,this.drag_y, out path, out pos);",
1175 " // if there are not items in the tree.. the we have to set isOver to true for anything..",
1176 " var isEmpty = false;",
1177 " if (_this.model.el.iter_n_children(null) < 1) {",
1178 " print(\"got NO children?\\n\");",
1179 " isOver = true; //??? ",
1181 " pos = Gtk.TreeViewDropPosition.INTO_OR_AFTER;",
1186 " //var action = Gdk.DragAction.COPY;",
1187 " // unless we are copying!!! ctl button..",
1189 " var action = (ctx.get_actions() & Gdk.DragAction.MOVE) > 0 ?",
1190 " Gdk.DragAction.COPY : Gdk.DragAction.MOVE ;",
1191 " // Gdk.DragAction.MOVE : Gdk.DragAction.COPY ;",
1194 " if (_this.model.el.iter_n_children(null) < 1) {",
1195 " // no children.. -- asume it's ok..",
1197 " targetData = \"|%d|\".printf((int)Gtk.TreeViewDropPosition.INTO_OR_AFTER);",
1199 " // continue through to allow drop...",
1207 " //print(\"ISOVER? \" + isOver);",
1210 " Gtk.drag_finish (ctx, false, false, time); // drop failed..",
1211 " return true; // not over apoint!?! - no action on drop or motion..",
1214 " // drag node is parent of child..",
1215 " //console.log(\"SRC TREEPATH: \" + src.treepath);",
1216 " //console.log(\"TARGET TREEPATH: \" + data.path.to_string());",
1218 " // nned to check a few here..",
1219 " //Gtk.TreeViewDropPosition.INTO_OR_AFTER",
1220 " //Gtk.TreeViewDropPosition.INTO_OR_BEFORE",
1221 " //Gtk.TreeViewDropPosition.AFTER",
1222 " //Gtk.TreeViewDropPosition.BEFORE",
1224 " // locally dragged items to not really use the ",
1225 " var selection_text = this.dragData;",
1229 " if (selection_text == null || selection_text.length < 1) {",
1230 " //print(\"Error - drag selection text returned NULL\");",
1232 " Gtk.drag_finish (ctx, false, false, time); // drop failed..",
1233 " return true; /// -- fixme -- this is not really correct..",
1236 " // see if we are dragging into ourself?",
1237 " print (\"got selection text of \" + selection_text);",
1239 " var target_path = path.to_string();",
1240 " //print(\"target_path=\"+target_path);",
1243 " if (selection_text == target_path) {",
1244 " print(\"self drag ?? == we should perhaps allow copy onto self..\\n\");",
1246 " Gtk.drag_finish (ctx, false, false, time); // drop failed..",
1248 " return true; /// -- fixme -- this is not really correct..",
1253 " //print(\"DUMPING DATA\");",
1254 " //console.dump(data);",
1257 " //print(data.path.to_string() +' => '+ data.pos);",
1259 " // dropList is a list of xtypes that this node could be dropped on.",
1260 " // it is set up when we start to drag..",
1263 " targetData = _this.model.findDropNodeByPath( path.to_string(), this.dropList, pos);",
1265 " print(\"targetDAta: \" + targetData +\"\\n\");",
1267 " if (targetData.length < 1) {",
1268 " //print(\"Can not find drop node path\");",
1270 " Gtk.drag_finish (ctx, false, false, time); // drop failed..",
1276 " // continue on to allow drop..",
1278 " // at this point, drag is not in motion... -- as checked above... - so it's a real drop event..",
1281 " var delete_selection_data = false;",
1283 " if (action == Gdk.DragAction.ASK) {",
1284 " /* Ask the user to move or copy, then set the ctx action. */",
1287 " if (action == Gdk.DragAction.MOVE) {",
1288 " delete_selection_data = true;",
1291 " // drag around.. - reorder..",
1292 " _this.model.moveNode(targetData, action);",
1298 " // we can send stuff to souce here...",
1301 "// do we always say failure, so we handle the reall drop?",
1302 " Gtk.drag_finish (ctx, false, false,time); //delete_selection_data, time);",
1314 " (drag_context) => {",
1315 "\t//Seed.print('LEFT-TREE: drag-end');",
1316 " this.dragData = \"\";",
1317 " this.dropList = null;",
1318 "// this.targetData = \"\";",
1319 " this.highlightDropPath(\"\",0);",
1324 " ( ctx, x, y, time) => {",
1325 " print(\"got drag motion\\n\");",
1326 " var src = Gtk.drag_get_source_widget(ctx);",
1327 " this.drag_x = x;",
1328 " this.drag_y = y; ",
1330 " if (src != this.el) {",
1334 " // the point of this is to detect where an item could be dropped..",
1335 " print(\"requesting drag data\\n\");",
1336 " this.drag_in_motion = true;",
1338 " // request data that will be recieved by the recieve... ",
1339 " Gtk.drag_get_data",
1341 " this.el, // will receive 'drag-data-received' signal ",
1342 " ctx, // represents the current state of the DnD ",
1343 " Gdk.Atom.intern(\"STRING\",true), // the target type we want ",
1344 " time // time stamp ",
1350 " print(\"action: %d\\n\", ctx.get_actions());",
1351 " //print(\"GETTING POS\");",
1352 " var targetData = \"\";",
1354 " Gtk.TreePath path;",
1355 " Gtk.TreeViewDropPosition pos;",
1356 " var isOver = _this.view.el.get_dest_row_at_pos(this.drag_x,this.drag_y, out path, out pos);",
1358 " // if there are not items in the tree.. the we have to set isOver to true for anything..",
1359 " var isEmpty = false;",
1360 " if (_this.model.el.iter_n_children(null) < 1) {",
1361 " print(\"got NO children?\\n\");",
1362 " isOver = true; //??? ",
1364 " pos = Gtk.TreeViewDropPosition.INTO_OR_AFTER;",
1368 " // ------------- a drag from self..",
1371 " //var action = Gdk.DragAction.COPY;",
1372 " // unless we are copying!!! ctl button..",
1374 " var action = (ctx.get_actions() & Gdk.DragAction.MOVE) > 0 ?",
1375 " Gdk.DragAction.COPY : Gdk.DragAction.MOVE ;",
1376 " // Gdk.DragAction.MOVE : Gdk.DragAction.COPY ;",
1379 " if (_this.model.el.iter_n_children(null) < 1) {",
1380 " // no children.. -- asume it's ok..",
1382 " targetData = \"|%d|\".printf((int)Gtk.TreeViewDropPosition.INTO_OR_AFTER);",
1384 " this.highlightDropPath(\"\", (Gtk.TreeViewDropPosition)0); ",
1385 " Gdk.drag_status(ctx, action ,time);",
1388 " // continue through to allow drop...",
1396 " //print(\"ISOVER? \" + isOver);",
1399 " Gdk.drag_status(ctx, 0 ,time);",
1400 " this.highlightDropPath(\"\", (Gtk.TreeViewDropPosition)0); ",
1405 " // drag node is parent of child..",
1406 " //console.log(\"SRC TREEPATH: \" + src.treepath);",
1407 " //console.log(\"TARGET TREEPATH: \" + data.path.to_string());",
1409 " // nned to check a few here..",
1410 " //Gtk.TreeViewDropPosition.INTO_OR_AFTER",
1411 " //Gtk.TreeViewDropPosition.INTO_OR_BEFORE",
1412 " //Gtk.TreeViewDropPosition.AFTER",
1413 " //Gtk.TreeViewDropPosition.BEFORE",
1415 " // locally dragged items to not really use the ",
1416 " var selection_text = this.dragData;",
1420 " if (selection_text == null || selection_text.length < 1) {",
1421 " //print(\"Error - drag selection text returned NULL\");",
1422 " Gdk.drag_status(ctx, 0 ,time);",
1423 " this.highlightDropPath(\"\", (Gtk.TreeViewDropPosition)0);",
1428 " // see if we are dragging into ourself?",
1429 " var target_path = path.to_string(); ",
1430 " print (\"Drag %s onto %s--%d\\n \", selection_text, target_path, pos);",
1432 " // pos : 3 = ontop - 0 = after, 1 = before",
1433 " //print(\"target_path=\"+target_path);",
1436 " if (selection_text == target_path) {",
1437 " print(\"self drag ?? == we should perhaps allow copy onto self..\\n\");",
1439 " Gdk.drag_status(ctx, 0 ,time);",
1440 " this.highlightDropPath(\"\", (Gtk.TreeViewDropPosition)0);",
1442 "// -- fixme -- this is not really correct..",
1447 " //print(\"DUMPING DATA\");",
1448 " //console.dump(data);",
1451 " //print(data.path.to_string() +' => '+ data.pos);",
1453 " // dropList is a list of xtypes that this node could be dropped on.",
1454 " // it is set up when we start to drag..",
1457 " targetData = _this.model.findDropNodeByPath( path.to_string(), this.dropList, pos);",
1459 " print(\"targetDAta: \" + targetData +\"\\n\");",
1461 " if (targetData.length < 1) {",
1462 " //print(\"Can not find drop node path\");",
1464 " Gdk.drag_status(ctx, 0, time);",
1465 " this.highlightDropPath(\"\", (Gtk.TreeViewDropPosition)0);",
1469 " var td_ar = targetData.split(\"|\");",
1473 " Gdk.drag_status(ctx, action ,time);",
1474 " this.highlightDropPath(td_ar[0], (Gtk.TreeViewDropPosition)int.parse(td_ar[1]));",
1480 "key_press_event" : [
1482 " this.key_is_pressed = true;",
1486 "key_release_event" : [
1488 " this.key_is_pressed = false;",
1494 "tooltip_column" : 1,
1495 "xtype" : "TreeView",
1496 "| void highlightDropPath" : [
1497 " ( string treepath, Gtk.TreeViewDropPosition pos) {",
1499 " // highlighting for drag/drop",
1500 " if (treepath.length > 0) {",
1501 " this.el.set_drag_dest_row( new Gtk.TreePath.from_string( treepath ), pos);",
1503 " this.el.set_drag_dest_row(null, Gtk.TreeViewDropPosition.INTO_OR_AFTER);",
1508 "| void selectNode" : [
1509 "(string treepath_str, string source) {",
1510 "\tthis.lastEventSource = source;",
1511 " //this.selection.select_path(new Gtk.TreePath.from_string( treepath_str));",
1512 " var tp = new Gtk.TreePath.from_string(treepath_str);",
1514 " this.el.set_cursor(tp, null, false); ",
1515 " this.el.scroll_to_cell(tp, null, false, 0,0);",
1519 "| void setCursor" : [
1520 "(string treepath, string sourceEvent) {",
1521 "\tthis.lastEventSource = sourceEvent;",
1522 "\t//this.blockChanges = true; << block changes prevents loading of 'node data' and firing of node_selected..",
1523 " this.el.set_cursor(new Gtk.TreePath.from_string(treepath), null, false); ",
1524 " // fire node_selected..",
1525 " //this.blockChanges = false;",
1526 "\tthis.lastEventSource = \"\";",
1534 "id" : "LeftTreeMenu",
1539 "label" : "Delete Element",
1544 " print(\"ACTIVATE?\");",
1547 " _this.model.deleteSelected();",
1551 "xtype" : "MenuItem"
1556 "label" : "Save as Template",
1561 " DialogSaveTemplate.singleton().show(",
1562 " (Gtk.Window) _this.el.get_toplevel (), ",
1563 " _this.main_window.windowstate.file.palete(), ",
1564 " _this.getActiveElement()",
1571 "xtype" : "MenuItem"
1576 "label" : "Save as Module",
1580 " var node = _this.getActiveElement();",
1581 " var name = DialogSaveModule.singleton().show(",
1582 " (Gtk.Window) _this.el.get_toplevel (), ",
1583 " _this.main_window.windowstate.project, ",
1586 " if (name.length < 1) {",
1590 " node.set_prop( new JsRender.NodeProp.special(\"xinclude\", name));",
1591 " node.items.clear();",
1594 " var s = _this.view.el.get_selection();",
1596 " print(\"GET SELECTED?\");",
1597 " Gtk.TreeIter iter;",
1598 " Gtk.TreeModel mod;",
1601 " if (!s.get_selected(out mod, out iter)) {",
1602 " return; // nothing seleted..",
1604 " Gtk.TreeIter citer;",
1605 " var n_cn = mod.iter_n_children(iter) -1;",
1606 " for (var i = n_cn; i > -1; i--) {",
1607 " mod.iter_nth_child(out citer, iter, i);",
1610 " print(\"removing node from Tree\\n\"); ",
1612 " _this.model.el.remove(ref citer);",
1614 " _this.changed();",
1615 " _this.node_selected(node, \"tree\");",
1621 "xtype" : "MenuItem"
1627 "xtype" : "ScrolledWindow"
1631 "| JsRender.JsRender getActiveFile" : [
1633 " return this.main_window.windowstate.file;",
1637 "| JsRender.Node? getActiveElement" : [
1638 " () { // return path to actie node.",
1640 " var path = this.getActivePath();",
1641 " if (path.length < 1) {",
1644 " return _this.model.pathToNode(path);",
1649 "| string getActivePath" : [
1652 " var view = this.view.el;",
1653 " if (view.get_selection().count_selected_rows() < 1) {",
1656 " Gtk.TreeIter iter;",
1657 " Gtk.TreeModel mod;",
1658 " view.get_selection().get_selected(out mod, out iter);",
1659 " return mod.get_path(iter).to_string();",
1666 "name" : "WindowLeftTree",
1668 "path" : "/home/alan/gitlive/roobuilder/src/Builder4/WindowLeftTree.bjs",