"items" : [
{
"$ xns" : "Gtk",
- "bool show_title_buttons" : false,
+ "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
"id" : "header",
"items" : [
{
"$ xns" : "Gtk",
- "* prop" : "title_widget",
+ "bool always_show_image" : true,
+ "bool hexpand" : true,
+ "id" : "cancelbtn",
+ "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 hexpand" : true,
"id" : "headertitle",
"string label" : "Add / Edit property",
"xtype" : "Label"
+ },
+ {
+ "$ xns" : "Gtk",
+ "bool always_show_image" : true,
+ "bool hexpand" : true,
+ "id" : "savebtn",
+ "listeners" : {
+ "clicked" : [
+ "() => {",
+ "\tif (!_this.is_new) {",
+ "\t\t_this.el.hide();",
+ "\t}",
+ "\t",
+ "\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.changed();",
+ "\t_this.mainwindow.windowstate.left_props.view.editProp(prop);",
+ "",
+ "\t",
+ "\t",
+ "}"
+ ]
+ },
+ "string label" : "Add Property",
+ "xtype" : "Button"
}
],
- "xtype" : "HeaderBar"
+ "xtype" : "Box"
+ },
+ {
+ "$ visible" : true,
+ "$ xns" : "Gtk",
+ "Gtk.Align halign" : "Gtk.Align.START",
+ "Gtk.Justification justify" : "Gtk.Justification.LEFT",
+ "int margin_top" : 12,
+ "label" : "Property Type (eg. property or method)",
+ "x_options" : 4,
+ "xtype" : "Label"
},
{
"$ xns" : "Gtk",
- "bool show_row_separators" : true,
- "bool show_separators" : true,
+ "bool show_arrow" : true,
"id" : "ptype",
"items" : [
{
+ "$ strings" : "JsRender.NodePropType.get_pulldown_list()",
"$ 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" : "StringList"
}
],
- "xtype" : "ColumnView",
+ "listeners" : {
+ "notify[\"selected\"]" : [
+ "() => {",
+ "",
+ "\t_this.el.grab_focus(); // stop prevent autohide breaking.",
+ " }"
+ ]
+ },
+ "xtype" : "DropDown",
"| 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;",
- "",
+ "\tvar sl = this.el.model as Gtk.StringList;",
+ "\tvar str = sl.get_string(this.el.selected);",
+ "\treturn JsRender.NodePropType.nameToType(str);",
"}"
],
"| 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;",
+ "(JsRender.NodePropType ty) {",
+ "\tvar str = ty.to_name();",
+ "\tvar sl = this.el.model as Gtk.StringList;",
+ "\tfor(var i = 0; i < sl.get_n_items(); i++) {",
+ "\t\tif(sl.get_string(i) == str) {",
+ "\t\t\tthis.el.set_selected(i);",
+ "\t\t\tbreak;",
"\t\t}",
"\t}",
- "\tGLib.debug(\"failed to set selected ptype\");",
- "\t_this.pselmodel.el.set_selected(0);",
+ "\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.changed();",
- "\t_this.mainwindow.windowstate.left_props.view.editProp(prop);",
- "",
- "\t",
- "\t",
- "}"
- ]
- },
- "string label" : "Add Property",
- "xtype" : "Button"
- }
- ],
- "xtype" : "Box"
}
],
"xtype" : "Box"
"\t GLib.debug(\"SHOWALL - POPIP\\n\");",
"\t",
"\tthis.kname.el.grab_focus();",
- "\tthis.buttonbar.el.hide();",
+ "\tthis.savebtn.el.set_label(\"Save\");",
+ "\tthis.cancelbtn.el.visible = false;",
"\tif (this.is_new) {",
- "\t\tthis.buttonbar.el.show();",
+ "\t\tthis.savebtn.el.set_label(\"Add Property\");",
+ "\t\tthis.cancelbtn.el.visible = true;",
"\t}",
"\tthis.error.setError(\"\");",
"\tthis.el.show();",