3 "gen_extended" : false,
6 "# JsRender.NodePropType ptype" : "",
8 "* ctor" : "new Gtk.Popover()",
9 "Gtk.PositionType position" : "Gtk.PositionType.RIGHT",
10 "JsRender.Node? node" : "null",
11 "Xcls_MainWindow mainwindow" : "",
12 "bool active" : false,
13 "bool hexpand" : false,
15 "id" : "PopoverAddProp",
16 "int height_request" : 800,
17 "int width_request" : 900,
20 "$ shadow_type" : "Gtk.ShadowType.IN",
22 "* pack" : "set_child",
23 "Gtk.PolicyType hscrollbar_policy" : "Gtk.PolicyType.AUTOMATIC",
24 "Gtk.PolicyType vscrollbar_policy" : "Gtk.PolicyType.AUTOMATIC",
29 "* pack" : "set_child",
30 "bool hexpand" : true,
31 "bool reorderable" : true,
32 "bool show_column_separators" : true,
33 "bool show_row_separators" : true,
34 "bool single_click_activate" : false,
35 "bool vexpand" : true,
42 "(n_press, x, y) => {",
44 "\tif (n_press < 2) { /// doubleclick?",
50 "\t// use selection?!",
51 "\tvar tr = (Gtk.TreeListRow)_this.selmodel.el.selected_item;",
52 "\tGLib.debug(\"SELECTED = %s\", tr.item.get_type().name());",
53 "\tvar prop = (JsRender.NodeProp) tr.item;",
57 "\t// double press ? ",
58 "//\tvar row = _this.view.getRowAt(x,y, out pos );",
59 "//\tvar prop = _this.sortmodel.getNodeAt(row);",
61 "//\t_this.select(np);",
63 "\tif (!prop.name.contains(\"[]\") && _this.node.has_prop_key(prop)) {",
64 "\t\tGLib.debug(\"node already has this key.\");",
65 "\t\treturn; // cant add it twice? -- ",
67 "\t// you can not click on ones with children.",
69 "\tif (prop.childstore.n_items > 0 ) {",
70 "\t\tGLib.debug(\"no clicking on expandables\");",
73 "\t// if it's a node...",
74 "\tif (prop.add_node != null) {",
76 "\t\tif (!prop.name.contains(\"[]\") && null != _this.node.findProp(prop.name)) {",
77 "\t\t\tGLib.debug(\"Add Child already contains child with %s\", prop.name);\t",
78 "\t\t\treturn;\t\t\t\t\t",
80 "\t\t GLib.debug(\"Add Child Node %s\", prop.name);\t\t\t",
81 "\t\t _this.el.hide();",
82 "\t\t var add = prop.add_node.deepClone();",
83 "\t\t_this.node.appendChild(add);",
84 "\t\t _this.mainwindow.windowstate.left_props.changed();",
85 "\t\t _this.mainwindow.windowstate.left_tree.model.selectNode(add);",
91 "\tGLib.debug(\"Add %s\", prop.name);",
92 "\tvar add = prop.dupe();",
93 "\t_this.node.add_prop(add);",
94 "\t _this.mainwindow.windowstate.left_props.changed();",
95 " \t_this.mainwindow.windowstate.left_props.view.editProp(add);",
98 "\t //_this.mainwindow.windowstate.left_props.changed();",
104 "xtype" : "GestureClick"
109 "bool can_unselect" : true,
116 "\t//this.el.set_sorter(new Gtk.TreeListRowSorter(_this.view.el.sorter));",
126 "new Gtk.TreeListModel(",
127 " new GLib.ListStore(typeof(JsRender.NodeProp)), //..... << that's our store..",
128 " false, // passthru",
129 " false, // autexpand",
131 " \treturn ((JsRender.NodeProp)item).childstore;",
140 "xtype" : "TreeListModel",
141 "| JsRender.NodeProp getNodeAt" : [
144 " var tr = (Gtk.TreeListRow)this.el.get_item(row);",
146 " return (JsRender.NodeProp)tr.get_item();",
161 "* prop" : "expression",
162 "GLib.Type this_type" : "typeof(JsRender.NodeProp)",
163 "string property_name" : "sort_name",
164 "xtype" : "PropertyExpression"
167 "xtype" : "StringSorter"
170 "xtype" : "TreeListRowSorter"
173 "xtype" : "SortListModel",
174 "| JsRender.NodeProp? getNodeAt" : [
177 " var tr = (Gtk.TreeListRow)this.el.get_item(row);",
179 " // GLib.debug(\"get_item (2) = %s\", a.get_type().name());",
182 " return (JsRender.NodeProp)tr.get_item();",
188 "xtype" : "SingleSelection",
189 "| JsRender.NodeProp? getNodeAt" : [
192 " var tr = (Gtk.TreeListRow)this.el.get_item(row);",
194 " var a = tr.get_item();; ",
195 " GLib.debug(\"get_item (2) = %s\", a.get_type().name());",
197 " return (JsRender.NodeProp)tr.get_item();",
206 "\t this.el.set_sorter( new Gtk.StringSorter(",
207 "\t \tnew Gtk.PropertyExpression(typeof(JsRender.NodeProp), null, \"name\")",
213 "* pack" : "append_column",
214 "bool expand" : true,
215 "bool resizable" : true,
220 "* prop" : "factory",
224 "\t //GLib.debug(\"listitme is is %s\", ((Gtk.ListItem)listitem).get_type().name());",
228 "\t//var expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child();",
229 "\tvar expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child();",
232 "\tvar lbl = (Gtk.Label) expand.child;",
234 "\t if (lbl.label != \"\") { // do not update",
239 "\tvar lr = (Gtk.TreeListRow)((Gtk.ListItem)listitem).get_item();",
240 "\tvar np = (JsRender.NodeProp) lr.get_item();",
241 "\tGLib.debug(\"change %s to %s\", lbl.label, np.name);",
242 "\tlbl.label = np.to_property_option_markup(np.propertyof == _this.node.fqn());",
243 "\tlbl.tooltip_markup = np.to_property_option_tooltip();",
245 " expand.set_hide_expander( np.childstore.n_items < 1);",
246 " \texpand.set_list_row(lr);",
249 " \t// bind image...",
257 "\tvar expand = new Gtk.TreeExpander();",
259 "\texpand.set_indent_for_depth(true);",
260 "\texpand.set_indent_for_icon(true);",
262 "\tvar lbl = new Gtk.Label(\"\");",
263 "\tlbl.use_markup = true;",
266 " \tlbl.halign = Gtk.Align.START;",
267 " \tlbl.xalign = 0;",
270 "\texpand.set_child(lbl);",
271 "\t((Gtk.ListItem)listitem).set_child(expand);",
272 "\t((Gtk.ListItem)listitem).activatable = false;",
277 "xtype" : "SignalListItemFactory"
280 "string title" : "Double click to add",
281 "xtype" : "ColumnViewColumn"
287 "\t this.el.set_sorter( new Gtk.StringSorter(",
288 "\t \tnew Gtk.PropertyExpression(typeof(JsRender.NodeProp), null, \"rtype\")",
294 "* pack" : "append_column",
295 "bool expand" : true,
296 "bool resizable" : true,
300 "* prop" : "factory",
305 " \tvar lbl = (Gtk.Label) ((Gtk.ListItem)listitem).get_child(); ",
306 " \tvar lr = (Gtk.TreeListRow)((Gtk.ListItem)listitem).get_item();",
307 "\tvar np = (JsRender.NodeProp) lr.get_item();",
309 " if (lbl.label != \"\") { // do not update",
312 "\tlbl.label = np.rtype;",
321 "\tvar label = new Gtk.Label(\"\");",
322 " \tlabel.halign = Gtk.Align.START;",
323 " \tlabel.xalign = 0;",
324 "\t((Gtk.ListItem)listitem).set_child(label);",
325 "\t((Gtk.ListItem)listitem).activatable = false;",
330 "xtype" : "SignalListItemFactory"
333 "string title" : "Type",
334 "xtype" : "ColumnViewColumn"
340 "\t this.el.set_sorter( new Gtk.StringSorter(",
341 "\t \tnew Gtk.PropertyExpression(typeof(JsRender.NodeProp), null, \"propertyof\")",
347 "* pack" : "append_column",
348 "bool expand" : true,
349 "bool resizable" : true,
353 "* prop" : "factory",
358 " \tvar lbl = (Gtk.Label) ((Gtk.ListItem)listitem).get_child(); ",
359 " \tvar lr = (Gtk.TreeListRow)((Gtk.ListItem)listitem).get_item();",
360 "\tvar np = (JsRender.NodeProp) lr.get_item();",
362 " if (lbl.label != \"\") { // do not update",
365 "\tlbl.label = np.propertyof;",
374 "\tvar label = new Gtk.Label(\"\");",
375 "\tlabel.halign = Gtk.Align.START;",
376 " \tlabel.xalign = 0;",
377 "\t((Gtk.ListItem)listitem).set_child(label);",
378 "\t((Gtk.ListItem)listitem).activatable = false;",
383 "xtype" : "SignalListItemFactory"
386 "string title" : "Property of",
387 "xtype" : "ColumnViewColumn"
390 "xtype" : "ColumnView",
392 "(double x, double in_y, out string pos) {",
399 "from \thttps://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465",
400 " \tvar colview = gesture.widget;",
401 " \tvar line_no = check_list_widget(colview, x,y);",
402 " if (line_no > -1) {",
403 " \t\tvar item = colview.model.get_item(line_no);",
409 " \t\t//GLib.debug(\"offset = %d y = %d\", (int) voff, (int) in_y);",
410 " \tvar y = in_y + _this.viewwin.el.vadjustment.value; ",
411 " var child = this.el.get_first_child(); ",
412 " \t//Gtk.Allocation alloc = { 0, 0, 0, 0 };",
413 " \tvar line_no = -1; ",
414 " \tvar reading_header = true;",
415 " \tvar real_y = 0;",
416 " \tvar header_height = 0;",
417 " \tpos = \"none\";",
419 " \twhile (child != null) {",
420 "\t\t\t//GLib.debug(\"Got %s\", child.get_type().name());",
421 " \t if (reading_header) {",
424 "\t\t\t\tif (child.get_type().name() != \"GtkColumnListView\") {",
425 "\t\t\t h += child.get_height();",
426 "\t\t\t\t\tchild = child.get_next_sibling();",
427 "\t\t\t\t\tcontinue;",
429 "\t\t\t\t// should be columnlistview",
430 "\t\t\t\tchild = child.get_first_child(); ",
431 "\t\t\t GLib.debug(\"header height=%d\", h);",
432 "\t\t\t\theader_height = h;",
434 "\t\t\t\treading_header = false;",
438 "\t\t if (child.get_type().name() != \"GtkColumnViewRowWidget\") {",
439 " \t\t child = child.get_next_sibling();",
443 "\t\t \tif (y < header_height) {",
448 "\t\t\tvar hh = child.get_height();",
449 "\t\t\t//child.get_allocation(out alloc);",
450 "\t\t\t//GLib.debug(\"got cell xy = %d,%d w,h= %d,%d\", alloc.x, alloc.y, alloc.width, alloc.height);",
451 "\t\t\t//GLib.debug(\"row %d y= %d %s\", line_no, (int) (header_height + alloc.y),",
453 "\t\t\t//\tchild.visible ? \"VIS\" : \"hidden\");",
455 "\t\t if (y > (header_height + real_y) && y <= (header_height + real_y + hh) ) {",
456 "\t\t \tif (y > ( header_height + real_y + (hh * 0.8))) {",
457 "\t\t \t\tpos = \"below\";",
458 "\t \t\t} else if (y > ( header_height + real_y + (hh * 0.2))) {",
459 "\t \t\t\tpos = \"over\";",
461 " \t\t\t\tpos = \"above\";",
463 "\t\t \t GLib.debug(\"getRowAt return : %d, %s\", line_no, pos);",
464 "\t\t\t return line_no;",
468 "\t\t if (real_y + hh > y) {",
472 "\t child = child.get_next_sibling(); ",
480 "xtype" : "ScrolledWindow"
486 " var m = (GLib.ListStore) _this.model.el.model;",
494 "\tthis.ptype = JsRender.NodePropType.NONE;",
496 "\tthis.node = null;",
501 "(Palete.Palete pal, JsRender.NodePropType ptype, JsRender.Node node , Gtk.Widget onbtn) {",
503 " /// what does this do?",
504 " //if (this.prop_or_listener != \"\" && this.prop_or_listener == prop_or_listener) {",
505 " //\tthis.prop_or_listener = \"\";",
506 " //\tthis.el.hide();",
509 "\tthis.node = node;",
511 "\tvar xtype = node.fqn();",
515 " this.ptype = ptype;",
517 " \t var m = (GLib.ListStore) _this.model.el.model;",
518 "\t m.remove_all();",
521 " ///Gee.HashMap<string,GirObject>",
522 " var elementList = pal.getPropertiesFor( xtype, ptype);",
524 " //print (\"GOT \" + elementList.length + \" items for \" + fullpath + \"|\" + type);",
525 " // console.dump(elementList);",
527 " var miter = elementList.map_iterator();",
528 " while (miter.next()) {",
529 " var p = miter.get_value(); // nodeprop.",
531 "\t\tvar prop = p.toNodeProp(pal, xtype);",
532 "\t\tif (prop == null) {",
535 "\t\tif (node.has_prop_key(prop)) {",
536 "\t\t\tGLib.debug(\"Skip - has key already %s\", prop.name);",
537 "\t\t\tcontinue;\t\t\t",
539 "\t\t//JsRender.NodeProp",
540 "\t\tGLib.debug(\"Prop add %s\", prop.name);",
541 "\t \t m.append(prop);",
544 " // set size up...",
547 " var win = this.mainwindow.el;",
548 " // var w = win.get_width();",
549 " var h = win.get_height() - 50;",
552 " // left tree = 250, editor area = 500?",
555 "\t// max hieght ...",
556 " this.el.set_size_request( 550, h);",
557 " //this.el.set_parent(onbtn);",
558 "\t_this.view.el.sort_by_column(null, Gtk.SortType.ASCENDING);",
559 "\t_this.view.el.sort_by_column(_this.name.el, Gtk.SortType.ASCENDING);",
561 "\t//Gtk.Allocation rect;",
562 "\t//onbtn.get_allocation(out rect);",
563 "\t//this.el.set_pointing_to(rect);",
566 " //while(Gtk.events_pending()) { ",
567 " // Gtk.main_iteration(); // why?",
569 " // this.hpane.el.set_position( 0);",
575 "name" : "PopoverAddProp"