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 || node.oid != this.node.oid) {
117 var prop = node.lineToProp( (int)diag.range.start.line) ;
119 var row = _this.selmodel.propToRow(prop);
123 var w = this.view.getWidgetAtRow(row);
127 var ed = diag.category.down();
128 if (ed != "err" && w.has_css_class("node-err")) {
131 if (ed == "err" && w.has_css_class("node-warn")) {
132 w.remove_css_class("node-warn");
134 if (ed == "err" && w.has_css_class("node-depr")) {
135 w.remove_css_class("node-depr");
137 if (!w.has_css_class("node-"+ ed)) {
138 w.add_css_class("node-" + ed);
144 public string keyFormat (string val, string type) {
146 // Glib.markup_escape_text(val);
148 if (type == "listener") {
149 return "<span font_weight=\"bold\" color=\"#660000\">" +
150 GLib.Markup.escape_text(val) +
154 if (val.length < 1) {
155 return "<span color=\"#FF0000\">--empty--</span>";
160 //# - object properties
162 // all of these... - display value is last element..
163 var ar = val.strip().split(" ");
166 var dval = GLib.Markup.escape_text(ar[ar.length-1]);
172 case '@': // signal // just bold balck?
173 if (dval[0] == '@') {
174 dval = dval.substring(1);
177 return @"<span font_weight=\"bold\">@ $dval</span>";
178 case '#': // object properties?
179 if (dval[0] == '#') {
180 dval = dval.substring(1);
182 return @"<span font_weight=\"bold\">$dval</span>";
184 if (dval[0] == '*') {
185 dval = dval.substring(1);
187 return @"<span color=\"#0000CC\" font_weight=\"bold\">$dval</span>";
189 if (dval[0] == '$') {
190 dval = dval.substring(1);
192 return @"<span style=\"italic\">$dval</span>";
193 case '|': // user defined methods
194 if (dval[0] == '|') {
195 dval = dval.substring(1);
197 return @"<span color=\"#008000\" font_weight=\"bold\">$dval</span>";
208 public void deleteSelected () {
216 var s = this.view.el.get_selection();
217 s.get_selected(out mod, out iter);
221 mod.get_value(iter, 0 , out gval);
222 var prop = (JsRender.NodeProp)gval;
224 this.load(this.file, this.node);
227 // stop editor after fetching property - otherwise prop is null.
232 case JsRender.NodePropType.LISTENER:
233 this.node.listeners.unset(prop.to_index_key());
237 this.node.props.unset(prop.to_index_key());
240 this.load(this.file, this.node);
245 public void removeErrors () {
246 var child = this.view.el.get_first_child();
248 var reading_header = true;
250 while (child != null) {
251 //GLib.debug("Got %s", child.get_type().name());
253 if (reading_header) {
256 if (child.get_type().name() != "GtkColumnListView") {
258 child = child.get_next_sibling();
261 // should be columnlistview
262 child = child.get_first_child();
266 reading_header = false;
270 if (child.has_css_class("node-err")) {
271 child.remove_css_class("node-err");
273 if (child.has_css_class("node-warn")) {
274 child.remove_css_class("node-warn");
277 if (child.has_css_class("node-depr")) {
278 child.remove_css_class("node-depr");
281 child = child.get_next_sibling();
283 //GLib.debug("Rturning null");
286 public void load (JsRender.JsRender file, JsRender.Node? node)
288 // not sure when to initialize this - we should do it on setting main window really.
291 if (this.view.popover == null) {
292 this.view.popover = new Xcls_PopoverProperty();
293 this.view.popover.mainwindow = _this.main_window;
297 if (this.node != null) {
298 this.node.dupeProps(); // ensures removeall will not do somethign silly
302 GLib.debug("load leftprops\n");
308 this.model.el.remove_all();
310 //this.get('/RightEditor').el.hide();
315 node.loadProps(this.model.el, _this.main_window.windowstate.project);
318 //GLib.debug("clear selection\n");
320 this.loading = false;
321 this.selmodel.el.set_selected(Gtk.INVALID_LIST_POSITION);
324 //this.model.el.set_sort_column_id(4,Gtk.SortType.ASCENDING); // sort by real key..
326 // this.view.el.get_selection().unselect_all();
328 // _this.keycol.el.set_max_width(_this.EditProps.el.get_allocated_width()/ 2);
329 // _this.valcol.el.set_max_width(_this.EditProps.el.get_allocated_width()/ 2);
332 public class Xcls_Box1 : Object
335 private Xcls_LeftProps _this;
341 public Xcls_Box1(Xcls_LeftProps _owner )
344 this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
348 // set gobject values
349 this.el.hexpand = true;
350 var child_1 = new Xcls_Label2( _this );
352 this.el.append( child_1.el );
353 var child_2 = new Xcls_Button3( _this );
355 this.el.append( child_2.el );
356 var child_3 = new Xcls_Button4( _this );
358 this.el.append( child_3.el );
359 var child_4 = new Xcls_MenuButton5( _this );
361 this.el.append( child_4.el );
364 // user defined functions
366 public class Xcls_Label2 : Object
369 private Xcls_LeftProps _this;
375 public Xcls_Label2(Xcls_LeftProps _owner )
378 this.el = new Gtk.Label( "Add:" );
382 // set gobject values
383 this.el.margin_end = 5;
384 this.el.margin_start = 5;
387 // user defined functions
390 public class Xcls_Button3 : Object
392 public Gtk.Button el;
393 private Xcls_LeftProps _this;
397 public bool always_show_image;
400 public Xcls_Button3(Xcls_LeftProps _owner )
403 this.el = new Gtk.Button();
406 this.always_show_image = true;
408 // set gobject values
409 this.el.icon_name = "format-justify-left";
410 this.el.hexpand = true;
411 this.el.tooltip_text = "Add Property";
412 this.el.label = "Property";
415 this.el.clicked.connect( ( ) => {
417 _this.main_window.windowstate.showProps(
419 JsRender.NodePropType.PROP
425 // user defined functions
428 public class Xcls_Button4 : Object
430 public Gtk.Button el;
431 private Xcls_LeftProps _this;
435 public bool always_show_image;
438 public Xcls_Button4(Xcls_LeftProps _owner )
441 this.el = new Gtk.Button();
444 this.always_show_image = true;
446 // set gobject values
447 this.el.icon_name = "appointment-new";
448 this.el.hexpand = true;
449 this.el.tooltip_text = "Add Event Code";
450 this.el.label = "Event";
453 this.el.clicked.connect( ( ) => {
456 _this.main_window.windowstate.showProps(
458 JsRender.NodePropType.LISTENER
465 // user defined functions
468 public class Xcls_MenuButton5 : Object
470 public Gtk.MenuButton el;
471 private Xcls_LeftProps _this;
477 public Xcls_MenuButton5(Xcls_LeftProps _owner )
480 this.el = new Gtk.MenuButton();
484 // set gobject values
485 this.el.label = "Other";
486 new Xcls_addpop( _this );
487 this.el.popover = _this.addpop.el;
490 // user defined functions
492 public class Xcls_addpop : Object
494 public Gtk.Popover el;
495 private Xcls_LeftProps _this;
501 public Xcls_addpop(Xcls_LeftProps _owner )
505 this.el = new Gtk.Popover();
509 // set gobject values
510 var child_1 = new Xcls_Box7( _this );
511 this.el.child = child_1.el;
514 // user defined functions
516 public class Xcls_Box7 : Object
519 private Xcls_LeftProps _this;
525 public Xcls_Box7(Xcls_LeftProps _owner )
528 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
532 // set gobject values
533 var child_1 = new Xcls_Button8( _this );
535 this.el.append( child_1.el );
536 var child_2 = new Xcls_Button10( _this );
538 this.el.append( child_2.el );
539 var child_3 = new Xcls_Button12( _this );
541 this.el.append( child_3.el );
542 var child_4 = new Xcls_Button14( _this );
544 this.el.append( child_4.el );
545 var child_5 = new Xcls_Button16( _this );
547 this.el.append( child_5.el );
548 var child_6 = new Xcls_Separator18( _this );
550 this.el.append( child_6.el );
551 var child_7 = new Xcls_Button19( _this );
553 this.el.append( child_7.el );
554 var child_8 = new Xcls_Button21( _this );
556 this.el.append( child_8.el );
557 var child_9 = new Xcls_Button23( _this );
559 this.el.append( child_9.el );
560 var child_10 = new Xcls_Separator25( _this );
562 this.el.append( child_10.el );
563 var child_11 = new Xcls_Button26( _this );
565 this.el.append( child_11.el );
566 var child_12 = new Xcls_Button28( _this );
568 this.el.append( child_12.el );
569 var child_13 = new Xcls_Button30( _this );
571 this.el.append( child_13.el );
572 var child_14 = new Xcls_Separator32( _this );
574 this.el.append( child_14.el );
575 var child_15 = new Xcls_Button33( _this );
577 this.el.append( child_15.el );
578 var child_16 = new Xcls_Button35( _this );
580 this.el.append( child_16.el );
581 var child_17 = new Xcls_Button37( _this );
583 this.el.append( child_17.el );
586 // user defined functions
588 public class Xcls_Button8 : Object
590 public Gtk.Button el;
591 private Xcls_LeftProps _this;
597 public Xcls_Button8(Xcls_LeftProps _owner )
600 this.el = new Gtk.Button();
604 // set gobject values
605 this.el.has_frame = false;
606 var child_1 = new Xcls_Label9( _this );
607 this.el.child = child_1.el;
610 this.el.clicked.connect( () => {
611 _this.addpop.el.hide();
612 // is this userdef or special??
613 var add = new JsRender.NodeProp.prop("id");
614 if (_this.node.has_prop_key(add)) {
618 _this.node.add_prop( add );
620 _this.view.editProp( add );
625 // user defined functions
627 public class Xcls_Label9 : Object
630 private Xcls_LeftProps _this;
636 public Xcls_Label9(Xcls_LeftProps _owner )
639 this.el = new Gtk.Label( "id: _this.{ID} (Vala)" );
643 // set gobject values
644 this.el.halign = Gtk.Align.START;
645 this.el.tooltip_text = "Using _this.{ID} will map to this element";
648 // user defined functions
652 public class Xcls_Button10 : Object
654 public Gtk.Button el;
655 private Xcls_LeftProps _this;
661 public Xcls_Button10(Xcls_LeftProps _owner )
664 this.el = new Gtk.Button();
668 // set gobject values
669 this.el.has_frame = false;
670 var child_1 = new Xcls_Label11( _this );
671 this.el.child = child_1.el;
674 this.el.clicked.connect( ( ) => {
677 _this.addpop.el.hide();
678 // is this userdef or special??
679 var add = new JsRender.NodeProp.special("pack", "add");
680 if (_this.node.has_prop_key(add)) {
684 _this.node.add_prop( add );
686 _this.view.editProp( add );
692 // user defined functions
694 public class Xcls_Label11 : Object
697 private Xcls_LeftProps _this;
703 public Xcls_Label11(Xcls_LeftProps _owner )
706 this.el = new Gtk.Label( "pack: Pack method (Vala)" );
710 // set gobject values
711 this.el.halign = Gtk.Align.START;
712 this.el.tooltip_text = "how to pack this element onto parent, (method, 2nd arg, 3rd arg) .. the 1st argument is filled by the element";
715 // user defined functions
719 public class Xcls_Button12 : Object
721 public Gtk.Button el;
722 private Xcls_LeftProps _this;
728 public Xcls_Button12(Xcls_LeftProps _owner )
731 this.el = new Gtk.Button();
735 // set gobject values
736 this.el.has_frame = false;
737 var child_1 = new Xcls_Label13( _this );
738 this.el.child = child_1.el;
741 this.el.clicked.connect( ( ) => {
743 _this.addpop.el.hide();
744 // is this userdef or special??
745 var add = new JsRender.NodeProp.special("ctor");
746 if (_this.node.has_prop_key(add)) {
750 _this.node.add_prop( add );
752 _this.view.editProp( add );
757 // user defined functions
759 public class Xcls_Label13 : Object
762 private Xcls_LeftProps _this;
768 public Xcls_Label13(Xcls_LeftProps _owner )
771 this.el = new Gtk.Label( "ctor: Alterative to default contructor (Vala)" );
775 // set gobject values
776 this.el.halign = Gtk.Align.START;
777 this.el.tooltip_text = "eg. \n\nnew Clutter.Image.from_file(.....)";
780 // user defined functions
784 public class Xcls_Button14 : Object
786 public Gtk.Button el;
787 private Xcls_LeftProps _this;
793 public Xcls_Button14(Xcls_LeftProps _owner )
796 this.el = new Gtk.Button();
800 // set gobject values
801 this.el.has_frame = false;
802 var child_1 = new Xcls_Label15( _this );
803 this.el.child = child_1.el;
806 this.el.clicked.connect( ( ) => {
808 _this.addpop.el.hide();
809 // is this userdef or special??
810 var add = new JsRender.NodeProp.special("init","{\n\n}\n" ) ;
811 if (_this.node.has_prop_key(add)) {
815 _this.node.add_prop( add );
817 _this.view.editProp( add );
821 // user defined functions
823 public class Xcls_Label15 : Object
826 private Xcls_LeftProps _this;
832 public Xcls_Label15(Xcls_LeftProps _owner )
835 this.el = new Gtk.Label( "init: initialziation code (vala)" );
839 // set gobject values
840 this.el.halign = Gtk.Align.START;
841 this.el.tooltip_text = "This code is called after the ctor";
844 // user defined functions
848 public class Xcls_Button16 : Object
850 public Gtk.Button el;
851 private Xcls_LeftProps _this;
857 public Xcls_Button16(Xcls_LeftProps _owner )
860 this.el = new Gtk.Button();
864 // set gobject values
865 this.el.has_frame = false;
866 var child_1 = new Xcls_Label17( _this );
867 this.el.child = child_1.el;
870 this.el.clicked.connect( () => {
871 _this.addpop.el.hide();
873 // is this userdef or special??
874 var add = new JsRender.NodeProp.prop("cms-id","string", "" ) ;
875 if (_this.node.has_prop_key(add)) {
879 _this.node.add_prop( add );
881 _this.view.editProp( add );
886 // user defined functions
888 public class Xcls_Label17 : Object
891 private Xcls_LeftProps _this;
897 public Xcls_Label17(Xcls_LeftProps _owner )
900 this.el = new Gtk.Label( "cms-id: (Roo JS/Pman library)" );
904 // set gobject values
905 this.el.halign = Gtk.Align.START;
906 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";
909 // user defined functions
913 public class Xcls_Separator18 : Object
915 public Gtk.Separator el;
916 private Xcls_LeftProps _this;
922 public Xcls_Separator18(Xcls_LeftProps _owner )
925 this.el = new Gtk.Separator( Gtk.Orientation.HORIZONTAL );
929 // set gobject values
932 // user defined functions
935 public class Xcls_Button19 : Object
937 public Gtk.Button el;
938 private Xcls_LeftProps _this;
944 public Xcls_Button19(Xcls_LeftProps _owner )
947 this.el = new Gtk.Button();
951 // set gobject values
952 this.el.has_frame = false;
953 var child_1 = new Xcls_Label20( _this );
954 this.el.child = child_1.el;
957 this.el.clicked.connect( (self) => {
958 _this.addpop.el.hide();
959 _this.view.popover.show(
962 new JsRender.NodeProp.user("", "string", "") ,
970 // user defined functions
972 public class Xcls_Label20 : Object
975 private Xcls_LeftProps _this;
981 public Xcls_Label20(Xcls_LeftProps _owner )
984 this.el = new Gtk.Label( "String" );
988 // set gobject values
989 this.el.halign = Gtk.Align.START;
990 this.el.tooltip_text = "Add a user defined string property";
993 // user defined functions
997 public class Xcls_Button21 : Object
999 public Gtk.Button el;
1000 private Xcls_LeftProps _this;
1006 public Xcls_Button21(Xcls_LeftProps _owner )
1009 this.el = new Gtk.Button();
1013 // set gobject values
1014 this.el.has_frame = false;
1015 var child_1 = new Xcls_Label22( _this );
1016 this.el.child = child_1.el;
1019 this.el.clicked.connect( ( ) =>{
1021 _this.addpop.el.hide();
1022 _this.view.popover.show(
1025 new JsRender.NodeProp.user("", "int", "0") ,
1033 // user defined functions
1035 public class Xcls_Label22 : Object
1037 public Gtk.Label el;
1038 private Xcls_LeftProps _this;
1044 public Xcls_Label22(Xcls_LeftProps _owner )
1047 this.el = new Gtk.Label( "Number" );
1051 // set gobject values
1052 this.el.halign = Gtk.Align.START;
1053 this.el.tooltip_text = "Add a user defined number property";
1056 // user defined functions
1060 public class Xcls_Button23 : Object
1062 public Gtk.Button el;
1063 private Xcls_LeftProps _this;
1069 public Xcls_Button23(Xcls_LeftProps _owner )
1072 this.el = new Gtk.Button();
1076 // set gobject values
1077 this.el.has_frame = false;
1078 var child_1 = new Xcls_Label24( _this );
1079 this.el.child = child_1.el;
1082 this.el.clicked.connect( ( ) =>{
1084 _this.addpop.el.hide();
1085 _this.view.popover.show(
1088 new JsRender.NodeProp.user("", "bool", "true") ,
1096 // user defined functions
1098 public class Xcls_Label24 : Object
1100 public Gtk.Label el;
1101 private Xcls_LeftProps _this;
1107 public Xcls_Label24(Xcls_LeftProps _owner )
1110 this.el = new Gtk.Label( "Boolean" );
1114 // set gobject values
1115 this.el.halign = Gtk.Align.START;
1116 this.el.tooltip_text = "Add a user defined boolean property";
1119 // user defined functions
1123 public class Xcls_Separator25 : Object
1125 public Gtk.Separator el;
1126 private Xcls_LeftProps _this;
1132 public Xcls_Separator25(Xcls_LeftProps _owner )
1135 this.el = new Gtk.Separator( Gtk.Orientation.HORIZONTAL );
1139 // set gobject values
1142 // user defined functions
1145 public class Xcls_Button26 : Object
1147 public Gtk.Button el;
1148 private Xcls_LeftProps _this;
1154 public Xcls_Button26(Xcls_LeftProps _owner )
1157 this.el = new Gtk.Button();
1161 // set gobject values
1162 this.el.has_frame = false;
1163 var child_1 = new Xcls_Label27( _this );
1164 this.el.child = child_1.el;
1167 this.el.clicked.connect( ( ) =>{
1168 _this.addpop.el.hide();
1169 _this.view.popover.show(
1172 new JsRender.NodeProp.jsmethod("") ,
1181 // user defined functions
1183 public class Xcls_Label27 : Object
1185 public Gtk.Label el;
1186 private Xcls_LeftProps _this;
1192 public Xcls_Label27(Xcls_LeftProps _owner )
1195 this.el = new Gtk.Label( "Javascript Function" );
1199 // set gobject values
1200 this.el.halign = Gtk.Align.START;
1201 this.el.tooltip_text = "Add a javascript function";
1204 // user defined functions
1208 public class Xcls_Button28 : Object
1210 public Gtk.Button el;
1211 private Xcls_LeftProps _this;
1217 public Xcls_Button28(Xcls_LeftProps _owner )
1220 this.el = new Gtk.Button();
1224 // set gobject values
1225 this.el.has_frame = false;
1226 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 );
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 );
1371 this.el.child = child_1.el;
1374 this.el.clicked.connect( ( ) =>{
1375 _this.addpop.el.hide();
1376 _this.view.popover.show(
1379 new JsRender.NodeProp.prop("flexy:if", "string", "value_or_condition") ,
1388 // user defined functions
1390 public class Xcls_Label34 : Object
1392 public Gtk.Label el;
1393 private Xcls_LeftProps _this;
1399 public Xcls_Label34(Xcls_LeftProps _owner )
1402 this.el = new Gtk.Label( "Flexy - If" );
1406 // set gobject values
1407 this.el.halign = Gtk.Align.START;
1408 this.el.tooltip_text = "Add a flexy if (for HTML templates)";
1411 // user defined functions
1415 public class Xcls_Button35 : Object
1417 public Gtk.Button el;
1418 private Xcls_LeftProps _this;
1424 public Xcls_Button35(Xcls_LeftProps _owner )
1427 this.el = new Gtk.Button();
1431 // set gobject values
1432 this.el.has_frame = false;
1433 var child_1 = new Xcls_Label36( _this );
1434 this.el.child = child_1.el;
1437 this.el.clicked.connect( ( ) =>{
1438 _this.addpop.el.hide();
1439 _this.view.popover.show(
1442 new JsRender.NodeProp.prop("flexy:include", "string", "name_of_file.html") ,
1451 // user defined functions
1453 public class Xcls_Label36 : Object
1455 public Gtk.Label el;
1456 private Xcls_LeftProps _this;
1462 public Xcls_Label36(Xcls_LeftProps _owner )
1465 this.el = new Gtk.Label( "Flexy - Include" );
1469 // set gobject values
1470 this.el.halign = Gtk.Align.START;
1471 this.el.tooltip_text = "Add a flexy include (for HTML templates)";
1474 // user defined functions
1478 public class Xcls_Button37 : Object
1480 public Gtk.Button el;
1481 private Xcls_LeftProps _this;
1487 public Xcls_Button37(Xcls_LeftProps _owner )
1490 this.el = new Gtk.Button();
1494 // set gobject values
1495 this.el.has_frame = false;
1496 this.el.tooltip_markup = "Add a flexy include (for HTML templates)";
1497 var child_1 = new Xcls_Label38( _this );
1498 this.el.child = child_1.el;
1501 this.el.clicked.connect( ( ) =>{
1502 _this.addpop.el.hide();
1503 _this.view.popover.show(
1506 new JsRender.NodeProp.prop("flexy:if", "string", "value_or_condition") ,
1514 // user defined functions
1516 public class Xcls_Label38 : Object
1518 public Gtk.Label el;
1519 private Xcls_LeftProps _this;
1525 public Xcls_Label38(Xcls_LeftProps _owner )
1528 this.el = new Gtk.Label( "Flexy - Foreach" );
1532 // set gobject values
1533 this.el.halign = Gtk.Align.START;
1534 this.el.tooltip_text = "Add a flexy foreach (for HTML templates)";
1537 // user defined functions
1545 public class Xcls_EditProps : Object
1547 public Gtk.ScrolledWindow el;
1548 private Xcls_LeftProps _this;
1552 public bool editing;
1555 public Xcls_EditProps(Xcls_LeftProps _owner )
1558 _this.EditProps = this;
1559 this.el = new Gtk.ScrolledWindow();
1562 this.editing = false;
1564 // set gobject values
1565 this.el.hexpand = true;
1566 this.el.vexpand = true;
1567 new Xcls_view( _this );
1568 this.el.set_child ( _this.view.el );
1574 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
1578 // user defined functions
1580 public class Xcls_view : Object
1582 public Gtk.ColumnView el;
1583 private Xcls_LeftProps _this;
1587 public Gtk.CssProvider css;
1588 public Xcls_PopoverProperty popover;
1591 public Xcls_view(Xcls_LeftProps _owner )
1595 new Xcls_selmodel( _this );
1596 this.el = new Gtk.ColumnView( _this.selmodel.el );
1599 this.popover = null;
1601 // set gobject values
1602 this.el.name = "leftprops-view";
1603 this.el.single_click_activate = false;
1604 this.el.hexpand = true;
1605 this.el.vexpand = true;
1606 this.el.show_row_separators = true;
1607 new Xcls_deletemenu( _this );
1608 var child_3 = new Xcls_GestureClick44( _this );
1610 this.el.add_controller( child_3.el );
1611 var child_4 = new Xcls_GestureClick45( _this );
1613 this.el.add_controller( child_4.el );
1614 new Xcls_keycol( _this );
1615 this.el.append_column ( _this.keycol.el );
1616 new Xcls_valcol( _this );
1617 this.el.append_column ( _this.valcol.el );
1618 new Xcls_ContextMenu( _this );
1624 this.css = new Gtk.CssProvider();
1626 this.css.load_from_string("
1627 #leftprops-view { font-size: 12px;}
1629 #leftprops-view dropdown button {
1633 #leftprops-view cell dropdown label {
1637 #leftprops-view cell {
1641 #leftprops-view cell label, #leftprops-view cell editablelable {
1646 Gtk.StyleContext.add_provider_for_display(
1647 this.el.get_display(),
1649 Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
1656 // user defined functions
1657 public Gtk.Widget? getWidgetAtRow (uint row) {
1660 from https://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465
1661 var colview = gesture.widget;
1662 var line_no = check_list_widget(colview, x,y);
1664 var item = colview.model.get_item(line_no);
1668 GLib.debug("Get Widget At Row %d", (int)row);
1669 var child = this.el.get_first_child();
1671 var reading_header = true;
1673 while (child != null) {
1674 GLib.debug("Got %s", child.get_type().name());
1675 if (reading_header) {
1678 if (child.get_type().name() != "GtkColumnListView") {
1679 child = child.get_next_sibling();
1682 child = child.get_first_child();
1683 reading_header = false;
1686 if (child.get_type().name() != "GtkColumnViewRowWidget") {
1687 child = child.get_next_sibling();
1691 if (line_no == row) {
1692 GLib.debug("Returning widget %s", child.get_type().name());
1693 return (Gtk.Widget)child;
1695 child = child.get_next_sibling();
1697 GLib.debug("Rturning null");
1701 public void editProp (JsRender.NodeProp prop)
1703 var sm = _this.selmodel.el;
1706 GLib.debug("finding node");
1707 _this.selmodel.selectProp(prop);
1709 for (var i = 0 ; i < sm.n_items; i++) {
1710 var r = (JsRender.NodeProp)sm.get_item(i);
1711 if (r.equals(prop)) {
1717 GLib.debug("finding node - cant find it");
1721 var r = this.getWidgetAtRow(sr);
1722 GLib.debug("r = %s", r.get_type().name());
1723 var ca = r.get_first_child();
1724 var ll = (Gtk.Label)ca.get_first_child();
1725 var cb = ca.get_next_sibling();
1726 var b = cb.get_first_child();
1727 var e = (Gtk.EditableLabel) b.get_first_child();
1728 var l = (Gtk.Label) e.get_next_sibling();
1729 var d = (Gtk.DropDown) l.get_next_sibling();
1731 GLib.debug("row key = %s", ll.label);
1732 if (e.get_visible()) {
1733 _this.stop_editor();
1735 //GLib.Timeout.add_once(500, () => {
1736 // var st = (Gtk.Stack) e.get_first_child();
1737 // var ed = (Gtk.Entry) st.get_visible_child();
1738 // ed.grab_focus_without_selecting();
1742 if (d.get_visible()) {
1743 _this.stop_editor();
1747 if (l.get_visible()) {
1748 _this.stop_editor();
1749 _this.show_editor(_this.file, prop.parent, prop);
1755 //gtkcolumnviewrowwidget
1759 // entry / label / dropdown
1763 public int getColAt (double x, double y) {
1766 from https://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465
1769 //Gtk.Allocation alloc = { 0, 0, 0, 0 };
1770 var child = this.el.get_first_child();
1774 while (child != null) {
1775 GLib.debug("Got %s", child.get_type().name());
1777 if (child.get_type().name() == "GtkColumnViewRowWidget") {
1778 child = child.get_first_child();
1782 //child.get_allocation(out alloc);
1783 if (x < (child.get_width() + offx)) {
1786 offx += child.get_width();
1788 child = child.get_next_sibling();
1795 public int getRowAt (double x, double in_y, out string pos) {
1802 from https://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465
1803 var colview = gesture.widget;
1804 var line_no = check_list_widget(colview, x,y);
1806 var item = colview.model.get_item(line_no);
1812 //GLib.debug("offset = %d y = %d", (int) voff, (int) in_y);
1813 var y = in_y + _this.EditProps.el.vadjustment.value;
1814 var child = this.el.get_first_child();
1815 //Gtk.Allocation alloc = { 0, 0, 0, 0 };
1817 var reading_header = true;
1819 var header_height = 0;
1822 while (child != null) {
1823 //GLib.debug("Got %s", child.get_type().name());
1824 if (reading_header) {
1827 if (child.get_type().name() != "GtkColumnListView") {
1828 h += child.get_height();
1829 child = child.get_next_sibling();
1832 // should be columnlistview
1833 child = child.get_first_child();
1834 //GLib.debug("header height=%d", h);
1837 reading_header = false;
1841 if (child.get_type().name() != "GtkColumnViewRowWidget") {
1842 child = child.get_next_sibling();
1846 if (y < header_height) {
1851 var hh = child.get_height();
1852 if (child.has_css_class("node-err") ||
1853 child.has_css_class("node-warn") ||
1854 child.has_css_class("node-depr")) {
1859 //child.get_allocation(out alloc);
1860 //GLib.debug("got cell xy = %d,%d w,h= %d,%d", alloc.x, alloc.y, alloc.width, alloc.height);
1861 //GLib.debug("row %d y= %d %s", line_no, (int) (header_height + alloc.y),
1863 // child.visible ? "VIS" : "hidden");
1865 if (y > (header_height + real_y) && y <= (header_height + real_y + hh) ) {
1866 if (y > ( header_height + real_y + (hh * 0.8))) {
1868 } else if (y > ( header_height + real_y + (hh * 0.2))) {
1873 GLib.debug("getRowAt return : %d, %s", line_no, pos);
1878 if (real_y + hh > y) {
1882 child = child.get_next_sibling();
1888 public class Xcls_deletemenu : Object
1890 public Gtk.Popover el;
1891 private Xcls_LeftProps _this;
1897 public Xcls_deletemenu(Xcls_LeftProps _owner )
1900 _this.deletemenu = this;
1901 this.el = new Gtk.Popover();
1905 // set gobject values
1906 var child_1 = new Xcls_Box42( _this );
1907 this.el.child = child_1.el;
1910 // user defined functions
1912 public class Xcls_Box42 : Object
1915 private Xcls_LeftProps _this;
1921 public Xcls_Box42(Xcls_LeftProps _owner )
1924 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
1928 // set gobject values
1929 var child_1 = new Xcls_Button43( _this );
1931 this.el.append( child_1.el );
1934 // user defined functions
1936 public class Xcls_Button43 : Object
1938 public Gtk.Button el;
1939 private Xcls_LeftProps _this;
1945 public Xcls_Button43(Xcls_LeftProps _owner )
1948 this.el = new Gtk.Button();
1952 // set gobject values
1953 this.el.label = "Delete";
1956 this.el.clicked.connect( ( ) => {
1959 var n = (JsRender.NodeProp) _this.selmodel.el.selected_item;
1961 _this.deletemenu.el.hide();
1962 _this.node.remove_prop(n);
1966 // user defined functions
1971 public class Xcls_GestureClick44 : Object
1973 public Gtk.GestureClick el;
1974 private Xcls_LeftProps _this;
1980 public Xcls_GestureClick44(Xcls_LeftProps _owner )
1983 this.el = new Gtk.GestureClick();
1987 // set gobject values
1990 this.el.pressed.connect( (n_press, in_x, in_y) => {
1992 GLib.debug("Prssed %d", (int) this.el.get_current_button());
1994 var col = _this.view.getColAt(in_x, in_y);
1999 var row = _this.view.getRowAt(in_x, in_y, out pos);
2005 GLib.debug("hit row %d", row);
2006 var prop = _this.selmodel.getPropAt(row);
2007 _this.selmodel.selectProp(prop);
2009 //var point_at = _this.view.getWidgetAtRow(row);
2011 // need to shift down, as ev.y does not inclucde header apparently..
2012 // or popover might be trying to do a central?
2013 // _this.view.editPropertyDetails(prop, (int) in_y + 12);
2014 _this.stop_editor();
2015 _this.view.popover.show(
2025 // user defined functions
2028 public class Xcls_GestureClick45 : Object
2030 public Gtk.GestureClick el;
2031 private Xcls_LeftProps _this;
2037 public Xcls_GestureClick45(Xcls_LeftProps _owner )
2040 this.el = new Gtk.GestureClick();
2044 // set gobject values
2048 this.el.pressed.connect( (n_press, in_x, in_y) => {
2053 var row = _this.view.getRowAt(in_x, in_y, out pos);
2060 _this.stop_editor();
2061 GLib.debug("hit row %d", row);
2062 var prop = _this.selmodel.getPropAt(row);
2063 _this.selmodel.selectProp(prop);
2067 GLib.debug("Prssed %d", (int) this.el.get_current_button());
2068 //_this.deletemenu.el.set_parent(_this.view.el);
2069 if (_this.deletemenu.el.parent == null) {
2070 _this.deletemenu.el.set_parent(_this.main_window.el);
2075 _this.deletemenu.el.set_offset(
2076 (int)in_x - _this.view.el.get_width() ,
2077 (int)in_y - _this.view.el.get_height()
2079 _this.deletemenu.el.set_position(Gtk.PositionType.BOTTOM);
2080 _this.deletemenu.el.popup();
2085 // user defined functions
2088 public class Xcls_selmodel : Object
2090 public Gtk.SingleSelection el;
2091 private Xcls_LeftProps _this;
2097 public Xcls_selmodel(Xcls_LeftProps _owner )
2100 _this.selmodel = this;
2101 new Xcls_model( _this );
2102 this.el = new Gtk.SingleSelection( _this.model.el );
2106 // set gobject values
2107 this.el.can_unselect = true;
2110 // user defined functions
2111 public int propToRow (JsRender.NodeProp prop) {
2112 for (var i = 0 ; i < this.el.n_items; i++) {
2113 var r = (JsRender.NodeProp)this.el.get_item(i);
2114 if (r.equals(prop)) {
2122 public void startEditing (JsRender.NodeProp prop) {
2123 // should we call select?? - caller does int (from windowstate)
2126 public void selectProp (JsRender.NodeProp prop) {
2127 for (var i = 0 ; i < this.el.n_items; i++) {
2128 var r = (JsRender.NodeProp)this.el.get_item(i);
2129 if (r.equals(prop)) {
2130 this.el.selected = i;
2136 public JsRender.NodeProp getPropAt (uint row) {
2138 return (JsRender.NodeProp) this.el.get_item(row);
2143 public class Xcls_model : Object
2145 public GLib.ListStore el;
2146 private Xcls_LeftProps _this;
2152 public Xcls_model(Xcls_LeftProps _owner )
2156 this.el = new GLib.ListStore(typeof(JsRender.NodeProp));
2160 // set gobject values
2163 // user defined functions
2167 public class Xcls_keycol : Object
2169 public Gtk.ColumnViewColumn el;
2170 private Xcls_LeftProps _this;
2176 public Xcls_keycol(Xcls_LeftProps _owner )
2179 _this.keycol = this;
2180 var child_1 = new Xcls_SignalListItemFactory49( _this );
2182 this.el = new Gtk.ColumnViewColumn( "Property", child_1.el );
2186 // set gobject values
2187 this.el.id = "keycol";
2188 this.el.expand = true;
2189 this.el.resizable = true;
2192 // user defined functions
2194 public class Xcls_SignalListItemFactory49 : Object
2196 public Gtk.SignalListItemFactory el;
2197 private Xcls_LeftProps _this;
2203 public Xcls_SignalListItemFactory49(Xcls_LeftProps _owner )
2206 this.el = new Gtk.SignalListItemFactory();
2210 // set gobject values
2213 this.el.setup.connect( (listitem) => {
2214 var lbl = new Gtk.Label("");
2215 ((Gtk.ListItem)listitem).set_child(lbl);
2216 lbl.justify = Gtk.Justification.LEFT;
2218 lbl.use_markup = true;
2219 lbl.ellipsize = Pango.EllipsizeMode.START;
2220 /*lbl.changed.connect(() => {
2221 // notify and save the changed value...
2222 //var prop = (JsRender.NodeProp) ((Gtk.ListItem)listitem.get_item());
2224 //prop.val = lbl.text;
2225 //_this.updateIter(iter,prop);
2229 ((Gtk.ListItem)listitem).activatable = true;
2231 this.el.bind.connect( (listitem) => {
2232 var lb = (Gtk.Label) ((Gtk.ListItem)listitem).get_child();
2233 var item = (JsRender.NodeProp) ((Gtk.ListItem)listitem).get_item();
2236 item.bind_property("to_display_name_prop",
2238 GLib.BindingFlags.SYNC_CREATE);
2239 item.bind_property("to_tooltip_name_prop",
2240 lb, "tooltip_markup",
2241 GLib.BindingFlags.SYNC_CREATE);
2242 // was item (1) in old layout
2248 // user defined functions
2252 public class Xcls_valcol : Object
2254 public Gtk.ColumnViewColumn el;
2255 private Xcls_LeftProps _this;
2261 public Xcls_valcol(Xcls_LeftProps _owner )
2264 _this.valcol = this;
2265 var child_1 = new Xcls_SignalListItemFactory51( _this );
2267 this.el = new Gtk.ColumnViewColumn( "Value", child_1.el );
2271 // set gobject values
2272 this.el.id = "valcol";
2273 this.el.expand = true;
2274 this.el.resizable = true;
2277 // user defined functions
2279 public class Xcls_SignalListItemFactory51 : Object
2281 public Gtk.SignalListItemFactory el;
2282 private Xcls_LeftProps _this;
2286 public bool is_setting;
2289 public Xcls_SignalListItemFactory51(Xcls_LeftProps _owner )
2292 this.el = new Gtk.SignalListItemFactory();
2295 this.is_setting = false;
2297 // set gobject values
2300 this.el.setup.connect( (listitem) => {
2301 var hb = new Gtk.Box(Gtk.Orientation.HORIZONTAL,0);
2302 var elbl = new Gtk.EditableLabel("");
2303 elbl.hexpand = true;
2305 var lbl = new Gtk.Label("");
2308 lbl.use_markup = true;
2310 lbl.ellipsize = Pango.EllipsizeMode.END;
2311 var cb = new Gtk.DropDown(new Gtk.StringList({}), null);
2315 ((Gtk.ListItem)listitem).set_child(hb);
2317 var ef = new Gtk.EventControllerFocus();
2318 ef.enter.connect(() => {
2319 _this.stop_editor();
2320 var prop = (JsRender.NodeProp)((Gtk.ListItem)listitem).get_item();
2321 _this.selmodel.selectProp(prop);
2323 elbl.add_controller(ef);
2326 // dropdown??? - stop editing, and highliht node
2327 var tb = (Gtk.ToggleButton) cb.get_first_child();
2328 tb.clicked.connect(() => {
2329 var prop = (JsRender.NodeProp)((Gtk.ListItem)listitem).get_item();
2331 _this.stop_editor();
2332 _this.selmodel.selectProp(prop);
2335 elbl.changed.connect(() => {
2336 // notify and save the changed value...
2338 //_this.updateIter(iter,prop);
2339 // this should happen automatically
2341 if (!_this.loading && !this.is_setting) {
2342 var prop = (JsRender.NodeProp)((Gtk.ListItem)listitem).get_item();
2345 prop.val = elbl.text;
2346 GLib.debug("calling changed");
2354 cb.notify["selected"].connect(() => {
2355 // dropdown selection changed.
2359 //_this.updateIter(iter,prop);
2360 if (!_this.loading && !this.is_setting) {
2361 var prop = (JsRender.NodeProp)((Gtk.ListItem)listitem).get_item();
2362 var model = (Gtk.StringList)cb.model;
2363 prop.val = model.get_string(cb.selected);
2364 GLib.debug("property set to %s", prop.val);
2365 GLib.debug("calling changed");
2372 var gc = new Gtk.GestureClick();
2373 lbl.add_controller(gc);
2374 gc.pressed.connect(() => {
2375 var prop = (JsRender.NodeProp)((Gtk.ListItem)listitem).get_item();
2376 _this.stop_editor();
2377 _this.show_editor(_this.file, prop.parent, prop);
2383 this.el.bind.connect( (listitem) => {
2384 this.is_setting = true;
2387 var bx = (Gtk.Box) ((Gtk.ListItem)listitem).get_child();
2392 var elbl = (Gtk.EditableLabel)bx.get_first_child();
2393 var lbl = (Gtk.Label) elbl.get_next_sibling();
2394 var cb = (Gtk.DropDown) lbl.get_next_sibling();
2395 // decide if it's a combo or editable text..
2396 var model = (Gtk.StringList) cb.model;
2402 var prop = (JsRender.NodeProp) ((Gtk.ListItem)listitem).get_item();
2403 //GLib.debug("prop = %s", prop.get_type().name());
2404 //GLib.debug("prop.val = %s", prop.val);
2405 //GLib.debug("prop.key = %s", prop.to_display_name());
2407 var use_textarea = prop.useTextArea();
2410 var pal = _this.file.project.palete;
2413 var has_opts = pal.typeOptions(_this.node.fqn(), prop.name, prop.rtype, out opts);
2415 if (!has_opts && prop.ptype == JsRender.NodePropType.RAW) {
2416 use_textarea = true;
2421 prop.bind_property("val_short",
2423 GLib.BindingFlags.SYNC_CREATE);
2424 prop.bind_property("val_tooltip",
2425 lbl, "tooltip_markup",
2426 GLib.BindingFlags.SYNC_CREATE);
2428 this.is_setting = false;
2437 // others... - fill in options for true/false?
2438 // GLib.debug (ktype.up());
2441 while(model.get_n_items() > 0) {
2445 // can not remove - hopefully always empty.
2447 for(var i = 0; i < opts.length; i ++) {
2448 model.append( opts[i]);
2449 // not sure this is a great idea...
2450 if (opts[i].down() == prop.val.down()) {
2454 GLib.debug("Set selected item to %d", sel);
2455 cb.set_selected(sel > -1 ? sel : Gtk.INVALID_LIST_POSITION);
2456 this.is_setting = false;
2460 // see if type is a Enum.
2461 // triggers a changed event
2463 elbl.set_text(prop.val);
2466 this.is_setting = false;
2475 // user defined functions
2479 public class Xcls_ContextMenu : Object
2481 public Gtk.Popover el;
2482 private Xcls_LeftProps _this;
2488 public Xcls_ContextMenu(Xcls_LeftProps _owner )
2491 _this.ContextMenu = this;
2492 this.el = new Gtk.Popover();
2496 // set gobject values
2497 var child_1 = new Xcls_Box53( _this );
2498 this.el.child = child_1.el;
2501 // user defined functions
2503 public class Xcls_Box53 : Object
2506 private Xcls_LeftProps _this;
2512 public Xcls_Box53(Xcls_LeftProps _owner )
2515 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
2519 // set gobject values
2520 var child_1 = new Xcls_Button54( _this );
2522 this.el.append( child_1.el );
2525 // user defined functions
2527 public class Xcls_Button54 : Object
2529 public Gtk.Button el;
2530 private Xcls_LeftProps _this;
2536 public Xcls_Button54(Xcls_LeftProps _owner )
2539 this.el = new Gtk.Button();
2543 // set gobject values
2544 this.el.label = "Delete";
2547 this.el.activate.connect( ( ) =>{
2548 _this.deleteSelected();
2553 // user defined functions