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");
296 this.model.el.remove_all();
298 //this.get('/RightEditor').el.hide();
300 GLib.debug("node is null return");
304 node.loadProps(this.model.el, _this.main_window.windowstate.project);
307 //GLib.debug("clear selection\n");
309 this.loading = false;
310 this.selmodel.el.set_selected(Gtk.INVALID_LIST_POSITION);
313 //this.model.el.set_sort_column_id(4,Gtk.SortType.ASCENDING); // sort by real key..
315 // this.view.el.get_selection().unselect_all();
317 // _this.keycol.el.set_max_width(_this.EditProps.el.get_allocated_width()/ 2);
318 // _this.valcol.el.set_max_width(_this.EditProps.el.get_allocated_width()/ 2);
321 public class Xcls_Box1 : Object
324 private Xcls_LeftProps _this;
330 public Xcls_Box1(Xcls_LeftProps _owner )
333 this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
337 // set gobject values
338 this.el.hexpand = true;
339 var child_1 = new Xcls_Label2( _this );
341 this.el.append( child_1.el );
342 var child_2 = new Xcls_Button3( _this );
344 this.el.append( child_2.el );
345 var child_3 = new Xcls_Button4( _this );
347 this.el.append( child_3.el );
348 var child_4 = new Xcls_MenuButton5( _this );
350 this.el.append( child_4.el );
353 // user defined functions
355 public class Xcls_Label2 : Object
358 private Xcls_LeftProps _this;
364 public Xcls_Label2(Xcls_LeftProps _owner )
367 this.el = new Gtk.Label( "Add:" );
371 // set gobject values
372 this.el.margin_end = 5;
373 this.el.margin_start = 5;
376 // user defined functions
379 public class Xcls_Button3 : Object
381 public Gtk.Button el;
382 private Xcls_LeftProps _this;
386 public bool always_show_image;
389 public Xcls_Button3(Xcls_LeftProps _owner )
392 this.el = new Gtk.Button();
395 this.always_show_image = true;
397 // set gobject values
398 this.el.icon_name = "format-justify-left";
399 this.el.hexpand = true;
400 this.el.tooltip_text = "Add Property";
401 this.el.label = "Property";
404 this.el.clicked.connect( ( ) => {
406 _this.main_window.windowstate.showProps(
408 JsRender.NodePropType.PROP
414 // user defined functions
417 public class Xcls_Button4 : Object
419 public Gtk.Button el;
420 private Xcls_LeftProps _this;
424 public bool always_show_image;
427 public Xcls_Button4(Xcls_LeftProps _owner )
430 this.el = new Gtk.Button();
433 this.always_show_image = true;
435 // set gobject values
436 this.el.icon_name = "appointment-new";
437 this.el.hexpand = true;
438 this.el.tooltip_text = "Add Event Code";
439 this.el.label = "Event";
442 this.el.clicked.connect( ( ) => {
445 _this.main_window.windowstate.showProps(
447 JsRender.NodePropType.LISTENER
454 // user defined functions
457 public class Xcls_MenuButton5 : Object
459 public Gtk.MenuButton el;
460 private Xcls_LeftProps _this;
466 public Xcls_MenuButton5(Xcls_LeftProps _owner )
469 this.el = new Gtk.MenuButton();
473 // set gobject values
474 this.el.label = "Other";
475 new Xcls_addpop( _this );
476 this.el.popover = _this.addpop.el;
479 // user defined functions
481 public class Xcls_addpop : Object
483 public Gtk.Popover el;
484 private Xcls_LeftProps _this;
490 public Xcls_addpop(Xcls_LeftProps _owner )
494 this.el = new Gtk.Popover();
498 // set gobject values
499 var child_1 = new Xcls_Box7( _this );
501 this.el.child = child_1.el;
504 // user defined functions
506 public class Xcls_Box7 : Object
509 private Xcls_LeftProps _this;
515 public Xcls_Box7(Xcls_LeftProps _owner )
518 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
522 // set gobject values
523 var child_1 = new Xcls_Button8( _this );
525 this.el.append( child_1.el );
526 var child_2 = new Xcls_Button10( _this );
528 this.el.append( child_2.el );
529 var child_3 = new Xcls_Button12( _this );
531 this.el.append( child_3.el );
532 var child_4 = new Xcls_Button14( _this );
534 this.el.append( child_4.el );
535 var child_5 = new Xcls_Button16( _this );
537 this.el.append( child_5.el );
538 var child_6 = new Xcls_Separator18( _this );
540 this.el.append( child_6.el );
541 var child_7 = new Xcls_Button19( _this );
543 this.el.append( child_7.el );
544 var child_8 = new Xcls_Button21( _this );
546 this.el.append( child_8.el );
547 var child_9 = new Xcls_Button23( _this );
549 this.el.append( child_9.el );
550 var child_10 = new Xcls_Separator25( _this );
552 this.el.append( child_10.el );
553 var child_11 = new Xcls_Button26( _this );
555 this.el.append( child_11.el );
556 var child_12 = new Xcls_Button28( _this );
558 this.el.append( child_12.el );
559 var child_13 = new Xcls_Button30( _this );
561 this.el.append( child_13.el );
562 var child_14 = new Xcls_Separator32( _this );
564 this.el.append( child_14.el );
565 var child_15 = new Xcls_Button33( _this );
567 this.el.append( child_15.el );
568 var child_16 = new Xcls_Button35( _this );
570 this.el.append( child_16.el );
571 var child_17 = new Xcls_Button37( _this );
573 this.el.append( child_17.el );
576 // user defined functions
578 public class Xcls_Button8 : Object
580 public Gtk.Button el;
581 private Xcls_LeftProps _this;
587 public Xcls_Button8(Xcls_LeftProps _owner )
590 this.el = new Gtk.Button();
594 // set gobject values
595 this.el.has_frame = false;
596 var child_1 = new Xcls_Label9( _this );
598 this.el.child = child_1.el;
601 this.el.clicked.connect( () => {
602 _this.addpop.el.hide();
603 // is this userdef or special??
604 var add = new JsRender.NodeProp.prop("id");
605 if (_this.node.has_prop_key(add)) {
609 _this.node.add_prop( add );
611 _this.view.editProp( add );
616 // user defined functions
618 public class Xcls_Label9 : Object
621 private Xcls_LeftProps _this;
627 public Xcls_Label9(Xcls_LeftProps _owner )
630 this.el = new Gtk.Label( "id: _this.{ID} (Vala)" );
634 // set gobject values
635 this.el.halign = Gtk.Align.START;
636 this.el.tooltip_text = "Using _this.{ID} will map to this element";
639 // user defined functions
643 public class Xcls_Button10 : Object
645 public Gtk.Button el;
646 private Xcls_LeftProps _this;
652 public Xcls_Button10(Xcls_LeftProps _owner )
655 this.el = new Gtk.Button();
659 // set gobject values
660 this.el.has_frame = false;
661 var child_1 = new Xcls_Label11( _this );
663 this.el.child = child_1.el;
666 this.el.clicked.connect( ( ) => {
669 _this.addpop.el.hide();
670 // is this userdef or special??
671 var add = new JsRender.NodeProp.special("pack", "add");
672 if (_this.node.has_prop_key(add)) {
676 _this.node.add_prop( add );
678 _this.view.editProp( add );
684 // user defined functions
686 public class Xcls_Label11 : Object
689 private Xcls_LeftProps _this;
695 public Xcls_Label11(Xcls_LeftProps _owner )
698 this.el = new Gtk.Label( "pack: Pack method (Vala)" );
702 // set gobject values
703 this.el.halign = Gtk.Align.START;
704 this.el.tooltip_text = "how to pack this element onto parent, (method, 2nd arg, 3rd arg) .. the 1st argument is filled by the element";
707 // user defined functions
711 public class Xcls_Button12 : Object
713 public Gtk.Button el;
714 private Xcls_LeftProps _this;
720 public Xcls_Button12(Xcls_LeftProps _owner )
723 this.el = new Gtk.Button();
727 // set gobject values
728 this.el.has_frame = false;
729 var child_1 = new Xcls_Label13( _this );
731 this.el.child = child_1.el;
734 this.el.clicked.connect( ( ) => {
736 _this.addpop.el.hide();
737 // is this userdef or special??
738 var add = new JsRender.NodeProp.special("ctor");
739 if (_this.node.has_prop_key(add)) {
743 _this.node.add_prop( add );
745 _this.view.editProp( add );
750 // user defined functions
752 public class Xcls_Label13 : Object
755 private Xcls_LeftProps _this;
761 public Xcls_Label13(Xcls_LeftProps _owner )
764 this.el = new Gtk.Label( "ctor: Alterative to default contructor (Vala)" );
768 // set gobject values
769 this.el.halign = Gtk.Align.START;
770 this.el.tooltip_text = "eg. \n\nnew Clutter.Image.from_file(.....)";
773 // user defined functions
777 public class Xcls_Button14 : Object
779 public Gtk.Button el;
780 private Xcls_LeftProps _this;
786 public Xcls_Button14(Xcls_LeftProps _owner )
789 this.el = new Gtk.Button();
793 // set gobject values
794 this.el.has_frame = false;
795 var child_1 = new Xcls_Label15( _this );
797 this.el.child = child_1.el;
800 this.el.clicked.connect( ( ) => {
802 _this.addpop.el.hide();
803 // is this userdef or special??
804 var add = new JsRender.NodeProp.special("init","{\n\n}\n" ) ;
805 if (_this.node.has_prop_key(add)) {
809 _this.node.add_prop( add );
811 _this.view.editProp( add );
815 // user defined functions
817 public class Xcls_Label15 : Object
820 private Xcls_LeftProps _this;
826 public Xcls_Label15(Xcls_LeftProps _owner )
829 this.el = new Gtk.Label( "init: initialziation code (vala)" );
833 // set gobject values
834 this.el.halign = Gtk.Align.START;
835 this.el.tooltip_text = "This code is called after the ctor";
838 // user defined functions
842 public class Xcls_Button16 : Object
844 public Gtk.Button el;
845 private Xcls_LeftProps _this;
851 public Xcls_Button16(Xcls_LeftProps _owner )
854 this.el = new Gtk.Button();
858 // set gobject values
859 this.el.has_frame = false;
860 var child_1 = new Xcls_Label17( _this );
862 this.el.child = child_1.el;
865 this.el.clicked.connect( () => {
866 _this.addpop.el.hide();
868 // is this userdef or special??
869 var add = new JsRender.NodeProp.prop("cms-id","string", "" ) ;
870 if (_this.node.has_prop_key(add)) {
874 _this.node.add_prop( add );
876 _this.view.editProp( add );
881 // user defined functions
883 public class Xcls_Label17 : Object
886 private Xcls_LeftProps _this;
892 public Xcls_Label17(Xcls_LeftProps _owner )
895 this.el = new Gtk.Label( "cms-id: (Roo JS/Pman library)" );
899 // set gobject values
900 this.el.halign = Gtk.Align.START;
901 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";
904 // user defined functions
908 public class Xcls_Separator18 : Object
910 public Gtk.Separator el;
911 private Xcls_LeftProps _this;
917 public Xcls_Separator18(Xcls_LeftProps _owner )
920 this.el = new Gtk.Separator( Gtk.Orientation.HORIZONTAL );
924 // set gobject values
927 // user defined functions
930 public class Xcls_Button19 : Object
932 public Gtk.Button el;
933 private Xcls_LeftProps _this;
939 public Xcls_Button19(Xcls_LeftProps _owner )
942 this.el = new Gtk.Button();
946 // set gobject values
947 this.el.has_frame = false;
948 var child_1 = new Xcls_Label20( _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.user("", "string", "") ,
966 // user defined functions
968 public class Xcls_Label20 : Object
971 private Xcls_LeftProps _this;
977 public Xcls_Label20(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_Button21 : Object
995 public Gtk.Button el;
996 private Xcls_LeftProps _this;
1002 public Xcls_Button21(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_Label22( _this );
1013 this.el.child = child_1.el;
1016 this.el.clicked.connect( ( ) =>{
1018 _this.addpop.el.hide();
1019 _this.view.popover.show(
1022 new JsRender.NodeProp.user("", "int", "0") ,
1030 // user defined functions
1032 public class Xcls_Label22 : Object
1034 public Gtk.Label el;
1035 private Xcls_LeftProps _this;
1041 public Xcls_Label22(Xcls_LeftProps _owner )
1044 this.el = new Gtk.Label( "Number" );
1048 // set gobject values
1049 this.el.halign = Gtk.Align.START;
1050 this.el.tooltip_text = "Add a user defined number property";
1053 // user defined functions
1057 public class Xcls_Button23 : Object
1059 public Gtk.Button el;
1060 private Xcls_LeftProps _this;
1066 public Xcls_Button23(Xcls_LeftProps _owner )
1069 this.el = new Gtk.Button();
1073 // set gobject values
1074 this.el.has_frame = false;
1075 var child_1 = new Xcls_Label24( _this );
1077 this.el.child = child_1.el;
1080 this.el.clicked.connect( ( ) =>{
1082 _this.addpop.el.hide();
1083 _this.view.popover.show(
1086 new JsRender.NodeProp.user("", "bool", "true") ,
1094 // user defined functions
1096 public class Xcls_Label24 : Object
1098 public Gtk.Label el;
1099 private Xcls_LeftProps _this;
1105 public Xcls_Label24(Xcls_LeftProps _owner )
1108 this.el = new Gtk.Label( "Boolean" );
1112 // set gobject values
1113 this.el.halign = Gtk.Align.START;
1114 this.el.tooltip_text = "Add a user defined boolean property";
1117 // user defined functions
1121 public class Xcls_Separator25 : Object
1123 public Gtk.Separator el;
1124 private Xcls_LeftProps _this;
1130 public Xcls_Separator25(Xcls_LeftProps _owner )
1133 this.el = new Gtk.Separator( Gtk.Orientation.HORIZONTAL );
1137 // set gobject values
1140 // user defined functions
1143 public class Xcls_Button26 : Object
1145 public Gtk.Button el;
1146 private Xcls_LeftProps _this;
1152 public Xcls_Button26(Xcls_LeftProps _owner )
1155 this.el = new Gtk.Button();
1159 // set gobject values
1160 this.el.has_frame = false;
1161 var child_1 = new Xcls_Label27( _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_Label27 : Object
1184 public Gtk.Label el;
1185 private Xcls_LeftProps _this;
1191 public Xcls_Label27(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_Button28 : Object
1209 public Gtk.Button el;
1210 private Xcls_LeftProps _this;
1216 public Xcls_Button28(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_Label29( _this );
1227 this.el.child = child_1.el;
1230 this.el.clicked.connect( ( ) =>{
1231 _this.addpop.el.hide();
1232 _this.view.popover.show(
1235 new JsRender.NodeProp.valamethod("") ,
1242 // user defined functions
1244 public class Xcls_Label29 : Object
1246 public Gtk.Label el;
1247 private Xcls_LeftProps _this;
1253 public Xcls_Label29(Xcls_LeftProps _owner )
1256 this.el = new Gtk.Label( "Vala Method" );
1260 // set gobject values
1261 this.el.halign = Gtk.Align.START;
1262 this.el.tooltip_text = "Add a user defined method to a object";
1265 // user defined functions
1269 public class Xcls_Button30 : Object
1271 public Gtk.Button el;
1272 private Xcls_LeftProps _this;
1278 public Xcls_Button30(Xcls_LeftProps _owner )
1281 this.el = new Gtk.Button();
1285 // set gobject values
1286 this.el.has_frame = false;
1287 var child_1 = new Xcls_Label31( _this );
1289 this.el.child = child_1.el;
1292 this.el.clicked.connect( ( ) =>{
1293 _this.addpop.el.hide();
1294 _this.view.popover.show(
1297 new JsRender.NodeProp.sig("" ) ,
1304 // user defined functions
1306 public class Xcls_Label31 : Object
1308 public Gtk.Label el;
1309 private Xcls_LeftProps _this;
1315 public Xcls_Label31(Xcls_LeftProps _owner )
1318 this.el = new Gtk.Label( "Vala Signal" );
1322 // set gobject values
1323 this.el.halign = Gtk.Align.START;
1324 this.el.tooltip_text = "Add a user defined signal to a object";
1327 // user defined functions
1331 public class Xcls_Separator32 : Object
1333 public Gtk.Separator el;
1334 private Xcls_LeftProps _this;
1340 public Xcls_Separator32(Xcls_LeftProps _owner )
1343 this.el = new Gtk.Separator( Gtk.Orientation.HORIZONTAL );
1347 // set gobject values
1350 // user defined functions
1353 public class Xcls_Button33 : Object
1355 public Gtk.Button el;
1356 private Xcls_LeftProps _this;
1362 public Xcls_Button33(Xcls_LeftProps _owner )
1365 this.el = new Gtk.Button();
1369 // set gobject values
1370 this.el.has_frame = false;
1371 var child_1 = new Xcls_Label34( _this );
1373 this.el.child = child_1.el;
1376 this.el.clicked.connect( ( ) =>{
1377 _this.addpop.el.hide();
1378 _this.view.popover.show(
1381 new JsRender.NodeProp.prop("flexy:if", "string", "value_or_condition") ,
1390 // user defined functions
1392 public class Xcls_Label34 : Object
1394 public Gtk.Label el;
1395 private Xcls_LeftProps _this;
1401 public Xcls_Label34(Xcls_LeftProps _owner )
1404 this.el = new Gtk.Label( "Flexy - If" );
1408 // set gobject values
1409 this.el.halign = Gtk.Align.START;
1410 this.el.tooltip_text = "Add a flexy if (for HTML templates)";
1413 // user defined functions
1417 public class Xcls_Button35 : Object
1419 public Gtk.Button el;
1420 private Xcls_LeftProps _this;
1426 public Xcls_Button35(Xcls_LeftProps _owner )
1429 this.el = new Gtk.Button();
1433 // set gobject values
1434 this.el.has_frame = false;
1435 var child_1 = new Xcls_Label36( _this );
1437 this.el.child = child_1.el;
1440 this.el.clicked.connect( ( ) =>{
1441 _this.addpop.el.hide();
1442 _this.view.popover.show(
1445 new JsRender.NodeProp.prop("flexy:include", "string", "name_of_file.html") ,
1454 // user defined functions
1456 public class Xcls_Label36 : Object
1458 public Gtk.Label el;
1459 private Xcls_LeftProps _this;
1465 public Xcls_Label36(Xcls_LeftProps _owner )
1468 this.el = new Gtk.Label( "Flexy - Include" );
1472 // set gobject values
1473 this.el.halign = Gtk.Align.START;
1474 this.el.tooltip_text = "Add a flexy include (for HTML templates)";
1477 // user defined functions
1481 public class Xcls_Button37 : Object
1483 public Gtk.Button el;
1484 private Xcls_LeftProps _this;
1490 public Xcls_Button37(Xcls_LeftProps _owner )
1493 this.el = new Gtk.Button();
1497 // set gobject values
1498 this.el.has_frame = false;
1499 this.el.tooltip_markup = "Add a flexy include (for HTML templates)";
1500 var child_1 = new Xcls_Label38( _this );
1502 this.el.child = child_1.el;
1505 this.el.clicked.connect( ( ) =>{
1506 _this.addpop.el.hide();
1507 _this.view.popover.show(
1510 new JsRender.NodeProp.prop("flexy:if", "string", "value_or_condition") ,
1518 // user defined functions
1520 public class Xcls_Label38 : Object
1522 public Gtk.Label el;
1523 private Xcls_LeftProps _this;
1529 public Xcls_Label38(Xcls_LeftProps _owner )
1532 this.el = new Gtk.Label( "Flexy - Foreach" );
1536 // set gobject values
1537 this.el.halign = Gtk.Align.START;
1538 this.el.tooltip_text = "Add a flexy foreach (for HTML templates)";
1541 // user defined functions
1549 public class Xcls_EditProps : Object
1551 public Gtk.ScrolledWindow el;
1552 private Xcls_LeftProps _this;
1556 public bool editing;
1559 public Xcls_EditProps(Xcls_LeftProps _owner )
1562 _this.EditProps = this;
1563 this.el = new Gtk.ScrolledWindow();
1566 this.editing = false;
1568 // set gobject values
1569 this.el.hexpand = true;
1570 this.el.vexpand = true;
1571 new Xcls_view( _this );
1572 this.el.set_child ( _this.view.el );
1578 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
1582 // user defined functions
1584 public class Xcls_view : Object
1586 public Gtk.ColumnView el;
1587 private Xcls_LeftProps _this;
1591 public Xcls_PopoverProperty popover;
1594 public Xcls_view(Xcls_LeftProps _owner )
1598 new Xcls_selmodel( _this );
1599 this.el = new Gtk.ColumnView( _this.selmodel.el );
1602 this.popover = null;
1604 // set gobject values
1605 this.el.name = "leftprops-view";
1606 this.el.single_click_activate = false;
1607 this.el.hexpand = true;
1608 this.el.vexpand = true;
1609 this.el.show_row_separators = true;
1610 new Xcls_deletemenu( _this );
1611 var child_3 = new Xcls_GestureClick45( _this );
1613 this.el.add_controller( child_3.el );
1614 var child_4 = new Xcls_GestureClick46( _this );
1616 this.el.add_controller( child_4.el );
1617 new Xcls_keycol( _this );
1618 this.el.append_column ( _this.keycol.el );
1619 new Xcls_valcol( _this );
1620 this.el.append_column ( _this.valcol.el );
1621 new Xcls_ContextMenu( _this );
1624 // user defined functions
1625 public Gtk.Widget? getWidgetAtRow (uint row) {
1628 from https://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465
1629 var colview = gesture.widget;
1630 var line_no = check_list_widget(colview, x,y);
1632 var item = colview.model.get_item(line_no);
1636 //GLib.debug("Get Widget At Row %d", (int)row);
1637 var child = this.el.get_first_child();
1639 var reading_header = true;
1641 while (child != null) {
1642 //GLib.debug("Got %s", child.get_type().name());
1643 if (reading_header) {
1646 if (child.get_type().name() != "GtkColumnListView") {
1647 child = child.get_next_sibling();
1650 child = child.get_first_child();
1651 reading_header = false;
1654 if (child.get_type().name() != "GtkColumnViewRowWidget") {
1655 child = child.get_next_sibling();
1659 if (line_no == row) {
1660 //GLib.debug("Returning widget %s", child.get_type().name());
1661 return (Gtk.Widget)child;
1663 child = child.get_next_sibling();
1665 //GLib.debug("Rturning null");
1669 public void editProp (JsRender.NodeProp prop)
1671 var sm = _this.selmodel.el;
1674 GLib.debug("finding node");
1675 _this.selmodel.selectProp(prop);
1677 for (var i = 0 ; i < sm.n_items; i++) {
1678 var r = (JsRender.NodeProp)sm.get_item(i);
1679 if (r.equals(prop)) {
1685 GLib.debug("finding node - cant find it");
1689 var r = this.getWidgetAtRow(sr);
1690 GLib.debug("r = %s", r.get_type().name());
1691 var ca = r.get_first_child();
1692 var ll = (Gtk.Label)ca.get_first_child();
1693 var cb = ca.get_next_sibling();
1694 var b = cb.get_first_child();
1695 var e = (Gtk.EditableLabel) b.get_first_child();
1696 var l = (Gtk.Label) e.get_next_sibling();
1697 var d = (Gtk.DropDown) l.get_next_sibling();
1699 GLib.debug("row key = %s", ll.label);
1700 if (e.get_visible()) {
1701 _this.stop_editor();
1703 //GLib.Timeout.add_once(500, () => {
1704 // var st = (Gtk.Stack) e.get_first_child();
1705 // var ed = (Gtk.Entry) st.get_visible_child();
1706 // ed.grab_focus_without_selecting();
1710 if (d.get_visible()) {
1711 _this.stop_editor();
1715 if (l.get_visible()) {
1716 _this.stop_editor();
1717 if (prop.parent == null) {
1720 _this.show_editor(_this.file, prop.parent, prop);
1726 //gtkcolumnviewrowwidget
1730 // entry / label / dropdown
1734 public int getColAt (double x, double y) {
1737 from https://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465
1740 //Gtk.Allocation alloc = { 0, 0, 0, 0 };
1741 var child = this.el.get_first_child();
1745 while (child != null) {
1746 GLib.debug("Got %s", child.get_type().name());
1748 if (child.get_type().name() == "GtkColumnViewRowWidget") {
1749 child = child.get_first_child();
1753 //child.get_allocation(out alloc);
1754 if (x < (child.get_width() + offx)) {
1757 offx += child.get_width();
1759 child = child.get_next_sibling();
1766 public int getRowAt (double x, double y, out string pos) {
1769 var w = this.el.pick(x, y, Gtk.PickFlags.DEFAULT);
1770 //GLib.debug("got widget %s", w == null ? "nothing" : w.get_type().name());
1775 var row= w.get_ancestor(GLib.Type.from_name("GtkColumnViewRowWidget"));
1780 //GLib.debug("got colview %s", row == null ? "nothing" : row.get_type().name());
1785 while (cr.get_prev_sibling() != null) {
1787 cr = cr.get_prev_sibling();
1790 //GLib.debug("row number is %d", rn);
1791 //GLib.debug("click %d, %d", (int)x, (int)y);
1793 Graphene.Rect bounds;
1794 row.compute_bounds(this.el, out bounds);
1795 //GLib.debug("click x=%d, y=%d, w=%d, h=%d",
1796 // (int)bounds.get_x(), (int)bounds.get_y(),
1797 // (int)bounds.get_width(), (int)bounds.get_height()
1799 var ypos = y - bounds.get_y();
1800 //GLib.debug("rel ypos = %d", (int)ypos);
1801 var rpos = 100.0 * (ypos / bounds.get_height());
1802 //GLib.debug("rel pos = %d %%", (int)rpos);
1807 } else if (rpos < 20) {
1813 public class Xcls_deletemenu : Object
1815 public Gtk.Popover el;
1816 private Xcls_LeftProps _this;
1822 public Xcls_deletemenu(Xcls_LeftProps _owner )
1825 _this.deletemenu = this;
1826 this.el = new Gtk.Popover();
1830 // set gobject values
1831 var child_1 = new Xcls_Box42( _this );
1833 this.el.child = child_1.el;
1836 // user defined functions
1838 public class Xcls_Box42 : Object
1841 private Xcls_LeftProps _this;
1847 public Xcls_Box42(Xcls_LeftProps _owner )
1850 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
1854 // set gobject values
1855 var child_1 = new Xcls_Button43( _this );
1857 this.el.append( child_1.el );
1860 // user defined functions
1862 public class Xcls_Button43 : Object
1864 public Gtk.Button el;
1865 private Xcls_LeftProps _this;
1871 public Xcls_Button43(Xcls_LeftProps _owner )
1874 this.el = new Gtk.Button();
1878 // set gobject values
1879 this.el.has_frame = false;
1880 this.el.label = "Delete";
1881 var child_1 = new Xcls_Label44( _this );
1883 this.el.child = child_1.el;
1886 this.el.clicked.connect( ( ) => {
1889 var n = (JsRender.NodeProp) _this.selmodel.el.selected_item;
1891 _this.deletemenu.el.hide();
1892 _this.node.remove_prop(n);
1896 // user defined functions
1898 public class Xcls_Label44 : Object
1900 public Gtk.Label el;
1901 private Xcls_LeftProps _this;
1907 public Xcls_Label44(Xcls_LeftProps _owner )
1910 this.el = new Gtk.Label( "Delete Property / Method" );
1914 // set gobject values
1915 this.el.halign = Gtk.Align.START;
1918 // user defined functions
1924 public class Xcls_GestureClick45 : Object
1926 public Gtk.GestureClick el;
1927 private Xcls_LeftProps _this;
1933 public Xcls_GestureClick45(Xcls_LeftProps _owner )
1936 this.el = new Gtk.GestureClick();
1940 // set gobject values
1943 this.el.pressed.connect( (n_press, in_x, in_y) => {
1945 GLib.debug("Prssed %d", (int) this.el.get_current_button());
1947 var col = _this.view.getColAt(in_x, in_y);
1952 var row = _this.view.getRowAt(in_x, in_y, out pos);
1958 GLib.debug("hit row %d", row);
1959 var prop = _this.selmodel.getPropAt(row);
1960 _this.selmodel.selectProp(prop);
1962 //var point_at = _this.view.getWidgetAtRow(row);
1964 // need to shift down, as ev.y does not inclucde header apparently..
1965 // or popover might be trying to do a central?
1966 // _this.view.editPropertyDetails(prop, (int) in_y + 12);
1967 _this.stop_editor();
1968 _this.view.popover.show(
1978 // user defined functions
1981 public class Xcls_GestureClick46 : Object
1983 public Gtk.GestureClick el;
1984 private Xcls_LeftProps _this;
1990 public Xcls_GestureClick46(Xcls_LeftProps _owner )
1993 this.el = new Gtk.GestureClick();
1997 // set gobject values
2001 this.el.pressed.connect( (n_press, in_x, in_y) => {
2006 var row = _this.view.getRowAt(in_x, in_y, out pos);
2013 _this.stop_editor();
2014 GLib.debug("hit row %d", row);
2015 var prop = _this.selmodel.getPropAt(row);
2016 _this.selmodel.selectProp(prop);
2020 GLib.debug("Prssed %d", (int) this.el.get_current_button());
2021 //_this.deletemenu.el.set_parent(_this.view.el);
2022 if (_this.deletemenu.el.parent == null) {
2023 _this.deletemenu.el.set_parent(_this.main_window.el);
2028 _this.deletemenu.el.set_offset(
2029 (int)in_x - _this.view.el.get_width() ,
2030 (int)in_y - _this.view.el.get_height()
2032 _this.deletemenu.el.set_position(Gtk.PositionType.BOTTOM);
2033 _this.deletemenu.el.popup();
2038 // user defined functions
2041 public class Xcls_selmodel : Object
2043 public Gtk.SingleSelection el;
2044 private Xcls_LeftProps _this;
2050 public Xcls_selmodel(Xcls_LeftProps _owner )
2053 _this.selmodel = this;
2054 new Xcls_model( _this );
2055 this.el = new Gtk.SingleSelection( _this.model.el );
2059 // set gobject values
2060 this.el.can_unselect = true;
2063 // user defined functions
2064 public int propToRow (JsRender.NodeProp prop) {
2065 for (var i = 0 ; i < this.el.n_items; i++) {
2066 var r = (JsRender.NodeProp)this.el.get_item(i);
2067 if (r.equals(prop)) {
2075 public void startEditing (JsRender.NodeProp prop) {
2076 // should we call select?? - caller does int (from windowstate)
2079 public void selectProp (JsRender.NodeProp prop) {
2080 for (var i = 0 ; i < this.el.n_items; i++) {
2081 var r = (JsRender.NodeProp)this.el.get_item(i);
2082 if (r.equals(prop)) {
2083 this.el.selected = i;
2089 public JsRender.NodeProp getPropAt (uint row) {
2091 return (JsRender.NodeProp) this.el.get_item(row);
2096 public class Xcls_model : Object
2098 public GLib.ListStore el;
2099 private Xcls_LeftProps _this;
2105 public Xcls_model(Xcls_LeftProps _owner )
2109 this.el = new GLib.ListStore(typeof(JsRender.NodeProp));
2113 // set gobject values
2116 // user defined functions
2120 public class Xcls_keycol : Object
2122 public Gtk.ColumnViewColumn el;
2123 private Xcls_LeftProps _this;
2129 public Xcls_keycol(Xcls_LeftProps _owner )
2132 _this.keycol = this;
2133 var child_1 = new Xcls_SignalListItemFactory50( _this );
2135 this.el = new Gtk.ColumnViewColumn( "Property", child_1.el );
2139 // set gobject values
2140 this.el.id = "keycol";
2141 this.el.expand = true;
2142 this.el.resizable = true;
2145 // user defined functions
2147 public class Xcls_SignalListItemFactory50 : Object
2149 public Gtk.SignalListItemFactory el;
2150 private Xcls_LeftProps _this;
2156 public Xcls_SignalListItemFactory50(Xcls_LeftProps _owner )
2159 this.el = new Gtk.SignalListItemFactory();
2163 // set gobject values
2166 this.el.setup.connect( (listitem) => {
2167 var lbl = new Gtk.Label("");
2168 ((Gtk.ListItem)listitem).set_child(lbl);
2169 lbl.justify = Gtk.Justification.LEFT;
2171 lbl.use_markup = true;
2172 lbl.ellipsize = Pango.EllipsizeMode.START;
2173 /*lbl.changed.connect(() => {
2174 // notify and save the changed value...
2175 //var prop = (JsRender.NodeProp) ((Gtk.ListItem)listitem.get_item());
2177 //prop.val = lbl.text;
2178 //_this.updateIter(iter,prop);
2182 ((Gtk.ListItem)listitem).activatable = true;
2184 this.el.bind.connect( (listitem) => {
2185 var lb = (Gtk.Label) ((Gtk.ListItem)listitem).get_child();
2186 var item = (JsRender.NodeProp) ((Gtk.ListItem)listitem).get_item();
2191 item.bind_property("to_display_name_prop",
2193 GLib.BindingFlags.SYNC_CREATE);
2194 item.bind_property("to_tooltip_name_prop",
2195 lb, "tooltip_markup",
2196 GLib.BindingFlags.SYNC_CREATE);
2197 // was item (1) in old layout
2203 // user defined functions
2207 public class Xcls_valcol : Object
2209 public Gtk.ColumnViewColumn el;
2210 private Xcls_LeftProps _this;
2216 public Xcls_valcol(Xcls_LeftProps _owner )
2219 _this.valcol = this;
2220 var child_1 = new Xcls_SignalListItemFactory52( _this );
2222 this.el = new Gtk.ColumnViewColumn( "Value", child_1.el );
2226 // set gobject values
2227 this.el.id = "valcol";
2228 this.el.expand = true;
2229 this.el.resizable = true;
2232 // user defined functions
2234 public class Xcls_SignalListItemFactory52 : Object
2236 public Gtk.SignalListItemFactory el;
2237 private Xcls_LeftProps _this;
2241 public bool is_setting;
2244 public Xcls_SignalListItemFactory52(Xcls_LeftProps _owner )
2247 this.el = new Gtk.SignalListItemFactory();
2250 this.is_setting = false;
2252 // set gobject values
2255 this.el.setup.connect( (listitem) => {
2256 var hb = new Gtk.Box(Gtk.Orientation.HORIZONTAL,0);
2257 var elbl = new Gtk.EditableLabel("");
2258 elbl.hexpand = true;
2260 var lbl = new Gtk.Label("");
2263 lbl.use_markup = true;
2265 lbl.ellipsize = Pango.EllipsizeMode.END;
2266 var cb = new Gtk.DropDown(new Gtk.StringList({}), null);
2270 ((Gtk.ListItem)listitem).set_child(hb);
2272 var ef = new Gtk.EventControllerFocus();
2273 ef.enter.connect(() => {
2274 _this.stop_editor();
2275 var prop = (JsRender.NodeProp)((Gtk.ListItem)listitem).get_item();
2276 _this.selmodel.selectProp(prop);
2278 elbl.add_controller(ef);
2281 // dropdown??? - stop editing, and highliht node
2282 var tb = (Gtk.ToggleButton) cb.get_first_child();
2283 tb.clicked.connect(() => {
2284 var prop = (JsRender.NodeProp)((Gtk.ListItem)listitem).get_item();
2286 _this.stop_editor();
2287 _this.selmodel.selectProp(prop);
2290 elbl.changed.connect(() => {
2291 // notify and save the changed value...
2293 //_this.updateIter(iter,prop);
2294 // this should happen automatically
2296 if (!_this.loading && !this.is_setting) {
2297 var prop = (JsRender.NodeProp)((Gtk.ListItem)listitem).get_item();
2300 prop.val = elbl.text;
2301 GLib.debug("calling changed");
2309 cb.notify["selected"].connect(() => {
2310 // dropdown selection changed.
2314 //_this.updateIter(iter,prop);
2315 if (!_this.loading && !this.is_setting) {
2316 var prop = (JsRender.NodeProp)((Gtk.ListItem)listitem).get_item();
2317 var model = (Gtk.StringList)cb.model;
2318 prop.val = model.get_string(cb.selected);
2319 GLib.debug("property set to %s", prop.val);
2320 GLib.debug("calling changed");
2327 var gc = new Gtk.GestureClick();
2328 lbl.add_controller(gc);
2329 gc.pressed.connect(() => {
2330 var prop = (JsRender.NodeProp)((Gtk.ListItem)listitem).get_item();
2331 _this.stop_editor();
2332 _this.show_editor(_this.file, prop.parent, prop);
2338 this.el.bind.connect( (listitem) => {
2339 this.is_setting = true;
2342 var bx = (Gtk.Box) ((Gtk.ListItem)listitem).get_child();
2347 var elbl = (Gtk.EditableLabel)bx.get_first_child();
2348 var lbl = (Gtk.Label) elbl.get_next_sibling();
2349 var cb = (Gtk.DropDown) lbl.get_next_sibling();
2350 // decide if it's a combo or editable text..
2351 var model = (Gtk.StringList) cb.model;
2357 var prop = (JsRender.NodeProp) ((Gtk.ListItem)listitem).get_item();
2358 if (prop == null || _this.node == null ) {
2359 GLib.error("something is wrong");
2362 if ( _this.node.fqn() == "") {
2363 GLib.debug("node is missing fqn");
2367 //GLib.debug("prop = %s", prop.get_type().name());
2368 //GLib.debug("prop.val = %s", prop.val);
2369 //GLib.debug("prop.key = %s", prop.to_display_name());
2371 var use_textarea = prop.useTextArea();
2374 var pal = _this.file.project.palete;
2377 var has_opts = pal.typeOptions(_this.node.fqn(), prop.name, prop.rtype, out opts);
2379 if (!has_opts && prop.ptype == JsRender.NodePropType.RAW) {
2380 use_textarea = true;
2385 prop.bind_property("val_short",
2387 GLib.BindingFlags.SYNC_CREATE);
2388 prop.bind_property("val_tooltip",
2389 lbl, "tooltip_markup",
2390 GLib.BindingFlags.SYNC_CREATE);
2392 this.is_setting = false;
2401 // others... - fill in options for true/false?
2402 // GLib.debug (ktype.up());
2405 while(model.get_n_items() > 0) {
2409 // can not remove - hopefully always empty.
2411 for(var i = 0; i < opts.length; i ++) {
2412 model.append( opts[i]);
2413 // not sure this is a great idea...
2414 if (opts[i].down() == prop.val.down()) {
2418 GLib.debug("Set selected item to %d", sel);
2419 cb.set_selected(sel > -1 ? sel : Gtk.INVALID_LIST_POSITION);
2420 this.is_setting = false;
2424 // see if type is a Enum.
2425 // triggers a changed event
2427 elbl.set_text(prop.val);
2430 this.is_setting = false;
2439 // user defined functions
2443 public class Xcls_ContextMenu : Object
2445 public Gtk.Popover el;
2446 private Xcls_LeftProps _this;
2452 public Xcls_ContextMenu(Xcls_LeftProps _owner )
2455 _this.ContextMenu = this;
2456 this.el = new Gtk.Popover();
2460 // set gobject values
2461 var child_1 = new Xcls_Box54( _this );
2463 this.el.child = child_1.el;
2466 // user defined functions
2468 public class Xcls_Box54 : Object
2471 private Xcls_LeftProps _this;
2477 public Xcls_Box54(Xcls_LeftProps _owner )
2480 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
2484 // set gobject values
2485 var child_1 = new Xcls_Button55( _this );
2487 this.el.append( child_1.el );
2490 // user defined functions
2492 public class Xcls_Button55 : Object
2494 public Gtk.Button el;
2495 private Xcls_LeftProps _this;
2501 public Xcls_Button55(Xcls_LeftProps _owner )
2504 this.el = new Gtk.Button();
2508 // set gobject values
2509 this.el.label = "Delete";
2512 this.el.activate.connect( ( ) =>{
2513 _this.deleteSelected();
2518 // user defined functions