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 print("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 print("start editing?\n");
142 if (!this.stop_editor()) {
143 print("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 print("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 = Palete.factory(this.file.project.xtype);
217 var has_opts = pal.typeOptions(this.node.fqn(), kname, ktype, out opts);
221 // others... - fill in options for true/false?
222 print("turn on editing %s \n" , mod.get_path(iter).to_string());
226 print("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 print("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)
310 // really need a way to sort the hashmap...
311 var m = this.model.el;
313 var miter = node.listeners.map_iterator();
316 while(miter.next()) {
318 m.append(out iter,null);
320 this.updateIter(iter, "listener", miter.get_key(), miter.get_value());
326 miter = node.props.map_iterator();
329 while(miter.next()) {
331 m.append(out iter,null);
332 this.updateIter(iter, "prop", miter.get_key(), miter.get_value());
335 print("clear selection\n");
337 this.model.el.set_sort_column_id(6,Gtk.SortType.ASCENDING); // sort by real key..
339 this.view.el.get_selection().unselect_all();
341 var pane = _this.main_window.editpane.el;
342 var try_size = (i * 25) + 60; // est. 20px per line + 40px header
346 ((try_size * 1.0f) / (pane.max_position * 1.0f)) > 0.8f ?
347 (int) (pane.max_position * 0.2f) :
348 pane.max_position-try_size);
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);
487 if (this.node.props.has_key(fkey)) {
490 this.node.props.set(fkey,value);
495 this.load(this.file, this.node);
499 /// need to find the row which I've just added..
502 var s = this.view.el.get_selection();
505 print("trying to find new iter");
507 this.model.el.foreach((model, path, iter) => {
510 this.model.el.get_value(iter, 0 , out gval);
511 if ((string)gval != type) {
512 print("not type: %s = %s\n", (string)gval , type);
515 this.model.el.get_value(iter, 1 , out gval);
516 if ((string)gval != fkey) {
517 print("not key: %s = %s\n", (string)gval , fkey);
521 GLib.Timeout.add_full(GLib.Priority.DEFAULT,40 , () => {
523 this.startEditingValue(this.model.el.get_path(iter));
526 //s.select_iter(iter);
534 public void updateIter (Gtk.TreeIter iter, string type, string key, string kvalue) {
536 //print("update Iter %s, %s\n", key,kvalue);
537 //typeof(string), // 0 key type
538 //typeof(string), // 1 key
539 //typeof(string), // 2 key (display)
540 //typeof(string), // 3 value
541 //typeof(string), // 4 value (display)
542 //typeof(string), // 5 both (tooltip)
543 //typeof(string), // 6 key (sort)
545 var dl = kvalue.strip().split("\n");
547 var dis_val = dl.length > 1 ? (dl[0].strip()+ "...") : dl[0];
549 if (type == "listener") {
553 this.model.el.set(iter,
556 2, this.keyFormat(key ,type),
559 5, "<tt>" + GLib.Markup.escape_text(key + " " +kvalue) + "</tt>",
567 this.model.el.set(iter,
570 2, this.keyFormat(key , "prop"),
573 5, "<tt>" + GLib.Markup.escape_text(key + " " + kvalue) + "</tt>",
574 6, this.keySortFormat(key)
577 public class Xcls_Box2 : Object
580 private Xcls_LeftProps _this;
586 public Xcls_Box2(Xcls_LeftProps _owner )
589 this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
593 // set gobject values
594 var child_0 = new Xcls_Button3( _this );
596 this.el.add ( child_0.el );
599 // user defined functions
601 public class Xcls_Button3 : Object
603 public Gtk.Button el;
604 private Xcls_LeftProps _this;
610 public Xcls_Button3(Xcls_LeftProps _owner )
613 this.el = new Gtk.Button();
617 // set gobject values
618 this.el.hexpand = true;
619 var child_0 = new Xcls_Box4( _this );
621 this.el.add ( child_0.el );
622 var child_1 = new Xcls_AddPropertyPopup( _this );
626 this.el.button_press_event.connect( (self, ev) => {
630 var p = _this.AddPropertyPopup;
631 p.el.set_screen(Gdk.Screen.get_default());
633 p.el.popup(null, null, null, ev.button, ev.time);
638 // user defined functions
640 public class Xcls_Box4 : Object
643 private Xcls_LeftProps _this;
649 public Xcls_Box4(Xcls_LeftProps _owner )
652 this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
656 // set gobject values
657 var child_0 = new Xcls_Image5( _this );
659 this.el.add ( child_0.el );
660 var child_1 = new Xcls_Label6( _this );
662 this.el.add ( child_1.el );
665 // user defined functions
667 public class Xcls_Image5 : Object
670 private Xcls_LeftProps _this;
676 public Xcls_Image5(Xcls_LeftProps _owner )
679 this.el = new Gtk.Image();
683 // set gobject values
684 this.el.stock = Gtk.Stock.ADD;
685 this.el.icon_size = Gtk.IconSize.MENU;
688 // user defined functions
691 public class Xcls_Label6 : Object
694 private Xcls_LeftProps _this;
700 public Xcls_Label6(Xcls_LeftProps _owner )
703 this.el = new Gtk.Label( "Other" );
707 // set gobject values
710 // user defined functions
714 public class Xcls_AddPropertyPopup : Object
717 private Xcls_LeftProps _this;
723 public Xcls_AddPropertyPopup(Xcls_LeftProps _owner )
726 _this.AddPropertyPopup = this;
727 this.el = new Gtk.Menu();
731 // set gobject values
732 var child_0 = new Xcls_MenuItem8( _this );
734 this.el.append ( child_0.el );
735 var child_1 = new Xcls_MenuItem9( _this );
737 this.el.append ( child_1.el );
738 var child_2 = new Xcls_MenuItem10( _this );
740 this.el.append ( child_2.el );
741 var child_3 = new Xcls_MenuItem11( _this );
743 this.el.append ( child_3.el );
744 var child_4 = new Xcls_MenuItem12( _this );
746 this.el.append ( child_4.el );
747 var child_5 = new Xcls_SeparatorMenuItem13( _this );
749 this.el.add ( child_5.el );
750 var child_6 = new Xcls_MenuItem14( _this );
752 this.el.append ( child_6.el );
753 var child_7 = new Xcls_MenuItem15( _this );
755 this.el.append ( child_7.el );
756 var child_8 = new Xcls_MenuItem16( _this );
758 this.el.append ( child_8.el );
759 var child_9 = new Xcls_SeparatorMenuItem17( _this );
761 this.el.add ( child_9.el );
762 var child_10 = new Xcls_MenuItem18( _this );
764 this.el.append ( child_10.el );
765 var child_11 = new Xcls_MenuItem19( _this );
767 this.el.append ( child_11.el );
768 var child_12 = new Xcls_MenuItem20( _this );
770 this.el.append ( child_12.el );
771 var child_13 = new Xcls_SeparatorMenuItem21( _this );
773 this.el.add ( child_13.el );
774 var child_14 = new Xcls_MenuItem22( _this );
776 this.el.append ( child_14.el );
777 var child_15 = new Xcls_MenuItem23( _this );
779 this.el.append ( child_15.el );
780 var child_16 = new Xcls_MenuItem24( _this );
782 this.el.append ( child_16.el );
785 // user defined functions
787 public class Xcls_MenuItem8 : Object
789 public Gtk.MenuItem el;
790 private Xcls_LeftProps _this;
796 public Xcls_MenuItem8(Xcls_LeftProps _owner )
799 this.el = new Gtk.MenuItem();
803 // set gobject values
804 this.el.tooltip_markup = "Using _this.{ID} will map to this element";
805 this.el.label = "id: _this.{ID} (Vala)";
808 this.el.activate.connect( () => {
809 _this.addProp( "prop", "id", "", "");
813 // user defined functions
816 public class Xcls_MenuItem9 : Object
818 public Gtk.MenuItem el;
819 private Xcls_LeftProps _this;
825 public Xcls_MenuItem9(Xcls_LeftProps _owner )
828 this.el = new Gtk.MenuItem();
832 // set gobject values
833 this.el.tooltip_markup = "how to pack this element onto parent, (method, 2nd arg, 3rd arg) .. the 1st argument is filled by the element";
834 this.el.label = "pack: Pack method (Vala)";
837 this.el.activate.connect( ( ) => {
839 _this.addProp( "prop", "pack","add", "*");
843 // user defined functions
846 public class Xcls_MenuItem10 : Object
848 public Gtk.MenuItem el;
849 private Xcls_LeftProps _this;
855 public Xcls_MenuItem10(Xcls_LeftProps _owner )
858 this.el = new Gtk.MenuItem();
862 // set gobject values
863 this.el.tooltip_markup = "eg. \n\nnew Clutter.Image.from_file(.....)";
864 this.el.label = "ctor: Alterative to default contructor (Vala)";
867 this.el.activate.connect( ( ) => {
869 _this.addProp( "prop", "ctor","", "*");
873 // user defined functions
876 public class Xcls_MenuItem11 : Object
878 public Gtk.MenuItem el;
879 private Xcls_LeftProps _this;
885 public Xcls_MenuItem11(Xcls_LeftProps _owner )
888 this.el = new Gtk.MenuItem();
892 // set gobject values
893 this.el.tooltip_markup = "This code is called after the ctor";
894 this.el.label = "init: initialziation code (vala)";
897 this.el.activate.connect( ( ) => {
899 _this.addProp( "prop", "init", "{\n\n}\n", "*" );
903 // user defined functions
906 public class Xcls_MenuItem12 : Object
908 public Gtk.MenuItem el;
909 private Xcls_LeftProps _this;
915 public Xcls_MenuItem12(Xcls_LeftProps _owner )
918 this.el = new Gtk.MenuItem();
922 // set gobject values
923 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";
924 this.el.label = "cms-id: (Roo JS/Pman library)";
927 this.el.activate.connect( () => {
928 _this.addProp( "prop", "cms-id", "", "string");
932 // user defined functions
935 public class Xcls_SeparatorMenuItem13 : Object
937 public Gtk.SeparatorMenuItem el;
938 private Xcls_LeftProps _this;
944 public Xcls_SeparatorMenuItem13(Xcls_LeftProps _owner )
947 this.el = new Gtk.SeparatorMenuItem();
951 // set gobject values
954 // user defined functions
957 public class Xcls_MenuItem14 : Object
959 public Gtk.MenuItem el;
960 private Xcls_LeftProps _this;
966 public Xcls_MenuItem14(Xcls_LeftProps _owner )
969 this.el = new Gtk.MenuItem();
973 // set gobject values
974 this.el.tooltip_markup = "Add a user defined string property";
975 this.el.label = "String";
978 this.el.activate.connect( (self) => {
980 _this.addProp( "prop", "XXXX", "","string");
985 // user defined functions
988 public class Xcls_MenuItem15 : Object
990 public Gtk.MenuItem el;
991 private Xcls_LeftProps _this;
997 public Xcls_MenuItem15(Xcls_LeftProps _owner )
1000 this.el = new Gtk.MenuItem();
1004 // set gobject values
1005 this.el.tooltip_markup = "Add a user defined number property";
1006 this.el.label = "Number";
1009 this.el.activate.connect( ( ) =>{
1011 _this.addProp("prop", "XXX", "0", "int");
1015 // user defined functions
1018 public class Xcls_MenuItem16 : Object
1020 public Gtk.MenuItem el;
1021 private Xcls_LeftProps _this;
1027 public Xcls_MenuItem16(Xcls_LeftProps _owner )
1030 this.el = new Gtk.MenuItem();
1034 // set gobject values
1035 this.el.tooltip_markup = "Add a user defined boolean property";
1036 this.el.label = "Boolean";
1039 this.el.activate.connect( ( ) =>{
1041 _this.addProp( "prop", "XXX", "true", "bool");
1045 // user defined functions
1048 public class Xcls_SeparatorMenuItem17 : Object
1050 public Gtk.SeparatorMenuItem el;
1051 private Xcls_LeftProps _this;
1057 public Xcls_SeparatorMenuItem17(Xcls_LeftProps _owner )
1060 this.el = new Gtk.SeparatorMenuItem();
1064 // set gobject values
1067 // user defined functions
1070 public class Xcls_MenuItem18 : Object
1072 public Gtk.MenuItem el;
1073 private Xcls_LeftProps _this;
1079 public Xcls_MenuItem18(Xcls_LeftProps _owner )
1082 this.el = new Gtk.MenuItem();
1086 // set gobject values
1087 this.el.tooltip_markup = "Add a user function boolean property";
1088 this.el.label = "Javascript Function";
1091 this.el.activate.connect( ( ) =>{
1093 _this.addProp("prop", "XXXX", "function() { }", "| function");
1097 // user defined functions
1100 public class Xcls_MenuItem19 : Object
1102 public Gtk.MenuItem el;
1103 private Xcls_LeftProps _this;
1109 public Xcls_MenuItem19(Xcls_LeftProps _owner )
1112 this.el = new Gtk.MenuItem();
1116 // set gobject values
1117 this.el.tooltip_markup = "Add a user function boolean property";
1118 this.el.label = "Vala Method";
1121 this.el.activate.connect( ( ) =>{
1123 _this.addProp( "prop", "XXXX", "() {\n\n}\n", "| return_type");
1127 // user defined functions
1130 public class Xcls_MenuItem20 : Object
1132 public Gtk.MenuItem el;
1133 private Xcls_LeftProps _this;
1139 public Xcls_MenuItem20(Xcls_LeftProps _owner )
1142 this.el = new Gtk.MenuItem();
1146 // set gobject values
1147 this.el.tooltip_markup = "Add a vala signal";
1148 this.el.label = "Vala Signal";
1151 this.el.activate.connect( ( ) =>{
1153 _this.addProp( "prop", "XXXX", "()", "@ void");
1157 // user defined functions
1160 public class Xcls_SeparatorMenuItem21 : Object
1162 public Gtk.SeparatorMenuItem el;
1163 private Xcls_LeftProps _this;
1169 public Xcls_SeparatorMenuItem21(Xcls_LeftProps _owner )
1172 this.el = new Gtk.SeparatorMenuItem();
1176 // set gobject values
1179 // user defined functions
1182 public class Xcls_MenuItem22 : Object
1184 public Gtk.MenuItem el;
1185 private Xcls_LeftProps _this;
1191 public Xcls_MenuItem22(Xcls_LeftProps _owner )
1194 this.el = new Gtk.MenuItem();
1198 // set gobject values
1199 this.el.tooltip_markup = "Add a flexy if (for HTML templates)";
1200 this.el.label = "Flexy - If";
1203 this.el.activate.connect( ( ) =>{
1205 _this.addProp("prop", "flexy:if", "value_or_condition", "string");
1209 // user defined functions
1212 public class Xcls_MenuItem23 : Object
1214 public Gtk.MenuItem el;
1215 private Xcls_LeftProps _this;
1221 public Xcls_MenuItem23(Xcls_LeftProps _owner )
1224 this.el = new Gtk.MenuItem();
1228 // set gobject values
1229 this.el.tooltip_markup = "Add a flexy include (for HTML templates)";
1230 this.el.label = "Flexy - Include";
1233 this.el.activate.connect( ( ) =>{
1235 _this.addProp("prop", "flexy:include", "name_of_file.html", "string");
1239 // user defined functions
1242 public class Xcls_MenuItem24 : Object
1244 public Gtk.MenuItem el;
1245 private Xcls_LeftProps _this;
1251 public Xcls_MenuItem24(Xcls_LeftProps _owner )
1254 this.el = new Gtk.MenuItem();
1258 // set gobject values
1259 this.el.tooltip_markup = "Add a flexy foreach (for HTML templates)";
1260 this.el.label = "Flexy - Foreach";
1263 this.el.activate.connect( ( ) =>{
1265 _this.addProp("prop", "flexy:foreach", "array,key,value", "string");
1269 // user defined functions
1275 public class Xcls_EditProps : Object
1277 public Gtk.ScrolledWindow el;
1278 private Xcls_LeftProps _this;
1282 public bool editing;
1285 public Xcls_EditProps(Xcls_LeftProps _owner )
1288 _this.EditProps = this;
1289 this.el = new Gtk.ScrolledWindow( null, null );
1292 this.editing = false;
1294 // set gobject values
1295 this.el.shadow_type = Gtk.ShadowType.IN;
1296 var child_0 = new Xcls_view( _this );
1298 this.el.add ( child_0.el );
1304 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
1308 // user defined functions
1310 public class Xcls_view : Object
1312 public Gtk.TreeView el;
1313 private Xcls_LeftProps _this;
1317 public Xcls_PopoverProperty popover;
1320 public Xcls_view(Xcls_LeftProps _owner )
1324 this.el = new Gtk.TreeView();
1327 this.popover = null;
1329 // set gobject values
1330 this.el.tooltip_column = 5;
1331 this.el.enable_tree_lines = true;
1332 this.el.headers_visible = true;
1333 var child_0 = new Xcls_model( _this );
1335 this.el.set_model ( child_0.el );
1336 var child_1 = new Xcls_keycol( _this );
1338 this.el.append_column ( child_1.el );
1339 var child_2 = new Xcls_valcol( _this );
1341 this.el.append_column ( child_2.el );
1342 var child_3 = new Xcls_ContextMenu( _this );
1348 var selection = this.el.get_selection();
1349 selection.set_mode( Gtk.SelectionMode.SINGLE);
1352 var description = new Pango.FontDescription();
1353 description.set_size(10000);
1354 this.el.override_font(description);
1358 this.el.button_press_event.connect( ( ev) => {
1360 Gtk.TreeViewColumn col;
1364 if (!this.el.get_path_at_pos((int)ev.x, (int) ev.y, out path, out col, out cell_x, out cell_y )) {
1365 print("nothing selected on click");
1366 GLib.Timeout.add_full(GLib.Priority.DEFAULT,10 , () => {
1367 this.el.get_selection().unselect_all();
1371 _this.before_edit();
1372 return false; //not on a element.
1376 // double click on name..
1377 if (ev.type == Gdk.EventType.2BUTTON_PRESS && ev.button == 1 && col.title == "Name") {
1380 if (this.popover == null) {
1381 this.popover = new Xcls_PopoverProperty();
1382 this.popover.mainwindow = _this.main_window;
1386 _this.before_edit();
1387 _this.stop_editor();
1389 _this.keyrender.el.stop_editing(false);
1390 _this.keyrender.el.editable =false;
1392 _this.valrender.el.stop_editing(false);
1393 _this.valrender.el.editable =false;
1395 var mod = this.el.get_model();
1396 mod.get_iter (out iter, path);
1399 GLib.Value gvaltype, gval;
1400 mod.get_value(iter, 1 , out gval); // one is key..
1402 mod.get_value(iter,0, out gvaltype);
1404 this.popover.show(this.el, _this.node, (string)gvaltype, (string)gval);
1406 // _this.startEditingKey(path);
1415 if (ev.type == Gdk.EventType.BUTTON_PRESS && ev.button == 3) {
1417 //if (col.title == "Value") {
1418 // _this.before_edit();
1422 var p = _this.ContextMenu;
1424 p.el.set_screen(Gdk.Screen.get_default());
1426 p.el.popup(null, null, null, ev.button, ev.time);
1427 //Seed.print("click:" + res.column.title);
1429 GLib.Timeout.add_full(GLib.Priority.DEFAULT,10 , () => {
1431 this.el.get_selection().select_path(path);
1434 _this.before_edit();
1439 if (col.title != "Value") {
1440 print("col title != Value");
1442 GLib.Timeout.add_full(GLib.Priority.DEFAULT,10 , () => {
1443 this.el.get_selection().select_path(path);
1447 _this.before_edit();
1448 // XObject.error("column is not value?");
1449 return false; // ignore.. - key click.. ??? should we do this??
1453 // if the cell can be edited with a pulldown
1454 // then we should return true... - and let the start_editing handle it?
1461 // _this.before_edit(); <<< we really need to stop the other editor..
1462 _this.keyrender.el.stop_editing(false);
1463 _this.keyrender.el.editable =false;
1466 return _this.startEditingValue(path); // assumes selected row..
1475 // user defined functions
1477 public class Xcls_model : Object
1479 public Gtk.TreeStore el;
1480 private Xcls_LeftProps _this;
1486 public Xcls_model(Xcls_LeftProps _owner )
1490 this.el = new Gtk.TreeStore( 7, typeof(string), // 0 key type
1491 typeof(string), // 1 key
1492 typeof(string), // 2 key (display)
1493 typeof(string), // 3 value
1494 typeof(string), // 4 value (display)
1495 typeof(string), // 5 both (tooltip)
1496 typeof(string) // 6 key (for sorting)
1501 // set gobject values
1504 // user defined functions
1507 public class Xcls_keycol : Object
1509 public Gtk.TreeViewColumn el;
1510 private Xcls_LeftProps _this;
1516 public Xcls_keycol(Xcls_LeftProps _owner )
1519 _this.keycol = this;
1520 this.el = new Gtk.TreeViewColumn();
1524 // set gobject values
1525 this.el.title = "Name";
1526 this.el.resizable = true;
1527 var child_0 = new Xcls_keyrender( _this );
1529 this.el.pack_start ( child_0.el , false );
1533 this.el.add_attribute(_this.keyrender.el , "markup", 2 );
1534 this.el.add_attribute(_this.keyrender.el , "text", 1 );
1537 // user defined functions
1539 public class Xcls_keyrender : Object
1541 public Gtk.CellRendererText el;
1542 private Xcls_LeftProps _this;
1548 public Xcls_keyrender(Xcls_LeftProps _owner )
1551 _this.keyrender = this;
1552 this.el = new Gtk.CellRendererText();
1556 // set gobject values
1559 this.el.editing_started.connect( ( editable, path) => {
1562 _this.model.el.get_iter(out iter, new Gtk.TreePath.from_string(path));
1567 // this.get('/LeftPanel.model').activePath = path;
1568 _this.model.el.get_value(iter,1, out gval);
1569 var val = (string)gval;
1571 ((Gtk.Entry)editable).set_text(val);
1573 this.el.edited.connect( (path, newtext) => {
1574 print("Keyrender - signal:edited\n");
1576 this.el.editable = false;
1581 _this.model.el.get_iter(out iter, new Gtk.TreePath.from_string(path));
1584 _this.model.el.get_value(iter,1, out gval);
1585 var oldval = (string)gval;
1587 _this.model.el.get_value(iter,0, out gval);
1588 var ktype = (string)gval;
1590 _this.model.el.set_value(iter, 1, newtext);
1592 if (oldval == newtext) {
1597 print("ktype: %s\n",ktype);
1600 var ov = _this.node.listeners.get(oldval);
1601 _this.node.listeners.set(newtext, ov);
1602 _this.node.listeners.unset(oldval);
1604 _this.updateIter(iter, ktype, newtext, ov);
1608 var ov = _this.node.props.get(oldval);
1609 _this.node.props.set(newtext, ov);
1610 _this.node.props.unset(oldval);
1611 _this.updateIter(iter, ktype, newtext, ov);
1619 // user defined functions
1623 public class Xcls_valcol : Object
1625 public Gtk.TreeViewColumn el;
1626 private Xcls_LeftProps _this;
1632 public Xcls_valcol(Xcls_LeftProps _owner )
1635 _this.valcol = this;
1636 this.el = new Gtk.TreeViewColumn();
1640 // set gobject values
1641 this.el.title = "Value";
1642 this.el.resizable = true;
1643 var child_0 = new Xcls_valrender( _this );
1645 this.el.pack_start ( child_0.el , true );
1651 // typeof(string), // 0 key type
1652 // typeof(string), // 1 key
1653 // typeof(string), // 2 key (display)
1654 // typeof(string), // 3 value
1655 // typeof(string) // 4 value (display)
1658 this.el.add_attribute(_this.valrender.el , "text", 4 );
1659 //this.el.add_attribute(_this.valrender.el , "sensitive", 4 );
1660 //this.el.add_attribute(this.items[0].el , 'editable', 3 );
1661 // this.el.set_cell_data_func(cell, age_cell_data_func, NULL, NULL);
1663 // this.get('/LeftPanel').editableColumn= this;
1667 // user defined functions
1669 public class Xcls_valrender : Object
1671 public Gtk.CellRendererCombo el;
1672 private Xcls_LeftProps _this;
1678 public Xcls_valrender(Xcls_LeftProps _owner )
1681 _this.valrender = this;
1682 this.el = new Gtk.CellRendererCombo();
1686 // set gobject values
1687 this.el.editable = false;
1688 this.el.text_column = 0;
1689 this.el.has_entry = true;
1690 var child_0 = new Xcls_valrendermodel( _this );
1692 this.el.model = child_0.el;
1695 this.el.editing_started.connect( ( editable, path) => {
1696 //_this.editing = true;
1697 print("editing started called\n");
1698 if (!_this.allow_edit) {
1700 print("val - editing_Started\n");
1701 this.el.editable = false; // make sure it's not editor...
1706 _this.allow_edit =false;
1709 if ( this.el.has_entry ) {
1712 _this.model.el.get_iter(out iter, new Gtk.TreePath.from_string(path));
1717 // this.get('/LeftPanel.model').activePath = path;
1718 _this.model.el.get_value(iter,3, out gval);
1721 var val = (string)gval;
1722 var combo = (Gtk.ComboBox)editable;
1724 var entry = (Gtk.Entry) combo.get_child();
1725 entry.set_text(val);
1729 this.el.edited.connect( (path, newtext) => {
1730 print("Valrender - signal:edited\n");
1732 this.el.editable = false;
1737 2, "<b>" + miter.get_key() + "</b>",
1738 3, miter.get_value(),
1739 4, display_value(short);
1745 _this.model.el.get_iter(out iter, new Gtk.TreePath.from_string(path));
1748 _this.model.el.get_value(iter,0, out gval);
1749 var ktype = (string)gval;
1752 _this.model.el.get_value(iter,3, out gval);
1753 var oldval = (string)gval;
1755 _this.model.el.get_value(iter,1, out gval);
1756 var key = (string)gval;
1762 _this.node.listeners.set(key, newtext);
1763 _this.updateIter(iter,ktype,key,newtext);
1766 _this.node.props.set(key,newtext);
1767 _this.updateIter(iter,ktype, key,newtext);
1770 // _this.load(_this.file,_this.node);
1776 // user defined functions
1777 public void setOptions (string[] ar) {
1778 var m = _this.valrendermodel.el;
1781 for (var i =0; i < ar.length; i++) {
1783 m.set_value(iret, 0, ar[i]);
1788 public class Xcls_valrendermodel : Object
1790 public Gtk.ListStore el;
1791 private Xcls_LeftProps _this;
1797 public Xcls_valrendermodel(Xcls_LeftProps _owner )
1800 _this.valrendermodel = this;
1801 this.el = new Gtk.ListStore( 1, typeof(string) );
1805 // set gobject values
1808 // user defined functions
1813 public class Xcls_ContextMenu : Object
1816 private Xcls_LeftProps _this;
1822 public Xcls_ContextMenu(Xcls_LeftProps _owner )
1825 _this.ContextMenu = this;
1826 this.el = new Gtk.Menu();
1830 // set gobject values
1831 var child_0 = new Xcls_MenuItem34( _this );
1833 this.el.append ( child_0.el );
1834 var child_1 = new Xcls_SeparatorMenuItem35( _this );
1836 this.el.append ( child_1.el );
1837 var child_2 = new Xcls_MenuItem36( _this );
1839 this.el.append ( child_2.el );
1842 // user defined functions
1844 public class Xcls_MenuItem34 : Object
1846 public Gtk.MenuItem el;
1847 private Xcls_LeftProps _this;
1853 public Xcls_MenuItem34(Xcls_LeftProps _owner )
1856 this.el = new Gtk.MenuItem();
1860 // set gobject values
1861 this.el.label = "Edit (double click)";
1864 this.el.activate.connect( ( ) =>{
1866 var s = _this.view.el.get_selection();
1869 s.get_selected (out mod, out iter);
1871 if (_this.view.popover == null) {
1872 _this.view.popover = new Xcls_PopoverProperty();
1873 _this.view.popover.mainwindow = _this.main_window;
1877 _this.before_edit();
1878 _this.stop_editor();
1880 _this.keyrender.el.stop_editing(false);
1881 _this.keyrender.el.editable =false;
1883 _this.valrender.el.stop_editing(false);
1884 _this.valrender.el.editable =false;
1887 GLib.Value gvaltype, gval;
1888 mod.get_value(iter, 1 , out gval); // one is key..
1890 mod.get_value(iter,0, out gvaltype);
1892 _this.view.popover.show(_this.view.el, _this.node, (string)gvaltype, (string)gval);
1896 // _this.startEditingKey(model.get_path(iter));
1900 // user defined functions
1903 public class Xcls_SeparatorMenuItem35 : Object
1905 public Gtk.SeparatorMenuItem el;
1906 private Xcls_LeftProps _this;
1912 public Xcls_SeparatorMenuItem35(Xcls_LeftProps _owner )
1915 this.el = new Gtk.SeparatorMenuItem();
1919 // set gobject values
1922 // user defined functions
1925 public class Xcls_MenuItem36 : Object
1927 public Gtk.MenuItem el;
1928 private Xcls_LeftProps _this;
1934 public Xcls_MenuItem36(Xcls_LeftProps _owner )
1937 this.el = new Gtk.MenuItem();
1941 // set gobject values
1942 this.el.label = "Delete";
1945 this.el.activate.connect( ( ) =>{
1946 _this.deleteSelected();
1950 // user defined functions