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);
435 p.el.set_parent(this.el);
436 //p.el.set_pointing_to(rect);
438 p.el.set_position(Gtk.PositionType.BOTTOM);
439 p.el.autohide = true;
445 // user defined functions
447 public class Xcls_AddPropertyPopup : Object
449 public Gtk.Popover el;
450 private Xcls_LeftProps _this;
456 public Xcls_AddPropertyPopup(Xcls_LeftProps _owner )
459 _this.AddPropertyPopup = this;
460 this.el = new Gtk.Popover();
464 // set gobject values
465 this.el.autohide = true;
466 var child_1 = new Xcls_Box8( _this );
467 this.el.child = child_1.el;
470 // user defined functions
472 public class Xcls_Box8 : Object
475 private Xcls_LeftProps _this;
481 public Xcls_Box8(Xcls_LeftProps _owner )
484 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
488 // set gobject values
489 var child_1 = new Xcls_Button9( _this );
491 this.el.append( child_1.el );
492 var child_2 = new Xcls_Button10( _this );
494 this.el.append( child_2.el );
495 var child_3 = new Xcls_Button11( _this );
497 this.el.append( child_3.el );
498 var child_4 = new Xcls_Button12( _this );
500 this.el.append( child_4.el );
501 var child_5 = new Xcls_Button13( _this );
503 this.el.append( child_5.el );
504 var child_6 = new Xcls_Separator14( _this );
506 this.el.append( child_6.el );
507 var child_7 = new Xcls_Button15( _this );
509 this.el.append( child_7.el );
510 var child_8 = new Xcls_Button16( _this );
512 this.el.append( child_8.el );
513 var child_9 = new Xcls_Button17( _this );
515 this.el.append( child_9.el );
516 var child_10 = new Xcls_Separator18( _this );
518 this.el.append( child_10.el );
519 var child_11 = new Xcls_Button19( _this );
521 this.el.append( child_11.el );
522 var child_12 = new Xcls_Button20( _this );
524 this.el.append( child_12.el );
525 var child_13 = new Xcls_Button21( _this );
527 this.el.append( child_13.el );
528 var child_14 = new Xcls_Separator22( _this );
530 this.el.append( child_14.el );
531 var child_15 = new Xcls_Button23( _this );
533 this.el.append( child_15.el );
534 var child_16 = new Xcls_Button24( _this );
536 this.el.append( child_16.el );
537 var child_17 = new Xcls_Button25( _this );
539 this.el.append( child_17.el );
542 // user defined functions
544 public class Xcls_Button9 : Object
546 public Gtk.Button el;
547 private Xcls_LeftProps _this;
553 public Xcls_Button9(Xcls_LeftProps _owner )
556 this.el = new Gtk.Button();
560 // set gobject values
561 this.el.tooltip_markup = "Using _this.{ID} will map to this element";
562 this.el.label = "id: _this.{ID} (Vala)";
565 this.el.clicked.connect( () => {
566 _this.AddPropertyPopup.el.hide();
567 // is this userdef or special??
568 var add = new JsRender.NodeProp.prop("id");
569 if (_this.node.has_prop_key(add)) {
573 _this.node.add_prop( add );
575 _this.view.editProp( add );
581 // user defined functions
584 public class Xcls_Button10 : Object
586 public Gtk.Button el;
587 private Xcls_LeftProps _this;
593 public Xcls_Button10(Xcls_LeftProps _owner )
596 this.el = new Gtk.Button();
600 // set gobject values
601 this.el.tooltip_markup = "how to pack this element onto parent, (method, 2nd arg, 3rd arg) .. the 1st argument is filled by the element";
602 this.el.label = "pack: Pack method (Vala)";
605 this.el.clicked.connect( ( ) => {
608 _this.AddPropertyPopup.el.hide();
609 // is this userdef or special??
610 var add = new JsRender.NodeProp.special("pack", "add");
611 if (_this.node.has_prop_key(add)) {
615 _this.node.add_prop( add );
617 _this.view.editProp( add );
623 // user defined functions
626 public class Xcls_Button11 : Object
628 public Gtk.Button el;
629 private Xcls_LeftProps _this;
635 public Xcls_Button11(Xcls_LeftProps _owner )
638 this.el = new Gtk.Button();
642 // set gobject values
643 this.el.tooltip_markup = "eg. \n\nnew Clutter.Image.from_file(.....)";
644 this.el.label = "ctor: Alterative to default contructor (Vala)";
647 this.el.clicked.connect( ( ) => {
649 _this.AddPropertyPopup.el.hide();
650 // is this userdef or special??
651 var add = new JsRender.NodeProp.special("ctor");
652 if (_this.node.has_prop_key(add)) {
656 _this.node.add_prop( add );
658 _this.view.editProp( add );
663 // user defined functions
666 public class Xcls_Button12 : Object
668 public Gtk.Button el;
669 private Xcls_LeftProps _this;
675 public Xcls_Button12(Xcls_LeftProps _owner )
678 this.el = new Gtk.Button();
682 // set gobject values
683 this.el.tooltip_markup = "This code is called after the ctor";
684 this.el.label = "init: initialziation code (vala)";
687 this.el.clicked.connect( ( ) => {
689 _this.AddPropertyPopup.el.hide();
690 // is this userdef or special??
691 var add = new JsRender.NodeProp.special("init","{\n\n}\n" ) ;
692 if (_this.node.has_prop_key(add)) {
696 _this.node.add_prop( add );
698 _this.view.editProp( add );
702 // user defined functions
705 public class Xcls_Button13 : Object
707 public Gtk.Button el;
708 private Xcls_LeftProps _this;
714 public Xcls_Button13(Xcls_LeftProps _owner )
717 this.el = new Gtk.Button();
721 // set gobject values
722 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";
723 this.el.label = "cms-id: (Roo JS/Pman library)";
726 this.el.clicked.connect( () => {
728 _this.AddPropertyPopup.el.hide();
729 // is this userdef or special??
730 var add = new JsRender.NodeProp.prop("cms-id","string", "" ) ;
731 if (_this.node.has_prop_key(add)) {
735 _this.node.add_prop( add );
737 _this.view.editProp( add );
742 // user defined functions
745 public class Xcls_Separator14 : Object
747 public Gtk.Separator el;
748 private Xcls_LeftProps _this;
754 public Xcls_Separator14(Xcls_LeftProps _owner )
757 this.el = new Gtk.Separator( Gtk.Orientation.HORIZONTAL );
761 // set gobject values
764 // user defined functions
767 public class Xcls_Button15 : Object
769 public Gtk.Button el;
770 private Xcls_LeftProps _this;
776 public Xcls_Button15(Xcls_LeftProps _owner )
779 this.el = new Gtk.Button();
783 // set gobject values
784 this.el.tooltip_markup = "Add a user defined string property";
785 this.el.label = "String";
788 this.el.clicked.connect( (self) => {
789 _this.AddPropertyPopup.el.hide();
790 _this.view.popover.show(
793 new JsRender.NodeProp.prop("", "string", "") ,
801 // user defined functions
804 public class Xcls_Button16 : Object
806 public Gtk.Button el;
807 private Xcls_LeftProps _this;
813 public Xcls_Button16(Xcls_LeftProps _owner )
816 this.el = new Gtk.Button();
820 // set gobject values
821 this.el.tooltip_markup = "Add a user defined number property";
822 this.el.label = "Number";
825 this.el.clicked.connect( ( ) =>{
826 _this.AddPropertyPopup.el.hide();
828 _this.view.popover.show(
831 new JsRender.NodeProp.prop("", "int", "0") ,
839 // user defined functions
842 public class Xcls_Button17 : Object
844 public Gtk.Button el;
845 private Xcls_LeftProps _this;
851 public Xcls_Button17(Xcls_LeftProps _owner )
854 this.el = new Gtk.Button();
858 // set gobject values
859 this.el.tooltip_markup = "Add a user defined boolean property";
860 this.el.label = "Boolean";
863 this.el.clicked.connect( ( ) =>{
865 _this.AddPropertyPopup.el.hide();
866 _this.view.popover.show(
869 new JsRender.NodeProp.prop("", "bool", "true") ,
877 // user defined functions
880 public class Xcls_Separator18 : Object
882 public Gtk.Separator el;
883 private Xcls_LeftProps _this;
889 public Xcls_Separator18(Xcls_LeftProps _owner )
892 this.el = new Gtk.Separator( Gtk.Orientation.HORIZONTAL );
896 // set gobject values
899 // user defined functions
902 public class Xcls_Button19 : Object
904 public Gtk.Button el;
905 private Xcls_LeftProps _this;
911 public Xcls_Button19(Xcls_LeftProps _owner )
914 this.el = new Gtk.Button();
918 // set gobject values
919 this.el.tooltip_markup = "Add a user function boolean property";
920 this.el.label = "Javascript Function";
923 this.el.clicked.connect( ( ) =>{
924 _this.AddPropertyPopup.el.hide();
925 _this.view.popover.show(
928 new JsRender.NodeProp.jsmethod("") ,
937 // user defined functions
940 public class Xcls_Button20 : Object
942 public Gtk.Button el;
943 private Xcls_LeftProps _this;
949 public Xcls_Button20(Xcls_LeftProps _owner )
952 this.el = new Gtk.Button();
956 // set gobject values
957 this.el.tooltip_markup = "Add a user function boolean property";
958 this.el.label = "Vala Method";
961 this.el.clicked.connect( ( ) =>{
962 _this.AddPropertyPopup.el.hide();
963 _this.view.popover.show(
966 new JsRender.NodeProp.valamethod("") ,
973 // user defined functions
976 public class Xcls_Button21 : Object
978 public Gtk.Button el;
979 private Xcls_LeftProps _this;
985 public Xcls_Button21(Xcls_LeftProps _owner )
988 this.el = new Gtk.Button();
992 // set gobject values
993 this.el.tooltip_markup = "Add a vala signal";
994 this.el.label = "Vala Signal";
997 this.el.clicked.connect( ( ) =>{
998 _this.AddPropertyPopup.el.hide();
999 _this.view.popover.show(
1002 new JsRender.NodeProp.sig("" ) ,
1009 // user defined functions
1012 public class Xcls_Separator22 : Object
1014 public Gtk.Separator el;
1015 private Xcls_LeftProps _this;
1021 public Xcls_Separator22(Xcls_LeftProps _owner )
1024 this.el = new Gtk.Separator( Gtk.Orientation.HORIZONTAL );
1028 // set gobject values
1031 // user defined functions
1034 public class Xcls_Button23 : Object
1036 public Gtk.Button el;
1037 private Xcls_LeftProps _this;
1043 public Xcls_Button23(Xcls_LeftProps _owner )
1046 this.el = new Gtk.Button();
1050 // set gobject values
1051 this.el.tooltip_markup = "Add a flexy if (for HTML templates)";
1052 this.el.label = "Flexy - If";
1055 this.el.clicked.connect( ( ) =>{
1056 _this.AddPropertyPopup.el.hide();
1057 _this.view.popover.show(
1060 new JsRender.NodeProp.prop("flexy:if", "string", "value_or_condition") ,
1069 // user defined functions
1072 public class Xcls_Button24 : Object
1074 public Gtk.Button el;
1075 private Xcls_LeftProps _this;
1081 public Xcls_Button24(Xcls_LeftProps _owner )
1084 this.el = new Gtk.Button();
1088 // set gobject values
1089 this.el.tooltip_markup = "Add a flexy include (for HTML templates)";
1090 this.el.label = "Flexy - Include";
1093 this.el.clicked.connect( ( ) =>{
1094 _this.AddPropertyPopup.el.hide();
1095 _this.view.popover.show(
1098 new JsRender.NodeProp.prop("flexy:include", "string", "name_of_file.html") ,
1107 // user defined functions
1110 public class Xcls_Button25 : Object
1112 public Gtk.Button el;
1113 private Xcls_LeftProps _this;
1119 public Xcls_Button25(Xcls_LeftProps _owner )
1122 this.el = new Gtk.Button();
1126 // set gobject values
1127 this.el.tooltip_markup = "Add a flexy include (for HTML templates)";
1128 this.el.label = "Flexy - Foreach";
1131 this.el.clicked.connect( ( ) =>{
1132 _this.AddPropertyPopup.el.hide();
1133 _this.view.popover.show(
1136 new JsRender.NodeProp.prop("flexy:if", "string", "value_or_condition") ,
1144 // user defined functions
1151 public class Xcls_EditProps : Object
1153 public Gtk.ScrolledWindow el;
1154 private Xcls_LeftProps _this;
1158 public bool editing;
1161 public Xcls_EditProps(Xcls_LeftProps _owner )
1164 _this.EditProps = this;
1165 this.el = new Gtk.ScrolledWindow();
1168 this.editing = false;
1170 // set gobject values
1171 this.el.hexpand = true;
1172 this.el.vexpand = true;
1173 new Xcls_view( _this );
1174 this.el.set_child ( _this.view.el );
1180 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
1184 // user defined functions
1186 public class Xcls_view : Object
1188 public Gtk.ColumnView el;
1189 private Xcls_LeftProps _this;
1193 public Gtk.CssProvider css;
1194 public Xcls_PopoverProperty popover;
1197 public Xcls_view(Xcls_LeftProps _owner )
1201 new Xcls_selmodel( _this );
1202 this.el = new Gtk.ColumnView( _this.selmodel.el );
1205 this.popover = null;
1207 // set gobject values
1208 this.el.name = "leftprops-view";
1209 this.el.single_click_activate = false;
1210 this.el.hexpand = true;
1211 this.el.vexpand = true;
1212 this.el.show_row_separators = true;
1213 new Xcls_deletemenu( _this );
1214 var child_3 = new Xcls_GestureClick31( _this );
1216 this.el.add_controller( child_3.el );
1217 var child_4 = new Xcls_GestureClick32( _this );
1219 this.el.add_controller( child_4.el );
1220 new Xcls_keycol( _this );
1221 this.el.append_column ( _this.keycol.el );
1222 new Xcls_valcol( _this );
1223 this.el.append_column ( _this.valcol.el );
1224 new Xcls_ContextMenu( _this );
1230 this.css = new Gtk.CssProvider();
1232 this.css.load_from_string("
1233 #leftprops-view { font-size: 12px;}
1235 #leftprops-view dropdown button {
1239 #leftprops-view cell dropdown label {
1243 #leftprops-view cell {
1247 #leftprops-view cell label, #leftprops-view cell editablelable {
1252 Gtk.StyleContext.add_provider_for_display(
1253 this.el.get_display(),
1255 Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
1262 // user defined functions
1263 public Gtk.Widget? getWidgetAtRow (uint row) {
1266 from https://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465
1267 var colview = gesture.widget;
1268 var line_no = check_list_widget(colview, x,y);
1270 var item = colview.model.get_item(line_no);
1274 GLib.debug("Get Widget At Row %d", (int)row);
1275 var child = this.el.get_first_child();
1277 var reading_header = true;
1279 while (child != null) {
1280 GLib.debug("Got %s", child.get_type().name());
1281 if (reading_header) {
1284 if (child.get_type().name() != "GtkColumnListView") {
1285 child = child.get_next_sibling();
1288 child = child.get_first_child();
1289 reading_header = false;
1291 if (child.get_type().name() != "GtkColumnViewRowWidget") {
1292 child = child.get_next_sibling();
1296 if (line_no == row) {
1297 GLib.debug("Returning widget %s", child.get_type().name());
1298 return (Gtk.Widget)child;
1300 child = child.get_next_sibling();
1302 GLib.debug("Rturning null");
1306 public void editProp (JsRender.NodeProp prop)
1308 var sm = _this.selmodel.el;
1311 GLib.debug("finding node");
1312 _this.selmodel.selectProp(prop);
1314 for (var i = 0 ; i < sm.n_items; i++) {
1315 var r = (JsRender.NodeProp)sm.get_item(i);
1316 if (r.equals(prop)) {
1322 GLib.debug("finding node - cant find it");
1326 var r = this.getWidgetAtRow(sr);
1327 GLib.debug("r = %s", r.get_type().name());
1328 var ca = r.get_first_child();
1329 var ll = (Gtk.Label)ca.get_first_child();
1330 var cb = ca.get_next_sibling();
1331 var b = cb.get_first_child();
1332 var e = (Gtk.Entry) b.get_first_child();
1333 var l = (Gtk.Label) e.get_next_sibling();
1334 var d = (Gtk.DropDown) l.get_next_sibling();
1336 GLib.debug("row key = %s", ll.label);
1337 if (e.get_visible()) {
1338 _this.stop_editor();
1339 e.grab_focus_without_selecting();
1342 if (d.get_visible()) {
1343 _this.stop_editor();
1347 if (l.get_visible()) {
1348 _this.stop_editor();
1349 _this.show_editor(_this.file, prop.parent, prop);
1355 //gtkcolumnviewrowwidget
1359 // entry / label / dropdown
1363 public int getColAt (double x, double y) {
1366 from https://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465
1369 //Gtk.Allocation alloc = { 0, 0, 0, 0 };
1370 var child = this.el.get_first_child();
1374 while (child != null) {
1375 GLib.debug("Got %s", child.get_type().name());
1377 if (child.get_type().name() == "GtkColumnViewRowWidget") {
1378 child = child.get_first_child();
1382 //child.get_allocation(out alloc);
1383 if (x < (child.get_width() + offx)) {
1386 offx += child.get_width();
1388 child = child.get_next_sibling();
1395 public int getRowAt (double x, double in_y, out string pos) {
1402 from https://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465
1403 var colview = gesture.widget;
1404 var line_no = check_list_widget(colview, x,y);
1406 var item = colview.model.get_item(line_no);
1412 //GLib.debug("offset = %d y = %d", (int) voff, (int) in_y);
1413 var y = in_y + _this.EditProps.el.vadjustment.value;
1414 var child = this.el.get_first_child();
1415 //Gtk.Allocation alloc = { 0, 0, 0, 0 };
1417 var reading_header = true;
1419 var header_height = 0;
1422 while (child != null) {
1423 //GLib.debug("Got %s", child.get_type().name());
1424 if (reading_header) {
1427 if (child.get_type().name() != "GtkColumnListView") {
1428 h += child.get_height();
1429 child = child.get_next_sibling();
1432 // should be columnlistview
1433 child = child.get_first_child();
1434 GLib.debug("header height=%d", h);
1437 reading_header = false;
1441 if (child.get_type().name() != "GtkColumnViewRowWidget") {
1442 child = child.get_next_sibling();
1446 if (y < header_height) {
1451 var hh = child.get_height();
1452 //child.get_allocation(out alloc);
1453 //GLib.debug("got cell xy = %d,%d w,h= %d,%d", alloc.x, alloc.y, alloc.width, alloc.height);
1454 //GLib.debug("row %d y= %d %s", line_no, (int) (header_height + alloc.y),
1456 // child.visible ? "VIS" : "hidden");
1458 if (y > (header_height + real_y) && y <= (header_height + real_y + hh) ) {
1459 if (y > ( header_height + real_y + (hh * 0.8))) {
1461 } else if (y > ( header_height + real_y + (hh * 0.2))) {
1466 GLib.debug("getRowAt return : %d, %s", line_no, pos);
1471 if (real_y + hh > y) {
1475 child = child.get_next_sibling();
1481 public class Xcls_deletemenu : Object
1483 public Gtk.Popover el;
1484 private Xcls_LeftProps _this;
1490 public Xcls_deletemenu(Xcls_LeftProps _owner )
1493 _this.deletemenu = this;
1494 this.el = new Gtk.Popover();
1498 // set gobject values
1499 var child_1 = new Xcls_Box29( _this );
1500 this.el.child = child_1.el;
1503 // user defined functions
1505 public class Xcls_Box29 : Object
1508 private Xcls_LeftProps _this;
1514 public Xcls_Box29(Xcls_LeftProps _owner )
1517 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
1521 // set gobject values
1522 var child_1 = new Xcls_Button30( _this );
1524 this.el.append( child_1.el );
1527 // user defined functions
1529 public class Xcls_Button30 : Object
1531 public Gtk.Button el;
1532 private Xcls_LeftProps _this;
1538 public Xcls_Button30(Xcls_LeftProps _owner )
1541 this.el = new Gtk.Button();
1545 // set gobject values
1546 this.el.label = "Delete";
1549 this.el.clicked.connect( ( ) => {
1552 var n = (JsRender.NodeProp) _this.selmodel.el.selected_item;
1554 _this.deletemenu.el.hide();
1555 _this.node.remove_prop(n);
1559 // user defined functions
1564 public class Xcls_GestureClick31 : Object
1566 public Gtk.GestureClick el;
1567 private Xcls_LeftProps _this;
1573 public Xcls_GestureClick31(Xcls_LeftProps _owner )
1576 this.el = new Gtk.GestureClick();
1580 // set gobject values
1583 this.el.pressed.connect( (n_press, in_x, in_y) => {
1585 GLib.debug("Prssed %d", (int) this.el.get_current_button());
1587 var col = _this.view.getColAt(in_x, in_y);
1592 var row = _this.view.getRowAt(in_x, in_y, out pos);
1598 GLib.debug("hit row %d", row);
1599 var prop = _this.selmodel.getPropAt(row);
1600 _this.selmodel.selectProp(prop);
1602 //var point_at = _this.view.getWidgetAtRow(row);
1604 // need to shift down, as ev.y does not inclucde header apparently..
1605 // or popover might be trying to do a central?
1606 // _this.view.editPropertyDetails(prop, (int) in_y + 12);
1607 _this.stop_editor();
1608 _this.view.popover.show(
1618 // user defined functions
1621 public class Xcls_GestureClick32 : Object
1623 public Gtk.GestureClick el;
1624 private Xcls_LeftProps _this;
1630 public Xcls_GestureClick32(Xcls_LeftProps _owner )
1633 this.el = new Gtk.GestureClick();
1637 // set gobject values
1641 this.el.pressed.connect( (n_press, in_x, in_y) => {
1646 var row = _this.view.getRowAt(in_x, in_y, out pos);
1653 _this.stop_editor();
1654 GLib.debug("hit row %d", row);
1655 var prop = _this.selmodel.getPropAt(row);
1656 _this.selmodel.selectProp(prop);
1660 GLib.debug("Prssed %d", (int) this.el.get_current_button());
1661 //_this.deletemenu.el.set_parent(_this.view.el);
1662 _this.deletemenu.el.set_parent(_this.main_window.el);
1666 _this.deletemenu.el.set_offset(
1667 (int)in_x - _this.view.el.get_width() ,
1668 (int)in_y - _this.view.el.get_height()
1670 _this.deletemenu.el.set_position(Gtk.PositionType.BOTTOM);
1671 _this.deletemenu.el.popup();
1676 // user defined functions
1679 public class Xcls_selmodel : Object
1681 public Gtk.SingleSelection el;
1682 private Xcls_LeftProps _this;
1688 public Xcls_selmodel(Xcls_LeftProps _owner )
1691 _this.selmodel = this;
1692 new Xcls_model( _this );
1693 this.el = new Gtk.SingleSelection( _this.model.el );
1697 // set gobject values
1698 this.el.can_unselect = true;
1701 // user defined functions
1702 public void startEditing (JsRender.NodeProp prop) {
1703 // should we call select?? - caller does int (from windowstate)
1706 public void selectProp (JsRender.NodeProp prop) {
1707 for (var i = 0 ; i < this.el.n_items; i++) {
1708 var r = (JsRender.NodeProp)this.el.get_item(i);
1709 if (r.equals(prop)) {
1710 this.el.selected = i;
1716 public JsRender.NodeProp getPropAt (uint row) {
1718 return (JsRender.NodeProp) this.el.get_item(row);
1723 public class Xcls_model : Object
1725 public GLib.ListStore el;
1726 private Xcls_LeftProps _this;
1732 public Xcls_model(Xcls_LeftProps _owner )
1736 this.el = new GLib.ListStore(typeof(JsRender.NodeProp));
1740 // set gobject values
1743 // user defined functions
1747 public class Xcls_keycol : Object
1749 public Gtk.ColumnViewColumn el;
1750 private Xcls_LeftProps _this;
1756 public Xcls_keycol(Xcls_LeftProps _owner )
1759 _this.keycol = this;
1760 var child_1 = new Xcls_SignalListItemFactory36( _this );
1762 this.el = new Gtk.ColumnViewColumn( "Property", child_1.el );
1766 // set gobject values
1767 this.el.id = "keycol";
1768 this.el.expand = true;
1769 this.el.resizable = true;
1772 // user defined functions
1774 public class Xcls_SignalListItemFactory36 : Object
1776 public Gtk.SignalListItemFactory el;
1777 private Xcls_LeftProps _this;
1783 public Xcls_SignalListItemFactory36(Xcls_LeftProps _owner )
1786 this.el = new Gtk.SignalListItemFactory();
1790 // set gobject values
1793 this.el.setup.connect( (listitem) => {
1794 var lbl = new Gtk.Label("");
1795 ((Gtk.ListItem)listitem).set_child(lbl);
1796 lbl.justify = Gtk.Justification.LEFT;
1798 lbl.use_markup = true;
1799 lbl.ellipsize = Pango.EllipsizeMode.START;
1800 /*lbl.changed.connect(() => {
1801 // notify and save the changed value...
1802 //var prop = (JsRender.NodeProp) ((Gtk.ListItem)listitem.get_item());
1804 //prop.val = lbl.text;
1805 //_this.updateIter(iter,prop);
1809 ((Gtk.ListItem)listitem).activatable = true;
1811 this.el.bind.connect( (listitem) => {
1812 var lb = (Gtk.Label) ((Gtk.ListItem)listitem).get_child();
1813 var item = (JsRender.NodeProp) ((Gtk.ListItem)listitem).get_item();
1816 item.bind_property("to_display_name_prop",
1818 GLib.BindingFlags.SYNC_CREATE);
1819 item.bind_property("to_tooltip_name_prop",
1820 lb, "tooltip_markup",
1821 GLib.BindingFlags.SYNC_CREATE);
1822 // was item (1) in old layout
1828 // user defined functions
1832 public class Xcls_valcol : Object
1834 public Gtk.ColumnViewColumn el;
1835 private Xcls_LeftProps _this;
1841 public Xcls_valcol(Xcls_LeftProps _owner )
1844 _this.valcol = this;
1845 var child_1 = new Xcls_SignalListItemFactory38( _this );
1847 this.el = new Gtk.ColumnViewColumn( "Value", child_1.el );
1851 // set gobject values
1852 this.el.id = "valcol";
1853 this.el.expand = true;
1854 this.el.resizable = true;
1857 // user defined functions
1859 public class Xcls_SignalListItemFactory38 : Object
1861 public Gtk.SignalListItemFactory el;
1862 private Xcls_LeftProps _this;
1866 public bool is_setting;
1869 public Xcls_SignalListItemFactory38(Xcls_LeftProps _owner )
1872 this.el = new Gtk.SignalListItemFactory();
1875 this.is_setting = false;
1877 // set gobject values
1880 this.el.setup.connect( (listitem) => {
1881 var hb = new Gtk.Box(Gtk.Orientation.HORIZONTAL,0);
1882 var elbl = new Gtk.EditableLabel("");
1883 elbl.hexpand = true;
1885 var lbl = new Gtk.Label("");
1888 lbl.use_markup = true;
1890 lbl.ellipsize = Pango.EllipsizeMode.END;
1891 var cb = new Gtk.DropDown(new Gtk.StringList({}), null);
1895 ((Gtk.ListItem)listitem).set_child(hb);
1897 var ef = new Gtk.EventControllerFocus();
1898 ef.enter.connect(() => {
1899 _this.stop_editor();
1900 var prop = (JsRender.NodeProp)((Gtk.ListItem)listitem).get_item();
1901 _this.selmodel.selectProp(prop);
1903 elbl.add_controller(ef);
1906 // dropdown??? - stop editing, and highliht node
1907 var tb = (Gtk.ToggleButton) cb.get_first_child();
1908 tb.clicked.connect(() => {
1909 var prop = (JsRender.NodeProp)((Gtk.ListItem)listitem).get_item();
1911 _this.stop_editor();
1912 _this.selmodel.selectProp(prop);
1915 elbl.changed.connect(() => {
1916 // notify and save the changed value...
1918 //_this.updateIter(iter,prop);
1919 // this should happen automatically
1921 if (!_this.loading && !this.is_setting) {
1922 var prop = (JsRender.NodeProp)((Gtk.ListItem)listitem).get_item();
1925 prop.val = elbl.text;
1926 GLib.debug("calling changed");
1934 cb.notify["selected"].connect(() => {
1935 // dropdown selection changed.
1939 //_this.updateIter(iter,prop);
1940 if (!_this.loading && !this.is_setting) {
1941 var prop = (JsRender.NodeProp)((Gtk.ListItem)listitem).get_item();
1942 var model = (Gtk.StringList)cb.model;
1943 prop.val = model.get_string(cb.selected);
1944 GLib.debug("property set to %s", prop.val);
1945 GLib.debug("calling changed");
1952 var gc = new Gtk.GestureClick();
1953 lbl.add_controller(gc);
1954 gc.pressed.connect(() => {
1955 var prop = (JsRender.NodeProp)((Gtk.ListItem)listitem).get_item();
1956 _this.stop_editor();
1957 _this.show_editor(_this.file, prop.parent, prop);
1963 this.el.bind.connect( (listitem) => {
1964 this.is_setting = true;
1967 var bx = (Gtk.Box) ((Gtk.ListItem)listitem).get_child();
1972 var elbl = (Gtk.EditableLabel)bx.get_first_child();
1973 var lbl = (Gtk.Label) elbl.get_next_sibling();
1974 var cb = (Gtk.DropDown) lbl.get_next_sibling();
1975 // decide if it's a combo or editable text..
1976 var model = (Gtk.StringList) cb.model;
1982 var prop = (JsRender.NodeProp) ((Gtk.ListItem)listitem).get_item();
1983 //GLib.debug("prop = %s", prop.get_type().name());
1984 //GLib.debug("prop.val = %s", prop.val);
1985 //GLib.debug("prop.key = %s", prop.to_display_name());
1987 var use_textarea = prop.useTextArea();
1990 var pal = _this.file.project.palete;
1993 var has_opts = pal.typeOptions(_this.node.fqn(), prop.name, prop.rtype, out opts);
1995 if (!has_opts && prop.ptype == JsRender.NodePropType.RAW) {
1996 use_textarea = true;
2001 prop.bind_property("val_short",
2003 GLib.BindingFlags.SYNC_CREATE);
2004 prop.bind_property("val_tooltip",
2005 lbl, "tooltip_markup",
2006 GLib.BindingFlags.SYNC_CREATE);
2008 this.is_setting = false;
2017 // others... - fill in options for true/false?
2018 // GLib.debug (ktype.up());
2021 while(model.get_n_items() > 0) {
2025 // can not remove - hopefully always empty.
2027 for(var i = 0; i < opts.length; i ++) {
2028 model.append( opts[i]);
2029 // not sure this is a great idea...
2030 if (opts[i].down() == prop.val.down()) {
2034 GLib.debug("Set selected item to %d", sel);
2035 cb.set_selected(sel > -1 ? sel : Gtk.INVALID_LIST_POSITION);
2036 this.is_setting = false;
2040 // see if type is a Enum.
2041 // triggers a changed event
2043 elbl.set_text(prop.val);
2046 this.is_setting = false;
2055 // user defined functions
2059 public class Xcls_ContextMenu : Object
2061 public Gtk.Popover el;
2062 private Xcls_LeftProps _this;
2068 public Xcls_ContextMenu(Xcls_LeftProps _owner )
2071 _this.ContextMenu = this;
2072 this.el = new Gtk.Popover();
2076 // set gobject values
2077 var child_1 = new Xcls_Box40( _this );
2078 this.el.child = child_1.el;
2081 // user defined functions
2083 public class Xcls_Box40 : Object
2086 private Xcls_LeftProps _this;
2092 public Xcls_Box40(Xcls_LeftProps _owner )
2095 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
2099 // set gobject values
2100 var child_1 = new Xcls_Button41( _this );
2102 this.el.append( child_1.el );
2105 // user defined functions
2107 public class Xcls_Button41 : Object
2109 public Gtk.Button el;
2110 private Xcls_LeftProps _this;
2116 public Xcls_Button41(Xcls_LeftProps _owner )
2119 this.el = new Gtk.Button();
2123 // set gobject values
2124 this.el.label = "Delete";
2127 this.el.activate.connect( ( ) =>{
2128 _this.deleteSelected();
2133 // user defined functions