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_Box1( _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 || this.node == null || node.oid != this.node.oid) {
117 var prop = node.lineToProp( (int)diag.range.start.line) ;
121 var row = _this.selmodel.propToRow(prop);
125 var w = this.view.getWidgetAtRow(row);
129 var ed = diag.category.down();
130 if (ed != "err" && w.has_css_class("node-err")) {
133 if (ed == "err" && w.has_css_class("node-warn")) {
134 w.remove_css_class("node-warn");
136 if (ed == "err" && w.has_css_class("node-depr")) {
137 w.remove_css_class("node-depr");
139 if (!w.has_css_class("node-"+ ed)) {
140 w.add_css_class("node-" + ed);
146 public string keyFormat (string val, string type) {
148 // Glib.markup_escape_text(val);
150 if (type == "listener") {
151 return "<span font_weight=\"bold\" color=\"#660000\">" +
152 GLib.Markup.escape_text(val) +
156 if (val.length < 1) {
157 return "<span color=\"#FF0000\">--empty--</span>";
162 //# - object properties
164 // all of these... - display value is last element..
165 var ar = val.strip().split(" ");
168 var dval = GLib.Markup.escape_text(ar[ar.length-1]);
174 case '@': // signal // just bold balck?
175 if (dval[0] == '@') {
176 dval = dval.substring(1);
179 return @"<span font_weight=\"bold\">@ $dval</span>";
180 case '#': // object properties?
181 if (dval[0] == '#') {
182 dval = dval.substring(1);
184 return @"<span font_weight=\"bold\">$dval</span>";
186 if (dval[0] == '*') {
187 dval = dval.substring(1);
189 return @"<span color=\"#0000CC\" font_weight=\"bold\">$dval</span>";
191 if (dval[0] == '$') {
192 dval = dval.substring(1);
194 return @"<span style=\"italic\">$dval</span>";
195 case '|': // user defined methods
196 if (dval[0] == '|') {
197 dval = dval.substring(1);
199 return @"<span color=\"#008000\" font_weight=\"bold\">$dval</span>";
210 public void deleteSelected () {
218 var s = this.view.el.get_selection();
219 s.get_selected(out mod, out iter);
223 mod.get_value(iter, 0 , out gval);
224 var prop = (JsRender.NodeProp)gval;
226 this.load(this.file, this.node);
229 // stop editor after fetching property - otherwise prop is null.
234 case JsRender.NodePropType.LISTENER:
235 this.node.listeners.unset(prop.to_index_key());
239 this.node.props.unset(prop.to_index_key());
242 this.load(this.file, this.node);
247 public void removeErrors () {
248 var child = this.view.el.get_first_child();
250 var reading_header = true;
252 while (child != null) {
253 //GLib.debug("Got %s", child.get_type().name());
255 if (reading_header) {
258 if (child.get_type().name() != "GtkColumnListView") {
260 child = child.get_next_sibling();
263 // should be columnlistview
264 child = child.get_first_child();
268 reading_header = false;
272 if (child.has_css_class("node-err")) {
273 child.remove_css_class("node-err");
275 if (child.has_css_class("node-warn")) {
276 child.remove_css_class("node-warn");
279 if (child.has_css_class("node-depr")) {
280 child.remove_css_class("node-depr");
283 child = child.get_next_sibling();
285 //GLib.debug("Rturning null");
288 public void load (JsRender.JsRender file, JsRender.Node? node)
290 // not sure when to initialize this - we should do it on setting main window really.
293 if (this.view.popover == null) {
294 this.view.popover = new Xcls_PopoverProperty();
295 this.view.popover.mainwindow = _this.main_window;
299 if (this.node != null) {
300 this.node.dupeProps(); // ensures removeall will not do somethign silly
304 GLib.debug("load leftprops\n");
310 this.model.el.remove_all();
312 //this.get('/RightEditor').el.hide();
317 node.loadProps(this.model.el, _this.main_window.windowstate.project);
320 //GLib.debug("clear selection\n");
322 this.loading = false;
323 this.selmodel.el.set_selected(Gtk.INVALID_LIST_POSITION);
326 //this.model.el.set_sort_column_id(4,Gtk.SortType.ASCENDING); // sort by real key..
328 // this.view.el.get_selection().unselect_all();
330 // _this.keycol.el.set_max_width(_this.EditProps.el.get_allocated_width()/ 2);
331 // _this.valcol.el.set_max_width(_this.EditProps.el.get_allocated_width()/ 2);
334 public class Xcls_Box1 : Object
337 private Xcls_LeftProps _this;
343 public Xcls_Box1(Xcls_LeftProps _owner )
346 this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
350 // set gobject values
351 this.el.hexpand = true;
352 var child_1 = new Xcls_Label2( _this );
354 this.el.append( child_1.el );
355 var child_2 = new Xcls_Button3( _this );
357 this.el.append( child_2.el );
358 var child_3 = new Xcls_Button4( _this );
360 this.el.append( child_3.el );
361 var child_4 = new Xcls_MenuButton5( _this );
363 this.el.append( child_4.el );
366 // user defined functions
368 public class Xcls_Label2 : Object
371 private Xcls_LeftProps _this;
377 public Xcls_Label2(Xcls_LeftProps _owner )
380 this.el = new Gtk.Label( "Add:" );
384 // set gobject values
385 this.el.margin_end = 5;
386 this.el.margin_start = 5;
389 // user defined functions
392 public class Xcls_Button3 : Object
394 public Gtk.Button el;
395 private Xcls_LeftProps _this;
399 public bool always_show_image;
402 public Xcls_Button3(Xcls_LeftProps _owner )
405 this.el = new Gtk.Button();
408 this.always_show_image = true;
410 // set gobject values
411 this.el.icon_name = "format-justify-left";
412 this.el.hexpand = true;
413 this.el.tooltip_text = "Add Property";
414 this.el.label = "Property";
417 this.el.clicked.connect( ( ) => {
419 _this.main_window.windowstate.showProps(
421 JsRender.NodePropType.PROP
427 // user defined functions
430 public class Xcls_Button4 : Object
432 public Gtk.Button el;
433 private Xcls_LeftProps _this;
437 public bool always_show_image;
440 public Xcls_Button4(Xcls_LeftProps _owner )
443 this.el = new Gtk.Button();
446 this.always_show_image = true;
448 // set gobject values
449 this.el.icon_name = "appointment-new";
450 this.el.hexpand = true;
451 this.el.tooltip_text = "Add Event Code";
452 this.el.label = "Event";
455 this.el.clicked.connect( ( ) => {
458 _this.main_window.windowstate.showProps(
460 JsRender.NodePropType.LISTENER
467 // user defined functions
470 public class Xcls_MenuButton5 : Object
472 public Gtk.MenuButton el;
473 private Xcls_LeftProps _this;
479 public Xcls_MenuButton5(Xcls_LeftProps _owner )
482 this.el = new Gtk.MenuButton();
486 // set gobject values
487 this.el.label = "Other";
488 new Xcls_addpop( _this );
489 this.el.popover = _this.addpop.el;
492 // user defined functions
494 public class Xcls_addpop : Object
496 public Gtk.Popover el;
497 private Xcls_LeftProps _this;
503 public Xcls_addpop(Xcls_LeftProps _owner )
507 this.el = new Gtk.Popover();
511 // set gobject values
512 var child_1 = new Xcls_Box7( _this );
513 this.el.child = child_1.el;
516 // user defined functions
518 public class Xcls_Box7 : Object
521 private Xcls_LeftProps _this;
527 public Xcls_Box7(Xcls_LeftProps _owner )
530 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
534 // set gobject values
535 var child_1 = new Xcls_Button8( _this );
537 this.el.append( child_1.el );
538 var child_2 = new Xcls_Button10( _this );
540 this.el.append( child_2.el );
541 var child_3 = new Xcls_Button12( _this );
543 this.el.append( child_3.el );
544 var child_4 = new Xcls_Button14( _this );
546 this.el.append( child_4.el );
547 var child_5 = new Xcls_Button16( _this );
549 this.el.append( child_5.el );
550 var child_6 = new Xcls_Separator18( _this );
552 this.el.append( child_6.el );
553 var child_7 = new Xcls_Button19( _this );
555 this.el.append( child_7.el );
556 var child_8 = new Xcls_Button21( _this );
558 this.el.append( child_8.el );
559 var child_9 = new Xcls_Button23( _this );
561 this.el.append( child_9.el );
562 var child_10 = new Xcls_Separator25( _this );
564 this.el.append( child_10.el );
565 var child_11 = new Xcls_Button26( _this );
567 this.el.append( child_11.el );
568 var child_12 = new Xcls_Button28( _this );
570 this.el.append( child_12.el );
571 var child_13 = new Xcls_Button30( _this );
573 this.el.append( child_13.el );
574 var child_14 = new Xcls_Separator32( _this );
576 this.el.append( child_14.el );
577 var child_15 = new Xcls_Button33( _this );
579 this.el.append( child_15.el );
580 var child_16 = new Xcls_Button35( _this );
582 this.el.append( child_16.el );
583 var child_17 = new Xcls_Button37( _this );
585 this.el.append( child_17.el );
588 // user defined functions
590 public class Xcls_Button8 : Object
592 public Gtk.Button el;
593 private Xcls_LeftProps _this;
599 public Xcls_Button8(Xcls_LeftProps _owner )
602 this.el = new Gtk.Button();
606 // set gobject values
607 this.el.has_frame = false;
608 var child_1 = new Xcls_Label9( _this );
609 this.el.child = child_1.el;
612 this.el.clicked.connect( () => {
613 _this.addpop.el.hide();
614 // is this userdef or special??
615 var add = new JsRender.NodeProp.prop("id");
616 if (_this.node.has_prop_key(add)) {
620 _this.node.add_prop( add );
622 _this.view.editProp( add );
627 // user defined functions
629 public class Xcls_Label9 : Object
632 private Xcls_LeftProps _this;
638 public Xcls_Label9(Xcls_LeftProps _owner )
641 this.el = new Gtk.Label( "id: _this.{ID} (Vala)" );
645 // set gobject values
646 this.el.halign = Gtk.Align.START;
647 this.el.tooltip_text = "Using _this.{ID} will map to this element";
650 // user defined functions
654 public class Xcls_Button10 : Object
656 public Gtk.Button el;
657 private Xcls_LeftProps _this;
663 public Xcls_Button10(Xcls_LeftProps _owner )
666 this.el = new Gtk.Button();
670 // set gobject values
671 this.el.has_frame = false;
672 var child_1 = new Xcls_Label11( _this );
673 this.el.child = child_1.el;
676 this.el.clicked.connect( ( ) => {
679 _this.addpop.el.hide();
680 // is this userdef or special??
681 var add = new JsRender.NodeProp.special("pack", "add");
682 if (_this.node.has_prop_key(add)) {
686 _this.node.add_prop( add );
688 _this.view.editProp( add );
694 // user defined functions
696 public class Xcls_Label11 : Object
699 private Xcls_LeftProps _this;
705 public Xcls_Label11(Xcls_LeftProps _owner )
708 this.el = new Gtk.Label( "pack: Pack method (Vala)" );
712 // set gobject values
713 this.el.halign = Gtk.Align.START;
714 this.el.tooltip_text = "how to pack this element onto parent, (method, 2nd arg, 3rd arg) .. the 1st argument is filled by the element";
717 // user defined functions
721 public class Xcls_Button12 : Object
723 public Gtk.Button el;
724 private Xcls_LeftProps _this;
730 public Xcls_Button12(Xcls_LeftProps _owner )
733 this.el = new Gtk.Button();
737 // set gobject values
738 this.el.has_frame = false;
739 var child_1 = new Xcls_Label13( _this );
740 this.el.child = child_1.el;
743 this.el.clicked.connect( ( ) => {
745 _this.addpop.el.hide();
746 // is this userdef or special??
747 var add = new JsRender.NodeProp.special("ctor");
748 if (_this.node.has_prop_key(add)) {
752 _this.node.add_prop( add );
754 _this.view.editProp( add );
759 // user defined functions
761 public class Xcls_Label13 : Object
764 private Xcls_LeftProps _this;
770 public Xcls_Label13(Xcls_LeftProps _owner )
773 this.el = new Gtk.Label( "ctor: Alterative to default contructor (Vala)" );
777 // set gobject values
778 this.el.halign = Gtk.Align.START;
779 this.el.tooltip_text = "eg. \n\nnew Clutter.Image.from_file(.....)";
782 // user defined functions
786 public class Xcls_Button14 : Object
788 public Gtk.Button el;
789 private Xcls_LeftProps _this;
795 public Xcls_Button14(Xcls_LeftProps _owner )
798 this.el = new Gtk.Button();
802 // set gobject values
803 this.el.has_frame = false;
804 var child_1 = new Xcls_Label15( _this );
805 this.el.child = child_1.el;
808 this.el.clicked.connect( ( ) => {
810 _this.addpop.el.hide();
811 // is this userdef or special??
812 var add = new JsRender.NodeProp.special("init","{\n\n}\n" ) ;
813 if (_this.node.has_prop_key(add)) {
817 _this.node.add_prop( add );
819 _this.view.editProp( add );
823 // user defined functions
825 public class Xcls_Label15 : Object
828 private Xcls_LeftProps _this;
834 public Xcls_Label15(Xcls_LeftProps _owner )
837 this.el = new Gtk.Label( "init: initialziation code (vala)" );
841 // set gobject values
842 this.el.halign = Gtk.Align.START;
843 this.el.tooltip_text = "This code is called after the ctor";
846 // user defined functions
850 public class Xcls_Button16 : Object
852 public Gtk.Button el;
853 private Xcls_LeftProps _this;
859 public Xcls_Button16(Xcls_LeftProps _owner )
862 this.el = new Gtk.Button();
866 // set gobject values
867 this.el.has_frame = false;
868 var child_1 = new Xcls_Label17( _this );
869 this.el.child = child_1.el;
872 this.el.clicked.connect( () => {
873 _this.addpop.el.hide();
875 // is this userdef or special??
876 var add = new JsRender.NodeProp.prop("cms-id","string", "" ) ;
877 if (_this.node.has_prop_key(add)) {
881 _this.node.add_prop( add );
883 _this.view.editProp( add );
888 // user defined functions
890 public class Xcls_Label17 : Object
893 private Xcls_LeftProps _this;
899 public Xcls_Label17(Xcls_LeftProps _owner )
902 this.el = new Gtk.Label( "cms-id: (Roo JS/Pman library)" );
906 // set gobject values
907 this.el.halign = Gtk.Align.START;
908 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";
911 // user defined functions
915 public class Xcls_Separator18 : Object
917 public Gtk.Separator el;
918 private Xcls_LeftProps _this;
924 public Xcls_Separator18(Xcls_LeftProps _owner )
927 this.el = new Gtk.Separator( Gtk.Orientation.HORIZONTAL );
931 // set gobject values
934 // user defined functions
937 public class Xcls_Button19 : Object
939 public Gtk.Button el;
940 private Xcls_LeftProps _this;
946 public Xcls_Button19(Xcls_LeftProps _owner )
949 this.el = new Gtk.Button();
953 // set gobject values
954 this.el.has_frame = false;
955 var child_1 = new Xcls_Label20( _this );
956 this.el.child = child_1.el;
959 this.el.clicked.connect( (self) => {
960 _this.addpop.el.hide();
961 _this.view.popover.show(
964 new JsRender.NodeProp.user("", "string", "") ,
972 // user defined functions
974 public class Xcls_Label20 : Object
977 private Xcls_LeftProps _this;
983 public Xcls_Label20(Xcls_LeftProps _owner )
986 this.el = new Gtk.Label( "String" );
990 // set gobject values
991 this.el.halign = Gtk.Align.START;
992 this.el.tooltip_text = "Add a user defined string property";
995 // user defined functions
999 public class Xcls_Button21 : Object
1001 public Gtk.Button el;
1002 private Xcls_LeftProps _this;
1008 public Xcls_Button21(Xcls_LeftProps _owner )
1011 this.el = new Gtk.Button();
1015 // set gobject values
1016 this.el.has_frame = false;
1017 var child_1 = new Xcls_Label22( _this );
1018 this.el.child = child_1.el;
1021 this.el.clicked.connect( ( ) =>{
1023 _this.addpop.el.hide();
1024 _this.view.popover.show(
1027 new JsRender.NodeProp.user("", "int", "0") ,
1035 // user defined functions
1037 public class Xcls_Label22 : Object
1039 public Gtk.Label el;
1040 private Xcls_LeftProps _this;
1046 public Xcls_Label22(Xcls_LeftProps _owner )
1049 this.el = new Gtk.Label( "Number" );
1053 // set gobject values
1054 this.el.halign = Gtk.Align.START;
1055 this.el.tooltip_text = "Add a user defined number property";
1058 // user defined functions
1062 public class Xcls_Button23 : Object
1064 public Gtk.Button el;
1065 private Xcls_LeftProps _this;
1071 public Xcls_Button23(Xcls_LeftProps _owner )
1074 this.el = new Gtk.Button();
1078 // set gobject values
1079 this.el.has_frame = false;
1080 var child_1 = new Xcls_Label24( _this );
1081 this.el.child = child_1.el;
1084 this.el.clicked.connect( ( ) =>{
1086 _this.addpop.el.hide();
1087 _this.view.popover.show(
1090 new JsRender.NodeProp.user("", "bool", "true") ,
1098 // user defined functions
1100 public class Xcls_Label24 : Object
1102 public Gtk.Label el;
1103 private Xcls_LeftProps _this;
1109 public Xcls_Label24(Xcls_LeftProps _owner )
1112 this.el = new Gtk.Label( "Boolean" );
1116 // set gobject values
1117 this.el.halign = Gtk.Align.START;
1118 this.el.tooltip_text = "Add a user defined boolean property";
1121 // user defined functions
1125 public class Xcls_Separator25 : Object
1127 public Gtk.Separator el;
1128 private Xcls_LeftProps _this;
1134 public Xcls_Separator25(Xcls_LeftProps _owner )
1137 this.el = new Gtk.Separator( Gtk.Orientation.HORIZONTAL );
1141 // set gobject values
1144 // user defined functions
1147 public class Xcls_Button26 : Object
1149 public Gtk.Button el;
1150 private Xcls_LeftProps _this;
1156 public Xcls_Button26(Xcls_LeftProps _owner )
1159 this.el = new Gtk.Button();
1163 // set gobject values
1164 this.el.has_frame = false;
1165 var child_1 = new Xcls_Label27( _this );
1166 this.el.child = child_1.el;
1169 this.el.clicked.connect( ( ) =>{
1170 _this.addpop.el.hide();
1171 _this.view.popover.show(
1174 new JsRender.NodeProp.jsmethod("") ,
1183 // user defined functions
1185 public class Xcls_Label27 : Object
1187 public Gtk.Label el;
1188 private Xcls_LeftProps _this;
1194 public Xcls_Label27(Xcls_LeftProps _owner )
1197 this.el = new Gtk.Label( "Javascript Function" );
1201 // set gobject values
1202 this.el.halign = Gtk.Align.START;
1203 this.el.tooltip_text = "Add a javascript function";
1206 // user defined functions
1210 public class Xcls_Button28 : Object
1212 public Gtk.Button el;
1213 private Xcls_LeftProps _this;
1219 public Xcls_Button28(Xcls_LeftProps _owner )
1222 this.el = new Gtk.Button();
1226 // set gobject values
1227 this.el.has_frame = false;
1228 var child_1 = new Xcls_Label29( _this );
1229 this.el.child = child_1.el;
1232 this.el.clicked.connect( ( ) =>{
1233 _this.addpop.el.hide();
1234 _this.view.popover.show(
1237 new JsRender.NodeProp.valamethod("") ,
1244 // user defined functions
1246 public class Xcls_Label29 : Object
1248 public Gtk.Label el;
1249 private Xcls_LeftProps _this;
1255 public Xcls_Label29(Xcls_LeftProps _owner )
1258 this.el = new Gtk.Label( "Vala Method" );
1262 // set gobject values
1263 this.el.halign = Gtk.Align.START;
1264 this.el.tooltip_text = "Add a user defined method to a object";
1267 // user defined functions
1271 public class Xcls_Button30 : Object
1273 public Gtk.Button el;
1274 private Xcls_LeftProps _this;
1280 public Xcls_Button30(Xcls_LeftProps _owner )
1283 this.el = new Gtk.Button();
1287 // set gobject values
1288 this.el.has_frame = false;
1289 var child_1 = new Xcls_Label31( _this );
1290 this.el.child = child_1.el;
1293 this.el.clicked.connect( ( ) =>{
1294 _this.addpop.el.hide();
1295 _this.view.popover.show(
1298 new JsRender.NodeProp.sig("" ) ,
1305 // user defined functions
1307 public class Xcls_Label31 : Object
1309 public Gtk.Label el;
1310 private Xcls_LeftProps _this;
1316 public Xcls_Label31(Xcls_LeftProps _owner )
1319 this.el = new Gtk.Label( "Vala Signal" );
1323 // set gobject values
1324 this.el.halign = Gtk.Align.START;
1325 this.el.tooltip_text = "Add a user defined signal to a object";
1328 // user defined functions
1332 public class Xcls_Separator32 : Object
1334 public Gtk.Separator el;
1335 private Xcls_LeftProps _this;
1341 public Xcls_Separator32(Xcls_LeftProps _owner )
1344 this.el = new Gtk.Separator( Gtk.Orientation.HORIZONTAL );
1348 // set gobject values
1351 // user defined functions
1354 public class Xcls_Button33 : Object
1356 public Gtk.Button el;
1357 private Xcls_LeftProps _this;
1363 public Xcls_Button33(Xcls_LeftProps _owner )
1366 this.el = new Gtk.Button();
1370 // set gobject values
1371 this.el.has_frame = false;
1372 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 );
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 );
1500 this.el.child = child_1.el;
1503 this.el.clicked.connect( ( ) =>{
1504 _this.addpop.el.hide();
1505 _this.view.popover.show(
1508 new JsRender.NodeProp.prop("flexy:if", "string", "value_or_condition") ,
1516 // user defined functions
1518 public class Xcls_Label38 : Object
1520 public Gtk.Label el;
1521 private Xcls_LeftProps _this;
1527 public Xcls_Label38(Xcls_LeftProps _owner )
1530 this.el = new Gtk.Label( "Flexy - Foreach" );
1534 // set gobject values
1535 this.el.halign = Gtk.Align.START;
1536 this.el.tooltip_text = "Add a flexy foreach (for HTML templates)";
1539 // user defined functions
1547 public class Xcls_EditProps : Object
1549 public Gtk.ScrolledWindow el;
1550 private Xcls_LeftProps _this;
1554 public bool editing;
1557 public Xcls_EditProps(Xcls_LeftProps _owner )
1560 _this.EditProps = this;
1561 this.el = new Gtk.ScrolledWindow();
1564 this.editing = false;
1566 // set gobject values
1567 this.el.hexpand = true;
1568 this.el.vexpand = true;
1569 new Xcls_view( _this );
1570 this.el.set_child ( _this.view.el );
1576 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
1580 // user defined functions
1582 public class Xcls_view : Object
1584 public Gtk.ColumnView el;
1585 private Xcls_LeftProps _this;
1589 public Xcls_PopoverProperty popover;
1592 public Xcls_view(Xcls_LeftProps _owner )
1596 new Xcls_selmodel( _this );
1597 this.el = new Gtk.ColumnView( _this.selmodel.el );
1600 this.popover = null;
1602 // set gobject values
1603 this.el.name = "leftprops-view";
1604 this.el.single_click_activate = false;
1605 this.el.hexpand = true;
1606 this.el.vexpand = true;
1607 this.el.show_row_separators = true;
1608 new Xcls_deletemenu( _this );
1609 var child_3 = new Xcls_GestureClick45( _this );
1611 this.el.add_controller( child_3.el );
1612 var child_4 = new Xcls_GestureClick46( _this );
1614 this.el.add_controller( child_4.el );
1615 new Xcls_keycol( _this );
1616 this.el.append_column ( _this.keycol.el );
1617 new Xcls_valcol( _this );
1618 this.el.append_column ( _this.valcol.el );
1619 new Xcls_ContextMenu( _this );
1622 // user defined functions
1623 public Gtk.Widget? getWidgetAtRow (uint row) {
1626 from https://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465
1627 var colview = gesture.widget;
1628 var line_no = check_list_widget(colview, x,y);
1630 var item = colview.model.get_item(line_no);
1634 //GLib.debug("Get Widget At Row %d", (int)row);
1635 var child = this.el.get_first_child();
1637 var reading_header = true;
1639 while (child != null) {
1640 //GLib.debug("Got %s", child.get_type().name());
1641 if (reading_header) {
1644 if (child.get_type().name() != "GtkColumnListView") {
1645 child = child.get_next_sibling();
1648 child = child.get_first_child();
1649 reading_header = false;
1652 if (child.get_type().name() != "GtkColumnViewRowWidget") {
1653 child = child.get_next_sibling();
1657 if (line_no == row) {
1658 //GLib.debug("Returning widget %s", child.get_type().name());
1659 return (Gtk.Widget)child;
1661 child = child.get_next_sibling();
1663 //GLib.debug("Rturning null");
1667 public void editProp (JsRender.NodeProp prop)
1669 var sm = _this.selmodel.el;
1672 GLib.debug("finding node");
1673 _this.selmodel.selectProp(prop);
1675 for (var i = 0 ; i < sm.n_items; i++) {
1676 var r = (JsRender.NodeProp)sm.get_item(i);
1677 if (r.equals(prop)) {
1683 GLib.debug("finding node - cant find it");
1687 var r = this.getWidgetAtRow(sr);
1688 GLib.debug("r = %s", r.get_type().name());
1689 var ca = r.get_first_child();
1690 var ll = (Gtk.Label)ca.get_first_child();
1691 var cb = ca.get_next_sibling();
1692 var b = cb.get_first_child();
1693 var e = (Gtk.EditableLabel) b.get_first_child();
1694 var l = (Gtk.Label) e.get_next_sibling();
1695 var d = (Gtk.DropDown) l.get_next_sibling();
1697 GLib.debug("row key = %s", ll.label);
1698 if (e.get_visible()) {
1699 _this.stop_editor();
1701 //GLib.Timeout.add_once(500, () => {
1702 // var st = (Gtk.Stack) e.get_first_child();
1703 // var ed = (Gtk.Entry) st.get_visible_child();
1704 // ed.grab_focus_without_selecting();
1708 if (d.get_visible()) {
1709 _this.stop_editor();
1713 if (l.get_visible()) {
1714 _this.stop_editor();
1715 _this.show_editor(_this.file, prop.parent, prop);
1721 //gtkcolumnviewrowwidget
1725 // entry / label / dropdown
1729 public int getColAt (double x, double y) {
1732 from https://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465
1735 //Gtk.Allocation alloc = { 0, 0, 0, 0 };
1736 var child = this.el.get_first_child();
1740 while (child != null) {
1741 GLib.debug("Got %s", child.get_type().name());
1743 if (child.get_type().name() == "GtkColumnViewRowWidget") {
1744 child = child.get_first_child();
1748 //child.get_allocation(out alloc);
1749 if (x < (child.get_width() + offx)) {
1752 offx += child.get_width();
1754 child = child.get_next_sibling();
1761 public int getRowAt (double x, double y, out string pos) {
1764 var w = this.el.pick(x, y, Gtk.PickFlags.DEFAULT);
1765 //GLib.debug("got widget %s", w == null ? "nothing" : w.get_type().name());
1770 var row= w.get_ancestor(GLib.Type.from_name("GtkColumnViewRowWidget"));
1775 //GLib.debug("got colview %s", row == null ? "nothing" : row.get_type().name());
1780 while (cr.get_prev_sibling() != null) {
1782 cr = cr.get_prev_sibling();
1785 //GLib.debug("row number is %d", rn);
1786 //GLib.debug("click %d, %d", (int)x, (int)y);
1788 Graphene.Rect bounds;
1789 row.compute_bounds(this.el, out bounds);
1790 //GLib.debug("click x=%d, y=%d, w=%d, h=%d",
1791 // (int)bounds.get_x(), (int)bounds.get_y(),
1792 // (int)bounds.get_width(), (int)bounds.get_height()
1794 var ypos = y - bounds.get_y();
1795 //GLib.debug("rel ypos = %d", (int)ypos);
1796 var rpos = 100.0 * (ypos / bounds.get_height());
1797 //GLib.debug("rel pos = %d %%", (int)rpos);
1802 } else if (rpos < 20) {
1808 public class Xcls_deletemenu : Object
1810 public Gtk.Popover el;
1811 private Xcls_LeftProps _this;
1817 public Xcls_deletemenu(Xcls_LeftProps _owner )
1820 _this.deletemenu = this;
1821 this.el = new Gtk.Popover();
1825 // set gobject values
1826 var child_1 = new Xcls_Box42( _this );
1827 this.el.child = child_1.el;
1830 // user defined functions
1832 public class Xcls_Box42 : Object
1835 private Xcls_LeftProps _this;
1841 public Xcls_Box42(Xcls_LeftProps _owner )
1844 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
1848 // set gobject values
1849 var child_1 = new Xcls_Button43( _this );
1851 this.el.append( child_1.el );
1854 // user defined functions
1856 public class Xcls_Button43 : Object
1858 public Gtk.Button el;
1859 private Xcls_LeftProps _this;
1865 public Xcls_Button43(Xcls_LeftProps _owner )
1868 this.el = new Gtk.Button();
1872 // set gobject values
1873 this.el.has_frame = false;
1874 this.el.label = "Delete";
1875 var child_1 = new Xcls_Label44( _this );
1876 this.el.child = child_1.el;
1879 this.el.clicked.connect( ( ) => {
1882 var n = (JsRender.NodeProp) _this.selmodel.el.selected_item;
1884 _this.deletemenu.el.hide();
1885 _this.node.remove_prop(n);
1889 // user defined functions
1891 public class Xcls_Label44 : Object
1893 public Gtk.Label el;
1894 private Xcls_LeftProps _this;
1900 public Xcls_Label44(Xcls_LeftProps _owner )
1903 this.el = new Gtk.Label( "Delete Property / Method" );
1907 // set gobject values
1908 this.el.halign = Gtk.Align.START;
1911 // user defined functions
1917 public class Xcls_GestureClick45 : Object
1919 public Gtk.GestureClick el;
1920 private Xcls_LeftProps _this;
1926 public Xcls_GestureClick45(Xcls_LeftProps _owner )
1929 this.el = new Gtk.GestureClick();
1933 // set gobject values
1936 this.el.pressed.connect( (n_press, in_x, in_y) => {
1938 GLib.debug("Prssed %d", (int) this.el.get_current_button());
1940 var col = _this.view.getColAt(in_x, in_y);
1945 var row = _this.view.getRowAt(in_x, in_y, out pos);
1951 GLib.debug("hit row %d", row);
1952 var prop = _this.selmodel.getPropAt(row);
1953 _this.selmodel.selectProp(prop);
1955 //var point_at = _this.view.getWidgetAtRow(row);
1957 // need to shift down, as ev.y does not inclucde header apparently..
1958 // or popover might be trying to do a central?
1959 // _this.view.editPropertyDetails(prop, (int) in_y + 12);
1960 _this.stop_editor();
1961 _this.view.popover.show(
1971 // user defined functions
1974 public class Xcls_GestureClick46 : Object
1976 public Gtk.GestureClick el;
1977 private Xcls_LeftProps _this;
1983 public Xcls_GestureClick46(Xcls_LeftProps _owner )
1986 this.el = new Gtk.GestureClick();
1990 // set gobject values
1994 this.el.pressed.connect( (n_press, in_x, in_y) => {
1999 var row = _this.view.getRowAt(in_x, in_y, out pos);
2006 _this.stop_editor();
2007 GLib.debug("hit row %d", row);
2008 var prop = _this.selmodel.getPropAt(row);
2009 _this.selmodel.selectProp(prop);
2013 GLib.debug("Prssed %d", (int) this.el.get_current_button());
2014 //_this.deletemenu.el.set_parent(_this.view.el);
2015 if (_this.deletemenu.el.parent == null) {
2016 _this.deletemenu.el.set_parent(_this.main_window.el);
2021 _this.deletemenu.el.set_offset(
2022 (int)in_x - _this.view.el.get_width() ,
2023 (int)in_y - _this.view.el.get_height()
2025 _this.deletemenu.el.set_position(Gtk.PositionType.BOTTOM);
2026 _this.deletemenu.el.popup();
2031 // user defined functions
2034 public class Xcls_selmodel : Object
2036 public Gtk.SingleSelection el;
2037 private Xcls_LeftProps _this;
2043 public Xcls_selmodel(Xcls_LeftProps _owner )
2046 _this.selmodel = this;
2047 new Xcls_model( _this );
2048 this.el = new Gtk.SingleSelection( _this.model.el );
2052 // set gobject values
2053 this.el.can_unselect = true;
2056 // user defined functions
2057 public int propToRow (JsRender.NodeProp prop) {
2058 for (var i = 0 ; i < this.el.n_items; i++) {
2059 var r = (JsRender.NodeProp)this.el.get_item(i);
2060 if (r.equals(prop)) {
2068 public void startEditing (JsRender.NodeProp prop) {
2069 // should we call select?? - caller does int (from windowstate)
2072 public void selectProp (JsRender.NodeProp prop) {
2073 for (var i = 0 ; i < this.el.n_items; i++) {
2074 var r = (JsRender.NodeProp)this.el.get_item(i);
2075 if (r.equals(prop)) {
2076 this.el.selected = i;
2082 public JsRender.NodeProp getPropAt (uint row) {
2084 return (JsRender.NodeProp) this.el.get_item(row);
2089 public class Xcls_model : Object
2091 public GLib.ListStore el;
2092 private Xcls_LeftProps _this;
2098 public Xcls_model(Xcls_LeftProps _owner )
2102 this.el = new GLib.ListStore(typeof(JsRender.NodeProp));
2106 // set gobject values
2109 // user defined functions
2113 public class Xcls_keycol : Object
2115 public Gtk.ColumnViewColumn el;
2116 private Xcls_LeftProps _this;
2122 public Xcls_keycol(Xcls_LeftProps _owner )
2125 _this.keycol = this;
2126 var child_1 = new Xcls_SignalListItemFactory50( _this );
2128 this.el = new Gtk.ColumnViewColumn( "Property", child_1.el );
2132 // set gobject values
2133 this.el.id = "keycol";
2134 this.el.expand = true;
2135 this.el.resizable = true;
2138 // user defined functions
2140 public class Xcls_SignalListItemFactory50 : Object
2142 public Gtk.SignalListItemFactory el;
2143 private Xcls_LeftProps _this;
2149 public Xcls_SignalListItemFactory50(Xcls_LeftProps _owner )
2152 this.el = new Gtk.SignalListItemFactory();
2156 // set gobject values
2159 this.el.setup.connect( (listitem) => {
2160 var lbl = new Gtk.Label("");
2161 ((Gtk.ListItem)listitem).set_child(lbl);
2162 lbl.justify = Gtk.Justification.LEFT;
2164 lbl.use_markup = true;
2165 lbl.ellipsize = Pango.EllipsizeMode.START;
2166 /*lbl.changed.connect(() => {
2167 // notify and save the changed value...
2168 //var prop = (JsRender.NodeProp) ((Gtk.ListItem)listitem.get_item());
2170 //prop.val = lbl.text;
2171 //_this.updateIter(iter,prop);
2175 ((Gtk.ListItem)listitem).activatable = true;
2177 this.el.bind.connect( (listitem) => {
2178 var lb = (Gtk.Label) ((Gtk.ListItem)listitem).get_child();
2179 var item = (JsRender.NodeProp) ((Gtk.ListItem)listitem).get_item();
2182 item.bind_property("to_display_name_prop",
2184 GLib.BindingFlags.SYNC_CREATE);
2185 item.bind_property("to_tooltip_name_prop",
2186 lb, "tooltip_markup",
2187 GLib.BindingFlags.SYNC_CREATE);
2188 // was item (1) in old layout
2194 // user defined functions
2198 public class Xcls_valcol : Object
2200 public Gtk.ColumnViewColumn el;
2201 private Xcls_LeftProps _this;
2207 public Xcls_valcol(Xcls_LeftProps _owner )
2210 _this.valcol = this;
2211 var child_1 = new Xcls_SignalListItemFactory52( _this );
2213 this.el = new Gtk.ColumnViewColumn( "Value", child_1.el );
2217 // set gobject values
2218 this.el.id = "valcol";
2219 this.el.expand = true;
2220 this.el.resizable = true;
2223 // user defined functions
2225 public class Xcls_SignalListItemFactory52 : Object
2227 public Gtk.SignalListItemFactory el;
2228 private Xcls_LeftProps _this;
2232 public bool is_setting;
2235 public Xcls_SignalListItemFactory52(Xcls_LeftProps _owner )
2238 this.el = new Gtk.SignalListItemFactory();
2241 this.is_setting = false;
2243 // set gobject values
2246 this.el.setup.connect( (listitem) => {
2247 var hb = new Gtk.Box(Gtk.Orientation.HORIZONTAL,0);
2248 var elbl = new Gtk.EditableLabel("");
2249 elbl.hexpand = true;
2251 var lbl = new Gtk.Label("");
2254 lbl.use_markup = true;
2256 lbl.ellipsize = Pango.EllipsizeMode.END;
2257 var cb = new Gtk.DropDown(new Gtk.StringList({}), null);
2261 ((Gtk.ListItem)listitem).set_child(hb);
2263 var ef = new Gtk.EventControllerFocus();
2264 ef.enter.connect(() => {
2265 _this.stop_editor();
2266 var prop = (JsRender.NodeProp)((Gtk.ListItem)listitem).get_item();
2267 _this.selmodel.selectProp(prop);
2269 elbl.add_controller(ef);
2272 // dropdown??? - stop editing, and highliht node
2273 var tb = (Gtk.ToggleButton) cb.get_first_child();
2274 tb.clicked.connect(() => {
2275 var prop = (JsRender.NodeProp)((Gtk.ListItem)listitem).get_item();
2277 _this.stop_editor();
2278 _this.selmodel.selectProp(prop);
2281 elbl.changed.connect(() => {
2282 // notify and save the changed value...
2284 //_this.updateIter(iter,prop);
2285 // this should happen automatically
2287 if (!_this.loading && !this.is_setting) {
2288 var prop = (JsRender.NodeProp)((Gtk.ListItem)listitem).get_item();
2291 prop.val = elbl.text;
2292 GLib.debug("calling changed");
2300 cb.notify["selected"].connect(() => {
2301 // dropdown selection changed.
2305 //_this.updateIter(iter,prop);
2306 if (!_this.loading && !this.is_setting) {
2307 var prop = (JsRender.NodeProp)((Gtk.ListItem)listitem).get_item();
2308 var model = (Gtk.StringList)cb.model;
2309 prop.val = model.get_string(cb.selected);
2310 GLib.debug("property set to %s", prop.val);
2311 GLib.debug("calling changed");
2318 var gc = new Gtk.GestureClick();
2319 lbl.add_controller(gc);
2320 gc.pressed.connect(() => {
2321 var prop = (JsRender.NodeProp)((Gtk.ListItem)listitem).get_item();
2322 _this.stop_editor();
2323 _this.show_editor(_this.file, prop.parent, prop);
2329 this.el.bind.connect( (listitem) => {
2330 this.is_setting = true;
2333 var bx = (Gtk.Box) ((Gtk.ListItem)listitem).get_child();
2338 var elbl = (Gtk.EditableLabel)bx.get_first_child();
2339 var lbl = (Gtk.Label) elbl.get_next_sibling();
2340 var cb = (Gtk.DropDown) lbl.get_next_sibling();
2341 // decide if it's a combo or editable text..
2342 var model = (Gtk.StringList) cb.model;
2348 var prop = (JsRender.NodeProp) ((Gtk.ListItem)listitem).get_item();
2349 //GLib.debug("prop = %s", prop.get_type().name());
2350 //GLib.debug("prop.val = %s", prop.val);
2351 //GLib.debug("prop.key = %s", prop.to_display_name());
2353 var use_textarea = prop.useTextArea();
2356 var pal = _this.file.project.palete;
2359 var has_opts = pal.typeOptions(_this.node.fqn(), prop.name, prop.rtype, out opts);
2361 if (!has_opts && prop.ptype == JsRender.NodePropType.RAW) {
2362 use_textarea = true;
2367 prop.bind_property("val_short",
2369 GLib.BindingFlags.SYNC_CREATE);
2370 prop.bind_property("val_tooltip",
2371 lbl, "tooltip_markup",
2372 GLib.BindingFlags.SYNC_CREATE);
2374 this.is_setting = false;
2383 // others... - fill in options for true/false?
2384 // GLib.debug (ktype.up());
2387 while(model.get_n_items() > 0) {
2391 // can not remove - hopefully always empty.
2393 for(var i = 0; i < opts.length; i ++) {
2394 model.append( opts[i]);
2395 // not sure this is a great idea...
2396 if (opts[i].down() == prop.val.down()) {
2400 GLib.debug("Set selected item to %d", sel);
2401 cb.set_selected(sel > -1 ? sel : Gtk.INVALID_LIST_POSITION);
2402 this.is_setting = false;
2406 // see if type is a Enum.
2407 // triggers a changed event
2409 elbl.set_text(prop.val);
2412 this.is_setting = false;
2421 // user defined functions
2425 public class Xcls_ContextMenu : Object
2427 public Gtk.Popover el;
2428 private Xcls_LeftProps _this;
2434 public Xcls_ContextMenu(Xcls_LeftProps _owner )
2437 _this.ContextMenu = this;
2438 this.el = new Gtk.Popover();
2442 // set gobject values
2443 var child_1 = new Xcls_Box54( _this );
2444 this.el.child = child_1.el;
2447 // user defined functions
2449 public class Xcls_Box54 : Object
2452 private Xcls_LeftProps _this;
2458 public Xcls_Box54(Xcls_LeftProps _owner )
2461 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
2465 // set gobject values
2466 var child_1 = new Xcls_Button55( _this );
2468 this.el.append( child_1.el );
2471 // user defined functions
2473 public class Xcls_Button55 : Object
2475 public Gtk.Button el;
2476 private Xcls_LeftProps _this;
2482 public Xcls_Button55(Xcls_LeftProps _owner )
2485 this.el = new Gtk.Button();
2489 // set gobject values
2490 this.el.label = "Delete";
2493 this.el.activate.connect( ( ) =>{
2494 _this.deleteSelected();
2499 // user defined functions