{ "build_module" : "", "gen_extended" : false, "items" : [ { "$ xns" : "Gtk", "@ void after_node_change" : "(JsRender.Node? node)", "@ void before_node_change" : "(JsRender.Node? node)", "Gtk.PositionType position" : "Gtk.PositionType.RIGHT", "Xcls_MainWindow mainwindow" : "", "bool active" : false, "bool hexpand" : false, "bool modal" : true, "id" : "PopoverAddObject", "int height_request" : 800, "int width_request" : 900, "items" : [ { "$ shadow_type" : "Gtk.ShadowType.IN", "$ xns" : "Gtk", "* init" : [ " this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);", " this.el.set_size_request(-1,200);", " ", "" ], "* pack" : "set_child", "id" : "viewwin", "items" : [ { "$ xns" : "Gtk", "* pack" : "set_child", "bool hexpand" : true, "bool vexpand" : true, "id" : "view", "items" : [ { "$ Gdk.DragAction[] actions" : "Gdk.DragAction.COPY | Gdk.DragAction.MOVE ", "$ xns" : "Gtk", "listeners" : { "drag_begin" : [ "( drag ) => {", "\tGLib.debug(\"SOURCE: drag-begin\");", "\t ", " // find what is selected in our tree...", " var data = _this.selmodel.getSelectedNode();", "\tif (data == null) {", "\t\treturn ;", "\t}", "\t ", " var xname = data.fqn();", " GLib.debug (\"XNAME IS %s\", xname);", "", " \tvar widget = _this.view.getWidgetAtRow(_this.selmodel.el.selected);", " \t", " \t", " var paintable = new Gtk.WidgetPaintable(widget);", " this.el.set_icon(paintable, 0,0);", " ", " ", "}" ], "drag_end" : [ "(drag, delete_data) => {", "\t_this.hide();", "", "}", "" ], "prepare" : [ "(x, y) => {", "", "\t", "\t", "///\t( drag_context, data, info, time) => {", " ", "", "\t//print(\"drag-data-get\");", " \tvar ndata = _this.selmodel.getSelectedNode();", "\tif (ndata == null) {", "\t \tGLib.debug(\"return empty string - no selection..\");", "\t\treturn null;", "\t ", "\t}", "", " ", "\t//data.set_text(tp,tp.length); ", "", "\tvar \tstr = ndata.toJsonString();", "\tGLib.debug(\"prepare store: %s\", str);", "\tGLib.Value ov = GLib.Value(typeof(string));", "\tov.set_string(str);", " \tvar cont = new Gdk.ContentProvider.for_value(ov);", " ", "\t//GLib.Value v = GLib.Value(typeof(string));", "\t//var str = drop.read_text( [ \"text/plain\" ] 0);", "\t ", "\t//cont.get_value(ref v);", "\t//GLib.debug(\"set %s\", v.get_string());", " ", " \treturn cont;", "\t ", "}", "" ] }, "xtype" : "DragSource" }, { "$ xns" : "Gtk", "* prop" : "model", "id" : "selmodel", "items" : [ { "$ xns" : "Gtk", "* ctor" : [ "new Gtk.TreeListModel(", " new GLib.ListStore(typeof(JsRender.Node)), //..... << that's our store..", " false, // passthru", " true, // autexpand", " (item) => {", " \treturn ((JsRender.Node)item).childstore;", " ", " }", " ", " ", ")" ], "* prop" : "model", "id" : "model", "xtype" : "TreeListModel" } ], "xtype" : "SingleSelection", "| JsRender.Node 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.Node)tr.get_item();", "\t ", "}" ], "| JsRender.Node? getSelectedNode" : [ "() {", " if (this.el.selected_item == null) {", "\t\treturn null;", " }\t\t\t ", " var tr = (Gtk.TreeListRow)this.el.selected_item;", " return (JsRender.Node)tr.get_item();", "\t ", "}" ] }, { "$ xns" : "Gtk", "* pack" : "append_column", "bool expand" : true, "id" : "maincol", "items" : [ { "$ xns" : "Gtk", "* prop" : "factory", "listeners" : { "bind" : [ "(listitem) => {", "\t //GLib.debug(\"listitme is is %s\", ((Gtk.ListItem)listitem).get_type().name());", "\t", "\t//var expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child();", " ", "\t ", " \tvar hbox = (Gtk.Box) ((Gtk.ListItem)listitem).get_child();", " ", " ", "\t", "\tvar img = (Gtk.Image) hbox.get_first_child();", "\tvar lbl = (Gtk.Label) img.get_next_sibling();", "\t", "\tvar lr = (Gtk.TreeListRow)((Gtk.ListItem)listitem).get_item();", "\t", "\t", "\t", "\tvar node = (JsRender.Node) lr.get_item();", "\t", " GLib.debug(\"node is %s\", node.get_type().name());", " GLib.debug(\"lbl is %s\", lbl.get_type().name());", " GLib.debug(\"node fqn %s\", node.fqn());", "// was item (1) in old layout", "", "\t ", " \timg.file = node.iconFilename;", " \tlbl.label = node.fqn();", "// \tlbl.tooltip_markup = node.nodeTip();", " ", " ", " \t// bind image...", " \t", "}", "" ], "setup" : [ "(listitem) => {", "\t", " ", "\tvar hbox = new Gtk.Box(Gtk.Orientation.HORIZONTAL,0);", "\tvar icon = new Gtk.Image();", "\tvar lbl = new Gtk.Label(\"\");", "\tlbl.use_markup = true;", "\t", "\t", " \tlbl.justify = Gtk.Justification.LEFT;", " \tlbl.xalign = 0;", "\tlbl.margin_start = 4;", "//\tlistitem.activatable = true; ??", "\t", "\thbox.append(icon);", "\thbox.append(lbl);", "\t ", "\t((Gtk.ListItem)listitem).set_child(hbox);", "\t ", "}", "" ] }, "xtype" : "SignalListItemFactory" } ], "title" : "Drag to add Object", "xtype" : "ColumnViewColumn" }, { "$ xns" : "Gtk", "listeners" : { "pressed" : [ "(n_press, x, y) => {", "\tif (n_press < 2) { /// doubleclick?", "\t\treturn;", "\t}", "\t//var pos = \"\";", "\t// find left tree selected node", "\tvar addto = _this.mainwindow.windowstate.left_tree.selmodel.getSelectedNode();", "\t//var row = _this.view.getRowAt(x,y, out pos);", "\t", " \t var add = _this.selmodel.getSelectedNode().deepClone();", "\taddto.appendChild(add);", "\t_this.mainwindow.windowstate.left_props.changed();", "\t_this.mainwindow.windowstate.left_tree.model.selectNode(add);", "}", "" ] }, "xtype" : "GestureClick" } ], "xtype" : "ColumnView", "| Gtk.Widget? getWidgetAt" : [ "(double x, double in_y) {", "/*", " \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*/", " \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 curr_y = 0;", " \tvar header_height = 0;", " \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 line_no++;", "", "\t\t\tif (y < header_height) {", "\t\t \treturn null;", "\t \t}", "", "\t\t\tvar hh = child.get_height();", "\t\t\t//GLib.debug(\"got cell xy = %d,%d w,h= %d,%d\", alloc.x, alloc.y, alloc.width, alloc.height);", "", "\t\t if (y > curr_y && y <= header_height + hh + curr_y ) {", "\t\t\t return (Gtk.Widget)child;", "\t\t }", "\t\t curr_y += hh ;", "", "\t\t if (curr_y > y) {", "\t\t return null;", "\t }", "\t child = child.get_next_sibling(); ", " \t}", " return null;", "", " }" ], "| Gtk.Widget? getWidgetAtRow" : [ "(uint row) {", "/*", "// ?? could be done with model?", " \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\tGLib.debug(\"Get Widget At Row %d\", (int)row);", " var child = this.el.get_first_child(); ", " \tvar line_no = -1; ", " \tvar reading_header = true;", "", " \twhile (child != null) {", "\t\t\tGLib.debug(\"Got %s\", child.get_type().name());", " \t if (reading_header) {", "\t\t\t ", "\t\t\t ", "\t\t\t\tif (child.get_type().name() != \"GtkColumnListView\") {", "\t\t\t\t\tchild = child.get_next_sibling();", "\t\t\t\t\tcontinue;", "\t\t\t\t}", "\t\t\t\tchild = child.get_first_child(); ", "\t\t\t\treading_header = false;", "\t }", "\t\t if (child.get_type().name() != \"GtkColumnViewRowWidget\") {", " \t\t child = child.get_next_sibling();", " \t\t continue;", "\t\t }", "\t\t line_no++;", "\t\t\tif (line_no == row) {", "\t\t\t\tGLib.debug(\"Returning widget %s\", child.get_type().name());", "\t\t\t return (Gtk.Widget)child;", "\t\t }", "\t child = child.get_next_sibling(); ", " \t}", "\t\tGLib.debug(\"Rturning null\");", " return null;", "", " }" ], "| 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 a_clear" : [ "() {", " var m = (GLib.ListStore) _this.model.el.model;", "\tm.remove_all();", "", "\t", "", "}", "" ], "| void hide" : [ "() {", " ", "\tthis.el.hide();", "}", "" ], "| void show" : [ "(Palete.Palete pal, string cls, Gtk.Widget onbtn) {", "", " ", "", " var tr = pal.getChildList(cls, false);", " var m = (GLib.ListStore) _this.model.el.model;", "\tm.remove_all();", "", "\t", "\t// new version will not support properties here..", "\t// they will be part of the properties, clicking will add a node..", "\t// will change the return list above eventually?", "\t", " ", "\tforeach (var dname in tr) {", "\t\t ", "", "\t\tGLib.debug(\"add to model: %s\", dname);\t\t", "\t\tm.append(pal.fqnToNode(dname));", "\t}", "\t m.sort( (a, b) => {", "", "\t\t\treturn Posix.strcmp( ((JsRender.Node)a).fqn(), ((JsRender.Node)b).fqn());", "\t\t\t", "\t\t});", "\t ", " ", " var win = this.mainwindow.el;", " //var w = win.get_width();", " var h = win.get_height();", "", " ", " // left tree = 250, editor area = 500?", " ", " // min 450?", "\t// max hieght ...", " this.el.set_size_request( 350, h); // full height?", "", " this.el.set_parent(onbtn);", "", " //if (this.el.relative_to == null) {", " \t//Gtk.Allocation rect;", " \t//onbtn.get_allocation(out rect);", " // this.el.set_pointing_to(rect);", " //}", " this.selmodel.el.set_selected(Gtk.INVALID_LIST_POSITION);", " this.el.show();", " ", "}", "" ] } ], "name" : "PopoverAddObject" }