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 int last_error_counter;
32 public signal void changed ();
33 public JsRender.JsRender file;
34 public JsRender.Node node;
35 public signal void show_editor (JsRender.JsRender file, JsRender.Node node, JsRender.NodeProp prop);
38 public Xcls_LeftProps()
41 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
45 this.allow_edit = false;
46 this.main_window = null;
47 this.last_error_counter = -1;
50 this.el.homogeneous = false ;
51 this.el.hexpand = true;
52 this.el.vexpand = true;
53 var child_1 = new Xcls_Box2( _this );
55 this.el.append( child_1.el );
56 new Xcls_EditProps( _this );
57 this.el.append( _this.EditProps.el );
60 // user defined functions
61 public string keySortFormat (string key) {
62 // listeners first - with 0
69 var bits = key.split(" ");
72 return "2 " + bits[bits.length -1];
76 return "3 " + bits[bits.length -1];
81 return "4 " + bits[bits.length -1];
84 return "5 " + bits[bits.length -1];
89 public void updateErrors () {
91 var ar = file.getErrors();
94 this.last_error_counter = file.error_counter ;
98 if (this.last_error_counter == file.error_counter) {
103 foreach(var diag in ar) {
106 // print("get inter\n");
107 var node= file.lineToNode( (int)diag.range.start.line) ;
108 if (node == null || node.oid != this.node.oid) {
111 var prop = node.lineToProp( (int)diag.range.start.line) ;
113 var row = _this.selmodel.propToRow(prop);
117 var w = this.view.getWidgetAtRow(row);
121 var ed = diag.category.down();
122 if (ed != "err" && w.has_css_class("node-err")) {
125 if (ed == "err" && w.has_css_class("node-warn")) {
126 w.remove_css_class("node-warn");
128 if (ed == "err" && w.has_css_class("node-depr")) {
129 w.remove_css_class("node-depr");
131 if (!w.has_css_class("node-"+ ed)) {
132 w.add_css_class("node-" + ed);
138 public string keyFormat (string val, string type) {
140 // Glib.markup_escape_text(val);
142 if (type == "listener") {
143 return "<span font_weight=\"bold\" color=\"#660000\">" +
144 GLib.Markup.escape_text(val) +
148 if (val.length < 1) {
149 return "<span color=\"#FF0000\">--empty--</span>";
154 //# - object properties
156 // all of these... - display value is last element..
157 var ar = val.strip().split(" ");
160 var dval = GLib.Markup.escape_text(ar[ar.length-1]);
166 case '@': // signal // just bold balck?
167 if (dval[0] == '@') {
168 dval = dval.substring(1);
171 return @"<span font_weight=\"bold\">@ $dval</span>";
172 case '#': // object properties?
173 if (dval[0] == '#') {
174 dval = dval.substring(1);
176 return @"<span font_weight=\"bold\">$dval</span>";
178 if (dval[0] == '*') {
179 dval = dval.substring(1);
181 return @"<span color=\"#0000CC\" font_weight=\"bold\">$dval</span>";
183 if (dval[0] == '$') {
184 dval = dval.substring(1);
186 return @"<span style=\"italic\">$dval</span>";
187 case '|': // user defined methods
188 if (dval[0] == '|') {
189 dval = dval.substring(1);
191 return @"<span color=\"#008000\" font_weight=\"bold\">$dval</span>";
202 public void deleteSelected () {
210 var s = this.view.el.get_selection();
211 s.get_selected(out mod, out iter);
215 mod.get_value(iter, 0 , out gval);
216 var prop = (JsRender.NodeProp)gval;
218 this.load(this.file, this.node);
221 // stop editor after fetching property - otherwise prop is null.
226 case JsRender.NodePropType.LISTENER:
227 this.node.listeners.unset(prop.to_index_key());
231 this.node.props.unset(prop.to_index_key());
234 this.load(this.file, this.node);
239 public void removeErrors () {
240 var child = this.view.el.get_first_child();
242 var reading_header = true;
244 while (child != null) {
245 GLib.debug("Got %s", child.get_type().name());
247 if (reading_header) {
250 if (child.get_type().name() != "GtkColumnListView") {
252 child = child.get_next_sibling();
255 // should be columnlistview
256 child = child.get_first_child();
260 reading_header = false;
264 if (!child.has_css_class("node-err")) {
265 child.remove_css_class("node-err");
267 if (!child.has_css_class("node-warn")) {
268 child.remove_css_class("node-warn");
271 if (!child.has_css_class("node-depr")) {
272 child.remove_css_class("node-depr");
275 child = child.get_next_sibling();
277 //GLib.debug("Rturning null");
280 public void a_addProp (JsRender.NodeProp prop) {
281 // info includes key, val, skel, etype..
282 //console.dump(info);
283 //type = info.type.toLowerCase();
284 //var data = this.toJS();
287 if (prop.ptype == JsRender.NodePropType.LISTENER) {
288 if (this.node.listeners.has_key(prop.name)) {
291 this.node.listeners.set(prop.name,prop);
293 assert(this.node != null);
294 assert(this.node.props != null);
295 if (this.node.props.has_key(prop.to_index_key())) {
298 this.node.props.set(prop.to_index_key(),prop);
303 this.load(this.file, this.node);
308 GLib.debug("trying to find new iter");
313 public void load (JsRender.JsRender file, JsRender.Node? node)
315 // not sure when to initialize this - we should do it on setting main window really.
318 if (this.view.popover == null) {
319 this.view.popover = new Xcls_PopoverProperty();
320 this.view.popover.mainwindow = _this.main_window;
324 if (this.node != null) {
325 this.node.dupeProps(); // ensures removeall will not do somethign silly
329 GLib.debug("load leftprops\n");
335 this.model.el.remove_all();
337 //this.get('/RightEditor').el.hide();
341 node.loadProps(this.model.el);
344 //GLib.debug("clear selection\n");
346 this.loading = false;
347 this.selmodel.el.set_selected(Gtk.INVALID_LIST_POSITION);
350 //this.model.el.set_sort_column_id(4,Gtk.SortType.ASCENDING); // sort by real key..
352 // this.view.el.get_selection().unselect_all();
354 // _this.keycol.el.set_max_width(_this.EditProps.el.get_allocated_width()/ 2);
355 // _this.valcol.el.set_max_width(_this.EditProps.el.get_allocated_width()/ 2);
358 public class Xcls_Box2 : Object
361 private Xcls_LeftProps _this;
367 public Xcls_Box2(Xcls_LeftProps _owner )
370 this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
374 // set gobject values
375 this.el.hexpand = true;
376 var child_1 = new Xcls_Label3( _this );
378 this.el.append( child_1.el );
379 var child_2 = new Xcls_Button4( _this );
381 this.el.append( child_2.el );
382 var child_3 = new Xcls_Button5( _this );
384 this.el.append( child_3.el );
385 var child_4 = new Xcls_Button6( _this );
387 this.el.append( child_4.el );
390 // user defined functions
392 public class Xcls_Label3 : Object
395 private Xcls_LeftProps _this;
401 public Xcls_Label3(Xcls_LeftProps _owner )
404 this.el = new Gtk.Label( "Add:" );
408 // set gobject values
409 this.el.margin_end = 5;
410 this.el.margin_start = 5;
413 // user defined functions
416 public class Xcls_Button4 : Object
418 public Gtk.Button el;
419 private Xcls_LeftProps _this;
423 public bool always_show_image;
426 public Xcls_Button4(Xcls_LeftProps _owner )
429 this.el = new Gtk.Button();
432 this.always_show_image = true;
434 // set gobject values
435 this.el.icon_name = "format-justify-left";
436 this.el.hexpand = true;
437 this.el.tooltip_text = "Add Property";
438 this.el.label = "Property";
441 this.el.clicked.connect( ( ) => {
443 _this.main_window.windowstate.showProps(
445 JsRender.NodePropType.PROP
451 // user defined functions
454 public class Xcls_Button5 : Object
456 public Gtk.Button el;
457 private Xcls_LeftProps _this;
461 public bool always_show_image;
464 public Xcls_Button5(Xcls_LeftProps _owner )
467 this.el = new Gtk.Button();
470 this.always_show_image = true;
472 // set gobject values
473 this.el.icon_name = "appointment-new";
474 this.el.hexpand = true;
475 this.el.tooltip_text = "Add Event Code";
476 this.el.label = "Event";
479 this.el.clicked.connect( ( ) => {
482 _this.main_window.windowstate.showProps(
484 JsRender.NodePropType.LISTENER
491 // user defined functions
494 public class Xcls_Button6 : Object
496 public Gtk.Button el;
497 private Xcls_LeftProps _this;
501 public bool always_show_image;
504 public Xcls_Button6(Xcls_LeftProps _owner )
507 this.el = new Gtk.Button();
510 this.always_show_image = true;
512 // set gobject values
513 this.el.icon_name = "list-add";
514 this.el.hexpand = true;
515 this.el.label = "Other";
516 new Xcls_AddPropertyPopup( _this );
519 this.el.clicked.connect( ( ) => {
520 //_this.before_edit();
523 var p = _this.AddPropertyPopup;
525 // Gtk.Allocation rect;
526 //this.el.get_allocation(out rect);
527 if (p.el.parent == null) {
528 p.el.set_parent(this.el);
530 //p.el.set_pointing_to(rect);
532 p.el.set_position(Gtk.PositionType.BOTTOM);
533 p.el.autohide = true;
539 // user defined functions
541 public class Xcls_AddPropertyPopup : Object
543 public Gtk.Popover el;
544 private Xcls_LeftProps _this;
550 public Xcls_AddPropertyPopup(Xcls_LeftProps _owner )
553 _this.AddPropertyPopup = this;
554 this.el = new Gtk.Popover();
558 // set gobject values
559 this.el.autohide = true;
560 var child_1 = new Xcls_Box8( _this );
561 this.el.child = child_1.el;
564 // user defined functions
566 public class Xcls_Box8 : Object
569 private Xcls_LeftProps _this;
575 public Xcls_Box8(Xcls_LeftProps _owner )
578 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
582 // set gobject values
583 var child_1 = new Xcls_Button9( _this );
585 this.el.append( child_1.el );
586 var child_2 = new Xcls_Button10( _this );
588 this.el.append( child_2.el );
589 var child_3 = new Xcls_Button11( _this );
591 this.el.append( child_3.el );
592 var child_4 = new Xcls_Button12( _this );
594 this.el.append( child_4.el );
595 var child_5 = new Xcls_Button13( _this );
597 this.el.append( child_5.el );
598 var child_6 = new Xcls_Separator14( _this );
600 this.el.append( child_6.el );
601 var child_7 = new Xcls_Button15( _this );
603 this.el.append( child_7.el );
604 var child_8 = new Xcls_Button16( _this );
606 this.el.append( child_8.el );
607 var child_9 = new Xcls_Button17( _this );
609 this.el.append( child_9.el );
610 var child_10 = new Xcls_Separator18( _this );
612 this.el.append( child_10.el );
613 var child_11 = new Xcls_Button19( _this );
615 this.el.append( child_11.el );
616 var child_12 = new Xcls_Button20( _this );
618 this.el.append( child_12.el );
619 var child_13 = new Xcls_Button21( _this );
621 this.el.append( child_13.el );
622 var child_14 = new Xcls_Separator22( _this );
624 this.el.append( child_14.el );
625 var child_15 = new Xcls_Button23( _this );
627 this.el.append( child_15.el );
628 var child_16 = new Xcls_Button24( _this );
630 this.el.append( child_16.el );
631 var child_17 = new Xcls_Button25( _this );
633 this.el.append( child_17.el );
636 // user defined functions
638 public class Xcls_Button9 : Object
640 public Gtk.Button el;
641 private Xcls_LeftProps _this;
647 public Xcls_Button9(Xcls_LeftProps _owner )
650 this.el = new Gtk.Button();
654 // set gobject values
655 this.el.tooltip_markup = "Using _this.{ID} will map to this element";
656 this.el.label = "id: _this.{ID} (Vala)";
659 this.el.clicked.connect( () => {
660 _this.AddPropertyPopup.el.hide();
661 // is this userdef or special??
662 var add = new JsRender.NodeProp.prop("id");
663 if (_this.node.has_prop_key(add)) {
667 _this.node.add_prop( add );
669 _this.view.editProp( add );
675 // user defined functions
678 public class Xcls_Button10 : Object
680 public Gtk.Button el;
681 private Xcls_LeftProps _this;
687 public Xcls_Button10(Xcls_LeftProps _owner )
690 this.el = new Gtk.Button();
694 // set gobject values
695 this.el.tooltip_markup = "how to pack this element onto parent, (method, 2nd arg, 3rd arg) .. the 1st argument is filled by the element";
696 this.el.label = "pack: Pack method (Vala)";
699 this.el.clicked.connect( ( ) => {
702 _this.AddPropertyPopup.el.hide();
703 // is this userdef or special??
704 var add = new JsRender.NodeProp.special("pack", "add");
705 if (_this.node.has_prop_key(add)) {
709 _this.node.add_prop( add );
711 _this.view.editProp( add );
717 // user defined functions
720 public class Xcls_Button11 : Object
722 public Gtk.Button el;
723 private Xcls_LeftProps _this;
729 public Xcls_Button11(Xcls_LeftProps _owner )
732 this.el = new Gtk.Button();
736 // set gobject values
737 this.el.tooltip_markup = "eg. \n\nnew Clutter.Image.from_file(.....)";
738 this.el.label = "ctor: Alterative to default contructor (Vala)";
741 this.el.clicked.connect( ( ) => {
743 _this.AddPropertyPopup.el.hide();
744 // is this userdef or special??
745 var add = new JsRender.NodeProp.special("ctor");
746 if (_this.node.has_prop_key(add)) {
750 _this.node.add_prop( add );
752 _this.view.editProp( add );
757 // user defined functions
760 public class Xcls_Button12 : Object
762 public Gtk.Button el;
763 private Xcls_LeftProps _this;
769 public Xcls_Button12(Xcls_LeftProps _owner )
772 this.el = new Gtk.Button();
776 // set gobject values
777 this.el.tooltip_markup = "This code is called after the ctor";
778 this.el.label = "init: initialziation code (vala)";
781 this.el.clicked.connect( ( ) => {
783 _this.AddPropertyPopup.el.hide();
784 // is this userdef or special??
785 var add = new JsRender.NodeProp.special("init","{\n\n}\n" ) ;
786 if (_this.node.has_prop_key(add)) {
790 _this.node.add_prop( add );
792 _this.view.editProp( add );
796 // user defined functions
799 public class Xcls_Button13 : Object
801 public Gtk.Button el;
802 private Xcls_LeftProps _this;
808 public Xcls_Button13(Xcls_LeftProps _owner )
811 this.el = new Gtk.Button();
815 // set gobject values
816 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";
817 this.el.label = "cms-id: (Roo JS/Pman library)";
820 this.el.clicked.connect( () => {
822 _this.AddPropertyPopup.el.hide();
823 // is this userdef or special??
824 var add = new JsRender.NodeProp.prop("cms-id","string", "" ) ;
825 if (_this.node.has_prop_key(add)) {
829 _this.node.add_prop( add );
831 _this.view.editProp( add );
836 // user defined functions
839 public class Xcls_Separator14 : Object
841 public Gtk.Separator el;
842 private Xcls_LeftProps _this;
848 public Xcls_Separator14(Xcls_LeftProps _owner )
851 this.el = new Gtk.Separator( Gtk.Orientation.HORIZONTAL );
855 // set gobject values
858 // user defined functions
861 public class Xcls_Button15 : Object
863 public Gtk.Button el;
864 private Xcls_LeftProps _this;
870 public Xcls_Button15(Xcls_LeftProps _owner )
873 this.el = new Gtk.Button();
877 // set gobject values
878 this.el.tooltip_markup = "Add a user defined string property";
879 this.el.label = "String";
882 this.el.clicked.connect( (self) => {
883 _this.AddPropertyPopup.el.hide();
884 _this.view.popover.show(
887 new JsRender.NodeProp.prop("", "string", "") ,
895 // user defined functions
898 public class Xcls_Button16 : Object
900 public Gtk.Button el;
901 private Xcls_LeftProps _this;
907 public Xcls_Button16(Xcls_LeftProps _owner )
910 this.el = new Gtk.Button();
914 // set gobject values
915 this.el.tooltip_markup = "Add a user defined number property";
916 this.el.label = "Number";
919 this.el.clicked.connect( ( ) =>{
920 _this.AddPropertyPopup.el.hide();
922 _this.view.popover.show(
925 new JsRender.NodeProp.prop("", "int", "0") ,
933 // user defined functions
936 public class Xcls_Button17 : Object
938 public Gtk.Button el;
939 private Xcls_LeftProps _this;
945 public Xcls_Button17(Xcls_LeftProps _owner )
948 this.el = new Gtk.Button();
952 // set gobject values
953 this.el.tooltip_markup = "Add a user defined boolean property";
954 this.el.label = "Boolean";
957 this.el.clicked.connect( ( ) =>{
959 _this.AddPropertyPopup.el.hide();
960 _this.view.popover.show(
963 new JsRender.NodeProp.prop("", "bool", "true") ,
971 // user defined functions
974 public class Xcls_Separator18 : Object
976 public Gtk.Separator el;
977 private Xcls_LeftProps _this;
983 public Xcls_Separator18(Xcls_LeftProps _owner )
986 this.el = new Gtk.Separator( Gtk.Orientation.HORIZONTAL );
990 // set gobject values
993 // user defined functions
996 public class Xcls_Button19 : Object
998 public Gtk.Button el;
999 private Xcls_LeftProps _this;
1005 public Xcls_Button19(Xcls_LeftProps _owner )
1008 this.el = new Gtk.Button();
1012 // set gobject values
1013 this.el.tooltip_markup = "Add a user function boolean property";
1014 this.el.label = "Javascript Function";
1017 this.el.clicked.connect( ( ) =>{
1018 _this.AddPropertyPopup.el.hide();
1019 _this.view.popover.show(
1022 new JsRender.NodeProp.jsmethod("") ,
1031 // user defined functions
1034 public class Xcls_Button20 : Object
1036 public Gtk.Button el;
1037 private Xcls_LeftProps _this;
1043 public Xcls_Button20(Xcls_LeftProps _owner )
1046 this.el = new Gtk.Button();
1050 // set gobject values
1051 this.el.tooltip_markup = "Add a user function boolean property";
1052 this.el.label = "Vala Method";
1055 this.el.clicked.connect( ( ) =>{
1056 _this.AddPropertyPopup.el.hide();
1057 _this.view.popover.show(
1060 new JsRender.NodeProp.valamethod("") ,
1067 // user defined functions
1070 public class Xcls_Button21 : Object
1072 public Gtk.Button el;
1073 private Xcls_LeftProps _this;
1079 public Xcls_Button21(Xcls_LeftProps _owner )
1082 this.el = new Gtk.Button();
1086 // set gobject values
1087 this.el.tooltip_markup = "Add a vala signal";
1088 this.el.label = "Vala Signal";
1091 this.el.clicked.connect( ( ) =>{
1092 _this.AddPropertyPopup.el.hide();
1093 _this.view.popover.show(
1096 new JsRender.NodeProp.sig("" ) ,
1103 // user defined functions
1106 public class Xcls_Separator22 : Object
1108 public Gtk.Separator el;
1109 private Xcls_LeftProps _this;
1115 public Xcls_Separator22(Xcls_LeftProps _owner )
1118 this.el = new Gtk.Separator( Gtk.Orientation.HORIZONTAL );
1122 // set gobject values
1125 // user defined functions
1128 public class Xcls_Button23 : Object
1130 public Gtk.Button el;
1131 private Xcls_LeftProps _this;
1137 public Xcls_Button23(Xcls_LeftProps _owner )
1140 this.el = new Gtk.Button();
1144 // set gobject values
1145 this.el.tooltip_markup = "Add a flexy if (for HTML templates)";
1146 this.el.label = "Flexy - If";
1149 this.el.clicked.connect( ( ) =>{
1150 _this.AddPropertyPopup.el.hide();
1151 _this.view.popover.show(
1154 new JsRender.NodeProp.prop("flexy:if", "string", "value_or_condition") ,
1163 // user defined functions
1166 public class Xcls_Button24 : Object
1168 public Gtk.Button el;
1169 private Xcls_LeftProps _this;
1175 public Xcls_Button24(Xcls_LeftProps _owner )
1178 this.el = new Gtk.Button();
1182 // set gobject values
1183 this.el.tooltip_markup = "Add a flexy include (for HTML templates)";
1184 this.el.label = "Flexy - Include";
1187 this.el.clicked.connect( ( ) =>{
1188 _this.AddPropertyPopup.el.hide();
1189 _this.view.popover.show(
1192 new JsRender.NodeProp.prop("flexy:include", "string", "name_of_file.html") ,
1201 // user defined functions
1204 public class Xcls_Button25 : Object
1206 public Gtk.Button el;
1207 private Xcls_LeftProps _this;
1213 public Xcls_Button25(Xcls_LeftProps _owner )
1216 this.el = new Gtk.Button();
1220 // set gobject values
1221 this.el.tooltip_markup = "Add a flexy include (for HTML templates)";
1222 this.el.label = "Flexy - Foreach";
1225 this.el.clicked.connect( ( ) =>{
1226 _this.AddPropertyPopup.el.hide();
1227 _this.view.popover.show(
1230 new JsRender.NodeProp.prop("flexy:if", "string", "value_or_condition") ,
1238 // user defined functions
1245 public class Xcls_EditProps : Object
1247 public Gtk.ScrolledWindow el;
1248 private Xcls_LeftProps _this;
1252 public bool editing;
1255 public Xcls_EditProps(Xcls_LeftProps _owner )
1258 _this.EditProps = this;
1259 this.el = new Gtk.ScrolledWindow();
1262 this.editing = false;
1264 // set gobject values
1265 this.el.hexpand = true;
1266 this.el.vexpand = true;
1267 new Xcls_view( _this );
1268 this.el.set_child ( _this.view.el );
1274 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
1278 // user defined functions
1280 public class Xcls_view : Object
1282 public Gtk.ColumnView el;
1283 private Xcls_LeftProps _this;
1287 public Gtk.CssProvider css;
1288 public Xcls_PopoverProperty popover;
1291 public Xcls_view(Xcls_LeftProps _owner )
1295 new Xcls_selmodel( _this );
1296 this.el = new Gtk.ColumnView( _this.selmodel.el );
1299 this.popover = null;
1301 // set gobject values
1302 this.el.name = "leftprops-view";
1303 this.el.single_click_activate = false;
1304 this.el.hexpand = true;
1305 this.el.vexpand = true;
1306 this.el.show_row_separators = true;
1307 new Xcls_deletemenu( _this );
1308 var child_3 = new Xcls_GestureClick31( _this );
1310 this.el.add_controller( child_3.el );
1311 var child_4 = new Xcls_GestureClick32( _this );
1313 this.el.add_controller( child_4.el );
1314 new Xcls_keycol( _this );
1315 this.el.append_column ( _this.keycol.el );
1316 new Xcls_valcol( _this );
1317 this.el.append_column ( _this.valcol.el );
1318 new Xcls_ContextMenu( _this );
1324 this.css = new Gtk.CssProvider();
1326 this.css.load_from_string("
1327 #leftprops-view { font-size: 12px;}
1329 #leftprops-view dropdown button {
1333 #leftprops-view cell dropdown label {
1337 #leftprops-view cell {
1341 #leftprops-view cell label, #leftprops-view cell editablelable {
1346 Gtk.StyleContext.add_provider_for_display(
1347 this.el.get_display(),
1349 Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
1356 // user defined functions
1357 public Gtk.Widget? getWidgetAtRow (uint row) {
1360 from https://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465
1361 var colview = gesture.widget;
1362 var line_no = check_list_widget(colview, x,y);
1364 var item = colview.model.get_item(line_no);
1368 GLib.debug("Get Widget At Row %d", (int)row);
1369 var child = this.el.get_first_child();
1371 var reading_header = true;
1373 while (child != null) {
1374 GLib.debug("Got %s", child.get_type().name());
1375 if (reading_header) {
1378 if (child.get_type().name() != "GtkColumnListView") {
1379 child = child.get_next_sibling();
1382 child = child.get_first_child();
1383 reading_header = false;
1386 if (child.get_type().name() != "GtkColumnViewRowWidget") {
1387 child = child.get_next_sibling();
1391 if (line_no == row) {
1392 GLib.debug("Returning widget %s", child.get_type().name());
1393 return (Gtk.Widget)child;
1395 child = child.get_next_sibling();
1397 GLib.debug("Rturning null");
1401 public void editProp (JsRender.NodeProp prop)
1403 var sm = _this.selmodel.el;
1406 GLib.debug("finding node");
1407 _this.selmodel.selectProp(prop);
1409 for (var i = 0 ; i < sm.n_items; i++) {
1410 var r = (JsRender.NodeProp)sm.get_item(i);
1411 if (r.equals(prop)) {
1417 GLib.debug("finding node - cant find it");
1421 var r = this.getWidgetAtRow(sr);
1422 GLib.debug("r = %s", r.get_type().name());
1423 var ca = r.get_first_child();
1424 var ll = (Gtk.Label)ca.get_first_child();
1425 var cb = ca.get_next_sibling();
1426 var b = cb.get_first_child();
1427 var e = (Gtk.EditableLabel) b.get_first_child();
1428 var l = (Gtk.Label) e.get_next_sibling();
1429 var d = (Gtk.DropDown) l.get_next_sibling();
1431 GLib.debug("row key = %s", ll.label);
1432 if (e.get_visible()) {
1433 _this.stop_editor();
1435 //GLib.Timeout.add_once(500, () => {
1436 // var st = (Gtk.Stack) e.get_first_child();
1437 // var ed = (Gtk.Entry) st.get_visible_child();
1438 // ed.grab_focus_without_selecting();
1442 if (d.get_visible()) {
1443 _this.stop_editor();
1447 if (l.get_visible()) {
1448 _this.stop_editor();
1449 _this.show_editor(_this.file, prop.parent, prop);
1455 //gtkcolumnviewrowwidget
1459 // entry / label / dropdown
1463 public int getColAt (double x, double y) {
1466 from https://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465
1469 //Gtk.Allocation alloc = { 0, 0, 0, 0 };
1470 var child = this.el.get_first_child();
1474 while (child != null) {
1475 GLib.debug("Got %s", child.get_type().name());
1477 if (child.get_type().name() == "GtkColumnViewRowWidget") {
1478 child = child.get_first_child();
1482 //child.get_allocation(out alloc);
1483 if (x < (child.get_width() + offx)) {
1486 offx += child.get_width();
1488 child = child.get_next_sibling();
1495 public int getRowAt (double x, double in_y, out string pos) {
1502 from https://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465
1503 var colview = gesture.widget;
1504 var line_no = check_list_widget(colview, x,y);
1506 var item = colview.model.get_item(line_no);
1512 //GLib.debug("offset = %d y = %d", (int) voff, (int) in_y);
1513 var y = in_y + _this.EditProps.el.vadjustment.value;
1514 var child = this.el.get_first_child();
1515 //Gtk.Allocation alloc = { 0, 0, 0, 0 };
1517 var reading_header = true;
1519 var header_height = 0;
1522 while (child != null) {
1523 //GLib.debug("Got %s", child.get_type().name());
1524 if (reading_header) {
1527 if (child.get_type().name() != "GtkColumnListView") {
1528 h += child.get_height();
1529 child = child.get_next_sibling();
1532 // should be columnlistview
1533 child = child.get_first_child();
1534 GLib.debug("header height=%d", h);
1537 reading_header = false;
1541 if (child.get_type().name() != "GtkColumnViewRowWidget") {
1542 child = child.get_next_sibling();
1546 if (y < header_height) {
1551 var hh = child.get_height();
1552 //child.get_allocation(out alloc);
1553 //GLib.debug("got cell xy = %d,%d w,h= %d,%d", alloc.x, alloc.y, alloc.width, alloc.height);
1554 //GLib.debug("row %d y= %d %s", line_no, (int) (header_height + alloc.y),
1556 // child.visible ? "VIS" : "hidden");
1558 if (y > (header_height + real_y) && y <= (header_height + real_y + hh) ) {
1559 if (y > ( header_height + real_y + (hh * 0.8))) {
1561 } else if (y > ( header_height + real_y + (hh * 0.2))) {
1566 GLib.debug("getRowAt return : %d, %s", line_no, pos);
1571 if (real_y + hh > y) {
1575 child = child.get_next_sibling();
1581 public class Xcls_deletemenu : Object
1583 public Gtk.Popover el;
1584 private Xcls_LeftProps _this;
1590 public Xcls_deletemenu(Xcls_LeftProps _owner )
1593 _this.deletemenu = this;
1594 this.el = new Gtk.Popover();
1598 // set gobject values
1599 var child_1 = new Xcls_Box29( _this );
1600 this.el.child = child_1.el;
1603 // user defined functions
1605 public class Xcls_Box29 : Object
1608 private Xcls_LeftProps _this;
1614 public Xcls_Box29(Xcls_LeftProps _owner )
1617 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
1621 // set gobject values
1622 var child_1 = new Xcls_Button30( _this );
1624 this.el.append( child_1.el );
1627 // user defined functions
1629 public class Xcls_Button30 : Object
1631 public Gtk.Button el;
1632 private Xcls_LeftProps _this;
1638 public Xcls_Button30(Xcls_LeftProps _owner )
1641 this.el = new Gtk.Button();
1645 // set gobject values
1646 this.el.label = "Delete";
1649 this.el.clicked.connect( ( ) => {
1652 var n = (JsRender.NodeProp) _this.selmodel.el.selected_item;
1654 _this.deletemenu.el.hide();
1655 _this.node.remove_prop(n);
1659 // user defined functions
1664 public class Xcls_GestureClick31 : Object
1666 public Gtk.GestureClick el;
1667 private Xcls_LeftProps _this;
1673 public Xcls_GestureClick31(Xcls_LeftProps _owner )
1676 this.el = new Gtk.GestureClick();
1680 // set gobject values
1683 this.el.pressed.connect( (n_press, in_x, in_y) => {
1685 GLib.debug("Prssed %d", (int) this.el.get_current_button());
1687 var col = _this.view.getColAt(in_x, in_y);
1692 var row = _this.view.getRowAt(in_x, in_y, out pos);
1698 GLib.debug("hit row %d", row);
1699 var prop = _this.selmodel.getPropAt(row);
1700 _this.selmodel.selectProp(prop);
1702 //var point_at = _this.view.getWidgetAtRow(row);
1704 // need to shift down, as ev.y does not inclucde header apparently..
1705 // or popover might be trying to do a central?
1706 // _this.view.editPropertyDetails(prop, (int) in_y + 12);
1707 _this.stop_editor();
1708 _this.view.popover.show(
1718 // user defined functions
1721 public class Xcls_GestureClick32 : Object
1723 public Gtk.GestureClick el;
1724 private Xcls_LeftProps _this;
1730 public Xcls_GestureClick32(Xcls_LeftProps _owner )
1733 this.el = new Gtk.GestureClick();
1737 // set gobject values
1741 this.el.pressed.connect( (n_press, in_x, in_y) => {
1746 var row = _this.view.getRowAt(in_x, in_y, out pos);
1753 _this.stop_editor();
1754 GLib.debug("hit row %d", row);
1755 var prop = _this.selmodel.getPropAt(row);
1756 _this.selmodel.selectProp(prop);
1760 GLib.debug("Prssed %d", (int) this.el.get_current_button());
1761 //_this.deletemenu.el.set_parent(_this.view.el);
1762 if (_this.deletemenu.el.parent == null) {
1763 _this.deletemenu.el.set_parent(_this.main_window.el);
1768 _this.deletemenu.el.set_offset(
1769 (int)in_x - _this.view.el.get_width() ,
1770 (int)in_y - _this.view.el.get_height()
1772 _this.deletemenu.el.set_position(Gtk.PositionType.BOTTOM);
1773 _this.deletemenu.el.popup();
1778 // user defined functions
1781 public class Xcls_selmodel : Object
1783 public Gtk.SingleSelection el;
1784 private Xcls_LeftProps _this;
1790 public Xcls_selmodel(Xcls_LeftProps _owner )
1793 _this.selmodel = this;
1794 new Xcls_model( _this );
1795 this.el = new Gtk.SingleSelection( _this.model.el );
1799 // set gobject values
1800 this.el.can_unselect = true;
1803 // user defined functions
1804 public int propToRow (JsRender.NodeProp prop) {
1805 for (var i = 0 ; i < this.el.n_items; i++) {
1806 var r = (JsRender.NodeProp)this.el.get_item(i);
1807 if (r.equals(prop)) {
1815 public void startEditing (JsRender.NodeProp prop) {
1816 // should we call select?? - caller does int (from windowstate)
1819 public void selectProp (JsRender.NodeProp prop) {
1820 for (var i = 0 ; i < this.el.n_items; i++) {
1821 var r = (JsRender.NodeProp)this.el.get_item(i);
1822 if (r.equals(prop)) {
1823 this.el.selected = i;
1829 public JsRender.NodeProp getPropAt (uint row) {
1831 return (JsRender.NodeProp) this.el.get_item(row);
1836 public class Xcls_model : Object
1838 public GLib.ListStore el;
1839 private Xcls_LeftProps _this;
1845 public Xcls_model(Xcls_LeftProps _owner )
1849 this.el = new GLib.ListStore(typeof(JsRender.NodeProp));
1853 // set gobject values
1856 // user defined functions
1860 public class Xcls_keycol : Object
1862 public Gtk.ColumnViewColumn el;
1863 private Xcls_LeftProps _this;
1869 public Xcls_keycol(Xcls_LeftProps _owner )
1872 _this.keycol = this;
1873 var child_1 = new Xcls_SignalListItemFactory36( _this );
1875 this.el = new Gtk.ColumnViewColumn( "Property", child_1.el );
1879 // set gobject values
1880 this.el.id = "keycol";
1881 this.el.expand = true;
1882 this.el.resizable = true;
1885 // user defined functions
1887 public class Xcls_SignalListItemFactory36 : Object
1889 public Gtk.SignalListItemFactory el;
1890 private Xcls_LeftProps _this;
1896 public Xcls_SignalListItemFactory36(Xcls_LeftProps _owner )
1899 this.el = new Gtk.SignalListItemFactory();
1903 // set gobject values
1906 this.el.setup.connect( (listitem) => {
1907 var lbl = new Gtk.Label("");
1908 ((Gtk.ListItem)listitem).set_child(lbl);
1909 lbl.justify = Gtk.Justification.LEFT;
1911 lbl.use_markup = true;
1912 lbl.ellipsize = Pango.EllipsizeMode.START;
1913 /*lbl.changed.connect(() => {
1914 // notify and save the changed value...
1915 //var prop = (JsRender.NodeProp) ((Gtk.ListItem)listitem.get_item());
1917 //prop.val = lbl.text;
1918 //_this.updateIter(iter,prop);
1922 ((Gtk.ListItem)listitem).activatable = true;
1924 this.el.bind.connect( (listitem) => {
1925 var lb = (Gtk.Label) ((Gtk.ListItem)listitem).get_child();
1926 var item = (JsRender.NodeProp) ((Gtk.ListItem)listitem).get_item();
1929 item.bind_property("to_display_name_prop",
1931 GLib.BindingFlags.SYNC_CREATE);
1932 item.bind_property("to_tooltip_name_prop",
1933 lb, "tooltip_markup",
1934 GLib.BindingFlags.SYNC_CREATE);
1935 // was item (1) in old layout
1941 // user defined functions
1945 public class Xcls_valcol : Object
1947 public Gtk.ColumnViewColumn el;
1948 private Xcls_LeftProps _this;
1954 public Xcls_valcol(Xcls_LeftProps _owner )
1957 _this.valcol = this;
1958 var child_1 = new Xcls_SignalListItemFactory38( _this );
1960 this.el = new Gtk.ColumnViewColumn( "Value", child_1.el );
1964 // set gobject values
1965 this.el.id = "valcol";
1966 this.el.expand = true;
1967 this.el.resizable = true;
1970 // user defined functions
1972 public class Xcls_SignalListItemFactory38 : Object
1974 public Gtk.SignalListItemFactory el;
1975 private Xcls_LeftProps _this;
1979 public bool is_setting;
1982 public Xcls_SignalListItemFactory38(Xcls_LeftProps _owner )
1985 this.el = new Gtk.SignalListItemFactory();
1988 this.is_setting = false;
1990 // set gobject values
1993 this.el.setup.connect( (listitem) => {
1994 var hb = new Gtk.Box(Gtk.Orientation.HORIZONTAL,0);
1995 var elbl = new Gtk.EditableLabel("");
1996 elbl.hexpand = true;
1998 var lbl = new Gtk.Label("");
2001 lbl.use_markup = true;
2003 lbl.ellipsize = Pango.EllipsizeMode.END;
2004 var cb = new Gtk.DropDown(new Gtk.StringList({}), null);
2008 ((Gtk.ListItem)listitem).set_child(hb);
2010 var ef = new Gtk.EventControllerFocus();
2011 ef.enter.connect(() => {
2012 _this.stop_editor();
2013 var prop = (JsRender.NodeProp)((Gtk.ListItem)listitem).get_item();
2014 _this.selmodel.selectProp(prop);
2016 elbl.add_controller(ef);
2019 // dropdown??? - stop editing, and highliht node
2020 var tb = (Gtk.ToggleButton) cb.get_first_child();
2021 tb.clicked.connect(() => {
2022 var prop = (JsRender.NodeProp)((Gtk.ListItem)listitem).get_item();
2024 _this.stop_editor();
2025 _this.selmodel.selectProp(prop);
2028 elbl.changed.connect(() => {
2029 // notify and save the changed value...
2031 //_this.updateIter(iter,prop);
2032 // this should happen automatically
2034 if (!_this.loading && !this.is_setting) {
2035 var prop = (JsRender.NodeProp)((Gtk.ListItem)listitem).get_item();
2038 prop.val = elbl.text;
2039 GLib.debug("calling changed");
2047 cb.notify["selected"].connect(() => {
2048 // dropdown selection changed.
2052 //_this.updateIter(iter,prop);
2053 if (!_this.loading && !this.is_setting) {
2054 var prop = (JsRender.NodeProp)((Gtk.ListItem)listitem).get_item();
2055 var model = (Gtk.StringList)cb.model;
2056 prop.val = model.get_string(cb.selected);
2057 GLib.debug("property set to %s", prop.val);
2058 GLib.debug("calling changed");
2065 var gc = new Gtk.GestureClick();
2066 lbl.add_controller(gc);
2067 gc.pressed.connect(() => {
2068 var prop = (JsRender.NodeProp)((Gtk.ListItem)listitem).get_item();
2069 _this.stop_editor();
2070 _this.show_editor(_this.file, prop.parent, prop);
2076 this.el.bind.connect( (listitem) => {
2077 this.is_setting = true;
2080 var bx = (Gtk.Box) ((Gtk.ListItem)listitem).get_child();
2085 var elbl = (Gtk.EditableLabel)bx.get_first_child();
2086 var lbl = (Gtk.Label) elbl.get_next_sibling();
2087 var cb = (Gtk.DropDown) lbl.get_next_sibling();
2088 // decide if it's a combo or editable text..
2089 var model = (Gtk.StringList) cb.model;
2095 var prop = (JsRender.NodeProp) ((Gtk.ListItem)listitem).get_item();
2096 //GLib.debug("prop = %s", prop.get_type().name());
2097 //GLib.debug("prop.val = %s", prop.val);
2098 //GLib.debug("prop.key = %s", prop.to_display_name());
2100 var use_textarea = prop.useTextArea();
2103 var pal = _this.file.project.palete;
2106 var has_opts = pal.typeOptions(_this.node.fqn(), prop.name, prop.rtype, out opts);
2108 if (!has_opts && prop.ptype == JsRender.NodePropType.RAW) {
2109 use_textarea = true;
2114 prop.bind_property("val_short",
2116 GLib.BindingFlags.SYNC_CREATE);
2117 prop.bind_property("val_tooltip",
2118 lbl, "tooltip_markup",
2119 GLib.BindingFlags.SYNC_CREATE);
2121 this.is_setting = false;
2130 // others... - fill in options for true/false?
2131 // GLib.debug (ktype.up());
2134 while(model.get_n_items() > 0) {
2138 // can not remove - hopefully always empty.
2140 for(var i = 0; i < opts.length; i ++) {
2141 model.append( opts[i]);
2142 // not sure this is a great idea...
2143 if (opts[i].down() == prop.val.down()) {
2147 GLib.debug("Set selected item to %d", sel);
2148 cb.set_selected(sel > -1 ? sel : Gtk.INVALID_LIST_POSITION);
2149 this.is_setting = false;
2153 // see if type is a Enum.
2154 // triggers a changed event
2156 elbl.set_text(prop.val);
2159 this.is_setting = false;
2168 // user defined functions
2172 public class Xcls_ContextMenu : Object
2174 public Gtk.Popover el;
2175 private Xcls_LeftProps _this;
2181 public Xcls_ContextMenu(Xcls_LeftProps _owner )
2184 _this.ContextMenu = this;
2185 this.el = new Gtk.Popover();
2189 // set gobject values
2190 var child_1 = new Xcls_Box40( _this );
2191 this.el.child = child_1.el;
2194 // user defined functions
2196 public class Xcls_Box40 : Object
2199 private Xcls_LeftProps _this;
2205 public Xcls_Box40(Xcls_LeftProps _owner )
2208 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
2212 // set gobject values
2213 var child_1 = new Xcls_Button41( _this );
2215 this.el.append( child_1.el );
2218 // user defined functions
2220 public class Xcls_Button41 : Object
2222 public Gtk.Button el;
2223 private Xcls_LeftProps _this;
2229 public Xcls_Button41(Xcls_LeftProps _owner )
2232 this.el = new Gtk.Button();
2236 // set gobject values
2237 this.el.label = "Delete";
2240 this.el.activate.connect( ( ) =>{
2241 _this.deleteSelected();
2246 // user defined functions