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 Xcls_PopoverProperty popover;
1590 public Xcls_view(Xcls_LeftProps _owner )
1594 new Xcls_selmodel( _this );
1595 this.el = new Gtk.ColumnView( _this.selmodel.el );
1598 this.popover = null;
1600 // set gobject values
1601 this.el.name = "leftprops-view";
1602 this.el.single_click_activate = false;
1603 this.el.hexpand = true;
1604 this.el.vexpand = true;
1605 this.el.show_row_separators = true;
1606 new Xcls_deletemenu( _this );
1607 var child_3 = new Xcls_GestureClick45( _this );
1609 this.el.add_controller( child_3.el );
1610 var child_4 = new Xcls_GestureClick46( _this );
1612 this.el.add_controller( child_4.el );
1613 new Xcls_keycol( _this );
1614 this.el.append_column ( _this.keycol.el );
1615 new Xcls_valcol( _this );
1616 this.el.append_column ( _this.valcol.el );
1617 new Xcls_ContextMenu( _this );
1620 // user defined functions
1621 public Gtk.Widget? getWidgetAtRow (uint row) {
1624 from https://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465
1625 var colview = gesture.widget;
1626 var line_no = check_list_widget(colview, x,y);
1628 var item = colview.model.get_item(line_no);
1632 GLib.debug("Get Widget At Row %d", (int)row);
1633 var child = this.el.get_first_child();
1635 var reading_header = true;
1637 while (child != null) {
1638 GLib.debug("Got %s", child.get_type().name());
1639 if (reading_header) {
1642 if (child.get_type().name() != "GtkColumnListView") {
1643 child = child.get_next_sibling();
1646 child = child.get_first_child();
1647 reading_header = false;
1650 if (child.get_type().name() != "GtkColumnViewRowWidget") {
1651 child = child.get_next_sibling();
1655 if (line_no == row) {
1656 GLib.debug("Returning widget %s", child.get_type().name());
1657 return (Gtk.Widget)child;
1659 child = child.get_next_sibling();
1661 GLib.debug("Rturning null");
1665 public void editProp (JsRender.NodeProp prop)
1667 var sm = _this.selmodel.el;
1670 GLib.debug("finding node");
1671 _this.selmodel.selectProp(prop);
1673 for (var i = 0 ; i < sm.n_items; i++) {
1674 var r = (JsRender.NodeProp)sm.get_item(i);
1675 if (r.equals(prop)) {
1681 GLib.debug("finding node - cant find it");
1685 var r = this.getWidgetAtRow(sr);
1686 GLib.debug("r = %s", r.get_type().name());
1687 var ca = r.get_first_child();
1688 var ll = (Gtk.Label)ca.get_first_child();
1689 var cb = ca.get_next_sibling();
1690 var b = cb.get_first_child();
1691 var e = (Gtk.EditableLabel) b.get_first_child();
1692 var l = (Gtk.Label) e.get_next_sibling();
1693 var d = (Gtk.DropDown) l.get_next_sibling();
1695 GLib.debug("row key = %s", ll.label);
1696 if (e.get_visible()) {
1697 _this.stop_editor();
1699 //GLib.Timeout.add_once(500, () => {
1700 // var st = (Gtk.Stack) e.get_first_child();
1701 // var ed = (Gtk.Entry) st.get_visible_child();
1702 // ed.grab_focus_without_selecting();
1706 if (d.get_visible()) {
1707 _this.stop_editor();
1711 if (l.get_visible()) {
1712 _this.stop_editor();
1713 _this.show_editor(_this.file, prop.parent, prop);
1719 //gtkcolumnviewrowwidget
1723 // entry / label / dropdown
1727 public int getColAt (double x, double y) {
1730 from https://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465
1733 //Gtk.Allocation alloc = { 0, 0, 0, 0 };
1734 var child = this.el.get_first_child();
1738 while (child != null) {
1739 GLib.debug("Got %s", child.get_type().name());
1741 if (child.get_type().name() == "GtkColumnViewRowWidget") {
1742 child = child.get_first_child();
1746 //child.get_allocation(out alloc);
1747 if (x < (child.get_width() + offx)) {
1750 offx += child.get_width();
1752 child = child.get_next_sibling();
1759 public int getRowAt (double x, double y, out string pos) {
1762 var w = this.el.pick(x, y, Gtk.PickFlags.DEFAULT);
1763 //GLib.debug("got widget %s", w == null ? "nothing" : w.get_type().name());
1768 var row= w.get_ancestor(GLib.Type.from_name("GtkColumnViewRowWidget"));
1773 //GLib.debug("got colview %s", row == null ? "nothing" : row.get_type().name());
1778 while (cr.get_prev_sibling() != null) {
1780 cr = cr.get_prev_sibling();
1783 //GLib.debug("row number is %d", rn);
1784 //GLib.debug("click %d, %d", (int)x, (int)y);
1786 Graphene.Rect bounds;
1787 row.compute_bounds(this.el, out bounds);
1788 //GLib.debug("click x=%d, y=%d, w=%d, h=%d",
1789 // (int)bounds.get_x(), (int)bounds.get_y(),
1790 // (int)bounds.get_width(), (int)bounds.get_height()
1792 var ypos = y - bounds.get_y();
1793 //GLib.debug("rel ypos = %d", (int)ypos);
1794 var rpos = 100.0 * (ypos / bounds.get_height());
1795 //GLib.debug("rel pos = %d %%", (int)rpos);
1800 } else if (rpos < 20) {
1806 public class Xcls_deletemenu : Object
1808 public Gtk.Popover el;
1809 private Xcls_LeftProps _this;
1815 public Xcls_deletemenu(Xcls_LeftProps _owner )
1818 _this.deletemenu = this;
1819 this.el = new Gtk.Popover();
1823 // set gobject values
1824 var child_1 = new Xcls_Box42( _this );
1825 this.el.child = child_1.el;
1828 // user defined functions
1830 public class Xcls_Box42 : Object
1833 private Xcls_LeftProps _this;
1839 public Xcls_Box42(Xcls_LeftProps _owner )
1842 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
1846 // set gobject values
1847 var child_1 = new Xcls_Button43( _this );
1849 this.el.append( child_1.el );
1852 // user defined functions
1854 public class Xcls_Button43 : Object
1856 public Gtk.Button el;
1857 private Xcls_LeftProps _this;
1863 public Xcls_Button43(Xcls_LeftProps _owner )
1866 this.el = new Gtk.Button();
1870 // set gobject values
1871 this.el.has_frame = false;
1872 this.el.label = "Delete";
1873 var child_1 = new Xcls_Label44( _this );
1874 this.el.child = child_1.el;
1877 this.el.clicked.connect( ( ) => {
1880 var n = (JsRender.NodeProp) _this.selmodel.el.selected_item;
1882 _this.deletemenu.el.hide();
1883 _this.node.remove_prop(n);
1887 // user defined functions
1889 public class Xcls_Label44 : Object
1891 public Gtk.Label el;
1892 private Xcls_LeftProps _this;
1898 public Xcls_Label44(Xcls_LeftProps _owner )
1901 this.el = new Gtk.Label( "Delete Property / Method" );
1905 // set gobject values
1906 this.el.halign = Gtk.Align.START;
1909 // user defined functions
1915 public class Xcls_GestureClick45 : Object
1917 public Gtk.GestureClick el;
1918 private Xcls_LeftProps _this;
1924 public Xcls_GestureClick45(Xcls_LeftProps _owner )
1927 this.el = new Gtk.GestureClick();
1931 // set gobject values
1934 this.el.pressed.connect( (n_press, in_x, in_y) => {
1936 GLib.debug("Prssed %d", (int) this.el.get_current_button());
1938 var col = _this.view.getColAt(in_x, in_y);
1943 var row = _this.view.getRowAt(in_x, in_y, out pos);
1949 GLib.debug("hit row %d", row);
1950 var prop = _this.selmodel.getPropAt(row);
1951 _this.selmodel.selectProp(prop);
1953 //var point_at = _this.view.getWidgetAtRow(row);
1955 // need to shift down, as ev.y does not inclucde header apparently..
1956 // or popover might be trying to do a central?
1957 // _this.view.editPropertyDetails(prop, (int) in_y + 12);
1958 _this.stop_editor();
1959 _this.view.popover.show(
1969 // user defined functions
1972 public class Xcls_GestureClick46 : Object
1974 public Gtk.GestureClick el;
1975 private Xcls_LeftProps _this;
1981 public Xcls_GestureClick46(Xcls_LeftProps _owner )
1984 this.el = new Gtk.GestureClick();
1988 // set gobject values
1992 this.el.pressed.connect( (n_press, in_x, in_y) => {
1997 var row = _this.view.getRowAt(in_x, in_y, out pos);
2004 _this.stop_editor();
2005 GLib.debug("hit row %d", row);
2006 var prop = _this.selmodel.getPropAt(row);
2007 _this.selmodel.selectProp(prop);
2011 GLib.debug("Prssed %d", (int) this.el.get_current_button());
2012 //_this.deletemenu.el.set_parent(_this.view.el);
2013 if (_this.deletemenu.el.parent == null) {
2014 _this.deletemenu.el.set_parent(_this.main_window.el);
2019 _this.deletemenu.el.set_offset(
2020 (int)in_x - _this.view.el.get_width() ,
2021 (int)in_y - _this.view.el.get_height()
2023 _this.deletemenu.el.set_position(Gtk.PositionType.BOTTOM);
2024 _this.deletemenu.el.popup();
2029 // user defined functions
2032 public class Xcls_selmodel : Object
2034 public Gtk.SingleSelection el;
2035 private Xcls_LeftProps _this;
2041 public Xcls_selmodel(Xcls_LeftProps _owner )
2044 _this.selmodel = this;
2045 new Xcls_model( _this );
2046 this.el = new Gtk.SingleSelection( _this.model.el );
2050 // set gobject values
2051 this.el.can_unselect = true;
2054 // user defined functions
2055 public int propToRow (JsRender.NodeProp prop) {
2056 for (var i = 0 ; i < this.el.n_items; i++) {
2057 var r = (JsRender.NodeProp)this.el.get_item(i);
2058 if (r.equals(prop)) {
2066 public void startEditing (JsRender.NodeProp prop) {
2067 // should we call select?? - caller does int (from windowstate)
2070 public void selectProp (JsRender.NodeProp prop) {
2071 for (var i = 0 ; i < this.el.n_items; i++) {
2072 var r = (JsRender.NodeProp)this.el.get_item(i);
2073 if (r.equals(prop)) {
2074 this.el.selected = i;
2080 public JsRender.NodeProp getPropAt (uint row) {
2082 return (JsRender.NodeProp) this.el.get_item(row);
2087 public class Xcls_model : Object
2089 public GLib.ListStore el;
2090 private Xcls_LeftProps _this;
2096 public Xcls_model(Xcls_LeftProps _owner )
2100 this.el = new GLib.ListStore(typeof(JsRender.NodeProp));
2104 // set gobject values
2107 // user defined functions
2111 public class Xcls_keycol : Object
2113 public Gtk.ColumnViewColumn el;
2114 private Xcls_LeftProps _this;
2120 public Xcls_keycol(Xcls_LeftProps _owner )
2123 _this.keycol = this;
2124 var child_1 = new Xcls_SignalListItemFactory50( _this );
2126 this.el = new Gtk.ColumnViewColumn( "Property", child_1.el );
2130 // set gobject values
2131 this.el.id = "keycol";
2132 this.el.expand = true;
2133 this.el.resizable = true;
2136 // user defined functions
2138 public class Xcls_SignalListItemFactory50 : Object
2140 public Gtk.SignalListItemFactory el;
2141 private Xcls_LeftProps _this;
2147 public Xcls_SignalListItemFactory50(Xcls_LeftProps _owner )
2150 this.el = new Gtk.SignalListItemFactory();
2154 // set gobject values
2157 this.el.setup.connect( (listitem) => {
2158 var lbl = new Gtk.Label("");
2159 ((Gtk.ListItem)listitem).set_child(lbl);
2160 lbl.justify = Gtk.Justification.LEFT;
2162 lbl.use_markup = true;
2163 lbl.ellipsize = Pango.EllipsizeMode.START;
2164 /*lbl.changed.connect(() => {
2165 // notify and save the changed value...
2166 //var prop = (JsRender.NodeProp) ((Gtk.ListItem)listitem.get_item());
2168 //prop.val = lbl.text;
2169 //_this.updateIter(iter,prop);
2173 ((Gtk.ListItem)listitem).activatable = true;
2175 this.el.bind.connect( (listitem) => {
2176 var lb = (Gtk.Label) ((Gtk.ListItem)listitem).get_child();
2177 var item = (JsRender.NodeProp) ((Gtk.ListItem)listitem).get_item();
2180 item.bind_property("to_display_name_prop",
2182 GLib.BindingFlags.SYNC_CREATE);
2183 item.bind_property("to_tooltip_name_prop",
2184 lb, "tooltip_markup",
2185 GLib.BindingFlags.SYNC_CREATE);
2186 // was item (1) in old layout
2192 // user defined functions
2196 public class Xcls_valcol : Object
2198 public Gtk.ColumnViewColumn el;
2199 private Xcls_LeftProps _this;
2205 public Xcls_valcol(Xcls_LeftProps _owner )
2208 _this.valcol = this;
2209 var child_1 = new Xcls_SignalListItemFactory52( _this );
2211 this.el = new Gtk.ColumnViewColumn( "Value", child_1.el );
2215 // set gobject values
2216 this.el.id = "valcol";
2217 this.el.expand = true;
2218 this.el.resizable = true;
2221 // user defined functions
2223 public class Xcls_SignalListItemFactory52 : Object
2225 public Gtk.SignalListItemFactory el;
2226 private Xcls_LeftProps _this;
2230 public bool is_setting;
2233 public Xcls_SignalListItemFactory52(Xcls_LeftProps _owner )
2236 this.el = new Gtk.SignalListItemFactory();
2239 this.is_setting = false;
2241 // set gobject values
2244 this.el.setup.connect( (listitem) => {
2245 var hb = new Gtk.Box(Gtk.Orientation.HORIZONTAL,0);
2246 var elbl = new Gtk.EditableLabel("");
2247 elbl.hexpand = true;
2249 var lbl = new Gtk.Label("");
2252 lbl.use_markup = true;
2254 lbl.ellipsize = Pango.EllipsizeMode.END;
2255 var cb = new Gtk.DropDown(new Gtk.StringList({}), null);
2259 ((Gtk.ListItem)listitem).set_child(hb);
2261 var ef = new Gtk.EventControllerFocus();
2262 ef.enter.connect(() => {
2263 _this.stop_editor();
2264 var prop = (JsRender.NodeProp)((Gtk.ListItem)listitem).get_item();
2265 _this.selmodel.selectProp(prop);
2267 elbl.add_controller(ef);
2270 // dropdown??? - stop editing, and highliht node
2271 var tb = (Gtk.ToggleButton) cb.get_first_child();
2272 tb.clicked.connect(() => {
2273 var prop = (JsRender.NodeProp)((Gtk.ListItem)listitem).get_item();
2275 _this.stop_editor();
2276 _this.selmodel.selectProp(prop);
2279 elbl.changed.connect(() => {
2280 // notify and save the changed value...
2282 //_this.updateIter(iter,prop);
2283 // this should happen automatically
2285 if (!_this.loading && !this.is_setting) {
2286 var prop = (JsRender.NodeProp)((Gtk.ListItem)listitem).get_item();
2289 prop.val = elbl.text;
2290 GLib.debug("calling changed");
2298 cb.notify["selected"].connect(() => {
2299 // dropdown selection changed.
2303 //_this.updateIter(iter,prop);
2304 if (!_this.loading && !this.is_setting) {
2305 var prop = (JsRender.NodeProp)((Gtk.ListItem)listitem).get_item();
2306 var model = (Gtk.StringList)cb.model;
2307 prop.val = model.get_string(cb.selected);
2308 GLib.debug("property set to %s", prop.val);
2309 GLib.debug("calling changed");
2316 var gc = new Gtk.GestureClick();
2317 lbl.add_controller(gc);
2318 gc.pressed.connect(() => {
2319 var prop = (JsRender.NodeProp)((Gtk.ListItem)listitem).get_item();
2320 _this.stop_editor();
2321 _this.show_editor(_this.file, prop.parent, prop);
2327 this.el.bind.connect( (listitem) => {
2328 this.is_setting = true;
2331 var bx = (Gtk.Box) ((Gtk.ListItem)listitem).get_child();
2336 var elbl = (Gtk.EditableLabel)bx.get_first_child();
2337 var lbl = (Gtk.Label) elbl.get_next_sibling();
2338 var cb = (Gtk.DropDown) lbl.get_next_sibling();
2339 // decide if it's a combo or editable text..
2340 var model = (Gtk.StringList) cb.model;
2346 var prop = (JsRender.NodeProp) ((Gtk.ListItem)listitem).get_item();
2347 //GLib.debug("prop = %s", prop.get_type().name());
2348 //GLib.debug("prop.val = %s", prop.val);
2349 //GLib.debug("prop.key = %s", prop.to_display_name());
2351 var use_textarea = prop.useTextArea();
2354 var pal = _this.file.project.palete;
2357 var has_opts = pal.typeOptions(_this.node.fqn(), prop.name, prop.rtype, out opts);
2359 if (!has_opts && prop.ptype == JsRender.NodePropType.RAW) {
2360 use_textarea = true;
2365 prop.bind_property("val_short",
2367 GLib.BindingFlags.SYNC_CREATE);
2368 prop.bind_property("val_tooltip",
2369 lbl, "tooltip_markup",
2370 GLib.BindingFlags.SYNC_CREATE);
2372 this.is_setting = false;
2381 // others... - fill in options for true/false?
2382 // GLib.debug (ktype.up());
2385 while(model.get_n_items() > 0) {
2389 // can not remove - hopefully always empty.
2391 for(var i = 0; i < opts.length; i ++) {
2392 model.append( opts[i]);
2393 // not sure this is a great idea...
2394 if (opts[i].down() == prop.val.down()) {
2398 GLib.debug("Set selected item to %d", sel);
2399 cb.set_selected(sel > -1 ? sel : Gtk.INVALID_LIST_POSITION);
2400 this.is_setting = false;
2404 // see if type is a Enum.
2405 // triggers a changed event
2407 elbl.set_text(prop.val);
2410 this.is_setting = false;
2419 // user defined functions
2423 public class Xcls_ContextMenu : Object
2425 public Gtk.Popover el;
2426 private Xcls_LeftProps _this;
2432 public Xcls_ContextMenu(Xcls_LeftProps _owner )
2435 _this.ContextMenu = this;
2436 this.el = new Gtk.Popover();
2440 // set gobject values
2441 var child_1 = new Xcls_Box54( _this );
2442 this.el.child = child_1.el;
2445 // user defined functions
2447 public class Xcls_Box54 : Object
2450 private Xcls_LeftProps _this;
2456 public Xcls_Box54(Xcls_LeftProps _owner )
2459 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
2463 // set gobject values
2464 var child_1 = new Xcls_Button55( _this );
2466 this.el.append( child_1.el );
2469 // user defined functions
2471 public class Xcls_Button55 : Object
2473 public Gtk.Button el;
2474 private Xcls_LeftProps _this;
2480 public Xcls_Button55(Xcls_LeftProps _owner )
2483 this.el = new Gtk.Button();
2487 // set gobject values
2488 this.el.label = "Delete";
2491 this.el.activate.connect( ( ) =>{
2492 _this.deleteSelected();
2497 // user defined functions