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];
87 public string keyFormat (string val, string type) {
89 // Glib.markup_escape_text(val);
91 if (type == "listener") {
92 return "<span font_weight=\"bold\" color=\"#660000\">" +
93 GLib.Markup.escape_text(val) +
98 return "<span color=\"#FF0000\">--empty--</span>";
103 //# - object properties
105 // all of these... - display value is last element..
106 var ar = val.strip().split(" ");
109 var dval = GLib.Markup.escape_text(ar[ar.length-1]);
115 case '@': // signal // just bold balck?
116 if (dval[0] == '@') {
117 dval = dval.substring(1);
120 return @"<span font_weight=\"bold\">@ $dval</span>";
121 case '#': // object properties?
122 if (dval[0] == '#') {
123 dval = dval.substring(1);
125 return @"<span font_weight=\"bold\">$dval</span>";
127 if (dval[0] == '*') {
128 dval = dval.substring(1);
130 return @"<span color=\"#0000CC\" font_weight=\"bold\">$dval</span>";
132 if (dval[0] == '$') {
133 dval = dval.substring(1);
135 return @"<span style=\"italic\">$dval</span>";
136 case '|': // user defined methods
137 if (dval[0] == '|') {
138 dval = dval.substring(1);
140 return @"<span color=\"#008000\" font_weight=\"bold\">$dval</span>";
151 public void deleteSelected () {
159 var s = this.view.el.get_selection();
160 s.get_selected(out mod, out iter);
164 mod.get_value(iter, 0 , out gval);
165 var prop = (JsRender.NodeProp)gval;
167 this.load(this.file, this.node);
170 // stop editor after fetching property - otherwise prop is null.
175 case JsRender.NodePropType.LISTENER:
176 this.node.listeners.unset(prop.to_index_key());
180 this.node.props.unset(prop.to_index_key());
183 this.load(this.file, this.node);
188 public void a_addProp (JsRender.NodeProp prop) {
189 // info includes key, val, skel, etype..
190 //console.dump(info);
191 //type = info.type.toLowerCase();
192 //var data = this.toJS();
195 if (prop.ptype == JsRender.NodePropType.LISTENER) {
196 if (this.node.listeners.has_key(prop.name)) {
199 this.node.listeners.set(prop.name,prop);
201 assert(this.node != null);
202 assert(this.node.props != null);
203 if (this.node.props.has_key(prop.to_index_key())) {
206 this.node.props.set(prop.to_index_key(),prop);
211 this.load(this.file, this.node);
216 GLib.debug("trying to find new iter");
221 public void load (JsRender.JsRender file, JsRender.Node? node)
223 // not sure when to initialize this - we should do it on setting main window really.
226 if (this.view.popover == null) {
227 this.view.popover = new Xcls_PopoverProperty();
228 this.view.popover.mainwindow = _this.main_window;
232 if (this.node != null) {
233 this.node.dupeProps(); // ensures removeall will not do somethign silly
237 GLib.debug("load leftprops\n");
243 this.model.el.remove_all();
245 //this.get('/RightEditor').el.hide();
249 node.loadProps(this.model.el);
252 //GLib.debug("clear selection\n");
254 this.loading = false;
255 this.selmodel.el.set_selected(Gtk.INVALID_LIST_POSITION);
257 //this.model.el.set_sort_column_id(4,Gtk.SortType.ASCENDING); // sort by real key..
259 // this.view.el.get_selection().unselect_all();
261 // _this.keycol.el.set_max_width(_this.EditProps.el.get_allocated_width()/ 2);
262 // _this.valcol.el.set_max_width(_this.EditProps.el.get_allocated_width()/ 2);
265 public class Xcls_Box2 : Object
268 private Xcls_LeftProps _this;
274 public Xcls_Box2(Xcls_LeftProps _owner )
277 this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
281 // set gobject values
282 this.el.hexpand = true;
283 var child_1 = new Xcls_Label3( _this );
285 this.el.append( child_1.el );
286 var child_2 = new Xcls_Button4( _this );
288 this.el.append( child_2.el );
289 var child_3 = new Xcls_Button5( _this );
291 this.el.append( child_3.el );
292 var child_4 = new Xcls_Button6( _this );
294 this.el.append( child_4.el );
297 // user defined functions
299 public class Xcls_Label3 : Object
302 private Xcls_LeftProps _this;
308 public Xcls_Label3(Xcls_LeftProps _owner )
311 this.el = new Gtk.Label( "Add:" );
315 // set gobject values
316 this.el.margin_end = 5;
317 this.el.margin_start = 5;
320 // user defined functions
323 public class Xcls_Button4 : Object
325 public Gtk.Button el;
326 private Xcls_LeftProps _this;
330 public bool always_show_image;
333 public Xcls_Button4(Xcls_LeftProps _owner )
336 this.el = new Gtk.Button();
339 this.always_show_image = true;
341 // set gobject values
342 this.el.icon_name = "format-justify-left";
343 this.el.hexpand = true;
344 this.el.tooltip_text = "Add Property";
345 this.el.label = "Property";
348 this.el.clicked.connect( ( ) => {
350 _this.main_window.windowstate.showProps(
352 JsRender.NodePropType.PROP
358 // user defined functions
361 public class Xcls_Button5 : Object
363 public Gtk.Button el;
364 private Xcls_LeftProps _this;
368 public bool always_show_image;
371 public Xcls_Button5(Xcls_LeftProps _owner )
374 this.el = new Gtk.Button();
377 this.always_show_image = true;
379 // set gobject values
380 this.el.icon_name = "appointment-new";
381 this.el.hexpand = true;
382 this.el.tooltip_text = "Add Event Code";
383 this.el.label = "Event";
386 this.el.clicked.connect( ( ) => {
389 _this.main_window.windowstate.showProps(
391 JsRender.NodePropType.LISTENER
398 // user defined functions
401 public class Xcls_Button6 : Object
403 public Gtk.Button el;
404 private Xcls_LeftProps _this;
408 public bool always_show_image;
411 public Xcls_Button6(Xcls_LeftProps _owner )
414 this.el = new Gtk.Button();
417 this.always_show_image = true;
419 // set gobject values
420 this.el.icon_name = "list-add";
421 this.el.hexpand = true;
422 this.el.label = "Other";
423 new Xcls_AddPropertyPopup( _this );
426 this.el.clicked.connect( ( ) => {
427 //_this.before_edit();
430 var p = _this.AddPropertyPopup;
432 // Gtk.Allocation rect;
433 //this.el.get_allocation(out rect);
434 if (p.el.parent == null) {
435 p.el.set_parent(this.el);
437 //p.el.set_pointing_to(rect);
439 p.el.set_position(Gtk.PositionType.BOTTOM);
440 p.el.autohide = true;
446 // user defined functions
448 public class Xcls_AddPropertyPopup : Object
450 public Gtk.Popover el;
451 private Xcls_LeftProps _this;
457 public Xcls_AddPropertyPopup(Xcls_LeftProps _owner )
460 _this.AddPropertyPopup = this;
461 this.el = new Gtk.Popover();
465 // set gobject values
466 this.el.autohide = true;
467 var child_1 = new Xcls_Box8( _this );
468 this.el.child = child_1.el;
471 // user defined functions
473 public class Xcls_Box8 : Object
476 private Xcls_LeftProps _this;
482 public Xcls_Box8(Xcls_LeftProps _owner )
485 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
489 // set gobject values
490 var child_1 = new Xcls_Button9( _this );
492 this.el.append( child_1.el );
493 var child_2 = new Xcls_Button10( _this );
495 this.el.append( child_2.el );
496 var child_3 = new Xcls_Button11( _this );
498 this.el.append( child_3.el );
499 var child_4 = new Xcls_Button12( _this );
501 this.el.append( child_4.el );
502 var child_5 = new Xcls_Button13( _this );
504 this.el.append( child_5.el );
505 var child_6 = new Xcls_Separator14( _this );
507 this.el.append( child_6.el );
508 var child_7 = new Xcls_Button15( _this );
510 this.el.append( child_7.el );
511 var child_8 = new Xcls_Button16( _this );
513 this.el.append( child_8.el );
514 var child_9 = new Xcls_Button17( _this );
516 this.el.append( child_9.el );
517 var child_10 = new Xcls_Separator18( _this );
519 this.el.append( child_10.el );
520 var child_11 = new Xcls_Button19( _this );
522 this.el.append( child_11.el );
523 var child_12 = new Xcls_Button20( _this );
525 this.el.append( child_12.el );
526 var child_13 = new Xcls_Button21( _this );
528 this.el.append( child_13.el );
529 var child_14 = new Xcls_Separator22( _this );
531 this.el.append( child_14.el );
532 var child_15 = new Xcls_Button23( _this );
534 this.el.append( child_15.el );
535 var child_16 = new Xcls_Button24( _this );
537 this.el.append( child_16.el );
538 var child_17 = new Xcls_Button25( _this );
540 this.el.append( child_17.el );
543 // user defined functions
545 public class Xcls_Button9 : Object
547 public Gtk.Button el;
548 private Xcls_LeftProps _this;
554 public Xcls_Button9(Xcls_LeftProps _owner )
557 this.el = new Gtk.Button();
561 // set gobject values
562 this.el.tooltip_markup = "Using _this.{ID} will map to this element";
563 this.el.label = "id: _this.{ID} (Vala)";
566 this.el.clicked.connect( () => {
567 _this.AddPropertyPopup.el.hide();
568 // is this userdef or special??
569 var add = new JsRender.NodeProp.prop("id");
570 if (_this.node.has_prop_key(add)) {
574 _this.node.add_prop( add );
576 _this.view.editProp( add );
582 // user defined functions
585 public class Xcls_Button10 : Object
587 public Gtk.Button el;
588 private Xcls_LeftProps _this;
594 public Xcls_Button10(Xcls_LeftProps _owner )
597 this.el = new Gtk.Button();
601 // set gobject values
602 this.el.tooltip_markup = "how to pack this element onto parent, (method, 2nd arg, 3rd arg) .. the 1st argument is filled by the element";
603 this.el.label = "pack: Pack method (Vala)";
606 this.el.clicked.connect( ( ) => {
609 _this.AddPropertyPopup.el.hide();
610 // is this userdef or special??
611 var add = new JsRender.NodeProp.special("pack", "add");
612 if (_this.node.has_prop_key(add)) {
616 _this.node.add_prop( add );
618 _this.view.editProp( add );
624 // user defined functions
627 public class Xcls_Button11 : Object
629 public Gtk.Button el;
630 private Xcls_LeftProps _this;
636 public Xcls_Button11(Xcls_LeftProps _owner )
639 this.el = new Gtk.Button();
643 // set gobject values
644 this.el.tooltip_markup = "eg. \n\nnew Clutter.Image.from_file(.....)";
645 this.el.label = "ctor: Alterative to default contructor (Vala)";
648 this.el.clicked.connect( ( ) => {
650 _this.AddPropertyPopup.el.hide();
651 // is this userdef or special??
652 var add = new JsRender.NodeProp.special("ctor");
653 if (_this.node.has_prop_key(add)) {
657 _this.node.add_prop( add );
659 _this.view.editProp( add );
664 // user defined functions
667 public class Xcls_Button12 : Object
669 public Gtk.Button el;
670 private Xcls_LeftProps _this;
676 public Xcls_Button12(Xcls_LeftProps _owner )
679 this.el = new Gtk.Button();
683 // set gobject values
684 this.el.tooltip_markup = "This code is called after the ctor";
685 this.el.label = "init: initialziation code (vala)";
688 this.el.clicked.connect( ( ) => {
690 _this.AddPropertyPopup.el.hide();
691 // is this userdef or special??
692 var add = new JsRender.NodeProp.special("init","{\n\n}\n" ) ;
693 if (_this.node.has_prop_key(add)) {
697 _this.node.add_prop( add );
699 _this.view.editProp( add );
703 // user defined functions
706 public class Xcls_Button13 : Object
708 public Gtk.Button el;
709 private Xcls_LeftProps _this;
715 public Xcls_Button13(Xcls_LeftProps _owner )
718 this.el = new Gtk.Button();
722 // set gobject values
723 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";
724 this.el.label = "cms-id: (Roo JS/Pman library)";
727 this.el.clicked.connect( () => {
729 _this.AddPropertyPopup.el.hide();
730 // is this userdef or special??
731 var add = new JsRender.NodeProp.prop("cms-id","string", "" ) ;
732 if (_this.node.has_prop_key(add)) {
736 _this.node.add_prop( add );
738 _this.view.editProp( add );
743 // user defined functions
746 public class Xcls_Separator14 : Object
748 public Gtk.Separator el;
749 private Xcls_LeftProps _this;
755 public Xcls_Separator14(Xcls_LeftProps _owner )
758 this.el = new Gtk.Separator( Gtk.Orientation.HORIZONTAL );
762 // set gobject values
765 // user defined functions
768 public class Xcls_Button15 : Object
770 public Gtk.Button el;
771 private Xcls_LeftProps _this;
777 public Xcls_Button15(Xcls_LeftProps _owner )
780 this.el = new Gtk.Button();
784 // set gobject values
785 this.el.tooltip_markup = "Add a user defined string property";
786 this.el.label = "String";
789 this.el.clicked.connect( (self) => {
790 _this.AddPropertyPopup.el.hide();
791 _this.view.popover.show(
794 new JsRender.NodeProp.prop("", "string", "") ,
802 // user defined functions
805 public class Xcls_Button16 : Object
807 public Gtk.Button el;
808 private Xcls_LeftProps _this;
814 public Xcls_Button16(Xcls_LeftProps _owner )
817 this.el = new Gtk.Button();
821 // set gobject values
822 this.el.tooltip_markup = "Add a user defined number property";
823 this.el.label = "Number";
826 this.el.clicked.connect( ( ) =>{
827 _this.AddPropertyPopup.el.hide();
829 _this.view.popover.show(
832 new JsRender.NodeProp.prop("", "int", "0") ,
840 // user defined functions
843 public class Xcls_Button17 : Object
845 public Gtk.Button el;
846 private Xcls_LeftProps _this;
852 public Xcls_Button17(Xcls_LeftProps _owner )
855 this.el = new Gtk.Button();
859 // set gobject values
860 this.el.tooltip_markup = "Add a user defined boolean property";
861 this.el.label = "Boolean";
864 this.el.clicked.connect( ( ) =>{
866 _this.AddPropertyPopup.el.hide();
867 _this.view.popover.show(
870 new JsRender.NodeProp.prop("", "bool", "true") ,
878 // user defined functions
881 public class Xcls_Separator18 : Object
883 public Gtk.Separator el;
884 private Xcls_LeftProps _this;
890 public Xcls_Separator18(Xcls_LeftProps _owner )
893 this.el = new Gtk.Separator( Gtk.Orientation.HORIZONTAL );
897 // set gobject values
900 // user defined functions
903 public class Xcls_Button19 : Object
905 public Gtk.Button el;
906 private Xcls_LeftProps _this;
912 public Xcls_Button19(Xcls_LeftProps _owner )
915 this.el = new Gtk.Button();
919 // set gobject values
920 this.el.tooltip_markup = "Add a user function boolean property";
921 this.el.label = "Javascript Function";
924 this.el.clicked.connect( ( ) =>{
925 _this.AddPropertyPopup.el.hide();
926 _this.view.popover.show(
929 new JsRender.NodeProp.jsmethod("") ,
938 // user defined functions
941 public class Xcls_Button20 : Object
943 public Gtk.Button el;
944 private Xcls_LeftProps _this;
950 public Xcls_Button20(Xcls_LeftProps _owner )
953 this.el = new Gtk.Button();
957 // set gobject values
958 this.el.tooltip_markup = "Add a user function boolean property";
959 this.el.label = "Vala Method";
962 this.el.clicked.connect( ( ) =>{
963 _this.AddPropertyPopup.el.hide();
964 _this.view.popover.show(
967 new JsRender.NodeProp.valamethod("") ,
974 // user defined functions
977 public class Xcls_Button21 : Object
979 public Gtk.Button el;
980 private Xcls_LeftProps _this;
986 public Xcls_Button21(Xcls_LeftProps _owner )
989 this.el = new Gtk.Button();
993 // set gobject values
994 this.el.tooltip_markup = "Add a vala signal";
995 this.el.label = "Vala Signal";
998 this.el.clicked.connect( ( ) =>{
999 _this.AddPropertyPopup.el.hide();
1000 _this.view.popover.show(
1003 new JsRender.NodeProp.sig("" ) ,
1010 // user defined functions
1013 public class Xcls_Separator22 : Object
1015 public Gtk.Separator el;
1016 private Xcls_LeftProps _this;
1022 public Xcls_Separator22(Xcls_LeftProps _owner )
1025 this.el = new Gtk.Separator( Gtk.Orientation.HORIZONTAL );
1029 // set gobject values
1032 // user defined functions
1035 public class Xcls_Button23 : Object
1037 public Gtk.Button el;
1038 private Xcls_LeftProps _this;
1044 public Xcls_Button23(Xcls_LeftProps _owner )
1047 this.el = new Gtk.Button();
1051 // set gobject values
1052 this.el.tooltip_markup = "Add a flexy if (for HTML templates)";
1053 this.el.label = "Flexy - If";
1056 this.el.clicked.connect( ( ) =>{
1057 _this.AddPropertyPopup.el.hide();
1058 _this.view.popover.show(
1061 new JsRender.NodeProp.prop("flexy:if", "string", "value_or_condition") ,
1070 // user defined functions
1073 public class Xcls_Button24 : Object
1075 public Gtk.Button el;
1076 private Xcls_LeftProps _this;
1082 public Xcls_Button24(Xcls_LeftProps _owner )
1085 this.el = new Gtk.Button();
1089 // set gobject values
1090 this.el.tooltip_markup = "Add a flexy include (for HTML templates)";
1091 this.el.label = "Flexy - Include";
1094 this.el.clicked.connect( ( ) =>{
1095 _this.AddPropertyPopup.el.hide();
1096 _this.view.popover.show(
1099 new JsRender.NodeProp.prop("flexy:include", "string", "name_of_file.html") ,
1108 // user defined functions
1111 public class Xcls_Button25 : Object
1113 public Gtk.Button el;
1114 private Xcls_LeftProps _this;
1120 public Xcls_Button25(Xcls_LeftProps _owner )
1123 this.el = new Gtk.Button();
1127 // set gobject values
1128 this.el.tooltip_markup = "Add a flexy include (for HTML templates)";
1129 this.el.label = "Flexy - Foreach";
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") ,
1145 // user defined functions
1152 public class Xcls_EditProps : Object
1154 public Gtk.ScrolledWindow el;
1155 private Xcls_LeftProps _this;
1159 public bool editing;
1162 public Xcls_EditProps(Xcls_LeftProps _owner )
1165 _this.EditProps = this;
1166 this.el = new Gtk.ScrolledWindow();
1169 this.editing = false;
1171 // set gobject values
1172 this.el.hexpand = true;
1173 this.el.vexpand = true;
1174 new Xcls_view( _this );
1175 this.el.set_child ( _this.view.el );
1181 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
1185 // user defined functions
1187 public class Xcls_view : Object
1189 public Gtk.ColumnView el;
1190 private Xcls_LeftProps _this;
1194 public Gtk.CssProvider css;
1195 public Xcls_PopoverProperty popover;
1198 public Xcls_view(Xcls_LeftProps _owner )
1202 new Xcls_selmodel( _this );
1203 this.el = new Gtk.ColumnView( _this.selmodel.el );
1206 this.popover = null;
1208 // set gobject values
1209 this.el.name = "leftprops-view";
1210 this.el.single_click_activate = false;
1211 this.el.hexpand = true;
1212 this.el.vexpand = true;
1213 this.el.show_row_separators = true;
1214 new Xcls_deletemenu( _this );
1215 var child_3 = new Xcls_GestureClick31( _this );
1217 this.el.add_controller( child_3.el );
1218 var child_4 = new Xcls_GestureClick32( _this );
1220 this.el.add_controller( child_4.el );
1221 new Xcls_keycol( _this );
1222 this.el.append_column ( _this.keycol.el );
1223 new Xcls_valcol( _this );
1224 this.el.append_column ( _this.valcol.el );
1225 new Xcls_ContextMenu( _this );
1231 this.css = new Gtk.CssProvider();
1233 this.css.load_from_string("
1234 #leftprops-view { font-size: 12px;}
1236 #leftprops-view dropdown button {
1240 #leftprops-view cell dropdown label {
1244 #leftprops-view cell {
1248 #leftprops-view cell label, #leftprops-view cell editablelable {
1253 Gtk.StyleContext.add_provider_for_display(
1254 this.el.get_display(),
1256 Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
1263 // user defined functions
1264 public Gtk.Widget? getWidgetAtRow (uint row) {
1267 from https://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465
1268 var colview = gesture.widget;
1269 var line_no = check_list_widget(colview, x,y);
1271 var item = colview.model.get_item(line_no);
1275 GLib.debug("Get Widget At Row %d", (int)row);
1276 var child = this.el.get_first_child();
1278 var reading_header = true;
1280 while (child != null) {
1281 GLib.debug("Got %s", child.get_type().name());
1282 if (reading_header) {
1285 if (child.get_type().name() != "GtkColumnListView") {
1286 child = child.get_next_sibling();
1289 child = child.get_first_child();
1290 reading_header = false;
1292 if (child.get_type().name() != "GtkColumnViewRowWidget") {
1293 child = child.get_next_sibling();
1297 if (line_no == row) {
1298 GLib.debug("Returning widget %s", child.get_type().name());
1299 return (Gtk.Widget)child;
1301 child = child.get_next_sibling();
1303 GLib.debug("Rturning null");
1307 public void editProp (JsRender.NodeProp prop)
1309 var sm = _this.selmodel.el;
1312 GLib.debug("finding node");
1313 _this.selmodel.selectProp(prop);
1315 for (var i = 0 ; i < sm.n_items; i++) {
1316 var r = (JsRender.NodeProp)sm.get_item(i);
1317 if (r.equals(prop)) {
1323 GLib.debug("finding node - cant find it");
1327 var r = this.getWidgetAtRow(sr);
1328 GLib.debug("r = %s", r.get_type().name());
1329 var ca = r.get_first_child();
1330 var ll = (Gtk.Label)ca.get_first_child();
1331 var cb = ca.get_next_sibling();
1332 var b = cb.get_first_child();
1333 var e = (Gtk.EditableLabel) b.get_first_child();
1334 var l = (Gtk.Label) e.get_next_sibling();
1335 var d = (Gtk.DropDown) l.get_next_sibling();
1337 GLib.debug("row key = %s", ll.label);
1338 if (e.get_visible()) {
1339 _this.stop_editor();
1341 //GLib.Timeout.add_once(500, () => {
1342 // var st = (Gtk.Stack) e.get_first_child();
1343 // var ed = (Gtk.Entry) st.get_visible_child();
1344 // ed.grab_focus_without_selecting();
1348 if (d.get_visible()) {
1349 _this.stop_editor();
1353 if (l.get_visible()) {
1354 _this.stop_editor();
1355 _this.show_editor(_this.file, prop.parent, prop);
1361 //gtkcolumnviewrowwidget
1365 // entry / label / dropdown
1369 public int getColAt (double x, double y) {
1372 from https://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465
1375 //Gtk.Allocation alloc = { 0, 0, 0, 0 };
1376 var child = this.el.get_first_child();
1380 while (child != null) {
1381 GLib.debug("Got %s", child.get_type().name());
1383 if (child.get_type().name() == "GtkColumnViewRowWidget") {
1384 child = child.get_first_child();
1388 //child.get_allocation(out alloc);
1389 if (x < (child.get_width() + offx)) {
1392 offx += child.get_width();
1394 child = child.get_next_sibling();
1401 public int getRowAt (double x, double in_y, out string pos) {
1408 from https://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465
1409 var colview = gesture.widget;
1410 var line_no = check_list_widget(colview, x,y);
1412 var item = colview.model.get_item(line_no);
1418 //GLib.debug("offset = %d y = %d", (int) voff, (int) in_y);
1419 var y = in_y + _this.EditProps.el.vadjustment.value;
1420 var child = this.el.get_first_child();
1421 //Gtk.Allocation alloc = { 0, 0, 0, 0 };
1423 var reading_header = true;
1425 var header_height = 0;
1428 while (child != null) {
1429 //GLib.debug("Got %s", child.get_type().name());
1430 if (reading_header) {
1433 if (child.get_type().name() != "GtkColumnListView") {
1434 h += child.get_height();
1435 child = child.get_next_sibling();
1438 // should be columnlistview
1439 child = child.get_first_child();
1440 GLib.debug("header height=%d", h);
1443 reading_header = false;
1447 if (child.get_type().name() != "GtkColumnViewRowWidget") {
1448 child = child.get_next_sibling();
1452 if (y < header_height) {
1457 var hh = child.get_height();
1458 //child.get_allocation(out alloc);
1459 //GLib.debug("got cell xy = %d,%d w,h= %d,%d", alloc.x, alloc.y, alloc.width, alloc.height);
1460 //GLib.debug("row %d y= %d %s", line_no, (int) (header_height + alloc.y),
1462 // child.visible ? "VIS" : "hidden");
1464 if (y > (header_height + real_y) && y <= (header_height + real_y + hh) ) {
1465 if (y > ( header_height + real_y + (hh * 0.8))) {
1467 } else if (y > ( header_height + real_y + (hh * 0.2))) {
1472 GLib.debug("getRowAt return : %d, %s", line_no, pos);
1477 if (real_y + hh > y) {
1481 child = child.get_next_sibling();
1487 public class Xcls_deletemenu : Object
1489 public Gtk.Popover el;
1490 private Xcls_LeftProps _this;
1496 public Xcls_deletemenu(Xcls_LeftProps _owner )
1499 _this.deletemenu = this;
1500 this.el = new Gtk.Popover();
1504 // set gobject values
1505 var child_1 = new Xcls_Box29( _this );
1506 this.el.child = child_1.el;
1509 // user defined functions
1511 public class Xcls_Box29 : Object
1514 private Xcls_LeftProps _this;
1520 public Xcls_Box29(Xcls_LeftProps _owner )
1523 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
1527 // set gobject values
1528 var child_1 = new Xcls_Button30( _this );
1530 this.el.append( child_1.el );
1533 // user defined functions
1535 public class Xcls_Button30 : Object
1537 public Gtk.Button el;
1538 private Xcls_LeftProps _this;
1544 public Xcls_Button30(Xcls_LeftProps _owner )
1547 this.el = new Gtk.Button();
1551 // set gobject values
1552 this.el.label = "Delete";
1555 this.el.clicked.connect( ( ) => {
1558 var n = (JsRender.NodeProp) _this.selmodel.el.selected_item;
1560 _this.deletemenu.el.hide();
1561 _this.node.remove_prop(n);
1565 // user defined functions
1570 public class Xcls_GestureClick31 : Object
1572 public Gtk.GestureClick el;
1573 private Xcls_LeftProps _this;
1579 public Xcls_GestureClick31(Xcls_LeftProps _owner )
1582 this.el = new Gtk.GestureClick();
1586 // set gobject values
1589 this.el.pressed.connect( (n_press, in_x, in_y) => {
1591 GLib.debug("Prssed %d", (int) this.el.get_current_button());
1593 var col = _this.view.getColAt(in_x, in_y);
1598 var row = _this.view.getRowAt(in_x, in_y, out pos);
1604 GLib.debug("hit row %d", row);
1605 var prop = _this.selmodel.getPropAt(row);
1606 _this.selmodel.selectProp(prop);
1608 //var point_at = _this.view.getWidgetAtRow(row);
1610 // need to shift down, as ev.y does not inclucde header apparently..
1611 // or popover might be trying to do a central?
1612 // _this.view.editPropertyDetails(prop, (int) in_y + 12);
1613 _this.stop_editor();
1614 _this.view.popover.show(
1624 // user defined functions
1627 public class Xcls_GestureClick32 : Object
1629 public Gtk.GestureClick el;
1630 private Xcls_LeftProps _this;
1636 public Xcls_GestureClick32(Xcls_LeftProps _owner )
1639 this.el = new Gtk.GestureClick();
1643 // set gobject values
1647 this.el.pressed.connect( (n_press, in_x, in_y) => {
1652 var row = _this.view.getRowAt(in_x, in_y, out pos);
1659 _this.stop_editor();
1660 GLib.debug("hit row %d", row);
1661 var prop = _this.selmodel.getPropAt(row);
1662 _this.selmodel.selectProp(prop);
1666 GLib.debug("Prssed %d", (int) this.el.get_current_button());
1667 //_this.deletemenu.el.set_parent(_this.view.el);
1668 if (_this.deletemenu.el.parent == null) {
1669 _this.deletemenu.el.set_parent(_this.main_window.el);
1674 _this.deletemenu.el.set_offset(
1675 (int)in_x - _this.view.el.get_width() ,
1676 (int)in_y - _this.view.el.get_height()
1678 _this.deletemenu.el.set_position(Gtk.PositionType.BOTTOM);
1679 _this.deletemenu.el.popup();
1684 // user defined functions
1687 public class Xcls_selmodel : Object
1689 public Gtk.SingleSelection el;
1690 private Xcls_LeftProps _this;
1696 public Xcls_selmodel(Xcls_LeftProps _owner )
1699 _this.selmodel = this;
1700 new Xcls_model( _this );
1701 this.el = new Gtk.SingleSelection( _this.model.el );
1705 // set gobject values
1706 this.el.can_unselect = true;
1709 // user defined functions
1710 public void startEditing (JsRender.NodeProp prop) {
1711 // should we call select?? - caller does int (from windowstate)
1714 public void selectProp (JsRender.NodeProp prop) {
1715 for (var i = 0 ; i < this.el.n_items; i++) {
1716 var r = (JsRender.NodeProp)this.el.get_item(i);
1717 if (r.equals(prop)) {
1718 this.el.selected = i;
1724 public JsRender.NodeProp getPropAt (uint row) {
1726 return (JsRender.NodeProp) this.el.get_item(row);
1731 public class Xcls_model : Object
1733 public GLib.ListStore el;
1734 private Xcls_LeftProps _this;
1740 public Xcls_model(Xcls_LeftProps _owner )
1744 this.el = new GLib.ListStore(typeof(JsRender.NodeProp));
1748 // set gobject values
1751 // user defined functions
1755 public class Xcls_keycol : Object
1757 public Gtk.ColumnViewColumn el;
1758 private Xcls_LeftProps _this;
1764 public Xcls_keycol(Xcls_LeftProps _owner )
1767 _this.keycol = this;
1768 var child_1 = new Xcls_SignalListItemFactory36( _this );
1770 this.el = new Gtk.ColumnViewColumn( "Property", child_1.el );
1774 // set gobject values
1775 this.el.id = "keycol";
1776 this.el.expand = true;
1777 this.el.resizable = true;
1780 // user defined functions
1782 public class Xcls_SignalListItemFactory36 : Object
1784 public Gtk.SignalListItemFactory el;
1785 private Xcls_LeftProps _this;
1791 public Xcls_SignalListItemFactory36(Xcls_LeftProps _owner )
1794 this.el = new Gtk.SignalListItemFactory();
1798 // set gobject values
1801 this.el.setup.connect( (listitem) => {
1802 var lbl = new Gtk.Label("");
1803 ((Gtk.ListItem)listitem).set_child(lbl);
1804 lbl.justify = Gtk.Justification.LEFT;
1806 lbl.use_markup = true;
1807 lbl.ellipsize = Pango.EllipsizeMode.START;
1808 /*lbl.changed.connect(() => {
1809 // notify and save the changed value...
1810 //var prop = (JsRender.NodeProp) ((Gtk.ListItem)listitem.get_item());
1812 //prop.val = lbl.text;
1813 //_this.updateIter(iter,prop);
1817 ((Gtk.ListItem)listitem).activatable = true;
1819 this.el.bind.connect( (listitem) => {
1820 var lb = (Gtk.Label) ((Gtk.ListItem)listitem).get_child();
1821 var item = (JsRender.NodeProp) ((Gtk.ListItem)listitem).get_item();
1824 item.bind_property("to_display_name_prop",
1826 GLib.BindingFlags.SYNC_CREATE);
1827 item.bind_property("to_tooltip_name_prop",
1828 lb, "tooltip_markup",
1829 GLib.BindingFlags.SYNC_CREATE);
1830 // was item (1) in old layout
1836 // user defined functions
1840 public class Xcls_valcol : Object
1842 public Gtk.ColumnViewColumn el;
1843 private Xcls_LeftProps _this;
1849 public Xcls_valcol(Xcls_LeftProps _owner )
1852 _this.valcol = this;
1853 var child_1 = new Xcls_SignalListItemFactory38( _this );
1855 this.el = new Gtk.ColumnViewColumn( "Value", child_1.el );
1859 // set gobject values
1860 this.el.id = "valcol";
1861 this.el.expand = true;
1862 this.el.resizable = true;
1865 // user defined functions
1867 public class Xcls_SignalListItemFactory38 : Object
1869 public Gtk.SignalListItemFactory el;
1870 private Xcls_LeftProps _this;
1874 public bool is_setting;
1877 public Xcls_SignalListItemFactory38(Xcls_LeftProps _owner )
1880 this.el = new Gtk.SignalListItemFactory();
1883 this.is_setting = false;
1885 // set gobject values
1888 this.el.setup.connect( (listitem) => {
1889 var hb = new Gtk.Box(Gtk.Orientation.HORIZONTAL,0);
1890 var elbl = new Gtk.EditableLabel("");
1891 elbl.hexpand = true;
1893 var lbl = new Gtk.Label("");
1896 lbl.use_markup = true;
1898 lbl.ellipsize = Pango.EllipsizeMode.END;
1899 var cb = new Gtk.DropDown(new Gtk.StringList({}), null);
1903 ((Gtk.ListItem)listitem).set_child(hb);
1905 var ef = new Gtk.EventControllerFocus();
1906 ef.enter.connect(() => {
1907 _this.stop_editor();
1908 var prop = (JsRender.NodeProp)((Gtk.ListItem)listitem).get_item();
1909 _this.selmodel.selectProp(prop);
1911 elbl.add_controller(ef);
1914 // dropdown??? - stop editing, and highliht node
1915 var tb = (Gtk.ToggleButton) cb.get_first_child();
1916 tb.clicked.connect(() => {
1917 var prop = (JsRender.NodeProp)((Gtk.ListItem)listitem).get_item();
1919 _this.stop_editor();
1920 _this.selmodel.selectProp(prop);
1923 elbl.changed.connect(() => {
1924 // notify and save the changed value...
1926 //_this.updateIter(iter,prop);
1927 // this should happen automatically
1929 if (!_this.loading && !this.is_setting) {
1930 var prop = (JsRender.NodeProp)((Gtk.ListItem)listitem).get_item();
1933 prop.val = elbl.text;
1934 GLib.debug("calling changed");
1942 cb.notify["selected"].connect(() => {
1943 // dropdown selection changed.
1947 //_this.updateIter(iter,prop);
1948 if (!_this.loading && !this.is_setting) {
1949 var prop = (JsRender.NodeProp)((Gtk.ListItem)listitem).get_item();
1950 var model = (Gtk.StringList)cb.model;
1951 prop.val = model.get_string(cb.selected);
1952 GLib.debug("property set to %s", prop.val);
1953 GLib.debug("calling changed");
1960 var gc = new Gtk.GestureClick();
1961 lbl.add_controller(gc);
1962 gc.pressed.connect(() => {
1963 var prop = (JsRender.NodeProp)((Gtk.ListItem)listitem).get_item();
1964 _this.stop_editor();
1965 _this.show_editor(_this.file, prop.parent, prop);
1971 this.el.bind.connect( (listitem) => {
1972 this.is_setting = true;
1975 var bx = (Gtk.Box) ((Gtk.ListItem)listitem).get_child();
1980 var elbl = (Gtk.EditableLabel)bx.get_first_child();
1981 var lbl = (Gtk.Label) elbl.get_next_sibling();
1982 var cb = (Gtk.DropDown) lbl.get_next_sibling();
1983 // decide if it's a combo or editable text..
1984 var model = (Gtk.StringList) cb.model;
1990 var prop = (JsRender.NodeProp) ((Gtk.ListItem)listitem).get_item();
1991 //GLib.debug("prop = %s", prop.get_type().name());
1992 //GLib.debug("prop.val = %s", prop.val);
1993 //GLib.debug("prop.key = %s", prop.to_display_name());
1995 var use_textarea = prop.useTextArea();
1998 var pal = _this.file.project.palete;
2001 var has_opts = pal.typeOptions(_this.node.fqn(), prop.name, prop.rtype, out opts);
2003 if (!has_opts && prop.ptype == JsRender.NodePropType.RAW) {
2004 use_textarea = true;
2009 prop.bind_property("val_short",
2011 GLib.BindingFlags.SYNC_CREATE);
2012 prop.bind_property("val_tooltip",
2013 lbl, "tooltip_markup",
2014 GLib.BindingFlags.SYNC_CREATE);
2016 this.is_setting = false;
2025 // others... - fill in options for true/false?
2026 // GLib.debug (ktype.up());
2029 while(model.get_n_items() > 0) {
2033 // can not remove - hopefully always empty.
2035 for(var i = 0; i < opts.length; i ++) {
2036 model.append( opts[i]);
2037 // not sure this is a great idea...
2038 if (opts[i].down() == prop.val.down()) {
2042 GLib.debug("Set selected item to %d", sel);
2043 cb.set_selected(sel > -1 ? sel : Gtk.INVALID_LIST_POSITION);
2044 this.is_setting = false;
2048 // see if type is a Enum.
2049 // triggers a changed event
2051 elbl.set_text(prop.val);
2054 this.is_setting = false;
2063 // user defined functions
2067 public class Xcls_ContextMenu : Object
2069 public Gtk.Popover el;
2070 private Xcls_LeftProps _this;
2076 public Xcls_ContextMenu(Xcls_LeftProps _owner )
2079 _this.ContextMenu = this;
2080 this.el = new Gtk.Popover();
2084 // set gobject values
2085 var child_1 = new Xcls_Box40( _this );
2086 this.el.child = child_1.el;
2089 // user defined functions
2091 public class Xcls_Box40 : Object
2094 private Xcls_LeftProps _this;
2100 public Xcls_Box40(Xcls_LeftProps _owner )
2103 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
2107 // set gobject values
2108 var child_1 = new Xcls_Button41( _this );
2110 this.el.append( child_1.el );
2113 // user defined functions
2115 public class Xcls_Button41 : Object
2117 public Gtk.Button el;
2118 private Xcls_LeftProps _this;
2124 public Xcls_Button41(Xcls_LeftProps _owner )
2127 this.el = new Gtk.Button();
2131 // set gobject values
2132 this.el.label = "Delete";
2135 this.el.activate.connect( ( ) =>{
2136 _this.deleteSelected();
2141 // user defined functions