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_AddPropertyPopup AddPropertyPopup;
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 signal void changed ();
32 public JsRender.JsRender file;
33 public JsRender.Node node;
34 public signal void show_editor (JsRender.JsRender file, JsRender.Node node, JsRender.NodeProp prop);
37 public Xcls_LeftProps()
40 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
44 this.allow_edit = false;
45 this.main_window = null;
48 this.el.homogeneous = false ;
49 this.el.hexpand = true;
50 this.el.vexpand = true;
51 var child_1 = new Xcls_Box2( _this );
53 this.el.append( child_1.el );
54 new Xcls_EditProps( _this );
55 this.el.append( _this.EditProps.el );
58 // user defined functions
59 public string keySortFormat (string key) {
60 // listeners first - with 0
67 var bits = key.split(" ");
70 return "2 " + bits[bits.length -1];
74 return "3 " + bits[bits.length -1];
79 return "4 " + bits[bits.length -1];
82 return "5 " + bits[bits.length -1];
88 public void updateErrors () {
90 var ar = file.getErrors();
93 this.last_error_counter = file.error_counter ;
97 if (this.last_error_counter == file.error_counter) {
102 foreach(var diag in ar) {
105 // print("get inter\n");
106 var node= file.lineToNode( (int)diag.range.start.line) ;
107 if (node == null || node.oid != this.node.oid) {
110 var prop = node.lineToProp( (int)diag.range.start.line) ;
112 var row = _this.selmodel.propToRow(prop);
116 var w = this.view.getWidgetAtRow(row);
120 if (!w.has_css_class("node-error")) {
121 w.add_css_class("node-error");
128 public string keyFormat (string val, string type) {
130 // Glib.markup_escape_text(val);
132 if (type == "listener") {
133 return "<span font_weight=\"bold\" color=\"#660000\">" +
134 GLib.Markup.escape_text(val) +
138 if (val.length < 1) {
139 return "<span color=\"#FF0000\">--empty--</span>";
144 //# - object properties
146 // all of these... - display value is last element..
147 var ar = val.strip().split(" ");
150 var dval = GLib.Markup.escape_text(ar[ar.length-1]);
156 case '@': // signal // just bold balck?
157 if (dval[0] == '@') {
158 dval = dval.substring(1);
161 return @"<span font_weight=\"bold\">@ $dval</span>";
162 case '#': // object properties?
163 if (dval[0] == '#') {
164 dval = dval.substring(1);
166 return @"<span font_weight=\"bold\">$dval</span>";
168 if (dval[0] == '*') {
169 dval = dval.substring(1);
171 return @"<span color=\"#0000CC\" font_weight=\"bold\">$dval</span>";
173 if (dval[0] == '$') {
174 dval = dval.substring(1);
176 return @"<span style=\"italic\">$dval</span>";
177 case '|': // user defined methods
178 if (dval[0] == '|') {
179 dval = dval.substring(1);
181 return @"<span color=\"#008000\" font_weight=\"bold\">$dval</span>";
192 public void deleteSelected () {
200 var s = this.view.el.get_selection();
201 s.get_selected(out mod, out iter);
205 mod.get_value(iter, 0 , out gval);
206 var prop = (JsRender.NodeProp)gval;
208 this.load(this.file, this.node);
211 // stop editor after fetching property - otherwise prop is null.
216 case JsRender.NodePropType.LISTENER:
217 this.node.listeners.unset(prop.to_index_key());
221 this.node.props.unset(prop.to_index_key());
224 this.load(this.file, this.node);
229 public void removeErrors () {
230 var child = this.view.el.get_first_child();
232 var reading_header = true;
234 while (child != null) {
235 GLib.debug("Got %s", child.get_type().name());
237 if (reading_header) {
240 if (child.get_type().name() != "GtkColumnListView") {
242 child = child.get_next_sibling();
245 // should be columnlistview
246 child = child.get_first_child();
250 reading_header = false;
254 if (!child.has_css_class("error-node")) {
255 child.remove_css_class("error-node");
258 child = child.get_next_sibling();
260 //GLib.debug("Rturning null");
263 public void a_addProp (JsRender.NodeProp prop) {
264 // info includes key, val, skel, etype..
265 //console.dump(info);
266 //type = info.type.toLowerCase();
267 //var data = this.toJS();
270 if (prop.ptype == JsRender.NodePropType.LISTENER) {
271 if (this.node.listeners.has_key(prop.name)) {
274 this.node.listeners.set(prop.name,prop);
276 assert(this.node != null);
277 assert(this.node.props != null);
278 if (this.node.props.has_key(prop.to_index_key())) {
281 this.node.props.set(prop.to_index_key(),prop);
286 this.load(this.file, this.node);
291 GLib.debug("trying to find new iter");
296 public void load (JsRender.JsRender file, JsRender.Node? node)
298 // not sure when to initialize this - we should do it on setting main window really.
301 if (this.view.popover == null) {
302 this.view.popover = new Xcls_PopoverProperty();
303 this.view.popover.mainwindow = _this.main_window;
307 if (this.node != null) {
308 this.node.dupeProps(); // ensures removeall will not do somethign silly
312 GLib.debug("load leftprops\n");
318 this.model.el.remove_all();
320 //this.get('/RightEditor').el.hide();
324 node.loadProps(this.model.el);
327 //GLib.debug("clear selection\n");
329 this.loading = false;
330 this.selmodel.el.set_selected(Gtk.INVALID_LIST_POSITION);
333 //this.model.el.set_sort_column_id(4,Gtk.SortType.ASCENDING); // sort by real key..
335 // this.view.el.get_selection().unselect_all();
337 // _this.keycol.el.set_max_width(_this.EditProps.el.get_allocated_width()/ 2);
338 // _this.valcol.el.set_max_width(_this.EditProps.el.get_allocated_width()/ 2);
341 public class Xcls_Box2 : Object
344 private Xcls_LeftProps _this;
350 public Xcls_Box2(Xcls_LeftProps _owner )
353 this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
357 // set gobject values
358 this.el.hexpand = true;
359 var child_1 = new Xcls_Label3( _this );
361 this.el.append( child_1.el );
362 var child_2 = new Xcls_Button4( _this );
364 this.el.append( child_2.el );
365 var child_3 = new Xcls_Button5( _this );
367 this.el.append( child_3.el );
368 var child_4 = new Xcls_Button6( _this );
370 this.el.append( child_4.el );
373 // user defined functions
375 public class Xcls_Label3 : Object
378 private Xcls_LeftProps _this;
384 public Xcls_Label3(Xcls_LeftProps _owner )
387 this.el = new Gtk.Label( "Add:" );
391 // set gobject values
392 this.el.margin_end = 5;
393 this.el.margin_start = 5;
396 // user defined functions
399 public class Xcls_Button4 : Object
401 public Gtk.Button el;
402 private Xcls_LeftProps _this;
406 public bool always_show_image;
409 public Xcls_Button4(Xcls_LeftProps _owner )
412 this.el = new Gtk.Button();
415 this.always_show_image = true;
417 // set gobject values
418 this.el.icon_name = "format-justify-left";
419 this.el.hexpand = true;
420 this.el.tooltip_text = "Add Property";
421 this.el.label = "Property";
424 this.el.clicked.connect( ( ) => {
426 _this.main_window.windowstate.showProps(
428 JsRender.NodePropType.PROP
434 // user defined functions
437 public class Xcls_Button5 : Object
439 public Gtk.Button el;
440 private Xcls_LeftProps _this;
444 public bool always_show_image;
447 public Xcls_Button5(Xcls_LeftProps _owner )
450 this.el = new Gtk.Button();
453 this.always_show_image = true;
455 // set gobject values
456 this.el.icon_name = "appointment-new";
457 this.el.hexpand = true;
458 this.el.tooltip_text = "Add Event Code";
459 this.el.label = "Event";
462 this.el.clicked.connect( ( ) => {
465 _this.main_window.windowstate.showProps(
467 JsRender.NodePropType.LISTENER
474 // user defined functions
477 public class Xcls_Button6 : Object
479 public Gtk.Button el;
480 private Xcls_LeftProps _this;
484 public bool always_show_image;
487 public Xcls_Button6(Xcls_LeftProps _owner )
490 this.el = new Gtk.Button();
493 this.always_show_image = true;
495 // set gobject values
496 this.el.icon_name = "list-add";
497 this.el.hexpand = true;
498 this.el.label = "Other";
499 new Xcls_AddPropertyPopup( _this );
502 this.el.clicked.connect( ( ) => {
503 //_this.before_edit();
506 var p = _this.AddPropertyPopup;
508 // Gtk.Allocation rect;
509 //this.el.get_allocation(out rect);
510 if (p.el.parent == null) {
511 p.el.set_parent(this.el);
513 //p.el.set_pointing_to(rect);
515 p.el.set_position(Gtk.PositionType.BOTTOM);
516 p.el.autohide = true;
522 // user defined functions
524 public class Xcls_AddPropertyPopup : Object
526 public Gtk.Popover el;
527 private Xcls_LeftProps _this;
533 public Xcls_AddPropertyPopup(Xcls_LeftProps _owner )
536 _this.AddPropertyPopup = this;
537 this.el = new Gtk.Popover();
541 // set gobject values
542 this.el.autohide = true;
543 var child_1 = new Xcls_Box8( _this );
544 this.el.child = child_1.el;
547 // user defined functions
549 public class Xcls_Box8 : Object
552 private Xcls_LeftProps _this;
558 public Xcls_Box8(Xcls_LeftProps _owner )
561 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
565 // set gobject values
566 var child_1 = new Xcls_Button9( _this );
568 this.el.append( child_1.el );
569 var child_2 = new Xcls_Button10( _this );
571 this.el.append( child_2.el );
572 var child_3 = new Xcls_Button11( _this );
574 this.el.append( child_3.el );
575 var child_4 = new Xcls_Button12( _this );
577 this.el.append( child_4.el );
578 var child_5 = new Xcls_Button13( _this );
580 this.el.append( child_5.el );
581 var child_6 = new Xcls_Separator14( _this );
583 this.el.append( child_6.el );
584 var child_7 = new Xcls_Button15( _this );
586 this.el.append( child_7.el );
587 var child_8 = new Xcls_Button16( _this );
589 this.el.append( child_8.el );
590 var child_9 = new Xcls_Button17( _this );
592 this.el.append( child_9.el );
593 var child_10 = new Xcls_Separator18( _this );
595 this.el.append( child_10.el );
596 var child_11 = new Xcls_Button19( _this );
598 this.el.append( child_11.el );
599 var child_12 = new Xcls_Button20( _this );
601 this.el.append( child_12.el );
602 var child_13 = new Xcls_Button21( _this );
604 this.el.append( child_13.el );
605 var child_14 = new Xcls_Separator22( _this );
607 this.el.append( child_14.el );
608 var child_15 = new Xcls_Button23( _this );
610 this.el.append( child_15.el );
611 var child_16 = new Xcls_Button24( _this );
613 this.el.append( child_16.el );
614 var child_17 = new Xcls_Button25( _this );
616 this.el.append( child_17.el );
619 // user defined functions
621 public class Xcls_Button9 : Object
623 public Gtk.Button el;
624 private Xcls_LeftProps _this;
630 public Xcls_Button9(Xcls_LeftProps _owner )
633 this.el = new Gtk.Button();
637 // set gobject values
638 this.el.tooltip_markup = "Using _this.{ID} will map to this element";
639 this.el.label = "id: _this.{ID} (Vala)";
642 this.el.clicked.connect( () => {
643 _this.AddPropertyPopup.el.hide();
644 // is this userdef or special??
645 var add = new JsRender.NodeProp.prop("id");
646 if (_this.node.has_prop_key(add)) {
650 _this.node.add_prop( add );
652 _this.view.editProp( add );
658 // user defined functions
661 public class Xcls_Button10 : Object
663 public Gtk.Button el;
664 private Xcls_LeftProps _this;
670 public Xcls_Button10(Xcls_LeftProps _owner )
673 this.el = new Gtk.Button();
677 // set gobject values
678 this.el.tooltip_markup = "how to pack this element onto parent, (method, 2nd arg, 3rd arg) .. the 1st argument is filled by the element";
679 this.el.label = "pack: Pack method (Vala)";
682 this.el.clicked.connect( ( ) => {
685 _this.AddPropertyPopup.el.hide();
686 // is this userdef or special??
687 var add = new JsRender.NodeProp.special("pack", "add");
688 if (_this.node.has_prop_key(add)) {
692 _this.node.add_prop( add );
694 _this.view.editProp( add );
700 // user defined functions
703 public class Xcls_Button11 : Object
705 public Gtk.Button el;
706 private Xcls_LeftProps _this;
712 public Xcls_Button11(Xcls_LeftProps _owner )
715 this.el = new Gtk.Button();
719 // set gobject values
720 this.el.tooltip_markup = "eg. \n\nnew Clutter.Image.from_file(.....)";
721 this.el.label = "ctor: Alterative to default contructor (Vala)";
724 this.el.clicked.connect( ( ) => {
726 _this.AddPropertyPopup.el.hide();
727 // is this userdef or special??
728 var add = new JsRender.NodeProp.special("ctor");
729 if (_this.node.has_prop_key(add)) {
733 _this.node.add_prop( add );
735 _this.view.editProp( add );
740 // user defined functions
743 public class Xcls_Button12 : Object
745 public Gtk.Button el;
746 private Xcls_LeftProps _this;
752 public Xcls_Button12(Xcls_LeftProps _owner )
755 this.el = new Gtk.Button();
759 // set gobject values
760 this.el.tooltip_markup = "This code is called after the ctor";
761 this.el.label = "init: initialziation code (vala)";
764 this.el.clicked.connect( ( ) => {
766 _this.AddPropertyPopup.el.hide();
767 // is this userdef or special??
768 var add = new JsRender.NodeProp.special("init","{\n\n}\n" ) ;
769 if (_this.node.has_prop_key(add)) {
773 _this.node.add_prop( add );
775 _this.view.editProp( add );
779 // user defined functions
782 public class Xcls_Button13 : Object
784 public Gtk.Button el;
785 private Xcls_LeftProps _this;
791 public Xcls_Button13(Xcls_LeftProps _owner )
794 this.el = new Gtk.Button();
798 // set gobject values
799 this.el.tooltip_markup = "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";
800 this.el.label = "cms-id: (Roo JS/Pman library)";
803 this.el.clicked.connect( () => {
805 _this.AddPropertyPopup.el.hide();
806 // is this userdef or special??
807 var add = new JsRender.NodeProp.prop("cms-id","string", "" ) ;
808 if (_this.node.has_prop_key(add)) {
812 _this.node.add_prop( add );
814 _this.view.editProp( add );
819 // user defined functions
822 public class Xcls_Separator14 : Object
824 public Gtk.Separator el;
825 private Xcls_LeftProps _this;
831 public Xcls_Separator14(Xcls_LeftProps _owner )
834 this.el = new Gtk.Separator( Gtk.Orientation.HORIZONTAL );
838 // set gobject values
841 // user defined functions
844 public class Xcls_Button15 : Object
846 public Gtk.Button el;
847 private Xcls_LeftProps _this;
853 public Xcls_Button15(Xcls_LeftProps _owner )
856 this.el = new Gtk.Button();
860 // set gobject values
861 this.el.tooltip_markup = "Add a user defined string property";
862 this.el.label = "String";
865 this.el.clicked.connect( (self) => {
866 _this.AddPropertyPopup.el.hide();
867 _this.view.popover.show(
870 new JsRender.NodeProp.prop("", "string", "") ,
878 // user defined functions
881 public class Xcls_Button16 : Object
883 public Gtk.Button el;
884 private Xcls_LeftProps _this;
890 public Xcls_Button16(Xcls_LeftProps _owner )
893 this.el = new Gtk.Button();
897 // set gobject values
898 this.el.tooltip_markup = "Add a user defined number property";
899 this.el.label = "Number";
902 this.el.clicked.connect( ( ) =>{
903 _this.AddPropertyPopup.el.hide();
905 _this.view.popover.show(
908 new JsRender.NodeProp.prop("", "int", "0") ,
916 // user defined functions
919 public class Xcls_Button17 : Object
921 public Gtk.Button el;
922 private Xcls_LeftProps _this;
928 public Xcls_Button17(Xcls_LeftProps _owner )
931 this.el = new Gtk.Button();
935 // set gobject values
936 this.el.tooltip_markup = "Add a user defined boolean property";
937 this.el.label = "Boolean";
940 this.el.clicked.connect( ( ) =>{
942 _this.AddPropertyPopup.el.hide();
943 _this.view.popover.show(
946 new JsRender.NodeProp.prop("", "bool", "true") ,
954 // user defined functions
957 public class Xcls_Separator18 : Object
959 public Gtk.Separator el;
960 private Xcls_LeftProps _this;
966 public Xcls_Separator18(Xcls_LeftProps _owner )
969 this.el = new Gtk.Separator( Gtk.Orientation.HORIZONTAL );
973 // set gobject values
976 // user defined functions
979 public class Xcls_Button19 : Object
981 public Gtk.Button el;
982 private Xcls_LeftProps _this;
988 public Xcls_Button19(Xcls_LeftProps _owner )
991 this.el = new Gtk.Button();
995 // set gobject values
996 this.el.tooltip_markup = "Add a user function boolean property";
997 this.el.label = "Javascript Function";
1000 this.el.clicked.connect( ( ) =>{
1001 _this.AddPropertyPopup.el.hide();
1002 _this.view.popover.show(
1005 new JsRender.NodeProp.jsmethod("") ,
1014 // user defined functions
1017 public class Xcls_Button20 : Object
1019 public Gtk.Button el;
1020 private Xcls_LeftProps _this;
1026 public Xcls_Button20(Xcls_LeftProps _owner )
1029 this.el = new Gtk.Button();
1033 // set gobject values
1034 this.el.tooltip_markup = "Add a user function boolean property";
1035 this.el.label = "Vala Method";
1038 this.el.clicked.connect( ( ) =>{
1039 _this.AddPropertyPopup.el.hide();
1040 _this.view.popover.show(
1043 new JsRender.NodeProp.valamethod("") ,
1050 // user defined functions
1053 public class Xcls_Button21 : Object
1055 public Gtk.Button el;
1056 private Xcls_LeftProps _this;
1062 public Xcls_Button21(Xcls_LeftProps _owner )
1065 this.el = new Gtk.Button();
1069 // set gobject values
1070 this.el.tooltip_markup = "Add a vala signal";
1071 this.el.label = "Vala Signal";
1074 this.el.clicked.connect( ( ) =>{
1075 _this.AddPropertyPopup.el.hide();
1076 _this.view.popover.show(
1079 new JsRender.NodeProp.sig("" ) ,
1086 // user defined functions
1089 public class Xcls_Separator22 : Object
1091 public Gtk.Separator el;
1092 private Xcls_LeftProps _this;
1098 public Xcls_Separator22(Xcls_LeftProps _owner )
1101 this.el = new Gtk.Separator( Gtk.Orientation.HORIZONTAL );
1105 // set gobject values
1108 // user defined functions
1111 public class Xcls_Button23 : Object
1113 public Gtk.Button el;
1114 private Xcls_LeftProps _this;
1120 public Xcls_Button23(Xcls_LeftProps _owner )
1123 this.el = new Gtk.Button();
1127 // set gobject values
1128 this.el.tooltip_markup = "Add a flexy if (for HTML templates)";
1129 this.el.label = "Flexy - If";
1132 this.el.clicked.connect( ( ) =>{
1133 _this.AddPropertyPopup.el.hide();
1134 _this.view.popover.show(
1137 new JsRender.NodeProp.prop("flexy:if", "string", "value_or_condition") ,
1146 // user defined functions
1149 public class Xcls_Button24 : Object
1151 public Gtk.Button el;
1152 private Xcls_LeftProps _this;
1158 public Xcls_Button24(Xcls_LeftProps _owner )
1161 this.el = new Gtk.Button();
1165 // set gobject values
1166 this.el.tooltip_markup = "Add a flexy include (for HTML templates)";
1167 this.el.label = "Flexy - Include";
1170 this.el.clicked.connect( ( ) =>{
1171 _this.AddPropertyPopup.el.hide();
1172 _this.view.popover.show(
1175 new JsRender.NodeProp.prop("flexy:include", "string", "name_of_file.html") ,
1184 // user defined functions
1187 public class Xcls_Button25 : Object
1189 public Gtk.Button el;
1190 private Xcls_LeftProps _this;
1196 public Xcls_Button25(Xcls_LeftProps _owner )
1199 this.el = new Gtk.Button();
1203 // set gobject values
1204 this.el.tooltip_markup = "Add a flexy include (for HTML templates)";
1205 this.el.label = "Flexy - Foreach";
1208 this.el.clicked.connect( ( ) =>{
1209 _this.AddPropertyPopup.el.hide();
1210 _this.view.popover.show(
1213 new JsRender.NodeProp.prop("flexy:if", "string", "value_or_condition") ,
1221 // user defined functions
1228 public class Xcls_EditProps : Object
1230 public Gtk.ScrolledWindow el;
1231 private Xcls_LeftProps _this;
1235 public bool editing;
1238 public Xcls_EditProps(Xcls_LeftProps _owner )
1241 _this.EditProps = this;
1242 this.el = new Gtk.ScrolledWindow();
1245 this.editing = false;
1247 // set gobject values
1248 this.el.hexpand = true;
1249 this.el.vexpand = true;
1250 new Xcls_view( _this );
1251 this.el.set_child ( _this.view.el );
1257 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
1261 // user defined functions
1263 public class Xcls_view : Object
1265 public Gtk.ColumnView el;
1266 private Xcls_LeftProps _this;
1270 public Gtk.CssProvider css;
1271 public Xcls_PopoverProperty popover;
1274 public Xcls_view(Xcls_LeftProps _owner )
1278 new Xcls_selmodel( _this );
1279 this.el = new Gtk.ColumnView( _this.selmodel.el );
1282 this.popover = null;
1284 // set gobject values
1285 this.el.name = "leftprops-view";
1286 this.el.single_click_activate = false;
1287 this.el.hexpand = true;
1288 this.el.vexpand = true;
1289 this.el.show_row_separators = true;
1290 new Xcls_deletemenu( _this );
1291 var child_3 = new Xcls_GestureClick31( _this );
1293 this.el.add_controller( child_3.el );
1294 var child_4 = new Xcls_GestureClick32( _this );
1296 this.el.add_controller( child_4.el );
1297 new Xcls_keycol( _this );
1298 this.el.append_column ( _this.keycol.el );
1299 new Xcls_valcol( _this );
1300 this.el.append_column ( _this.valcol.el );
1301 new Xcls_ContextMenu( _this );
1307 this.css = new Gtk.CssProvider();
1309 this.css.load_from_string("
1310 #leftprops-view { font-size: 12px;}
1312 #leftprops-view dropdown button {
1316 #leftprops-view cell dropdown label {
1320 #leftprops-view cell {
1324 #leftprops-view cell label, #leftprops-view cell editablelable {
1329 Gtk.StyleContext.add_provider_for_display(
1330 this.el.get_display(),
1332 Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
1339 // user defined functions
1340 public Gtk.Widget? getWidgetAtRow (uint row) {
1343 from https://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465
1344 var colview = gesture.widget;
1345 var line_no = check_list_widget(colview, x,y);
1347 var item = colview.model.get_item(line_no);
1351 GLib.debug("Get Widget At Row %d", (int)row);
1352 var child = this.el.get_first_child();
1354 var reading_header = true;
1356 while (child != null) {
1357 GLib.debug("Got %s", child.get_type().name());
1358 if (reading_header) {
1361 if (child.get_type().name() != "GtkColumnListView") {
1362 child = child.get_next_sibling();
1365 child = child.get_first_child();
1366 reading_header = false;
1369 if (child.get_type().name() != "GtkColumnViewRowWidget") {
1370 child = child.get_next_sibling();
1374 if (line_no == row) {
1375 GLib.debug("Returning widget %s", child.get_type().name());
1376 return (Gtk.Widget)child;
1378 child = child.get_next_sibling();
1380 GLib.debug("Rturning null");
1384 public void editProp (JsRender.NodeProp prop)
1386 var sm = _this.selmodel.el;
1389 GLib.debug("finding node");
1390 _this.selmodel.selectProp(prop);
1392 for (var i = 0 ; i < sm.n_items; i++) {
1393 var r = (JsRender.NodeProp)sm.get_item(i);
1394 if (r.equals(prop)) {
1400 GLib.debug("finding node - cant find it");
1404 var r = this.getWidgetAtRow(sr);
1405 GLib.debug("r = %s", r.get_type().name());
1406 var ca = r.get_first_child();
1407 var ll = (Gtk.Label)ca.get_first_child();
1408 var cb = ca.get_next_sibling();
1409 var b = cb.get_first_child();
1410 var e = (Gtk.EditableLabel) b.get_first_child();
1411 var l = (Gtk.Label) e.get_next_sibling();
1412 var d = (Gtk.DropDown) l.get_next_sibling();
1414 GLib.debug("row key = %s", ll.label);
1415 if (e.get_visible()) {
1416 _this.stop_editor();
1418 //GLib.Timeout.add_once(500, () => {
1419 // var st = (Gtk.Stack) e.get_first_child();
1420 // var ed = (Gtk.Entry) st.get_visible_child();
1421 // ed.grab_focus_without_selecting();
1425 if (d.get_visible()) {
1426 _this.stop_editor();
1430 if (l.get_visible()) {
1431 _this.stop_editor();
1432 _this.show_editor(_this.file, prop.parent, prop);
1438 //gtkcolumnviewrowwidget
1442 // entry / label / dropdown
1446 public int getColAt (double x, double y) {
1449 from https://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465
1452 //Gtk.Allocation alloc = { 0, 0, 0, 0 };
1453 var child = this.el.get_first_child();
1457 while (child != null) {
1458 GLib.debug("Got %s", child.get_type().name());
1460 if (child.get_type().name() == "GtkColumnViewRowWidget") {
1461 child = child.get_first_child();
1465 //child.get_allocation(out alloc);
1466 if (x < (child.get_width() + offx)) {
1469 offx += child.get_width();
1471 child = child.get_next_sibling();
1478 public int getRowAt (double x, double in_y, out string pos) {
1485 from https://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465
1486 var colview = gesture.widget;
1487 var line_no = check_list_widget(colview, x,y);
1489 var item = colview.model.get_item(line_no);
1495 //GLib.debug("offset = %d y = %d", (int) voff, (int) in_y);
1496 var y = in_y + _this.EditProps.el.vadjustment.value;
1497 var child = this.el.get_first_child();
1498 //Gtk.Allocation alloc = { 0, 0, 0, 0 };
1500 var reading_header = true;
1502 var header_height = 0;
1505 while (child != null) {
1506 //GLib.debug("Got %s", child.get_type().name());
1507 if (reading_header) {
1510 if (child.get_type().name() != "GtkColumnListView") {
1511 h += child.get_height();
1512 child = child.get_next_sibling();
1515 // should be columnlistview
1516 child = child.get_first_child();
1517 GLib.debug("header height=%d", h);
1520 reading_header = false;
1524 if (child.get_type().name() != "GtkColumnViewRowWidget") {
1525 child = child.get_next_sibling();
1529 if (y < header_height) {
1534 var hh = child.get_height();
1535 //child.get_allocation(out alloc);
1536 //GLib.debug("got cell xy = %d,%d w,h= %d,%d", alloc.x, alloc.y, alloc.width, alloc.height);
1537 //GLib.debug("row %d y= %d %s", line_no, (int) (header_height + alloc.y),
1539 // child.visible ? "VIS" : "hidden");
1541 if (y > (header_height + real_y) && y <= (header_height + real_y + hh) ) {
1542 if (y > ( header_height + real_y + (hh * 0.8))) {
1544 } else if (y > ( header_height + real_y + (hh * 0.2))) {
1549 GLib.debug("getRowAt return : %d, %s", line_no, pos);
1554 if (real_y + hh > y) {
1558 child = child.get_next_sibling();
1564 public class Xcls_deletemenu : Object
1566 public Gtk.Popover el;
1567 private Xcls_LeftProps _this;
1573 public Xcls_deletemenu(Xcls_LeftProps _owner )
1576 _this.deletemenu = this;
1577 this.el = new Gtk.Popover();
1581 // set gobject values
1582 var child_1 = new Xcls_Box29( _this );
1583 this.el.child = child_1.el;
1586 // user defined functions
1588 public class Xcls_Box29 : Object
1591 private Xcls_LeftProps _this;
1597 public Xcls_Box29(Xcls_LeftProps _owner )
1600 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
1604 // set gobject values
1605 var child_1 = new Xcls_Button30( _this );
1607 this.el.append( child_1.el );
1610 // user defined functions
1612 public class Xcls_Button30 : Object
1614 public Gtk.Button el;
1615 private Xcls_LeftProps _this;
1621 public Xcls_Button30(Xcls_LeftProps _owner )
1624 this.el = new Gtk.Button();
1628 // set gobject values
1629 this.el.label = "Delete";
1632 this.el.clicked.connect( ( ) => {
1635 var n = (JsRender.NodeProp) _this.selmodel.el.selected_item;
1637 _this.deletemenu.el.hide();
1638 _this.node.remove_prop(n);
1642 // user defined functions
1647 public class Xcls_GestureClick31 : Object
1649 public Gtk.GestureClick el;
1650 private Xcls_LeftProps _this;
1656 public Xcls_GestureClick31(Xcls_LeftProps _owner )
1659 this.el = new Gtk.GestureClick();
1663 // set gobject values
1666 this.el.pressed.connect( (n_press, in_x, in_y) => {
1668 GLib.debug("Prssed %d", (int) this.el.get_current_button());
1670 var col = _this.view.getColAt(in_x, in_y);
1675 var row = _this.view.getRowAt(in_x, in_y, out pos);
1681 GLib.debug("hit row %d", row);
1682 var prop = _this.selmodel.getPropAt(row);
1683 _this.selmodel.selectProp(prop);
1685 //var point_at = _this.view.getWidgetAtRow(row);
1687 // need to shift down, as ev.y does not inclucde header apparently..
1688 // or popover might be trying to do a central?
1689 // _this.view.editPropertyDetails(prop, (int) in_y + 12);
1690 _this.stop_editor();
1691 _this.view.popover.show(
1701 // user defined functions
1704 public class Xcls_GestureClick32 : Object
1706 public Gtk.GestureClick el;
1707 private Xcls_LeftProps _this;
1713 public Xcls_GestureClick32(Xcls_LeftProps _owner )
1716 this.el = new Gtk.GestureClick();
1720 // set gobject values
1724 this.el.pressed.connect( (n_press, in_x, in_y) => {
1729 var row = _this.view.getRowAt(in_x, in_y, out pos);
1736 _this.stop_editor();
1737 GLib.debug("hit row %d", row);
1738 var prop = _this.selmodel.getPropAt(row);
1739 _this.selmodel.selectProp(prop);
1743 GLib.debug("Prssed %d", (int) this.el.get_current_button());
1744 //_this.deletemenu.el.set_parent(_this.view.el);
1745 if (_this.deletemenu.el.parent == null) {
1746 _this.deletemenu.el.set_parent(_this.main_window.el);
1751 _this.deletemenu.el.set_offset(
1752 (int)in_x - _this.view.el.get_width() ,
1753 (int)in_y - _this.view.el.get_height()
1755 _this.deletemenu.el.set_position(Gtk.PositionType.BOTTOM);
1756 _this.deletemenu.el.popup();
1761 // user defined functions
1764 public class Xcls_selmodel : Object
1766 public Gtk.SingleSelection el;
1767 private Xcls_LeftProps _this;
1773 public Xcls_selmodel(Xcls_LeftProps _owner )
1776 _this.selmodel = this;
1777 new Xcls_model( _this );
1778 this.el = new Gtk.SingleSelection( _this.model.el );
1782 // set gobject values
1783 this.el.can_unselect = true;
1786 // user defined functions
1787 public void startEditing (JsRender.NodeProp prop) {
1788 // should we call select?? - caller does int (from windowstate)
1791 public void selectProp (JsRender.NodeProp prop) {
1792 for (var i = 0 ; i < this.el.n_items; i++) {
1793 var r = (JsRender.NodeProp)this.el.get_item(i);
1794 if (r.equals(prop)) {
1795 this.el.selected = i;
1801 public JsRender.NodeProp getPropAt (uint row) {
1803 return (JsRender.NodeProp) this.el.get_item(row);
1808 public class Xcls_model : Object
1810 public GLib.ListStore el;
1811 private Xcls_LeftProps _this;
1817 public Xcls_model(Xcls_LeftProps _owner )
1821 this.el = new GLib.ListStore(typeof(JsRender.NodeProp));
1825 // set gobject values
1828 // user defined functions
1832 public class Xcls_keycol : Object
1834 public Gtk.ColumnViewColumn el;
1835 private Xcls_LeftProps _this;
1841 public Xcls_keycol(Xcls_LeftProps _owner )
1844 _this.keycol = this;
1845 var child_1 = new Xcls_SignalListItemFactory36( _this );
1847 this.el = new Gtk.ColumnViewColumn( "Property", child_1.el );
1851 // set gobject values
1852 this.el.id = "keycol";
1853 this.el.expand = true;
1854 this.el.resizable = true;
1857 // user defined functions
1859 public class Xcls_SignalListItemFactory36 : Object
1861 public Gtk.SignalListItemFactory el;
1862 private Xcls_LeftProps _this;
1868 public Xcls_SignalListItemFactory36(Xcls_LeftProps _owner )
1871 this.el = new Gtk.SignalListItemFactory();
1875 // set gobject values
1878 this.el.setup.connect( (listitem) => {
1879 var lbl = new Gtk.Label("");
1880 ((Gtk.ListItem)listitem).set_child(lbl);
1881 lbl.justify = Gtk.Justification.LEFT;
1883 lbl.use_markup = true;
1884 lbl.ellipsize = Pango.EllipsizeMode.START;
1885 /*lbl.changed.connect(() => {
1886 // notify and save the changed value...
1887 //var prop = (JsRender.NodeProp) ((Gtk.ListItem)listitem.get_item());
1889 //prop.val = lbl.text;
1890 //_this.updateIter(iter,prop);
1894 ((Gtk.ListItem)listitem).activatable = true;
1896 this.el.bind.connect( (listitem) => {
1897 var lb = (Gtk.Label) ((Gtk.ListItem)listitem).get_child();
1898 var item = (JsRender.NodeProp) ((Gtk.ListItem)listitem).get_item();
1901 item.bind_property("to_display_name_prop",
1903 GLib.BindingFlags.SYNC_CREATE);
1904 item.bind_property("to_tooltip_name_prop",
1905 lb, "tooltip_markup",
1906 GLib.BindingFlags.SYNC_CREATE);
1907 // was item (1) in old layout
1913 // user defined functions
1917 public class Xcls_valcol : Object
1919 public Gtk.ColumnViewColumn el;
1920 private Xcls_LeftProps _this;
1926 public Xcls_valcol(Xcls_LeftProps _owner )
1929 _this.valcol = this;
1930 var child_1 = new Xcls_SignalListItemFactory38( _this );
1932 this.el = new Gtk.ColumnViewColumn( "Value", child_1.el );
1936 // set gobject values
1937 this.el.id = "valcol";
1938 this.el.expand = true;
1939 this.el.resizable = true;
1942 // user defined functions
1944 public class Xcls_SignalListItemFactory38 : Object
1946 public Gtk.SignalListItemFactory el;
1947 private Xcls_LeftProps _this;
1951 public bool is_setting;
1954 public Xcls_SignalListItemFactory38(Xcls_LeftProps _owner )
1957 this.el = new Gtk.SignalListItemFactory();
1960 this.is_setting = false;
1962 // set gobject values
1965 this.el.setup.connect( (listitem) => {
1966 var hb = new Gtk.Box(Gtk.Orientation.HORIZONTAL,0);
1967 var elbl = new Gtk.EditableLabel("");
1968 elbl.hexpand = true;
1970 var lbl = new Gtk.Label("");
1973 lbl.use_markup = true;
1975 lbl.ellipsize = Pango.EllipsizeMode.END;
1976 var cb = new Gtk.DropDown(new Gtk.StringList({}), null);
1980 ((Gtk.ListItem)listitem).set_child(hb);
1982 var ef = new Gtk.EventControllerFocus();
1983 ef.enter.connect(() => {
1984 _this.stop_editor();
1985 var prop = (JsRender.NodeProp)((Gtk.ListItem)listitem).get_item();
1986 _this.selmodel.selectProp(prop);
1988 elbl.add_controller(ef);
1991 // dropdown??? - stop editing, and highliht node
1992 var tb = (Gtk.ToggleButton) cb.get_first_child();
1993 tb.clicked.connect(() => {
1994 var prop = (JsRender.NodeProp)((Gtk.ListItem)listitem).get_item();
1996 _this.stop_editor();
1997 _this.selmodel.selectProp(prop);
2000 elbl.changed.connect(() => {
2001 // notify and save the changed value...
2003 //_this.updateIter(iter,prop);
2004 // this should happen automatically
2006 if (!_this.loading && !this.is_setting) {
2007 var prop = (JsRender.NodeProp)((Gtk.ListItem)listitem).get_item();
2010 prop.val = elbl.text;
2011 GLib.debug("calling changed");
2019 cb.notify["selected"].connect(() => {
2020 // dropdown selection changed.
2024 //_this.updateIter(iter,prop);
2025 if (!_this.loading && !this.is_setting) {
2026 var prop = (JsRender.NodeProp)((Gtk.ListItem)listitem).get_item();
2027 var model = (Gtk.StringList)cb.model;
2028 prop.val = model.get_string(cb.selected);
2029 GLib.debug("property set to %s", prop.val);
2030 GLib.debug("calling changed");
2037 var gc = new Gtk.GestureClick();
2038 lbl.add_controller(gc);
2039 gc.pressed.connect(() => {
2040 var prop = (JsRender.NodeProp)((Gtk.ListItem)listitem).get_item();
2041 _this.stop_editor();
2042 _this.show_editor(_this.file, prop.parent, prop);
2048 this.el.bind.connect( (listitem) => {
2049 this.is_setting = true;
2052 var bx = (Gtk.Box) ((Gtk.ListItem)listitem).get_child();
2057 var elbl = (Gtk.EditableLabel)bx.get_first_child();
2058 var lbl = (Gtk.Label) elbl.get_next_sibling();
2059 var cb = (Gtk.DropDown) lbl.get_next_sibling();
2060 // decide if it's a combo or editable text..
2061 var model = (Gtk.StringList) cb.model;
2067 var prop = (JsRender.NodeProp) ((Gtk.ListItem)listitem).get_item();
2068 //GLib.debug("prop = %s", prop.get_type().name());
2069 //GLib.debug("prop.val = %s", prop.val);
2070 //GLib.debug("prop.key = %s", prop.to_display_name());
2072 var use_textarea = prop.useTextArea();
2075 var pal = _this.file.project.palete;
2078 var has_opts = pal.typeOptions(_this.node.fqn(), prop.name, prop.rtype, out opts);
2080 if (!has_opts && prop.ptype == JsRender.NodePropType.RAW) {
2081 use_textarea = true;
2086 prop.bind_property("val_short",
2088 GLib.BindingFlags.SYNC_CREATE);
2089 prop.bind_property("val_tooltip",
2090 lbl, "tooltip_markup",
2091 GLib.BindingFlags.SYNC_CREATE);
2093 this.is_setting = false;
2102 // others... - fill in options for true/false?
2103 // GLib.debug (ktype.up());
2106 while(model.get_n_items() > 0) {
2110 // can not remove - hopefully always empty.
2112 for(var i = 0; i < opts.length; i ++) {
2113 model.append( opts[i]);
2114 // not sure this is a great idea...
2115 if (opts[i].down() == prop.val.down()) {
2119 GLib.debug("Set selected item to %d", sel);
2120 cb.set_selected(sel > -1 ? sel : Gtk.INVALID_LIST_POSITION);
2121 this.is_setting = false;
2125 // see if type is a Enum.
2126 // triggers a changed event
2128 elbl.set_text(prop.val);
2131 this.is_setting = false;
2140 // user defined functions
2144 public class Xcls_ContextMenu : Object
2146 public Gtk.Popover el;
2147 private Xcls_LeftProps _this;
2153 public Xcls_ContextMenu(Xcls_LeftProps _owner )
2156 _this.ContextMenu = this;
2157 this.el = new Gtk.Popover();
2161 // set gobject values
2162 var child_1 = new Xcls_Box40( _this );
2163 this.el.child = child_1.el;
2166 // user defined functions
2168 public class Xcls_Box40 : Object
2171 private Xcls_LeftProps _this;
2177 public Xcls_Box40(Xcls_LeftProps _owner )
2180 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
2184 // set gobject values
2185 var child_1 = new Xcls_Button41( _this );
2187 this.el.append( child_1.el );
2190 // user defined functions
2192 public class Xcls_Button41 : Object
2194 public Gtk.Button el;
2195 private Xcls_LeftProps _this;
2201 public Xcls_Button41(Xcls_LeftProps _owner )
2204 this.el = new Gtk.Button();
2208 // set gobject values
2209 this.el.label = "Delete";
2212 this.el.activate.connect( ( ) =>{
2213 _this.deleteSelected();
2218 // user defined functions