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, 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,value);
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 = value.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 + " " +value) + "</tt>",
567 this.model.el.set(iter,
570 2, this.keyFormat(key , "prop"),
573 5, "<tt>" + GLib.Markup.escape_text(key + " " + value) + "</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_SeparatorMenuItem12( _this );
746 this.el.add ( child_4.el );
747 var child_5 = new Xcls_MenuItem13( _this );
749 this.el.append ( 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_SeparatorMenuItem16( _this );
758 this.el.add ( child_8.el );
759 var child_9 = new Xcls_MenuItem17( _this );
761 this.el.append ( 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_SeparatorMenuItem20( _this );
770 this.el.add ( child_12.el );
771 var child_13 = new Xcls_MenuItem21( _this );
773 this.el.append ( 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 );
782 // user defined functions
784 public class Xcls_MenuItem8 : Object
786 public Gtk.MenuItem el;
787 private Xcls_LeftProps _this;
793 public Xcls_MenuItem8(Xcls_LeftProps _owner )
796 this.el = new Gtk.MenuItem();
800 // set gobject values
801 this.el.tooltip_markup = "Using _this.{ID} will map to this element";
802 this.el.label = "id: _this.{ID} (Vala)";
805 this.el.activate.connect( () => {
806 _this.addProp( "prop", "id", "", "");
810 // user defined functions
813 public class Xcls_MenuItem9 : Object
815 public Gtk.MenuItem el;
816 private Xcls_LeftProps _this;
822 public Xcls_MenuItem9(Xcls_LeftProps _owner )
825 this.el = new Gtk.MenuItem();
829 // set gobject values
830 this.el.tooltip_markup = "how to pack this element onto parent, (method, 2nd arg, 3rd arg) .. the 1st argument is filled by the element";
831 this.el.label = "pack: Pack method (Vala)";
834 this.el.activate.connect( ( ) => {
836 _this.addProp( "prop", "pack","add", "*");
840 // user defined functions
843 public class Xcls_MenuItem10 : Object
845 public Gtk.MenuItem el;
846 private Xcls_LeftProps _this;
852 public Xcls_MenuItem10(Xcls_LeftProps _owner )
855 this.el = new Gtk.MenuItem();
859 // set gobject values
860 this.el.tooltip_markup = "eg. \n\nnew Clutter.Image.from_file(.....)";
861 this.el.label = "ctor: Alterative to default contructor";
864 this.el.activate.connect( ( ) => {
866 _this.addProp( "prop", "ctor","", "*");
870 // user defined functions
873 public class Xcls_MenuItem11 : Object
875 public Gtk.MenuItem el;
876 private Xcls_LeftProps _this;
882 public Xcls_MenuItem11(Xcls_LeftProps _owner )
885 this.el = new Gtk.MenuItem();
889 // set gobject values
890 this.el.tooltip_markup = "This code is called after the ctor";
891 this.el.label = "init: initialziation code (vala)";
894 this.el.activate.connect( ( ) => {
896 _this.addProp( "prop", "init", "{\n\n}\n", "*" );
900 // user defined functions
903 public class Xcls_SeparatorMenuItem12 : Object
905 public Gtk.SeparatorMenuItem el;
906 private Xcls_LeftProps _this;
912 public Xcls_SeparatorMenuItem12(Xcls_LeftProps _owner )
915 this.el = new Gtk.SeparatorMenuItem();
919 // set gobject values
922 // user defined functions
925 public class Xcls_MenuItem13 : Object
927 public Gtk.MenuItem el;
928 private Xcls_LeftProps _this;
934 public Xcls_MenuItem13(Xcls_LeftProps _owner )
937 this.el = new Gtk.MenuItem();
941 // set gobject values
942 this.el.tooltip_markup = "Add a user defined string property";
943 this.el.label = "String";
946 this.el.activate.connect( (self) => {
948 _this.addProp( "prop", "XXXX", "","string");
953 // user defined functions
956 public class Xcls_MenuItem14 : Object
958 public Gtk.MenuItem el;
959 private Xcls_LeftProps _this;
965 public Xcls_MenuItem14(Xcls_LeftProps _owner )
968 this.el = new Gtk.MenuItem();
972 // set gobject values
973 this.el.tooltip_markup = "Add a user defined number property";
974 this.el.label = "Number";
977 this.el.activate.connect( ( ) =>{
979 _this.addProp("prop", "XXX", "0", "int");
983 // user defined functions
986 public class Xcls_MenuItem15 : Object
988 public Gtk.MenuItem el;
989 private Xcls_LeftProps _this;
995 public Xcls_MenuItem15(Xcls_LeftProps _owner )
998 this.el = new Gtk.MenuItem();
1002 // set gobject values
1003 this.el.tooltip_markup = "Add a user defined boolean property";
1004 this.el.label = "Boolean";
1007 this.el.activate.connect( ( ) =>{
1009 _this.addProp( "prop", "XXX", "true", "bool");
1013 // user defined functions
1016 public class Xcls_SeparatorMenuItem16 : Object
1018 public Gtk.SeparatorMenuItem el;
1019 private Xcls_LeftProps _this;
1025 public Xcls_SeparatorMenuItem16(Xcls_LeftProps _owner )
1028 this.el = new Gtk.SeparatorMenuItem();
1032 // set gobject values
1035 // user defined functions
1038 public class Xcls_MenuItem17 : Object
1040 public Gtk.MenuItem el;
1041 private Xcls_LeftProps _this;
1047 public Xcls_MenuItem17(Xcls_LeftProps _owner )
1050 this.el = new Gtk.MenuItem();
1054 // set gobject values
1055 this.el.tooltip_markup = "Add a user function boolean property";
1056 this.el.label = "Javascript Function";
1059 this.el.activate.connect( ( ) =>{
1061 _this.addProp("prop", "XXXX", "function() { }", "| function");
1065 // user defined functions
1068 public class Xcls_MenuItem18 : Object
1070 public Gtk.MenuItem el;
1071 private Xcls_LeftProps _this;
1077 public Xcls_MenuItem18(Xcls_LeftProps _owner )
1080 this.el = new Gtk.MenuItem();
1084 // set gobject values
1085 this.el.tooltip_markup = "Add a user function boolean property";
1086 this.el.label = "Vala Method";
1089 this.el.activate.connect( ( ) =>{
1091 _this.addProp( "prop", "XXXX", "() {\n\n}\n", "| return_type");
1095 // user defined functions
1098 public class Xcls_MenuItem19 : Object
1100 public Gtk.MenuItem el;
1101 private Xcls_LeftProps _this;
1107 public Xcls_MenuItem19(Xcls_LeftProps _owner )
1110 this.el = new Gtk.MenuItem();
1114 // set gobject values
1115 this.el.tooltip_markup = "Add a vala signal";
1116 this.el.label = "Vala Signal";
1119 this.el.activate.connect( ( ) =>{
1121 _this.addProp( "prop", "XXXX", "()", "@ void");
1125 // user defined functions
1128 public class Xcls_SeparatorMenuItem20 : Object
1130 public Gtk.SeparatorMenuItem el;
1131 private Xcls_LeftProps _this;
1137 public Xcls_SeparatorMenuItem20(Xcls_LeftProps _owner )
1140 this.el = new Gtk.SeparatorMenuItem();
1144 // set gobject values
1147 // user defined functions
1150 public class Xcls_MenuItem21 : Object
1152 public Gtk.MenuItem el;
1153 private Xcls_LeftProps _this;
1159 public Xcls_MenuItem21(Xcls_LeftProps _owner )
1162 this.el = new Gtk.MenuItem();
1166 // set gobject values
1167 this.el.tooltip_markup = "Add a flexy if (for HTML templates)";
1168 this.el.label = "Flexy - If";
1171 this.el.activate.connect( ( ) =>{
1173 _this.addProp("prop", "flexy:if", "value_or_condition", "string");
1177 // user defined functions
1180 public class Xcls_MenuItem22 : Object
1182 public Gtk.MenuItem el;
1183 private Xcls_LeftProps _this;
1189 public Xcls_MenuItem22(Xcls_LeftProps _owner )
1192 this.el = new Gtk.MenuItem();
1196 // set gobject values
1197 this.el.tooltip_markup = "Add a flexy include (for HTML templates)";
1198 this.el.label = "Flexy - Include";
1201 this.el.activate.connect( ( ) =>{
1203 _this.addProp("prop", "flexy:include", "name_of_file.html", "string");
1207 // user defined functions
1210 public class Xcls_MenuItem23 : Object
1212 public Gtk.MenuItem el;
1213 private Xcls_LeftProps _this;
1219 public Xcls_MenuItem23(Xcls_LeftProps _owner )
1222 this.el = new Gtk.MenuItem();
1226 // set gobject values
1227 this.el.tooltip_markup = "Add a flexy foreach (for HTML templates)";
1228 this.el.label = "Flexy - Foreach";
1231 this.el.activate.connect( ( ) =>{
1233 _this.addProp("prop", "flexy:foreach", "array,key,value", "string");
1237 // user defined functions
1243 public class Xcls_EditProps : Object
1245 public Gtk.ScrolledWindow el;
1246 private Xcls_LeftProps _this;
1250 public bool editing;
1253 public Xcls_EditProps(Xcls_LeftProps _owner )
1256 _this.EditProps = this;
1257 this.el = new Gtk.ScrolledWindow( null, null );
1260 this.editing = false;
1262 // set gobject values
1263 this.el.shadow_type = Gtk.ShadowType.IN;
1264 var child_0 = new Xcls_view( _this );
1266 this.el.add ( child_0.el );
1272 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
1276 // user defined functions
1278 public class Xcls_view : Object
1280 public Gtk.TreeView el;
1281 private Xcls_LeftProps _this;
1285 public Xcls_PopoverProperty popover;
1288 public Xcls_view(Xcls_LeftProps _owner )
1292 this.el = new Gtk.TreeView();
1295 this.popover = null;
1297 // set gobject values
1298 this.el.tooltip_column = 5;
1299 this.el.enable_tree_lines = true;
1300 this.el.headers_visible = true;
1301 var child_0 = new Xcls_model( _this );
1303 this.el.set_model ( child_0.el );
1304 var child_1 = new Xcls_keycol( _this );
1306 this.el.append_column ( child_1.el );
1307 var child_2 = new Xcls_valcol( _this );
1309 this.el.append_column ( child_2.el );
1310 var child_3 = new Xcls_ContextMenu( _this );
1316 var selection = this.el.get_selection();
1317 selection.set_mode( Gtk.SelectionMode.SINGLE);
1320 var description = new Pango.FontDescription();
1321 description.set_size(10000);
1322 this.el.override_font(description);
1326 this.el.button_press_event.connect( ( ev) => {
1328 Gtk.TreeViewColumn col;
1332 if (!this.el.get_path_at_pos((int)ev.x, (int) ev.y, out path, out col, out cell_x, out cell_y )) {
1333 print("nothing selected on click");
1334 GLib.Timeout.add_full(GLib.Priority.DEFAULT,10 , () => {
1335 this.el.get_selection().unselect_all();
1339 _this.before_edit();
1340 return false; //not on a element.
1344 // double click on name..
1345 if (ev.type == Gdk.EventType.2BUTTON_PRESS && ev.button == 1 && col.title == "Name") {
1348 if (this.popover == null) {
1349 this.popover = new Xcls_PopoverProperty();
1350 this.popover.mainwindow = _this.main_window;
1354 _this.before_edit();
1355 _this.stop_editor();
1357 _this.keyrender.el.stop_editing(false);
1358 _this.keyrender.el.editable =false;
1360 _this.valrender.el.stop_editing(false);
1361 _this.valrender.el.editable =false;
1363 var mod = this.el.get_model();
1364 mod.get_iter (out iter, path);
1367 GLib.Value gvaltype, gval;
1368 mod.get_value(iter, 1 , out gval); // one is key..
1370 mod.get_value(iter,0, out gvaltype);
1372 this.popover.show(this.el, _this.node, (string)gvaltype, (string)gval);
1374 // _this.startEditingKey(path);
1383 if (ev.type == Gdk.EventType.BUTTON_PRESS && ev.button == 3) {
1385 //if (col.title == "Value") {
1386 // _this.before_edit();
1390 var p = _this.ContextMenu;
1392 p.el.set_screen(Gdk.Screen.get_default());
1394 p.el.popup(null, null, null, ev.button, ev.time);
1395 //Seed.print("click:" + res.column.title);
1397 GLib.Timeout.add_full(GLib.Priority.DEFAULT,10 , () => {
1399 this.el.get_selection().select_path(path);
1402 _this.before_edit();
1407 if (col.title != "Value") {
1408 print("col title != Value");
1410 GLib.Timeout.add_full(GLib.Priority.DEFAULT,10 , () => {
1411 this.el.get_selection().select_path(path);
1415 _this.before_edit();
1416 // XObject.error("column is not value?");
1417 return false; // ignore.. - key click.. ??? should we do this??
1421 // if the cell can be edited with a pulldown
1422 // then we should return true... - and let the start_editing handle it?
1429 // _this.before_edit(); <<< we really need to stop the other editor..
1430 _this.keyrender.el.stop_editing(false);
1431 _this.keyrender.el.editable =false;
1434 return _this.startEditingValue(path); // assumes selected row..
1443 // user defined functions
1445 public class Xcls_model : Object
1447 public Gtk.TreeStore el;
1448 private Xcls_LeftProps _this;
1454 public Xcls_model(Xcls_LeftProps _owner )
1458 this.el = new Gtk.TreeStore( 7, typeof(string), // 0 key type
1459 typeof(string), // 1 key
1460 typeof(string), // 2 key (display)
1461 typeof(string), // 3 value
1462 typeof(string), // 4 value (display)
1463 typeof(string), // 5 both (tooltip)
1464 typeof(string) // 6 key (for sorting)
1469 // set gobject values
1472 // user defined functions
1475 public class Xcls_keycol : Object
1477 public Gtk.TreeViewColumn el;
1478 private Xcls_LeftProps _this;
1484 public Xcls_keycol(Xcls_LeftProps _owner )
1487 _this.keycol = this;
1488 this.el = new Gtk.TreeViewColumn();
1492 // set gobject values
1493 this.el.title = "Name";
1494 this.el.resizable = true;
1495 var child_0 = new Xcls_keyrender( _this );
1497 this.el.pack_start ( child_0.el , false );
1501 this.el.add_attribute(_this.keyrender.el , "markup", 2 );
1502 this.el.add_attribute(_this.keyrender.el , "text", 1 );
1505 // user defined functions
1507 public class Xcls_keyrender : Object
1509 public Gtk.CellRendererText el;
1510 private Xcls_LeftProps _this;
1516 public Xcls_keyrender(Xcls_LeftProps _owner )
1519 _this.keyrender = this;
1520 this.el = new Gtk.CellRendererText();
1524 // set gobject values
1527 this.el.editing_started.connect( ( editable, path) => {
1530 _this.model.el.get_iter(out iter, new Gtk.TreePath.from_string(path));
1535 // this.get('/LeftPanel.model').activePath = path;
1536 _this.model.el.get_value(iter,1, out gval);
1537 var val = (string)gval;
1539 ((Gtk.Entry)editable).set_text(val);
1541 this.el.edited.connect( (path, newtext) => {
1542 print("Keyrender - signal:edited\n");
1544 this.el.editable = false;
1549 _this.model.el.get_iter(out iter, new Gtk.TreePath.from_string(path));
1552 _this.model.el.get_value(iter,1, out gval);
1553 var oldval = (string)gval;
1555 _this.model.el.get_value(iter,0, out gval);
1556 var ktype = (string)gval;
1558 _this.model.el.set_value(iter, 1, newtext);
1560 if (oldval == newtext) {
1565 print("ktype: %s\n",ktype);
1568 var ov = _this.node.listeners.get(oldval);
1569 _this.node.listeners.set(newtext, ov);
1570 _this.node.listeners.unset(oldval);
1572 _this.updateIter(iter, ktype, newtext, ov);
1576 var ov = _this.node.props.get(oldval);
1577 _this.node.props.set(newtext, ov);
1578 _this.node.props.unset(oldval);
1579 _this.updateIter(iter, ktype, newtext, ov);
1587 // user defined functions
1591 public class Xcls_valcol : Object
1593 public Gtk.TreeViewColumn el;
1594 private Xcls_LeftProps _this;
1600 public Xcls_valcol(Xcls_LeftProps _owner )
1603 _this.valcol = this;
1604 this.el = new Gtk.TreeViewColumn();
1608 // set gobject values
1609 this.el.title = "Value";
1610 this.el.resizable = true;
1611 var child_0 = new Xcls_valrender( _this );
1613 this.el.pack_start ( child_0.el , true );
1619 // typeof(string), // 0 key type
1620 // typeof(string), // 1 key
1621 // typeof(string), // 2 key (display)
1622 // typeof(string), // 3 value
1623 // typeof(string) // 4 value (display)
1626 this.el.add_attribute(_this.valrender.el , "text", 4 );
1627 //this.el.add_attribute(_this.valrender.el , "sensitive", 4 );
1628 //this.el.add_attribute(this.items[0].el , 'editable', 3 );
1629 // this.el.set_cell_data_func(cell, age_cell_data_func, NULL, NULL);
1631 // this.get('/LeftPanel').editableColumn= this;
1635 // user defined functions
1637 public class Xcls_valrender : Object
1639 public Gtk.CellRendererCombo el;
1640 private Xcls_LeftProps _this;
1646 public Xcls_valrender(Xcls_LeftProps _owner )
1649 _this.valrender = this;
1650 this.el = new Gtk.CellRendererCombo();
1654 // set gobject values
1655 this.el.editable = false;
1656 this.el.text_column = 0;
1657 this.el.has_entry = true;
1658 var child_0 = new Xcls_valrendermodel( _this );
1660 this.el.model = child_0.el;
1663 this.el.editing_started.connect( ( editable, path) => {
1664 //_this.editing = true;
1665 print("editing started called\n");
1666 if (!_this.allow_edit) {
1668 print("val - editing_Started\n");
1669 this.el.editable = false; // make sure it's not editor...
1674 _this.allow_edit =false;
1677 if ( this.el.has_entry ) {
1680 _this.model.el.get_iter(out iter, new Gtk.TreePath.from_string(path));
1685 // this.get('/LeftPanel.model').activePath = path;
1686 _this.model.el.get_value(iter,3, out gval);
1689 var val = (string)gval;
1690 var combo = (Gtk.ComboBox)editable;
1692 var entry = (Gtk.Entry) combo.get_child();
1693 entry.set_text(val);
1697 this.el.edited.connect( (path, newtext) => {
1698 print("Valrender - signal:edited\n");
1700 this.el.editable = false;
1705 2, "<b>" + miter.get_key() + "</b>",
1706 3, miter.get_value(),
1707 4, display_value(short);
1713 _this.model.el.get_iter(out iter, new Gtk.TreePath.from_string(path));
1716 _this.model.el.get_value(iter,0, out gval);
1717 var ktype = (string)gval;
1720 _this.model.el.get_value(iter,3, out gval);
1721 var oldval = (string)gval;
1723 _this.model.el.get_value(iter,1, out gval);
1724 var key = (string)gval;
1730 _this.node.listeners.set(key, newtext);
1731 _this.updateIter(iter,ktype,key,newtext);
1734 _this.node.props.set(key,newtext);
1735 _this.updateIter(iter,ktype, key,newtext);
1738 // _this.load(_this.file,_this.node);
1744 // user defined functions
1745 public void setOptions (string[] ar) {
1746 var m = _this.valrendermodel.el;
1749 for (var i =0; i < ar.length; i++) {
1751 m.set_value(iret, 0, ar[i]);
1756 public class Xcls_valrendermodel : Object
1758 public Gtk.ListStore el;
1759 private Xcls_LeftProps _this;
1765 public Xcls_valrendermodel(Xcls_LeftProps _owner )
1768 _this.valrendermodel = this;
1769 this.el = new Gtk.ListStore( 1, typeof(string) );
1773 // set gobject values
1776 // user defined functions
1781 public class Xcls_ContextMenu : Object
1784 private Xcls_LeftProps _this;
1790 public Xcls_ContextMenu(Xcls_LeftProps _owner )
1793 _this.ContextMenu = this;
1794 this.el = new Gtk.Menu();
1798 // set gobject values
1799 var child_0 = new Xcls_MenuItem33( _this );
1801 this.el.append ( child_0.el );
1802 var child_1 = new Xcls_SeparatorMenuItem34( _this );
1804 this.el.append ( child_1.el );
1805 var child_2 = new Xcls_MenuItem35( _this );
1807 this.el.append ( child_2.el );
1810 // user defined functions
1812 public class Xcls_MenuItem33 : Object
1814 public Gtk.MenuItem el;
1815 private Xcls_LeftProps _this;
1821 public Xcls_MenuItem33(Xcls_LeftProps _owner )
1824 this.el = new Gtk.MenuItem();
1828 // set gobject values
1829 this.el.label = "Edit";
1832 this.el.activate.connect( ( ) =>{
1834 var s = _this.view.el.get_selection();
1836 Gtk.TreeModel model;
1837 s.get_selected (out model, out iter);
1838 _this.startEditingKey(model.get_path(iter));
1842 // user defined functions
1845 public class Xcls_SeparatorMenuItem34 : Object
1847 public Gtk.SeparatorMenuItem el;
1848 private Xcls_LeftProps _this;
1854 public Xcls_SeparatorMenuItem34(Xcls_LeftProps _owner )
1857 this.el = new Gtk.SeparatorMenuItem();
1861 // set gobject values
1864 // user defined functions
1867 public class Xcls_MenuItem35 : Object
1869 public Gtk.MenuItem el;
1870 private Xcls_LeftProps _this;
1876 public Xcls_MenuItem35(Xcls_LeftProps _owner )
1879 this.el = new Gtk.MenuItem();
1883 // set gobject values
1884 this.el.label = "Delete";
1887 this.el.activate.connect( ( ) =>{
1888 _this.deleteSelected();
1892 // user defined functions