{
"build_module" : "builder",
"gen_extended" : false,
"items" : [
{
"# JsRender.NodeProp? prop" : "",
"$ xns" : "Gtk",
"* ctor" : "new Gtk.Popover()",
"@ void success" : "(Project.Project pr, JsRender.JsRender file)",
"Gtk.PositionType position" : "Gtk.PositionType.RIGHT",
"JsRender.Node node" : "",
"Xcls_MainWindow mainwindow" : "null",
"bool autohide" : true,
"bool done" : false,
"bool is_new" : false,
"id" : "PopoverProperty",
"items" : [
{
"$ xns" : "Gtk",
"* pack" : "set_child",
"Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
"bool homogeneous" : false,
"items" : [
{
"$ xns" : "Gtk",
"bool show_title_buttons" : false,
"id" : "header",
"items" : [
{
"$ xns" : "Gtk",
"* prop" : "title_widget",
"id" : "headertitle",
"string label" : "Add / Edit property",
"xtype" : "Label"
}
],
"xtype" : "HeaderBar"
},
{
"$ xns" : "Gtk",
"bool show_row_separators" : true,
"bool show_separators" : true,
"id" : "ptype",
"items" : [
{
"$ xns" : "Gtk",
"* prop" : "model",
"id" : "pselmodel",
"items" : [
{
"$ xns" : "GLib",
"* ctor" : "new GLib.ListStore(typeof(JsRender.NodeProp));",
"* init" : [
"{",
"",
"",
"\tthis.el.append( new JsRender.NodeProp.prop(\"\"));",
"\tthis.el.append( new JsRender.NodeProp.raw(\"\"));",
"\tthis.el.append( new JsRender.NodeProp.valamethod(\"\"));",
"\tthis.el.append( new JsRender.NodeProp.special(\"\"));\t",
"\tthis.el.append( new JsRender.NodeProp.listener(\"\"));\t\t",
"\tthis.el.append( new JsRender.NodeProp.user(\"\"));\t",
"\tthis.el.append( new JsRender.NodeProp.sig(\"\"));\t",
"\t",
"",
"}",
""
],
"* prop" : "model",
"id" : "pmodel",
"xtype" : "ListStore"
}
],
"xtype" : "SingleSelection"
},
{
"$ xns" : "Gtk",
"* pack" : "append_column",
"items" : [
{
"$ xns" : "Gtk",
"* prop" : "factory",
"listeners" : {
"bind" : [
"(listitem) => {",
"",
" \tvar lbl = (Gtk.Label) ((Gtk.ListItem)listitem).get_child(); ",
" \tvar np = (JsRender.NodeProp)((Gtk.ListItem)listitem).get_item();",
" ",
"\t",
" ",
"\tlbl.label = np.ptype.to_name();",
" \t ",
"}",
""
],
"setup" : [
"(listitem) => {",
"",
"\t ",
"\tvar label = new Gtk.Label(\"\");",
"\tlabel.xalign = 0;",
"\t ",
"\t((Gtk.ListItem)listitem).set_child(label);",
"\t((Gtk.ListItem)listitem).activatable = false;",
"\t",
"}",
""
]
},
"xtype" : "SignalListItemFactory"
}
],
"string title" : "Property Type",
"xtype" : "ColumnViewColumn"
}
],
"xtype" : "ColumnView",
"| JsRender.NodePropType getValue" : [
"() {",
"\t",
"\tvar li = (JsRender.NodeProp) _this.pmodel.el.get_item(",
"\t\t_this.pselmodel.el.get_selected()",
"\t\t);",
"\treturn li.ptype;",
"",
"}"
],
"| void setValue" : [
"(JsRender.NodePropType pt) ",
"{",
" \tfor (var i = 0; i < _this.pmodel.el.n_items; i++) {",
"\t \tvar li = (JsRender.NodeProp) _this.pmodel.el.get_item(i);",
" \t\tif (li.ptype == pt) {",
" \t\t\t_this.pselmodel.el.set_selected(i);",
" \t\t\treturn;",
"\t\t}",
"\t}",
"\tGLib.debug(\"failed to set selected ptype\");",
"\t_this.pselmodel.el.set_selected(0);",
"}"
]
},
{
"$ visible" : true,
"$ xns" : "Gtk",
"Gtk.Align halign" : "Gtk.Align.START",
"Gtk.Justification justify" : "Gtk.Justification.LEFT",
"int margin_top" : 12,
"label" : "Type or Return Type",
"x_options" : 4,
"xtype" : "Label"
},
{
"$ visible" : true,
"$ xns" : "Gtk",
"id" : "ktype",
"xtype" : "Entry"
},
{
"$ visible" : true,
"$ xns" : "Gtk",
"Gtk.Align halign" : "Gtk.Align.START",
"Gtk.Justification justify" : "Gtk.Justification.LEFT",
"int margin_top" : 12,
"label" : "Name",
"tooltip_text" : "center, north, south, east, west",
"x_options" : 4,
"xtype" : "Label"
},
{
"$ visible" : true,
"$ xns" : "Gtk",
"id" : "kname",
"items" : [
{
"$ xns" : "Gtk",
"listeners" : {
"leave" : [
"( ) => {",
"",
" _this.error.setError(\"\");",
"\tvar val = _this.kname.el.get_text().strip(); ",
"\tif (val.length < 1) {",
"\t\t_this.error.setError(\"Name can not be empty\");",
"\t}",
"",
"}",
""
]
},
"xtype" : "EventControllerFocus"
},
{
"$ xns" : "Gtk",
"listeners" : {
"key_released" : [
"(keyval, keycode, state) => {",
"",
" _this.error.setError(\"\");",
"\tvar val = _this.kname.el.get_text().strip(); ",
"\tif (val.length < 1) {",
"\t\t_this.error.setError(\"Name can not be empty\");",
"\t}",
"",
"}",
""
]
},
"xtype" : "EventControllerKey"
}
],
"xtype" : "Entry"
},
{
"$ visible" : true,
"$ xns" : "Gtk",
"Gtk.Align halign" : "Gtk.Align.START",
"Gtk.Justification justify" : "Gtk.Justification.LEFT",
"bool use_markup" : true,
"id" : "error",
"int margin_top" : 0,
"label" : "Error Message",
"tooltip_text" : "center, north, south, east, west",
"x_options" : 4,
"xtype" : "Label",
"| void setError" : [
"(string err) {",
"\tif (err == \"\") {",
"\t\tthis.el.label = \"\";",
"\t} else {",
"",
"\t\t",
"\t\tthis.el.label = \"\" + err + \"\";",
"\t}",
"}",
""
]
},
{
"$ xns" : "Gtk",
"Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
"id" : "buttonbar",
"int margin_top" : 20,
"items" : [
{
"$ xns" : "Gtk",
"bool always_show_image" : true,
"bool hexpand" : true,
"listeners" : {
"clicked" : [
"() => {",
"\t_this.prop = null;",
"\t_this.is_new = false;",
"\t_this.kname.el.set_text(\"Cancel\");",
"\t_this.el.hide();",
"\t",
"}"
]
},
"string label" : "Cancel",
"xtype" : "Button"
},
{
"$ xns" : "Gtk",
"bool always_show_image" : true,
"bool hexpand" : true,
"listeners" : {
"clicked" : [
"() => {",
"\t// check if text is not empty..",
"\tif ( _this.kname.el.get_text().strip().length < 1) {",
"\t",
"\t\t// error should already be showing?",
"\t\treturn;",
"\t}",
"\t ",
"\t// since we can't add listeners?!?!?",
"\t// only check props.",
"\t// check if property already exists in node.\t",
"",
"",
"\tvar prop = new JsRender.NodeProp(",
"\t\t_this.kname.el.get_text().strip(),",
"\t\t_this.ptype.getValue(),",
"\t\t_this.ktype.el.get_text().strip(),",
"\t\t_this.prop.val",
"\t);",
"",
"\tif (_this.node.props.has_key(prop.to_index_key())) {",
"\t\t_this.error.setError(\"Property already exists\");",
"\t\treturn;\t",
"\t}",
"\t",
"\t",
"\t",
"\t_this.node.add_prop(prop);",
"\t// hide self",
"\t_this.prop = null; // skip checks..",
"\t_this.is_new = false;",
"\t_this.el.hide();",
" ",
"\t_this.mainwindow.windowstate.left_props.view.editProp(prop);",
"",
"\t",
"\t",
"}"
]
},
"string label" : "Add Property",
"xtype" : "Button"
}
],
"xtype" : "Box"
}
],
"xtype" : "Box"
}
],
"listeners" : {
"closed" : [
"() => {",
"",
" \tGLib.debug(\"popover closed\");",
"\tif (_this.is_new) {",
"\t\t// dont allow hiding if we are creating a new one.",
"\t\t// on.hide will reshow it.",
"\t\treturn;",
"\t}",
"\tif (_this.prop == null) {",
"\t\t// hide and dont update.",
"\t\treturn;",
"\t}",
"\tif (this.kname.el.get_text().strip().length < 1) {",
"\t\treturn;",
"\t}",
"\t",
" ",
" \t",
" ",
" \tthis.updateProp();",
" ",
"\t ",
"",
"",
" ",
"} "
],
"hide" : [
"() => {",
" \tGLib.debug(\"popover hidden\");",
"\tif (_this.is_new || this.kname.el.get_text().strip().length < 1) {",
"\t\t// dont allow hiding if we are creating a new one.",
"\t\tGLib.debug(\"prevent hiding as its new or text is empty\"); ",
"\t\tthis.el.show();",
"\t\treturn;",
"",
"\t}",
"\t",
"}"
]
},
"string key_type" : "",
"string old_keyname" : "",
"xtype" : "Popover",
"| void show" : [
"(",
"\tGtk.Widget btn, ",
"\tJsRender.Node node, ",
"\tJsRender.NodeProp prop, ",
"\tint y,",
"\tbool is_new = false",
"\t ) ",
"{",
"\t",
" ",
"\tthis.is_new = is_new; ",
"\tvar pref = is_new ? \"Add \" : \"Modify \";",
"\tif (prop.ptype == JsRender.NodePropType.LISTENER) {",
"\t\tthis.headertitle.el.label = pref + \"Event Listener\"; // cant really happen yet?",
"\t} else {",
"\t\tthis.headertitle.el.label = pref + \"Property\";",
"\t}",
"\tthis.prop = prop;",
"\tthis.node = node;",
"\t",
"\t_this.kname.el.set_text(prop.name);",
"\t_this.ktype.el.set_text(prop.rtype);",
"\t",
" \t_this.ptype.setValue(prop.ptype);",
"\t// does node have this property...",
"",
"",
"\t_this.node = node;",
"\t//console.log('show all');",
"\t",
"\tGLib.debug(\"set parent = %s\", btn.get_type().name());",
"\tvar par = btn.get_parent();",
"\t",
"\tif (par == null) {",
"\t\tGLib.debug(\"parent of that is null - not showing\");",
"\t\treturn;",
"\t}",
"\tif (this.el.parent == null) {",
"\t\tthis.el.set_parent(btn);",
"\t}",
"\tvar r = Gdk.Rectangle() {",
"\t\t\tx = btn.get_width(), // align left...",
"\t\t\ty = 0,",
"\t\t\twidth = 1,",
"\t\t\theight = 1",
"\t\t};",
"\t//Gtk.Allocation rect;",
"\t//btn.get_allocation(out rect);",
" this.el.set_pointing_to(r);",
" ",
"",
"\t ",
"\tif (y > -1) {",
"\t\t ",
"\t\t r = Gdk.Rectangle() {",
"\t\t\tx = btn.get_width(), // align left...",
"\t\t\ty = y,",
"\t\t\twidth = 1,",
"\t\t\theight = 1",
"\t\t};",
"\t\tthis.el.set_pointing_to( r);",
"\t}",
"\t",
"\t",
"",
"\t//this.el.set_position(Gtk.PositionType.TOP);",
"",
"\t// window + header?",
"\t GLib.debug(\"SHOWALL - POPIP\\n\");",
"\t",
"\tthis.kname.el.grab_focus();",
"\tthis.buttonbar.el.hide();",
"\tif (this.is_new) {",
"\t\tthis.buttonbar.el.show();",
"\t}",
"\tthis.error.setError(\"\");",
"\tthis.el.show();",
"\t//this.success = c.success;",
" ",
"}"
],
"| void updateProp" : [
"() {",
" \tGLib.debug(\"updateProp called\");",
"",
"\t",
"\t",
"\t_this.prop.name = this.kname.el.get_text().strip();",
"\t_this.prop.ptype = this.ptype.getValue();",
"\t_this.prop.rtype = this.ktype.el.get_text().strip();",
"\t",
"\t ",
"}",
""
]
}
],
"name" : "PopoverProperty"
}