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 "bool show_title_buttons" : false,
34 "* prop" : "title_widget",
36 "string label" : "Add / Edit property",
44 "bool show_row_separators" : true,
45 "bool show_separators" : true,
55 "* ctor" : "new GLib.ListStore(typeof(JsRender.NodeProp));",
60 "\tthis.el.append( new JsRender.NodeProp.prop(\"\"));",
61 "\tthis.el.append( new JsRender.NodeProp.raw(\"\"));",
62 "\tthis.el.append( new JsRender.NodeProp.valamethod(\"\"));",
63 "\tthis.el.append( new JsRender.NodeProp.special(\"\"));\t",
64 "\tthis.el.append( new JsRender.NodeProp.listener(\"\"));\t\t",
65 "\tthis.el.append( new JsRender.NodeProp.user(\"\"));\t",
66 "\tthis.el.append( new JsRender.NodeProp.sig(\"\"));\t",
77 "xtype" : "SingleSelection"
81 "* pack" : "append_column",
90 " \tvar lbl = (Gtk.Label) ((Gtk.ListItem)listitem).get_child(); ",
91 " \tvar np = (JsRender.NodeProp)((Gtk.ListItem)listitem).get_item();",
95 "\tlbl.label = np.ptype.to_name();",
104 "\tvar label = new Gtk.Label(\"\");",
105 "\tlabel.xalign = 0;",
107 "\t((Gtk.ListItem)listitem).set_child(label);",
108 "\t((Gtk.ListItem)listitem).activatable = false;",
114 "xtype" : "SignalListItemFactory"
117 "string title" : "Property Type",
118 "xtype" : "ColumnViewColumn"
121 "xtype" : "ColumnView",
122 "| JsRender.NodePropType getValue" : [
125 "\tvar li = (JsRender.NodeProp) _this.pmodel.el.get_item(",
126 "\t\t_this.pselmodel.el.get_selected()",
128 "\treturn li.ptype;",
132 "| void setValue" : [
133 "(JsRender.NodePropType pt) ",
135 " \tfor (var i = 0; i < _this.pmodel.el.n_items; i++) {",
136 "\t \tvar li = (JsRender.NodeProp) _this.pmodel.el.get_item(i);",
137 " \t\tif (li.ptype == pt) {",
138 " \t\t\t_this.pselmodel.el.set_selected(i);",
142 "\tGLib.debug(\"failed to set selected ptype\");",
143 "\t_this.pselmodel.el.set_selected(0);",
150 "Gtk.Align halign" : "Gtk.Align.START",
151 "Gtk.Justification justify" : "Gtk.Justification.LEFT",
152 "int margin_top" : 12,
153 "label" : "Type or Return Type",
166 "Gtk.Align halign" : "Gtk.Align.START",
167 "Gtk.Justification justify" : "Gtk.Justification.LEFT",
168 "int margin_top" : 12,
170 "tooltip_text" : "center, north, south, east, west",
185 " _this.error.setError(\"\");",
186 "\tvar val = _this.kname.el.get_text().strip(); ",
187 "\tif (val.length < 1) {",
188 "\t\t_this.error.setError(\"Name can not be empty\");",
195 "xtype" : "EventControllerFocus"
201 "(keyval, keycode, state) => {",
203 " _this.error.setError(\"\");",
204 "\tvar val = _this.kname.el.get_text().strip(); ",
205 "\tif (val.length < 1) {",
206 "\t\t_this.error.setError(\"Name can not be empty\");",
213 "xtype" : "EventControllerKey"
221 "Gtk.Align halign" : "Gtk.Align.START",
222 "Gtk.Justification justify" : "Gtk.Justification.LEFT",
223 "bool use_markup" : true,
225 "int margin_top" : 0,
226 "label" : "<span color=\"red\">Error Message</span>",
227 "tooltip_text" : "center, north, south, east, west",
230 "| void setError" : [
232 "\tif (err == \"\") {",
233 "\t\tthis.el.label = \"\";",
237 "\t\tthis.el.label = \"<span color=\\\"red\\\">\" + err + \"</span>\";",
245 "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
247 "int margin_top" : 20,
251 "bool always_show_image" : true,
252 "bool hexpand" : true,
256 "\t_this.prop = null;",
257 "\t_this.is_new = false;",
258 "\t_this.kname.el.set_text(\"Cancel\");",
259 "\t_this.el.hide();",
264 "string label" : "Cancel",
269 "bool always_show_image" : true,
270 "bool hexpand" : true,
274 "\t// check if text is not empty..",
275 "\tif ( _this.kname.el.get_text().strip().length < 1) {",
277 "\t\t// error should already be showing?",
281 "\t// since we can't add listeners?!?!?",
282 "\t// only check props.",
283 "\t// check if property already exists in node.\t",
286 "\tvar prop = new JsRender.NodeProp(",
287 "\t\t_this.kname.el.get_text().strip(),",
288 "\t\t_this.ptype.getValue(),",
289 "\t\t_this.ktype.el.get_text().strip(),",
290 "\t\t_this.prop.val",
293 "\tif (_this.node.props.has_key(prop.to_index_key())) {",
294 "\t\t_this.error.setError(\"Property already exists\");",
300 "\t_this.node.add_prop(prop);",
302 "\t_this.prop = null; // skip checks..",
303 "\t_this.is_new = false;",
304 "\t_this.el.hide();",
305 " \t_this.mainwindow.windowstate.left_props.changed();",
306 "\t_this.mainwindow.windowstate.left_props.view.editProp(prop);",
313 "string label" : "Add Property",
327 " \tGLib.debug(\"popover closed\");",
328 "\tif (_this.is_new) {",
329 "\t\t// dont allow hiding if we are creating a new one.",
330 "\t\t// on.hide will reshow it.",
333 "\tif (_this.prop == null) {",
334 "\t\t// hide and dont update.",
337 "\tif (this.kname.el.get_text().strip().length < 1) {",
344 " \tthis.updateProp();",
354 " \tGLib.debug(\"popover hidden\");",
355 "\tif (_this.is_new || this.kname.el.get_text().strip().length < 1) {",
356 "\t\t// dont allow hiding if we are creating a new one.",
357 "\t\tGLib.debug(\"prevent hiding as its new or text is empty\"); ",
358 "\t\tthis.el.show();",
362 "\tif (this.original_prop != null && !this.prop.equals(this.original_prop)) {",
363 "\t\t// this is convoluted..",
364 "\t\t_this.mainwindow.windowstate.left_props.changed(); ",
374 "\tGtk.Widget btn, ",
375 "\tJsRender.Node node, ",
376 "\tJsRender.NodeProp prop, ",
378 "\tbool is_new = false",
382 " this.original_prop = prop.dupe();",
383 "\tthis.is_new = is_new; ",
384 "\tvar pref = is_new ? \"Add \" : \"Modify \";",
385 "\tif (prop.ptype == JsRender.NodePropType.LISTENER) {",
386 "\t\tthis.headertitle.el.label = pref + \"Event Listener\"; // cant really happen yet?",
388 "\t\tthis.headertitle.el.label = pref + \"Property\";",
390 "\tthis.prop = prop;",
391 "\tthis.node = node;",
393 "\t_this.kname.el.set_text(prop.name);",
394 "\t_this.ktype.el.set_text(prop.rtype);",
396 " \t_this.ptype.setValue(prop.ptype);",
397 "\t// does node have this property...",
400 "\t_this.node = node;",
401 "\t//console.log('show all');",
403 "\tGLib.debug(\"set parent = %s\", btn.get_type().name());",
404 "\tvar par = btn.get_parent();",
406 "\tif (par == null) {",
407 "\t\tGLib.debug(\"parent of that is null - not showing\");",
410 "\tif (this.el.parent == null) {",
411 "\t\tthis.el.set_parent(btn);",
413 "\tvar r = Gdk.Rectangle() {",
414 "\t\t\tx = btn.get_width(), // align left...",
419 "\t//Gtk.Allocation rect;",
420 "\t//btn.get_allocation(out rect);",
421 " this.el.set_pointing_to(r);",
427 "\t\t r = Gdk.Rectangle() {",
428 "\t\t\tx = btn.get_width(), // align left...",
433 "\t\tthis.el.set_pointing_to( r);",
438 "\t//this.el.set_position(Gtk.PositionType.TOP);",
440 "\t// window + header?",
441 "\t GLib.debug(\"SHOWALL - POPIP\\n\");",
443 "\tthis.kname.el.grab_focus();",
444 "\tthis.buttonbar.el.hide();",
445 "\tif (this.is_new) {",
446 "\t\tthis.buttonbar.el.show();",
448 "\tthis.error.setError(\"\");",
450 "\t//this.success = c.success;",
454 "| void updateProp" : [
456 " \tGLib.debug(\"updateProp called\");",
460 "\t_this.prop.name = this.kname.el.get_text().strip();",
461 "\t_this.prop.ptype = this.ptype.getValue();",
462 "\t_this.prop.rtype = this.ktype.el.get_text().strip();",
470 "name" : "PopoverProperty"