2 "build_module" : "builder",
3 "gen_extended" : false,
6 "# Gtk.PositionType position" : "Gtk.PositionType.RIGHT",
7 "# JsRender.Node node" : "",
8 "# JsRender.NodeProp? original_prop" : "null",
9 "# JsRender.NodeProp? prop" : "null",
10 "# Xcls_MainWindow mainwindow" : "null",
11 "# string key_type" : "",
12 "# string old_keyname" : "",
14 "* ctor" : "new Gtk.Popover()",
15 "@ void success" : "(Project.Project pr, JsRender.JsRender file)",
16 "bool autohide" : true,
18 "bool is_new" : false,
19 "id" : "PopoverProperty",
23 "* pack" : "set_child",
24 "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
25 "bool homogeneous" : false,
29 "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
34 "bool always_show_image" : true,
35 "bool hexpand" : true,
40 "\t_this.prop = null;",
41 "\t_this.is_new = false;",
42 "\t_this.kname.el.set_text(\"Cancel\");",
48 "string label" : "Cancel",
53 "bool hexpand" : true,
55 "string label" : "Add / Edit property",
60 "bool always_show_image" : true,
61 "bool hexpand" : true,
66 "\tif (!_this.is_new) {",
67 "\t\t_this.el.hide();",
70 "\t// check if text is not empty..",
71 "\tif ( _this.kname.el.get_text().strip().length < 1) {",
73 "\t\t// error should already be showing?",
77 "\t// since we can't add listeners?!?!?",
78 "\t// only check props.",
79 "\t// check if property already exists in node.\t",
82 "\tvar prop = new JsRender.NodeProp(",
83 "\t\t_this.kname.el.get_text().strip(),",
84 "\t\t_this.ptype.getValue(),",
85 "\t\t_this.ktype.el.get_text().strip(),",
89 "\tif (_this.node.props.has_key(prop.to_index_key())) {",
90 "\t\t_this.error.setError(\"Property already exists\");",
96 "\t_this.node.add_prop(prop);",
98 "\t_this.prop = null; // skip checks..",
99 "\t_this.is_new = false;",
100 "\t_this.el.hide();",
101 " \t_this.mainwindow.windowstate.left_props.changed();",
102 "\t_this.mainwindow.windowstate.left_props.view.editProp(prop);",
109 "string label" : "Add Property",
118 "Gtk.Align halign" : "Gtk.Align.START",
119 "Gtk.Justification justify" : "Gtk.Justification.LEFT",
120 "int margin_top" : 12,
121 "label" : "Property Type (eg. property or method)",
127 "bool show_arrow" : true,
131 "$ strings" : "JsRender.NodePropType.get_pulldown_list()",
134 "xtype" : "StringList"
138 "notify[\"selected\"]" : [
141 "\t_this.el.grab_focus(); // stop prevent autohide breaking.",
145 "xtype" : "DropDown",
146 "| JsRender.NodePropType getValue" : [
148 "\tvar sl = this.el.model as Gtk.StringList;",
149 "\tvar str = sl.get_string(this.el.selected);",
150 "\treturn JsRender.NodePropType.nameToType(str);",
153 "| void setValue" : [
154 "(JsRender.NodePropType ty) {",
155 "\tvar str = ty.to_name();",
156 "\tvar sl = this.el.model as Gtk.StringList;",
157 "\tfor(var i = 0; i < sl.get_n_items(); i++) {",
158 "\t\tif(sl.get_string(i) == str) {",
159 "\t\t\tthis.el.set_selected(i);",
170 "Gtk.Align halign" : "Gtk.Align.START",
171 "Gtk.Justification justify" : "Gtk.Justification.LEFT",
172 "int margin_top" : 12,
173 "label" : "Type or Return Type",
186 "Gtk.Align halign" : "Gtk.Align.START",
187 "Gtk.Justification justify" : "Gtk.Justification.LEFT",
188 "int margin_top" : 12,
190 "tooltip_text" : "center, north, south, east, west",
205 " _this.error.setError(\"\");",
206 "\tvar val = _this.kname.el.get_text().strip(); ",
207 "\tif (val.length < 1) {",
208 "\t\t_this.error.setError(\"Name can not be empty\");",
215 "xtype" : "EventControllerFocus"
221 "(keyval, keycode, state) => {",
223 " _this.error.setError(\"\");",
224 "\tvar val = _this.kname.el.get_text().strip(); ",
225 "\tif (val.length < 1) {",
226 "\t\t_this.error.setError(\"Name can not be empty\");",
233 "xtype" : "EventControllerKey"
241 "Gtk.Align halign" : "Gtk.Align.START",
242 "Gtk.Justification justify" : "Gtk.Justification.LEFT",
243 "bool use_markup" : true,
245 "int margin_top" : 0,
246 "label" : "<span color=\"red\">Error Message</span>",
247 "tooltip_text" : "center, north, south, east, west",
250 "| void setError" : [
252 "\tif (err == \"\") {",
253 "\t\tthis.el.label = \"\";",
257 "\t\tthis.el.label = \"<span color=\\\"red\\\">\" + err + \"</span>\";",
271 " \tGLib.debug(\"popover closed\");",
272 "\tif (_this.is_new) {",
273 "\t\t// dont allow hiding if we are creating a new one.",
274 "\t\t// on.hide will reshow it.",
277 "\tif (_this.prop == null) {",
278 "\t\t// hide and dont update.",
281 "\tif (this.kname.el.get_text().strip().length < 1) {",
288 " \tthis.updateProp();",
298 " \tGLib.debug(\"popover hidden\");",
299 "\tif (_this.is_new || this.kname.el.get_text().strip().length < 1) {",
300 "\t\t// dont allow hiding if we are creating a new one.",
301 "\t\tGLib.debug(\"prevent hiding as its new or text is empty\"); ",
302 "\t\tthis.el.show();",
306 "\tif (this.original_prop != null && !this.prop.equals(this.original_prop)) {",
307 "\t\t// this is convoluted..",
308 "\t\t_this.mainwindow.windowstate.left_props.changed(); ",
318 "\tGtk.Widget btn, ",
319 "\tJsRender.Node node, ",
320 "\tJsRender.NodeProp prop, ",
322 "\tbool is_new = false",
326 " this.original_prop = prop.dupe();",
327 "\tthis.is_new = is_new; ",
328 "\tvar pref = is_new ? \"Add \" : \"Modify \";",
329 "\tif (prop.ptype == JsRender.NodePropType.LISTENER) {",
330 "\t\tthis.headertitle.el.label = pref + \"Event Listener\"; // cant really happen yet?",
332 "\t\tthis.headertitle.el.label = pref + \"Property\";",
334 "\tthis.prop = prop;",
335 "\tthis.node = node;",
337 "\t_this.kname.el.set_text(prop.name);",
338 "\t_this.ktype.el.set_text(prop.rtype);",
340 " \t_this.ptype.setValue(prop.ptype);",
341 "\t// does node have this property...",
344 "\t_this.node = node;",
345 "\t//console.log('show all');",
347 "\tGLib.debug(\"set parent = %s\", btn.get_type().name());",
348 "\tvar par = btn.get_parent();",
350 "\tif (par == null) {",
351 "\t\tGLib.debug(\"parent of that is null - not showing\");",
354 "\tif (this.el.parent == null) {",
355 "\t\tthis.el.set_parent(btn);",
357 "\tvar r = Gdk.Rectangle() {",
358 "\t\t\tx = btn.get_width(), // align left...",
363 "\t//Gtk.Allocation rect;",
364 "\t//btn.get_allocation(out rect);",
365 " this.el.set_pointing_to(r);",
371 "\t\t r = Gdk.Rectangle() {",
372 "\t\t\tx = btn.get_width(), // align left...",
377 "\t\tthis.el.set_pointing_to( r);",
382 "\t//this.el.set_position(Gtk.PositionType.TOP);",
384 "\t// window + header?",
385 "\t GLib.debug(\"SHOWALL - POPIP\\n\");",
387 "\tthis.kname.el.grab_focus();",
388 "\tthis.savebtn.el.set_label(\"Save\");",
389 "\tthis.cancelbtn.el.visible = false;",
390 "\tif (this.is_new) {",
391 "\t\tthis.savebtn.el.set_label(\"Add Property\");",
392 "\t\tthis.cancelbtn.el.visible = true;",
394 "\tthis.error.setError(\"\");",
396 "\t//this.success = c.success;",
400 "| void updateProp" : [
402 " \tGLib.debug(\"updateProp called\");",
406 "\t_this.prop.name = this.kname.el.get_text().strip();",
407 "\t_this.prop.ptype = this.ptype.getValue();",
408 "\t_this.prop.rtype = this.ktype.el.get_text().strip();",
416 "name" : "PopoverProperty"