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 before_edit ()
60 print("before edit - stop editing\n");
62 // these do not appear to trigger save...
63 _this.keyrender.el.stop_editing(false);
64 _this.keyrender.el.editable =false;
66 _this.valrender.el.stop_editing(false);
67 _this.valrender.el.editable =false;
70 // technicall stop the popup editor..
73 public string keySortFormat (string key) {
74 // listeners first - with 0
81 var bits = key.split(" ");
84 return "2 " + bits[bits.length -1];
88 return "3 " + bits[bits.length -1];
93 return "4 " + bits[bits.length -1];
96 return "5 " + bits[bits.length -1];
101 public void finish_editing () {
105 public bool startEditingValue ( Gtk.TreePath path) {
107 // ONLY return true if editing is allowed - eg. combo..
109 print("start editing?\n");
110 if (!this.stop_editor()) {
111 print("stop editor failed\n");
117 var mod = this.model.el;
118 mod.get_iter (out iter, path);
124 2, "<b>" + miter.get_key() + "</b>",
130 mod.get_value(iter, 3 , out gval);
131 var val = (string)gval;
133 mod.get_value(iter, 1 , out gval);
134 var key = (string)gval;
137 string kname, kflag, ktype;
138 this.node.normalize_key(key, out kname, out kflag, out ktype);
141 mod.get_value(iter, 0 , out gval);
142 var type = (string)gval; // listerner or prop..
146 var use_textarea = false;
148 //------------ things that require the text editor...
150 if (type == "listener") {
153 if (key.length > 0 && key[0] == '|') { // user defined method
156 if (key.length > 0 && key[0] == '$') { // raw string
159 if (key.length > 0 && key == "* init") {
162 if (val.length > 40) { // long value...
169 print("Call show editor\n");
170 GLib.Timeout.add_full(GLib.Priority.DEFAULT,10 , () => {
171 this.view.el.get_selection().select_path(path);
173 this.show_editor(file, node, type, key);
182 var pal = Palete.factory(this.file.project.xtype);
185 var has_opts = pal.typeOptions(this.node.fqn(), kname, ktype, out opts);
189 // others... - fill in options for true/false?
190 print("turn on editing %s \n" , mod.get_path(iter).to_string());
194 print("start editing try/false)???");
195 this.valrender.el.has_entry = false;
197 this.valrender.setOptions(opts);
199 this.valrender.el.has_entry = false;
200 this.valrender.el.editable = true;
201 this.allow_edit = true;
202 GLib.Timeout.add_full(GLib.Priority.DEFAULT,100 , () => {
203 this.view.el.set_cursor_on_cell(
214 // see if type is a Enum.
221 this.valrender.setOptions(opts);
223 GLib.Timeout.add_full(GLib.Priority.DEFAULT,10 , () => {
225 // at this point - work out the type...
226 // if its' a combo... then show the options..
227 this.valrender.el.has_entry = true;
229 this.valrender.el.editable = true;
232 this.allow_edit = true;
238 this.view.el.set_cursor_on_cell(
248 public void load (JsRender.JsRender file, JsRender.Node? node)
250 print("load leftprops\n");
256 this.model.el.clear();
258 //this.get('/RightEditor').el.hide();
265 //var provider = this.get('/LeftTree').getPaleteProvider();
268 //typeof(string), // 0 key type
269 //typeof(string), // 1 key
270 //typeof(string), // 2 key (display)
271 //typeof(string), // 3 value
272 //typeof(string), // 4 value (display)
273 //typeof(string), // 5 both (tooltip)
278 // really need a way to sort the hashmap...
279 var m = this.model.el;
281 var miter = node.listeners.map_iterator();
284 while(miter.next()) {
286 m.append(out iter,null);
288 this.updateIter(iter, "listener", miter.get_key(), miter.get_value());
294 miter = node.props.map_iterator();
297 while(miter.next()) {
299 m.append(out iter,null);
300 this.updateIter(iter, "prop", miter.get_key(), miter.get_value());
303 print("clear selection\n");
305 this.model.el.set_sort_column_id(6,Gtk.SortType.ASCENDING); // sort by real key..
307 this.view.el.get_selection().unselect_all();
309 var pane = _this.main_window.editpane.el;
310 var try_size = (i * 25) + 60; // est. 20px per line + 40px header
314 ((try_size * 1.0f) / (pane.max_position * 1.0f)) > 0.8f ?
315 (int) (pane.max_position * 0.2f) :
316 pane.max_position-try_size);
320 public string keyFormat (string val, string type) {
322 // Glib.markup_escape_text(val);
324 if (type == "listener") {
325 return "<span font_weight=\"bold\" color=\"#660000\">" +
326 GLib.Markup.escape_text(val) +
330 if (val.length < 1) {
331 return "<span color=\"#FF0000\">--empty--</span>";
336 //# - object properties
338 // all of these... - display value is last element..
339 var ar = val.strip().split(" ");
342 var dval = GLib.Markup.escape_text(ar[ar.length-1]);
348 case '@': // signal // just bold balck?
349 if (dval[0] == '@') {
350 dval = dval.substring(1);
353 return @"<span font_weight=\"bold\">@ $dval</span>";
354 case '#': // object properties?
355 if (dval[0] == '#') {
356 dval = dval.substring(1);
358 return @"<span font_weight=\"bold\">$dval</span>";
360 if (dval[0] == '*') {
361 dval = dval.substring(1);
363 return @"<span color=\"#0000CC\" font_weight=\"bold\">$dval</span>";
365 if (dval[0] == '$') {
366 dval = dval.substring(1);
368 return @"<span style=\"italic\">$dval</span>";
369 case '|': // user defined methods
370 if (dval[0] == '|') {
371 dval = dval.substring(1);
373 return @"<span color=\"#008000\" font_weight=\"bold\">$dval</span>";
384 public void deleteSelected () {
389 var s = this.view.el.get_selection();
390 s.get_selected(out mod, out iter);
394 mod.get_value(iter, 0 , out gval);
395 var type = (string)gval;
397 mod.get_value(iter, 1 , out gval);
398 var key = (string)gval;
402 this.node.listeners.unset(key);
406 this.node.props.unset(key);
409 this.load(this.file, this.node);
413 public void startEditingKey ( Gtk.TreePath path) {
415 if (!this.stop_editor()) {
419 // others... - fill in options for true/false?
422 GLib.Timeout.add_full(GLib.Priority.DEFAULT,10 , () => {
423 this.allow_edit = true;
424 this.keyrender.el.editable = true;
426 this.view.el.set_cursor_on_cell(
438 public Gtk.TreeIter keyToIter (string oldkey, string type, string key, string kvalue) {
440 var m = _this.model.el;
443 m.foreach((model, path, iter) => {
448 GLib.Value gvaltype, gval;
449 mod.get_value(iter, 1 , out gval); // one is key..
451 mod.get_value(iter,0, out gvaltype);
453 if (oldkey == ((string)gval) && type == ((string)gvaltype)) {
454 this.updateIter(iter, type, key, kvalue);
465 public void addProp (string in_type, string key, string value, string value_type) {
466 // info includes key, val, skel, etype..
467 //console.dump(info);
468 //type = info.type.toLowerCase();
469 //var data = this.toJS();
471 var type = in_type == "signals" ? "listener" : in_type;
473 var fkey = (value_type.length > 0 ? value_type + " " : "") + key;
475 if (type == "listener") {
476 if (this.node.listeners.has_key(key)) {
479 this.node.listeners.set(key,value);
482 if (this.node.props.has_key(fkey)) {
485 this.node.props.set(fkey,value);
490 this.load(this.file, this.node);
494 /// need to find the row which I've just added..
497 var s = this.view.el.get_selection();
500 print("trying to find new iter");
502 this.model.el.foreach((model, path, iter) => {
505 this.model.el.get_value(iter, 0 , out gval);
506 if ((string)gval != type) {
507 print("not type: %s = %s\n", (string)gval , type);
510 this.model.el.get_value(iter, 1 , out gval);
511 if ((string)gval != fkey) {
512 print("not key: %s = %s\n", (string)gval , fkey);
516 GLib.Timeout.add_full(GLib.Priority.DEFAULT,40 , () => {
518 this.startEditingValue(this.model.el.get_path(iter));
521 //s.select_iter(iter);
529 public void updateIter (Gtk.TreeIter iter, string type, string key, string value) {
531 print("update Iter %s, %s\n", key,value);
532 //typeof(string), // 0 key type
533 //typeof(string), // 1 key
534 //typeof(string), // 2 key (display)
535 //typeof(string), // 3 value
536 //typeof(string), // 4 value (display)
537 //typeof(string), // 5 both (tooltip)
538 //typeof(string), // 6 key (sort)
540 var dl = value.strip().split("\n");
542 var dis_val = dl.length > 1 ? (dl[0].strip()+ "...") : dl[0];
544 if (type == "listener") {
548 this.model.el.set(iter,
551 2, this.keyFormat(key ,type),
554 5, "<tt>" + GLib.Markup.escape_text(key + " " +value) + "</tt>",
562 this.model.el.set(iter,
565 2, this.keyFormat(key , "prop"),
568 5, "<tt>" + GLib.Markup.escape_text(key + " " + value) + "</tt>",
569 6, this.keySortFormat(key)
572 public class Xcls_Box2 : Object
575 private Xcls_LeftProps _this;
581 public Xcls_Box2(Xcls_LeftProps _owner )
584 this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
588 // set gobject values
589 var child_0 = new Xcls_Button3( _this );
591 this.el.add ( child_0.el );
594 // user defined functions
596 public class Xcls_Button3 : Object
598 public Gtk.Button el;
599 private Xcls_LeftProps _this;
605 public Xcls_Button3(Xcls_LeftProps _owner )
608 this.el = new Gtk.Button();
612 // set gobject values
613 this.el.hexpand = true;
614 var child_0 = new Xcls_Box4( _this );
616 this.el.add ( child_0.el );
617 var child_1 = new Xcls_AddPropertyPopup( _this );
621 this.el.button_press_event.connect( (self, ev) => {
625 var p = _this.AddPropertyPopup;
626 p.el.set_screen(Gdk.Screen.get_default());
628 p.el.popup(null, null, null, ev.button, ev.time);
633 // user defined functions
635 public class Xcls_Box4 : Object
638 private Xcls_LeftProps _this;
644 public Xcls_Box4(Xcls_LeftProps _owner )
647 this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
651 // set gobject values
652 var child_0 = new Xcls_Image5( _this );
654 this.el.add ( child_0.el );
655 var child_1 = new Xcls_Label6( _this );
657 this.el.add ( child_1.el );
660 // user defined functions
662 public class Xcls_Image5 : Object
665 private Xcls_LeftProps _this;
671 public Xcls_Image5(Xcls_LeftProps _owner )
674 this.el = new Gtk.Image();
678 // set gobject values
679 this.el.stock = Gtk.Stock.ADD;
680 this.el.icon_size = Gtk.IconSize.MENU;
683 // user defined functions
686 public class Xcls_Label6 : Object
689 private Xcls_LeftProps _this;
695 public Xcls_Label6(Xcls_LeftProps _owner )
698 this.el = new Gtk.Label( "Other" );
702 // set gobject values
705 // user defined functions
709 public class Xcls_AddPropertyPopup : Object
712 private Xcls_LeftProps _this;
718 public Xcls_AddPropertyPopup(Xcls_LeftProps _owner )
721 _this.AddPropertyPopup = this;
722 this.el = new Gtk.Menu();
726 // set gobject values
727 var child_0 = new Xcls_MenuItem8( _this );
729 this.el.append ( child_0.el );
730 var child_1 = new Xcls_MenuItem9( _this );
732 this.el.append ( child_1.el );
733 var child_2 = new Xcls_MenuItem10( _this );
735 this.el.append ( child_2.el );
736 var child_3 = new Xcls_MenuItem11( _this );
738 this.el.append ( child_3.el );
739 var child_4 = new Xcls_SeparatorMenuItem12( _this );
741 this.el.add ( child_4.el );
742 var child_5 = new Xcls_MenuItem13( _this );
744 this.el.append ( child_5.el );
745 var child_6 = new Xcls_MenuItem14( _this );
747 this.el.append ( child_6.el );
748 var child_7 = new Xcls_MenuItem15( _this );
750 this.el.append ( child_7.el );
751 var child_8 = new Xcls_SeparatorMenuItem16( _this );
753 this.el.add ( child_8.el );
754 var child_9 = new Xcls_MenuItem17( _this );
756 this.el.append ( child_9.el );
757 var child_10 = new Xcls_MenuItem18( _this );
759 this.el.append ( child_10.el );
760 var child_11 = new Xcls_MenuItem19( _this );
762 this.el.append ( child_11.el );
763 var child_12 = new Xcls_SeparatorMenuItem20( _this );
765 this.el.add ( child_12.el );
766 var child_13 = new Xcls_MenuItem21( _this );
768 this.el.append ( child_13.el );
769 var child_14 = new Xcls_MenuItem22( _this );
771 this.el.append ( child_14.el );
772 var child_15 = new Xcls_MenuItem23( _this );
774 this.el.append ( child_15.el );
777 // user defined functions
779 public class Xcls_MenuItem8 : Object
781 public Gtk.MenuItem el;
782 private Xcls_LeftProps _this;
788 public Xcls_MenuItem8(Xcls_LeftProps _owner )
791 this.el = new Gtk.MenuItem();
795 // set gobject values
796 this.el.tooltip_markup = "Using _this.{ID} will map to this element";
797 this.el.label = "id: _this.{ID} (Vala)";
800 this.el.activate.connect( () => {
801 _this.addProp( "prop", "id", "", "");
805 // user defined functions
808 public class Xcls_MenuItem9 : Object
810 public Gtk.MenuItem el;
811 private Xcls_LeftProps _this;
817 public Xcls_MenuItem9(Xcls_LeftProps _owner )
820 this.el = new Gtk.MenuItem();
824 // set gobject values
825 this.el.tooltip_markup = "how to pack this element onto parent, (method, 2nd arg, 3rd arg) .. the 1st argument is filled by the element";
826 this.el.label = "pack: Pack method (Vala)";
829 this.el.activate.connect( ( ) => {
831 _this.addProp( "prop", "pack","add", "*");
835 // user defined functions
838 public class Xcls_MenuItem10 : Object
840 public Gtk.MenuItem el;
841 private Xcls_LeftProps _this;
847 public Xcls_MenuItem10(Xcls_LeftProps _owner )
850 this.el = new Gtk.MenuItem();
854 // set gobject values
855 this.el.tooltip_markup = "eg. \n\nnew Clutter.Image.from_file(.....)";
856 this.el.label = "ctor: Alterative to default contructor";
859 this.el.activate.connect( ( ) => {
861 _this.addProp( "prop", "ctor","", "*");
865 // user defined functions
868 public class Xcls_MenuItem11 : Object
870 public Gtk.MenuItem el;
871 private Xcls_LeftProps _this;
877 public Xcls_MenuItem11(Xcls_LeftProps _owner )
880 this.el = new Gtk.MenuItem();
884 // set gobject values
885 this.el.tooltip_markup = "This code is called after the ctor";
886 this.el.label = "init: initialziation code (vala)";
889 this.el.activate.connect( ( ) => {
891 _this.addProp( "prop", "init", "{\n\n}\n", "*" );
895 // user defined functions
898 public class Xcls_SeparatorMenuItem12 : Object
900 public Gtk.SeparatorMenuItem el;
901 private Xcls_LeftProps _this;
907 public Xcls_SeparatorMenuItem12(Xcls_LeftProps _owner )
910 this.el = new Gtk.SeparatorMenuItem();
914 // set gobject values
917 // user defined functions
920 public class Xcls_MenuItem13 : Object
922 public Gtk.MenuItem el;
923 private Xcls_LeftProps _this;
929 public Xcls_MenuItem13(Xcls_LeftProps _owner )
932 this.el = new Gtk.MenuItem();
936 // set gobject values
937 this.el.tooltip_markup = "Add a user defined string property";
938 this.el.label = "String";
941 this.el.activate.connect( (self) => {
943 _this.addProp( "prop", "XXXX", "","string");
948 // user defined functions
951 public class Xcls_MenuItem14 : Object
953 public Gtk.MenuItem el;
954 private Xcls_LeftProps _this;
960 public Xcls_MenuItem14(Xcls_LeftProps _owner )
963 this.el = new Gtk.MenuItem();
967 // set gobject values
968 this.el.tooltip_markup = "Add a user defined number property";
969 this.el.label = "Number";
972 this.el.activate.connect( ( ) =>{
974 _this.addProp("prop", "XXX", "0", "int");
978 // user defined functions
981 public class Xcls_MenuItem15 : Object
983 public Gtk.MenuItem el;
984 private Xcls_LeftProps _this;
990 public Xcls_MenuItem15(Xcls_LeftProps _owner )
993 this.el = new Gtk.MenuItem();
997 // set gobject values
998 this.el.tooltip_markup = "Add a user defined boolean property";
999 this.el.label = "Boolean";
1002 this.el.activate.connect( ( ) =>{
1004 _this.addProp( "prop", "XXX", "true", "bool");
1008 // user defined functions
1011 public class Xcls_SeparatorMenuItem16 : Object
1013 public Gtk.SeparatorMenuItem el;
1014 private Xcls_LeftProps _this;
1020 public Xcls_SeparatorMenuItem16(Xcls_LeftProps _owner )
1023 this.el = new Gtk.SeparatorMenuItem();
1027 // set gobject values
1030 // user defined functions
1033 public class Xcls_MenuItem17 : Object
1035 public Gtk.MenuItem el;
1036 private Xcls_LeftProps _this;
1042 public Xcls_MenuItem17(Xcls_LeftProps _owner )
1045 this.el = new Gtk.MenuItem();
1049 // set gobject values
1050 this.el.tooltip_markup = "Add a user function boolean property";
1051 this.el.label = "Javascript Function";
1054 this.el.activate.connect( ( ) =>{
1056 _this.addProp("prop", "XXXX", "function() { }", "| function");
1060 // user defined functions
1063 public class Xcls_MenuItem18 : Object
1065 public Gtk.MenuItem el;
1066 private Xcls_LeftProps _this;
1072 public Xcls_MenuItem18(Xcls_LeftProps _owner )
1075 this.el = new Gtk.MenuItem();
1079 // set gobject values
1080 this.el.tooltip_markup = "Add a user function boolean property";
1081 this.el.label = "Vala Method";
1084 this.el.activate.connect( ( ) =>{
1086 _this.addProp( "prop", "XXXX", "() {\n\n}\n", "| return_type");
1090 // user defined functions
1093 public class Xcls_MenuItem19 : Object
1095 public Gtk.MenuItem el;
1096 private Xcls_LeftProps _this;
1102 public Xcls_MenuItem19(Xcls_LeftProps _owner )
1105 this.el = new Gtk.MenuItem();
1109 // set gobject values
1110 this.el.tooltip_markup = "Add a vala signal";
1111 this.el.label = "Vala Signal";
1114 this.el.activate.connect( ( ) =>{
1116 _this.addProp( "prop", "XXXX", "()", "@ void");
1120 // user defined functions
1123 public class Xcls_SeparatorMenuItem20 : Object
1125 public Gtk.SeparatorMenuItem el;
1126 private Xcls_LeftProps _this;
1132 public Xcls_SeparatorMenuItem20(Xcls_LeftProps _owner )
1135 this.el = new Gtk.SeparatorMenuItem();
1139 // set gobject values
1142 // user defined functions
1145 public class Xcls_MenuItem21 : Object
1147 public Gtk.MenuItem el;
1148 private Xcls_LeftProps _this;
1154 public Xcls_MenuItem21(Xcls_LeftProps _owner )
1157 this.el = new Gtk.MenuItem();
1161 // set gobject values
1162 this.el.tooltip_markup = "Add a flexy if (for HTML templates)";
1163 this.el.label = "Flexy - If";
1166 this.el.activate.connect( ( ) =>{
1168 _this.addProp("prop", "flexy:if", "value_or_condition", "string");
1172 // user defined functions
1175 public class Xcls_MenuItem22 : Object
1177 public Gtk.MenuItem el;
1178 private Xcls_LeftProps _this;
1184 public Xcls_MenuItem22(Xcls_LeftProps _owner )
1187 this.el = new Gtk.MenuItem();
1191 // set gobject values
1192 this.el.tooltip_markup = "Add a flexy include (for HTML templates)";
1193 this.el.label = "Flexy - Include";
1196 this.el.activate.connect( ( ) =>{
1198 _this.addProp("prop", "flexy:include", "name_of_file.html", "string");
1202 // user defined functions
1205 public class Xcls_MenuItem23 : Object
1207 public Gtk.MenuItem el;
1208 private Xcls_LeftProps _this;
1214 public Xcls_MenuItem23(Xcls_LeftProps _owner )
1217 this.el = new Gtk.MenuItem();
1221 // set gobject values
1222 this.el.tooltip_markup = "Add a flexy foreach (for HTML templates)";
1223 this.el.label = "Flexy - Foreach";
1226 this.el.activate.connect( ( ) =>{
1228 _this.addProp("prop", "flexy:foreach", "array,key,value", "string");
1232 // user defined functions
1238 public class Xcls_EditProps : Object
1240 public Gtk.ScrolledWindow el;
1241 private Xcls_LeftProps _this;
1245 public bool editing;
1248 public Xcls_EditProps(Xcls_LeftProps _owner )
1251 _this.EditProps = this;
1252 this.el = new Gtk.ScrolledWindow( null, null );
1255 this.editing = false;
1257 // set gobject values
1258 this.el.shadow_type = Gtk.ShadowType.IN;
1259 var child_0 = new Xcls_view( _this );
1261 this.el.add ( child_0.el );
1267 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
1271 // user defined functions
1273 public class Xcls_view : Object
1275 public Gtk.TreeView el;
1276 private Xcls_LeftProps _this;
1280 public Xcls_PopoverProperty popover;
1283 public Xcls_view(Xcls_LeftProps _owner )
1287 this.el = new Gtk.TreeView();
1290 this.popover = null;
1292 // set gobject values
1293 this.el.tooltip_column = 5;
1294 this.el.enable_tree_lines = true;
1295 this.el.headers_visible = true;
1296 var child_0 = new Xcls_model( _this );
1298 this.el.set_model ( child_0.el );
1299 var child_1 = new Xcls_keycol( _this );
1301 this.el.append_column ( child_1.el );
1302 var child_2 = new Xcls_valcol( _this );
1304 this.el.append_column ( child_2.el );
1305 var child_3 = new Xcls_ContextMenu( _this );
1311 var selection = this.el.get_selection();
1312 selection.set_mode( Gtk.SelectionMode.SINGLE);
1315 var description = new Pango.FontDescription();
1316 description.set_size(10000);
1317 this.el.override_font(description);
1321 this.el.button_press_event.connect( ( ev) => {
1323 Gtk.TreeViewColumn col;
1327 if (!this.el.get_path_at_pos((int)ev.x, (int) ev.y, out path, out col, out cell_x, out cell_y )) {
1328 print("nothing selected on click");
1329 GLib.Timeout.add_full(GLib.Priority.DEFAULT,10 , () => {
1330 this.el.get_selection().unselect_all();
1334 _this.before_edit();
1335 return false; //not on a element.
1339 // double click on name..
1340 if (ev.type == Gdk.EventType.2BUTTON_PRESS && ev.button == 1 && col.title == "Name") {
1343 if (this.popover == null) {
1344 this.popover = new Xcls_PopoverProperty();
1345 this.popover.mainwindow = _this.main_window;
1349 _this.before_edit();
1351 _this.keyrender.el.stop_editing(false);
1352 _this.keyrender.el.editable =false;
1354 _this.valrender.el.stop_editing(false);
1355 _this.valrender.el.editable =false;
1357 var mod = this.el.get_model();
1358 mod.get_iter (out iter, path);
1361 GLib.Value gvaltype, gval;
1362 mod.get_value(iter, 1 , out gval); // one is key..
1364 mod.get_value(iter,0, out gvaltype);
1366 //this.popover.show(this.el, _this.node, (string)gvaltype, (string)gval);
1368 _this.startEditingKey(path);
1377 if (ev.type == Gdk.EventType.BUTTON_PRESS && ev.button == 3) {
1379 //if (col.title == "Value") {
1380 // _this.before_edit();
1384 var p = _this.ContextMenu;
1386 p.el.set_screen(Gdk.Screen.get_default());
1388 p.el.popup(null, null, null, ev.button, ev.time);
1389 //Seed.print("click:" + res.column.title);
1391 GLib.Timeout.add_full(GLib.Priority.DEFAULT,10 , () => {
1393 this.el.get_selection().select_path(path);
1396 _this.before_edit();
1401 if (col.title != "Value") {
1402 print("col title != Value");
1404 GLib.Timeout.add_full(GLib.Priority.DEFAULT,10 , () => {
1405 this.el.get_selection().select_path(path);
1409 _this.before_edit();
1410 // XObject.error("column is not value?");
1411 return false; // ignore.. - key click.. ??? should we do this??
1415 // if the cell can be edited with a pulldown
1416 // then we should return true... - and let the start_editing handle it?
1423 // _this.before_edit(); <<< we really need to stop the other editor..
1424 _this.keyrender.el.stop_editing(false);
1425 _this.keyrender.el.editable =false;
1428 return _this.startEditingValue(path); // assumes selected row..
1437 // user defined functions
1439 public class Xcls_model : Object
1441 public Gtk.TreeStore el;
1442 private Xcls_LeftProps _this;
1448 public Xcls_model(Xcls_LeftProps _owner )
1452 this.el = new Gtk.TreeStore( 7, typeof(string), // 0 key type
1453 typeof(string), // 1 key
1454 typeof(string), // 2 key (display)
1455 typeof(string), // 3 value
1456 typeof(string), // 4 value (display)
1457 typeof(string), // 5 both (tooltip)
1458 typeof(string) // 6 key (for sorting)
1463 // set gobject values
1466 // user defined functions
1469 public class Xcls_keycol : Object
1471 public Gtk.TreeViewColumn el;
1472 private Xcls_LeftProps _this;
1478 public Xcls_keycol(Xcls_LeftProps _owner )
1481 _this.keycol = this;
1482 this.el = new Gtk.TreeViewColumn();
1486 // set gobject values
1487 this.el.title = "Name";
1488 this.el.resizable = true;
1489 var child_0 = new Xcls_keyrender( _this );
1491 this.el.pack_start ( child_0.el , false );
1495 this.el.add_attribute(_this.keyrender.el , "markup", 2 );
1496 this.el.add_attribute(_this.keyrender.el , "text", 1 );
1499 // user defined functions
1501 public class Xcls_keyrender : Object
1503 public Gtk.CellRendererText el;
1504 private Xcls_LeftProps _this;
1510 public Xcls_keyrender(Xcls_LeftProps _owner )
1513 _this.keyrender = this;
1514 this.el = new Gtk.CellRendererText();
1518 // set gobject values
1521 this.el.editing_started.connect( ( editable, path) => {
1524 _this.model.el.get_iter(out iter, new Gtk.TreePath.from_string(path));
1529 // this.get('/LeftPanel.model').activePath = path;
1530 _this.model.el.get_value(iter,1, out gval);
1531 var val = (string)gval;
1533 ((Gtk.Entry)editable).set_text(val);
1535 this.el.edited.connect( (path, newtext) => {
1536 print("Keyrender - signal:edited\n");
1538 this.el.editable = false;
1543 _this.model.el.get_iter(out iter, new Gtk.TreePath.from_string(path));
1546 _this.model.el.get_value(iter,1, out gval);
1547 var oldval = (string)gval;
1549 _this.model.el.get_value(iter,0, out gval);
1550 var ktype = (string)gval;
1552 _this.model.el.set_value(iter, 1, newtext);
1554 if (oldval == newtext) {
1559 print("ktype: %s\n",ktype);
1562 var ov = _this.node.listeners.get(oldval);
1563 _this.node.listeners.set(newtext, ov);
1564 _this.node.listeners.unset(oldval);
1566 _this.updateIter(iter, ktype, newtext, ov);
1570 var ov = _this.node.props.get(oldval);
1571 _this.node.props.set(newtext, ov);
1572 _this.node.props.unset(oldval);
1573 _this.updateIter(iter, ktype, newtext, ov);
1581 // user defined functions
1585 public class Xcls_valcol : Object
1587 public Gtk.TreeViewColumn el;
1588 private Xcls_LeftProps _this;
1594 public Xcls_valcol(Xcls_LeftProps _owner )
1597 _this.valcol = this;
1598 this.el = new Gtk.TreeViewColumn();
1602 // set gobject values
1603 this.el.title = "Value";
1604 this.el.resizable = true;
1605 var child_0 = new Xcls_valrender( _this );
1607 this.el.pack_start ( child_0.el , true );
1613 // typeof(string), // 0 key type
1614 // typeof(string), // 1 key
1615 // typeof(string), // 2 key (display)
1616 // typeof(string), // 3 value
1617 // typeof(string) // 4 value (display)
1620 this.el.add_attribute(_this.valrender.el , "text", 4 );
1621 //this.el.add_attribute(_this.valrender.el , "sensitive", 4 );
1622 //this.el.add_attribute(this.items[0].el , 'editable', 3 );
1623 // this.el.set_cell_data_func(cell, age_cell_data_func, NULL, NULL);
1625 // this.get('/LeftPanel').editableColumn= this;
1629 // user defined functions
1631 public class Xcls_valrender : Object
1633 public Gtk.CellRendererCombo el;
1634 private Xcls_LeftProps _this;
1640 public Xcls_valrender(Xcls_LeftProps _owner )
1643 _this.valrender = this;
1644 this.el = new Gtk.CellRendererCombo();
1648 // set gobject values
1649 this.el.editable = false;
1650 this.el.text_column = 0;
1651 this.el.has_entry = true;
1652 var child_0 = new Xcls_valrendermodel( _this );
1654 this.el.model = child_0.el;
1657 this.el.editing_started.connect( ( editable, path) => {
1658 //_this.editing = true;
1659 print("editing started called\n");
1660 if (!_this.allow_edit) {
1662 print("val - editing_Started\n");
1663 this.el.editable = false; // make sure it's not editor...
1668 _this.allow_edit =false;
1671 if ( this.el.has_entry ) {
1674 _this.model.el.get_iter(out iter, new Gtk.TreePath.from_string(path));
1679 // this.get('/LeftPanel.model').activePath = path;
1680 _this.model.el.get_value(iter,3, out gval);
1683 var val = (string)gval;
1684 var combo = (Gtk.ComboBox)editable;
1686 var entry = (Gtk.Entry) combo.get_child();
1687 entry.set_text(val);
1691 this.el.edited.connect( (path, newtext) => {
1692 print("Valrender - signal:edited\n");
1694 this.el.editable = false;
1699 2, "<b>" + miter.get_key() + "</b>",
1700 3, miter.get_value(),
1701 4, display_value(short);
1707 _this.model.el.get_iter(out iter, new Gtk.TreePath.from_string(path));
1710 _this.model.el.get_value(iter,0, out gval);
1711 var ktype = (string)gval;
1714 _this.model.el.get_value(iter,3, out gval);
1715 var oldval = (string)gval;
1717 _this.model.el.get_value(iter,1, out gval);
1718 var key = (string)gval;
1724 _this.node.listeners.set(key, newtext);
1725 _this.updateIter(iter,ktype,key,newtext);
1728 _this.node.props.set(key,newtext);
1729 _this.updateIter(iter,ktype, key,newtext);
1732 // _this.load(_this.file,_this.node);
1738 // user defined functions
1739 public void setOptions (string[] ar) {
1740 var m = _this.valrendermodel.el;
1743 for (var i =0; i < ar.length; i++) {
1745 m.set_value(iret, 0, ar[i]);
1750 public class Xcls_valrendermodel : Object
1752 public Gtk.ListStore el;
1753 private Xcls_LeftProps _this;
1759 public Xcls_valrendermodel(Xcls_LeftProps _owner )
1762 _this.valrendermodel = this;
1763 this.el = new Gtk.ListStore( 1, typeof(string) );
1767 // set gobject values
1770 // user defined functions
1775 public class Xcls_ContextMenu : Object
1778 private Xcls_LeftProps _this;
1784 public Xcls_ContextMenu(Xcls_LeftProps _owner )
1787 _this.ContextMenu = this;
1788 this.el = new Gtk.Menu();
1792 // set gobject values
1793 var child_0 = new Xcls_MenuItem33( _this );
1795 this.el.append ( child_0.el );
1796 var child_1 = new Xcls_SeparatorMenuItem34( _this );
1798 this.el.append ( child_1.el );
1799 var child_2 = new Xcls_MenuItem35( _this );
1801 this.el.append ( child_2.el );
1804 // user defined functions
1806 public class Xcls_MenuItem33 : Object
1808 public Gtk.MenuItem el;
1809 private Xcls_LeftProps _this;
1815 public Xcls_MenuItem33(Xcls_LeftProps _owner )
1818 this.el = new Gtk.MenuItem();
1822 // set gobject values
1823 this.el.label = "Edit";
1826 this.el.activate.connect( ( ) =>{
1828 var s = _this.view.el.get_selection();
1830 Gtk.TreeModel model;
1831 s.get_selected (out model, out iter);
1832 _this.startEditingKey(model.get_path(iter));
1836 // user defined functions
1839 public class Xcls_SeparatorMenuItem34 : Object
1841 public Gtk.SeparatorMenuItem el;
1842 private Xcls_LeftProps _this;
1848 public Xcls_SeparatorMenuItem34(Xcls_LeftProps _owner )
1851 this.el = new Gtk.SeparatorMenuItem();
1855 // set gobject values
1858 // user defined functions
1861 public class Xcls_MenuItem35 : Object
1863 public Gtk.MenuItem el;
1864 private Xcls_LeftProps _this;
1870 public Xcls_MenuItem35(Xcls_LeftProps _owner )
1873 this.el = new Gtk.MenuItem();
1877 // set gobject values
1878 this.el.label = "Delete";
1881 this.el.activate.connect( ( ) =>{
1882 _this.deleteSelected();
1886 // user defined functions