From e3b57ccfd017af2d15e1084430f18c477c55b9d6 Mon Sep 17 00:00:00 2001 From: Alan Knowles Date: Tue, 19 May 2015 17:04:46 +0800 Subject: [PATCH] src/Builder4/WindowLeftTree.bjs src/Builder4/WindowLeftTree.vala --- src/Builder4/WindowLeftTree.bjs | 20 ++-- src/Builder4/WindowLeftTree.vala | 168 ++++++++++++++++--------------- 2 files changed, 98 insertions(+), 90 deletions(-) diff --git a/src/Builder4/WindowLeftTree.bjs b/src/Builder4/WindowLeftTree.bjs index 02d3ab822..28106ae16 100644 --- a/src/Builder4/WindowLeftTree.bjs +++ b/src/Builder4/WindowLeftTree.bjs @@ -9,8 +9,8 @@ "items" : [ { "| JsRender.Node? getActiveElement" : " () { // return path to actie node.\n\n var path = this.getActivePath();\n if (path.length < 1) {\n return null;\n }\n return _this.model.pathToNode(path);\n \n}\n", - "id" : "WindowLeftTree", "@ bool before_node_change" : "(JsRender.Node? node)", + "id" : "WindowLeftTree", "$ shadow_type" : "Gtk.ShadowType.IN", "* init" : " this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);\n \n", "| JsRender.JsRender getActiveFile" : "() {\n return this.model.file;\n}\n", @@ -20,13 +20,13 @@ "$ xns" : "Gtk", "@ void node_selected" : "(JsRender.Node? node)", "# Xcls_MainWindow main_window" : "null", - "| string getActivePath" : " () {\n var model = this.model;\n var view = this.view.el;\n if (view.get_selection().count_selected_rows() < 1) {\n return \"\";\n }\n Gtk.TreeIter iter;\n Gtk.TreeModel mod;\n view.get_selection().get_selected(out mod, out iter);\n return mod.get_path(iter).to_string();\n}\n", + "| string getActivePath" : " () {\n var model = this.model;\n var view = this.view.el;\n if (view.get_selection().count_selected_rows() < 1) {\n return \"\";\n }\n Gtk.TreeIter iter;\n Gtk.TreeModel mod;\n view.get_selection().get_selected(out mod, out iter);\n return mod.get_path(iter).to_string();\n}\n ", "items" : [ { "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}", - "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}", "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 while (Gtk.events_pending()) {\n Gtk.main_iteration();\n }\n var cp = mod.get_path(iter);\n Gtk.TreePath sp, ep;\n this.el.get_visible_range(out sp, out ep);\n // if sp is before cp then retuns 1.\n // if cp is before ep then retuns 1.\n if (cp.compare(sp) >= 0 && ep.compare(cp) >=1) {\n return false;\n }\n \n \n \n this.el.scroll_to_cell(new Gtk.TreePath.from_string(_this.model.activePath), null, true, 0.1f,0.0f);\n \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 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 print(\"got drag motion\\n\");\n var src = Gtk.drag_get_source_widget(ctx);\n this.drag_x = x;\n this.drag_y = y; \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(\"requesting drag data\\n\");\n this.drag_in_motion = true;\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 print(\"action: %d\\n\", ctx.get_actions());\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 \n var action = (ctx.get_actions() & Gdk.DragAction.MOVE) > 0 ?\n Gdk.DragAction.COPY : Gdk.DragAction.MOVE ;\n // 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 var target_path = path.to_string(); \n print (\"Drag %s onto %s--%d\\n \", selection_text, target_path, pos);\n \n // pos : 3 = ontop - 0 = after, 1 = before\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 data.set (data.get_target (), 8, (uchar[]) tp.to_utf8 ());\n \n \n // print(\"return \" + tp);\n }", @@ -34,8 +34,8 @@ "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 \n var action = (ctx.get_actions() & Gdk.DragAction.MOVE) > 0 ?\n Gdk.DragAction.COPY : Gdk.DragAction.MOVE ;\n // 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 (action == Gdk.DragAction.ASK) {\n /* Ask the user to move or copy, then set the ctx action. */\n }\n\n if (action == Gdk.DragAction.MOVE) {\n delete_selection_data = true;\n }\n \n // drag around.. - reorder..\n _this.model.moveNode(targetData, action);\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" : "", - "# int drag_x" : "", "# string[] dropList" : "", + "# int drag_x" : "", "id" : "view", "gboolean headers_visible" : true, "# int drag_y" : "", @@ -53,8 +53,8 @@ "items" : [ { "| string findDropNode" : " (string treepath_str, string[] targets) {\n\n // this is used by the dragdrop code in the roo version AFAIR..\n\n //var path = treepath_str.replace(/^builder-/, '');\n // treemap is depreciated... - should really check if model has any entries..\n\n if (this.el.iter_n_children(null) < 1) {\n //print(\"NO KEYS\");\n return \"|%d\".printf((int)Gtk.TreeViewDropPosition.INTO_OR_AFTER);\n }\n //print(\"FIND treepath: \" + path);\n //console.dump(this.treemap);\n \n //if (!treepath_str.match(/^builder-/)) {\n // return []; // nothing!\n //}\n if (targets.length > 0 && targets[0] == \"*\") {\n return treepath_str;\n }\n return this.findDropNodeByPath(treepath_str,targets, -1);\n}\n", - "currentTree" : false, "id" : "model", + "currentTree" : false, "# DialogTemplateSelect template_select" : "null", "* init" : "print(\"model initialized\");\n\n", "| void loadFile" : "(JsRender.JsRender f) {\n //console.dump(f);\n this.el.clear();\n this.file = f;\n \n \n// if (!f) {\n// console.log('missing file');\n// return;\n// }\n \n // load the file if not loaded..\n if (f.tree == null) {\n f.loadItems( );\n }\n // if it's still null?\n if (f.tree == null) {\n return;\n }\n \n /// this.get('/Window').setTitle(f.project.getName() + ' - ' + f.name);\n \n //if (f.items.length && typeof(f.items[0]) == 'string') {\n \n //this.get('/RightEditor').el.show();\n //this.get('/RightEditor.view').load( f.items[0]);\n // return;\n //}\n //print(\"LOAD\");\n //print(JSON.stringify(f.items, null,4));\n //console.dump(f.items);\n var o = new Gee.ArrayList();\n o.add(f.tree);\n this.load(o,null);\n \n _this.view.el.expand_all();\n\n if (f.tree.items.size < 1) {\n // single item..\n \n //this.get('/Window.leftvpaned').el.set_position(80);\n // select first...\n _this.view.el.set_cursor( \n new Gtk.TreePath.from_string(\"0\"), null, false);\n \n \n } else {\n //this.get('/Window.leftvpaned').el.set_position(200);\n }\n \n return;\n /* \n \n //print(\"hide right editior\");\n //this.get('/RightEditor').el.hide();\n //this.get('/Editor').el.hide();\n //print(\"set current tree\");\n //this.currentTree = this.toJS(false, false)[0];\n //console.dump(this.currentTree);\n //this.currentTree = this.currentTree || { items: [] };\n //_this.renderView();\n //console.dump(this.map);\n //var RightPalete = imports.Builder.RightPalete.RightPalete;\n \n \n var pm = this.get('/RightPalete.model');\n // set up provider..\n \n this.get('/RightPalete').provider = this.get('/LeftTree').getPaleteProvider();\n \n if (!this.get('/RightPalete').provider) {\n print (\"********* PALETE PROVIDER MISSING?!!\");\n }\n this.get('/LeftTree').renderView();\n \n pm.load( this.get('/LeftTree').getPaleteProvider().gatherList(this.listAllTypes()));\n \n \n \n this.get('/Window.view-notebook').el.set_current_page(\n this.get('/LeftTree.model').file.getType()== 'Roo' ? 0 : -1);\n */\n \n}\n", @@ -84,8 +84,8 @@ "items" : [ { "id" : "renderer", - "xtype" : "CellRendererText", "* pack" : "pack_start,true", + "xtype" : "CellRendererText", "$ xns" : "Gtk" } ] @@ -94,8 +94,8 @@ }, { "id" : "LeftTreeMenu", - "xtype" : "Menu", "* pack" : false, + "xtype" : "Menu", "$ xns" : "Gtk", "items" : [ { @@ -103,8 +103,8 @@ "activate" : " ( ) => {\n \n print(\"ACTIVATE?\");\n \n \n _this.model.deleteSelected();\n}" }, "label" : "Delete Element", - "xtype" : "MenuItem", "* pack" : "add", + "xtype" : "MenuItem", "$ xns" : "Gtk" }, { @@ -112,8 +112,8 @@ "activate" : " () => {\n\n DialogSaveTemplate.singleton().show(\n (Gtk.Window) _this.el.get_toplevel (), \n _this.model.file.palete(), \n _this.getActiveElement()\n );\n \n \n}" }, "label" : "Save as Template", - "xtype" : "MenuItem", "* pack" : "add", + "xtype" : "MenuItem", "$ xns" : "Gtk" }, { @@ -121,8 +121,8 @@ "activate" : " () => {\n var node = _this.getActiveElement();\n var name = DialogSaveModule.singleton().show(\n (Gtk.Window) _this.el.get_toplevel (), \n _this.model.file.project, \n node\n );\n if (name.length < 1) {\n return;\n \n }\n node.props.set(\"* xinclude\", name);\n node.items.clear();\n\n\n var s = _this.view.el.get_selection();\n \n print(\"GET SELECTED?\");\n Gtk.TreeIter iter;\n Gtk.TreeModel mod;\n\n \n if (!s.get_selected(out mod, out iter)) {\n return; // nothing seleted..\n }\n Gtk.TreeIter citer;\n var n_cn = mod.iter_n_children(iter) -1;\n for (var i = n_cn; i > -1; i--) {\n mod.iter_nth_child(out citer, iter, i);\n \n\n print(\"removing node from Tree\\n\"); \n \n _this.model.el.remove(ref citer);\n }\n _this.changed();\n _this.node_selected(node);\n \n \n}" }, "label" : "Save as Module", - "xtype" : "MenuItem", "* pack" : "add", + "xtype" : "MenuItem", "$ xns" : "Gtk" } ] diff --git a/src/Builder4/WindowLeftTree.vala b/src/Builder4/WindowLeftTree.vala index 26b99eb2b..b7bd7ab1c 100644 --- a/src/Builder4/WindowLeftTree.vala +++ b/src/Builder4/WindowLeftTree.vala @@ -1,6 +1,6 @@ static Xcls_WindowLeftTree _WindowLeftTree; -public class Xcls_WindowLeftTree : Object +public class Xcls_WindowLeftTree : Object { public Gtk.ScrolledWindow el; private Xcls_WindowLeftTree _this; @@ -23,7 +23,7 @@ public class Xcls_WindowLeftTree : Object public signal void node_selected (JsRender.Node? node); public Xcls_MainWindow main_window; - // ctor + // ctor public Xcls_WindowLeftTree() { _this = this; @@ -40,12 +40,12 @@ public class Xcls_WindowLeftTree : Object var child_1 = new Xcls_LeftTreeMenu( _this ); child_1.ref(); - // init method + // init method this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC); } - // user defined functions + // user defined functions public JsRender.Node? getActiveElement () { // return path to actie node. var path = this.getActivePath(); @@ -69,7 +69,7 @@ public class Xcls_WindowLeftTree : Object view.get_selection().get_selected(out mod, out iter); return mod.get_path(iter).to_string(); } - public class Xcls_view : Object + public class Xcls_view : Object { public Gtk.TreeView el; private Xcls_WindowLeftTree _this; @@ -77,13 +77,13 @@ public class Xcls_WindowLeftTree : Object // my vars (def) public string dragData; - public int drag_x; public string[] dropList; + public int drag_x; public int drag_y; public bool drag_in_motion; public bool blockChanges; - // ctor + // ctor public Xcls_view(Xcls_WindowLeftTree _owner ) { _this = _owner; @@ -104,7 +104,7 @@ public class Xcls_WindowLeftTree : Object child_1.ref(); this.el.append_column ( child_1.el ); - // init method + // init method { var description = new Pango.FontDescription(); @@ -145,7 +145,7 @@ public class Xcls_WindowLeftTree : Object //Gtk.drag_dest_add_text_targets(this.el); } - // listeners + //listeners this.el.button_press_event.connect( ( ev) => { //console.log("button press?"); if (! _this.before_node_change(null) ) { @@ -174,50 +174,6 @@ public class Xcls_WindowLeftTree : Object // print("click:" + res.path.to_string()); return true; }); - this.el.drag_begin.connect( ( ctx) => { - //print('SOURCE: drag-begin'); - - - //this.targetData = ""; - - // find what is selected in our tree... - - var s = _this.view.el.get_selection(); - if (s.count_selected_rows() < 1) { - return; - } - Gtk.TreeIter iter; - Gtk.TreeModel mod; - s.get_selected(out mod, out iter); - - - - // set some properties of the tree for use by the dropped element. - GLib.Value value; - _this.model.el.get_value(iter, 2, out value); - var tp = mod.get_path(iter).to_string(); - var data = (JsRender.Node)(value.dup_object()); - var xname = data.fqn(); - print ("XNAME IS " + xname+ "\n"); - this.dragData = tp; - this.dropList = _this.model.file.palete().getDropList(xname); - - print ("DROP LIST IS " + string.joinv(", ", this.dropList) + "\n"); - - - // make the drag icon a picture of the node that was selected - - - // by default returns the path.. - var path = _this.model.el.get_path(iter); - - - var pix = this.el.create_row_drag_icon ( path); - - Gtk.drag_set_icon_surface (ctx, pix) ; - - return; - }); this.el.cursor_changed.connect( ( ) => { @@ -292,6 +248,50 @@ public class Xcls_WindowLeftTree : Object return ; }); + this.el.drag_begin.connect( ( ctx) => { + //print('SOURCE: drag-begin'); + + + //this.targetData = ""; + + // find what is selected in our tree... + + var s = _this.view.el.get_selection(); + if (s.count_selected_rows() < 1) { + return; + } + Gtk.TreeIter iter; + Gtk.TreeModel mod; + s.get_selected(out mod, out iter); + + + + // set some properties of the tree for use by the dropped element. + GLib.Value value; + _this.model.el.get_value(iter, 2, out value); + var tp = mod.get_path(iter).to_string(); + var data = (JsRender.Node)(value.dup_object()); + var xname = data.fqn(); + print ("XNAME IS " + xname+ "\n"); + this.dragData = tp; + this.dropList = _this.model.file.palete().getDropList(xname); + + print ("DROP LIST IS " + string.joinv(", ", this.dropList) + "\n"); + + + // make the drag icon a picture of the node that was selected + + + // by default returns the path.. + var path = _this.model.el.get_path(iter); + + + var pix = this.el.create_row_drag_icon ( path); + + Gtk.drag_set_icon_surface (ctx, pix) ; + + return; + }); this.el.drag_end.connect( (drag_context) => { //Seed.print('LEFT-TREE: drag-end'); this.dragData = ""; @@ -809,7 +809,7 @@ public class Xcls_WindowLeftTree : Object }); } - // user defined functions + // user defined functions public void highlightDropPath ( string treepath, Gtk.TreeViewDropPosition pos) { // highlighting for drag/drop @@ -828,7 +828,7 @@ public class Xcls_WindowLeftTree : Object this.el.scroll_to_cell(tp, null, false, 0,0); } } - public class Xcls_model : Object + public class Xcls_model : Object { public Gtk.TreeStore el; private Xcls_WindowLeftTree _this; @@ -840,7 +840,7 @@ public class Xcls_WindowLeftTree : Object public string activePath; public Project.Project? project; - // ctor + // ctor public Xcls_model(Xcls_WindowLeftTree _owner ) { _this = _owner; @@ -855,12 +855,12 @@ public class Xcls_WindowLeftTree : Object // set gobject values - // init method + // init method print("model initialized"); } - // user defined functions + // user defined functions public string findDropNode (string treepath_str, string[] targets) { // this is used by the dragdrop code in the roo version AFAIR.. @@ -1374,7 +1374,8 @@ public class Xcls_WindowLeftTree : Object } } - public class Xcls_TreeViewColumn4 : Object + + public class Xcls_TreeViewColumn4 : Object { public Gtk.TreeViewColumn el; private Xcls_WindowLeftTree _this; @@ -1382,7 +1383,7 @@ public class Xcls_WindowLeftTree : Object // my vars (def) - // ctor + // ctor public Xcls_TreeViewColumn4(Xcls_WindowLeftTree _owner ) { _this = _owner; @@ -1396,14 +1397,14 @@ public class Xcls_WindowLeftTree : Object child_0.ref(); this.el.pack_start ( child_0.el , true ); - // init method + // init method this.el.add_attribute(_this.renderer.el , "markup", 0 ); } - // user defined functions + // user defined functions } - public class Xcls_renderer : Object + public class Xcls_renderer : Object { public Gtk.CellRendererText el; private Xcls_WindowLeftTree _this; @@ -1411,7 +1412,7 @@ public class Xcls_WindowLeftTree : Object // my vars (def) - // ctor + // ctor public Xcls_renderer(Xcls_WindowLeftTree _owner ) { _this = _owner; @@ -1423,9 +1424,12 @@ public class Xcls_WindowLeftTree : Object // set gobject values } - // user defined functions + // user defined functions } - public class Xcls_LeftTreeMenu : Object + + + + public class Xcls_LeftTreeMenu : Object { public Gtk.Menu el; private Xcls_WindowLeftTree _this; @@ -1433,7 +1437,7 @@ public class Xcls_WindowLeftTree : Object // my vars (def) - // ctor + // ctor public Xcls_LeftTreeMenu(Xcls_WindowLeftTree _owner ) { _this = _owner; @@ -1454,9 +1458,9 @@ public class Xcls_WindowLeftTree : Object this.el.add ( child_2.el ); } - // user defined functions + // user defined functions } - public class Xcls_MenuItem7 : Object + public class Xcls_MenuItem7 : Object { public Gtk.MenuItem el; private Xcls_WindowLeftTree _this; @@ -1464,7 +1468,7 @@ public class Xcls_WindowLeftTree : Object // my vars (def) - // ctor + // ctor public Xcls_MenuItem7(Xcls_WindowLeftTree _owner ) { _this = _owner; @@ -1475,7 +1479,7 @@ public class Xcls_WindowLeftTree : Object // set gobject values this.el.label = "Delete Element"; - // listeners + //listeners this.el.activate.connect( ( ) => { print("ACTIVATE?"); @@ -1485,9 +1489,10 @@ public class Xcls_WindowLeftTree : Object }); } - // user defined functions + // user defined functions } - public class Xcls_MenuItem8 : Object + + public class Xcls_MenuItem8 : Object { public Gtk.MenuItem el; private Xcls_WindowLeftTree _this; @@ -1495,7 +1500,7 @@ public class Xcls_WindowLeftTree : Object // my vars (def) - // ctor + // ctor public Xcls_MenuItem8(Xcls_WindowLeftTree _owner ) { _this = _owner; @@ -1506,7 +1511,7 @@ public class Xcls_WindowLeftTree : Object // set gobject values this.el.label = "Save as Template"; - // listeners + //listeners this.el.activate.connect( () => { DialogSaveTemplate.singleton().show( @@ -1519,9 +1524,10 @@ public class Xcls_WindowLeftTree : Object }); } - // user defined functions + // user defined functions } - public class Xcls_MenuItem9 : Object + + public class Xcls_MenuItem9 : Object { public Gtk.MenuItem el; private Xcls_WindowLeftTree _this; @@ -1529,7 +1535,7 @@ public class Xcls_WindowLeftTree : Object // my vars (def) - // ctor + // ctor public Xcls_MenuItem9(Xcls_WindowLeftTree _owner ) { _this = _owner; @@ -1540,7 +1546,7 @@ public class Xcls_WindowLeftTree : Object // set gobject values this.el.label = "Save as Module"; - // listeners + //listeners this.el.activate.connect( () => { var node = _this.getActiveElement(); var name = DialogSaveModule.singleton().show( @@ -1583,6 +1589,8 @@ public class Xcls_WindowLeftTree : Object }); } - // user defined functions + // user defined functions } + + } -- 2.39.2