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();
93 if (this.last_error_counter != file.error_counter) {
97 this.last_error_counter = file.error_counter ;
101 if (this.last_error_counter == file.error_counter) {
106 foreach(var diag in ar) {
109 // print("get inter\n");
110 var node= file.lineToNode( (int)diag.range.start.line) ;
111 if (node == null || node.oid != this.node.oid) {
114 var prop = node.lineToProp( (int)diag.range.start.line) ;
116 var row = _this.selmodel.propToRow(prop);
120 var w = this.view.getWidgetAtRow(row);
124 var ed = diag.category.down();
125 if (ed != "err" && w.has_css_class("node-err")) {
128 if (ed == "err" && w.has_css_class("node-warn")) {
129 w.remove_css_class("node-warn");
131 if (ed == "err" && w.has_css_class("node-depr")) {
132 w.remove_css_class("node-depr");
134 if (!w.has_css_class("node-"+ ed)) {
135 w.add_css_class("node-" + ed);
141 public string keyFormat (string val, string type) {
143 // Glib.markup_escape_text(val);
145 if (type == "listener") {
146 return "<span font_weight=\"bold\" color=\"#660000\">" +
147 GLib.Markup.escape_text(val) +
151 if (val.length < 1) {
152 return "<span color=\"#FF0000\">--empty--</span>";
157 //# - object properties
159 // all of these... - display value is last element..
160 var ar = val.strip().split(" ");
163 var dval = GLib.Markup.escape_text(ar[ar.length-1]);
169 case '@': // signal // just bold balck?
170 if (dval[0] == '@') {
171 dval = dval.substring(1);
174 return @"<span font_weight=\"bold\">@ $dval</span>";
175 case '#': // object properties?
176 if (dval[0] == '#') {
177 dval = dval.substring(1);
179 return @"<span font_weight=\"bold\">$dval</span>";
181 if (dval[0] == '*') {
182 dval = dval.substring(1);
184 return @"<span color=\"#0000CC\" font_weight=\"bold\">$dval</span>";
186 if (dval[0] == '$') {
187 dval = dval.substring(1);
189 return @"<span style=\"italic\">$dval</span>";
190 case '|': // user defined methods
191 if (dval[0] == '|') {
192 dval = dval.substring(1);
194 return @"<span color=\"#008000\" font_weight=\"bold\">$dval</span>";
205 public void deleteSelected () {
213 var s = this.view.el.get_selection();
214 s.get_selected(out mod, out iter);
218 mod.get_value(iter, 0 , out gval);
219 var prop = (JsRender.NodeProp)gval;
221 this.load(this.file, this.node);
224 // stop editor after fetching property - otherwise prop is null.
229 case JsRender.NodePropType.LISTENER:
230 this.node.listeners.unset(prop.to_index_key());
234 this.node.props.unset(prop.to_index_key());
237 this.load(this.file, this.node);
242 public void removeErrors () {
243 var child = this.view.el.get_first_child();
245 var reading_header = true;
247 while (child != null) {
248 //GLib.debug("Got %s", child.get_type().name());
250 if (reading_header) {
253 if (child.get_type().name() != "GtkColumnListView") {
255 child = child.get_next_sibling();
258 // should be columnlistview
259 child = child.get_first_child();
263 reading_header = false;
267 if (child.has_css_class("node-err")) {
268 child.remove_css_class("node-err");
270 if (child.has_css_class("node-warn")) {
271 child.remove_css_class("node-warn");
274 if (child.has_css_class("node-depr")) {
275 child.remove_css_class("node-depr");
278 child = child.get_next_sibling();
280 //GLib.debug("Rturning null");
283 public void load (JsRender.JsRender file, JsRender.Node? node)
285 // not sure when to initialize this - we should do it on setting main window really.
288 if (this.view.popover == null) {
289 this.view.popover = new Xcls_PopoverProperty();
290 this.view.popover.mainwindow = _this.main_window;
294 if (this.node != null) {
295 this.node.dupeProps(); // ensures removeall will not do somethign silly
299 GLib.debug("load leftprops\n");
305 this.model.el.remove_all();
307 //this.get('/RightEditor').el.hide();
311 node.loadProps(this.model.el);
314 //GLib.debug("clear selection\n");
316 this.loading = false;
317 this.selmodel.el.set_selected(Gtk.INVALID_LIST_POSITION);
320 //this.model.el.set_sort_column_id(4,Gtk.SortType.ASCENDING); // sort by real key..
322 // this.view.el.get_selection().unselect_all();
324 // _this.keycol.el.set_max_width(_this.EditProps.el.get_allocated_width()/ 2);
325 // _this.valcol.el.set_max_width(_this.EditProps.el.get_allocated_width()/ 2);
328 public class Xcls_Box2 : Object
331 private Xcls_LeftProps _this;
337 public Xcls_Box2(Xcls_LeftProps _owner )
340 this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
344 // set gobject values
345 this.el.hexpand = true;
346 var child_1 = new Xcls_Label3( _this );
348 this.el.append( child_1.el );
349 var child_2 = new Xcls_Button4( _this );
351 this.el.append( child_2.el );
352 var child_3 = new Xcls_Button5( _this );
354 this.el.append( child_3.el );
355 var child_4 = new Xcls_MenuButton6( _this );
357 this.el.append( child_4.el );
360 // user defined functions
362 public class Xcls_Label3 : Object
365 private Xcls_LeftProps _this;
371 public Xcls_Label3(Xcls_LeftProps _owner )
374 this.el = new Gtk.Label( "Add:" );
378 // set gobject values
379 this.el.margin_end = 5;
380 this.el.margin_start = 5;
383 // user defined functions
386 public class Xcls_Button4 : Object
388 public Gtk.Button el;
389 private Xcls_LeftProps _this;
393 public bool always_show_image;
396 public Xcls_Button4(Xcls_LeftProps _owner )
399 this.el = new Gtk.Button();
402 this.always_show_image = true;
404 // set gobject values
405 this.el.icon_name = "format-justify-left";
406 this.el.hexpand = true;
407 this.el.tooltip_text = "Add Property";
408 this.el.label = "Property";
411 this.el.clicked.connect( ( ) => {
413 _this.main_window.windowstate.showProps(
415 JsRender.NodePropType.PROP
421 // user defined functions
424 public class Xcls_Button5 : Object
426 public Gtk.Button el;
427 private Xcls_LeftProps _this;
431 public bool always_show_image;
434 public Xcls_Button5(Xcls_LeftProps _owner )
437 this.el = new Gtk.Button();
440 this.always_show_image = true;
442 // set gobject values
443 this.el.icon_name = "appointment-new";
444 this.el.hexpand = true;
445 this.el.tooltip_text = "Add Event Code";
446 this.el.label = "Event";
449 this.el.clicked.connect( ( ) => {
452 _this.main_window.windowstate.showProps(
454 JsRender.NodePropType.LISTENER
461 // user defined functions
464 public class Xcls_MenuButton6 : Object
466 public Gtk.MenuButton el;
467 private Xcls_LeftProps _this;
473 public Xcls_MenuButton6(Xcls_LeftProps _owner )
476 this.el = new Gtk.MenuButton();
480 // set gobject values
481 this.el.label = "Other";
482 new Xcls_addpop( _this );
483 this.el.popover = _this.addpop.el;
486 // user defined functions
488 public class Xcls_addpop : Object
490 public Gtk.Popover el;
491 private Xcls_LeftProps _this;
497 public Xcls_addpop(Xcls_LeftProps _owner )
501 this.el = new Gtk.Popover();
505 // set gobject values
506 var child_1 = new Xcls_Box8( _this );
507 this.el.child = child_1.el;
510 // user defined functions
512 public class Xcls_Box8 : Object
515 private Xcls_LeftProps _this;
521 public Xcls_Box8(Xcls_LeftProps _owner )
524 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
528 // set gobject values
529 var child_1 = new Xcls_Button9( _this );
531 this.el.append( child_1.el );
532 var child_2 = new Xcls_Button11( _this );
534 this.el.append( child_2.el );
535 var child_3 = new Xcls_Button13( _this );
537 this.el.append( child_3.el );
538 var child_4 = new Xcls_Button15( _this );
540 this.el.append( child_4.el );
541 var child_5 = new Xcls_Button17( _this );
543 this.el.append( child_5.el );
544 var child_6 = new Xcls_Separator19( _this );
546 this.el.append( child_6.el );
547 var child_7 = new Xcls_Button20( _this );
549 this.el.append( child_7.el );
550 var child_8 = new Xcls_Button22( _this );
552 this.el.append( child_8.el );
553 var child_9 = new Xcls_Button24( _this );
555 this.el.append( child_9.el );
556 var child_10 = new Xcls_Separator26( _this );
558 this.el.append( child_10.el );
559 var child_11 = new Xcls_Button27( _this );
561 this.el.append( child_11.el );
562 var child_12 = new Xcls_Button29( _this );
564 this.el.append( child_12.el );
565 var child_13 = new Xcls_Button31( _this );
567 this.el.append( child_13.el );
568 var child_14 = new Xcls_Separator33( _this );
570 this.el.append( child_14.el );
571 var child_15 = new Xcls_Button34( _this );
573 this.el.append( child_15.el );
574 var child_16 = new Xcls_Button36( _this );
576 this.el.append( child_16.el );
577 var child_17 = new Xcls_Button38( _this );
579 this.el.append( child_17.el );
582 // user defined functions
584 public class Xcls_Button9 : Object
586 public Gtk.Button el;
587 private Xcls_LeftProps _this;
593 public Xcls_Button9(Xcls_LeftProps _owner )
596 this.el = new Gtk.Button();
600 // set gobject values
601 this.el.has_frame = false;
602 var child_1 = new Xcls_Label10( _this );
603 this.el.child = child_1.el;
606 this.el.clicked.connect( () => {
607 _this.addpop.el.hide();
608 // is this userdef or special??
609 var add = new JsRender.NodeProp.prop("id");
610 if (_this.node.has_prop_key(add)) {
614 _this.node.add_prop( add );
616 _this.view.editProp( add );
621 // user defined functions
623 public class Xcls_Label10 : Object
626 private Xcls_LeftProps _this;
632 public Xcls_Label10(Xcls_LeftProps _owner )
635 this.el = new Gtk.Label( "id: _this.{ID} (Vala)" );
639 // set gobject values
640 this.el.halign = Gtk.Align.START;
641 this.el.tooltip_text = "Using _this.{ID} will map to this element";
644 // user defined functions
648 public class Xcls_Button11 : Object
650 public Gtk.Button el;
651 private Xcls_LeftProps _this;
657 public Xcls_Button11(Xcls_LeftProps _owner )
660 this.el = new Gtk.Button();
664 // set gobject values
665 this.el.has_frame = false;
666 var child_1 = new Xcls_Label12( _this );
667 this.el.child = child_1.el;
670 this.el.clicked.connect( ( ) => {
673 _this.addpop.el.hide();
674 // is this userdef or special??
675 var add = new JsRender.NodeProp.special("pack", "add");
676 if (_this.node.has_prop_key(add)) {
680 _this.node.add_prop( add );
682 _this.view.editProp( add );
688 // user defined functions
690 public class Xcls_Label12 : Object
693 private Xcls_LeftProps _this;
699 public Xcls_Label12(Xcls_LeftProps _owner )
702 this.el = new Gtk.Label( "pack: Pack method (Vala)" );
706 // set gobject values
707 this.el.halign = Gtk.Align.START;
708 this.el.tooltip_text = "how to pack this element onto parent, (method, 2nd arg, 3rd arg) .. the 1st argument is filled by the element";
711 // user defined functions
715 public class Xcls_Button13 : Object
717 public Gtk.Button el;
718 private Xcls_LeftProps _this;
724 public Xcls_Button13(Xcls_LeftProps _owner )
727 this.el = new Gtk.Button();
731 // set gobject values
732 this.el.has_frame = false;
733 var child_1 = new Xcls_Label14( _this );
734 this.el.child = child_1.el;
737 this.el.clicked.connect( ( ) => {
739 _this.addpop.el.hide();
740 // is this userdef or special??
741 var add = new JsRender.NodeProp.special("ctor");
742 if (_this.node.has_prop_key(add)) {
746 _this.node.add_prop( add );
748 _this.view.editProp( add );
753 // user defined functions
755 public class Xcls_Label14 : Object
758 private Xcls_LeftProps _this;
764 public Xcls_Label14(Xcls_LeftProps _owner )
767 this.el = new Gtk.Label( "ctor: Alterative to default contructor (Vala)" );
771 // set gobject values
772 this.el.halign = Gtk.Align.START;
773 this.el.tooltip_text = "eg. \n\nnew Clutter.Image.from_file(.....)";
776 // user defined functions
780 public class Xcls_Button15 : Object
782 public Gtk.Button el;
783 private Xcls_LeftProps _this;
789 public Xcls_Button15(Xcls_LeftProps _owner )
792 this.el = new Gtk.Button();
796 // set gobject values
797 this.el.has_frame = false;
798 var child_1 = new Xcls_Label16( _this );
799 this.el.child = child_1.el;
802 this.el.clicked.connect( ( ) => {
804 _this.addpop.el.hide();
805 // is this userdef or special??
806 var add = new JsRender.NodeProp.special("init","{\n\n}\n" ) ;
807 if (_this.node.has_prop_key(add)) {
811 _this.node.add_prop( add );
813 _this.view.editProp( add );
817 // user defined functions
819 public class Xcls_Label16 : Object
822 private Xcls_LeftProps _this;
828 public Xcls_Label16(Xcls_LeftProps _owner )
831 this.el = new Gtk.Label( "init: initialziation code (vala)" );
835 // set gobject values
836 this.el.halign = Gtk.Align.START;
837 this.el.tooltip_text = "This code is called after the ctor";
840 // user defined functions
844 public class Xcls_Button17 : Object
846 public Gtk.Button el;
847 private Xcls_LeftProps _this;
853 public Xcls_Button17(Xcls_LeftProps _owner )
856 this.el = new Gtk.Button();
860 // set gobject values
861 this.el.has_frame = false;
862 var child_1 = new Xcls_Label18( _this );
863 this.el.child = child_1.el;
866 this.el.clicked.connect( () => {
867 _this.addpop.el.hide();
869 // is this userdef or special??
870 var add = new JsRender.NodeProp.prop("cms-id","string", "" ) ;
871 if (_this.node.has_prop_key(add)) {
875 _this.node.add_prop( add );
877 _this.view.editProp( add );
882 // user defined functions
884 public class Xcls_Label18 : Object
887 private Xcls_LeftProps _this;
893 public Xcls_Label18(Xcls_LeftProps _owner )
896 this.el = new Gtk.Label( "cms-id: (Roo JS/Pman library)" );
900 // set gobject values
901 this.el.halign = Gtk.Align.START;
902 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";
905 // user defined functions
909 public class Xcls_Separator19 : Object
911 public Gtk.Separator el;
912 private Xcls_LeftProps _this;
918 public Xcls_Separator19(Xcls_LeftProps _owner )
921 this.el = new Gtk.Separator( Gtk.Orientation.HORIZONTAL );
925 // set gobject values
928 // user defined functions
931 public class Xcls_Button20 : Object
933 public Gtk.Button el;
934 private Xcls_LeftProps _this;
940 public Xcls_Button20(Xcls_LeftProps _owner )
943 this.el = new Gtk.Button();
947 // set gobject values
948 this.el.has_frame = false;
949 var child_1 = new Xcls_Label21( _this );
950 this.el.child = child_1.el;
953 this.el.clicked.connect( (self) => {
954 _this.addpop.el.hide();
955 _this.view.popover.show(
958 new JsRender.NodeProp.prop("", "string", "") ,
966 // user defined functions
968 public class Xcls_Label21 : Object
971 private Xcls_LeftProps _this;
977 public Xcls_Label21(Xcls_LeftProps _owner )
980 this.el = new Gtk.Label( "String" );
984 // set gobject values
985 this.el.halign = Gtk.Align.START;
986 this.el.tooltip_text = "Add a user defined string property";
989 // user defined functions
993 public class Xcls_Button22 : Object
995 public Gtk.Button el;
996 private Xcls_LeftProps _this;
1002 public Xcls_Button22(Xcls_LeftProps _owner )
1005 this.el = new Gtk.Button();
1009 // set gobject values
1010 this.el.has_frame = false;
1011 var child_1 = new Xcls_Label23( _this );
1012 this.el.child = child_1.el;
1015 this.el.clicked.connect( ( ) =>{
1017 _this.addpop.el.hide();
1018 _this.view.popover.show(
1021 new JsRender.NodeProp.prop("", "int", "0") ,
1029 // user defined functions
1031 public class Xcls_Label23 : Object
1033 public Gtk.Label el;
1034 private Xcls_LeftProps _this;
1040 public Xcls_Label23(Xcls_LeftProps _owner )
1043 this.el = new Gtk.Label( "Number" );
1047 // set gobject values
1048 this.el.halign = Gtk.Align.START;
1049 this.el.tooltip_text = "Add a user defined number property";
1052 // user defined functions
1056 public class Xcls_Button24 : Object
1058 public Gtk.Button el;
1059 private Xcls_LeftProps _this;
1065 public Xcls_Button24(Xcls_LeftProps _owner )
1068 this.el = new Gtk.Button();
1072 // set gobject values
1073 this.el.has_frame = false;
1074 var child_1 = new Xcls_Label25( _this );
1075 this.el.child = child_1.el;
1078 this.el.clicked.connect( ( ) =>{
1080 _this.addpop.el.hide();
1081 _this.view.popover.show(
1084 new JsRender.NodeProp.prop("", "bool", "true") ,
1092 // user defined functions
1094 public class Xcls_Label25 : Object
1096 public Gtk.Label el;
1097 private Xcls_LeftProps _this;
1103 public Xcls_Label25(Xcls_LeftProps _owner )
1106 this.el = new Gtk.Label( "Boolean" );
1110 // set gobject values
1111 this.el.halign = Gtk.Align.START;
1112 this.el.tooltip_text = "Add a user defined boolean property";
1115 // user defined functions
1119 public class Xcls_Separator26 : Object
1121 public Gtk.Separator el;
1122 private Xcls_LeftProps _this;
1128 public Xcls_Separator26(Xcls_LeftProps _owner )
1131 this.el = new Gtk.Separator( Gtk.Orientation.HORIZONTAL );
1135 // set gobject values
1138 // user defined functions
1141 public class Xcls_Button27 : Object
1143 public Gtk.Button el;
1144 private Xcls_LeftProps _this;
1150 public Xcls_Button27(Xcls_LeftProps _owner )
1153 this.el = new Gtk.Button();
1157 // set gobject values
1158 this.el.has_frame = false;
1159 var child_1 = new Xcls_Label28( _this );
1160 this.el.child = child_1.el;
1163 this.el.clicked.connect( ( ) =>{
1164 _this.addpop.el.hide();
1165 _this.view.popover.show(
1168 new JsRender.NodeProp.jsmethod("") ,
1177 // user defined functions
1179 public class Xcls_Label28 : Object
1181 public Gtk.Label el;
1182 private Xcls_LeftProps _this;
1188 public Xcls_Label28(Xcls_LeftProps _owner )
1191 this.el = new Gtk.Label( "Javascript Function" );
1195 // set gobject values
1196 this.el.halign = Gtk.Align.START;
1197 this.el.tooltip_text = "Add a javascript function";
1200 // user defined functions
1204 public class Xcls_Button29 : Object
1206 public Gtk.Button el;
1207 private Xcls_LeftProps _this;
1213 public Xcls_Button29(Xcls_LeftProps _owner )
1216 this.el = new Gtk.Button();
1220 // set gobject values
1221 this.el.has_frame = false;
1222 var child_1 = new Xcls_Label30( _this );
1223 this.el.child = child_1.el;
1226 this.el.clicked.connect( ( ) =>{
1227 _this.addpop.el.hide();
1228 _this.view.popover.show(
1231 new JsRender.NodeProp.valamethod("") ,
1238 // user defined functions
1240 public class Xcls_Label30 : Object
1242 public Gtk.Label el;
1243 private Xcls_LeftProps _this;
1249 public Xcls_Label30(Xcls_LeftProps _owner )
1252 this.el = new Gtk.Label( "Vala Method" );
1256 // set gobject values
1257 this.el.halign = Gtk.Align.START;
1258 this.el.tooltip_text = "Add a user defined method to a object";
1261 // user defined functions
1265 public class Xcls_Button31 : Object
1267 public Gtk.Button el;
1268 private Xcls_LeftProps _this;
1274 public Xcls_Button31(Xcls_LeftProps _owner )
1277 this.el = new Gtk.Button();
1281 // set gobject values
1282 this.el.has_frame = false;
1283 var child_1 = new Xcls_Label32( _this );
1284 this.el.child = child_1.el;
1287 this.el.clicked.connect( ( ) =>{
1288 _this.addpop.el.hide();
1289 _this.view.popover.show(
1292 new JsRender.NodeProp.sig("" ) ,
1299 // user defined functions
1301 public class Xcls_Label32 : Object
1303 public Gtk.Label el;
1304 private Xcls_LeftProps _this;
1310 public Xcls_Label32(Xcls_LeftProps _owner )
1313 this.el = new Gtk.Label( "Vala Signal" );
1317 // set gobject values
1318 this.el.halign = Gtk.Align.START;
1319 this.el.tooltip_text = "Add a user defined signal to a object";
1322 // user defined functions
1326 public class Xcls_Separator33 : Object
1328 public Gtk.Separator el;
1329 private Xcls_LeftProps _this;
1335 public Xcls_Separator33(Xcls_LeftProps _owner )
1338 this.el = new Gtk.Separator( Gtk.Orientation.HORIZONTAL );
1342 // set gobject values
1345 // user defined functions
1348 public class Xcls_Button34 : Object
1350 public Gtk.Button el;
1351 private Xcls_LeftProps _this;
1357 public Xcls_Button34(Xcls_LeftProps _owner )
1360 this.el = new Gtk.Button();
1364 // set gobject values
1365 this.el.has_frame = false;
1366 var child_1 = new Xcls_Label35( _this );
1367 this.el.child = child_1.el;
1370 this.el.clicked.connect( ( ) =>{
1371 _this.addpop.el.hide();
1372 _this.view.popover.show(
1375 new JsRender.NodeProp.prop("flexy:if", "string", "value_or_condition") ,
1384 // user defined functions
1386 public class Xcls_Label35 : Object
1388 public Gtk.Label el;
1389 private Xcls_LeftProps _this;
1395 public Xcls_Label35(Xcls_LeftProps _owner )
1398 this.el = new Gtk.Label( "Flexy - If" );
1402 // set gobject values
1403 this.el.halign = Gtk.Align.START;
1404 this.el.tooltip_text = "Add a flexy if (for HTML templates)";
1407 // user defined functions
1411 public class Xcls_Button36 : Object
1413 public Gtk.Button el;
1414 private Xcls_LeftProps _this;
1420 public Xcls_Button36(Xcls_LeftProps _owner )
1423 this.el = new Gtk.Button();
1427 // set gobject values
1428 this.el.has_frame = false;
1429 var child_1 = new Xcls_Label37( _this );
1430 this.el.child = child_1.el;
1433 this.el.clicked.connect( ( ) =>{
1434 _this.addpop.el.hide();
1435 _this.view.popover.show(
1438 new JsRender.NodeProp.prop("flexy:include", "string", "name_of_file.html") ,
1447 // user defined functions
1449 public class Xcls_Label37 : Object
1451 public Gtk.Label el;
1452 private Xcls_LeftProps _this;
1458 public Xcls_Label37(Xcls_LeftProps _owner )
1461 this.el = new Gtk.Label( "Flexy - Include" );
1465 // set gobject values
1466 this.el.halign = Gtk.Align.START;
1467 this.el.tooltip_text = "Add a flexy include (for HTML templates)";
1470 // user defined functions
1474 public class Xcls_Button38 : Object
1476 public Gtk.Button el;
1477 private Xcls_LeftProps _this;
1483 public Xcls_Button38(Xcls_LeftProps _owner )
1486 this.el = new Gtk.Button();
1490 // set gobject values
1491 this.el.has_frame = false;
1492 this.el.tooltip_markup = "Add a flexy include (for HTML templates)";
1493 var child_1 = new Xcls_Label39( _this );
1494 this.el.child = child_1.el;
1497 this.el.clicked.connect( ( ) =>{
1498 _this.addpop.el.hide();
1499 _this.view.popover.show(
1502 new JsRender.NodeProp.prop("flexy:if", "string", "value_or_condition") ,
1510 // user defined functions
1512 public class Xcls_Label39 : Object
1514 public Gtk.Label el;
1515 private Xcls_LeftProps _this;
1521 public Xcls_Label39(Xcls_LeftProps _owner )
1524 this.el = new Gtk.Label( "Flexy - Foreach" );
1528 // set gobject values
1529 this.el.halign = Gtk.Align.START;
1530 this.el.tooltip_text = "Add a flexy foreach (for HTML templates)";
1533 // user defined functions
1541 public class Xcls_EditProps : Object
1543 public Gtk.ScrolledWindow el;
1544 private Xcls_LeftProps _this;
1548 public bool editing;
1551 public Xcls_EditProps(Xcls_LeftProps _owner )
1554 _this.EditProps = this;
1555 this.el = new Gtk.ScrolledWindow();
1558 this.editing = false;
1560 // set gobject values
1561 this.el.hexpand = true;
1562 this.el.vexpand = true;
1563 new Xcls_view( _this );
1564 this.el.set_child ( _this.view.el );
1570 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
1574 // user defined functions
1576 public class Xcls_view : Object
1578 public Gtk.ColumnView el;
1579 private Xcls_LeftProps _this;
1583 public Gtk.CssProvider css;
1584 public Xcls_PopoverProperty popover;
1587 public Xcls_view(Xcls_LeftProps _owner )
1591 new Xcls_selmodel( _this );
1592 this.el = new Gtk.ColumnView( _this.selmodel.el );
1595 this.popover = null;
1597 // set gobject values
1598 this.el.name = "leftprops-view";
1599 this.el.single_click_activate = false;
1600 this.el.hexpand = true;
1601 this.el.vexpand = true;
1602 this.el.show_row_separators = true;
1603 new Xcls_deletemenu( _this );
1604 var child_3 = new Xcls_GestureClick45( _this );
1606 this.el.add_controller( child_3.el );
1607 var child_4 = new Xcls_GestureClick46( _this );
1609 this.el.add_controller( child_4.el );
1610 new Xcls_keycol( _this );
1611 this.el.append_column ( _this.keycol.el );
1612 new Xcls_valcol( _this );
1613 this.el.append_column ( _this.valcol.el );
1614 new Xcls_ContextMenu( _this );
1620 this.css = new Gtk.CssProvider();
1622 this.css.load_from_string("
1623 #leftprops-view { font-size: 12px;}
1625 #leftprops-view dropdown button {
1629 #leftprops-view cell dropdown label {
1633 #leftprops-view cell {
1637 #leftprops-view cell label, #leftprops-view cell editablelable {
1642 Gtk.StyleContext.add_provider_for_display(
1643 this.el.get_display(),
1645 Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
1652 // user defined functions
1653 public Gtk.Widget? getWidgetAtRow (uint row) {
1656 from https://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465
1657 var colview = gesture.widget;
1658 var line_no = check_list_widget(colview, x,y);
1660 var item = colview.model.get_item(line_no);
1664 GLib.debug("Get Widget At Row %d", (int)row);
1665 var child = this.el.get_first_child();
1667 var reading_header = true;
1669 while (child != null) {
1670 GLib.debug("Got %s", child.get_type().name());
1671 if (reading_header) {
1674 if (child.get_type().name() != "GtkColumnListView") {
1675 child = child.get_next_sibling();
1678 child = child.get_first_child();
1679 reading_header = false;
1682 if (child.get_type().name() != "GtkColumnViewRowWidget") {
1683 child = child.get_next_sibling();
1687 if (line_no == row) {
1688 GLib.debug("Returning widget %s", child.get_type().name());
1689 return (Gtk.Widget)child;
1691 child = child.get_next_sibling();
1693 GLib.debug("Rturning null");
1697 public void editProp (JsRender.NodeProp prop)
1699 var sm = _this.selmodel.el;
1702 GLib.debug("finding node");
1703 _this.selmodel.selectProp(prop);
1705 for (var i = 0 ; i < sm.n_items; i++) {
1706 var r = (JsRender.NodeProp)sm.get_item(i);
1707 if (r.equals(prop)) {
1713 GLib.debug("finding node - cant find it");
1717 var r = this.getWidgetAtRow(sr);
1718 GLib.debug("r = %s", r.get_type().name());
1719 var ca = r.get_first_child();
1720 var ll = (Gtk.Label)ca.get_first_child();
1721 var cb = ca.get_next_sibling();
1722 var b = cb.get_first_child();
1723 var e = (Gtk.EditableLabel) b.get_first_child();
1724 var l = (Gtk.Label) e.get_next_sibling();
1725 var d = (Gtk.DropDown) l.get_next_sibling();
1727 GLib.debug("row key = %s", ll.label);
1728 if (e.get_visible()) {
1729 _this.stop_editor();
1731 //GLib.Timeout.add_once(500, () => {
1732 // var st = (Gtk.Stack) e.get_first_child();
1733 // var ed = (Gtk.Entry) st.get_visible_child();
1734 // ed.grab_focus_without_selecting();
1738 if (d.get_visible()) {
1739 _this.stop_editor();
1743 if (l.get_visible()) {
1744 _this.stop_editor();
1745 _this.show_editor(_this.file, prop.parent, prop);
1751 //gtkcolumnviewrowwidget
1755 // entry / label / dropdown
1759 public int getColAt (double x, double y) {
1762 from https://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465
1765 //Gtk.Allocation alloc = { 0, 0, 0, 0 };
1766 var child = this.el.get_first_child();
1770 while (child != null) {
1771 GLib.debug("Got %s", child.get_type().name());
1773 if (child.get_type().name() == "GtkColumnViewRowWidget") {
1774 child = child.get_first_child();
1778 //child.get_allocation(out alloc);
1779 if (x < (child.get_width() + offx)) {
1782 offx += child.get_width();
1784 child = child.get_next_sibling();
1791 public int getRowAt (double x, double in_y, out string pos) {
1798 from https://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465
1799 var colview = gesture.widget;
1800 var line_no = check_list_widget(colview, x,y);
1802 var item = colview.model.get_item(line_no);
1808 //GLib.debug("offset = %d y = %d", (int) voff, (int) in_y);
1809 var y = in_y + _this.EditProps.el.vadjustment.value;
1810 var child = this.el.get_first_child();
1811 //Gtk.Allocation alloc = { 0, 0, 0, 0 };
1813 var reading_header = true;
1815 var header_height = 0;
1818 while (child != null) {
1819 //GLib.debug("Got %s", child.get_type().name());
1820 if (reading_header) {
1823 if (child.get_type().name() != "GtkColumnListView") {
1824 h += child.get_height();
1825 child = child.get_next_sibling();
1828 // should be columnlistview
1829 child = child.get_first_child();
1830 //GLib.debug("header height=%d", h);
1833 reading_header = false;
1837 if (child.get_type().name() != "GtkColumnViewRowWidget") {
1838 child = child.get_next_sibling();
1842 if (y < header_height) {
1847 var hh = child.get_height();
1848 if (child.has_css_class("node-err") ||
1849 child.has_css_class("node-warn") ||
1850 child.has_css_class("node-depr")) {
1855 //child.get_allocation(out alloc);
1856 //GLib.debug("got cell xy = %d,%d w,h= %d,%d", alloc.x, alloc.y, alloc.width, alloc.height);
1857 //GLib.debug("row %d y= %d %s", line_no, (int) (header_height + alloc.y),
1859 // child.visible ? "VIS" : "hidden");
1861 if (y > (header_height + real_y) && y <= (header_height + real_y + hh) ) {
1862 if (y > ( header_height + real_y + (hh * 0.8))) {
1864 } else if (y > ( header_height + real_y + (hh * 0.2))) {
1869 GLib.debug("getRowAt return : %d, %s", line_no, pos);
1874 if (real_y + hh > y) {
1878 child = child.get_next_sibling();
1884 public class Xcls_deletemenu : Object
1886 public Gtk.Popover el;
1887 private Xcls_LeftProps _this;
1893 public Xcls_deletemenu(Xcls_LeftProps _owner )
1896 _this.deletemenu = this;
1897 this.el = new Gtk.Popover();
1901 // set gobject values
1902 var child_1 = new Xcls_Box43( _this );
1903 this.el.child = child_1.el;
1906 // user defined functions
1908 public class Xcls_Box43 : Object
1911 private Xcls_LeftProps _this;
1917 public Xcls_Box43(Xcls_LeftProps _owner )
1920 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
1924 // set gobject values
1925 var child_1 = new Xcls_Button44( _this );
1927 this.el.append( child_1.el );
1930 // user defined functions
1932 public class Xcls_Button44 : Object
1934 public Gtk.Button el;
1935 private Xcls_LeftProps _this;
1941 public Xcls_Button44(Xcls_LeftProps _owner )
1944 this.el = new Gtk.Button();
1948 // set gobject values
1949 this.el.label = "Delete";
1952 this.el.clicked.connect( ( ) => {
1955 var n = (JsRender.NodeProp) _this.selmodel.el.selected_item;
1957 _this.deletemenu.el.hide();
1958 _this.node.remove_prop(n);
1962 // user defined functions
1967 public class Xcls_GestureClick45 : Object
1969 public Gtk.GestureClick el;
1970 private Xcls_LeftProps _this;
1976 public Xcls_GestureClick45(Xcls_LeftProps _owner )
1979 this.el = new Gtk.GestureClick();
1983 // set gobject values
1986 this.el.pressed.connect( (n_press, in_x, in_y) => {
1988 GLib.debug("Prssed %d", (int) this.el.get_current_button());
1990 var col = _this.view.getColAt(in_x, in_y);
1995 var row = _this.view.getRowAt(in_x, in_y, out pos);
2001 GLib.debug("hit row %d", row);
2002 var prop = _this.selmodel.getPropAt(row);
2003 _this.selmodel.selectProp(prop);
2005 //var point_at = _this.view.getWidgetAtRow(row);
2007 // need to shift down, as ev.y does not inclucde header apparently..
2008 // or popover might be trying to do a central?
2009 // _this.view.editPropertyDetails(prop, (int) in_y + 12);
2010 _this.stop_editor();
2011 _this.view.popover.show(
2021 // user defined functions
2024 public class Xcls_GestureClick46 : Object
2026 public Gtk.GestureClick el;
2027 private Xcls_LeftProps _this;
2033 public Xcls_GestureClick46(Xcls_LeftProps _owner )
2036 this.el = new Gtk.GestureClick();
2040 // set gobject values
2044 this.el.pressed.connect( (n_press, in_x, in_y) => {
2049 var row = _this.view.getRowAt(in_x, in_y, out pos);
2056 _this.stop_editor();
2057 GLib.debug("hit row %d", row);
2058 var prop = _this.selmodel.getPropAt(row);
2059 _this.selmodel.selectProp(prop);
2063 GLib.debug("Prssed %d", (int) this.el.get_current_button());
2064 //_this.deletemenu.el.set_parent(_this.view.el);
2065 if (_this.deletemenu.el.parent == null) {
2066 _this.deletemenu.el.set_parent(_this.main_window.el);
2071 _this.deletemenu.el.set_offset(
2072 (int)in_x - _this.view.el.get_width() ,
2073 (int)in_y - _this.view.el.get_height()
2075 _this.deletemenu.el.set_position(Gtk.PositionType.BOTTOM);
2076 _this.deletemenu.el.popup();
2081 // user defined functions
2084 public class Xcls_selmodel : Object
2086 public Gtk.SingleSelection el;
2087 private Xcls_LeftProps _this;
2093 public Xcls_selmodel(Xcls_LeftProps _owner )
2096 _this.selmodel = this;
2097 new Xcls_model( _this );
2098 this.el = new Gtk.SingleSelection( _this.model.el );
2102 // set gobject values
2103 this.el.can_unselect = true;
2106 // user defined functions
2107 public int propToRow (JsRender.NodeProp prop) {
2108 for (var i = 0 ; i < this.el.n_items; i++) {
2109 var r = (JsRender.NodeProp)this.el.get_item(i);
2110 if (r.equals(prop)) {
2118 public void startEditing (JsRender.NodeProp prop) {
2119 // should we call select?? - caller does int (from windowstate)
2122 public void selectProp (JsRender.NodeProp prop) {
2123 for (var i = 0 ; i < this.el.n_items; i++) {
2124 var r = (JsRender.NodeProp)this.el.get_item(i);
2125 if (r.equals(prop)) {
2126 this.el.selected = i;
2132 public JsRender.NodeProp getPropAt (uint row) {
2134 return (JsRender.NodeProp) this.el.get_item(row);
2139 public class Xcls_model : Object
2141 public GLib.ListStore el;
2142 private Xcls_LeftProps _this;
2148 public Xcls_model(Xcls_LeftProps _owner )
2152 this.el = new GLib.ListStore(typeof(JsRender.NodeProp));
2156 // set gobject values
2159 // user defined functions
2163 public class Xcls_keycol : Object
2165 public Gtk.ColumnViewColumn el;
2166 private Xcls_LeftProps _this;
2172 public Xcls_keycol(Xcls_LeftProps _owner )
2175 _this.keycol = this;
2176 var child_1 = new Xcls_SignalListItemFactory50( _this );
2178 this.el = new Gtk.ColumnViewColumn( "Property", child_1.el );
2182 // set gobject values
2183 this.el.id = "keycol";
2184 this.el.expand = true;
2185 this.el.resizable = true;
2188 // user defined functions
2190 public class Xcls_SignalListItemFactory50 : Object
2192 public Gtk.SignalListItemFactory el;
2193 private Xcls_LeftProps _this;
2199 public Xcls_SignalListItemFactory50(Xcls_LeftProps _owner )
2202 this.el = new Gtk.SignalListItemFactory();
2206 // set gobject values
2209 this.el.setup.connect( (listitem) => {
2210 var lbl = new Gtk.Label("");
2211 ((Gtk.ListItem)listitem).set_child(lbl);
2212 lbl.justify = Gtk.Justification.LEFT;
2214 lbl.use_markup = true;
2215 lbl.ellipsize = Pango.EllipsizeMode.START;
2216 /*lbl.changed.connect(() => {
2217 // notify and save the changed value...
2218 //var prop = (JsRender.NodeProp) ((Gtk.ListItem)listitem.get_item());
2220 //prop.val = lbl.text;
2221 //_this.updateIter(iter,prop);
2225 ((Gtk.ListItem)listitem).activatable = true;
2227 this.el.bind.connect( (listitem) => {
2228 var lb = (Gtk.Label) ((Gtk.ListItem)listitem).get_child();
2229 var item = (JsRender.NodeProp) ((Gtk.ListItem)listitem).get_item();
2232 item.bind_property("to_display_name_prop",
2234 GLib.BindingFlags.SYNC_CREATE);
2235 item.bind_property("to_tooltip_name_prop",
2236 lb, "tooltip_markup",
2237 GLib.BindingFlags.SYNC_CREATE);
2238 // was item (1) in old layout
2244 // user defined functions
2248 public class Xcls_valcol : Object
2250 public Gtk.ColumnViewColumn el;
2251 private Xcls_LeftProps _this;
2257 public Xcls_valcol(Xcls_LeftProps _owner )
2260 _this.valcol = this;
2261 var child_1 = new Xcls_SignalListItemFactory52( _this );
2263 this.el = new Gtk.ColumnViewColumn( "Value", child_1.el );
2267 // set gobject values
2268 this.el.id = "valcol";
2269 this.el.expand = true;
2270 this.el.resizable = true;
2273 // user defined functions
2275 public class Xcls_SignalListItemFactory52 : Object
2277 public Gtk.SignalListItemFactory el;
2278 private Xcls_LeftProps _this;
2282 public bool is_setting;
2285 public Xcls_SignalListItemFactory52(Xcls_LeftProps _owner )
2288 this.el = new Gtk.SignalListItemFactory();
2291 this.is_setting = false;
2293 // set gobject values
2296 this.el.setup.connect( (listitem) => {
2297 var hb = new Gtk.Box(Gtk.Orientation.HORIZONTAL,0);
2298 var elbl = new Gtk.EditableLabel("");
2299 elbl.hexpand = true;
2301 var lbl = new Gtk.Label("");
2304 lbl.use_markup = true;
2306 lbl.ellipsize = Pango.EllipsizeMode.END;
2307 var cb = new Gtk.DropDown(new Gtk.StringList({}), null);
2311 ((Gtk.ListItem)listitem).set_child(hb);
2313 var ef = new Gtk.EventControllerFocus();
2314 ef.enter.connect(() => {
2315 _this.stop_editor();
2316 var prop = (JsRender.NodeProp)((Gtk.ListItem)listitem).get_item();
2317 _this.selmodel.selectProp(prop);
2319 elbl.add_controller(ef);
2322 // dropdown??? - stop editing, and highliht node
2323 var tb = (Gtk.ToggleButton) cb.get_first_child();
2324 tb.clicked.connect(() => {
2325 var prop = (JsRender.NodeProp)((Gtk.ListItem)listitem).get_item();
2327 _this.stop_editor();
2328 _this.selmodel.selectProp(prop);
2331 elbl.changed.connect(() => {
2332 // notify and save the changed value...
2334 //_this.updateIter(iter,prop);
2335 // this should happen automatically
2337 if (!_this.loading && !this.is_setting) {
2338 var prop = (JsRender.NodeProp)((Gtk.ListItem)listitem).get_item();
2341 prop.val = elbl.text;
2342 GLib.debug("calling changed");
2350 cb.notify["selected"].connect(() => {
2351 // dropdown selection changed.
2355 //_this.updateIter(iter,prop);
2356 if (!_this.loading && !this.is_setting) {
2357 var prop = (JsRender.NodeProp)((Gtk.ListItem)listitem).get_item();
2358 var model = (Gtk.StringList)cb.model;
2359 prop.val = model.get_string(cb.selected);
2360 GLib.debug("property set to %s", prop.val);
2361 GLib.debug("calling changed");
2368 var gc = new Gtk.GestureClick();
2369 lbl.add_controller(gc);
2370 gc.pressed.connect(() => {
2371 var prop = (JsRender.NodeProp)((Gtk.ListItem)listitem).get_item();
2372 _this.stop_editor();
2373 _this.show_editor(_this.file, prop.parent, prop);
2379 this.el.bind.connect( (listitem) => {
2380 this.is_setting = true;
2383 var bx = (Gtk.Box) ((Gtk.ListItem)listitem).get_child();
2388 var elbl = (Gtk.EditableLabel)bx.get_first_child();
2389 var lbl = (Gtk.Label) elbl.get_next_sibling();
2390 var cb = (Gtk.DropDown) lbl.get_next_sibling();
2391 // decide if it's a combo or editable text..
2392 var model = (Gtk.StringList) cb.model;
2398 var prop = (JsRender.NodeProp) ((Gtk.ListItem)listitem).get_item();
2399 //GLib.debug("prop = %s", prop.get_type().name());
2400 //GLib.debug("prop.val = %s", prop.val);
2401 //GLib.debug("prop.key = %s", prop.to_display_name());
2403 var use_textarea = prop.useTextArea();
2406 var pal = _this.file.project.palete;
2409 var has_opts = pal.typeOptions(_this.node.fqn(), prop.name, prop.rtype, out opts);
2411 if (!has_opts && prop.ptype == JsRender.NodePropType.RAW) {
2412 use_textarea = true;
2417 prop.bind_property("val_short",
2419 GLib.BindingFlags.SYNC_CREATE);
2420 prop.bind_property("val_tooltip",
2421 lbl, "tooltip_markup",
2422 GLib.BindingFlags.SYNC_CREATE);
2424 this.is_setting = false;
2433 // others... - fill in options for true/false?
2434 // GLib.debug (ktype.up());
2437 while(model.get_n_items() > 0) {
2441 // can not remove - hopefully always empty.
2443 for(var i = 0; i < opts.length; i ++) {
2444 model.append( opts[i]);
2445 // not sure this is a great idea...
2446 if (opts[i].down() == prop.val.down()) {
2450 GLib.debug("Set selected item to %d", sel);
2451 cb.set_selected(sel > -1 ? sel : Gtk.INVALID_LIST_POSITION);
2452 this.is_setting = false;
2456 // see if type is a Enum.
2457 // triggers a changed event
2459 elbl.set_text(prop.val);
2462 this.is_setting = false;
2471 // user defined functions
2475 public class Xcls_ContextMenu : Object
2477 public Gtk.Popover el;
2478 private Xcls_LeftProps _this;
2484 public Xcls_ContextMenu(Xcls_LeftProps _owner )
2487 _this.ContextMenu = this;
2488 this.el = new Gtk.Popover();
2492 // set gobject values
2493 var child_1 = new Xcls_Box54( _this );
2494 this.el.child = child_1.el;
2497 // user defined functions
2499 public class Xcls_Box54 : Object
2502 private Xcls_LeftProps _this;
2508 public Xcls_Box54(Xcls_LeftProps _owner )
2511 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
2515 // set gobject values
2516 var child_1 = new Xcls_Button55( _this );
2518 this.el.append( child_1.el );
2521 // user defined functions
2523 public class Xcls_Button55 : Object
2525 public Gtk.Button el;
2526 private Xcls_LeftProps _this;
2532 public Xcls_Button55(Xcls_LeftProps _owner )
2535 this.el = new Gtk.Button();
2539 // set gobject values
2540 this.el.label = "Delete";
2543 this.el.activate.connect( ( ) =>{
2544 _this.deleteSelected();
2549 // user defined functions