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 () {
94 var ar = file.getErrors();
95 if (ar == null || ar.size < 1) {
96 if (this.last_error_counter != file.error_counter) {
100 this.last_error_counter = file.error_counter ;
104 if (this.last_error_counter == file.error_counter) {
109 foreach(var diag in ar) {
112 // print("get inter\n");
113 var node= file.lineToNode( (int)diag.range.start.line) ;
114 if (node == null || node.oid != this.node.oid) {
117 var prop = node.lineToProp( (int)diag.range.start.line) ;
119 var row = _this.selmodel.propToRow(prop);
123 var w = this.view.getWidgetAtRow(row);
127 var ed = diag.category.down();
128 if (ed != "err" && w.has_css_class("node-err")) {
131 if (ed == "err" && w.has_css_class("node-warn")) {
132 w.remove_css_class("node-warn");
134 if (ed == "err" && w.has_css_class("node-depr")) {
135 w.remove_css_class("node-depr");
137 if (!w.has_css_class("node-"+ ed)) {
138 w.add_css_class("node-" + ed);
144 public string keyFormat (string val, string type) {
146 // Glib.markup_escape_text(val);
148 if (type == "listener") {
149 return "<span font_weight=\"bold\" color=\"#660000\">" +
150 GLib.Markup.escape_text(val) +
154 if (val.length < 1) {
155 return "<span color=\"#FF0000\">--empty--</span>";
160 //# - object properties
162 // all of these... - display value is last element..
163 var ar = val.strip().split(" ");
166 var dval = GLib.Markup.escape_text(ar[ar.length-1]);
172 case '@': // signal // just bold balck?
173 if (dval[0] == '@') {
174 dval = dval.substring(1);
177 return @"<span font_weight=\"bold\">@ $dval</span>";
178 case '#': // object properties?
179 if (dval[0] == '#') {
180 dval = dval.substring(1);
182 return @"<span font_weight=\"bold\">$dval</span>";
184 if (dval[0] == '*') {
185 dval = dval.substring(1);
187 return @"<span color=\"#0000CC\" font_weight=\"bold\">$dval</span>";
189 if (dval[0] == '$') {
190 dval = dval.substring(1);
192 return @"<span style=\"italic\">$dval</span>";
193 case '|': // user defined methods
194 if (dval[0] == '|') {
195 dval = dval.substring(1);
197 return @"<span color=\"#008000\" font_weight=\"bold\">$dval</span>";
208 public void deleteSelected () {
216 var s = this.view.el.get_selection();
217 s.get_selected(out mod, out iter);
221 mod.get_value(iter, 0 , out gval);
222 var prop = (JsRender.NodeProp)gval;
224 this.load(this.file, this.node);
227 // stop editor after fetching property - otherwise prop is null.
232 case JsRender.NodePropType.LISTENER:
233 this.node.listeners.unset(prop.to_index_key());
237 this.node.props.unset(prop.to_index_key());
240 this.load(this.file, this.node);
245 public void removeErrors () {
246 var child = this.view.el.get_first_child();
248 var reading_header = true;
250 while (child != null) {
251 //GLib.debug("Got %s", child.get_type().name());
253 if (reading_header) {
256 if (child.get_type().name() != "GtkColumnListView") {
258 child = child.get_next_sibling();
261 // should be columnlistview
262 child = child.get_first_child();
266 reading_header = false;
270 if (child.has_css_class("node-err")) {
271 child.remove_css_class("node-err");
273 if (child.has_css_class("node-warn")) {
274 child.remove_css_class("node-warn");
277 if (child.has_css_class("node-depr")) {
278 child.remove_css_class("node-depr");
281 child = child.get_next_sibling();
283 //GLib.debug("Rturning null");
286 public void load (JsRender.JsRender file, JsRender.Node? node)
288 // not sure when to initialize this - we should do it on setting main window really.
291 if (this.view.popover == null) {
292 this.view.popover = new Xcls_PopoverProperty();
293 this.view.popover.mainwindow = _this.main_window;
297 if (this.node != null) {
298 this.node.dupeProps(); // ensures removeall will not do somethign silly
302 GLib.debug("load leftprops\n");
308 this.model.el.remove_all();
310 //this.get('/RightEditor').el.hide();
314 node.loadProps(this.model.el);
317 //GLib.debug("clear selection\n");
319 this.loading = false;
320 this.selmodel.el.set_selected(Gtk.INVALID_LIST_POSITION);
323 //this.model.el.set_sort_column_id(4,Gtk.SortType.ASCENDING); // sort by real key..
325 // this.view.el.get_selection().unselect_all();
327 // _this.keycol.el.set_max_width(_this.EditProps.el.get_allocated_width()/ 2);
328 // _this.valcol.el.set_max_width(_this.EditProps.el.get_allocated_width()/ 2);
331 public class Xcls_Box2 : Object
334 private Xcls_LeftProps _this;
340 public Xcls_Box2(Xcls_LeftProps _owner )
343 this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
347 // set gobject values
348 this.el.hexpand = true;
349 var child_1 = new Xcls_Label3( _this );
351 this.el.append( child_1.el );
352 var child_2 = new Xcls_Button4( _this );
354 this.el.append( child_2.el );
355 var child_3 = new Xcls_Button5( _this );
357 this.el.append( child_3.el );
358 var child_4 = new Xcls_MenuButton6( _this );
360 this.el.append( child_4.el );
363 // user defined functions
365 public class Xcls_Label3 : Object
368 private Xcls_LeftProps _this;
374 public Xcls_Label3(Xcls_LeftProps _owner )
377 this.el = new Gtk.Label( "Add:" );
381 // set gobject values
382 this.el.margin_end = 5;
383 this.el.margin_start = 5;
386 // user defined functions
389 public class Xcls_Button4 : Object
391 public Gtk.Button el;
392 private Xcls_LeftProps _this;
396 public bool always_show_image;
399 public Xcls_Button4(Xcls_LeftProps _owner )
402 this.el = new Gtk.Button();
405 this.always_show_image = true;
407 // set gobject values
408 this.el.icon_name = "format-justify-left";
409 this.el.hexpand = true;
410 this.el.tooltip_text = "Add Property";
411 this.el.label = "Property";
414 this.el.clicked.connect( ( ) => {
416 _this.main_window.windowstate.showProps(
418 JsRender.NodePropType.PROP
424 // user defined functions
427 public class Xcls_Button5 : Object
429 public Gtk.Button el;
430 private Xcls_LeftProps _this;
434 public bool always_show_image;
437 public Xcls_Button5(Xcls_LeftProps _owner )
440 this.el = new Gtk.Button();
443 this.always_show_image = true;
445 // set gobject values
446 this.el.icon_name = "appointment-new";
447 this.el.hexpand = true;
448 this.el.tooltip_text = "Add Event Code";
449 this.el.label = "Event";
452 this.el.clicked.connect( ( ) => {
455 _this.main_window.windowstate.showProps(
457 JsRender.NodePropType.LISTENER
464 // user defined functions
467 public class Xcls_MenuButton6 : Object
469 public Gtk.MenuButton el;
470 private Xcls_LeftProps _this;
476 public Xcls_MenuButton6(Xcls_LeftProps _owner )
479 this.el = new Gtk.MenuButton();
483 // set gobject values
484 this.el.label = "Other";
485 new Xcls_addpop( _this );
486 this.el.popover = _this.addpop.el;
489 // user defined functions
491 public class Xcls_addpop : Object
493 public Gtk.Popover el;
494 private Xcls_LeftProps _this;
500 public Xcls_addpop(Xcls_LeftProps _owner )
504 this.el = new Gtk.Popover();
508 // set gobject values
509 var child_1 = new Xcls_Box8( _this );
510 this.el.child = child_1.el;
513 // user defined functions
515 public class Xcls_Box8 : Object
518 private Xcls_LeftProps _this;
524 public Xcls_Box8(Xcls_LeftProps _owner )
527 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
531 // set gobject values
532 var child_1 = new Xcls_Button9( _this );
534 this.el.append( child_1.el );
535 var child_2 = new Xcls_Button11( _this );
537 this.el.append( child_2.el );
538 var child_3 = new Xcls_Button13( _this );
540 this.el.append( child_3.el );
541 var child_4 = new Xcls_Button15( _this );
543 this.el.append( child_4.el );
544 var child_5 = new Xcls_Button17( _this );
546 this.el.append( child_5.el );
547 var child_6 = new Xcls_Separator19( _this );
549 this.el.append( child_6.el );
550 var child_7 = new Xcls_Button20( _this );
552 this.el.append( child_7.el );
553 var child_8 = new Xcls_Button22( _this );
555 this.el.append( child_8.el );
556 var child_9 = new Xcls_Button24( _this );
558 this.el.append( child_9.el );
559 var child_10 = new Xcls_Separator26( _this );
561 this.el.append( child_10.el );
562 var child_11 = new Xcls_Button27( _this );
564 this.el.append( child_11.el );
565 var child_12 = new Xcls_Button29( _this );
567 this.el.append( child_12.el );
568 var child_13 = new Xcls_Button31( _this );
570 this.el.append( child_13.el );
571 var child_14 = new Xcls_Separator33( _this );
573 this.el.append( child_14.el );
574 var child_15 = new Xcls_Button34( _this );
576 this.el.append( child_15.el );
577 var child_16 = new Xcls_Button36( _this );
579 this.el.append( child_16.el );
580 var child_17 = new Xcls_Button38( _this );
582 this.el.append( child_17.el );
585 // user defined functions
587 public class Xcls_Button9 : Object
589 public Gtk.Button el;
590 private Xcls_LeftProps _this;
596 public Xcls_Button9(Xcls_LeftProps _owner )
599 this.el = new Gtk.Button();
603 // set gobject values
604 this.el.has_frame = false;
605 var child_1 = new Xcls_Label10( _this );
606 this.el.child = child_1.el;
609 this.el.clicked.connect( () => {
610 _this.addpop.el.hide();
611 // is this userdef or special??
612 var add = new JsRender.NodeProp.prop("id");
613 if (_this.node.has_prop_key(add)) {
617 _this.node.add_prop( add );
619 _this.view.editProp( add );
624 // user defined functions
626 public class Xcls_Label10 : Object
629 private Xcls_LeftProps _this;
635 public Xcls_Label10(Xcls_LeftProps _owner )
638 this.el = new Gtk.Label( "id: _this.{ID} (Vala)" );
642 // set gobject values
643 this.el.halign = Gtk.Align.START;
644 this.el.tooltip_text = "Using _this.{ID} will map to this element";
647 // user defined functions
651 public class Xcls_Button11 : Object
653 public Gtk.Button el;
654 private Xcls_LeftProps _this;
660 public Xcls_Button11(Xcls_LeftProps _owner )
663 this.el = new Gtk.Button();
667 // set gobject values
668 this.el.has_frame = false;
669 var child_1 = new Xcls_Label12( _this );
670 this.el.child = child_1.el;
673 this.el.clicked.connect( ( ) => {
676 _this.addpop.el.hide();
677 // is this userdef or special??
678 var add = new JsRender.NodeProp.special("pack", "add");
679 if (_this.node.has_prop_key(add)) {
683 _this.node.add_prop( add );
685 _this.view.editProp( add );
691 // user defined functions
693 public class Xcls_Label12 : Object
696 private Xcls_LeftProps _this;
702 public Xcls_Label12(Xcls_LeftProps _owner )
705 this.el = new Gtk.Label( "pack: Pack method (Vala)" );
709 // set gobject values
710 this.el.halign = Gtk.Align.START;
711 this.el.tooltip_text = "how to pack this element onto parent, (method, 2nd arg, 3rd arg) .. the 1st argument is filled by the element";
714 // user defined functions
718 public class Xcls_Button13 : Object
720 public Gtk.Button el;
721 private Xcls_LeftProps _this;
727 public Xcls_Button13(Xcls_LeftProps _owner )
730 this.el = new Gtk.Button();
734 // set gobject values
735 this.el.has_frame = false;
736 var child_1 = new Xcls_Label14( _this );
737 this.el.child = child_1.el;
740 this.el.clicked.connect( ( ) => {
742 _this.addpop.el.hide();
743 // is this userdef or special??
744 var add = new JsRender.NodeProp.special("ctor");
745 if (_this.node.has_prop_key(add)) {
749 _this.node.add_prop( add );
751 _this.view.editProp( add );
756 // user defined functions
758 public class Xcls_Label14 : Object
761 private Xcls_LeftProps _this;
767 public Xcls_Label14(Xcls_LeftProps _owner )
770 this.el = new Gtk.Label( "ctor: Alterative to default contructor (Vala)" );
774 // set gobject values
775 this.el.halign = Gtk.Align.START;
776 this.el.tooltip_text = "eg. \n\nnew Clutter.Image.from_file(.....)";
779 // user defined functions
783 public class Xcls_Button15 : Object
785 public Gtk.Button el;
786 private Xcls_LeftProps _this;
792 public Xcls_Button15(Xcls_LeftProps _owner )
795 this.el = new Gtk.Button();
799 // set gobject values
800 this.el.has_frame = false;
801 var child_1 = new Xcls_Label16( _this );
802 this.el.child = child_1.el;
805 this.el.clicked.connect( ( ) => {
807 _this.addpop.el.hide();
808 // is this userdef or special??
809 var add = new JsRender.NodeProp.special("init","{\n\n}\n" ) ;
810 if (_this.node.has_prop_key(add)) {
814 _this.node.add_prop( add );
816 _this.view.editProp( add );
820 // user defined functions
822 public class Xcls_Label16 : Object
825 private Xcls_LeftProps _this;
831 public Xcls_Label16(Xcls_LeftProps _owner )
834 this.el = new Gtk.Label( "init: initialziation code (vala)" );
838 // set gobject values
839 this.el.halign = Gtk.Align.START;
840 this.el.tooltip_text = "This code is called after the ctor";
843 // user defined functions
847 public class Xcls_Button17 : Object
849 public Gtk.Button el;
850 private Xcls_LeftProps _this;
856 public Xcls_Button17(Xcls_LeftProps _owner )
859 this.el = new Gtk.Button();
863 // set gobject values
864 this.el.has_frame = false;
865 var child_1 = new Xcls_Label18( _this );
866 this.el.child = child_1.el;
869 this.el.clicked.connect( () => {
870 _this.addpop.el.hide();
872 // is this userdef or special??
873 var add = new JsRender.NodeProp.prop("cms-id","string", "" ) ;
874 if (_this.node.has_prop_key(add)) {
878 _this.node.add_prop( add );
880 _this.view.editProp( add );
885 // user defined functions
887 public class Xcls_Label18 : Object
890 private Xcls_LeftProps _this;
896 public Xcls_Label18(Xcls_LeftProps _owner )
899 this.el = new Gtk.Label( "cms-id: (Roo JS/Pman library)" );
903 // set gobject values
904 this.el.halign = Gtk.Align.START;
905 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";
908 // user defined functions
912 public class Xcls_Separator19 : Object
914 public Gtk.Separator el;
915 private Xcls_LeftProps _this;
921 public Xcls_Separator19(Xcls_LeftProps _owner )
924 this.el = new Gtk.Separator( Gtk.Orientation.HORIZONTAL );
928 // set gobject values
931 // user defined functions
934 public class Xcls_Button20 : Object
936 public Gtk.Button el;
937 private Xcls_LeftProps _this;
943 public Xcls_Button20(Xcls_LeftProps _owner )
946 this.el = new Gtk.Button();
950 // set gobject values
951 this.el.has_frame = false;
952 var child_1 = new Xcls_Label21( _this );
953 this.el.child = child_1.el;
956 this.el.clicked.connect( (self) => {
957 _this.addpop.el.hide();
958 _this.view.popover.show(
961 new JsRender.NodeProp.prop("", "string", "") ,
969 // user defined functions
971 public class Xcls_Label21 : Object
974 private Xcls_LeftProps _this;
980 public Xcls_Label21(Xcls_LeftProps _owner )
983 this.el = new Gtk.Label( "String" );
987 // set gobject values
988 this.el.halign = Gtk.Align.START;
989 this.el.tooltip_text = "Add a user defined string property";
992 // user defined functions
996 public class Xcls_Button22 : Object
998 public Gtk.Button el;
999 private Xcls_LeftProps _this;
1005 public Xcls_Button22(Xcls_LeftProps _owner )
1008 this.el = new Gtk.Button();
1012 // set gobject values
1013 this.el.has_frame = false;
1014 var child_1 = new Xcls_Label23( _this );
1015 this.el.child = child_1.el;
1018 this.el.clicked.connect( ( ) =>{
1020 _this.addpop.el.hide();
1021 _this.view.popover.show(
1024 new JsRender.NodeProp.prop("", "int", "0") ,
1032 // user defined functions
1034 public class Xcls_Label23 : Object
1036 public Gtk.Label el;
1037 private Xcls_LeftProps _this;
1043 public Xcls_Label23(Xcls_LeftProps _owner )
1046 this.el = new Gtk.Label( "Number" );
1050 // set gobject values
1051 this.el.halign = Gtk.Align.START;
1052 this.el.tooltip_text = "Add a user defined number property";
1055 // user defined functions
1059 public class Xcls_Button24 : Object
1061 public Gtk.Button el;
1062 private Xcls_LeftProps _this;
1068 public Xcls_Button24(Xcls_LeftProps _owner )
1071 this.el = new Gtk.Button();
1075 // set gobject values
1076 this.el.has_frame = false;
1077 var child_1 = new Xcls_Label25( _this );
1078 this.el.child = child_1.el;
1081 this.el.clicked.connect( ( ) =>{
1083 _this.addpop.el.hide();
1084 _this.view.popover.show(
1087 new JsRender.NodeProp.prop("", "bool", "true") ,
1095 // user defined functions
1097 public class Xcls_Label25 : Object
1099 public Gtk.Label el;
1100 private Xcls_LeftProps _this;
1106 public Xcls_Label25(Xcls_LeftProps _owner )
1109 this.el = new Gtk.Label( "Boolean" );
1113 // set gobject values
1114 this.el.halign = Gtk.Align.START;
1115 this.el.tooltip_text = "Add a user defined boolean property";
1118 // user defined functions
1122 public class Xcls_Separator26 : Object
1124 public Gtk.Separator el;
1125 private Xcls_LeftProps _this;
1131 public Xcls_Separator26(Xcls_LeftProps _owner )
1134 this.el = new Gtk.Separator( Gtk.Orientation.HORIZONTAL );
1138 // set gobject values
1141 // user defined functions
1144 public class Xcls_Button27 : Object
1146 public Gtk.Button el;
1147 private Xcls_LeftProps _this;
1153 public Xcls_Button27(Xcls_LeftProps _owner )
1156 this.el = new Gtk.Button();
1160 // set gobject values
1161 this.el.has_frame = false;
1162 var child_1 = new Xcls_Label28( _this );
1163 this.el.child = child_1.el;
1166 this.el.clicked.connect( ( ) =>{
1167 _this.addpop.el.hide();
1168 _this.view.popover.show(
1171 new JsRender.NodeProp.jsmethod("") ,
1180 // user defined functions
1182 public class Xcls_Label28 : Object
1184 public Gtk.Label el;
1185 private Xcls_LeftProps _this;
1191 public Xcls_Label28(Xcls_LeftProps _owner )
1194 this.el = new Gtk.Label( "Javascript Function" );
1198 // set gobject values
1199 this.el.halign = Gtk.Align.START;
1200 this.el.tooltip_text = "Add a javascript function";
1203 // user defined functions
1207 public class Xcls_Button29 : Object
1209 public Gtk.Button el;
1210 private Xcls_LeftProps _this;
1216 public Xcls_Button29(Xcls_LeftProps _owner )
1219 this.el = new Gtk.Button();
1223 // set gobject values
1224 this.el.has_frame = false;
1225 var child_1 = new Xcls_Label30( _this );
1226 this.el.child = child_1.el;
1229 this.el.clicked.connect( ( ) =>{
1230 _this.addpop.el.hide();
1231 _this.view.popover.show(
1234 new JsRender.NodeProp.valamethod("") ,
1241 // user defined functions
1243 public class Xcls_Label30 : Object
1245 public Gtk.Label el;
1246 private Xcls_LeftProps _this;
1252 public Xcls_Label30(Xcls_LeftProps _owner )
1255 this.el = new Gtk.Label( "Vala Method" );
1259 // set gobject values
1260 this.el.halign = Gtk.Align.START;
1261 this.el.tooltip_text = "Add a user defined method to a object";
1264 // user defined functions
1268 public class Xcls_Button31 : Object
1270 public Gtk.Button el;
1271 private Xcls_LeftProps _this;
1277 public Xcls_Button31(Xcls_LeftProps _owner )
1280 this.el = new Gtk.Button();
1284 // set gobject values
1285 this.el.has_frame = false;
1286 var child_1 = new Xcls_Label32( _this );
1287 this.el.child = child_1.el;
1290 this.el.clicked.connect( ( ) =>{
1291 _this.addpop.el.hide();
1292 _this.view.popover.show(
1295 new JsRender.NodeProp.sig("" ) ,
1302 // user defined functions
1304 public class Xcls_Label32 : Object
1306 public Gtk.Label el;
1307 private Xcls_LeftProps _this;
1313 public Xcls_Label32(Xcls_LeftProps _owner )
1316 this.el = new Gtk.Label( "Vala Signal" );
1320 // set gobject values
1321 this.el.halign = Gtk.Align.START;
1322 this.el.tooltip_text = "Add a user defined signal to a object";
1325 // user defined functions
1329 public class Xcls_Separator33 : Object
1331 public Gtk.Separator el;
1332 private Xcls_LeftProps _this;
1338 public Xcls_Separator33(Xcls_LeftProps _owner )
1341 this.el = new Gtk.Separator( Gtk.Orientation.HORIZONTAL );
1345 // set gobject values
1348 // user defined functions
1351 public class Xcls_Button34 : Object
1353 public Gtk.Button el;
1354 private Xcls_LeftProps _this;
1360 public Xcls_Button34(Xcls_LeftProps _owner )
1363 this.el = new Gtk.Button();
1367 // set gobject values
1368 this.el.has_frame = false;
1369 var child_1 = new Xcls_Label35( _this );
1370 this.el.child = child_1.el;
1373 this.el.clicked.connect( ( ) =>{
1374 _this.addpop.el.hide();
1375 _this.view.popover.show(
1378 new JsRender.NodeProp.prop("flexy:if", "string", "value_or_condition") ,
1387 // user defined functions
1389 public class Xcls_Label35 : Object
1391 public Gtk.Label el;
1392 private Xcls_LeftProps _this;
1398 public Xcls_Label35(Xcls_LeftProps _owner )
1401 this.el = new Gtk.Label( "Flexy - If" );
1405 // set gobject values
1406 this.el.halign = Gtk.Align.START;
1407 this.el.tooltip_text = "Add a flexy if (for HTML templates)";
1410 // user defined functions
1414 public class Xcls_Button36 : Object
1416 public Gtk.Button el;
1417 private Xcls_LeftProps _this;
1423 public Xcls_Button36(Xcls_LeftProps _owner )
1426 this.el = new Gtk.Button();
1430 // set gobject values
1431 this.el.has_frame = false;
1432 var child_1 = new Xcls_Label37( _this );
1433 this.el.child = child_1.el;
1436 this.el.clicked.connect( ( ) =>{
1437 _this.addpop.el.hide();
1438 _this.view.popover.show(
1441 new JsRender.NodeProp.prop("flexy:include", "string", "name_of_file.html") ,
1450 // user defined functions
1452 public class Xcls_Label37 : Object
1454 public Gtk.Label el;
1455 private Xcls_LeftProps _this;
1461 public Xcls_Label37(Xcls_LeftProps _owner )
1464 this.el = new Gtk.Label( "Flexy - Include" );
1468 // set gobject values
1469 this.el.halign = Gtk.Align.START;
1470 this.el.tooltip_text = "Add a flexy include (for HTML templates)";
1473 // user defined functions
1477 public class Xcls_Button38 : Object
1479 public Gtk.Button el;
1480 private Xcls_LeftProps _this;
1486 public Xcls_Button38(Xcls_LeftProps _owner )
1489 this.el = new Gtk.Button();
1493 // set gobject values
1494 this.el.has_frame = false;
1495 this.el.tooltip_markup = "Add a flexy include (for HTML templates)";
1496 var child_1 = new Xcls_Label39( _this );
1497 this.el.child = child_1.el;
1500 this.el.clicked.connect( ( ) =>{
1501 _this.addpop.el.hide();
1502 _this.view.popover.show(
1505 new JsRender.NodeProp.prop("flexy:if", "string", "value_or_condition") ,
1513 // user defined functions
1515 public class Xcls_Label39 : Object
1517 public Gtk.Label el;
1518 private Xcls_LeftProps _this;
1524 public Xcls_Label39(Xcls_LeftProps _owner )
1527 this.el = new Gtk.Label( "Flexy - Foreach" );
1531 // set gobject values
1532 this.el.halign = Gtk.Align.START;
1533 this.el.tooltip_text = "Add a flexy foreach (for HTML templates)";
1536 // user defined functions
1544 public class Xcls_EditProps : Object
1546 public Gtk.ScrolledWindow el;
1547 private Xcls_LeftProps _this;
1551 public bool editing;
1554 public Xcls_EditProps(Xcls_LeftProps _owner )
1557 _this.EditProps = this;
1558 this.el = new Gtk.ScrolledWindow();
1561 this.editing = false;
1563 // set gobject values
1564 this.el.hexpand = true;
1565 this.el.vexpand = true;
1566 new Xcls_view( _this );
1567 this.el.set_child ( _this.view.el );
1573 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
1577 // user defined functions
1579 public class Xcls_view : Object
1581 public Gtk.ColumnView el;
1582 private Xcls_LeftProps _this;
1586 public Gtk.CssProvider css;
1587 public Xcls_PopoverProperty popover;
1590 public Xcls_view(Xcls_LeftProps _owner )
1594 new Xcls_selmodel( _this );
1595 this.el = new Gtk.ColumnView( _this.selmodel.el );
1598 this.popover = null;
1600 // set gobject values
1601 this.el.name = "leftprops-view";
1602 this.el.single_click_activate = false;
1603 this.el.hexpand = true;
1604 this.el.vexpand = true;
1605 this.el.show_row_separators = true;
1606 new Xcls_deletemenu( _this );
1607 var child_3 = new Xcls_GestureClick45( _this );
1609 this.el.add_controller( child_3.el );
1610 var child_4 = new Xcls_GestureClick46( _this );
1612 this.el.add_controller( child_4.el );
1613 new Xcls_keycol( _this );
1614 this.el.append_column ( _this.keycol.el );
1615 new Xcls_valcol( _this );
1616 this.el.append_column ( _this.valcol.el );
1617 new Xcls_ContextMenu( _this );
1623 this.css = new Gtk.CssProvider();
1625 this.css.load_from_string("
1626 #leftprops-view { font-size: 12px;}
1628 #leftprops-view dropdown button {
1632 #leftprops-view cell dropdown label {
1636 #leftprops-view cell {
1640 #leftprops-view cell label, #leftprops-view cell editablelable {
1645 Gtk.StyleContext.add_provider_for_display(
1646 this.el.get_display(),
1648 Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
1655 // user defined functions
1656 public Gtk.Widget? getWidgetAtRow (uint row) {
1659 from https://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465
1660 var colview = gesture.widget;
1661 var line_no = check_list_widget(colview, x,y);
1663 var item = colview.model.get_item(line_no);
1667 GLib.debug("Get Widget At Row %d", (int)row);
1668 var child = this.el.get_first_child();
1670 var reading_header = true;
1672 while (child != null) {
1673 GLib.debug("Got %s", child.get_type().name());
1674 if (reading_header) {
1677 if (child.get_type().name() != "GtkColumnListView") {
1678 child = child.get_next_sibling();
1681 child = child.get_first_child();
1682 reading_header = false;
1685 if (child.get_type().name() != "GtkColumnViewRowWidget") {
1686 child = child.get_next_sibling();
1690 if (line_no == row) {
1691 GLib.debug("Returning widget %s", child.get_type().name());
1692 return (Gtk.Widget)child;
1694 child = child.get_next_sibling();
1696 GLib.debug("Rturning null");
1700 public void editProp (JsRender.NodeProp prop)
1702 var sm = _this.selmodel.el;
1705 GLib.debug("finding node");
1706 _this.selmodel.selectProp(prop);
1708 for (var i = 0 ; i < sm.n_items; i++) {
1709 var r = (JsRender.NodeProp)sm.get_item(i);
1710 if (r.equals(prop)) {
1716 GLib.debug("finding node - cant find it");
1720 var r = this.getWidgetAtRow(sr);
1721 GLib.debug("r = %s", r.get_type().name());
1722 var ca = r.get_first_child();
1723 var ll = (Gtk.Label)ca.get_first_child();
1724 var cb = ca.get_next_sibling();
1725 var b = cb.get_first_child();
1726 var e = (Gtk.EditableLabel) b.get_first_child();
1727 var l = (Gtk.Label) e.get_next_sibling();
1728 var d = (Gtk.DropDown) l.get_next_sibling();
1730 GLib.debug("row key = %s", ll.label);
1731 if (e.get_visible()) {
1732 _this.stop_editor();
1734 //GLib.Timeout.add_once(500, () => {
1735 // var st = (Gtk.Stack) e.get_first_child();
1736 // var ed = (Gtk.Entry) st.get_visible_child();
1737 // ed.grab_focus_without_selecting();
1741 if (d.get_visible()) {
1742 _this.stop_editor();
1746 if (l.get_visible()) {
1747 _this.stop_editor();
1748 _this.show_editor(_this.file, prop.parent, prop);
1754 //gtkcolumnviewrowwidget
1758 // entry / label / dropdown
1762 public int getColAt (double x, double y) {
1765 from https://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465
1768 //Gtk.Allocation alloc = { 0, 0, 0, 0 };
1769 var child = this.el.get_first_child();
1773 while (child != null) {
1774 GLib.debug("Got %s", child.get_type().name());
1776 if (child.get_type().name() == "GtkColumnViewRowWidget") {
1777 child = child.get_first_child();
1781 //child.get_allocation(out alloc);
1782 if (x < (child.get_width() + offx)) {
1785 offx += child.get_width();
1787 child = child.get_next_sibling();
1794 public int getRowAt (double x, double in_y, out string pos) {
1801 from https://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465
1802 var colview = gesture.widget;
1803 var line_no = check_list_widget(colview, x,y);
1805 var item = colview.model.get_item(line_no);
1811 //GLib.debug("offset = %d y = %d", (int) voff, (int) in_y);
1812 var y = in_y + _this.EditProps.el.vadjustment.value;
1813 var child = this.el.get_first_child();
1814 //Gtk.Allocation alloc = { 0, 0, 0, 0 };
1816 var reading_header = true;
1818 var header_height = 0;
1821 while (child != null) {
1822 //GLib.debug("Got %s", child.get_type().name());
1823 if (reading_header) {
1826 if (child.get_type().name() != "GtkColumnListView") {
1827 h += child.get_height();
1828 child = child.get_next_sibling();
1831 // should be columnlistview
1832 child = child.get_first_child();
1833 //GLib.debug("header height=%d", h);
1836 reading_header = false;
1840 if (child.get_type().name() != "GtkColumnViewRowWidget") {
1841 child = child.get_next_sibling();
1845 if (y < header_height) {
1850 var hh = child.get_height();
1851 if (child.has_css_class("node-err") ||
1852 child.has_css_class("node-warn") ||
1853 child.has_css_class("node-depr")) {
1858 //child.get_allocation(out alloc);
1859 //GLib.debug("got cell xy = %d,%d w,h= %d,%d", alloc.x, alloc.y, alloc.width, alloc.height);
1860 //GLib.debug("row %d y= %d %s", line_no, (int) (header_height + alloc.y),
1862 // child.visible ? "VIS" : "hidden");
1864 if (y > (header_height + real_y) && y <= (header_height + real_y + hh) ) {
1865 if (y > ( header_height + real_y + (hh * 0.8))) {
1867 } else if (y > ( header_height + real_y + (hh * 0.2))) {
1872 GLib.debug("getRowAt return : %d, %s", line_no, pos);
1877 if (real_y + hh > y) {
1881 child = child.get_next_sibling();
1887 public class Xcls_deletemenu : Object
1889 public Gtk.Popover el;
1890 private Xcls_LeftProps _this;
1896 public Xcls_deletemenu(Xcls_LeftProps _owner )
1899 _this.deletemenu = this;
1900 this.el = new Gtk.Popover();
1904 // set gobject values
1905 var child_1 = new Xcls_Box43( _this );
1906 this.el.child = child_1.el;
1909 // user defined functions
1911 public class Xcls_Box43 : Object
1914 private Xcls_LeftProps _this;
1920 public Xcls_Box43(Xcls_LeftProps _owner )
1923 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
1927 // set gobject values
1928 var child_1 = new Xcls_Button44( _this );
1930 this.el.append( child_1.el );
1933 // user defined functions
1935 public class Xcls_Button44 : Object
1937 public Gtk.Button el;
1938 private Xcls_LeftProps _this;
1944 public Xcls_Button44(Xcls_LeftProps _owner )
1947 this.el = new Gtk.Button();
1951 // set gobject values
1952 this.el.label = "Delete";
1955 this.el.clicked.connect( ( ) => {
1958 var n = (JsRender.NodeProp) _this.selmodel.el.selected_item;
1960 _this.deletemenu.el.hide();
1961 _this.node.remove_prop(n);
1965 // user defined functions
1970 public class Xcls_GestureClick45 : Object
1972 public Gtk.GestureClick el;
1973 private Xcls_LeftProps _this;
1979 public Xcls_GestureClick45(Xcls_LeftProps _owner )
1982 this.el = new Gtk.GestureClick();
1986 // set gobject values
1989 this.el.pressed.connect( (n_press, in_x, in_y) => {
1991 GLib.debug("Prssed %d", (int) this.el.get_current_button());
1993 var col = _this.view.getColAt(in_x, in_y);
1998 var row = _this.view.getRowAt(in_x, in_y, out pos);
2004 GLib.debug("hit row %d", row);
2005 var prop = _this.selmodel.getPropAt(row);
2006 _this.selmodel.selectProp(prop);
2008 //var point_at = _this.view.getWidgetAtRow(row);
2010 // need to shift down, as ev.y does not inclucde header apparently..
2011 // or popover might be trying to do a central?
2012 // _this.view.editPropertyDetails(prop, (int) in_y + 12);
2013 _this.stop_editor();
2014 _this.view.popover.show(
2024 // user defined functions
2027 public class Xcls_GestureClick46 : Object
2029 public Gtk.GestureClick el;
2030 private Xcls_LeftProps _this;
2036 public Xcls_GestureClick46(Xcls_LeftProps _owner )
2039 this.el = new Gtk.GestureClick();
2043 // set gobject values
2047 this.el.pressed.connect( (n_press, in_x, in_y) => {
2052 var row = _this.view.getRowAt(in_x, in_y, out pos);
2059 _this.stop_editor();
2060 GLib.debug("hit row %d", row);
2061 var prop = _this.selmodel.getPropAt(row);
2062 _this.selmodel.selectProp(prop);
2066 GLib.debug("Prssed %d", (int) this.el.get_current_button());
2067 //_this.deletemenu.el.set_parent(_this.view.el);
2068 if (_this.deletemenu.el.parent == null) {
2069 _this.deletemenu.el.set_parent(_this.main_window.el);
2074 _this.deletemenu.el.set_offset(
2075 (int)in_x - _this.view.el.get_width() ,
2076 (int)in_y - _this.view.el.get_height()
2078 _this.deletemenu.el.set_position(Gtk.PositionType.BOTTOM);
2079 _this.deletemenu.el.popup();
2084 // user defined functions
2087 public class Xcls_selmodel : Object
2089 public Gtk.SingleSelection el;
2090 private Xcls_LeftProps _this;
2096 public Xcls_selmodel(Xcls_LeftProps _owner )
2099 _this.selmodel = this;
2100 new Xcls_model( _this );
2101 this.el = new Gtk.SingleSelection( _this.model.el );
2105 // set gobject values
2106 this.el.can_unselect = true;
2109 // user defined functions
2110 public int propToRow (JsRender.NodeProp prop) {
2111 for (var i = 0 ; i < this.el.n_items; i++) {
2112 var r = (JsRender.NodeProp)this.el.get_item(i);
2113 if (r.equals(prop)) {
2121 public void startEditing (JsRender.NodeProp prop) {
2122 // should we call select?? - caller does int (from windowstate)
2125 public void selectProp (JsRender.NodeProp prop) {
2126 for (var i = 0 ; i < this.el.n_items; i++) {
2127 var r = (JsRender.NodeProp)this.el.get_item(i);
2128 if (r.equals(prop)) {
2129 this.el.selected = i;
2135 public JsRender.NodeProp getPropAt (uint row) {
2137 return (JsRender.NodeProp) this.el.get_item(row);
2142 public class Xcls_model : Object
2144 public GLib.ListStore el;
2145 private Xcls_LeftProps _this;
2151 public Xcls_model(Xcls_LeftProps _owner )
2155 this.el = new GLib.ListStore(typeof(JsRender.NodeProp));
2159 // set gobject values
2162 // user defined functions
2166 public class Xcls_keycol : Object
2168 public Gtk.ColumnViewColumn el;
2169 private Xcls_LeftProps _this;
2175 public Xcls_keycol(Xcls_LeftProps _owner )
2178 _this.keycol = this;
2179 var child_1 = new Xcls_SignalListItemFactory50( _this );
2181 this.el = new Gtk.ColumnViewColumn( "Property", child_1.el );
2185 // set gobject values
2186 this.el.id = "keycol";
2187 this.el.expand = true;
2188 this.el.resizable = true;
2191 // user defined functions
2193 public class Xcls_SignalListItemFactory50 : Object
2195 public Gtk.SignalListItemFactory el;
2196 private Xcls_LeftProps _this;
2202 public Xcls_SignalListItemFactory50(Xcls_LeftProps _owner )
2205 this.el = new Gtk.SignalListItemFactory();
2209 // set gobject values
2212 this.el.setup.connect( (listitem) => {
2213 var lbl = new Gtk.Label("");
2214 ((Gtk.ListItem)listitem).set_child(lbl);
2215 lbl.justify = Gtk.Justification.LEFT;
2217 lbl.use_markup = true;
2218 lbl.ellipsize = Pango.EllipsizeMode.START;
2219 /*lbl.changed.connect(() => {
2220 // notify and save the changed value...
2221 //var prop = (JsRender.NodeProp) ((Gtk.ListItem)listitem.get_item());
2223 //prop.val = lbl.text;
2224 //_this.updateIter(iter,prop);
2228 ((Gtk.ListItem)listitem).activatable = true;
2230 this.el.bind.connect( (listitem) => {
2231 var lb = (Gtk.Label) ((Gtk.ListItem)listitem).get_child();
2232 var item = (JsRender.NodeProp) ((Gtk.ListItem)listitem).get_item();
2235 item.bind_property("to_display_name_prop",
2237 GLib.BindingFlags.SYNC_CREATE);
2238 item.bind_property("to_tooltip_name_prop",
2239 lb, "tooltip_markup",
2240 GLib.BindingFlags.SYNC_CREATE);
2241 // was item (1) in old layout
2247 // user defined functions
2251 public class Xcls_valcol : Object
2253 public Gtk.ColumnViewColumn el;
2254 private Xcls_LeftProps _this;
2260 public Xcls_valcol(Xcls_LeftProps _owner )
2263 _this.valcol = this;
2264 var child_1 = new Xcls_SignalListItemFactory52( _this );
2266 this.el = new Gtk.ColumnViewColumn( "Value", child_1.el );
2270 // set gobject values
2271 this.el.id = "valcol";
2272 this.el.expand = true;
2273 this.el.resizable = true;
2276 // user defined functions
2278 public class Xcls_SignalListItemFactory52 : Object
2280 public Gtk.SignalListItemFactory el;
2281 private Xcls_LeftProps _this;
2285 public bool is_setting;
2288 public Xcls_SignalListItemFactory52(Xcls_LeftProps _owner )
2291 this.el = new Gtk.SignalListItemFactory();
2294 this.is_setting = false;
2296 // set gobject values
2299 this.el.setup.connect( (listitem) => {
2300 var hb = new Gtk.Box(Gtk.Orientation.HORIZONTAL,0);
2301 var elbl = new Gtk.EditableLabel("");
2302 elbl.hexpand = true;
2304 var lbl = new Gtk.Label("");
2307 lbl.use_markup = true;
2309 lbl.ellipsize = Pango.EllipsizeMode.END;
2310 var cb = new Gtk.DropDown(new Gtk.StringList({}), null);
2314 ((Gtk.ListItem)listitem).set_child(hb);
2316 var ef = new Gtk.EventControllerFocus();
2317 ef.enter.connect(() => {
2318 _this.stop_editor();
2319 var prop = (JsRender.NodeProp)((Gtk.ListItem)listitem).get_item();
2320 _this.selmodel.selectProp(prop);
2322 elbl.add_controller(ef);
2325 // dropdown??? - stop editing, and highliht node
2326 var tb = (Gtk.ToggleButton) cb.get_first_child();
2327 tb.clicked.connect(() => {
2328 var prop = (JsRender.NodeProp)((Gtk.ListItem)listitem).get_item();
2330 _this.stop_editor();
2331 _this.selmodel.selectProp(prop);
2334 elbl.changed.connect(() => {
2335 // notify and save the changed value...
2337 //_this.updateIter(iter,prop);
2338 // this should happen automatically
2340 if (!_this.loading && !this.is_setting) {
2341 var prop = (JsRender.NodeProp)((Gtk.ListItem)listitem).get_item();
2344 prop.val = elbl.text;
2345 GLib.debug("calling changed");
2353 cb.notify["selected"].connect(() => {
2354 // dropdown selection changed.
2358 //_this.updateIter(iter,prop);
2359 if (!_this.loading && !this.is_setting) {
2360 var prop = (JsRender.NodeProp)((Gtk.ListItem)listitem).get_item();
2361 var model = (Gtk.StringList)cb.model;
2362 prop.val = model.get_string(cb.selected);
2363 GLib.debug("property set to %s", prop.val);
2364 GLib.debug("calling changed");
2371 var gc = new Gtk.GestureClick();
2372 lbl.add_controller(gc);
2373 gc.pressed.connect(() => {
2374 var prop = (JsRender.NodeProp)((Gtk.ListItem)listitem).get_item();
2375 _this.stop_editor();
2376 _this.show_editor(_this.file, prop.parent, prop);
2382 this.el.bind.connect( (listitem) => {
2383 this.is_setting = true;
2386 var bx = (Gtk.Box) ((Gtk.ListItem)listitem).get_child();
2391 var elbl = (Gtk.EditableLabel)bx.get_first_child();
2392 var lbl = (Gtk.Label) elbl.get_next_sibling();
2393 var cb = (Gtk.DropDown) lbl.get_next_sibling();
2394 // decide if it's a combo or editable text..
2395 var model = (Gtk.StringList) cb.model;
2401 var prop = (JsRender.NodeProp) ((Gtk.ListItem)listitem).get_item();
2402 //GLib.debug("prop = %s", prop.get_type().name());
2403 //GLib.debug("prop.val = %s", prop.val);
2404 //GLib.debug("prop.key = %s", prop.to_display_name());
2406 var use_textarea = prop.useTextArea();
2409 var pal = _this.file.project.palete;
2412 var has_opts = pal.typeOptions(_this.node.fqn(), prop.name, prop.rtype, out opts);
2414 if (!has_opts && prop.ptype == JsRender.NodePropType.RAW) {
2415 use_textarea = true;
2420 prop.bind_property("val_short",
2422 GLib.BindingFlags.SYNC_CREATE);
2423 prop.bind_property("val_tooltip",
2424 lbl, "tooltip_markup",
2425 GLib.BindingFlags.SYNC_CREATE);
2427 this.is_setting = false;
2436 // others... - fill in options for true/false?
2437 // GLib.debug (ktype.up());
2440 while(model.get_n_items() > 0) {
2444 // can not remove - hopefully always empty.
2446 for(var i = 0; i < opts.length; i ++) {
2447 model.append( opts[i]);
2448 // not sure this is a great idea...
2449 if (opts[i].down() == prop.val.down()) {
2453 GLib.debug("Set selected item to %d", sel);
2454 cb.set_selected(sel > -1 ? sel : Gtk.INVALID_LIST_POSITION);
2455 this.is_setting = false;
2459 // see if type is a Enum.
2460 // triggers a changed event
2462 elbl.set_text(prop.val);
2465 this.is_setting = false;
2474 // user defined functions
2478 public class Xcls_ContextMenu : Object
2480 public Gtk.Popover el;
2481 private Xcls_LeftProps _this;
2487 public Xcls_ContextMenu(Xcls_LeftProps _owner )
2490 _this.ContextMenu = this;
2491 this.el = new Gtk.Popover();
2495 // set gobject values
2496 var child_1 = new Xcls_Box54( _this );
2497 this.el.child = child_1.el;
2500 // user defined functions
2502 public class Xcls_Box54 : Object
2505 private Xcls_LeftProps _this;
2511 public Xcls_Box54(Xcls_LeftProps _owner )
2514 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
2518 // set gobject values
2519 var child_1 = new Xcls_Button55( _this );
2521 this.el.append( child_1.el );
2524 // user defined functions
2526 public class Xcls_Button55 : Object
2528 public Gtk.Button el;
2529 private Xcls_LeftProps _this;
2535 public Xcls_Button55(Xcls_LeftProps _owner )
2538 this.el = new Gtk.Button();
2542 // set gobject values
2543 this.el.label = "Delete";
2546 this.el.activate.connect( ( ) =>{
2547 _this.deleteSelected();
2552 // user defined functions