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.resource = node.iconResourceName;",
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 ws =_this.mainwindow.windowstate;",
245 "\tvar lt = ws.left_tree;",
247 "\tvar add = _this.selmodel.getSelectedNode().deepClone();",
248 "\tif (lt.model.el.n_items < 1) {",
249 "\t\tws.file.tree = add; ",
250 " \tadd.updated_count++;",
251 " \tvar m = (GLib.ListStore) lt.model.el.model;",
252 "\t\tm.append(add);",
253 "\t\tlt.model.selectNode(add); \t",
255 "\t\tlt.node_selected(add);",
258 "\tvar addto = _this.mainwindow.windowstate.left_tree.selmodel.getSelectedNode();\t",
259 "\t//var row = _this.view.getRowAt(x,y, out pos);",
262 "\taddto.appendChild(add);",
263 "\t_this.mainwindow.windowstate.left_props.changed();",
264 "\t_this.mainwindow.windowstate.left_tree.model.selectNode(add);",
269 "xtype" : "GestureClick"
272 "xtype" : "ColumnView",
273 "| Gtk.Widget? getWidgetAt" : [
274 "(double x, double in_y) {",
277 "from \thttps://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465",
278 " \tvar colview = gesture.widget;",
279 " \tvar line_no = check_list_widget(colview, x,y);",
280 " if (line_no > -1) {",
281 " \t\tvar item = colview.model.get_item(line_no);",
285 " \tvar y = in_y + _this.viewwin.el.vadjustment.value; ",
286 " var child = this.el.get_first_child(); ",
287 " \t//Gtk.Allocation alloc = { 0, 0, 0, 0 };",
288 " \tvar line_no = -1; ",
289 " \tvar reading_header = true;",
290 " \tvar curr_y = 0;",
291 " \tvar header_height = 0;",
293 " \twhile (child != null) {",
294 "\t\t\t//GLib.debug(\"Got %s\", child.get_type().name());",
295 "\t if (reading_header) {",
298 "\t\t\t\tif (child.get_type().name() != \"GtkColumnListView\") {",
299 "\t\t\t h += child.get_height();",
300 "\t\t\t\t\tchild = child.get_next_sibling();",
301 "\t\t\t\t\tcontinue;",
303 "\t\t\t\t// should be columnlistview",
304 "\t\t\t\tchild = child.get_first_child(); ",
305 "\t\t\t GLib.debug(\"header height=%d\", h);",
306 "\t\t\t\theader_height = h;",
308 "\t\t\t\treading_header = false;",
313 "\t\t\tif (y < header_height) {",
314 "\t\t \treturn null;",
317 "\t\t\tvar hh = child.get_height();",
318 "\t\t\t//GLib.debug(\"got cell xy = %d,%d w,h= %d,%d\", alloc.x, alloc.y, alloc.width, alloc.height);",
320 "\t\t if (y > curr_y && y <= header_height + hh + curr_y ) {",
321 "\t\t\t return (Gtk.Widget)child;",
323 "\t\t curr_y += hh ;",
325 "\t\t if (curr_y > y) {",
328 "\t child = child.get_next_sibling(); ",
334 "| Gtk.Widget? getWidgetAtRow" : [
337 "// ?? could be done with model?",
339 "from \thttps://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465",
340 " \tvar colview = gesture.widget;",
341 " \tvar line_no = check_list_widget(colview, x,y);",
342 " if (line_no > -1) {",
343 " \t\tvar item = colview.model.get_item(line_no);",
347 "\t\tGLib.debug(\"Get Widget At Row %d\", (int)row);",
348 " var child = this.el.get_first_child(); ",
349 " \tvar line_no = -1; ",
350 " \tvar reading_header = true;",
352 " \twhile (child != null) {",
353 "\t\t\tGLib.debug(\"Got %s\", child.get_type().name());",
354 " \t if (reading_header) {",
357 "\t\t\t\tif (child.get_type().name() != \"GtkColumnListView\") {",
358 "\t\t\t\t\tchild = child.get_next_sibling();",
359 "\t\t\t\t\tcontinue;",
361 "\t\t\t\tchild = child.get_first_child(); ",
362 "\t\t\t\treading_header = false;",
364 "\t\t if (child.get_type().name() != \"GtkColumnViewRowWidget\") {",
365 " \t\t child = child.get_next_sibling();",
369 "\t\t\tif (line_no == row) {",
370 "\t\t\t\tGLib.debug(\"Returning widget %s\", child.get_type().name());",
371 "\t\t\t return (Gtk.Widget)child;",
373 "\t child = child.get_next_sibling(); ",
375 "\t\tGLib.debug(\"Rturning null\");",
381 "(double x, double in_y, out string pos) {",
388 "from \thttps://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465",
389 " \tvar colview = gesture.widget;",
390 " \tvar line_no = check_list_widget(colview, x,y);",
391 " if (line_no > -1) {",
392 " \t\tvar item = colview.model.get_item(line_no);",
398 " \t\t//GLib.debug(\"offset = %d y = %d\", (int) voff, (int) in_y);",
399 " \tvar y = in_y + _this.viewwin.el.vadjustment.value; ",
400 " var child = this.el.get_first_child(); ",
401 " \t//Gtk.Allocation alloc = { 0, 0, 0, 0 };",
402 " \tvar line_no = -1; ",
403 " \tvar reading_header = true;",
404 " \tvar real_y = 0;",
405 " \tvar header_height = 0;",
406 " \tpos = \"none\";",
408 " \twhile (child != null) {",
409 "\t\t\t//GLib.debug(\"Got %s\", child.get_type().name());",
410 " \t if (reading_header) {",
413 "\t\t\t\tif (child.get_type().name() != \"GtkColumnListView\") {",
414 "\t\t\t h += child.get_height();",
415 "\t\t\t\t\tchild = child.get_next_sibling();",
416 "\t\t\t\t\tcontinue;",
418 "\t\t\t\t// should be columnlistview",
419 "\t\t\t\tchild = child.get_first_child(); ",
420 "\t\t\t GLib.debug(\"header height=%d\", h);",
421 "\t\t\t\theader_height = h;",
423 "\t\t\t\treading_header = false;",
427 "\t\t if (child.get_type().name() != \"GtkColumnViewRowWidget\") {",
428 " \t\t child = child.get_next_sibling();",
432 "\t\t \tif (y < header_height) {",
437 "\t\t\tvar hh = child.get_height();",
438 "\t\t\t//child.get_allocation(out alloc);",
439 "\t\t\t//GLib.debug(\"got cell xy = %d,%d w,h= %d,%d\", alloc.x, alloc.y, alloc.width, alloc.height);",
440 "\t\t\t//GLib.debug(\"row %d y= %d %s\", line_no, (int) (header_height + alloc.y),",
442 "\t\t\t//\tchild.visible ? \"VIS\" : \"hidden\");",
444 "\t\t if (y > (header_height + real_y) && y <= (header_height + real_y + hh) ) {",
445 "\t\t \tif (y > ( header_height + real_y + (hh * 0.8))) {",
446 "\t\t \t\tpos = \"below\";",
447 "\t \t\t} else if (y > ( header_height + real_y + (hh * 0.2))) {",
448 "\t \t\t\tpos = \"over\";",
450 " \t\t\t\tpos = \"above\";",
452 "\t\t \t GLib.debug(\"getRowAt return : %d, %s\", line_no, pos);",
453 "\t\t\t return line_no;",
457 "\t\t if (real_y + hh > y) {",
461 "\t child = child.get_next_sibling(); ",
469 "xtype" : "ScrolledWindow"
475 " var m = (GLib.ListStore) _this.model.el.model;",
491 "(Palete.Palete pal, string cls, Gtk.Widget onbtn) {",
495 " var tr = pal.getChildList(cls, false);",
496 " var m = (GLib.ListStore) _this.model.el.model;",
500 "\t// new version will not support properties here..",
501 "\t// they will be part of the properties, clicking will add a node..",
502 "\t// will change the return list above eventually?",
505 "\tforeach (var dname in tr) {",
508 "\t\tGLib.debug(\"add to model: %s\", dname);\t\t",
509 "\t\tm.append(pal.fqnToNode(dname));",
511 "\t m.sort( (a, b) => {",
513 "\t\t\treturn Posix.strcmp( ((JsRender.Node)a).fqn(), ((JsRender.Node)b).fqn());",
518 " var win = this.mainwindow.el;",
519 " //var w = win.get_width();",
520 " var h = win.get_height();",
523 " // left tree = 250, editor area = 500?",
526 "\t// max hieght ...",
527 " this.el.set_size_request( 350, h); // full height?",
529 " this.el.set_parent(onbtn);",
531 " //if (this.el.relative_to == null) {",
532 " \t//Gtk.Allocation rect;",
533 " \t//onbtn.get_allocation(out rect);",
534 " // this.el.set_pointing_to(rect);",
536 " this.selmodel.el.set_selected(Gtk.INVALID_LIST_POSITION);",
544 "name" : "PopoverAddObject"