{ "build_module" : "", "gen_extended" : false, "items" : [ { "# JsRender.NodePropType ptype" : "", "$ xns" : "Gtk", "* ctor" : "new Gtk.Popover()", "Gtk.PositionType position" : "Gtk.PositionType.RIGHT", "JsRender.Node? node" : "null", "Xcls_MainWindow mainwindow" : "", "bool active" : false, "bool hexpand" : false, "bool modal" : true, "id" : "PopoverAddProp", "int height_request" : 800, "int width_request" : 900, "items" : [ { "$ shadow_type" : "Gtk.ShadowType.IN", "$ xns" : "Gtk", "* pack" : "set_child", "Gtk.PolicyType hscrollbar_policy" : "Gtk.PolicyType.AUTOMATIC", "Gtk.PolicyType vscrollbar_policy" : "Gtk.PolicyType.AUTOMATIC", "id" : "viewwin", "items" : [ { "$ xns" : "Gtk", "* pack" : "set_child", "bool hexpand" : true, "bool reorderable" : true, "bool show_column_separators" : true, "bool show_row_separators" : true, "bool single_click_activate" : false, "bool vexpand" : true, "id" : "view", "items" : [ { "$ xns" : "Gtk", "listeners" : { "pressed" : [ "(n_press, x, y) => {", " ", "\tif (n_press < 2) { /// doubleclick?", "\t\treturn;", "\t}", "\t//string pos;", "\t", "\t", "\t// use selection?!", "\tvar tr = (Gtk.TreeListRow)_this.selmodel.el.selected_item;", "\tGLib.debug(\"SELECTED = %s\", tr.item.get_type().name());", "\tvar prop = (JsRender.NodeProp) tr.item;", "", "\t", "\t", "\t// double press ? ", "//\tvar row = _this.view.getRowAt(x,y, out pos );", "//\tvar prop = _this.sortmodel.getNodeAt(row);", " ", "//\t_this.select(np);", "\t", "\tif (!prop.name.contains(\"[]\") && _this.node.has_prop_key(prop)) {", "\t\tGLib.debug(\"node already has this key.\");", "\t\treturn; // cant add it twice? -- ", "\t}", "\t// you can not click on ones with children.", "\t", "\tif (prop.childstore.n_items > 0 ) {", "\t\tGLib.debug(\"no clicking on expandables\");", "\t\treturn;", "\t}", "\t// if it's a node...", "\tif (prop.add_node != null) {", "", "\t\tif (!prop.name.contains(\"[]\") && null != _this.node.findProp(prop.name)) {", "\t\t\tGLib.debug(\"Add Child already contains child with %s\", prop.name);\t", "\t\t\treturn;\t\t\t\t\t", "\t\t}", "\t\t GLib.debug(\"Add Child Node %s\", prop.name);\t\t\t", "\t\t _this.el.hide();", "\t\t var add = prop.add_node.deepClone();", "\t\t_this.node.appendChild(add);", "\t\t _this.mainwindow.windowstate.left_props.changed();", "\t\t _this.mainwindow.windowstate.left_tree.model.selectNode(add);", "\t\t ", "\t\treturn;", "\t}", "\t", "\t_this.el.hide();", "\tGLib.debug(\"Add %s\", prop.name);", "\tvar add = prop.dupe();", "\t_this.node.add_prop(add);", "\t _this.mainwindow.windowstate.left_props.changed();", " \t_this.mainwindow.windowstate.left_props.view.editProp(add);", "\t", "", "\t //_this.mainwindow.windowstate.left_props.changed();", "", "}", "" ] }, "xtype" : "GestureClick" }, { "$ xns" : "Gtk", "* prop" : "model", "bool can_unselect" : true, "id" : "selmodel", "items" : [ { "$ xns" : "Gtk", "* init" : [ "{", "\t//this.el.set_sorter(new Gtk.TreeListRowSorter(_this.view.el.sorter));", "}", "" ], "* prop" : "model", "id" : "sortmodel", "items" : [ { "$ xns" : "Gtk", "* ctor" : [ "new Gtk.TreeListModel(", " new GLib.ListStore(typeof(JsRender.NodeProp)), //..... << that's our store..", " false, // passthru", " false, // autexpand", " (item) => {", " \treturn ((JsRender.NodeProp)item).childstore;", " ", " }", " ", " ", ")" ], "* prop" : "model", "id" : "model", "xtype" : "TreeListModel", "| JsRender.NodeProp getNodeAt" : [ "(uint row) {", "", " var tr = (Gtk.TreeListRow)this.el.get_item(row);", " ", " return (JsRender.NodeProp)tr.get_item();", "\t ", "}" ] }, { "$ xns" : "Gtk", "* prop" : "sorter", "items" : [ { "$ xns" : "Gtk", "* prop" : "sorter", "items" : [ { "$ xns" : "Gtk", "* prop" : "expression", "GLib.Type this_type" : "typeof(JsRender.NodeProp)", "string property_name" : "sort_name", "xtype" : "PropertyExpression" } ], "xtype" : "StringSorter" } ], "xtype" : "TreeListRowSorter" } ], "xtype" : "SortListModel", "| JsRender.NodeProp? getNodeAt" : [ "(uint row) {", "", " var tr = (Gtk.TreeListRow)this.el.get_item(row);", " ", " // GLib.debug(\"get_item (2) = %s\", a.get_type().name());", " \t", " ", " return (JsRender.NodeProp)tr.get_item();", "\t ", "}" ] } ], "xtype" : "SingleSelection", "| JsRender.NodeProp? getNodeAt" : [ "(uint row) {", "", " var tr = (Gtk.TreeListRow)this.el.get_item(row);", " ", " var a = tr.get_item();; ", " GLib.debug(\"get_item (2) = %s\", a.get_type().name());", " ", " return (JsRender.NodeProp)tr.get_item();", "\t ", "}" ] }, { "$ xns" : "Gtk", "* init" : [ "{", "\t this.el.set_sorter( new Gtk.StringSorter(", "\t \tnew Gtk.PropertyExpression(typeof(JsRender.NodeProp), null, \"name\")", " \t));", "\t\t", "}", "" ], "* pack" : "append_column", "bool expand" : true, "bool resizable" : true, "id" : "name", "items" : [ { "$ xns" : "Gtk", "* prop" : "factory", "listeners" : { "bind" : [ "(listitem) => {", "\t //GLib.debug(\"listitme is is %s\", ((Gtk.ListItem)listitem).get_type().name());", "\t", "\t", "\t", "\t//var expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child();", "\tvar expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child();", "\t ", " ", "\tvar lbl = (Gtk.Label) expand.child;", "\t", "\t if (lbl.label != \"\") { // do not update", "\t \treturn;", " \t}", "\t", "", "\tvar lr = (Gtk.TreeListRow)((Gtk.ListItem)listitem).get_item();", "\tvar np = (JsRender.NodeProp) lr.get_item();", "\tGLib.debug(\"change %s to %s\", lbl.label, np.name);", "\tlbl.label = np.to_property_option_markup(np.propertyof == _this.node.fqn());", "\tlbl.tooltip_markup = np.to_property_option_tooltip();", "\t ", " expand.set_hide_expander( np.childstore.n_items < 1);", " \texpand.set_list_row(lr);", " ", " \t ", " \t// bind image...", " \t", "}", "" ], "setup" : [ "(listitem) => {", "\t", "\tvar expand = new Gtk.TreeExpander();", "\t ", "\texpand.set_indent_for_depth(true);", "\texpand.set_indent_for_icon(true);", "\t ", "\tvar lbl = new Gtk.Label(\"\");", "\tlbl.use_markup = true;", "\t", "\t", " \tlbl.halign = Gtk.Align.START;", " \tlbl.xalign = 0;", "", " ", "\texpand.set_child(lbl);", "\t((Gtk.ListItem)listitem).set_child(expand);", "\t((Gtk.ListItem)listitem).activatable = false;", "}", "" ] }, "xtype" : "SignalListItemFactory" } ], "string title" : "Double click to add", "xtype" : "ColumnViewColumn" }, { "$ xns" : "Gtk", "* init" : [ "{", "\t this.el.set_sorter( new Gtk.StringSorter(", "\t \tnew Gtk.PropertyExpression(typeof(JsRender.NodeProp), null, \"rtype\")", " \t));", "\t\t", "}", "" ], "* pack" : "append_column", "bool expand" : true, "bool resizable" : true, "items" : [ { "$ xns" : "Gtk", "* prop" : "factory", "listeners" : { "bind" : [ "(listitem) => {", "\t", " \tvar lbl = (Gtk.Label) ((Gtk.ListItem)listitem).get_child(); ", " \tvar lr = (Gtk.TreeListRow)((Gtk.ListItem)listitem).get_item();", "\tvar np = (JsRender.NodeProp) lr.get_item();", "\t", " if (lbl.label != \"\") { // do not update", "\t \treturn;", " \t}", "\tlbl.label = np.rtype;", " \t ", "}", "" ], "setup" : [ "(listitem) => {", "", "\t ", "\tvar label = new Gtk.Label(\"\");", " \tlabel.halign = Gtk.Align.START;", " \tlabel.xalign = 0;", "\t((Gtk.ListItem)listitem).set_child(label);", "\t((Gtk.ListItem)listitem).activatable = false;", "}", "" ] }, "xtype" : "SignalListItemFactory" } ], "string title" : "Type", "xtype" : "ColumnViewColumn" }, { "$ xns" : "Gtk", "* init" : [ "{", "\t this.el.set_sorter( new Gtk.StringSorter(", "\t \tnew Gtk.PropertyExpression(typeof(JsRender.NodeProp), null, \"propertyof\")", " \t));", "\t\t", "}", "" ], "* pack" : "append_column", "bool expand" : true, "bool resizable" : true, "items" : [ { "$ xns" : "Gtk", "* prop" : "factory", "listeners" : { "bind" : [ "(listitem) => {", "", " \tvar lbl = (Gtk.Label) ((Gtk.ListItem)listitem).get_child(); ", " \tvar lr = (Gtk.TreeListRow)((Gtk.ListItem)listitem).get_item();", "\tvar np = (JsRender.NodeProp) lr.get_item();", "\t", " if (lbl.label != \"\") { // do not update", "\t \treturn;", " \t}", "\tlbl.label = np.propertyof;", " \t ", "}", "" ], "setup" : [ "(listitem) => {", "", "\t ", "\tvar label = new Gtk.Label(\"\");", "\tlabel.halign = Gtk.Align.START;", " \tlabel.xalign = 0;", "\t((Gtk.ListItem)listitem).set_child(label);", "\t((Gtk.ListItem)listitem).activatable = false;", "}", "" ] }, "xtype" : "SignalListItemFactory" } ], "string title" : "Property of", "xtype" : "ColumnViewColumn" } ], "xtype" : "ColumnView", "| int getRowAt" : [ "(double x, double in_y, out string pos) {", "", "", "\t ", "", "/*", " \t", "from \thttps://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465", " \tvar colview = gesture.widget;", " \tvar line_no = check_list_widget(colview, x,y);", " if (line_no > -1) {", " \t\tvar item = colview.model.get_item(line_no);", " \t\t ", " \t}", " \t*/", " \t\t ", " \t\t", " \t\t//GLib.debug(\"offset = %d y = %d\", (int) voff, (int) in_y);", " \tvar y = in_y + _this.viewwin.el.vadjustment.value; ", " var child = this.el.get_first_child(); ", " \t//Gtk.Allocation alloc = { 0, 0, 0, 0 };", " \tvar line_no = -1; ", " \tvar reading_header = true;", " \tvar real_y = 0;", " \tvar header_height = 0;", " \tpos = \"none\";", " \tvar h = 0;", " \twhile (child != null) {", "\t\t\t//GLib.debug(\"Got %s\", child.get_type().name());", " \t if (reading_header) {", "\t\t\t\t", "", "\t\t\t\tif (child.get_type().name() != \"GtkColumnListView\") {", "\t\t\t h += child.get_height();", "\t\t\t\t\tchild = child.get_next_sibling();", "\t\t\t\t\tcontinue;", "\t\t\t\t}", "\t\t\t\t// should be columnlistview", "\t\t\t\tchild = child.get_first_child(); ", "\t\t\t GLib.debug(\"header height=%d\", h);", "\t\t\t\theader_height = h;", "\t\t\t\t", "\t\t\t\treading_header = false;", "\t\t\t\t", "\t }", "\t ", "\t\t if (child.get_type().name() != \"GtkColumnViewRowWidget\") {", " \t\t child = child.get_next_sibling();", " \t\t continue;", "\t\t }", "\t\t ", "\t\t \tif (y < header_height) {", "\t\t \treturn -1;", "\t \t}", "\t\t ", "\t\t line_no++;", "\t\t\tvar hh = child.get_height();", "\t\t\t//child.get_allocation(out alloc);", "\t\t\t//GLib.debug(\"got cell xy = %d,%d w,h= %d,%d\", alloc.x, alloc.y, alloc.width, alloc.height);", "\t\t\t//GLib.debug(\"row %d y= %d %s\", line_no, (int) (header_height + alloc.y),", "\t\t\t", "\t\t\t//\tchild.visible ? \"VIS\" : \"hidden\");", "", "\t\t if (y > (header_height + real_y) && y <= (header_height + real_y + hh) ) {", "\t\t \tif (y > ( header_height + real_y + (hh * 0.8))) {", "\t\t \t\tpos = \"below\";", "\t \t\t} else if (y > ( header_height + real_y + (hh * 0.2))) {", "\t \t\t\tpos = \"over\";", " \t\t\t} else {", " \t\t\t\tpos = \"above\";", "\t\t\t\t}", "\t\t \t GLib.debug(\"getRowAt return : %d, %s\", line_no, pos);", "\t\t\t return line_no;", "\t\t }", " ", "", "\t\t if (real_y + hh > y) {", "\t\t return -1;", "\t }", "\t real_y += hh;", "\t child = child.get_next_sibling(); ", " \t}", " return -1;", "", " }" ] } ], "xtype" : "ScrolledWindow" } ], "xtype" : "Popover", "| void clear" : [ "() {", " var m = (GLib.ListStore) _this.model.el.model;", "\tm.remove_all();", "", "}", "" ], "| void hide" : [ "() {", "\tthis.ptype = JsRender.NodePropType.NONE;", "\tthis.el.hide();", "\tthis.node = null;", "}", "" ], "| void show" : [ "(Palete.Palete pal, JsRender.NodePropType ptype, JsRender.Node node , Gtk.Widget onbtn) {", "", " /// what does this do?", " //if (this.prop_or_listener != \"\" && this.prop_or_listener == prop_or_listener) {", " //\tthis.prop_or_listener = \"\";", " //\tthis.el.hide();", " //\treturn;", "\t//}", "\tthis.node = node;", "\t", "\tvar xtype = node.fqn();", "\t", "\t// ", "\t", " this.ptype = ptype;", " ", " \t var m = (GLib.ListStore) _this.model.el.model;", "\t m.remove_all();", " ", " ", " ///Gee.HashMap", " var elementList = pal.getPropertiesFor( xtype, ptype);", " ", " //print (\"GOT \" + elementList.length + \" items for \" + fullpath + \"|\" + type);", " // console.dump(elementList);", " ", " var miter = elementList.map_iterator();", " while (miter.next()) {", " var p = miter.get_value(); // nodeprop.", " ", "\t\tvar prop = p.toNodeProp(pal, xtype);", "\t\tif (prop == null) {", "\t\t\tcontinue;", "\t\t}", "\t\tif (node.has_prop_key(prop)) {", "\t\t\tGLib.debug(\"Skip - has key already %s\", prop.name);", "\t\t\tcontinue;\t\t\t", "\t\t}", "\t\t//JsRender.NodeProp", "\t\tGLib.debug(\"Prop add %s\", prop.name);", "\t \t m.append(prop);", " }", " ", " // set size up...", " ", " ", " var win = this.mainwindow.el;", " // var w = win.get_width();", " var h = win.get_height() - 50;", "", "", " // left tree = 250, editor area = 500?", " ", " // min 450?", "\t// max hieght ...", " this.el.set_size_request( 550, h);", " //this.el.set_parent(onbtn);", "\t_this.view.el.sort_by_column(null, Gtk.SortType.ASCENDING);", "\t_this.view.el.sort_by_column(_this.name.el, Gtk.SortType.ASCENDING);", "", "\t//Gtk.Allocation rect;", "\t//onbtn.get_allocation(out rect);", "\t//this.el.set_pointing_to(rect);", " this.el.show();", " ", " //while(Gtk.events_pending()) { ", " // Gtk.main_iteration(); // why?", " //} ", " // this.hpane.el.set_position( 0);", "}", "" ] } ], "name" : "PopoverAddProp" }