1 static Xcls_WindowLeftTree _WindowLeftTree;
3 public class Xcls_WindowLeftTree : Object
5 public Gtk.ScrolledWindow el;
6 private Xcls_WindowLeftTree _this;
8 public static Xcls_WindowLeftTree singleton()
10 if (_WindowLeftTree == null) {
11 _WindowLeftTree= new Xcls_WindowLeftTree();
13 return _WindowLeftTree;
15 public Xcls_view view;
16 public Xcls_model model;
17 public Xcls_renderer renderer;
18 public Xcls_LeftTreeMenu LeftTreeMenu;
21 public signal bool before_node_change (JsRender.Node? node);
22 public signal void changed ();
23 public signal void node_selected (JsRender.Node? node);
24 public Xcls_MainWindow main_window;
27 public Xcls_WindowLeftTree()
30 this.el = new Gtk.ScrolledWindow( null, null );
33 this.main_window = null;
36 this.el.shadow_type = Gtk.ShadowType.IN;
37 var child_0 = new Xcls_view( _this );
39 this.el.add ( child_0.el );
40 var child_1 = new Xcls_LeftTreeMenu( _this );
45 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC); }
47 // user defined functions
48 public JsRender.Node? getActiveElement () { // return path to actie node.
50 var path = this.getActivePath();
51 if (path.length < 1) {
54 return _this.model.pathToNode(path);
57 public JsRender.JsRender getActiveFile () {
58 return this.model.file;
60 public string getActivePath () {
61 var model = this.model;
62 var view = this.view.el;
63 if (view.get_selection().count_selected_rows() < 1) {
68 view.get_selection().get_selected(out mod, out iter);
69 return mod.get_path(iter).to_string();
71 public class Xcls_view : Object
73 public Gtk.TreeView el;
74 private Xcls_WindowLeftTree _this;
78 public string dragData;
79 public string[] dropList;
82 public bool drag_in_motion;
83 public bool blockChanges;
86 public Xcls_view(Xcls_WindowLeftTree _owner )
90 this.el = new Gtk.TreeView();
93 this.blockChanges = false;
96 this.el.tooltip_column = 1;
97 this.el.enable_tree_lines = true;
98 this.el.headers_visible = false;
99 var child_0 = new Xcls_model( _this );
101 this.el.set_model ( child_0.el );
102 var child_1 = new Xcls_TreeViewColumn4( _this );
104 this.el.append_column ( child_1.el );
109 var description = new Pango.FontDescription();
110 description.set_size(8000);
111 this.el.modify_font(description);
113 var selection = this.el.get_selection();
114 selection.set_mode( Gtk.SelectionMode.SINGLE);
117 // is this really needed??
119 this.selection.signal['changed'].connect(function() {
120 _this.get('/LeftTree.view').listeners.cursor_changed.apply(
121 _this.get('/LeftTree.view'), [ _this.get('/LeftTree.view'), '']
125 Gtk.drag_source_set (
126 this.el, /* widget will be drag-able */
127 Gdk.ModifierType.BUTTON1_MASK, /* modifier that will start a drag */
128 Builder4.Application.targetList, /* lists of target to support */
129 Gdk.DragAction.COPY | Gdk.DragAction.MOVE /* what to do with data after dropped */
133 //Gtk.drag_source_add_text_targets(this.el);
137 this.el, /* widget that will accept a drop */
138 Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,
139 Builder4.Application.targetList, /* lists of target to support */
140 Gdk.DragAction.COPY | Gdk.DragAction.MOVE /* what to do with data after dropped */
143 //Gtk.drag_dest_set_target_list(this.el, Builder.Application.targetList);
144 //Gtk.drag_dest_add_text_targets(this.el);
147 this.el.button_press_event.connect( ( ev) => {
148 //console.log("button press?");
149 if (! _this.before_node_change(null) ) {
154 if (ev.type != Gdk.EventType.BUTTON_PRESS || ev.button != 3) {
155 //print("click" + ev.type);
159 if (!_this.view.el.get_path_at_pos((int)ev.x,(int)ev.y, out res, null, null, null) ) {
163 this.el.get_selection().select_path(res);
165 //if (!this.get('/LeftTreeMenu').el) {
166 // this.get('/LeftTreeMenu').init();
169 _this.LeftTreeMenu.el.set_screen(Gdk.Screen.get_default());
170 _this.LeftTreeMenu.el.show_all();
171 _this.LeftTreeMenu.el.popup(null, null, null, 3, ev.time);
172 // print("click:" + res.path.to_string());
175 this.el.cursor_changed.connect( ( ) => {
178 if (this.blockChanges) { // probably not needed..
181 if (!_this.before_node_change(null) ) {
182 this.blockChanges = true;
183 this.el.get_selection().unselect_all();
184 this.blockChanges = false;
187 if (_this.model.file == null) {
191 //var render = this.get('/LeftTree').getRenderer();
192 print("LEFT TREE -> view -> selection changed called\n");
195 // -- it appears that the selection is not updated.
197 GLib.Timeout.add_full(GLib.Priority.DEFAULT,10 , () => {
200 if (this.el.get_selection().count_selected_rows() < 1) {
202 print("selected rows < 1\n");
203 //??this.model.load( false);
204 _this.node_selected(null);
209 //console.log('changed');
210 var s = this.el.get_selection();
213 s.get_selected(out mod, out iter);
218 _this.model.el.get_value(iter, 2, out value);
219 _this.model.activePath = mod.get_path(iter).to_string();
221 var node = (JsRender.Node)value.dup_object();
222 _this.node_selected(node);
225 //_this.after_node_change(node);
227 // _this.model.file.changed(node, "tree");
229 //Seed.print( value.get_string());
233 this.el.drag_begin.connect( ( ctx) => {
234 //print('SOURCE: drag-begin');
237 //this.targetData = "";
239 // find what is selected in our tree...
241 var s = _this.view.el.get_selection();
242 if (s.count_selected_rows() < 1) {
247 s.get_selected(out mod, out iter);
251 // set some properties of the tree for use by the dropped element.
253 _this.model.el.get_value(iter, 2, out value);
254 var tp = mod.get_path(iter).to_string();
255 var data = (JsRender.Node)(value.dup_object());
256 var xname = data.fqn();
257 print ("XNAME IS " + xname+ "\n");
259 //this.dropList = _this.model.file.palete().getDropList(xname);
261 print ("DROP LIST IS " + string.joinv(", ", this.dropList) + "\n");
264 // make the drag icon a picture of the node that was selected
267 // by default returns the path..
270 var pix = this.el.create_row_drag_icon ( path);
272 Gtk.drag_set_icon_surface (ctx, pix) ;
276 this.el.drag_end.connect( (drag_context) => {
277 //Seed.print('LEFT-TREE: drag-end');
279 this.dropList = null;
280 // this.targetData = "";
281 this.highlightDropPath("",0);
284 this.el.drag_motion.connect( ( ctx, x, y, time) => {
286 // the point of this is to detect where an item could be dropped..
287 print("got drag motion");
288 this.drag_in_motion = true;
292 // request data that will be recieved by the recieve...
295 this.el, // will receive 'drag-data-received' signal
296 ctx, // represents the current state of the DnD
297 Gdk.Atom.intern("STRING",true), // the target type we want
303 this.el.drag_data_get.connect( ( drag_context, data, info, time) => {
306 //print("drag-data-get");
307 var s = this.el.get_selection();
308 if (s.count_selected_rows() < 1) {
310 print("return empty string - no selection..");
317 s.get_selected(out mod, out iter);
322 _this.model.el.get_value(iter, 2, out value);
323 var ndata = (JsRender.Node)(value.dup_object());
324 var xname = ndata.fqn();
327 var tp = mod.get_path(iter).to_string();
328 // by default returns the path..
330 if ( info != Gdk.Atom.intern("STRING",true) ) {
331 tp = node.toJsonString();
334 data.set_text(tp,tp.length);
339 // print("return " + tp);
341 this.el.drag_data_received.connect( (ctx, x, y, sel, info, time) => {
342 //print("Tree: drag-data-received");
345 var is_drag = info == Gdk.Atom.intern("STRING",true),
348 //print("GETTING POS");
352 Gtk.TreeViewDropPosition pos;
353 var isOver = _this.view.el.get_dest_row_at_pos(this.drag_x,this.drag_y, out path, out pos);
355 // if there are not items in the tree.. the we have to set isOver to true for anything..
357 if (_this.model.el.iter_n_children(null) < 1) {
358 print("got NO children?\n");
361 pos = Gtk.TreeViewDropPosition.INTO_OR_AFTER;
365 //console.log("LEFT-TREE: drag-motion");
366 var src = Gtk.drag_get_source_widget(ctx);
368 // a drag from elsewhere...- prevent drop..
369 if (src != this.el) {
370 //print("drag_data_recieved from another element");
373 var selection_text = sel.get_text();
376 if (selection_text == null || selection_text.length < 1 || !isOver) {
377 // nothing valid foudn to drop...
379 Gdk.drag_status(ctx, 0, time);
380 this.highlightDropPath("", (Gtk.TreeViewDropPosition)0);
383 Gtk.drag_finish (ctx, false, false, time); // drop failed..
388 JsRender.Node dropNode = new JsRender.Node();
390 var dropNodeType = selection_text;
391 var show_templates = true;
393 if (!is_drag && dropNodeType[0] == '{') {
394 var pa = new Json.Parser();
395 pa.load_from_data(dropNodeType);
396 dropNode = new JsRender.Node();
397 dropNode.loadFromJson( pa.get_root(), 2);
398 dropNodeType = dropNode.fqn();
399 show_templates = false;
402 dropNode.setFqn(selection_text);
406 // dropList --- need to gather this ...
407 //print("get dropList for : %s\n",selection_text);
408 var dropList = _this.model.file.palete().getDropList(dropNodeType);
410 print("dropList: %s\n", string.joinv(" , ", dropList));
412 targetData = _this.model.findDropNodeByPath( isEmpty ? "" : path.to_string(), dropList, pos);
414 print("targetDAta: " + targetData +"\n");
416 if (targetData.length < 1) {
418 // invalid drop path..
419 if (this.drag_in_motion) {
420 Gdk.drag_status(ctx, 0, time);
421 this.highlightDropPath("", (Gtk.TreeViewDropPosition)0);
424 Gtk.drag_finish (ctx, false, false, time); // drop failed..
430 var td_ar = targetData.split("|");
433 if (this.drag_in_motion) {
434 Gdk.drag_status(ctx, Gdk.DragAction.COPY ,time);
436 this.highlightDropPath( td_ar[0] , (Gtk.TreeViewDropPosition)int.parse(td_ar[1]));
439 // continue on to allow drop..
442 // at this point, drag is not in motion... -- as checked above... - so it's a real drop event..
445 _this.model.dropNode(targetData, dropNode, show_templates);
446 print("ADD new node!!!\n");
448 ///Xcls_DialogTemplateSelect.singleton().show( _this.model.file.palete(), node);
450 Gtk.drag_finish (ctx, false, false,time);
460 // ------------- a drag from self..
463 //var action = Gdk.DragAction.COPY;
464 // unless we are copying!!! ctl button..
465 var action = (ctx.get_actions() & Gdk.DragAction.MOVE) > 0 ? Gdk.DragAction.MOVE : Gdk.DragAction.COPY ;
468 if (_this.model.el.iter_n_children(null) < 1) {
469 // no children.. -- asume it's ok..
471 targetData = "|%d|".printf((int)Gtk.TreeViewDropPosition.INTO_OR_AFTER);
472 if (this.drag_in_motion) {
473 this.highlightDropPath("", (Gtk.TreeViewDropPosition)0);
474 Gdk.drag_status(ctx, action ,time);
477 // continue through to allow drop...
485 //print("ISOVER? " + isOver);
487 if (this.drag_in_motion) {
488 Gdk.drag_status(ctx, 0 ,time);
489 this.highlightDropPath("", (Gtk.TreeViewDropPosition)0);
492 Gtk.drag_finish (ctx, false, false, time); // drop failed..
493 return; // not over apoint!?! - no action on drop or motion..
496 // drag node is parent of child..
497 //console.log("SRC TREEPATH: " + src.treepath);
498 //console.log("TARGET TREEPATH: " + data.path.to_string());
500 // nned to check a few here..
501 //Gtk.TreeViewDropPosition.INTO_OR_AFTER
502 //Gtk.TreeViewDropPosition.INTO_OR_BEFORE
503 //Gtk.TreeViewDropPosition.AFTER
504 //Gtk.TreeViewDropPosition.BEFORE
506 // locally dragged items to not really use the
507 var selection_text = this.dragData;
511 if (selection_text == null || selection_text.length < 1) {
512 //print("Error - drag selection text returned NULL");
513 if (this.drag_in_motion) {
514 Gdk.drag_status(ctx, 0 ,time);
515 this.highlightDropPath("", (Gtk.TreeViewDropPosition)0);
518 Gtk.drag_finish (ctx, false, false, time); // drop failed..
519 return; /// -- fixme -- this is not really correct..
522 // see if we are dragging into ourself?
523 print ("got selection text of " + selection_text);
525 var target_path = path.to_string();
526 //print("target_path="+target_path);
529 if (selection_text == target_path) {
530 print("self drag ?? == we should perhaps allow copy onto self..\n");
531 if (this.drag_in_motion) {
532 Gdk.drag_status(ctx, 0 ,time);
533 this.highlightDropPath("", (Gtk.TreeViewDropPosition)0);
536 Gtk.drag_finish (ctx, false, false, time); // drop failed..
538 return; /// -- fixme -- this is not really correct..
543 //print("DUMPING DATA");
544 //console.dump(data);
547 //print(data.path.to_string() +' => '+ data.pos);
549 // dropList is a list of xtypes that this node could be dropped on.
550 // it is set up when we start to drag..
553 targetData = _this.model.findDropNodeByPath( path.to_string(), this.dropList, pos);
555 print("targetDAta: " + targetData +"\n");
557 if (targetData.length < 1) {
558 //print("Can not find drop node path");
559 if (this.drag_in_motion) {
560 Gdk.drag_status(ctx, 0, time);
561 this.highlightDropPath("", (Gtk.TreeViewDropPosition)0);
564 Gtk.drag_finish (ctx, false, false, time); // drop failed..
568 var td_ar = targetData.split("|");
571 if (this.drag_in_motion) {
572 Gdk.drag_status(ctx, action ,time);
573 this.highlightDropPath(td_ar[0], (Gtk.TreeViewDropPosition)int.parse(td_ar[1]));
576 // continue on to allow drop..
579 // at this point, drag is not in motion... -- as checked above... - so it's a real drop event..
582 var delete_selection_data = false;
584 if (ctx.get_actions() == Gdk.DragAction.ASK) {
585 /* Ask the user to move or copy, then set the ctx action. */
588 if (ctx.get_actions() == Gdk.DragAction.MOVE) {
589 delete_selection_data = true;
593 // drag around.. - reorder..
594 _this.model.moveNode(targetData, ctx.get_actions());
600 // we can send stuff to souce here...
603 // do we always say failure, so we handle the reall drop?
604 Gtk.drag_finish (ctx, false, false,time); //delete_selection_data, time);
607 this.el.drag_drop.connect( ( ctx, x, y, time) => {
608 //Seed.print("TARGET: drag-drop");
611 var src = Gtk.drag_get_source_widget(ctx);
613 if (src != this.el) {
617 this.drag_in_motion = false;
618 // request data that will be recieved by the recieve...
621 this.el, // will receive 'drag-data-received' signal
622 ctx, // represents the current state of the DnD
623 Gdk.Atom.intern("application/json",true), // the target type we want
628 // No target offered by source => error
634 // handle drop around self..
650 // user defined functions
651 public void highlightDropPath ( string treepath, Gtk.TreeViewDropPosition pos) {
653 // highlighting for drag/drop
654 if (treepath.length > 0) {
655 this.el.set_drag_dest_row( new Gtk.TreePath.from_string( treepath ), pos);
657 this.el.set_drag_dest_row(null, Gtk.TreeViewDropPosition.INTO_OR_AFTER);
661 public void selectNode (string treepath_str) {
662 //this.selection.select_path(new Gtk.TreePath.from_string( treepath_str));
663 var tp = new Gtk.TreePath.from_string(treepath_str);
665 this.el.set_cursor(tp, null, false);
666 this.el.scroll_to_cell(tp, null, false, 0,0);
669 public class Xcls_model : Object
671 public Gtk.TreeStore el;
672 private Xcls_WindowLeftTree _this;
676 public DialogTemplateSelect template_select;
677 public JsRender.JsRender? file;
678 public string activePath;
679 public Project.Project? project;
682 public Xcls_model(Xcls_WindowLeftTree _owner )
686 this.el = new Gtk.TreeStore( 3, typeof(string),typeof(string),typeof(Object) );
689 this.template_select = null;
691 this.activePath = "";
694 // set gobject values
698 print("model initialized"); }
700 // user defined functions
701 public string findDropNode (string treepath_str, string[] targets) {
703 // this is used by the dragdrop code in the roo version AFAIR..
705 //var path = treepath_str.replace(/^builder-/, '');
706 // treemap is depreciated... - should really check if model has any entries..
708 if (this.el.iter_n_children(null) < 1) {
710 return "|%d".printf((int)Gtk.TreeViewDropPosition.INTO_OR_AFTER);
712 //print("FIND treepath: " + path);
713 //console.dump(this.treemap);
715 //if (!treepath_str.match(/^builder-/)) {
716 // return []; // nothing!
718 if (targets.length > 0 && targets[0] == "*") {
721 return this.findDropNodeByPath(treepath_str,targets, -1);
723 public void loadFile (JsRender.JsRender f) {
730 // console.log('missing file');
734 // load the file if not loaded..
735 if (f.tree == null) {
738 // if it's still null?
739 if (f.tree == null) {
743 /// this.get('/Window').setTitle(f.project.getName() + ' - ' + f.name);
745 //if (f.items.length && typeof(f.items[0]) == 'string') {
747 //this.get('/RightEditor').el.show();
748 //this.get('/RightEditor.view').load( f.items[0]);
752 //print(JSON.stringify(f.items, null,4));
753 //console.dump(f.items);
754 var o = new Gee.ArrayList<JsRender.Node>();
758 _this.view.el.expand_all();
760 if (f.tree.items.size < 1) {
763 //this.get('/Window.leftvpaned').el.set_position(80);
765 _this.view.el.set_cursor(
766 new Gtk.TreePath.from_string("0"), null, false);
770 //this.get('/Window.leftvpaned').el.set_position(200);
776 //print("hide right editior");
777 //this.get('/RightEditor').el.hide();
778 //this.get('/Editor').el.hide();
779 //print("set current tree");
780 //this.currentTree = this.toJS(false, false)[0];
781 //console.dump(this.currentTree);
782 //this.currentTree = this.currentTree || { items: [] };
783 //_this.renderView();
784 //console.dump(this.map);
785 //var RightPalete = imports.Builder.RightPalete.RightPalete;
788 var pm = this.get('/RightPalete.model');
791 this.get('/RightPalete').provider = this.get('/LeftTree').getPaleteProvider();
793 if (!this.get('/RightPalete').provider) {
794 print ("********* PALETE PROVIDER MISSING?!!");
796 this.get('/LeftTree').renderView();
798 pm.load( this.get('/LeftTree').getPaleteProvider().gatherList(this.listAllTypes()));
802 this.get('/Window.view-notebook').el.set_current_page(
803 this.get('/LeftTree.model').file.getType()== 'Roo' ? 0 : -1);
807 public void updateSelected () {
810 var s = _this.view.el.get_selection();
817 if (!s.get_selected(out mod, out iter)) {
818 return; // nothing seleted..
822 this.el.get_value(iter, 2, out value);
823 var node = (JsRender.Node)(value.get_object());
825 this.el.set(iter, 0, node.nodeTitle(),
826 1, node.nodeTip(), -1
829 public string findDropNodeByPath (string treepath_str, string[] targets, int in_pref = -1) {
831 var path = treepath_str; // dupe it..
833 int pref = in_pref < 0 ? Gtk.TreeViewDropPosition.INTO_OR_AFTER : in_pref;
837 //console.dump(this.treemap);
839 print("findDropNodeByPath : got path length %d / %s\n", path.length, path);
841 if (path.length == 0) {
842 // top drop. // just return empty..
843 return "|%d".printf((int)pref) ;
848 while (path.length > 0) {
849 //print("LOOKING FOR PATH: " + path);
850 var node_data = this.pathToNode(path);
852 if (node_data == null) {
853 print("node not found");
857 var xname = node_data.fqn();
861 for (var i =0; i < targets.length; i++) {
863 if ((tg == xname) ) {
867 // if target is "xxxx:name"
868 if (tg.contains(xname +":")) {
870 var ar = tg.split(":");
876 if (match.length > 0) {
877 if (last.length > 0) { // pref is after/before..
878 // then it's after last
882 return last + "|%d".printf((int)pref) + "|" + prop;
886 return path + "|%d".printf( (int) Gtk.TreeViewDropPosition.INTO_OR_AFTER) + "|" + prop;
889 var par = path.split(":");
891 for (var i = 0; i < par.length-1; i++) {
895 path = string.joinv(":", ppar);
903 public void moveNode (string target_data, Gdk.DragAction action)
906 /// target_data = "path|pos");
909 //print("MOVE NODE");
910 // console.dump(target_data);
911 Gtk.TreeIter old_iter;
914 var s = _this.view.el.get_selection();
915 s.get_selected(out mod , out old_iter);
916 mod.get_path(old_iter);
918 var node = this.pathToNode(mod.get_path(old_iter).to_string());
919 //console.dump(node);
921 print("moveNode: ERROR - node is null?");
926 // needs to drop first, otherwise the target_data
927 // treepath will be invalid.
930 if ((action & Gdk.DragAction.MOVE) > 0) {
931 print("REMOVING OLD NODE : " + target_data + "\n");
933 this.dropNode(target_data, node, false);
934 this.el.remove(ref old_iter);
939 print("DROPPING NODE // copy: " + target_data + "\n");
940 node = node.deepClone();
941 this.dropNode(target_data, node, false);
945 //this.updateNode(false,true);
947 public void load (Gee.ArrayList<JsRender.Node> tr, Gtk.TreeIter? iter)
950 //this.insert(citer,iter,0);
951 for(var i =0 ; i < tr.size; i++) {
953 this.el.insert(out citer,iter,-1); // why not append?
955 this.el.append(out citer,null);
958 this.el.set(citer, 0, tr.get(i).nodeTitle(),
959 1, tr.get(i).nodeTip(), -1
961 var o = new GLib.Value(typeof(Object));
962 o.set_object((Object)tr.get(i));
964 this.el.set_value(citer, 2, o);
966 if (tr.get(i).items.size > 0) {
967 this.load(tr.get(i).items, citer);
974 public void deleteSelected () {
976 print("DELETE SELECTED?");
977 //_this.view.blockChanges = true;
978 print("GET SELECTION?");
980 var s = _this.view.el.get_selection();
982 print("GET SELECTED?");
987 if (!s.get_selected(out mod, out iter)) {
988 return; // nothing seleted..
994 print("GET vnode value?");
997 this.el.get_value(iter, 2, out value);
998 var data = (JsRender.Node)(value.get_object());
999 print("removing node from Render\n");
1000 if (data.parent == null) {
1001 this.file.tree = null;
1005 print("removing node from Tree\n");
1007 this.el.remove(ref iter);
1017 this.activePath= ""; // again!?!?
1018 //this.changed(null,true);
1022 _this.view.blockChanges = false;
1024 public JsRender.Node pathToNode (string path) {
1028 _this.model.el.get_iter_from_string(out iter, path);
1031 _this.model.el.get_value(iter, 2, out value);
1033 return (JsRender.Node)value.dup_object();
1036 public void dropNode (string target_data_str, JsRender.Node node, bool show_templates) {
1037 // print("drop Node");
1038 // console.dump(node);
1039 // console.dump(target_data);
1042 // 0 = before , 1=after 2/3 onto
1045 var target_data= target_data_str.split("|");
1047 var parent_str = target_data[0].length > 0 ? target_data[0] : "";
1048 var pos = target_data.length > 1 ? int.parse(target_data[1]) : 2; // ontop..
1051 Gtk.TreePath tree_path = parent_str.length > 0 ? new Gtk.TreePath.from_string( parent_str ) : null;
1055 //print("add " + tp + "@" + target_data[1] );
1057 JsRender.Node parentNode = null;
1059 Gtk.TreeIter iter_after;
1060 Gtk.TreeIter iter_par ;
1063 if (target_data.length == 3 && target_data[2].length > 0) {
1064 node.props.set("* prop", target_data[2]);
1067 Gtk.TreePath expand_parent = null;
1069 // we only need to show the template if it's come from else where?
1070 if (show_templates) {
1072 if (this.template_select == null) {
1073 this.template_select = new DialogTemplateSelect();
1076 var new_node = this.template_select.show(
1077 (Gtk.Window) _this.el.get_toplevel (),
1081 if (new_node != null) {
1086 //print("pos is %d \n".printf(pos));
1088 Gtk.TreeIter n_iter;
1090 if ( parent_str.length < 1) {
1091 this.el.append(out n_iter, null); // drop at top level..
1093 this.file.tree = node;
1096 } else if (pos < 2) {
1097 //print(target_data[1] > 0 ? 'insert_after' : 'insert_before');
1099 this.el.get_iter(out iter_after, tree_path );
1100 this.el.iter_parent(out iter_par, iter_after);
1101 expand_parent = this.el.get_path(iter_par);
1104 this.el.get_value( iter_par, 2, out value);
1105 parentNode = (JsRender.Node)value.dup_object();
1108 this.el.get_value( iter_after, 2, out value);
1109 var relNode = (JsRender.Node)value.dup_object();
1113 this.el.insert_after(out n_iter, iter_par , iter_after);
1114 var ix = parentNode.items.index_of(relNode);
1115 parentNode.items.insert(ix+1, node);
1118 this.el.insert_before(out n_iter, iter_par , iter_after);
1119 var ix = parentNode.items.index_of(relNode);
1120 parentNode.items.insert(ix, node);
1123 node.parent = parentNode;
1128 // print("appending to " + parent_str);
1129 this.el.get_iter(out iter_par, tree_path);
1130 this.el.append(out n_iter, iter_par );
1131 expand_parent = this.el.get_path(iter_par);
1134 this.el.get_value( iter_par, 2, out value);
1135 parentNode = (JsRender.Node)value.dup_object();
1136 node.parent = parentNode;
1137 parentNode.items.add(node);
1140 // reparent node in tree...
1143 // why only on no parent???
1145 //if (node.parent = null) {
1152 // work out what kind of packing to use.. -- should be in
1153 if (!node.has("pack") && parent_str.length > 1) {
1155 this.file.palete().fillPack(node,parentNode);
1162 this.el.set(n_iter, 0, node.nodeTitle(), 1, node.nodeTip(), -1 );
1163 var o = new GLib.Value(typeof(Object));
1164 o.set_object((Object)node);
1166 this.el.set_value(n_iter, 2, o);
1171 // load children - if it has any..
1173 if (node.items.size > 0) {
1174 this.load(node.items, n_iter);
1175 _this.view.el.expand_row(this.el.get_path(n_iter), true);
1176 } else if (expand_parent != null && !_this.view.el.is_row_expanded(expand_parent)) {
1177 _this.view.el.expand_row(expand_parent,true);
1180 //if (tp != null && (node.items.length() > 0 || pos > 1)) {
1181 // _this.view.el.expand_row(this.el.get_path(iter_par), true);
1183 // wee need to get the empty proptypes from somewhere..
1185 //var olditer = this.activeIter;
1186 this.activePath = this.el.get_path(n_iter).to_string();
1191 _this.view.el.set_cursor(this.el.get_path(n_iter), null, false);
1198 public class Xcls_TreeViewColumn4 : Object
1200 public Gtk.TreeViewColumn el;
1201 private Xcls_WindowLeftTree _this;
1207 public Xcls_TreeViewColumn4(Xcls_WindowLeftTree _owner )
1210 this.el = new Gtk.TreeViewColumn();
1214 // set gobject values
1215 this.el.title = "test";
1216 var child_0 = new Xcls_renderer( _this );
1218 this.el.pack_start ( child_0.el , true );
1222 this.el.add_attribute(_this.renderer.el , "markup", 0 ); }
1224 // user defined functions
1226 public class Xcls_renderer : Object
1228 public Gtk.CellRendererText el;
1229 private Xcls_WindowLeftTree _this;
1235 public Xcls_renderer(Xcls_WindowLeftTree _owner )
1238 _this.renderer = this;
1239 this.el = new Gtk.CellRendererText();
1243 // set gobject values
1246 // user defined functions
1248 public class Xcls_LeftTreeMenu : Object
1251 private Xcls_WindowLeftTree _this;
1257 public Xcls_LeftTreeMenu(Xcls_WindowLeftTree _owner )
1260 _this.LeftTreeMenu = this;
1261 this.el = new Gtk.Menu();
1265 // set gobject values
1266 var child_0 = new Xcls_MenuItem7( _this );
1268 this.el.add ( child_0.el );
1269 var child_1 = new Xcls_MenuItem8( _this );
1271 this.el.add ( child_1.el );
1272 var child_2 = new Xcls_MenuItem9( _this );
1274 this.el.add ( child_2.el );
1277 // user defined functions
1279 public class Xcls_MenuItem7 : Object
1281 public Gtk.MenuItem el;
1282 private Xcls_WindowLeftTree _this;
1288 public Xcls_MenuItem7(Xcls_WindowLeftTree _owner )
1291 this.el = new Gtk.MenuItem();
1295 // set gobject values
1296 this.el.label = "Delete Element";
1299 this.el.activate.connect( ( ) => {
1304 _this.model.deleteSelected();
1308 // user defined functions
1310 public class Xcls_MenuItem8 : Object
1312 public Gtk.MenuItem el;
1313 private Xcls_WindowLeftTree _this;
1319 public Xcls_MenuItem8(Xcls_WindowLeftTree _owner )
1322 this.el = new Gtk.MenuItem();
1326 // set gobject values
1327 this.el.label = "Save as Template";
1330 this.el.activate.connect( () => {
1332 DialogSaveTemplate.singleton().show(
1333 (Gtk.Window) _this.el.get_toplevel (),
1334 _this.model.file.palete(),
1335 _this.getActiveElement()
1342 // user defined functions
1344 public class Xcls_MenuItem9 : Object
1346 public Gtk.MenuItem el;
1347 private Xcls_WindowLeftTree _this;
1353 public Xcls_MenuItem9(Xcls_WindowLeftTree _owner )
1356 this.el = new Gtk.MenuItem();
1360 // set gobject values
1361 this.el.label = "Save as Module";
1364 this.el.activate.connect( () => {
1365 var node = _this.getActiveElement();
1366 var name = DialogSaveModule.singleton().show(
1367 (Gtk.Window) _this.el.get_toplevel (),
1368 _this.model.file.project,
1371 if (name.length < 1) {
1375 node.props.set("* xinclude", name);
1379 var s = _this.view.el.get_selection();
1381 print("GET SELECTED?");
1386 if (!s.get_selected(out mod, out iter)) {
1387 return; // nothing seleted..
1390 var n_cn = mod.iter_n_children(iter) -1;
1391 for (var i = n_cn; i > -1; i--) {
1392 mod.iter_nth_child(out citer, iter, i);
1395 print("removing node from Tree\n");
1397 _this.model.el.remove(ref citer);
1400 _this.node_selected(node);
1406 // user defined functions