From: Alan Knowles Date: Thu, 15 Jan 2015 04:46:40 +0000 (+0800) Subject: Builder4/WindowLeftTree.bjs X-Git-Url: http://git.roojs.org/?p=app.Builder.js;a=commitdiff_plain;h=aae2c8e9b6dea9efdfe9ac781548e04b810ba443 Builder4/WindowLeftTree.bjs Builder4/WindowLeftTree.vala --- diff --git a/Builder4/WindowLeftTree.bjs b/Builder4/WindowLeftTree.bjs index 63d42652d..637734c0a 100644 --- a/Builder4/WindowLeftTree.bjs +++ b/Builder4/WindowLeftTree.bjs @@ -61,7 +61,7 @@ "| void updateSelected" : "() {\n \n \n var s = _this.view.el.get_selection();\n \n Gtk.TreeIter iter;\n Gtk.TreeModel mod;\n \n \n \n if (!s.get_selected(out mod, out iter)) {\n return; // nothing seleted..\n }\n \n GLib.Value value;\n this.el.get_value(iter, 2, out value);\n var node = (JsRender.Node)(value.get_object());\n \n this.el.set(iter, 0, node.nodeTitle(),\n 1, node.nodeTip(), -1\n );\n}\n", "* pack" : "set_model", "xtype" : "TreeStore", - "| string findDropNodeByPath" : " (string treepath_str, string[] targets, int in_pref = -1) {\n\n var path = treepath_str; // dupe it..\n \n \n // pref : 3 = ontop - 0 = after, 1 = before\n int pref = in_pref < 0 ? Gtk.TreeViewDropPosition.INTO_OR_AFTER : in_pref;\n \n var last = \"\";\n \n //console.dump(this.treemap);\n \n print(\"findDropNodeByPath : got path length %d / %s\\n\", path.length, path);\n \n if (path.length == 0) {\n // top drop. // just return empty..\n return \"|%d\".printf((int)pref) ;\n \n }\n \n \n while (path.length > 0) {\n \n if (path.length == treepath_str.length && pref != Gtk.TreeViewDropPosition.INTO_OR_AFTER) {\n if (path.last_index_of(\":\") < 0 ) {\n return null;\n }\n path = path.substring(0, path.last_index_of(\":\"));\n print(\"DROP before or after : using %s\\n\",path);\n continue;\n }\n \n //print(\"LOOKING FOR PATH: \" + path);\n var node_data = this.pathToNode(path);\n \n if (node_data == null) {\n print(\"node not found\");\n return null;\n }\n \n var xname = node_data.fqn();\n var match = \"\";\n var prop = \"\";\n \n for (var i =0; i < targets.length; i++) {\n var tg = targets[i];\n if ((tg == xname) ) {\n match = tg;\n break;\n }\n // if target is \"xxxx:name\"\n if (tg.contains(xname +\":\")) {\n match = tg;\n var ar = tg.split(\":\");\n prop = ar[1];\n break;\n }\n }\n \n if (match.length > 0) {\n if (last.length > 0) { // pref is after/before..\n // then it's after last\n if (pref > 1) {\n return \"\";\n }\n return last + \"|%d\".printf((int)pref) + \"|\" + prop;\n\n \n }\n return path + \"|%d\".printf( (int) Gtk.TreeViewDropPosition.INTO_OR_AFTER) + \"|\" + prop;\n }\n last = \"\" + path;\n var par = path.split(\":\");\n string [] ppar = {};\n for (var i = 0; i < par.length-1; i++) {\n ppar += par[i];\n }\n \n path = string.joinv(\":\", ppar);\n\n\n }\n \n return \"\";\n \n}\n", + "| string findDropNodeByPath" : " (string treepath_str, string[] targets, int in_pref = -1) {\n\n var path = treepath_str; // dupe it..\n \n \n // pref : 3 = ontop - 0 = after, 1 = before\n int pref = in_pref < 0 ? Gtk.TreeViewDropPosition.INTO_OR_AFTER : in_pref;\n \n var last = \"\";\n \n //console.dump(this.treemap);\n \n print(\"findDropNodeByPath : got path length %d / %s\\n\", path.length, path);\n \n if (path.length == 0) {\n // top drop. // just return empty..\n return \"|%d\".printf((int)pref) ;\n \n }\n \n \n while (path.length > 0) {\n \n if (path.length == treepath_str.length && pref != Gtk.TreeViewDropPosition.INTO_OR_AFTER) {\n if (path.last_index_of(\":\") < 0 ) {\n return null;\n }\n path = path.substring(0, path.last_index_of(\":\"));\n last = treepath_str;\n print(\"DROP before or after : using %s\\n\",path);\n continue;\n }\n \n //print(\"LOOKING FOR PATH: \" + path);\n var node_data = this.pathToNode(path);\n \n if (node_data == null) {\n print(\"node not found\");\n return null;\n }\n \n var xname = node_data.fqn();\n var match = \"\";\n var prop = \"\";\n \n for (var i =0; i < targets.length; i++) {\n var tg = targets[i];\n if ((tg == xname) ) {\n match = tg;\n break;\n }\n // if target is \"xxxx:name\"\n if (tg.contains(xname +\":\")) {\n match = tg;\n var ar = tg.split(\":\");\n prop = ar[1];\n break;\n }\n }\n \n if (match.length > 0) {\n if (last.length > 0) { // pref is after/before..\n // then it's after last\n //if (pref > 1) {\n // return \"\";\n //}\n return last + \"|%d\".printf((int)pref) + \"|\" + prop;\n\n \n }\n return path + \"|%d\".printf( (int) Gtk.TreeViewDropPosition.INTO_OR_AFTER) + \"|\" + prop;\n }\n /*\n last = \"\" + path;\n var par = path.split(\":\");\n string [] ppar = {};\n for (var i = 0; i < par.length-1; i++) {\n ppar += par[i];\n }\n \n path = string.joinv(\":\", ppar);\n */\n break;\n\n }\n \n return \"\";\n \n}\n", "| void moveNode" : "(string target_data, Gdk.DragAction action) \n{\n \n /// target_data = \"path|pos\");\n \n \n //print(\"MOVE NODE\");\n // console.dump(target_data);\n Gtk.TreeIter old_iter;\n Gtk.TreeModel mod;\n \n var s = _this.view.el.get_selection();\n s.get_selected(out mod , out old_iter);\n mod.get_path(old_iter);\n \n var node = this.pathToNode(mod.get_path(old_iter).to_string());\n //console.dump(node);\n if (node == null) {\n print(\"moveNode: ERROR - node is null?\");\n }\n \n \n\n // needs to drop first, otherwise the target_data \n // treepath will be invalid.\n\n \n if ((action & Gdk.DragAction.MOVE) > 0) {\n print(\"REMOVING OLD NODE : \" + target_data + \"\\n\");\n node.remove();\n this.dropNode(target_data, node, false);\n this.el.remove(ref old_iter);\n \n \n \n } else {\n print(\"DROPPING NODE // copy: \" + target_data + \"\\n\");\n node = node.deepClone();\n this.dropNode(target_data, node, false);\n }\n _this.changed();\n this.activePath= \"\";\n //this.updateNode(false,true);\n}\n", "# string activePath" : "\"\"", "$ columns" : "typeof(string),typeof(string),typeof(Object)", diff --git a/Builder4/WindowLeftTree.vala b/Builder4/WindowLeftTree.vala index 01a4100b1..bfdb63f1b 100644 --- a/Builder4/WindowLeftTree.vala +++ b/Builder4/WindowLeftTree.vala @@ -997,6 +997,7 @@ public class Xcls_WindowLeftTree : Object return null; } path = path.substring(0, path.last_index_of(":")); + last = treepath_str; print("DROP before or after : using %s\n",path); continue; } @@ -1031,15 +1032,16 @@ public class Xcls_WindowLeftTree : Object if (match.length > 0) { if (last.length > 0) { // pref is after/before.. // then it's after last - if (pref > 1) { - return ""; - } + //if (pref > 1) { + // return ""; + //} return last + "|%d".printf((int)pref) + "|" + prop; } return path + "|%d".printf( (int) Gtk.TreeViewDropPosition.INTO_OR_AFTER) + "|" + prop; } + /* last = "" + path; var par = path.split(":"); string [] ppar = {}; @@ -1048,7 +1050,8 @@ public class Xcls_WindowLeftTree : Object } path = string.joinv(":", ppar); - + */ + break; }