1 static Xcls_LeftProps _LeftProps;
3 public class Xcls_LeftProps : Object
6 private Xcls_LeftProps _this;
8 public static Xcls_LeftProps singleton()
10 if (_LeftProps == null) {
11 _LeftProps= new Xcls_LeftProps();
15 public Xcls_addpop addpop;
16 public Xcls_EditProps EditProps;
17 public Xcls_view view;
18 public Xcls_deletemenu deletemenu;
19 public Xcls_selmodel selmodel;
20 public Xcls_model model;
21 public Xcls_keycol keycol;
22 public Xcls_valcol valcol;
23 public Xcls_ContextMenu ContextMenu;
27 public bool allow_edit;
28 public signal void show_add_props (string type);
29 public signal bool stop_editor ();
30 public Xcls_MainWindow main_window;
31 public int last_error_counter;
32 public signal void changed ();
33 public JsRender.JsRender file;
34 public JsRender.Node node;
35 public signal void show_editor (JsRender.JsRender file, JsRender.Node node, JsRender.NodeProp prop);
38 public Xcls_LeftProps()
41 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
45 this.allow_edit = false;
46 this.main_window = null;
47 this.last_error_counter = -1;
50 this.el.homogeneous = false ;
51 this.el.hexpand = true;
52 this.el.vexpand = true;
53 var child_1 = new Xcls_Box2( _this );
55 this.el.append( child_1.el );
56 new Xcls_EditProps( _this );
57 this.el.append( _this.EditProps.el );
60 // user defined functions
61 public string keySortFormat (string key) {
62 // listeners first - with 0
69 var bits = key.split(" ");
72 return "2 " + bits[bits.length -1];
76 return "3 " + bits[bits.length -1];
81 return "4 " + bits[bits.length -1];
84 return "5 " + bits[bits.length -1];
89 public void updateErrors () {
91 var ar = file.getErrors();
94 this.last_error_counter = file.error_counter ;
98 if (this.last_error_counter == file.error_counter) {
103 foreach(var diag in ar) {
106 // print("get inter\n");
107 var node= file.lineToNode( (int)diag.range.start.line) ;
108 if (node == null || node.oid != this.node.oid) {
111 var prop = node.lineToProp( (int)diag.range.start.line) ;
113 var row = _this.selmodel.propToRow(prop);
117 var w = this.view.getWidgetAtRow(row);
121 var ed = diag.category.down();
122 if (ed != "err" && w.has_css_class("node-err")) {
125 if (ed == "err" && w.has_css_class("node-warn")) {
126 w.remove_css_class("node-warn");
128 if (ed == "err" && w.has_css_class("node-depr")) {
129 w.remove_css_class("node-depr");
131 if (!w.has_css_class("node-"+ ed)) {
132 w.add_css_class("node-" + ed);
138 public string keyFormat (string val, string type) {
140 // Glib.markup_escape_text(val);
142 if (type == "listener") {
143 return "<span font_weight=\"bold\" color=\"#660000\">" +
144 GLib.Markup.escape_text(val) +
148 if (val.length < 1) {
149 return "<span color=\"#FF0000\">--empty--</span>";
154 //# - object properties
156 // all of these... - display value is last element..
157 var ar = val.strip().split(" ");
160 var dval = GLib.Markup.escape_text(ar[ar.length-1]);
166 case '@': // signal // just bold balck?
167 if (dval[0] == '@') {
168 dval = dval.substring(1);
171 return @"<span font_weight=\"bold\">@ $dval</span>";
172 case '#': // object properties?
173 if (dval[0] == '#') {
174 dval = dval.substring(1);
176 return @"<span font_weight=\"bold\">$dval</span>";
178 if (dval[0] == '*') {
179 dval = dval.substring(1);
181 return @"<span color=\"#0000CC\" font_weight=\"bold\">$dval</span>";
183 if (dval[0] == '$') {
184 dval = dval.substring(1);
186 return @"<span style=\"italic\">$dval</span>";
187 case '|': // user defined methods
188 if (dval[0] == '|') {
189 dval = dval.substring(1);
191 return @"<span color=\"#008000\" font_weight=\"bold\">$dval</span>";
202 public void deleteSelected () {
210 var s = this.view.el.get_selection();
211 s.get_selected(out mod, out iter);
215 mod.get_value(iter, 0 , out gval);
216 var prop = (JsRender.NodeProp)gval;
218 this.load(this.file, this.node);
221 // stop editor after fetching property - otherwise prop is null.
226 case JsRender.NodePropType.LISTENER:
227 this.node.listeners.unset(prop.to_index_key());
231 this.node.props.unset(prop.to_index_key());
234 this.load(this.file, this.node);
239 public void removeErrors () {
240 var child = this.view.el.get_first_child();
242 var reading_header = true;
244 while (child != null) {
245 GLib.debug("Got %s", child.get_type().name());
247 if (reading_header) {
250 if (child.get_type().name() != "GtkColumnListView") {
252 child = child.get_next_sibling();
255 // should be columnlistview
256 child = child.get_first_child();
260 reading_header = false;
264 if (child.has_css_class("node-err")) {
265 child.remove_css_class("node-err");
267 if (child.has_css_class("node-warn")) {
268 child.remove_css_class("node-warn");
271 if (child.has_css_class("node-depr")) {
272 child.remove_css_class("node-depr");
275 child = child.get_next_sibling();
277 //GLib.debug("Rturning null");
280 public void a_addProp (JsRender.NodeProp prop) {
281 // info includes key, val, skel, etype..
282 //console.dump(info);
283 //type = info.type.toLowerCase();
284 //var data = this.toJS();
287 if (prop.ptype == JsRender.NodePropType.LISTENER) {
288 if (this.node.listeners.has_key(prop.name)) {
291 this.node.listeners.set(prop.name,prop);
293 assert(this.node != null);
294 assert(this.node.props != null);
295 if (this.node.props.has_key(prop.to_index_key())) {
298 this.node.props.set(prop.to_index_key(),prop);
303 this.load(this.file, this.node);
308 GLib.debug("trying to find new iter");
313 public void load (JsRender.JsRender file, JsRender.Node? node)
315 // not sure when to initialize this - we should do it on setting main window really.
318 if (this.view.popover == null) {
319 this.view.popover = new Xcls_PopoverProperty();
320 this.view.popover.mainwindow = _this.main_window;
324 if (this.node != null) {
325 this.node.dupeProps(); // ensures removeall will not do somethign silly
329 GLib.debug("load leftprops\n");
335 this.model.el.remove_all();
337 //this.get('/RightEditor').el.hide();
341 node.loadProps(this.model.el);
344 //GLib.debug("clear selection\n");
346 this.loading = false;
347 this.selmodel.el.set_selected(Gtk.INVALID_LIST_POSITION);
350 //this.model.el.set_sort_column_id(4,Gtk.SortType.ASCENDING); // sort by real key..
352 // this.view.el.get_selection().unselect_all();
354 // _this.keycol.el.set_max_width(_this.EditProps.el.get_allocated_width()/ 2);
355 // _this.valcol.el.set_max_width(_this.EditProps.el.get_allocated_width()/ 2);
358 public class Xcls_Box2 : Object
361 private Xcls_LeftProps _this;
367 public Xcls_Box2(Xcls_LeftProps _owner )
370 this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
374 // set gobject values
375 this.el.hexpand = true;
376 var child_1 = new Xcls_Label3( _this );
378 this.el.append( child_1.el );
379 var child_2 = new Xcls_Button4( _this );
381 this.el.append( child_2.el );
382 var child_3 = new Xcls_Button5( _this );
384 this.el.append( child_3.el );
385 var child_4 = new Xcls_MenuButton6( _this );
387 this.el.append( child_4.el );
390 // user defined functions
392 public class Xcls_Label3 : Object
395 private Xcls_LeftProps _this;
401 public Xcls_Label3(Xcls_LeftProps _owner )
404 this.el = new Gtk.Label( "Add:" );
408 // set gobject values
409 this.el.margin_end = 5;
410 this.el.margin_start = 5;
413 // user defined functions
416 public class Xcls_Button4 : Object
418 public Gtk.Button el;
419 private Xcls_LeftProps _this;
423 public bool always_show_image;
426 public Xcls_Button4(Xcls_LeftProps _owner )
429 this.el = new Gtk.Button();
432 this.always_show_image = true;
434 // set gobject values
435 this.el.icon_name = "format-justify-left";
436 this.el.hexpand = true;
437 this.el.tooltip_text = "Add Property";
438 this.el.label = "Property";
441 this.el.clicked.connect( ( ) => {
443 _this.main_window.windowstate.showProps(
445 JsRender.NodePropType.PROP
451 // user defined functions
454 public class Xcls_Button5 : Object
456 public Gtk.Button el;
457 private Xcls_LeftProps _this;
461 public bool always_show_image;
464 public Xcls_Button5(Xcls_LeftProps _owner )
467 this.el = new Gtk.Button();
470 this.always_show_image = true;
472 // set gobject values
473 this.el.icon_name = "appointment-new";
474 this.el.hexpand = true;
475 this.el.tooltip_text = "Add Event Code";
476 this.el.label = "Event";
479 this.el.clicked.connect( ( ) => {
482 _this.main_window.windowstate.showProps(
484 JsRender.NodePropType.LISTENER
491 // user defined functions
494 public class Xcls_MenuButton6 : Object
496 public Gtk.MenuButton el;
497 private Xcls_LeftProps _this;
503 public Xcls_MenuButton6(Xcls_LeftProps _owner )
506 this.el = new Gtk.MenuButton();
510 // set gobject values
511 this.el.label = "Other";
512 new Xcls_addpop( _this );
513 this.el.popover = _this.addpop.el;
516 // user defined functions
518 public class Xcls_addpop : Object
520 public Gtk.Popover el;
521 private Xcls_LeftProps _this;
527 public Xcls_addpop(Xcls_LeftProps _owner )
531 this.el = new Gtk.Popover();
535 // set gobject values
536 var child_1 = new Xcls_Box8( _this );
537 this.el.child = child_1.el;
540 // user defined functions
542 public class Xcls_Box8 : Object
545 private Xcls_LeftProps _this;
551 public Xcls_Box8(Xcls_LeftProps _owner )
554 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
558 // set gobject values
559 var child_1 = new Xcls_Button9( _this );
561 this.el.append( child_1.el );
562 var child_2 = new Xcls_Button11( _this );
564 this.el.append( child_2.el );
565 var child_3 = new Xcls_Button13( _this );
567 this.el.append( child_3.el );
568 var child_4 = new Xcls_Button15( _this );
570 this.el.append( child_4.el );
571 var child_5 = new Xcls_Button17( _this );
573 this.el.append( child_5.el );
574 var child_6 = new Xcls_Separator19( _this );
576 this.el.append( child_6.el );
577 var child_7 = new Xcls_Button20( _this );
579 this.el.append( child_7.el );
580 var child_8 = new Xcls_Button22( _this );
582 this.el.append( child_8.el );
583 var child_9 = new Xcls_Button24( _this );
585 this.el.append( child_9.el );
586 var child_10 = new Xcls_Separator26( _this );
588 this.el.append( child_10.el );
589 var child_11 = new Xcls_Button27( _this );
591 this.el.append( child_11.el );
592 var child_12 = new Xcls_Button29( _this );
594 this.el.append( child_12.el );
595 var child_13 = new Xcls_Button31( _this );
597 this.el.append( child_13.el );
598 var child_14 = new Xcls_Separator33( _this );
600 this.el.append( child_14.el );
601 var child_15 = new Xcls_Button34( _this );
603 this.el.append( child_15.el );
604 var child_16 = new Xcls_Button36( _this );
606 this.el.append( child_16.el );
607 var child_17 = new Xcls_Button38( _this );
609 this.el.append( child_17.el );
612 // user defined functions
614 public class Xcls_Button9 : Object
616 public Gtk.Button el;
617 private Xcls_LeftProps _this;
623 public Xcls_Button9(Xcls_LeftProps _owner )
626 this.el = new Gtk.Button();
630 // set gobject values
631 this.el.has_frame = false;
632 var child_1 = new Xcls_Label10( _this );
633 this.el.child = child_1.el;
636 this.el.clicked.connect( () => {
637 _this.addpop.el.hide();
638 // is this userdef or special??
639 var add = new JsRender.NodeProp.prop("id");
640 if (_this.node.has_prop_key(add)) {
644 _this.node.add_prop( add );
646 _this.view.editProp( add );
651 // user defined functions
653 public class Xcls_Label10 : Object
656 private Xcls_LeftProps _this;
662 public Xcls_Label10(Xcls_LeftProps _owner )
665 this.el = new Gtk.Label( "id: _this.{ID} (Vala)" );
669 // set gobject values
670 this.el.halign = Gtk.Align.START;
671 this.el.tooltip_text = "Using _this.{ID} will map to this element";
674 // user defined functions
678 public class Xcls_Button11 : Object
680 public Gtk.Button el;
681 private Xcls_LeftProps _this;
687 public Xcls_Button11(Xcls_LeftProps _owner )
690 this.el = new Gtk.Button();
694 // set gobject values
695 this.el.has_frame = false;
696 var child_1 = new Xcls_Label12( _this );
697 this.el.child = child_1.el;
700 this.el.clicked.connect( ( ) => {
703 _this.addpop.el.hide();
704 // is this userdef or special??
705 var add = new JsRender.NodeProp.special("pack", "add");
706 if (_this.node.has_prop_key(add)) {
710 _this.node.add_prop( add );
712 _this.view.editProp( add );
718 // user defined functions
720 public class Xcls_Label12 : Object
723 private Xcls_LeftProps _this;
729 public Xcls_Label12(Xcls_LeftProps _owner )
732 this.el = new Gtk.Label( "pack: Pack method (Vala)" );
736 // set gobject values
737 this.el.halign = Gtk.Align.START;
738 this.el.tooltip_text = "how to pack this element onto parent, (method, 2nd arg, 3rd arg) .. the 1st argument is filled by the element";
741 // user defined functions
745 public class Xcls_Button13 : Object
747 public Gtk.Button el;
748 private Xcls_LeftProps _this;
754 public Xcls_Button13(Xcls_LeftProps _owner )
757 this.el = new Gtk.Button();
761 // set gobject values
762 this.el.has_frame = false;
763 var child_1 = new Xcls_Label14( _this );
764 this.el.child = child_1.el;
767 this.el.clicked.connect( ( ) => {
769 _this.addpop.el.hide();
770 // is this userdef or special??
771 var add = new JsRender.NodeProp.special("ctor");
772 if (_this.node.has_prop_key(add)) {
776 _this.node.add_prop( add );
778 _this.view.editProp( add );
783 // user defined functions
785 public class Xcls_Label14 : Object
788 private Xcls_LeftProps _this;
794 public Xcls_Label14(Xcls_LeftProps _owner )
797 this.el = new Gtk.Label( "ctor: Alterative to default contructor (Vala)" );
801 // set gobject values
802 this.el.halign = Gtk.Align.START;
803 this.el.tooltip_text = "eg. \n\nnew Clutter.Image.from_file(.....)";
806 // user defined functions
810 public class Xcls_Button15 : Object
812 public Gtk.Button el;
813 private Xcls_LeftProps _this;
819 public Xcls_Button15(Xcls_LeftProps _owner )
822 this.el = new Gtk.Button();
826 // set gobject values
827 this.el.has_frame = false;
828 var child_1 = new Xcls_Label16( _this );
829 this.el.child = child_1.el;
832 this.el.clicked.connect( ( ) => {
834 _this.addpop.el.hide();
835 // is this userdef or special??
836 var add = new JsRender.NodeProp.special("init","{\n\n}\n" ) ;
837 if (_this.node.has_prop_key(add)) {
841 _this.node.add_prop( add );
843 _this.view.editProp( add );
847 // user defined functions
849 public class Xcls_Label16 : Object
852 private Xcls_LeftProps _this;
858 public Xcls_Label16(Xcls_LeftProps _owner )
861 this.el = new Gtk.Label( "init: initialziation code (vala)" );
865 // set gobject values
866 this.el.halign = Gtk.Align.START;
867 this.el.tooltip_text = "This code is called after the ctor";
870 // user defined functions
874 public class Xcls_Button17 : Object
876 public Gtk.Button el;
877 private Xcls_LeftProps _this;
883 public Xcls_Button17(Xcls_LeftProps _owner )
886 this.el = new Gtk.Button();
890 // set gobject values
891 this.el.has_frame = false;
892 var child_1 = new Xcls_Label18( _this );
893 this.el.child = child_1.el;
896 this.el.clicked.connect( () => {
897 _this.addpop.el.hide();
899 // is this userdef or special??
900 var add = new JsRender.NodeProp.prop("cms-id","string", "" ) ;
901 if (_this.node.has_prop_key(add)) {
905 _this.node.add_prop( add );
907 _this.view.editProp( add );
912 // user defined functions
914 public class Xcls_Label18 : Object
917 private Xcls_LeftProps _this;
923 public Xcls_Label18(Xcls_LeftProps _owner )
926 this.el = new Gtk.Label( "cms-id: (Roo JS/Pman library)" );
930 // set gobject values
931 this.el.halign = Gtk.Align.START;
932 this.el.tooltip_text = "set the cms-id for this element, when converted to javascript, the html value will be wrapped with Pman.Cms.content({cms-id},{original-html})\n";
935 // user defined functions
939 public class Xcls_Separator19 : Object
941 public Gtk.Separator el;
942 private Xcls_LeftProps _this;
948 public Xcls_Separator19(Xcls_LeftProps _owner )
951 this.el = new Gtk.Separator( Gtk.Orientation.HORIZONTAL );
955 // set gobject values
958 // user defined functions
961 public class Xcls_Button20 : Object
963 public Gtk.Button el;
964 private Xcls_LeftProps _this;
970 public Xcls_Button20(Xcls_LeftProps _owner )
973 this.el = new Gtk.Button();
977 // set gobject values
978 this.el.has_frame = false;
979 var child_1 = new Xcls_Label21( _this );
980 this.el.child = child_1.el;
983 this.el.clicked.connect( (self) => {
984 _this.addpop.el.hide();
985 _this.view.popover.show(
988 new JsRender.NodeProp.prop("", "string", "") ,
996 // user defined functions
998 public class Xcls_Label21 : Object
1000 public Gtk.Label el;
1001 private Xcls_LeftProps _this;
1007 public Xcls_Label21(Xcls_LeftProps _owner )
1010 this.el = new Gtk.Label( "String" );
1014 // set gobject values
1015 this.el.halign = Gtk.Align.START;
1016 this.el.tooltip_text = "Add a user defined string property";
1019 // user defined functions
1023 public class Xcls_Button22 : Object
1025 public Gtk.Button el;
1026 private Xcls_LeftProps _this;
1032 public Xcls_Button22(Xcls_LeftProps _owner )
1035 this.el = new Gtk.Button();
1039 // set gobject values
1040 this.el.has_frame = false;
1041 var child_1 = new Xcls_Label23( _this );
1042 this.el.child = child_1.el;
1045 this.el.clicked.connect( ( ) =>{
1047 _this.addpop.el.hide();
1048 _this.view.popover.show(
1051 new JsRender.NodeProp.prop("", "int", "0") ,
1059 // user defined functions
1061 public class Xcls_Label23 : Object
1063 public Gtk.Label el;
1064 private Xcls_LeftProps _this;
1070 public Xcls_Label23(Xcls_LeftProps _owner )
1073 this.el = new Gtk.Label( "Number" );
1077 // set gobject values
1078 this.el.halign = Gtk.Align.START;
1079 this.el.tooltip_text = "Add a user defined number property";
1082 // user defined functions
1086 public class Xcls_Button24 : Object
1088 public Gtk.Button el;
1089 private Xcls_LeftProps _this;
1095 public Xcls_Button24(Xcls_LeftProps _owner )
1098 this.el = new Gtk.Button();
1102 // set gobject values
1103 this.el.has_frame = false;
1104 var child_1 = new Xcls_Label25( _this );
1105 this.el.child = child_1.el;
1108 this.el.clicked.connect( ( ) =>{
1110 _this.addpop.el.hide();
1111 _this.view.popover.show(
1114 new JsRender.NodeProp.prop("", "bool", "true") ,
1122 // user defined functions
1124 public class Xcls_Label25 : Object
1126 public Gtk.Label el;
1127 private Xcls_LeftProps _this;
1133 public Xcls_Label25(Xcls_LeftProps _owner )
1136 this.el = new Gtk.Label( "Boolean" );
1140 // set gobject values
1141 this.el.halign = Gtk.Align.START;
1142 this.el.tooltip_text = "Add a user defined boolean property";
1145 // user defined functions
1149 public class Xcls_Separator26 : Object
1151 public Gtk.Separator el;
1152 private Xcls_LeftProps _this;
1158 public Xcls_Separator26(Xcls_LeftProps _owner )
1161 this.el = new Gtk.Separator( Gtk.Orientation.HORIZONTAL );
1165 // set gobject values
1168 // user defined functions
1171 public class Xcls_Button27 : Object
1173 public Gtk.Button el;
1174 private Xcls_LeftProps _this;
1180 public Xcls_Button27(Xcls_LeftProps _owner )
1183 this.el = new Gtk.Button();
1187 // set gobject values
1188 this.el.has_frame = false;
1189 var child_1 = new Xcls_Label28( _this );
1190 this.el.child = child_1.el;
1193 this.el.clicked.connect( ( ) =>{
1194 _this.addpop.el.hide();
1195 _this.view.popover.show(
1198 new JsRender.NodeProp.jsmethod("") ,
1207 // user defined functions
1209 public class Xcls_Label28 : Object
1211 public Gtk.Label el;
1212 private Xcls_LeftProps _this;
1218 public Xcls_Label28(Xcls_LeftProps _owner )
1221 this.el = new Gtk.Label( "Javascript Function" );
1225 // set gobject values
1226 this.el.halign = Gtk.Align.START;
1227 this.el.tooltip_text = "Add a javascript function";
1230 // user defined functions
1234 public class Xcls_Button29 : Object
1236 public Gtk.Button el;
1237 private Xcls_LeftProps _this;
1243 public Xcls_Button29(Xcls_LeftProps _owner )
1246 this.el = new Gtk.Button();
1250 // set gobject values
1251 this.el.has_frame = false;
1252 var child_1 = new Xcls_Label30( _this );
1253 this.el.child = child_1.el;
1256 this.el.clicked.connect( ( ) =>{
1257 _this.addpop.el.hide();
1258 _this.view.popover.show(
1261 new JsRender.NodeProp.valamethod("") ,
1268 // user defined functions
1270 public class Xcls_Label30 : Object
1272 public Gtk.Label el;
1273 private Xcls_LeftProps _this;
1279 public Xcls_Label30(Xcls_LeftProps _owner )
1282 this.el = new Gtk.Label( "Vala Method" );
1286 // set gobject values
1287 this.el.halign = Gtk.Align.START;
1288 this.el.tooltip_text = "Add a user defined method to a object";
1291 // user defined functions
1295 public class Xcls_Button31 : Object
1297 public Gtk.Button el;
1298 private Xcls_LeftProps _this;
1304 public Xcls_Button31(Xcls_LeftProps _owner )
1307 this.el = new Gtk.Button();
1311 // set gobject values
1312 this.el.has_frame = false;
1313 var child_1 = new Xcls_Label32( _this );
1314 this.el.child = child_1.el;
1317 this.el.clicked.connect( ( ) =>{
1318 _this.addpop.el.hide();
1319 _this.view.popover.show(
1322 new JsRender.NodeProp.sig("" ) ,
1329 // user defined functions
1331 public class Xcls_Label32 : Object
1333 public Gtk.Label el;
1334 private Xcls_LeftProps _this;
1340 public Xcls_Label32(Xcls_LeftProps _owner )
1343 this.el = new Gtk.Label( "Vala Signal" );
1347 // set gobject values
1348 this.el.halign = Gtk.Align.START;
1349 this.el.tooltip_text = "Add a user defined signal to a object";
1352 // user defined functions
1356 public class Xcls_Separator33 : Object
1358 public Gtk.Separator el;
1359 private Xcls_LeftProps _this;
1365 public Xcls_Separator33(Xcls_LeftProps _owner )
1368 this.el = new Gtk.Separator( Gtk.Orientation.HORIZONTAL );
1372 // set gobject values
1375 // user defined functions
1378 public class Xcls_Button34 : Object
1380 public Gtk.Button el;
1381 private Xcls_LeftProps _this;
1387 public Xcls_Button34(Xcls_LeftProps _owner )
1390 this.el = new Gtk.Button();
1394 // set gobject values
1395 this.el.has_frame = false;
1396 var child_1 = new Xcls_Label35( _this );
1397 this.el.child = child_1.el;
1400 this.el.clicked.connect( ( ) =>{
1401 _this.addpop.el.hide();
1402 _this.view.popover.show(
1405 new JsRender.NodeProp.prop("flexy:if", "string", "value_or_condition") ,
1414 // user defined functions
1416 public class Xcls_Label35 : Object
1418 public Gtk.Label el;
1419 private Xcls_LeftProps _this;
1425 public Xcls_Label35(Xcls_LeftProps _owner )
1428 this.el = new Gtk.Label( "Flexy - If" );
1432 // set gobject values
1433 this.el.halign = Gtk.Align.START;
1434 this.el.tooltip_text = "Add a flexy if (for HTML templates)";
1437 // user defined functions
1441 public class Xcls_Button36 : Object
1443 public Gtk.Button el;
1444 private Xcls_LeftProps _this;
1450 public Xcls_Button36(Xcls_LeftProps _owner )
1453 this.el = new Gtk.Button();
1457 // set gobject values
1458 this.el.has_frame = false;
1459 var child_1 = new Xcls_Label37( _this );
1460 this.el.child = child_1.el;
1463 this.el.clicked.connect( ( ) =>{
1464 _this.addpop.el.hide();
1465 _this.view.popover.show(
1468 new JsRender.NodeProp.prop("flexy:include", "string", "name_of_file.html") ,
1477 // user defined functions
1479 public class Xcls_Label37 : Object
1481 public Gtk.Label el;
1482 private Xcls_LeftProps _this;
1488 public Xcls_Label37(Xcls_LeftProps _owner )
1491 this.el = new Gtk.Label( "Flexy - Include" );
1495 // set gobject values
1496 this.el.halign = Gtk.Align.START;
1497 this.el.tooltip_text = "Add a flexy include (for HTML templates)";
1500 // user defined functions
1504 public class Xcls_Button38 : Object
1506 public Gtk.Button el;
1507 private Xcls_LeftProps _this;
1513 public Xcls_Button38(Xcls_LeftProps _owner )
1516 this.el = new Gtk.Button();
1520 // set gobject values
1521 this.el.has_frame = false;
1522 this.el.tooltip_markup = "Add a flexy include (for HTML templates)";
1523 var child_1 = new Xcls_Label39( _this );
1524 this.el.child = child_1.el;
1527 this.el.clicked.connect( ( ) =>{
1528 _this.addpop.el.hide();
1529 _this.view.popover.show(
1532 new JsRender.NodeProp.prop("flexy:if", "string", "value_or_condition") ,
1540 // user defined functions
1542 public class Xcls_Label39 : Object
1544 public Gtk.Label el;
1545 private Xcls_LeftProps _this;
1551 public Xcls_Label39(Xcls_LeftProps _owner )
1554 this.el = new Gtk.Label( "Flexy - Foreach" );
1558 // set gobject values
1559 this.el.halign = Gtk.Align.START;
1560 this.el.tooltip_text = "Add a flexy foreach (for HTML templates)";
1563 // user defined functions
1571 public class Xcls_EditProps : Object
1573 public Gtk.ScrolledWindow el;
1574 private Xcls_LeftProps _this;
1578 public bool editing;
1581 public Xcls_EditProps(Xcls_LeftProps _owner )
1584 _this.EditProps = this;
1585 this.el = new Gtk.ScrolledWindow();
1588 this.editing = false;
1590 // set gobject values
1591 this.el.hexpand = true;
1592 this.el.vexpand = true;
1593 new Xcls_view( _this );
1594 this.el.set_child ( _this.view.el );
1600 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
1604 // user defined functions
1606 public class Xcls_view : Object
1608 public Gtk.ColumnView el;
1609 private Xcls_LeftProps _this;
1613 public Gtk.CssProvider css;
1614 public Xcls_PopoverProperty popover;
1617 public Xcls_view(Xcls_LeftProps _owner )
1621 new Xcls_selmodel( _this );
1622 this.el = new Gtk.ColumnView( _this.selmodel.el );
1625 this.popover = null;
1627 // set gobject values
1628 this.el.name = "leftprops-view";
1629 this.el.single_click_activate = false;
1630 this.el.hexpand = true;
1631 this.el.vexpand = true;
1632 this.el.show_row_separators = true;
1633 new Xcls_deletemenu( _this );
1634 var child_3 = new Xcls_GestureClick45( _this );
1636 this.el.add_controller( child_3.el );
1637 var child_4 = new Xcls_GestureClick46( _this );
1639 this.el.add_controller( child_4.el );
1640 new Xcls_keycol( _this );
1641 this.el.append_column ( _this.keycol.el );
1642 new Xcls_valcol( _this );
1643 this.el.append_column ( _this.valcol.el );
1644 new Xcls_ContextMenu( _this );
1650 this.css = new Gtk.CssProvider();
1652 this.css.load_from_string("
1653 #leftprops-view { font-size: 12px;}
1655 #leftprops-view dropdown button {
1659 #leftprops-view cell dropdown label {
1663 #leftprops-view cell {
1667 #leftprops-view cell label, #leftprops-view cell editablelable {
1672 Gtk.StyleContext.add_provider_for_display(
1673 this.el.get_display(),
1675 Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
1682 // user defined functions
1683 public Gtk.Widget? getWidgetAtRow (uint row) {
1686 from https://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465
1687 var colview = gesture.widget;
1688 var line_no = check_list_widget(colview, x,y);
1690 var item = colview.model.get_item(line_no);
1694 GLib.debug("Get Widget At Row %d", (int)row);
1695 var child = this.el.get_first_child();
1697 var reading_header = true;
1699 while (child != null) {
1700 GLib.debug("Got %s", child.get_type().name());
1701 if (reading_header) {
1704 if (child.get_type().name() != "GtkColumnListView") {
1705 child = child.get_next_sibling();
1708 child = child.get_first_child();
1709 reading_header = false;
1712 if (child.get_type().name() != "GtkColumnViewRowWidget") {
1713 child = child.get_next_sibling();
1717 if (line_no == row) {
1718 GLib.debug("Returning widget %s", child.get_type().name());
1719 return (Gtk.Widget)child;
1721 child = child.get_next_sibling();
1723 GLib.debug("Rturning null");
1727 public void editProp (JsRender.NodeProp prop)
1729 var sm = _this.selmodel.el;
1732 GLib.debug("finding node");
1733 _this.selmodel.selectProp(prop);
1735 for (var i = 0 ; i < sm.n_items; i++) {
1736 var r = (JsRender.NodeProp)sm.get_item(i);
1737 if (r.equals(prop)) {
1743 GLib.debug("finding node - cant find it");
1747 var r = this.getWidgetAtRow(sr);
1748 GLib.debug("r = %s", r.get_type().name());
1749 var ca = r.get_first_child();
1750 var ll = (Gtk.Label)ca.get_first_child();
1751 var cb = ca.get_next_sibling();
1752 var b = cb.get_first_child();
1753 var e = (Gtk.EditableLabel) b.get_first_child();
1754 var l = (Gtk.Label) e.get_next_sibling();
1755 var d = (Gtk.DropDown) l.get_next_sibling();
1757 GLib.debug("row key = %s", ll.label);
1758 if (e.get_visible()) {
1759 _this.stop_editor();
1761 //GLib.Timeout.add_once(500, () => {
1762 // var st = (Gtk.Stack) e.get_first_child();
1763 // var ed = (Gtk.Entry) st.get_visible_child();
1764 // ed.grab_focus_without_selecting();
1768 if (d.get_visible()) {
1769 _this.stop_editor();
1773 if (l.get_visible()) {
1774 _this.stop_editor();
1775 _this.show_editor(_this.file, prop.parent, prop);
1781 //gtkcolumnviewrowwidget
1785 // entry / label / dropdown
1789 public int getColAt (double x, double y) {
1792 from https://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465
1795 //Gtk.Allocation alloc = { 0, 0, 0, 0 };
1796 var child = this.el.get_first_child();
1800 while (child != null) {
1801 GLib.debug("Got %s", child.get_type().name());
1803 if (child.get_type().name() == "GtkColumnViewRowWidget") {
1804 child = child.get_first_child();
1808 //child.get_allocation(out alloc);
1809 if (x < (child.get_width() + offx)) {
1812 offx += child.get_width();
1814 child = child.get_next_sibling();
1821 public int getRowAt (double x, double in_y, out string pos) {
1828 from https://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465
1829 var colview = gesture.widget;
1830 var line_no = check_list_widget(colview, x,y);
1832 var item = colview.model.get_item(line_no);
1838 //GLib.debug("offset = %d y = %d", (int) voff, (int) in_y);
1839 var y = in_y + _this.EditProps.el.vadjustment.value;
1840 var child = this.el.get_first_child();
1841 //Gtk.Allocation alloc = { 0, 0, 0, 0 };
1843 var reading_header = true;
1845 var header_height = 0;
1848 while (child != null) {
1849 //GLib.debug("Got %s", child.get_type().name());
1850 if (reading_header) {
1853 if (child.get_type().name() != "GtkColumnListView") {
1854 h += child.get_height();
1855 child = child.get_next_sibling();
1858 // should be columnlistview
1859 child = child.get_first_child();
1860 GLib.debug("header height=%d", h);
1863 reading_header = false;
1867 if (child.get_type().name() != "GtkColumnViewRowWidget") {
1868 child = child.get_next_sibling();
1872 if (y < header_height) {
1877 var hh = child.get_height();
1878 //child.get_allocation(out alloc);
1879 //GLib.debug("got cell xy = %d,%d w,h= %d,%d", alloc.x, alloc.y, alloc.width, alloc.height);
1880 //GLib.debug("row %d y= %d %s", line_no, (int) (header_height + alloc.y),
1882 // child.visible ? "VIS" : "hidden");
1884 if (y > (header_height + real_y) && y <= (header_height + real_y + hh) ) {
1885 if (y > ( header_height + real_y + (hh * 0.8))) {
1887 } else if (y > ( header_height + real_y + (hh * 0.2))) {
1892 GLib.debug("getRowAt return : %d, %s", line_no, pos);
1897 if (real_y + hh > y) {
1901 child = child.get_next_sibling();
1907 public class Xcls_deletemenu : Object
1909 public Gtk.Popover el;
1910 private Xcls_LeftProps _this;
1916 public Xcls_deletemenu(Xcls_LeftProps _owner )
1919 _this.deletemenu = this;
1920 this.el = new Gtk.Popover();
1924 // set gobject values
1925 var child_1 = new Xcls_Box43( _this );
1926 this.el.child = child_1.el;
1929 // user defined functions
1931 public class Xcls_Box43 : Object
1934 private Xcls_LeftProps _this;
1940 public Xcls_Box43(Xcls_LeftProps _owner )
1943 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
1947 // set gobject values
1948 var child_1 = new Xcls_Button44( _this );
1950 this.el.append( child_1.el );
1953 // user defined functions
1955 public class Xcls_Button44 : Object
1957 public Gtk.Button el;
1958 private Xcls_LeftProps _this;
1964 public Xcls_Button44(Xcls_LeftProps _owner )
1967 this.el = new Gtk.Button();
1971 // set gobject values
1972 this.el.label = "Delete";
1975 this.el.clicked.connect( ( ) => {
1978 var n = (JsRender.NodeProp) _this.selmodel.el.selected_item;
1980 _this.deletemenu.el.hide();
1981 _this.node.remove_prop(n);
1985 // user defined functions
1990 public class Xcls_GestureClick45 : Object
1992 public Gtk.GestureClick el;
1993 private Xcls_LeftProps _this;
1999 public Xcls_GestureClick45(Xcls_LeftProps _owner )
2002 this.el = new Gtk.GestureClick();
2006 // set gobject values
2009 this.el.pressed.connect( (n_press, in_x, in_y) => {
2011 GLib.debug("Prssed %d", (int) this.el.get_current_button());
2013 var col = _this.view.getColAt(in_x, in_y);
2018 var row = _this.view.getRowAt(in_x, in_y, out pos);
2024 GLib.debug("hit row %d", row);
2025 var prop = _this.selmodel.getPropAt(row);
2026 _this.selmodel.selectProp(prop);
2028 //var point_at = _this.view.getWidgetAtRow(row);
2030 // need to shift down, as ev.y does not inclucde header apparently..
2031 // or popover might be trying to do a central?
2032 // _this.view.editPropertyDetails(prop, (int) in_y + 12);
2033 _this.stop_editor();
2034 _this.view.popover.show(
2044 // user defined functions
2047 public class Xcls_GestureClick46 : Object
2049 public Gtk.GestureClick el;
2050 private Xcls_LeftProps _this;
2056 public Xcls_GestureClick46(Xcls_LeftProps _owner )
2059 this.el = new Gtk.GestureClick();
2063 // set gobject values
2067 this.el.pressed.connect( (n_press, in_x, in_y) => {
2072 var row = _this.view.getRowAt(in_x, in_y, out pos);
2079 _this.stop_editor();
2080 GLib.debug("hit row %d", row);
2081 var prop = _this.selmodel.getPropAt(row);
2082 _this.selmodel.selectProp(prop);
2086 GLib.debug("Prssed %d", (int) this.el.get_current_button());
2087 //_this.deletemenu.el.set_parent(_this.view.el);
2088 if (_this.deletemenu.el.parent == null) {
2089 _this.deletemenu.el.set_parent(_this.main_window.el);
2094 _this.deletemenu.el.set_offset(
2095 (int)in_x - _this.view.el.get_width() ,
2096 (int)in_y - _this.view.el.get_height()
2098 _this.deletemenu.el.set_position(Gtk.PositionType.BOTTOM);
2099 _this.deletemenu.el.popup();
2104 // user defined functions
2107 public class Xcls_selmodel : Object
2109 public Gtk.SingleSelection el;
2110 private Xcls_LeftProps _this;
2116 public Xcls_selmodel(Xcls_LeftProps _owner )
2119 _this.selmodel = this;
2120 new Xcls_model( _this );
2121 this.el = new Gtk.SingleSelection( _this.model.el );
2125 // set gobject values
2126 this.el.can_unselect = true;
2129 // user defined functions
2130 public int propToRow (JsRender.NodeProp prop) {
2131 for (var i = 0 ; i < this.el.n_items; i++) {
2132 var r = (JsRender.NodeProp)this.el.get_item(i);
2133 if (r.equals(prop)) {
2141 public void startEditing (JsRender.NodeProp prop) {
2142 // should we call select?? - caller does int (from windowstate)
2145 public void selectProp (JsRender.NodeProp prop) {
2146 for (var i = 0 ; i < this.el.n_items; i++) {
2147 var r = (JsRender.NodeProp)this.el.get_item(i);
2148 if (r.equals(prop)) {
2149 this.el.selected = i;
2155 public JsRender.NodeProp getPropAt (uint row) {
2157 return (JsRender.NodeProp) this.el.get_item(row);
2162 public class Xcls_model : Object
2164 public GLib.ListStore el;
2165 private Xcls_LeftProps _this;
2171 public Xcls_model(Xcls_LeftProps _owner )
2175 this.el = new GLib.ListStore(typeof(JsRender.NodeProp));
2179 // set gobject values
2182 // user defined functions
2186 public class Xcls_keycol : Object
2188 public Gtk.ColumnViewColumn el;
2189 private Xcls_LeftProps _this;
2195 public Xcls_keycol(Xcls_LeftProps _owner )
2198 _this.keycol = this;
2199 var child_1 = new Xcls_SignalListItemFactory50( _this );
2201 this.el = new Gtk.ColumnViewColumn( "Property", child_1.el );
2205 // set gobject values
2206 this.el.id = "keycol";
2207 this.el.expand = true;
2208 this.el.resizable = true;
2211 // user defined functions
2213 public class Xcls_SignalListItemFactory50 : Object
2215 public Gtk.SignalListItemFactory el;
2216 private Xcls_LeftProps _this;
2222 public Xcls_SignalListItemFactory50(Xcls_LeftProps _owner )
2225 this.el = new Gtk.SignalListItemFactory();
2229 // set gobject values
2232 this.el.setup.connect( (listitem) => {
2233 var lbl = new Gtk.Label("");
2234 ((Gtk.ListItem)listitem).set_child(lbl);
2235 lbl.justify = Gtk.Justification.LEFT;
2237 lbl.use_markup = true;
2238 lbl.ellipsize = Pango.EllipsizeMode.START;
2239 /*lbl.changed.connect(() => {
2240 // notify and save the changed value...
2241 //var prop = (JsRender.NodeProp) ((Gtk.ListItem)listitem.get_item());
2243 //prop.val = lbl.text;
2244 //_this.updateIter(iter,prop);
2248 ((Gtk.ListItem)listitem).activatable = true;
2250 this.el.bind.connect( (listitem) => {
2251 var lb = (Gtk.Label) ((Gtk.ListItem)listitem).get_child();
2252 var item = (JsRender.NodeProp) ((Gtk.ListItem)listitem).get_item();
2255 item.bind_property("to_display_name_prop",
2257 GLib.BindingFlags.SYNC_CREATE);
2258 item.bind_property("to_tooltip_name_prop",
2259 lb, "tooltip_markup",
2260 GLib.BindingFlags.SYNC_CREATE);
2261 // was item (1) in old layout
2267 // user defined functions
2271 public class Xcls_valcol : Object
2273 public Gtk.ColumnViewColumn el;
2274 private Xcls_LeftProps _this;
2280 public Xcls_valcol(Xcls_LeftProps _owner )
2283 _this.valcol = this;
2284 var child_1 = new Xcls_SignalListItemFactory52( _this );
2286 this.el = new Gtk.ColumnViewColumn( "Value", child_1.el );
2290 // set gobject values
2291 this.el.id = "valcol";
2292 this.el.expand = true;
2293 this.el.resizable = true;
2296 // user defined functions
2298 public class Xcls_SignalListItemFactory52 : Object
2300 public Gtk.SignalListItemFactory el;
2301 private Xcls_LeftProps _this;
2305 public bool is_setting;
2308 public Xcls_SignalListItemFactory52(Xcls_LeftProps _owner )
2311 this.el = new Gtk.SignalListItemFactory();
2314 this.is_setting = false;
2316 // set gobject values
2319 this.el.setup.connect( (listitem) => {
2320 var hb = new Gtk.Box(Gtk.Orientation.HORIZONTAL,0);
2321 var elbl = new Gtk.EditableLabel("");
2322 elbl.hexpand = true;
2324 var lbl = new Gtk.Label("");
2327 lbl.use_markup = true;
2329 lbl.ellipsize = Pango.EllipsizeMode.END;
2330 var cb = new Gtk.DropDown(new Gtk.StringList({}), null);
2334 ((Gtk.ListItem)listitem).set_child(hb);
2336 var ef = new Gtk.EventControllerFocus();
2337 ef.enter.connect(() => {
2338 _this.stop_editor();
2339 var prop = (JsRender.NodeProp)((Gtk.ListItem)listitem).get_item();
2340 _this.selmodel.selectProp(prop);
2342 elbl.add_controller(ef);
2345 // dropdown??? - stop editing, and highliht node
2346 var tb = (Gtk.ToggleButton) cb.get_first_child();
2347 tb.clicked.connect(() => {
2348 var prop = (JsRender.NodeProp)((Gtk.ListItem)listitem).get_item();
2350 _this.stop_editor();
2351 _this.selmodel.selectProp(prop);
2354 elbl.changed.connect(() => {
2355 // notify and save the changed value...
2357 //_this.updateIter(iter,prop);
2358 // this should happen automatically
2360 if (!_this.loading && !this.is_setting) {
2361 var prop = (JsRender.NodeProp)((Gtk.ListItem)listitem).get_item();
2364 prop.val = elbl.text;
2365 GLib.debug("calling changed");
2373 cb.notify["selected"].connect(() => {
2374 // dropdown selection changed.
2378 //_this.updateIter(iter,prop);
2379 if (!_this.loading && !this.is_setting) {
2380 var prop = (JsRender.NodeProp)((Gtk.ListItem)listitem).get_item();
2381 var model = (Gtk.StringList)cb.model;
2382 prop.val = model.get_string(cb.selected);
2383 GLib.debug("property set to %s", prop.val);
2384 GLib.debug("calling changed");
2391 var gc = new Gtk.GestureClick();
2392 lbl.add_controller(gc);
2393 gc.pressed.connect(() => {
2394 var prop = (JsRender.NodeProp)((Gtk.ListItem)listitem).get_item();
2395 _this.stop_editor();
2396 _this.show_editor(_this.file, prop.parent, prop);
2402 this.el.bind.connect( (listitem) => {
2403 this.is_setting = true;
2406 var bx = (Gtk.Box) ((Gtk.ListItem)listitem).get_child();
2411 var elbl = (Gtk.EditableLabel)bx.get_first_child();
2412 var lbl = (Gtk.Label) elbl.get_next_sibling();
2413 var cb = (Gtk.DropDown) lbl.get_next_sibling();
2414 // decide if it's a combo or editable text..
2415 var model = (Gtk.StringList) cb.model;
2421 var prop = (JsRender.NodeProp) ((Gtk.ListItem)listitem).get_item();
2422 //GLib.debug("prop = %s", prop.get_type().name());
2423 //GLib.debug("prop.val = %s", prop.val);
2424 //GLib.debug("prop.key = %s", prop.to_display_name());
2426 var use_textarea = prop.useTextArea();
2429 var pal = _this.file.project.palete;
2432 var has_opts = pal.typeOptions(_this.node.fqn(), prop.name, prop.rtype, out opts);
2434 if (!has_opts && prop.ptype == JsRender.NodePropType.RAW) {
2435 use_textarea = true;
2440 prop.bind_property("val_short",
2442 GLib.BindingFlags.SYNC_CREATE);
2443 prop.bind_property("val_tooltip",
2444 lbl, "tooltip_markup",
2445 GLib.BindingFlags.SYNC_CREATE);
2447 this.is_setting = false;
2456 // others... - fill in options for true/false?
2457 // GLib.debug (ktype.up());
2460 while(model.get_n_items() > 0) {
2464 // can not remove - hopefully always empty.
2466 for(var i = 0; i < opts.length; i ++) {
2467 model.append( opts[i]);
2468 // not sure this is a great idea...
2469 if (opts[i].down() == prop.val.down()) {
2473 GLib.debug("Set selected item to %d", sel);
2474 cb.set_selected(sel > -1 ? sel : Gtk.INVALID_LIST_POSITION);
2475 this.is_setting = false;
2479 // see if type is a Enum.
2480 // triggers a changed event
2482 elbl.set_text(prop.val);
2485 this.is_setting = false;
2494 // user defined functions
2498 public class Xcls_ContextMenu : Object
2500 public Gtk.Popover el;
2501 private Xcls_LeftProps _this;
2507 public Xcls_ContextMenu(Xcls_LeftProps _owner )
2510 _this.ContextMenu = this;
2511 this.el = new Gtk.Popover();
2515 // set gobject values
2516 var child_1 = new Xcls_Box54( _this );
2517 this.el.child = child_1.el;
2520 // user defined functions
2522 public class Xcls_Box54 : Object
2525 private Xcls_LeftProps _this;
2531 public Xcls_Box54(Xcls_LeftProps _owner )
2534 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
2538 // set gobject values
2539 var child_1 = new Xcls_Button55( _this );
2541 this.el.append( child_1.el );
2544 // user defined functions
2546 public class Xcls_Button55 : Object
2548 public Gtk.Button el;
2549 private Xcls_LeftProps _this;
2555 public Xcls_Button55(Xcls_LeftProps _owner )
2558 this.el = new Gtk.Button();
2562 // set gobject values
2563 this.el.label = "Delete";
2566 this.el.activate.connect( ( ) =>{
2567 _this.deleteSelected();
2572 // user defined functions