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);
36 public Gee.ArrayList<Gtk.Widget>? error_widgets;
39 public Xcls_LeftProps()
42 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
46 this.allow_edit = false;
47 this.main_window = null;
48 this.last_error_counter = -1;
49 this.error_widgets = null;
52 this.el.homogeneous = false ;
53 this.el.hexpand = true;
54 this.el.vexpand = true;
55 var child_1 = new Xcls_Box1( _this );
57 this.el.append( child_1.el );
58 new Xcls_EditProps( _this );
59 this.el.append( _this.EditProps.el );
62 // user defined functions
63 public string keySortFormat (string key) {
64 // listeners first - with 0
71 var bits = key.split(" ");
74 return "2 " + bits[bits.length -1];
78 return "3 " + bits[bits.length -1];
83 return "4 " + bits[bits.length -1];
86 return "5 " + bits[bits.length -1];
91 public void updateErrors () {
96 var ar = file.getErrors();
97 if (ar == null || ar.size < 1) {
98 if (this.last_error_counter != file.error_counter) {
102 this.last_error_counter = file.error_counter ;
106 if (this.last_error_counter == file.error_counter) {
110 this.error_widgets = new Gee.ArrayList<Gtk.Widget>();
111 foreach(var diag in ar) {
114 // print("get inter\n");
115 var node = file.lineToNode( (int)diag.range.start.line) ;
116 if (node == null || this.node == null || node.oid != this.node.oid) {
119 var prop = node.lineToProp( (int)diag.range.start.line) ;
123 var row = _this.selmodel.propToRow(prop);
127 var w = this.view.getWidgetAtRow(row);
133 var ed = diag.category.down();
134 if (ed != "err" && w.has_css_class("node-err")) {
137 this.error_widgets.add(w);
138 if (ed == "err" && w.has_css_class("node-warn")) {
139 w.remove_css_class("node-warn");
141 if (ed == "err" && w.has_css_class("node-depr")) {
142 w.remove_css_class("node-depr");
144 if (!w.has_css_class("node-"+ ed)) {
145 w.add_css_class("node-" + ed);
151 public string keyFormat (string val, string type) {
153 // Glib.markup_escape_text(val);
155 if (type == "listener") {
156 return "<span font_weight=\"bold\" color=\"#660000\">" +
157 GLib.Markup.escape_text(val) +
161 if (val.length < 1) {
162 return "<span color=\"#FF0000\">--empty--</span>";
167 //# - object properties
169 // all of these... - display value is last element..
170 var ar = val.strip().split(" ");
173 var dval = GLib.Markup.escape_text(ar[ar.length-1]);
179 case '@': // signal // just bold balck?
180 if (dval[0] == '@') {
181 dval = dval.substring(1);
184 return @"<span font_weight=\"bold\">@ $dval</span>";
185 case '#': // object properties?
186 if (dval[0] == '#') {
187 dval = dval.substring(1);
189 return @"<span font_weight=\"bold\">$dval</span>";
191 if (dval[0] == '*') {
192 dval = dval.substring(1);
194 return @"<span color=\"#0000CC\" font_weight=\"bold\">$dval</span>";
196 if (dval[0] == '$') {
197 dval = dval.substring(1);
199 return @"<span style=\"italic\">$dval</span>";
200 case '|': // user defined methods
201 if (dval[0] == '|') {
202 dval = dval.substring(1);
204 return @"<span color=\"#008000\" font_weight=\"bold\">$dval</span>";
215 public void deleteSelected () {
223 var s = this.view.el.get_selection();
224 s.get_selected(out mod, out iter);
228 mod.get_value(iter, 0 , out gval);
229 var prop = (JsRender.NodeProp)gval;
231 this.load(this.file, this.node);
234 // stop editor after fetching property - otherwise prop is null.
239 case JsRender.NodePropType.LISTENER:
240 this.node.listeners.unset(prop.to_index_key());
244 this.node.props.unset(prop.to_index_key());
247 this.load(this.file, this.node);
252 public void removeErrors () {
253 if (this.error_widgets == null || this.error_widgets.size < 1) {
256 foreach(var child in this.error_widgets) {
258 if (child.has_css_class("node-err")) {
259 child.remove_css_class("node-err");
261 if (child.has_css_class("node-warn")) {
262 child.remove_css_class("node-warn");
265 if (child.has_css_class("node-depr")) {
266 child.remove_css_class("node-depr");
269 this.error_widgets = null;
271 //GLib.debug("Rturning null");
274 public void load (JsRender.JsRender file, JsRender.Node? node)
276 // not sure when to initialize this - we should do it on setting main window really.
279 if (this.view.popover == null) {
280 this.view.popover = new Xcls_PopoverProperty();
281 this.view.popover.mainwindow = _this.main_window;
285 if (this.node != null) {
286 this.node.dupeProps(); // ensures removeall will not do somethign silly
290 GLib.debug("load leftprops\n");
296 this.model.el.remove_all();
298 //this.get('/RightEditor').el.hide();
303 node.loadProps(this.model.el, _this.main_window.windowstate.project);
306 //GLib.debug("clear selection\n");
308 this.loading = false;
309 this.selmodel.el.set_selected(Gtk.INVALID_LIST_POSITION);
312 //this.model.el.set_sort_column_id(4,Gtk.SortType.ASCENDING); // sort by real key..
314 // this.view.el.get_selection().unselect_all();
316 // _this.keycol.el.set_max_width(_this.EditProps.el.get_allocated_width()/ 2);
317 // _this.valcol.el.set_max_width(_this.EditProps.el.get_allocated_width()/ 2);
320 public class Xcls_Box1 : Object
323 private Xcls_LeftProps _this;
329 public Xcls_Box1(Xcls_LeftProps _owner )
332 this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
336 // set gobject values
337 this.el.hexpand = true;
338 var child_1 = new Xcls_Label2( _this );
340 this.el.append( child_1.el );
341 var child_2 = new Xcls_Button3( _this );
343 this.el.append( child_2.el );
344 var child_3 = new Xcls_Button4( _this );
346 this.el.append( child_3.el );
347 var child_4 = new Xcls_MenuButton5( _this );
349 this.el.append( child_4.el );
352 // user defined functions
354 public class Xcls_Label2 : Object
357 private Xcls_LeftProps _this;
363 public Xcls_Label2(Xcls_LeftProps _owner )
366 this.el = new Gtk.Label( "Add:" );
370 // set gobject values
371 this.el.margin_end = 5;
372 this.el.margin_start = 5;
375 // user defined functions
378 public class Xcls_Button3 : Object
380 public Gtk.Button el;
381 private Xcls_LeftProps _this;
385 public bool always_show_image;
388 public Xcls_Button3(Xcls_LeftProps _owner )
391 this.el = new Gtk.Button();
394 this.always_show_image = true;
396 // set gobject values
397 this.el.icon_name = "format-justify-left";
398 this.el.hexpand = true;
399 this.el.tooltip_text = "Add Property";
400 this.el.label = "Property";
403 this.el.clicked.connect( ( ) => {
405 _this.main_window.windowstate.showProps(
407 JsRender.NodePropType.PROP
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 = "appointment-new";
436 this.el.hexpand = true;
437 this.el.tooltip_text = "Add Event Code";
438 this.el.label = "Event";
441 this.el.clicked.connect( ( ) => {
444 _this.main_window.windowstate.showProps(
446 JsRender.NodePropType.LISTENER
453 // user defined functions
456 public class Xcls_MenuButton5 : Object
458 public Gtk.MenuButton el;
459 private Xcls_LeftProps _this;
465 public Xcls_MenuButton5(Xcls_LeftProps _owner )
468 this.el = new Gtk.MenuButton();
472 // set gobject values
473 this.el.label = "Other";
474 new Xcls_addpop( _this );
475 this.el.popover = _this.addpop.el;
478 // user defined functions
480 public class Xcls_addpop : Object
482 public Gtk.Popover el;
483 private Xcls_LeftProps _this;
489 public Xcls_addpop(Xcls_LeftProps _owner )
493 this.el = new Gtk.Popover();
497 // set gobject values
498 var child_1 = new Xcls_Box7( _this );
500 this.el.child = child_1.el;
503 // user defined functions
505 public class Xcls_Box7 : Object
508 private Xcls_LeftProps _this;
514 public Xcls_Box7(Xcls_LeftProps _owner )
517 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
521 // set gobject values
522 var child_1 = new Xcls_Button8( _this );
524 this.el.append( child_1.el );
525 var child_2 = new Xcls_Button10( _this );
527 this.el.append( child_2.el );
528 var child_3 = new Xcls_Button12( _this );
530 this.el.append( child_3.el );
531 var child_4 = new Xcls_Button14( _this );
533 this.el.append( child_4.el );
534 var child_5 = new Xcls_Button16( _this );
536 this.el.append( child_5.el );
537 var child_6 = new Xcls_Separator18( _this );
539 this.el.append( child_6.el );
540 var child_7 = new Xcls_Button19( _this );
542 this.el.append( child_7.el );
543 var child_8 = new Xcls_Button21( _this );
545 this.el.append( child_8.el );
546 var child_9 = new Xcls_Button23( _this );
548 this.el.append( child_9.el );
549 var child_10 = new Xcls_Separator25( _this );
551 this.el.append( child_10.el );
552 var child_11 = new Xcls_Button26( _this );
554 this.el.append( child_11.el );
555 var child_12 = new Xcls_Button28( _this );
557 this.el.append( child_12.el );
558 var child_13 = new Xcls_Button30( _this );
560 this.el.append( child_13.el );
561 var child_14 = new Xcls_Separator32( _this );
563 this.el.append( child_14.el );
564 var child_15 = new Xcls_Button33( _this );
566 this.el.append( child_15.el );
567 var child_16 = new Xcls_Button35( _this );
569 this.el.append( child_16.el );
570 var child_17 = new Xcls_Button37( _this );
572 this.el.append( child_17.el );
575 // user defined functions
577 public class Xcls_Button8 : Object
579 public Gtk.Button el;
580 private Xcls_LeftProps _this;
586 public Xcls_Button8(Xcls_LeftProps _owner )
589 this.el = new Gtk.Button();
593 // set gobject values
594 this.el.has_frame = false;
595 var child_1 = new Xcls_Label9( _this );
597 this.el.child = child_1.el;
600 this.el.clicked.connect( () => {
601 _this.addpop.el.hide();
602 // is this userdef or special??
603 var add = new JsRender.NodeProp.prop("id");
604 if (_this.node.has_prop_key(add)) {
608 _this.node.add_prop( add );
610 _this.view.editProp( add );
615 // user defined functions
617 public class Xcls_Label9 : Object
620 private Xcls_LeftProps _this;
626 public Xcls_Label9(Xcls_LeftProps _owner )
629 this.el = new Gtk.Label( "id: _this.{ID} (Vala)" );
633 // set gobject values
634 this.el.halign = Gtk.Align.START;
635 this.el.tooltip_text = "Using _this.{ID} will map to this element";
638 // user defined functions
642 public class Xcls_Button10 : Object
644 public Gtk.Button el;
645 private Xcls_LeftProps _this;
651 public Xcls_Button10(Xcls_LeftProps _owner )
654 this.el = new Gtk.Button();
658 // set gobject values
659 this.el.has_frame = false;
660 var child_1 = new Xcls_Label11( _this );
662 this.el.child = child_1.el;
665 this.el.clicked.connect( ( ) => {
668 _this.addpop.el.hide();
669 // is this userdef or special??
670 var add = new JsRender.NodeProp.special("pack", "add");
671 if (_this.node.has_prop_key(add)) {
675 _this.node.add_prop( add );
677 _this.view.editProp( add );
683 // user defined functions
685 public class Xcls_Label11 : Object
688 private Xcls_LeftProps _this;
694 public Xcls_Label11(Xcls_LeftProps _owner )
697 this.el = new Gtk.Label( "pack: Pack method (Vala)" );
701 // set gobject values
702 this.el.halign = Gtk.Align.START;
703 this.el.tooltip_text = "how to pack this element onto parent, (method, 2nd arg, 3rd arg) .. the 1st argument is filled by the element";
706 // user defined functions
710 public class Xcls_Button12 : Object
712 public Gtk.Button el;
713 private Xcls_LeftProps _this;
719 public Xcls_Button12(Xcls_LeftProps _owner )
722 this.el = new Gtk.Button();
726 // set gobject values
727 this.el.has_frame = false;
728 var child_1 = new Xcls_Label13( _this );
730 this.el.child = child_1.el;
733 this.el.clicked.connect( ( ) => {
735 _this.addpop.el.hide();
736 // is this userdef or special??
737 var add = new JsRender.NodeProp.special("ctor");
738 if (_this.node.has_prop_key(add)) {
742 _this.node.add_prop( add );
744 _this.view.editProp( add );
749 // user defined functions
751 public class Xcls_Label13 : Object
754 private Xcls_LeftProps _this;
760 public Xcls_Label13(Xcls_LeftProps _owner )
763 this.el = new Gtk.Label( "ctor: Alterative to default contructor (Vala)" );
767 // set gobject values
768 this.el.halign = Gtk.Align.START;
769 this.el.tooltip_text = "eg. \n\nnew Clutter.Image.from_file(.....)";
772 // user defined functions
776 public class Xcls_Button14 : Object
778 public Gtk.Button el;
779 private Xcls_LeftProps _this;
785 public Xcls_Button14(Xcls_LeftProps _owner )
788 this.el = new Gtk.Button();
792 // set gobject values
793 this.el.has_frame = false;
794 var child_1 = new Xcls_Label15( _this );
796 this.el.child = child_1.el;
799 this.el.clicked.connect( ( ) => {
801 _this.addpop.el.hide();
802 // is this userdef or special??
803 var add = new JsRender.NodeProp.special("init","{\n\n}\n" ) ;
804 if (_this.node.has_prop_key(add)) {
808 _this.node.add_prop( add );
810 _this.view.editProp( add );
814 // user defined functions
816 public class Xcls_Label15 : Object
819 private Xcls_LeftProps _this;
825 public Xcls_Label15(Xcls_LeftProps _owner )
828 this.el = new Gtk.Label( "init: initialziation code (vala)" );
832 // set gobject values
833 this.el.halign = Gtk.Align.START;
834 this.el.tooltip_text = "This code is called after the ctor";
837 // user defined functions
841 public class Xcls_Button16 : Object
843 public Gtk.Button el;
844 private Xcls_LeftProps _this;
850 public Xcls_Button16(Xcls_LeftProps _owner )
853 this.el = new Gtk.Button();
857 // set gobject values
858 this.el.has_frame = false;
859 var child_1 = new Xcls_Label17( _this );
861 this.el.child = child_1.el;
864 this.el.clicked.connect( () => {
865 _this.addpop.el.hide();
867 // is this userdef or special??
868 var add = new JsRender.NodeProp.prop("cms-id","string", "" ) ;
869 if (_this.node.has_prop_key(add)) {
873 _this.node.add_prop( add );
875 _this.view.editProp( add );
880 // user defined functions
882 public class Xcls_Label17 : Object
885 private Xcls_LeftProps _this;
891 public Xcls_Label17(Xcls_LeftProps _owner )
894 this.el = new Gtk.Label( "cms-id: (Roo JS/Pman library)" );
898 // set gobject values
899 this.el.halign = Gtk.Align.START;
900 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";
903 // user defined functions
907 public class Xcls_Separator18 : Object
909 public Gtk.Separator el;
910 private Xcls_LeftProps _this;
916 public Xcls_Separator18(Xcls_LeftProps _owner )
919 this.el = new Gtk.Separator( Gtk.Orientation.HORIZONTAL );
923 // set gobject values
926 // user defined functions
929 public class Xcls_Button19 : Object
931 public Gtk.Button el;
932 private Xcls_LeftProps _this;
938 public Xcls_Button19(Xcls_LeftProps _owner )
941 this.el = new Gtk.Button();
945 // set gobject values
946 this.el.has_frame = false;
947 var child_1 = new Xcls_Label20( _this );
949 this.el.child = child_1.el;
952 this.el.clicked.connect( (self) => {
953 _this.addpop.el.hide();
954 _this.view.popover.show(
957 new JsRender.NodeProp.user("", "string", "") ,
965 // user defined functions
967 public class Xcls_Label20 : Object
970 private Xcls_LeftProps _this;
976 public Xcls_Label20(Xcls_LeftProps _owner )
979 this.el = new Gtk.Label( "String" );
983 // set gobject values
984 this.el.halign = Gtk.Align.START;
985 this.el.tooltip_text = "Add a user defined string property";
988 // user defined functions
992 public class Xcls_Button21 : Object
994 public Gtk.Button el;
995 private Xcls_LeftProps _this;
1001 public Xcls_Button21(Xcls_LeftProps _owner )
1004 this.el = new Gtk.Button();
1008 // set gobject values
1009 this.el.has_frame = false;
1010 var child_1 = new Xcls_Label22( _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.user("", "int", "0") ,
1029 // user defined functions
1031 public class Xcls_Label22 : Object
1033 public Gtk.Label el;
1034 private Xcls_LeftProps _this;
1040 public Xcls_Label22(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_Button23 : Object
1058 public Gtk.Button el;
1059 private Xcls_LeftProps _this;
1065 public Xcls_Button23(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_Label24( _this );
1076 this.el.child = child_1.el;
1079 this.el.clicked.connect( ( ) =>{
1081 _this.addpop.el.hide();
1082 _this.view.popover.show(
1085 new JsRender.NodeProp.user("", "bool", "true") ,
1093 // user defined functions
1095 public class Xcls_Label24 : Object
1097 public Gtk.Label el;
1098 private Xcls_LeftProps _this;
1104 public Xcls_Label24(Xcls_LeftProps _owner )
1107 this.el = new Gtk.Label( "Boolean" );
1111 // set gobject values
1112 this.el.halign = Gtk.Align.START;
1113 this.el.tooltip_text = "Add a user defined boolean property";
1116 // user defined functions
1120 public class Xcls_Separator25 : Object
1122 public Gtk.Separator el;
1123 private Xcls_LeftProps _this;
1129 public Xcls_Separator25(Xcls_LeftProps _owner )
1132 this.el = new Gtk.Separator( Gtk.Orientation.HORIZONTAL );
1136 // set gobject values
1139 // user defined functions
1142 public class Xcls_Button26 : Object
1144 public Gtk.Button el;
1145 private Xcls_LeftProps _this;
1151 public Xcls_Button26(Xcls_LeftProps _owner )
1154 this.el = new Gtk.Button();
1158 // set gobject values
1159 this.el.has_frame = false;
1160 var child_1 = new Xcls_Label27( _this );
1162 this.el.child = child_1.el;
1165 this.el.clicked.connect( ( ) =>{
1166 _this.addpop.el.hide();
1167 _this.view.popover.show(
1170 new JsRender.NodeProp.jsmethod("") ,
1179 // user defined functions
1181 public class Xcls_Label27 : Object
1183 public Gtk.Label el;
1184 private Xcls_LeftProps _this;
1190 public Xcls_Label27(Xcls_LeftProps _owner )
1193 this.el = new Gtk.Label( "Javascript Function" );
1197 // set gobject values
1198 this.el.halign = Gtk.Align.START;
1199 this.el.tooltip_text = "Add a javascript function";
1202 // user defined functions
1206 public class Xcls_Button28 : Object
1208 public Gtk.Button el;
1209 private Xcls_LeftProps _this;
1215 public Xcls_Button28(Xcls_LeftProps _owner )
1218 this.el = new Gtk.Button();
1222 // set gobject values
1223 this.el.has_frame = false;
1224 var child_1 = new Xcls_Label29( _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_Label29 : Object
1245 public Gtk.Label el;
1246 private Xcls_LeftProps _this;
1252 public Xcls_Label29(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_Button30 : Object
1270 public Gtk.Button el;
1271 private Xcls_LeftProps _this;
1277 public Xcls_Button30(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_Label31( _this );
1288 this.el.child = child_1.el;
1291 this.el.clicked.connect( ( ) =>{
1292 _this.addpop.el.hide();
1293 _this.view.popover.show(
1296 new JsRender.NodeProp.sig("" ) ,
1303 // user defined functions
1305 public class Xcls_Label31 : Object
1307 public Gtk.Label el;
1308 private Xcls_LeftProps _this;
1314 public Xcls_Label31(Xcls_LeftProps _owner )
1317 this.el = new Gtk.Label( "Vala Signal" );
1321 // set gobject values
1322 this.el.halign = Gtk.Align.START;
1323 this.el.tooltip_text = "Add a user defined signal to a object";
1326 // user defined functions
1330 public class Xcls_Separator32 : Object
1332 public Gtk.Separator el;
1333 private Xcls_LeftProps _this;
1339 public Xcls_Separator32(Xcls_LeftProps _owner )
1342 this.el = new Gtk.Separator( Gtk.Orientation.HORIZONTAL );
1346 // set gobject values
1349 // user defined functions
1352 public class Xcls_Button33 : Object
1354 public Gtk.Button el;
1355 private Xcls_LeftProps _this;
1361 public Xcls_Button33(Xcls_LeftProps _owner )
1364 this.el = new Gtk.Button();
1368 // set gobject values
1369 this.el.has_frame = false;
1370 var child_1 = new Xcls_Label34( _this );
1372 this.el.child = child_1.el;
1375 this.el.clicked.connect( ( ) =>{
1376 _this.addpop.el.hide();
1377 _this.view.popover.show(
1380 new JsRender.NodeProp.prop("flexy:if", "string", "value_or_condition") ,
1389 // user defined functions
1391 public class Xcls_Label34 : Object
1393 public Gtk.Label el;
1394 private Xcls_LeftProps _this;
1400 public Xcls_Label34(Xcls_LeftProps _owner )
1403 this.el = new Gtk.Label( "Flexy - If" );
1407 // set gobject values
1408 this.el.halign = Gtk.Align.START;
1409 this.el.tooltip_text = "Add a flexy if (for HTML templates)";
1412 // user defined functions
1416 public class Xcls_Button35 : Object
1418 public Gtk.Button el;
1419 private Xcls_LeftProps _this;
1425 public Xcls_Button35(Xcls_LeftProps _owner )
1428 this.el = new Gtk.Button();
1432 // set gobject values
1433 this.el.has_frame = false;
1434 var child_1 = new Xcls_Label36( _this );
1436 this.el.child = child_1.el;
1439 this.el.clicked.connect( ( ) =>{
1440 _this.addpop.el.hide();
1441 _this.view.popover.show(
1444 new JsRender.NodeProp.prop("flexy:include", "string", "name_of_file.html") ,
1453 // user defined functions
1455 public class Xcls_Label36 : Object
1457 public Gtk.Label el;
1458 private Xcls_LeftProps _this;
1464 public Xcls_Label36(Xcls_LeftProps _owner )
1467 this.el = new Gtk.Label( "Flexy - Include" );
1471 // set gobject values
1472 this.el.halign = Gtk.Align.START;
1473 this.el.tooltip_text = "Add a flexy include (for HTML templates)";
1476 // user defined functions
1480 public class Xcls_Button37 : Object
1482 public Gtk.Button el;
1483 private Xcls_LeftProps _this;
1489 public Xcls_Button37(Xcls_LeftProps _owner )
1492 this.el = new Gtk.Button();
1496 // set gobject values
1497 this.el.has_frame = false;
1498 this.el.tooltip_markup = "Add a flexy include (for HTML templates)";
1499 var child_1 = new Xcls_Label38( _this );
1501 this.el.child = child_1.el;
1504 this.el.clicked.connect( ( ) =>{
1505 _this.addpop.el.hide();
1506 _this.view.popover.show(
1509 new JsRender.NodeProp.prop("flexy:if", "string", "value_or_condition") ,
1517 // user defined functions
1519 public class Xcls_Label38 : Object
1521 public Gtk.Label el;
1522 private Xcls_LeftProps _this;
1528 public Xcls_Label38(Xcls_LeftProps _owner )
1531 this.el = new Gtk.Label( "Flexy - Foreach" );
1535 // set gobject values
1536 this.el.halign = Gtk.Align.START;
1537 this.el.tooltip_text = "Add a flexy foreach (for HTML templates)";
1540 // user defined functions
1548 public class Xcls_EditProps : Object
1550 public Gtk.ScrolledWindow el;
1551 private Xcls_LeftProps _this;
1555 public bool editing;
1558 public Xcls_EditProps(Xcls_LeftProps _owner )
1561 _this.EditProps = this;
1562 this.el = new Gtk.ScrolledWindow();
1565 this.editing = false;
1567 // set gobject values
1568 this.el.hexpand = true;
1569 this.el.vexpand = true;
1570 new Xcls_view( _this );
1571 this.el.set_child ( _this.view.el );
1577 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
1581 // user defined functions
1583 public class Xcls_view : Object
1585 public Gtk.ColumnView el;
1586 private Xcls_LeftProps _this;
1590 public Xcls_PopoverProperty popover;
1593 public Xcls_view(Xcls_LeftProps _owner )
1597 new Xcls_selmodel( _this );
1598 this.el = new Gtk.ColumnView( _this.selmodel.el );
1601 this.popover = null;
1603 // set gobject values
1604 this.el.name = "leftprops-view";
1605 this.el.single_click_activate = false;
1606 this.el.hexpand = true;
1607 this.el.vexpand = true;
1608 this.el.show_row_separators = true;
1609 new Xcls_deletemenu( _this );
1610 var child_3 = new Xcls_GestureClick45( _this );
1612 this.el.add_controller( child_3.el );
1613 var child_4 = new Xcls_GestureClick46( _this );
1615 this.el.add_controller( child_4.el );
1616 new Xcls_keycol( _this );
1617 this.el.append_column ( _this.keycol.el );
1618 new Xcls_valcol( _this );
1619 this.el.append_column ( _this.valcol.el );
1620 new Xcls_ContextMenu( _this );
1623 // user defined functions
1624 public Gtk.Widget? getWidgetAtRow (uint row) {
1627 from https://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465
1628 var colview = gesture.widget;
1629 var line_no = check_list_widget(colview, x,y);
1631 var item = colview.model.get_item(line_no);
1635 //GLib.debug("Get Widget At Row %d", (int)row);
1636 var child = this.el.get_first_child();
1638 var reading_header = true;
1640 while (child != null) {
1641 //GLib.debug("Got %s", child.get_type().name());
1642 if (reading_header) {
1645 if (child.get_type().name() != "GtkColumnListView") {
1646 child = child.get_next_sibling();
1649 child = child.get_first_child();
1650 reading_header = false;
1653 if (child.get_type().name() != "GtkColumnViewRowWidget") {
1654 child = child.get_next_sibling();
1658 if (line_no == row) {
1659 //GLib.debug("Returning widget %s", child.get_type().name());
1660 return (Gtk.Widget)child;
1662 child = child.get_next_sibling();
1664 //GLib.debug("Rturning null");
1668 public void editProp (JsRender.NodeProp prop)
1670 var sm = _this.selmodel.el;
1673 GLib.debug("finding node");
1674 _this.selmodel.selectProp(prop);
1676 for (var i = 0 ; i < sm.n_items; i++) {
1677 var r = (JsRender.NodeProp)sm.get_item(i);
1678 if (r.equals(prop)) {
1684 GLib.debug("finding node - cant find it");
1688 var r = this.getWidgetAtRow(sr);
1689 GLib.debug("r = %s", r.get_type().name());
1690 var ca = r.get_first_child();
1691 var ll = (Gtk.Label)ca.get_first_child();
1692 var cb = ca.get_next_sibling();
1693 var b = cb.get_first_child();
1694 var e = (Gtk.EditableLabel) b.get_first_child();
1695 var l = (Gtk.Label) e.get_next_sibling();
1696 var d = (Gtk.DropDown) l.get_next_sibling();
1698 GLib.debug("row key = %s", ll.label);
1699 if (e.get_visible()) {
1700 _this.stop_editor();
1702 //GLib.Timeout.add_once(500, () => {
1703 // var st = (Gtk.Stack) e.get_first_child();
1704 // var ed = (Gtk.Entry) st.get_visible_child();
1705 // ed.grab_focus_without_selecting();
1709 if (d.get_visible()) {
1710 _this.stop_editor();
1714 if (l.get_visible()) {
1715 _this.stop_editor();
1716 _this.show_editor(_this.file, prop.parent, prop);
1722 //gtkcolumnviewrowwidget
1726 // entry / label / dropdown
1730 public int getColAt (double x, double y) {
1733 from https://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465
1736 //Gtk.Allocation alloc = { 0, 0, 0, 0 };
1737 var child = this.el.get_first_child();
1741 while (child != null) {
1742 GLib.debug("Got %s", child.get_type().name());
1744 if (child.get_type().name() == "GtkColumnViewRowWidget") {
1745 child = child.get_first_child();
1749 //child.get_allocation(out alloc);
1750 if (x < (child.get_width() + offx)) {
1753 offx += child.get_width();
1755 child = child.get_next_sibling();
1762 public int getRowAt (double x, double y, out string pos) {
1765 var w = this.el.pick(x, y, Gtk.PickFlags.DEFAULT);
1766 //GLib.debug("got widget %s", w == null ? "nothing" : w.get_type().name());
1771 var row= w.get_ancestor(GLib.Type.from_name("GtkColumnViewRowWidget"));
1776 //GLib.debug("got colview %s", row == null ? "nothing" : row.get_type().name());
1781 while (cr.get_prev_sibling() != null) {
1783 cr = cr.get_prev_sibling();
1786 //GLib.debug("row number is %d", rn);
1787 //GLib.debug("click %d, %d", (int)x, (int)y);
1789 Graphene.Rect bounds;
1790 row.compute_bounds(this.el, out bounds);
1791 //GLib.debug("click x=%d, y=%d, w=%d, h=%d",
1792 // (int)bounds.get_x(), (int)bounds.get_y(),
1793 // (int)bounds.get_width(), (int)bounds.get_height()
1795 var ypos = y - bounds.get_y();
1796 //GLib.debug("rel ypos = %d", (int)ypos);
1797 var rpos = 100.0 * (ypos / bounds.get_height());
1798 //GLib.debug("rel pos = %d %%", (int)rpos);
1803 } else if (rpos < 20) {
1809 public class Xcls_deletemenu : Object
1811 public Gtk.Popover el;
1812 private Xcls_LeftProps _this;
1818 public Xcls_deletemenu(Xcls_LeftProps _owner )
1821 _this.deletemenu = this;
1822 this.el = new Gtk.Popover();
1826 // set gobject values
1827 var child_1 = new Xcls_Box42( _this );
1829 this.el.child = child_1.el;
1832 // user defined functions
1834 public class Xcls_Box42 : Object
1837 private Xcls_LeftProps _this;
1843 public Xcls_Box42(Xcls_LeftProps _owner )
1846 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
1850 // set gobject values
1851 var child_1 = new Xcls_Button43( _this );
1853 this.el.append( child_1.el );
1856 // user defined functions
1858 public class Xcls_Button43 : Object
1860 public Gtk.Button el;
1861 private Xcls_LeftProps _this;
1867 public Xcls_Button43(Xcls_LeftProps _owner )
1870 this.el = new Gtk.Button();
1874 // set gobject values
1875 this.el.has_frame = false;
1876 this.el.label = "Delete";
1877 var child_1 = new Xcls_Label44( _this );
1879 this.el.child = child_1.el;
1882 this.el.clicked.connect( ( ) => {
1885 var n = (JsRender.NodeProp) _this.selmodel.el.selected_item;
1887 _this.deletemenu.el.hide();
1888 _this.node.remove_prop(n);
1892 // user defined functions
1894 public class Xcls_Label44 : Object
1896 public Gtk.Label el;
1897 private Xcls_LeftProps _this;
1903 public Xcls_Label44(Xcls_LeftProps _owner )
1906 this.el = new Gtk.Label( "Delete Property / Method" );
1910 // set gobject values
1911 this.el.halign = Gtk.Align.START;
1914 // user defined functions
1920 public class Xcls_GestureClick45 : Object
1922 public Gtk.GestureClick el;
1923 private Xcls_LeftProps _this;
1929 public Xcls_GestureClick45(Xcls_LeftProps _owner )
1932 this.el = new Gtk.GestureClick();
1936 // set gobject values
1939 this.el.pressed.connect( (n_press, in_x, in_y) => {
1941 GLib.debug("Prssed %d", (int) this.el.get_current_button());
1943 var col = _this.view.getColAt(in_x, in_y);
1948 var row = _this.view.getRowAt(in_x, in_y, out pos);
1954 GLib.debug("hit row %d", row);
1955 var prop = _this.selmodel.getPropAt(row);
1956 _this.selmodel.selectProp(prop);
1958 //var point_at = _this.view.getWidgetAtRow(row);
1960 // need to shift down, as ev.y does not inclucde header apparently..
1961 // or popover might be trying to do a central?
1962 // _this.view.editPropertyDetails(prop, (int) in_y + 12);
1963 _this.stop_editor();
1964 _this.view.popover.show(
1974 // user defined functions
1977 public class Xcls_GestureClick46 : Object
1979 public Gtk.GestureClick el;
1980 private Xcls_LeftProps _this;
1986 public Xcls_GestureClick46(Xcls_LeftProps _owner )
1989 this.el = new Gtk.GestureClick();
1993 // set gobject values
1997 this.el.pressed.connect( (n_press, in_x, in_y) => {
2002 var row = _this.view.getRowAt(in_x, in_y, out pos);
2009 _this.stop_editor();
2010 GLib.debug("hit row %d", row);
2011 var prop = _this.selmodel.getPropAt(row);
2012 _this.selmodel.selectProp(prop);
2016 GLib.debug("Prssed %d", (int) this.el.get_current_button());
2017 //_this.deletemenu.el.set_parent(_this.view.el);
2018 if (_this.deletemenu.el.parent == null) {
2019 _this.deletemenu.el.set_parent(_this.main_window.el);
2024 _this.deletemenu.el.set_offset(
2025 (int)in_x - _this.view.el.get_width() ,
2026 (int)in_y - _this.view.el.get_height()
2028 _this.deletemenu.el.set_position(Gtk.PositionType.BOTTOM);
2029 _this.deletemenu.el.popup();
2034 // user defined functions
2037 public class Xcls_selmodel : Object
2039 public Gtk.SingleSelection el;
2040 private Xcls_LeftProps _this;
2046 public Xcls_selmodel(Xcls_LeftProps _owner )
2049 _this.selmodel = this;
2050 new Xcls_model( _this );
2051 this.el = new Gtk.SingleSelection( _this.model.el );
2055 // set gobject values
2056 this.el.can_unselect = true;
2059 // user defined functions
2060 public int propToRow (JsRender.NodeProp prop) {
2061 for (var i = 0 ; i < this.el.n_items; i++) {
2062 var r = (JsRender.NodeProp)this.el.get_item(i);
2063 if (r.equals(prop)) {
2071 public void startEditing (JsRender.NodeProp prop) {
2072 // should we call select?? - caller does int (from windowstate)
2075 public void selectProp (JsRender.NodeProp prop) {
2076 for (var i = 0 ; i < this.el.n_items; i++) {
2077 var r = (JsRender.NodeProp)this.el.get_item(i);
2078 if (r.equals(prop)) {
2079 this.el.selected = i;
2085 public JsRender.NodeProp getPropAt (uint row) {
2087 return (JsRender.NodeProp) this.el.get_item(row);
2092 public class Xcls_model : Object
2094 public GLib.ListStore el;
2095 private Xcls_LeftProps _this;
2101 public Xcls_model(Xcls_LeftProps _owner )
2105 this.el = new GLib.ListStore(typeof(JsRender.NodeProp));
2109 // set gobject values
2112 // user defined functions
2116 public class Xcls_keycol : Object
2118 public Gtk.ColumnViewColumn el;
2119 private Xcls_LeftProps _this;
2125 public Xcls_keycol(Xcls_LeftProps _owner )
2128 _this.keycol = this;
2129 var child_1 = new Xcls_SignalListItemFactory50( _this );
2131 this.el = new Gtk.ColumnViewColumn( "Property", child_1.el );
2135 // set gobject values
2136 this.el.id = "keycol";
2137 this.el.expand = true;
2138 this.el.resizable = true;
2141 // user defined functions
2143 public class Xcls_SignalListItemFactory50 : Object
2145 public Gtk.SignalListItemFactory el;
2146 private Xcls_LeftProps _this;
2152 public Xcls_SignalListItemFactory50(Xcls_LeftProps _owner )
2155 this.el = new Gtk.SignalListItemFactory();
2159 // set gobject values
2162 this.el.setup.connect( (listitem) => {
2163 var lbl = new Gtk.Label("");
2164 ((Gtk.ListItem)listitem).set_child(lbl);
2165 lbl.justify = Gtk.Justification.LEFT;
2167 lbl.use_markup = true;
2168 lbl.ellipsize = Pango.EllipsizeMode.START;
2169 /*lbl.changed.connect(() => {
2170 // notify and save the changed value...
2171 //var prop = (JsRender.NodeProp) ((Gtk.ListItem)listitem.get_item());
2173 //prop.val = lbl.text;
2174 //_this.updateIter(iter,prop);
2178 ((Gtk.ListItem)listitem).activatable = true;
2180 this.el.bind.connect( (listitem) => {
2181 var lb = (Gtk.Label) ((Gtk.ListItem)listitem).get_child();
2182 var item = (JsRender.NodeProp) ((Gtk.ListItem)listitem).get_item();
2185 item.bind_property("to_display_name_prop",
2187 GLib.BindingFlags.SYNC_CREATE);
2188 item.bind_property("to_tooltip_name_prop",
2189 lb, "tooltip_markup",
2190 GLib.BindingFlags.SYNC_CREATE);
2191 // was item (1) in old layout
2197 // user defined functions
2201 public class Xcls_valcol : Object
2203 public Gtk.ColumnViewColumn el;
2204 private Xcls_LeftProps _this;
2210 public Xcls_valcol(Xcls_LeftProps _owner )
2213 _this.valcol = this;
2214 var child_1 = new Xcls_SignalListItemFactory52( _this );
2216 this.el = new Gtk.ColumnViewColumn( "Value", child_1.el );
2220 // set gobject values
2221 this.el.id = "valcol";
2222 this.el.expand = true;
2223 this.el.resizable = true;
2226 // user defined functions
2228 public class Xcls_SignalListItemFactory52 : Object
2230 public Gtk.SignalListItemFactory el;
2231 private Xcls_LeftProps _this;
2235 public bool is_setting;
2238 public Xcls_SignalListItemFactory52(Xcls_LeftProps _owner )
2241 this.el = new Gtk.SignalListItemFactory();
2244 this.is_setting = false;
2246 // set gobject values
2249 this.el.setup.connect( (listitem) => {
2250 var hb = new Gtk.Box(Gtk.Orientation.HORIZONTAL,0);
2251 var elbl = new Gtk.EditableLabel("");
2252 elbl.hexpand = true;
2254 var lbl = new Gtk.Label("");
2257 lbl.use_markup = true;
2259 lbl.ellipsize = Pango.EllipsizeMode.END;
2260 var cb = new Gtk.DropDown(new Gtk.StringList({}), null);
2264 ((Gtk.ListItem)listitem).set_child(hb);
2266 var ef = new Gtk.EventControllerFocus();
2267 ef.enter.connect(() => {
2268 _this.stop_editor();
2269 var prop = (JsRender.NodeProp)((Gtk.ListItem)listitem).get_item();
2270 _this.selmodel.selectProp(prop);
2272 elbl.add_controller(ef);
2275 // dropdown??? - stop editing, and highliht node
2276 var tb = (Gtk.ToggleButton) cb.get_first_child();
2277 tb.clicked.connect(() => {
2278 var prop = (JsRender.NodeProp)((Gtk.ListItem)listitem).get_item();
2280 _this.stop_editor();
2281 _this.selmodel.selectProp(prop);
2284 elbl.changed.connect(() => {
2285 // notify and save the changed value...
2287 //_this.updateIter(iter,prop);
2288 // this should happen automatically
2290 if (!_this.loading && !this.is_setting) {
2291 var prop = (JsRender.NodeProp)((Gtk.ListItem)listitem).get_item();
2294 prop.val = elbl.text;
2295 GLib.debug("calling changed");
2303 cb.notify["selected"].connect(() => {
2304 // dropdown selection changed.
2308 //_this.updateIter(iter,prop);
2309 if (!_this.loading && !this.is_setting) {
2310 var prop = (JsRender.NodeProp)((Gtk.ListItem)listitem).get_item();
2311 var model = (Gtk.StringList)cb.model;
2312 prop.val = model.get_string(cb.selected);
2313 GLib.debug("property set to %s", prop.val);
2314 GLib.debug("calling changed");
2321 var gc = new Gtk.GestureClick();
2322 lbl.add_controller(gc);
2323 gc.pressed.connect(() => {
2324 var prop = (JsRender.NodeProp)((Gtk.ListItem)listitem).get_item();
2325 _this.stop_editor();
2326 _this.show_editor(_this.file, prop.parent, prop);
2332 this.el.bind.connect( (listitem) => {
2333 this.is_setting = true;
2336 var bx = (Gtk.Box) ((Gtk.ListItem)listitem).get_child();
2341 var elbl = (Gtk.EditableLabel)bx.get_first_child();
2342 var lbl = (Gtk.Label) elbl.get_next_sibling();
2343 var cb = (Gtk.DropDown) lbl.get_next_sibling();
2344 // decide if it's a combo or editable text..
2345 var model = (Gtk.StringList) cb.model;
2351 var prop = (JsRender.NodeProp) ((Gtk.ListItem)listitem).get_item();
2352 //GLib.debug("prop = %s", prop.get_type().name());
2353 //GLib.debug("prop.val = %s", prop.val);
2354 //GLib.debug("prop.key = %s", prop.to_display_name());
2356 var use_textarea = prop.useTextArea();
2359 var pal = _this.file.project.palete;
2362 var has_opts = pal.typeOptions(_this.node.fqn(), prop.name, prop.rtype, out opts);
2364 if (!has_opts && prop.ptype == JsRender.NodePropType.RAW) {
2365 use_textarea = true;
2370 prop.bind_property("val_short",
2372 GLib.BindingFlags.SYNC_CREATE);
2373 prop.bind_property("val_tooltip",
2374 lbl, "tooltip_markup",
2375 GLib.BindingFlags.SYNC_CREATE);
2377 this.is_setting = false;
2386 // others... - fill in options for true/false?
2387 // GLib.debug (ktype.up());
2390 while(model.get_n_items() > 0) {
2394 // can not remove - hopefully always empty.
2396 for(var i = 0; i < opts.length; i ++) {
2397 model.append( opts[i]);
2398 // not sure this is a great idea...
2399 if (opts[i].down() == prop.val.down()) {
2403 GLib.debug("Set selected item to %d", sel);
2404 cb.set_selected(sel > -1 ? sel : Gtk.INVALID_LIST_POSITION);
2405 this.is_setting = false;
2409 // see if type is a Enum.
2410 // triggers a changed event
2412 elbl.set_text(prop.val);
2415 this.is_setting = false;
2424 // user defined functions
2428 public class Xcls_ContextMenu : Object
2430 public Gtk.Popover el;
2431 private Xcls_LeftProps _this;
2437 public Xcls_ContextMenu(Xcls_LeftProps _owner )
2440 _this.ContextMenu = this;
2441 this.el = new Gtk.Popover();
2445 // set gobject values
2446 var child_1 = new Xcls_Box54( _this );
2448 this.el.child = child_1.el;
2451 // user defined functions
2453 public class Xcls_Box54 : Object
2456 private Xcls_LeftProps _this;
2462 public Xcls_Box54(Xcls_LeftProps _owner )
2465 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
2469 // set gobject values
2470 var child_1 = new Xcls_Button55( _this );
2472 this.el.append( child_1.el );
2475 // user defined functions
2477 public class Xcls_Button55 : Object
2479 public Gtk.Button el;
2480 private Xcls_LeftProps _this;
2486 public Xcls_Button55(Xcls_LeftProps _owner )
2489 this.el = new Gtk.Button();
2493 // set gobject values
2494 this.el.label = "Delete";
2497 this.el.activate.connect( ( ) =>{
2498 _this.deleteSelected();
2503 // user defined functions