3 "gen_extended" : false,
7 "@ void after_node_change" : "(JsRender.Node? node)",
8 "@ void before_node_change" : "(JsRender.Node? node)",
9 "Gtk.PositionType position" : "Gtk.PositionType.RIGHT",
10 "Xcls_MainWindow mainwindow" : "",
11 "bool active" : false,
12 "bool hexpand" : false,
14 "id" : "PopoverAddObject",
15 "int height_request" : 800,
16 "int width_request" : 900,
19 "$ shadow_type" : "Gtk.ShadowType.IN",
22 " this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);",
23 " this.el.set_size_request(-1,200);",
27 "* pack" : "set_child",
32 "* pack" : "set_child",
33 "bool hexpand" : true,
34 "bool vexpand" : true,
38 "$ Gdk.DragAction[] actions" : "Gdk.DragAction.COPY | Gdk.DragAction.MOVE ",
43 "\tGLib.debug(\"SOURCE: drag-begin\");",
45 " // find what is selected in our tree...",
46 " var data = _this.selmodel.getSelectedNode();",
47 "\tif (data == null) {",
51 " var xname = data.fqn();",
52 " GLib.debug (\"XNAME IS %s\", xname);",
54 " \tvar widget = _this.view.getWidgetAtRow(_this.selmodel.el.selected);",
57 " var paintable = new Gtk.WidgetPaintable(widget);",
58 " this.el.set_icon(paintable, 0,0);",
64 "(drag, delete_data) => {",
75 "///\t( drag_context, data, info, time) => {",
78 "\t//print(\"drag-data-get\");",
79 " \tvar ndata = _this.selmodel.getSelectedNode();",
80 "\tif (ndata == null) {",
81 "\t \tGLib.debug(\"return empty string - no selection..\");",
87 "\t//data.set_text(tp,tp.length); ",
89 "\tvar \tstr = ndata.toJsonString();",
90 "\tGLib.debug(\"prepare store: %s\", str);",
91 "\tGLib.Value ov = GLib.Value(typeof(string));",
92 "\tov.set_string(str);",
93 " \tvar cont = new Gdk.ContentProvider.for_value(ov);",
95 "\t//GLib.Value v = GLib.Value(typeof(string));",
96 "\t//var str = drop.read_text( [ \"text/plain\" ] 0);",
98 "\t//cont.get_value(ref v);",
99 "\t//GLib.debug(\"set %s\", v.get_string());",
107 "xtype" : "DragSource"
117 "new Gtk.TreeListModel(",
118 " new GLib.ListStore(typeof(JsRender.Node)), //..... << that's our store..",
119 " false, // passthru",
120 " true, // autexpand",
122 " \treturn ((JsRender.Node)item).childstore;",
131 "xtype" : "TreeListModel"
134 "xtype" : "SingleSelection",
135 "| JsRender.Node getNodeAt" : [
138 " var tr = (Gtk.TreeListRow)this.el.get_item(row);",
140 " var a = tr.get_item();; ",
141 " GLib.debug(\"get_item (2) = %s\", a.get_type().name());",
143 " return (JsRender.Node)tr.get_item();",
147 "| JsRender.Node? getSelectedNode" : [
149 " if (this.el.selected_item == null) {",
152 " var tr = (Gtk.TreeListRow)this.el.selected_item;",
153 " return (JsRender.Node)tr.get_item();",
160 "* pack" : "append_column",
161 "bool expand" : true,
166 "* prop" : "factory",
170 "\t //GLib.debug(\"listitme is is %s\", ((Gtk.ListItem)listitem).get_type().name());",
172 "\t//var expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child();",
175 " \tvar hbox = (Gtk.Box) ((Gtk.ListItem)listitem).get_child();",
179 "\tvar img = (Gtk.Image) hbox.get_first_child();",
180 "\tvar lbl = (Gtk.Label) img.get_next_sibling();",
182 "\tvar lr = (Gtk.TreeListRow)((Gtk.ListItem)listitem).get_item();",
186 "\tvar node = (JsRender.Node) lr.get_item();",
188 " GLib.debug(\"node is %s\", node.get_type().name());",
189 " GLib.debug(\"lbl is %s\", lbl.get_type().name());",
190 " GLib.debug(\"node fqn %s\", node.fqn());",
191 "// was item (1) in old layout",
194 " \timg.file = node.iconFilename;",
195 " \tlbl.label = node.fqn();",
196 "// \tlbl.tooltip_markup = node.nodeTip();",
199 " \t// bind image...",
208 "\tvar hbox = new Gtk.Box(Gtk.Orientation.HORIZONTAL,0);",
209 "\tvar icon = new Gtk.Image();",
210 "\tvar lbl = new Gtk.Label(\"\");",
211 "\tlbl.use_markup = true;",
214 " \tlbl.justify = Gtk.Justification.LEFT;",
215 " \tlbl.xalign = 0;",
216 "\tlbl.margin_start = 4;",
217 "//\tlistitem.activatable = true; ??",
219 "\thbox.append(icon);",
220 "\thbox.append(lbl);",
222 "\t((Gtk.ListItem)listitem).set_child(hbox);",
228 "xtype" : "SignalListItemFactory"
231 "title" : "Drag to add Object",
232 "xtype" : "ColumnViewColumn"
238 "(n_press, x, y) => {",
239 "\tif (n_press < 2) { /// doubleclick?",
242 "\t//var pos = \"\";",
243 "\t// find left tree selected node",
244 "\tvar addto = _this.mainwindow.windowstate.left_tree.selmodel.getSelectedNode();",
245 "\t//var row = _this.view.getRowAt(x,y, out pos);",
247 " \t var add = _this.selmodel.getSelectedNode().deepClone();",
248 "\taddto.appendChild(add);",
249 "\t_this.mainwindow.windowstate.left_props.changed();",
250 "\t_this.mainwindow.windowstate.left_tree.model.selectNode(add);",
255 "xtype" : "GestureClick"
258 "xtype" : "ColumnView",
259 "| Gtk.Widget? getWidgetAt" : [
260 "(double x, double in_y) {",
263 "from \thttps://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465",
264 " \tvar colview = gesture.widget;",
265 " \tvar line_no = check_list_widget(colview, x,y);",
266 " if (line_no > -1) {",
267 " \t\tvar item = colview.model.get_item(line_no);",
271 " \tvar y = in_y + _this.viewwin.el.vadjustment.value; ",
272 " var child = this.el.get_first_child(); ",
273 " \t//Gtk.Allocation alloc = { 0, 0, 0, 0 };",
274 " \tvar line_no = -1; ",
275 " \tvar reading_header = true;",
276 " \tvar curr_y = 0;",
277 " \tvar header_height = 0;",
279 " \twhile (child != null) {",
280 "\t\t\t//GLib.debug(\"Got %s\", child.get_type().name());",
281 "\t if (reading_header) {",
284 "\t\t\t\tif (child.get_type().name() != \"GtkColumnListView\") {",
285 "\t\t\t h += child.get_height();",
286 "\t\t\t\t\tchild = child.get_next_sibling();",
287 "\t\t\t\t\tcontinue;",
289 "\t\t\t\t// should be columnlistview",
290 "\t\t\t\tchild = child.get_first_child(); ",
291 "\t\t\t GLib.debug(\"header height=%d\", h);",
292 "\t\t\t\theader_height = h;",
294 "\t\t\t\treading_header = false;",
299 "\t\t\tif (y < header_height) {",
300 "\t\t \treturn null;",
303 "\t\t\tvar hh = child.get_height();",
304 "\t\t\t//GLib.debug(\"got cell xy = %d,%d w,h= %d,%d\", alloc.x, alloc.y, alloc.width, alloc.height);",
306 "\t\t if (y > curr_y && y <= header_height + hh + curr_y ) {",
307 "\t\t\t return (Gtk.Widget)child;",
309 "\t\t curr_y += hh ;",
311 "\t\t if (curr_y > y) {",
314 "\t child = child.get_next_sibling(); ",
320 "| Gtk.Widget? getWidgetAtRow" : [
323 "// ?? could be done with model?",
325 "from \thttps://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465",
326 " \tvar colview = gesture.widget;",
327 " \tvar line_no = check_list_widget(colview, x,y);",
328 " if (line_no > -1) {",
329 " \t\tvar item = colview.model.get_item(line_no);",
333 "\t\tGLib.debug(\"Get Widget At Row %d\", (int)row);",
334 " var child = this.el.get_first_child(); ",
335 " \tvar line_no = -1; ",
336 " \tvar reading_header = true;",
338 " \twhile (child != null) {",
339 "\t\t\tGLib.debug(\"Got %s\", child.get_type().name());",
340 " \t if (reading_header) {",
343 "\t\t\t\tif (child.get_type().name() != \"GtkColumnListView\") {",
344 "\t\t\t\t\tchild = child.get_next_sibling();",
345 "\t\t\t\t\tcontinue;",
347 "\t\t\t\tchild = child.get_first_child(); ",
348 "\t\t\t\treading_header = false;",
350 "\t\t if (child.get_type().name() != \"GtkColumnViewRowWidget\") {",
351 " \t\t child = child.get_next_sibling();",
355 "\t\t\tif (line_no == row) {",
356 "\t\t\t\tGLib.debug(\"Returning widget %s\", child.get_type().name());",
357 "\t\t\t return (Gtk.Widget)child;",
359 "\t child = child.get_next_sibling(); ",
361 "\t\tGLib.debug(\"Rturning null\");",
367 "(double x, double in_y, out string pos) {",
374 "from \thttps://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465",
375 " \tvar colview = gesture.widget;",
376 " \tvar line_no = check_list_widget(colview, x,y);",
377 " if (line_no > -1) {",
378 " \t\tvar item = colview.model.get_item(line_no);",
384 " \t\t//GLib.debug(\"offset = %d y = %d\", (int) voff, (int) in_y);",
385 " \tvar y = in_y + _this.viewwin.el.vadjustment.value; ",
386 " var child = this.el.get_first_child(); ",
387 " \t//Gtk.Allocation alloc = { 0, 0, 0, 0 };",
388 " \tvar line_no = -1; ",
389 " \tvar reading_header = true;",
390 " \tvar real_y = 0;",
391 " \tvar header_height = 0;",
392 " \tpos = \"none\";",
394 " \twhile (child != null) {",
395 "\t\t\t//GLib.debug(\"Got %s\", child.get_type().name());",
396 " \t if (reading_header) {",
399 "\t\t\t\tif (child.get_type().name() != \"GtkColumnListView\") {",
400 "\t\t\t h += child.get_height();",
401 "\t\t\t\t\tchild = child.get_next_sibling();",
402 "\t\t\t\t\tcontinue;",
404 "\t\t\t\t// should be columnlistview",
405 "\t\t\t\tchild = child.get_first_child(); ",
406 "\t\t\t GLib.debug(\"header height=%d\", h);",
407 "\t\t\t\theader_height = h;",
409 "\t\t\t\treading_header = false;",
413 "\t\t if (child.get_type().name() != \"GtkColumnViewRowWidget\") {",
414 " \t\t child = child.get_next_sibling();",
418 "\t\t \tif (y < header_height) {",
423 "\t\t\tvar hh = child.get_height();",
424 "\t\t\t//child.get_allocation(out alloc);",
425 "\t\t\t//GLib.debug(\"got cell xy = %d,%d w,h= %d,%d\", alloc.x, alloc.y, alloc.width, alloc.height);",
426 "\t\t\t//GLib.debug(\"row %d y= %d %s\", line_no, (int) (header_height + alloc.y),",
428 "\t\t\t//\tchild.visible ? \"VIS\" : \"hidden\");",
430 "\t\t if (y > (header_height + real_y) && y <= (header_height + real_y + hh) ) {",
431 "\t\t \tif (y > ( header_height + real_y + (hh * 0.8))) {",
432 "\t\t \t\tpos = \"below\";",
433 "\t \t\t} else if (y > ( header_height + real_y + (hh * 0.2))) {",
434 "\t \t\t\tpos = \"over\";",
436 " \t\t\t\tpos = \"above\";",
438 "\t\t \t GLib.debug(\"getRowAt return : %d, %s\", line_no, pos);",
439 "\t\t\t return line_no;",
443 "\t\t if (real_y + hh > y) {",
447 "\t child = child.get_next_sibling(); ",
455 "xtype" : "ScrolledWindow"
461 " var m = (GLib.ListStore) _this.model.el.model;",
477 "(Palete.Palete pal, string cls, Gtk.Widget onbtn) {",
481 " var tr = pal.getChildList(cls, false);",
482 " var m = (GLib.ListStore) _this.model.el.model;",
486 "\t// new version will not support properties here..",
487 "\t// they will be part of the properties, clicking will add a node..",
488 "\t// will change the return list above eventually?",
491 "\tforeach (var dname in tr) {",
494 "\t\tGLib.debug(\"add to model: %s\", dname);\t\t",
495 "\t\tm.append(pal.fqnToNode(dname));",
497 "\t m.sort( (a, b) => {",
499 "\t\t\treturn Posix.strcmp( ((JsRender.Node)a).fqn(), ((JsRender.Node)b).fqn());",
504 " var win = this.mainwindow.el;",
505 " //var w = win.get_width();",
506 " var h = win.get_height();",
509 " // left tree = 250, editor area = 500?",
512 "\t// max hieght ...",
513 " this.el.set_size_request( 350, h); // full height?",
515 " this.el.set_parent(onbtn);",
517 " //if (this.el.relative_to == null) {",
518 " \t//Gtk.Allocation rect;",
519 " \t//onbtn.get_allocation(out rect);",
520 " // this.el.set_pointing_to(rect);",
522 " this.selmodel.el.set_selected(Gtk.INVALID_LIST_POSITION);",
530 "name" : "PopoverAddObject"