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_model model;
19 public Xcls_keycol keycol;
20 public Xcls_keyrender keyrender;
21 public Xcls_valcol valcol;
22 public Xcls_valrender valrender;
23 public Xcls_valrendermodel valrendermodel;
24 public Xcls_ContextMenu ContextMenu;
27 public bool allow_edit;
28 public JsRender.JsRender file;
29 public signal bool stop_editor ();
30 public signal void show_editor (JsRender.JsRender file, JsRender.Node node, string type, string key);
31 public signal void changed ();
32 public signal void show_add_props (string type);
33 public Xcls_MainWindow main_window;
34 public JsRender.Node node;
37 public Xcls_LeftProps()
40 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
43 this.allow_edit = false;
44 this.main_window = null;
47 this.el.homogeneous = false ;
48 var child_0 = new Xcls_Box2( _this );
50 this.el.pack_start ( child_0.el , false,true,0 );
51 var child_1 = new Xcls_EditProps( _this );
53 this.el.pack_end ( child_1.el , true,true,0 );
56 // user defined functions
57 public void updateKey (string oldkey, string type, string key ) {
61 _this.model.el.foreach((mod, path, iter) => {
66 GLib.Value gvaltype, gval,kvalue;
67 mod.get_value(iter, 1 , out gval); // one is key..
69 mod.get_value(iter,0, out gvaltype);
71 mod.get_value(iter,3, out kvalue);
73 if (oldkey == ((string)gval) && type == ((string)gvaltype)) {
75 //print("update iter type=%s, key=%s value=%s\n", type, key,(string) kvalue);
77 this.updateIter(iter, type, key, (string)kvalue);
89 public void before_edit ()
92 GLib.debug("before edit - stop editing\n");
94 // these do not appear to trigger save...
95 _this.keyrender.el.stop_editing(false);
96 _this.keyrender.el.editable =false;
98 _this.valrender.el.stop_editing(false);
99 _this.valrender.el.editable =false;
102 // technicall stop the popup editor..
105 public string keySortFormat (string key) {
106 // listeners first - with 0
113 var bits = key.split(" ");
116 return "2 " + bits[bits.length -1];
120 return "3 " + bits[bits.length -1];
125 return "4 " + bits[bits.length -1];
128 return "5 " + bits[bits.length -1];
133 public void finish_editing () {
137 public bool startEditingValue ( Gtk.TreePath path) {
139 // ONLY return true if editing is allowed - eg. combo..
141 GLib.debug("start editing?\n");
142 if (!this.stop_editor()) {
143 GLib.debug("stop editor failed\n");
149 var mod = this.model.el;
150 mod.get_iter (out iter, path);
156 2, "<b>" + miter.get_key() + "</b>",
162 mod.get_value(iter, 3 , out gval);
163 var val = (string)gval;
165 mod.get_value(iter, 1 , out gval);
166 var key = (string)gval;
169 string kname, kflag, ktype;
170 this.node.normalize_key(key, out kname, out kflag, out ktype);
173 mod.get_value(iter, 0 , out gval);
174 var type = (string)gval; // listerner or prop..
178 var use_textarea = false;
180 //------------ things that require the text editor...
182 if (type == "listener") {
185 if (key.length > 0 && key[0] == '|') { // user defined method
188 if (key.length > 0 && key[0] == '$') { // raw string
191 if (key.length > 0 && key == "* init") {
194 if (val.length > 40) { // long value...
201 GLib.debug("Call show editor\n");
202 GLib.Timeout.add_full(GLib.Priority.DEFAULT,10 , () => {
203 this.view.el.get_selection().select_path(path);
205 this.show_editor(file, node, type, key);
214 var pal = this.file.project.palete;
217 var has_opts = pal.typeOptions(this.node.fqn(), kname, ktype, out opts);
221 // others... - fill in options for true/false?
222 GLib.debug("turn on editing %s \n" , mod.get_path(iter).to_string());
224 GLib.debug (ktype.up());
226 GLib.debug("start editing try/false)???");
227 this.valrender.el.has_entry = false;
229 this.valrender.setOptions(opts);
231 this.valrender.el.has_entry = false;
232 this.valrender.el.editable = true;
233 this.allow_edit = true;
234 GLib.Timeout.add_full(GLib.Priority.DEFAULT,100 , () => {
235 this.view.el.set_cursor_on_cell(
246 // see if type is a Enum.
253 this.valrender.setOptions(opts);
255 GLib.Timeout.add_full(GLib.Priority.DEFAULT,10 , () => {
257 // at this point - work out the type...
258 // if its' a combo... then show the options..
259 this.valrender.el.has_entry = true;
261 this.valrender.el.editable = true;
264 this.allow_edit = true;
270 this.view.el.set_cursor_on_cell(
280 public void load (JsRender.JsRender file, JsRender.Node? node)
282 GLib.debug("load leftprops\n");
288 this.model.el.clear();
290 //this.get('/RightEditor').el.hide();
297 //var provider = this.get('/LeftTree').getPaleteProvider();
300 //typeof(string), // 0 key type
301 //typeof(string), // 1 key
302 //typeof(string), // 2 key (display)
303 //typeof(string), // 3 value
304 //typeof(string), // 4 value (display)
305 //typeof(string), // 5 both (tooltip)
309 // really need a way to sort the hashmap...
310 var m = this.model.el;
312 var miter = node.listeners.map_iterator();
315 while(miter.next()) {
317 m.append(out iter,null);
319 this.updateIter(iter, "listener", miter.get_key(), miter.get_value());
325 miter = node.props.map_iterator();
328 while(miter.next()) {
330 m.append(out iter,null);
331 this.updateIter(iter, "prop", miter.get_key(), miter.get_value());
334 GLib.debug("clear selection\n");
336 this.model.el.set_sort_column_id(6,Gtk.SortType.ASCENDING); // sort by real key..
338 this.view.el.get_selection().unselect_all();
340 var pane = _this.main_window.editpane.el;
341 var try_size = (i * 25) + 60; // est. 20px per line + 40px header
342 GLib.Timeout.add_seconds(1, () => {
345 ((try_size * 1.0f) / (pane.max_position * 1.0f)) > 0.8f ?
346 (int) (pane.max_position * 0.2f) :
347 pane.max_position-try_size);
348 return GLib.Source.REMOVE;
352 public string keyFormat (string val, string type) {
354 // Glib.markup_escape_text(val);
356 if (type == "listener") {
357 return "<span font_weight=\"bold\" color=\"#660000\">" +
358 GLib.Markup.escape_text(val) +
362 if (val.length < 1) {
363 return "<span color=\"#FF0000\">--empty--</span>";
368 //# - object properties
370 // all of these... - display value is last element..
371 var ar = val.strip().split(" ");
374 var dval = GLib.Markup.escape_text(ar[ar.length-1]);
380 case '@': // signal // just bold balck?
381 if (dval[0] == '@') {
382 dval = dval.substring(1);
385 return @"<span font_weight=\"bold\">@ $dval</span>";
386 case '#': // object properties?
387 if (dval[0] == '#') {
388 dval = dval.substring(1);
390 return @"<span font_weight=\"bold\">$dval</span>";
392 if (dval[0] == '*') {
393 dval = dval.substring(1);
395 return @"<span color=\"#0000CC\" font_weight=\"bold\">$dval</span>";
397 if (dval[0] == '$') {
398 dval = dval.substring(1);
400 return @"<span style=\"italic\">$dval</span>";
401 case '|': // user defined methods
402 if (dval[0] == '|') {
403 dval = dval.substring(1);
405 return @"<span color=\"#008000\" font_weight=\"bold\">$dval</span>";
416 public void deleteSelected () {
421 var s = this.view.el.get_selection();
422 s.get_selected(out mod, out iter);
426 mod.get_value(iter, 0 , out gval);
427 var type = (string)gval;
429 mod.get_value(iter, 1 , out gval);
430 var key = (string)gval;
434 this.node.listeners.unset(key);
438 this.node.props.unset(key);
441 this.load(this.file, this.node);
445 public void startEditingKey ( Gtk.TreePath path) {
447 if (!this.stop_editor()) {
451 // others... - fill in options for true/false?
454 GLib.Timeout.add_full(GLib.Priority.DEFAULT,10 , () => {
455 this.allow_edit = true;
456 this.keyrender.el.editable = true;
458 this.view.el.set_cursor_on_cell(
470 public void addProp (string in_type, string key, string value, string value_type) {
471 // info includes key, val, skel, etype..
472 //console.dump(info);
473 //type = info.type.toLowerCase();
474 //var data = this.toJS();
476 var type = in_type == "signals" ? "listener" : in_type;
478 var fkey = (value_type.length > 0 ? value_type + " " : "") + key;
480 if (type == "listener") {
481 if (this.node.listeners.has_key(key)) {
484 this.node.listeners.set(key,value);
486 assert(this.node != null);
487 assert(this.node.props != null);
488 if (this.node.props.has_key(fkey)) {
491 this.node.props.set(fkey,value);
496 this.load(this.file, this.node);
500 /// need to find the row which I've just added..
503 var s = this.view.el.get_selection();
506 GLib.debug("trying to find new iter");
508 this.model.el.foreach((model, path, iter) => {
511 this.model.el.get_value(iter, 0 , out gval);
512 if ((string)gval != type) {
513 GLib.debug("not type: %s = %s\n", (string)gval , type);
516 this.model.el.get_value(iter, 1 , out gval);
517 if ((string)gval != fkey) {
518 GLib.debug("not key: %s = %s\n", (string)gval , fkey);
522 GLib.Timeout.add_full(GLib.Priority.DEFAULT,40 , () => {
524 this.startEditingValue(this.model.el.get_path(iter));
527 //s.select_iter(iter);
535 public void updateIter (Gtk.TreeIter iter, string type, string key, string kvalue) {
537 //print("update Iter %s, %s\n", key,kvalue);
538 //typeof(string), // 0 key type
539 //typeof(string), // 1 key
540 //typeof(string), // 2 key (display)
541 //typeof(string), // 3 value
542 //typeof(string), // 4 value (display)
543 //typeof(string), // 5 both (tooltip)
544 //typeof(string), // 6 key (sort)
546 var dl = kvalue.strip().split("\n");
548 var dis_val = dl.length > 1 ? (dl[0].strip()+ "...") : dl[0];
550 if (type == "listener") {
554 this.model.el.set(iter,
557 2, this.keyFormat(key ,type),
560 5, "<tt>" + GLib.Markup.escape_text(key + " " +kvalue) + "</tt>",
568 this.model.el.set(iter,
571 2, this.keyFormat(key , "prop"),
574 5, "<tt>" + GLib.Markup.escape_text(key + " " + kvalue) + "</tt>",
575 6, this.keySortFormat(key)
578 public class Xcls_Box2 : Object
581 private Xcls_LeftProps _this;
587 public Xcls_Box2(Xcls_LeftProps _owner )
590 this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
594 // set gobject values
595 var child_0 = new Xcls_Button3( _this );
597 this.el.add ( child_0.el );
600 // user defined functions
602 public class Xcls_Button3 : Object
604 public Gtk.Button el;
605 private Xcls_LeftProps _this;
611 public Xcls_Button3(Xcls_LeftProps _owner )
614 this.el = new Gtk.Button();
618 // set gobject values
619 this.el.hexpand = true;
620 var child_0 = new Xcls_Box4( _this );
622 this.el.add ( child_0.el );
623 var child_1 = new Xcls_AddPropertyPopup( _this );
627 this.el.button_press_event.connect( (self, ev) => {
631 var p = _this.AddPropertyPopup;
632 p.el.set_screen(Gdk.Screen.get_default());
634 p.el.popup(null, null, null, ev.button, ev.time);
639 // user defined functions
641 public class Xcls_Box4 : Object
644 private Xcls_LeftProps _this;
650 public Xcls_Box4(Xcls_LeftProps _owner )
653 this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
657 // set gobject values
658 var child_0 = new Xcls_Image5( _this );
660 this.el.add ( child_0.el );
661 var child_1 = new Xcls_Label6( _this );
663 this.el.add ( child_1.el );
666 // user defined functions
668 public class Xcls_Image5 : Object
671 private Xcls_LeftProps _this;
677 public Xcls_Image5(Xcls_LeftProps _owner )
680 this.el = new Gtk.Image();
684 // set gobject values
685 this.el.stock = Gtk.Stock.ADD;
686 this.el.icon_size = Gtk.IconSize.MENU;
689 // user defined functions
692 public class Xcls_Label6 : Object
695 private Xcls_LeftProps _this;
701 public Xcls_Label6(Xcls_LeftProps _owner )
704 this.el = new Gtk.Label( "Other" );
708 // set gobject values
711 // user defined functions
715 public class Xcls_AddPropertyPopup : Object
718 private Xcls_LeftProps _this;
724 public Xcls_AddPropertyPopup(Xcls_LeftProps _owner )
727 _this.AddPropertyPopup = this;
728 this.el = new Gtk.Menu();
732 // set gobject values
733 var child_0 = new Xcls_MenuItem8( _this );
735 this.el.append ( child_0.el );
736 var child_1 = new Xcls_MenuItem9( _this );
738 this.el.append ( child_1.el );
739 var child_2 = new Xcls_MenuItem10( _this );
741 this.el.append ( child_2.el );
742 var child_3 = new Xcls_MenuItem11( _this );
744 this.el.append ( child_3.el );
745 var child_4 = new Xcls_MenuItem12( _this );
747 this.el.append ( child_4.el );
748 var child_5 = new Xcls_SeparatorMenuItem13( _this );
750 this.el.add ( child_5.el );
751 var child_6 = new Xcls_MenuItem14( _this );
753 this.el.append ( child_6.el );
754 var child_7 = new Xcls_MenuItem15( _this );
756 this.el.append ( child_7.el );
757 var child_8 = new Xcls_MenuItem16( _this );
759 this.el.append ( child_8.el );
760 var child_9 = new Xcls_SeparatorMenuItem17( _this );
762 this.el.add ( child_9.el );
763 var child_10 = new Xcls_MenuItem18( _this );
765 this.el.append ( child_10.el );
766 var child_11 = new Xcls_MenuItem19( _this );
768 this.el.append ( child_11.el );
769 var child_12 = new Xcls_MenuItem20( _this );
771 this.el.append ( child_12.el );
772 var child_13 = new Xcls_SeparatorMenuItem21( _this );
774 this.el.add ( child_13.el );
775 var child_14 = new Xcls_MenuItem22( _this );
777 this.el.append ( child_14.el );
778 var child_15 = new Xcls_MenuItem23( _this );
780 this.el.append ( child_15.el );
781 var child_16 = new Xcls_MenuItem24( _this );
783 this.el.append ( child_16.el );
786 // user defined functions
788 public class Xcls_MenuItem8 : Object
790 public Gtk.MenuItem el;
791 private Xcls_LeftProps _this;
797 public Xcls_MenuItem8(Xcls_LeftProps _owner )
800 this.el = new Gtk.MenuItem();
804 // set gobject values
805 this.el.tooltip_markup = "Using _this.{ID} will map to this element";
806 this.el.label = "id: _this.{ID} (Vala)";
809 this.el.activate.connect( () => {
810 _this.addProp( "prop", "id", "", "");
814 // user defined functions
817 public class Xcls_MenuItem9 : Object
819 public Gtk.MenuItem el;
820 private Xcls_LeftProps _this;
826 public Xcls_MenuItem9(Xcls_LeftProps _owner )
829 this.el = new Gtk.MenuItem();
833 // set gobject values
834 this.el.tooltip_markup = "how to pack this element onto parent, (method, 2nd arg, 3rd arg) .. the 1st argument is filled by the element";
835 this.el.label = "pack: Pack method (Vala)";
838 this.el.activate.connect( ( ) => {
840 _this.addProp( "prop", "pack","add", "*");
844 // user defined functions
847 public class Xcls_MenuItem10 : Object
849 public Gtk.MenuItem el;
850 private Xcls_LeftProps _this;
856 public Xcls_MenuItem10(Xcls_LeftProps _owner )
859 this.el = new Gtk.MenuItem();
863 // set gobject values
864 this.el.tooltip_markup = "eg. \n\nnew Clutter.Image.from_file(.....)";
865 this.el.label = "ctor: Alterative to default contructor (Vala)";
868 this.el.activate.connect( ( ) => {
870 _this.addProp( "prop", "ctor","", "*");
874 // user defined functions
877 public class Xcls_MenuItem11 : Object
879 public Gtk.MenuItem el;
880 private Xcls_LeftProps _this;
886 public Xcls_MenuItem11(Xcls_LeftProps _owner )
889 this.el = new Gtk.MenuItem();
893 // set gobject values
894 this.el.tooltip_markup = "This code is called after the ctor";
895 this.el.label = "init: initialziation code (vala)";
898 this.el.activate.connect( ( ) => {
900 _this.addProp( "prop", "init", "{\n\n}\n", "*" );
904 // user defined functions
907 public class Xcls_MenuItem12 : Object
909 public Gtk.MenuItem el;
910 private Xcls_LeftProps _this;
916 public Xcls_MenuItem12(Xcls_LeftProps _owner )
919 this.el = new Gtk.MenuItem();
923 // set gobject values
924 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";
925 this.el.label = "cms-id: (Roo JS/Pman library)";
928 this.el.activate.connect( () => {
929 _this.addProp( "prop", "cms-id", "", "string");
933 // user defined functions
936 public class Xcls_SeparatorMenuItem13 : Object
938 public Gtk.SeparatorMenuItem el;
939 private Xcls_LeftProps _this;
945 public Xcls_SeparatorMenuItem13(Xcls_LeftProps _owner )
948 this.el = new Gtk.SeparatorMenuItem();
952 // set gobject values
955 // user defined functions
958 public class Xcls_MenuItem14 : Object
960 public Gtk.MenuItem el;
961 private Xcls_LeftProps _this;
967 public Xcls_MenuItem14(Xcls_LeftProps _owner )
970 this.el = new Gtk.MenuItem();
974 // set gobject values
975 this.el.tooltip_markup = "Add a user defined string property";
976 this.el.label = "String";
979 this.el.activate.connect( (self) => {
981 _this.addProp( "prop", "XXXX", "","string");
986 // user defined functions
989 public class Xcls_MenuItem15 : Object
991 public Gtk.MenuItem el;
992 private Xcls_LeftProps _this;
998 public Xcls_MenuItem15(Xcls_LeftProps _owner )
1001 this.el = new Gtk.MenuItem();
1005 // set gobject values
1006 this.el.tooltip_markup = "Add a user defined number property";
1007 this.el.label = "Number";
1010 this.el.activate.connect( ( ) =>{
1012 _this.addProp("prop", "XXX", "0", "int");
1016 // user defined functions
1019 public class Xcls_MenuItem16 : Object
1021 public Gtk.MenuItem el;
1022 private Xcls_LeftProps _this;
1028 public Xcls_MenuItem16(Xcls_LeftProps _owner )
1031 this.el = new Gtk.MenuItem();
1035 // set gobject values
1036 this.el.tooltip_markup = "Add a user defined boolean property";
1037 this.el.label = "Boolean";
1040 this.el.activate.connect( ( ) =>{
1042 _this.addProp( "prop", "XXX", "true", "bool");
1046 // user defined functions
1049 public class Xcls_SeparatorMenuItem17 : Object
1051 public Gtk.SeparatorMenuItem el;
1052 private Xcls_LeftProps _this;
1058 public Xcls_SeparatorMenuItem17(Xcls_LeftProps _owner )
1061 this.el = new Gtk.SeparatorMenuItem();
1065 // set gobject values
1068 // user defined functions
1071 public class Xcls_MenuItem18 : Object
1073 public Gtk.MenuItem el;
1074 private Xcls_LeftProps _this;
1080 public Xcls_MenuItem18(Xcls_LeftProps _owner )
1083 this.el = new Gtk.MenuItem();
1087 // set gobject values
1088 this.el.tooltip_markup = "Add a user function boolean property";
1089 this.el.label = "Javascript Function";
1092 this.el.activate.connect( ( ) =>{
1094 _this.addProp("prop", "XXXX", "function() { }", "| function");
1098 // user defined functions
1101 public class Xcls_MenuItem19 : Object
1103 public Gtk.MenuItem el;
1104 private Xcls_LeftProps _this;
1110 public Xcls_MenuItem19(Xcls_LeftProps _owner )
1113 this.el = new Gtk.MenuItem();
1117 // set gobject values
1118 this.el.tooltip_markup = "Add a user function boolean property";
1119 this.el.label = "Vala Method";
1122 this.el.activate.connect( ( ) =>{
1124 _this.addProp( "prop", "XXXX", "() {\n\n}\n", "| return_type");
1128 // user defined functions
1131 public class Xcls_MenuItem20 : Object
1133 public Gtk.MenuItem el;
1134 private Xcls_LeftProps _this;
1140 public Xcls_MenuItem20(Xcls_LeftProps _owner )
1143 this.el = new Gtk.MenuItem();
1147 // set gobject values
1148 this.el.tooltip_markup = "Add a vala signal";
1149 this.el.label = "Vala Signal";
1152 this.el.activate.connect( ( ) =>{
1154 _this.addProp( "prop", "XXXX", "()", "@ void");
1158 // user defined functions
1161 public class Xcls_SeparatorMenuItem21 : Object
1163 public Gtk.SeparatorMenuItem el;
1164 private Xcls_LeftProps _this;
1170 public Xcls_SeparatorMenuItem21(Xcls_LeftProps _owner )
1173 this.el = new Gtk.SeparatorMenuItem();
1177 // set gobject values
1180 // user defined functions
1183 public class Xcls_MenuItem22 : Object
1185 public Gtk.MenuItem el;
1186 private Xcls_LeftProps _this;
1192 public Xcls_MenuItem22(Xcls_LeftProps _owner )
1195 this.el = new Gtk.MenuItem();
1199 // set gobject values
1200 this.el.tooltip_markup = "Add a flexy if (for HTML templates)";
1201 this.el.label = "Flexy - If";
1204 this.el.activate.connect( ( ) =>{
1206 _this.addProp("prop", "flexy:if", "value_or_condition", "string");
1210 // user defined functions
1213 public class Xcls_MenuItem23 : Object
1215 public Gtk.MenuItem el;
1216 private Xcls_LeftProps _this;
1222 public Xcls_MenuItem23(Xcls_LeftProps _owner )
1225 this.el = new Gtk.MenuItem();
1229 // set gobject values
1230 this.el.tooltip_markup = "Add a flexy include (for HTML templates)";
1231 this.el.label = "Flexy - Include";
1234 this.el.activate.connect( ( ) =>{
1236 _this.addProp("prop", "flexy:include", "name_of_file.html", "string");
1240 // user defined functions
1243 public class Xcls_MenuItem24 : Object
1245 public Gtk.MenuItem el;
1246 private Xcls_LeftProps _this;
1252 public Xcls_MenuItem24(Xcls_LeftProps _owner )
1255 this.el = new Gtk.MenuItem();
1259 // set gobject values
1260 this.el.tooltip_markup = "Add a flexy foreach (for HTML templates)";
1261 this.el.label = "Flexy - Foreach";
1264 this.el.activate.connect( ( ) =>{
1266 _this.addProp("prop", "flexy:foreach", "array,key,value", "string");
1270 // user defined functions
1276 public class Xcls_EditProps : Object
1278 public Gtk.ScrolledWindow el;
1279 private Xcls_LeftProps _this;
1283 public bool editing;
1286 public Xcls_EditProps(Xcls_LeftProps _owner )
1289 _this.EditProps = this;
1290 this.el = new Gtk.ScrolledWindow( null, null );
1293 this.editing = false;
1295 // set gobject values
1296 this.el.shadow_type = Gtk.ShadowType.IN;
1297 var child_0 = new Xcls_view( _this );
1299 this.el.add ( child_0.el );
1305 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
1309 // user defined functions
1311 public class Xcls_view : Object
1313 public Gtk.TreeView el;
1314 private Xcls_LeftProps _this;
1318 public Xcls_PopoverProperty popover;
1321 public Xcls_view(Xcls_LeftProps _owner )
1325 this.el = new Gtk.TreeView();
1328 this.popover = null;
1330 // set gobject values
1331 this.el.tooltip_column = 5;
1332 this.el.enable_tree_lines = true;
1333 this.el.headers_visible = true;
1334 var child_0 = new Xcls_model( _this );
1336 this.el.set_model ( child_0.el );
1337 var child_1 = new Xcls_keycol( _this );
1339 this.el.append_column ( child_1.el );
1340 var child_2 = new Xcls_valcol( _this );
1342 this.el.append_column ( child_2.el );
1343 var child_3 = new Xcls_ContextMenu( _this );
1349 var selection = this.el.get_selection();
1350 selection.set_mode( Gtk.SelectionMode.SINGLE);
1353 var description = new Pango.FontDescription();
1354 description.set_size(10000);
1355 this.el.override_font(description);
1359 this.el.button_press_event.connect( ( ev) => {
1361 Gtk.TreeViewColumn col;
1365 if (!this.el.get_path_at_pos((int)ev.x, (int) ev.y, out path, out col, out cell_x, out cell_y )) {
1366 GLib.debug("nothing selected on click");
1367 GLib.Timeout.add_full(GLib.Priority.DEFAULT,10 , () => {
1368 this.el.get_selection().unselect_all();
1372 _this.before_edit();
1373 return false; //not on a element.
1377 // double click on name..
1378 if (ev.type == Gdk.EventType.2BUTTON_PRESS && ev.button == 1 && col.title == "Name") {
1381 if (this.popover == null) {
1382 this.popover = new Xcls_PopoverProperty();
1383 this.popover.mainwindow = _this.main_window;
1387 _this.before_edit();
1388 _this.stop_editor();
1390 _this.keyrender.el.stop_editing(false);
1391 _this.keyrender.el.editable =false;
1393 _this.valrender.el.stop_editing(false);
1394 _this.valrender.el.editable =false;
1396 var mod = this.el.get_model();
1397 mod.get_iter (out iter, path);
1400 GLib.Value gvaltype, gval;
1401 mod.get_value(iter, 1 , out gval); // one is key..
1403 mod.get_value(iter,0, out gvaltype);
1405 this.popover.show(this.el, _this.node, (string)gvaltype, (string)gval);
1407 // _this.startEditingKey(path);
1416 if (ev.type == Gdk.EventType.BUTTON_PRESS && ev.button == 3) {
1418 //if (col.title == "Value") {
1419 // _this.before_edit();
1423 var p = _this.ContextMenu;
1425 p.el.set_screen(Gdk.Screen.get_default());
1427 p.el.popup(null, null, null, ev.button, ev.time);
1428 //Seed.print("click:" + res.column.title);
1430 GLib.Timeout.add_full(GLib.Priority.DEFAULT,10 , () => {
1432 this.el.get_selection().select_path(path);
1435 _this.before_edit();
1440 if (col.title != "Value") {
1441 GLib.debug("col title != Value");
1443 GLib.Timeout.add_full(GLib.Priority.DEFAULT,10 , () => {
1444 this.el.get_selection().select_path(path);
1448 _this.before_edit();
1449 // XObject.error("column is not value?");
1450 return false; // ignore.. - key click.. ??? should we do this??
1454 // if the cell can be edited with a pulldown
1455 // then we should return true... - and let the start_editing handle it?
1462 // _this.before_edit(); <<< we really need to stop the other editor..
1463 _this.keyrender.el.stop_editing(false);
1464 _this.keyrender.el.editable =false;
1467 return _this.startEditingValue(path); // assumes selected row..
1476 // user defined functions
1478 public class Xcls_model : Object
1480 public Gtk.TreeStore el;
1481 private Xcls_LeftProps _this;
1487 public Xcls_model(Xcls_LeftProps _owner )
1491 this.el = new Gtk.TreeStore( 7, typeof(string), // 0 key type
1492 typeof(string), // 1 key
1493 typeof(string), // 2 key (display)
1494 typeof(string), // 3 value
1495 typeof(string), // 4 value (display)
1496 typeof(string), // 5 both (tooltip)
1497 typeof(string) // 6 key (for sorting)
1502 // set gobject values
1505 // user defined functions
1508 public class Xcls_keycol : Object
1510 public Gtk.TreeViewColumn el;
1511 private Xcls_LeftProps _this;
1517 public Xcls_keycol(Xcls_LeftProps _owner )
1520 _this.keycol = this;
1521 this.el = new Gtk.TreeViewColumn();
1525 // set gobject values
1526 this.el.title = "Name";
1527 this.el.resizable = true;
1528 var child_0 = new Xcls_keyrender( _this );
1530 this.el.pack_start ( child_0.el , false );
1534 this.el.add_attribute(_this.keyrender.el , "markup", 2 );
1535 this.el.add_attribute(_this.keyrender.el , "text", 1 );
1538 // user defined functions
1540 public class Xcls_keyrender : Object
1542 public Gtk.CellRendererText el;
1543 private Xcls_LeftProps _this;
1549 public Xcls_keyrender(Xcls_LeftProps _owner )
1552 _this.keyrender = this;
1553 this.el = new Gtk.CellRendererText();
1557 // set gobject values
1560 this.el.editing_started.connect( ( editable, path) => {
1563 _this.model.el.get_iter(out iter, new Gtk.TreePath.from_string(path));
1568 // this.get('/LeftPanel.model').activePath = path;
1569 _this.model.el.get_value(iter,1, out gval);
1570 var val = (string)gval;
1572 ((Gtk.Entry)editable).set_text(val);
1574 this.el.edited.connect( (path, newtext) => {
1575 GLib.debug("Keyrender - signal:edited\n");
1577 this.el.editable = false;
1582 _this.model.el.get_iter(out iter, new Gtk.TreePath.from_string(path));
1585 _this.model.el.get_value(iter,1, out gval);
1586 var oldval = (string)gval;
1588 _this.model.el.get_value(iter,0, out gval);
1589 var ktype = (string)gval;
1591 _this.model.el.set_value(iter, 1, newtext);
1593 if (oldval == newtext) {
1598 GLib.debug("ktype: %s\n",ktype);
1601 var ov = _this.node.listeners.get(oldval);
1602 _this.node.listeners.set(newtext, ov);
1603 _this.node.listeners.unset(oldval);
1605 _this.updateIter(iter, ktype, newtext, ov);
1609 var ov = _this.node.props.get(oldval);
1610 _this.node.props.set(newtext, ov);
1611 _this.node.props.unset(oldval);
1612 _this.updateIter(iter, ktype, newtext, ov);
1620 // user defined functions
1624 public class Xcls_valcol : Object
1626 public Gtk.TreeViewColumn el;
1627 private Xcls_LeftProps _this;
1633 public Xcls_valcol(Xcls_LeftProps _owner )
1636 _this.valcol = this;
1637 this.el = new Gtk.TreeViewColumn();
1641 // set gobject values
1642 this.el.title = "Value";
1643 this.el.resizable = true;
1644 var child_0 = new Xcls_valrender( _this );
1646 this.el.pack_start ( child_0.el , true );
1652 // typeof(string), // 0 key type
1653 // typeof(string), // 1 key
1654 // typeof(string), // 2 key (display)
1655 // typeof(string), // 3 value
1656 // typeof(string) // 4 value (display)
1659 this.el.add_attribute(_this.valrender.el , "text", 4 );
1660 //this.el.add_attribute(_this.valrender.el , "sensitive", 4 );
1661 //this.el.add_attribute(this.items[0].el , 'editable', 3 );
1662 // this.el.set_cell_data_func(cell, age_cell_data_func, NULL, NULL);
1664 // this.get('/LeftPanel').editableColumn= this;
1668 // user defined functions
1670 public class Xcls_valrender : Object
1672 public Gtk.CellRendererCombo el;
1673 private Xcls_LeftProps _this;
1679 public Xcls_valrender(Xcls_LeftProps _owner )
1682 _this.valrender = this;
1683 this.el = new Gtk.CellRendererCombo();
1687 // set gobject values
1688 this.el.editable = false;
1689 this.el.text_column = 0;
1690 this.el.has_entry = true;
1691 var child_0 = new Xcls_valrendermodel( _this );
1693 this.el.model = child_0.el;
1696 this.el.editing_started.connect( ( editable, path) => {
1697 //_this.editing = true;
1698 GLib.debug("editing started called\n");
1699 if (!_this.allow_edit) {
1701 GLib.debug("val - editing_Started\n");
1702 this.el.editable = false; // make sure it's not editor...
1707 _this.allow_edit =false;
1710 if ( this.el.has_entry ) {
1713 _this.model.el.get_iter(out iter, new Gtk.TreePath.from_string(path));
1718 // this.get('/LeftPanel.model').activePath = path;
1719 _this.model.el.get_value(iter,3, out gval);
1722 var val = (string)gval;
1723 var combo = (Gtk.ComboBox)editable;
1725 var entry = (Gtk.Entry) combo.get_child();
1726 entry.set_text(val);
1730 this.el.edited.connect( (path, newtext) => {
1731 GLib.debug("Valrender - signal:edited\n");
1733 this.el.editable = false;
1738 2, "<b>" + miter.get_key() + "</b>",
1739 3, miter.get_value(),
1740 4, display_value(short);
1746 _this.model.el.get_iter(out iter, new Gtk.TreePath.from_string(path));
1749 _this.model.el.get_value(iter,0, out gval);
1750 var ktype = (string)gval;
1753 _this.model.el.get_value(iter,3, out gval);
1754 var oldval = (string)gval;
1756 _this.model.el.get_value(iter,1, out gval);
1757 var key = (string)gval;
1763 _this.node.listeners.set(key, newtext);
1764 _this.updateIter(iter,ktype,key,newtext);
1767 _this.node.props.set(key,newtext);
1768 _this.updateIter(iter,ktype, key,newtext);
1771 // _this.load(_this.file,_this.node);
1777 // user defined functions
1778 public void setOptions (string[] ar) {
1779 var m = _this.valrendermodel.el;
1782 for (var i =0; i < ar.length; i++) {
1784 m.set_value(iret, 0, ar[i]);
1789 public class Xcls_valrendermodel : Object
1791 public Gtk.ListStore el;
1792 private Xcls_LeftProps _this;
1798 public Xcls_valrendermodel(Xcls_LeftProps _owner )
1801 _this.valrendermodel = this;
1802 this.el = new Gtk.ListStore( 1, typeof(string) );
1806 // set gobject values
1809 // user defined functions
1814 public class Xcls_ContextMenu : Object
1817 private Xcls_LeftProps _this;
1823 public Xcls_ContextMenu(Xcls_LeftProps _owner )
1826 _this.ContextMenu = this;
1827 this.el = new Gtk.Menu();
1831 // set gobject values
1832 var child_0 = new Xcls_MenuItem34( _this );
1834 this.el.append ( child_0.el );
1835 var child_1 = new Xcls_SeparatorMenuItem35( _this );
1837 this.el.append ( child_1.el );
1838 var child_2 = new Xcls_MenuItem36( _this );
1840 this.el.append ( child_2.el );
1843 // user defined functions
1845 public class Xcls_MenuItem34 : Object
1847 public Gtk.MenuItem el;
1848 private Xcls_LeftProps _this;
1854 public Xcls_MenuItem34(Xcls_LeftProps _owner )
1857 this.el = new Gtk.MenuItem();
1861 // set gobject values
1862 this.el.label = "Edit (double click)";
1865 this.el.activate.connect( ( ) =>{
1867 var s = _this.view.el.get_selection();
1870 s.get_selected (out mod, out iter);
1872 if (_this.view.popover == null) {
1873 _this.view.popover = new Xcls_PopoverProperty();
1874 _this.view.popover.mainwindow = _this.main_window;
1878 _this.before_edit();
1879 _this.stop_editor();
1881 _this.keyrender.el.stop_editing(false);
1882 _this.keyrender.el.editable =false;
1884 _this.valrender.el.stop_editing(false);
1885 _this.valrender.el.editable =false;
1888 GLib.Value gvaltype, gval;
1889 mod.get_value(iter, 1 , out gval); // one is key..
1891 mod.get_value(iter,0, out gvaltype);
1893 _this.view.popover.show(_this.view.el, _this.node, (string)gvaltype, (string)gval);
1897 // _this.startEditingKey(model.get_path(iter));
1901 // user defined functions
1904 public class Xcls_SeparatorMenuItem35 : Object
1906 public Gtk.SeparatorMenuItem el;
1907 private Xcls_LeftProps _this;
1913 public Xcls_SeparatorMenuItem35(Xcls_LeftProps _owner )
1916 this.el = new Gtk.SeparatorMenuItem();
1920 // set gobject values
1923 // user defined functions
1926 public class Xcls_MenuItem36 : Object
1928 public Gtk.MenuItem el;
1929 private Xcls_LeftProps _this;
1935 public Xcls_MenuItem36(Xcls_LeftProps _owner )
1938 this.el = new Gtk.MenuItem();
1942 // set gobject values
1943 this.el.label = "Delete";
1946 this.el.activate.connect( ( ) =>{
1947 _this.deleteSelected();
1951 // user defined functions