Fix #7242 - see if i can get the parent child tree.. from vala
[roobuilder] / src / Builder4 / WindowLeftProps.bjs
1 {
2  "build_module" : "builder",
3  "items" : [
4   {
5    "# JsRender.JsRender file" : "",
6    "# JsRender.Node node" : "",
7    "# Xcls_MainWindow main_window" : "null",
8    "# bool allow_edit" : false,
9    "$ homogeneous" : "false   ",
10    "$ xns" : "Gtk",
11    "@ bool stop_editor" : "()",
12    "@ void changed" : "()",
13    "@ void show_add_props" : "(string type)",
14    "@ void show_editor" : "(JsRender.JsRender file, JsRender.Node node, string type, string key)",
15    "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
16    "id" : "LeftProps",
17    "items" : [
18     {
19      "$ xns" : "Gtk",
20      "* pack" : "pack_start,false,true,0",
21      "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
22      "items" : [
23       {
24        "$ xns" : "Gtk",
25        "* pack" : "add",
26        "int margin_left" : 5,
27        "int margin_right" : 5,
28        "string label" : "Add:",
29        "xtype" : "Label"
30       },
31       {
32        "$ xns" : "Gtk",
33        "* pack" : "add",
34        "bool hexpand" : true,
35        "items" : [
36         {
37          "$ xns" : "Gtk",
38          "* pack" : false,
39          "id" : "AddPropertyPopup",
40          "items" : [
41           {
42            "$ xns" : "Gtk",
43            "* pack" : "append",
44            "label" : "id: _this.{ID} (Vala)",
45            "listeners" : {
46             "activate" : [
47              " ()  => {",
48              "    _this.addProp( \"prop\", \"id\", \"\", \"\");",
49              "}"
50             ]
51            },
52            "tooltip_markup" : "Using _this.{ID} will map to this element",
53            "xtype" : "MenuItem"
54           },
55           {
56            "$ xns" : "Gtk",
57            "* pack" : "append",
58            "label" : "pack: Pack method (Vala)",
59            "listeners" : {
60             "activate" : [
61              "  ( ) => {",
62              "",
63              "    _this.addProp( \"prop\", \"pack\",\"add\", \"*\");",
64              "}"
65             ]
66            },
67            "tooltip_markup" : "how to pack this element onto parent, (method, 2nd arg, 3rd arg) .. the 1st argument is filled by the element",
68            "xtype" : "MenuItem"
69           },
70           {
71            "$ xns" : "Gtk",
72            "* pack" : "append",
73            "label" : "ctor: Alterative to default contructor (Vala)",
74            "listeners" : {
75             "activate" : [
76              "  ( ) => {",
77              "",
78              "    _this.addProp( \"prop\", \"ctor\",\"\", \"*\");",
79              "}"
80             ]
81            },
82            "tooltip_markup" : [
83             "eg. ",
84             "",
85             "new Clutter.Image.from_file(.....)"
86            ],
87            "xtype" : "MenuItem"
88           },
89           {
90            "$ xns" : "Gtk",
91            "* pack" : "append",
92            "label" : "init: initialziation code (vala)",
93            "listeners" : {
94             "activate" : [
95              "  ( ) => {",
96              "",
97              "    _this.addProp( \"prop\",  \"init\", \"{\\n\\n}\\n\", \"*\" );",
98              "}"
99             ]
100            },
101            "tooltip_markup" : "This code is called after the ctor",
102            "xtype" : "MenuItem"
103           },
104           {
105            "$ xns" : "Gtk",
106            "* pack" : "append",
107            "label" : "cms-id: (Roo JS/Pman library)",
108            "listeners" : {
109             "activate" : [
110              " ()  => {",
111              "    _this.addProp( \"prop\", \"cms-id\", \"\", \"string\");",
112              "}"
113             ]
114            },
115            "tooltip_markup" : [
116             "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})",
117             ""
118            ],
119            "xtype" : "MenuItem"
120           },
121           {
122            "$ xns" : "Gtk",
123            "* pack" : "add",
124            "xtype" : "SeparatorMenuItem"
125           },
126           {
127            "$ xns" : "Gtk",
128            "* pack" : "append",
129            "label" : "String",
130            "listeners" : {
131             "activate" : [
132              "  (self) => {",
133              "",
134              "    _this.addProp( \"prop\", \"XXXX\", \"\",\"# string\");",
135              "",
136              "}"
137             ]
138            },
139            "tooltip_markup" : "Add a user defined string property",
140            "xtype" : "MenuItem"
141           },
142           {
143            "$ xns" : "Gtk",
144            "* pack" : "append",
145            "label" : "Number",
146            "listeners" : {
147             "activate" : [
148              "  ( ) =>{",
149              "",
150              "    _this.addProp(\"prop\",  \"XXX\", \"0\", \"int\");",
151              "}"
152             ]
153            },
154            "tooltip_markup" : "Add a user defined number property",
155            "xtype" : "MenuItem"
156           },
157           {
158            "$ xns" : "Gtk",
159            "* pack" : "append",
160            "label" : "Boolean",
161            "listeners" : {
162             "activate" : [
163              "  ( ) =>{",
164              "",
165              "    _this.addProp( \"prop\", \"XXX\", \"true\", \"bool\");",
166              "}"
167             ]
168            },
169            "tooltip_markup" : "Add a user defined boolean property",
170            "xtype" : "MenuItem"
171           },
172           {
173            "$ xns" : "Gtk",
174            "* pack" : "add",
175            "xtype" : "SeparatorMenuItem"
176           },
177           {
178            "$ xns" : "Gtk",
179            "* pack" : "append",
180            "label" : "Javascript Function",
181            "listeners" : {
182             "activate" : [
183              "  ( ) =>{",
184              "",
185              "    _this.addProp(\"prop\",  \"XXXX\", \"function() { }\", \"| function\");",
186              "}"
187             ]
188            },
189            "tooltip_markup" : "Add a user function boolean property",
190            "xtype" : "MenuItem"
191           },
192           {
193            "$ xns" : "Gtk",
194            "* pack" : "append",
195            "label" : "Vala Method",
196            "listeners" : {
197             "activate" : [
198              "  ( ) =>{",
199              "",
200              "    _this.addProp( \"prop\", \"XXXX\", \"() {\\n\\n}\\n\", \"| void\");",
201              "}"
202             ]
203            },
204            "tooltip_markup" : "Add a user function boolean property",
205            "xtype" : "MenuItem"
206           },
207           {
208            "$ xns" : "Gtk",
209            "* pack" : "append",
210            "label" : "Vala Signal",
211            "listeners" : {
212             "activate" : [
213              "  ( ) =>{",
214              "",
215              "    _this.addProp( \"prop\", \"XXXX\", \"()\", \"@ void\");",
216              "}"
217             ]
218            },
219            "tooltip_markup" : "Add a vala signal",
220            "xtype" : "MenuItem"
221           },
222           {
223            "$ xns" : "Gtk",
224            "* pack" : "add",
225            "xtype" : "SeparatorMenuItem"
226           },
227           {
228            "$ xns" : "Gtk",
229            "* pack" : "append",
230            "label" : "Flexy - If",
231            "listeners" : {
232             "activate" : [
233              "  ( ) =>{",
234              "",
235              "    _this.addProp(\"prop\",  \"flexy:if\", \"value_or_condition\", \"string\");",
236              "}"
237             ]
238            },
239            "tooltip_markup" : "Add a flexy if (for HTML templates)",
240            "xtype" : "MenuItem"
241           },
242           {
243            "$ xns" : "Gtk",
244            "* pack" : "append",
245            "label" : "Flexy - Include",
246            "listeners" : {
247             "activate" : [
248              "  ( ) =>{",
249              "",
250              "    _this.addProp(\"prop\",  \"flexy:include\", \"name_of_file.html\", \"string\");",
251              "}"
252             ]
253            },
254            "tooltip_markup" : "Add a flexy include (for HTML templates)",
255            "xtype" : "MenuItem"
256           },
257           {
258            "$ xns" : "Gtk",
259            "* pack" : "append",
260            "label" : "Flexy - Foreach",
261            "listeners" : {
262             "activate" : [
263              "  ( ) =>{",
264              "",
265              "    _this.addProp(\"prop\",  \"flexy:foreach\", \"array,key,value\", \"string\");",
266              "}"
267             ]
268            },
269            "tooltip_markup" : "Add a flexy foreach (for HTML templates)",
270            "xtype" : "MenuItem"
271           }
272          ],
273          "xtype" : "Menu"
274         },
275         {
276          "$ Gtk.Stock stock" : "Gtk.Stock.ADD",
277          "$ icon_size" : "Gtk.IconSize.MENU",
278          "$ xns" : "Gtk",
279          "* pack" : "set_image",
280          "xtype" : "Image"
281         }
282        ],
283        "listeners" : {
284         "button_press_event" : [
285          "  (self, ev) => {",
286          "    _this.before_edit();",
287          "    ",
288          "        ",
289          "    var p = _this.AddPropertyPopup;",
290          "    p.el.set_screen(Gdk.Screen.get_default());",
291          "    p.el.show_all();",
292          "     p.el.popup(null, null, null, ev.button, ev.time);",
293          "     return true;",
294          "}"
295         ]
296        },
297        "string label" : "Other",
298        "xtype" : "Button"
299       },
300       {
301        "$ tooltip_text" : "\"Add Property\"",
302        "$ xns" : "Gtk",
303        "* pack" : "add",
304        "bool always_show_image" : true,
305        "bool hexpand" : true,
306        "items" : [
307         {
308          "$ xns" : "Gtk",
309          "* pack" : "set_image",
310          "utf8 icon_name" : "format-justify-left",
311          "xtype" : "Image"
312         }
313        ],
314        "listeners" : {
315         "clicked" : [
316          "  ( ) => {",
317          "    ",
318          "     _this.main_window.windowstate.showProps(this.el, \"props\");",
319          " ",
320          "",
321          "}"
322         ]
323        },
324        "string label" : "Property",
325        "xtype" : "Button"
326       },
327       {
328        "$ tooltip_text" : "\"Add Event Code\"",
329        "$ xns" : "Gtk",
330        "* pack" : "add",
331        "bool always_show_image" : true,
332        "bool hexpand" : true,
333        "items" : [
334         {
335          "$ xns" : "Gtk",
336          "* pack" : "set_image",
337          "utf8 icon_name" : "appointment-new",
338          "xtype" : "Image"
339         }
340        ],
341        "listeners" : {
342         "clicked" : [
343          "  ( ) => {",
344          "    ",
345          " ",
346          "   _this.main_window.windowstate.showProps(this.el, \"signals\");",
347          "",
348          " ",
349          "}"
350         ]
351        },
352        "string label" : "Event",
353        "xtype" : "Button"
354       }
355      ],
356      "xtype" : "Box"
357     },
358     {
359      "# bool editing" : false,
360      "$ shadow_type" : "Gtk.ShadowType.IN",
361      "$ xns" : "Gtk",
362      "* init" : [
363       "  {",
364       "  ",
365       "   this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);",
366       "}",
367       ""
368      ],
369      "* pack" : "pack_end,true,true,0",
370      "id" : "EditProps",
371      "items" : [
372       {
373        "$ enable_tree_lines" : true,
374        "$ headers_visible" : true,
375        "$ xns" : "Gtk",
376        "* init" : [
377         "{",
378         "    var selection = this.el.get_selection();",
379         "    selection.set_mode( Gtk.SelectionMode.SINGLE);",
380         "",
381         "",
382         "    var description = new Pango.FontDescription();",
383         "    description.set_size(10000);",
384         "    this.el.override_font(description);",
385         "}",
386         ""
387        ],
388        "* pack" : "add",
389        "Xcls_PopoverProperty popover" : "null",
390        "id" : "view",
391        "items" : [
392         {
393          "$ changed" : [
394           "function(str, doRefresh) {",
395           "    if (!this.activePath) {",
396           "        return;",
397           "    }",
398           "    var iter = new Gtk.TreeIter();",
399           "    this.el.get_iter(iter, new Gtk.TreePath.from_string(this.activePath));",
400           "    ",
401           "    this.el.set_value(iter, 1, '' +str);",
402           "    this.el.set_value(iter, 3, '' + this.toShort(str));",
403           "    var type = this.getIterValue(iter, 4);",
404           "",
405           "    this.el.set_value(iter, 5, type + ' : ' + str);",
406           "    // update the tree...  ",
407           "",
408           "    this.get('/LeftTree.model').changed(this.toJS(), doRefresh); ",
409           "}",
410           ""
411          ],
412          "$ columns" : [
413           "     typeof(string),  // 0 key type",
414           "     typeof(string),  // 1 key",
415           "     typeof(string),  // 2 key (display)",
416           "     typeof(string),  // 3 value",
417           "     typeof(string),   // 4 value (display)",
418           "     typeof(string),   // 5 both (tooltip)     ",
419           "     typeof(string)   // 6 key (for sorting)",
420           ""
421          ],
422          "$ toShort" : [
423           "function(str) {",
424           "    var a = typeof(str) == 'string' ? str.split(\"\\n\") : [];",
425           "        return a.length > 1 ? a[0] + '....' : '' + str;",
426           "}",
427           ""
428          ],
429          "$ xns" : "Gtk",
430          "* pack" : "set_model",
431          "id" : "model",
432          "n_columns" : 7,
433          "xtype" : "TreeStore"
434         },
435         {
436          "$ resizable" : true,
437          "$ xns" : "Gtk",
438          "* init" : [
439           " this.el.add_attribute(_this.keyrender.el , \"markup\", 2 );",
440           " this.el.add_attribute(_this.keyrender.el , \"text\", 1 );",
441           "  "
442          ],
443          "* pack" : "append_column",
444          "id" : "keycol",
445          "items" : [
446           {
447            "$ xns" : "Gtk",
448            "* pack" : "pack_start,false",
449            "id" : "keyrender",
450            "listeners" : {
451             "edited" : [
452              "  (path, newtext) => {",
453              "        GLib.debug(\"Keyrender  - signal:edited\\n\");",
454              "    ",
455              "    this.el.editable = false;",
456              "  ",
457              " ",
458              "",
459              "        Gtk.TreeIter  iter;",
460              "        _this.model.el.get_iter(out iter, new Gtk.TreePath.from_string(path));",
461              "        GLib.Value gval;",
462              "        ",
463              "         _this.model.el.get_value(iter,1, out gval);",
464              "        var oldval = (string)gval;",
465              "        ",
466              "         _this.model.el.get_value(iter,0, out gval);",
467              "        var ktype = (string)gval;",
468              "       ",
469              "        _this.model.el.set_value(iter, 1, newtext);",
470              "        ",
471              "        if (oldval == newtext) {",
472              "            return;",
473              "        }",
474              "        ",
475              "        ",
476              "        GLib.debug(\"ktype: %s\\n\",ktype);",
477              "        switch(ktype) {",
478              "            case \"listener\":",
479              "                var ov = _this.node.listeners.get(oldval);",
480              "                _this.node.listeners.set(newtext, ov);",
481              "                _this.node.listeners.unset(oldval);",
482              "                ",
483              "                _this.updateIter(iter,  ktype, newtext, ov);",
484              "                ",
485              "                break;",
486              "            case \"props\":",
487              "                var ov = _this.node.props.get(oldval);",
488              "                _this.node.props.set(newtext, ov);",
489              "                _this.node.props.unset(oldval);",
490              "                _this.updateIter(iter,  ktype, newtext, ov);",
491              "                break;",
492              "         }",
493              "         _this.changed();",
494              "          ",
495              "}"
496             ],
497             "editing_started" : [
498              "(  editable, path) => {",
499              "",
500              "     Gtk.TreeIter  iter;",
501              "    _this.model.el.get_iter(out iter, new Gtk.TreePath.from_string(path));",
502              "    GLib.Value gval;",
503              "                  ",
504              "",
505              "",
506              "     //   this.get('/LeftPanel.model').activePath  = path;",
507              "    _this.model.el.get_value(iter,1, out gval);",
508              "        var val = (string)gval;",
509              "                 ",
510              "        ((Gtk.Entry)editable).set_text(val);                 ",
511              "}"
512             ]
513            },
514            "xtype" : "CellRendererText"
515           }
516          ],
517          "title" : "Name",
518          "xtype" : "TreeViewColumn"
519         },
520         {
521          "$ resizable" : true,
522          "$ xns" : "Gtk",
523          "* init" : [
524           "{",
525           "\t",
526           "\t//     typeof(string),  // 0 key type",
527           "    // typeof(string),  // 1 key",
528           "    // typeof(string),  // 2 key (display)",
529           "    // typeof(string),  // 3 value",
530           "    // typeof(string)   // 4 value (display)",
531           "",
532           "\t",
533           "\tthis.el.add_attribute(_this.valrender.el , \"text\", 4 );",
534           "\t//this.el.add_attribute(_this.valrender.el , \"sensitive\", 4 );",
535           "\t//this.el.add_attribute(this.items[0].el , 'editable', 3 );",
536           "          // this.el.set_cell_data_func(cell, age_cell_data_func, NULL, NULL);",
537           "",
538           " //\tthis.get('/LeftPanel').editableColumn= this;",
539           "}",
540           ""
541          ],
542          "* pack" : "append_column",
543          "id" : "valcol",
544          "items" : [
545           {
546            "$ editable" : false,
547            "$ has_entry" : true,
548            "$ xns" : "Gtk",
549            "* pack" : "pack_start,true",
550            "id" : "valrender",
551            "items" : [
552             {
553              "$ columns" : "typeof(string)",
554              "$ xns" : "Gtk",
555              "* pack" : false,
556              "* prop" : "model",
557              "id" : "valrendermodel",
558              "n_columns" : 1,
559              "xtype" : "ListStore"
560             }
561            ],
562            "listeners" : {
563             "edited" : [
564              "  (path, newtext) => {",
565              "    GLib.debug(\"Valrender  - signal:edited\\n\");",
566              "  ",
567              "        this.el.editable = false;",
568              "/*  ",
569              " m.set(iter, ",
570              "                0, \"listener\",",
571              "                1, miter.get_key(),",
572              "                2, \"<b>\" + miter.get_key() + \"</b>\",",
573              "                3, miter.get_value(),",
574              "                4, display_value(short);",
575              "            ); ",
576              "",
577              "  */      ",
578              "",
579              "        Gtk.TreeIter  iter;",
580              "        _this.model.el.get_iter(out iter, new Gtk.TreePath.from_string(path));",
581              "        GLib.Value gval;",
582              "        ",
583              "         _this.model.el.get_value(iter,0, out gval);",
584              "        var ktype = (string)gval;",
585              "        ",
586              "        ",
587              "         _this.model.el.get_value(iter,3, out gval);",
588              "        var oldval = (string)gval;",
589              "        ",
590              "         _this.model.el.get_value(iter,1, out gval);",
591              "        var key = (string)gval;",
592              "        ",
593              "         ",
594              "        ",
595              "        switch(ktype) {",
596              "            case \"listener\":",
597              "                _this.node.listeners.set(key, newtext);",
598              "                _this.updateIter(iter,ktype,key,newtext);",
599              "                break;",
600              "            case \"props\":",
601              "                _this.node.props.set(key,newtext);",
602              "                _this.updateIter(iter,ktype, key,newtext);                ",
603              "                break;",
604              "         }",
605              "//         _this.load(_this.file,_this.node);",
606              "         _this.changed();",
607              "          ",
608              "}"
609             ],
610             "editing_started" : [
611              "( editable, path) => {",
612              "    //_this.editing = true;",
613              "    GLib.debug(\"editing started called\\n\");",
614              "    if (!_this.allow_edit) {",
615              "       ",
616              "         GLib.debug(\"val - editing_Started\\n\");",
617              "        this.el.editable = false; // make sure it's not editor...",
618              "   ",
619              "         ",
620              "        return;",
621              "    }",
622              "     _this.allow_edit =false;",
623              "    ",
624              "   ",
625              "     if (  this.el.has_entry ) {",
626              "   ",
627              "         Gtk.TreeIter  iter;",
628              "        _this.model.el.get_iter(out iter, new Gtk.TreePath.from_string(path));",
629              "        GLib.Value gval;",
630              "                      ",
631              "",
632              "      ",
633              "         //   this.get('/LeftPanel.model').activePath  = path;",
634              "       _this.model.el.get_value(iter,3, out gval);",
635              "    ",
636              "",
637              "        var val = (string)gval;",
638              "        var combo =        (Gtk.ComboBox)editable;",
639              "",
640              "        var entry =  (Gtk.Entry) combo.get_child();        ",
641              "        entry.set_text(val);",
642              "    }",
643              "   ",
644              "}"
645             ]
646            },
647            "text_column" : 0,
648            "xtype" : "CellRendererCombo",
649            "|              void setOptions" : [
650             "(string[] ar) {",
651             "      var m = _this.valrendermodel.el;",
652             "        m.clear();",
653             "     Gtk.TreeIter iret;",
654             "    for (var i =0; i < ar.length; i++) {",
655             "            m.append(out iret);",
656             "            m.set_value(iret, 0, ar[i]);",
657             "    }",
658             "",
659             "}"
660            ]
661           }
662          ],
663          "title" : "Value",
664          "xtype" : "TreeViewColumn"
665         },
666         {
667          "$ xns" : "Gtk",
668          "* pack" : false,
669          "id" : "ContextMenu",
670          "items" : [
671           {
672            "$ xns" : "Gtk",
673            "* pack" : "append",
674            "label" : "Edit (double click)",
675            "listeners" : {
676             "activate" : [
677              "  ( )  =>{",
678              "  ",
679              "    var s = _this.view.el.get_selection();",
680              "    Gtk.TreeIter iter;",
681              "    Gtk.TreeModel mod;",
682              "    s.get_selected (out  mod, out  iter);",
683              "    ",
684              "      if (_this.view.popover == null) {",
685              "     \t\t   _this.view.popover = new Xcls_PopoverProperty();",
686              "     \t\t   _this.view.popover.mainwindow = _this.main_window;",
687              " \t\t}",
688              " \t\t",
689              " ",
690              "      _this.before_edit();",
691              "      _this.stop_editor();",
692              "\t  ",
693              "     _this.keyrender.el.stop_editing(false);",
694              "     _this.keyrender.el.editable  =false;",
695              "",
696              "     _this.valrender.el.stop_editing(false);",
697              "     _this.valrender.el.editable  =false;",
698              "     ",
699              "      ",
700              "\tGLib.Value gvaltype, gval;",
701              "\tmod.get_value(iter, 1 , out gval); // one is key..",
702              "\t",
703              "     mod.get_value(iter,0, out gvaltype);",
704              "",
705              "\t_this.view.popover.show(_this.view.el, _this.node, (string)gvaltype, (string)gval);",
706              "       ",
707              "    ",
708              "    ",
709              "   // _this.startEditingKey(model.get_path(iter));",
710              "}"
711             ]
712            },
713            "xtype" : "MenuItem"
714           },
715           {
716            "$ xns" : "Gtk",
717            "* pack" : "append",
718            "xtype" : "SeparatorMenuItem"
719           },
720           {
721            "$ xns" : "Gtk",
722            "* pack" : "append",
723            "label" : "Delete",
724            "listeners" : {
725             "activate" : [
726              "  ( )  =>{",
727              "\t_this.deleteSelected();",
728              "}"
729             ]
730            },
731            "xtype" : "MenuItem"
732           }
733          ],
734          "xtype" : "Menu"
735         }
736        ],
737        "listeners" : {
738         "button_press_event" : [
739          "  ( ev)  => {",
740          " ",
741          "    Gtk.TreeViewColumn col;",
742          "    int cell_x;",
743          "    int cell_y;",
744          "    Gtk.TreePath path;",
745          "    if (!this.el.get_path_at_pos((int)ev.x, (int) ev.y, out path, out col, out cell_x, out cell_y )) {",
746          "        GLib.debug(\"nothing selected on click\");",
747          "        GLib.Timeout.add_full(GLib.Priority.DEFAULT,10 , () => {",
748          "            this.el.get_selection().unselect_all();",
749          "",
750          "            return false;",
751          "        });",
752          "         _this.before_edit();",
753          "        return false; //not on a element.",
754          "    }",
755          "    ",
756          "     ",
757          "     // double click on name..",
758          "     if (ev.type == Gdk.EventType.2BUTTON_PRESS  && ev.button == 1 && col.title == \"Name\") {    ",
759          "        // show popup!.   ",
760          "        ",
761          "         if (this.popover == null) {",
762          "     \t\t   this.popover = new Xcls_PopoverProperty();",
763          "     \t\t   this.popover.mainwindow = _this.main_window;",
764          " \t\t}",
765          " \t\t",
766          " ",
767          "         _this.before_edit();",
768          "          _this.stop_editor();",
769          "\t\t  ",
770          "         _this.keyrender.el.stop_editing(false);",
771          "         _this.keyrender.el.editable  =false;",
772          "    ",
773          "         _this.valrender.el.stop_editing(false);",
774          "         _this.valrender.el.editable  =false;",
775          "         Gtk.TreeIter iter;",
776          "          var mod = this.el.get_model();",
777          "\t\t  mod.get_iter (out iter, path);",
778          "\t\t  ",
779          "       ",
780          "\t\tGLib.Value gvaltype, gval;",
781          "\t\tmod.get_value(iter, 1 , out gval); // one is key..",
782          "\t\t",
783          "\t     mod.get_value(iter,0, out gvaltype);",
784          "",
785          "        this.popover.show(this.el, _this.node, (string)gvaltype, (string)gval);",
786          "           ",
787          "        //  _this.startEditingKey(path); ",
788          "         ",
789          "        return false;",
790          "    }",
791          "    ",
792          "    ",
793          "    ",
794          "    ",
795          "     // right click.",
796          "     if (ev.type == Gdk.EventType.BUTTON_PRESS  && ev.button == 3) {    ",
797          "        // show popup!.   ",
798          "        //if (col.title == \"Value\") {",
799          "         //     _this.before_edit();",
800          "         //    return false;",
801          "         //}",
802          "",
803          "        var p = _this.ContextMenu;",
804          "",
805          "        p.el.set_screen(Gdk.Screen.get_default());",
806          "        p.el.show_all();",
807          "        p.el.popup(null, null, null,  ev.button, ev.time);",
808          "        //Seed.print(\"click:\" + res.column.title);",
809          "        // select the ",
810          "        GLib.Timeout.add_full(GLib.Priority.DEFAULT,10 , () => {",
811          "  ",
812          "            this.el.get_selection().select_path(path);",
813          "            return false;",
814          "        });",
815          "         _this.before_edit();",
816          "        return false;",
817          "    }",
818          "    ",
819          "     ",
820          "    if (col.title != \"Value\") {",
821          "        GLib.debug(\"col title != Value\");",
822          "        ",
823          "        GLib.Timeout.add_full(GLib.Priority.DEFAULT,10 , () => {",
824          "            this.el.get_selection().select_path(path);",
825          "            return false;",
826          "        });",
827          "        ",
828          "        _this.before_edit();",
829          "          //  XObject.error(\"column is not value?\");",
830          "        return false; // ignore.. - key click.. ??? should we do this??",
831          "    }",
832          "    ",
833          "    ",
834          "    // if the cell can be edited with a pulldown",
835          "    // then we should return true... - and let the start_editing handle it?",
836          "    ",
837          "    ",
838          "    ",
839          "    ",
840          "    ",
841          "      ",
842          "   //             _this.before_edit(); <<< we really need to stop the other editor..",
843          "     _this.keyrender.el.stop_editing(false);",
844          "    _this.keyrender.el.editable  =false;",
845          "    ",
846          "           ",
847          "    return _this.startEditingValue(path); // assumes selected row..",
848          "        ",
849          "   ",
850          "",
851          "              ",
852          "   ",
853          "}"
854         ]
855        },
856        "tooltip_column" : 5,
857        "xtype" : "TreeView"
858       }
859      ],
860      "xtype" : "ScrolledWindow"
861     }
862    ],
863    "xtype" : "Box",
864    "|              string keyFormat" : [
865     "(string val, string type) {",
866     "    ",
867     "    // Glib.markup_escape_text(val);",
868     "",
869     "    if (type == \"listener\") {",
870     "        return \"<span font_weight=\\\"bold\\\" color=\\\"#660000\\\">\" + ",
871     "            GLib.Markup.escape_text(val) +",
872     "             \"</span>\";",
873     "    }",
874     "    // property..",
875     "    if (val.length < 1) {",
876     "        return \"<span  color=\\\"#FF0000\\\">--empty--</span>\";",
877     "    }",
878     "    ",
879     "    //@ = signal",
880     "    //$ = property with ",
881     "    //# - object properties",
882     "    //* = special",
883     "    // all of these... - display value is last element..",
884     "    var ar = val.strip().split(\" \");",
885     "    ",
886     "    ",
887     "    var dval = GLib.Markup.escape_text(ar[ar.length-1]);",
888     "    ",
889     "    ",
890     "    ",
891     "    ",
892     "    switch(val[0]) {",
893     "        case '@': // signal // just bold balck?",
894     "            if (dval[0] == '@') {",
895     "                dval = dval.substring(1);",
896     "            }",
897     "        ",
898     "            return @\"<span  font_weight=\\\"bold\\\">@ $dval</span>\";        ",
899     "        case '#': // object properties?",
900     "            if (dval[0] == '#') {",
901     "                dval = dval.substring(1);",
902     "            }",
903     "            return @\"<span  font_weight=\\\"bold\\\">$dval</span>\";",
904     "        case '*': // special",
905     "            if (dval[0] == '*') {",
906     "                dval = dval.substring(1);",
907     "            }",
908     "            return @\"<span   color=\\\"#0000CC\\\" font_weight=\\\"bold\\\">$dval</span>\";            ",
909     "        case '$':",
910     "            if (dval[0] == '$') {",
911     "                dval = dval.substring(1);",
912     "            }",
913     "            return @\"<span   style=\\\"italic\\\">$dval</span>\";",
914     "       case '|': // user defined methods",
915     "            if (dval[0] == '|') {",
916     "                dval = dval.substring(1);",
917     "            }",
918     "            return @\"<span color=\\\"#008000\\\" font_weight=\\\"bold\\\">$dval</span>\";",
919     "            ",
920     "              ",
921     "            ",
922     "        default:",
923     "            return dval;",
924     "    }",
925     "      ",
926     "    ",
927     "",
928     "}"
929    ],
930    "|              string keySortFormat" : [
931     "(string key) {",
932     "    // listeners first - with 0",
933     "    // specials",
934     "    if (key[0] == '*') {",
935     "        return \"1 \" + key;",
936     "    }",
937     "    // functions",
938     "    ",
939     "    var bits = key.split(\" \");",
940     "    ",
941     "    if (key[0] == '|') {",
942     "        return \"2 \" + bits[bits.length -1];",
943     "    }",
944     "    // signals",
945     "    if (key[0] == '@') {",
946     "        return \"3 \" + bits[bits.length -1];",
947     "    }",
948     "        ",
949     "    // props",
950     "    if (key[0] == '#') {",
951     "        return \"4 \" + bits[bits.length -1];",
952     "    }",
953     "    // the rest..",
954     "    return \"5 \" + bits[bits.length -1];    ",
955     "",
956     "",
957     "",
958     "}"
959    ],
960    "|              void addProp" : [
961     " (string in_type, string key, string value, string value_type) {",
962     "      // info includes key, val, skel, etype..",
963     "      //console.dump(info);",
964     "        //type = info.type.toLowerCase();",
965     "        //var data = this.toJS();",
966     "          ",
967     "    var type = in_type == \"signals\" ? \"listener\" : in_type;",
968     "      ",
969     "    var fkey = (value_type.length > 0 ? value_type + \" \" : \"\") + key;",
970     "              ",
971     "    if (type == \"listener\") {",
972     "        if (this.node.listeners.has_key(key)) {",
973     "            return;",
974     "        }",
975     "        this.node.listeners.set(key,value);",
976     "    } else  {",
977     "         assert(this.node != null);",
978     "         assert(this.node.props != null);",
979     "        if (this.node.props.has_key(fkey)) {",
980     "            return;",
981     "        }",
982     "        this.node.props.set(fkey,value);",
983     "    }",
984     "            ",
985     "      ",
986     "    // add a row???",
987     "    this.load(this.file, this.node);",
988     "    ",
989     "    ",
990     "    ",
991     "    /// need to find the row which I've just added..",
992     "    ",
993     "    ",
994     "    var s = this.view.el.get_selection();",
995     "    s.unselect_all();",
996     "    ",
997     "    GLib.debug(\"trying to find new iter\");",
998     "  ",
999     "    this.model.el.foreach((model, path, iter) => {",
1000     "        GLib.Value gval;",
1001     "    ",
1002     "        this.model.el.get_value(iter, 0 , out gval);",
1003     "        if ((string)gval != type) {",
1004     "            GLib.debug(\"not type: %s = %s\\n\", (string)gval , type);",
1005     "            return false;",
1006     "        }",
1007     "        this.model.el.get_value(iter, 1 , out gval);",
1008     "        if ((string)gval != fkey) {",
1009     "            GLib.debug(\"not key: %s = %s\\n\", (string)gval , fkey);",
1010     "            return false;",
1011     "        }",
1012     "        // delay this?",
1013     "        GLib.Timeout.add_full(GLib.Priority.DEFAULT,40 , () => {",
1014     "        ",
1015     "            this.startEditingValue(this.model.el.get_path(iter));",
1016     "            return false;",
1017     "        });",
1018     "        //s.select_iter(iter);",
1019     "        return true; ",
1020     "    });",
1021     "    ",
1022     "    ",
1023     "    ",
1024     "              ",
1025     "}",
1026     ""
1027    ],
1028    "|              void before_edit" : [
1029     "()",
1030     "{",
1031     "",
1032     "    GLib.debug(\"before edit - stop editing\\n\");",
1033     "    ",
1034     "  // these do not appear to trigger save...",
1035     "    _this.keyrender.el.stop_editing(false);",
1036     "    _this.keyrender.el.editable  =false;",
1037     "",
1038     "    _this.valrender.el.stop_editing(false);",
1039     "    _this.valrender.el.editable  =false;    ",
1040     "    ",
1041     "    ",
1042     "// technicall stop the popup editor..",
1043     "",
1044     "}",
1045     ""
1046    ],
1047    "|              void deleteSelected" : [
1048     " () {",
1049     "    ",
1050     "        Gtk.TreeIter iter;",
1051     "        Gtk.TreeModel mod;",
1052     "        ",
1053     "        var s = this.view.el.get_selection();",
1054     "        s.get_selected(out mod, out iter);",
1055     "             ",
1056     "              ",
1057     "        GLib.Value gval;",
1058     "        mod.get_value(iter, 0 , out gval);",
1059     "        var type = (string)gval;",
1060     "        ",
1061     "        mod.get_value(iter, 1 , out gval);",
1062     "        var key = (string)gval;",
1063     "        ",
1064     "        switch(type) {",
1065     "            case \"listener\":",
1066     "                this.node.listeners.unset(key);",
1067     "                break;",
1068     "                ",
1069     "            case \"props\":",
1070     "                this.node.props.unset(key);",
1071     "                break;",
1072     "        }",
1073     "        this.load(this.file, this.node);",
1074     "        ",
1075     "        _this.changed();",
1076     "}"
1077    ],
1078    "|              void finish_editing" : [
1079     "() {",
1080     "     // ",
1081     "    this.before_edit();",
1082     "}"
1083    ],
1084    "|              void load" : [
1085     "(JsRender.JsRender file, JsRender.Node? node) ",
1086     "{",
1087     "    GLib.debug(\"load leftprops\\n\");",
1088     "    this.before_edit();",
1089     "    this.node = node;",
1090     "    this.file = file;",
1091     "    ",
1092     " ",
1093     "    this.model.el.clear();",
1094     "              ",
1095     "    //this.get('/RightEditor').el.hide();",
1096     "    if (node ==null) {",
1097     "        return ;",
1098     "    }",
1099     "     ",
1100     "    ",
1101     "",
1102     "    //var provider = this.get('/LeftTree').getPaleteProvider();",
1103     "    Gtk.TreeIter iter;",
1104     "    ",
1105     "    //typeof(string),  // 0 key type",
1106     "     //typeof(string),  // 1 key",
1107     "     //typeof(string),  // 2 key (display)",
1108     "     //typeof(string),  // 3 value",
1109     "     //typeof(string),  // 4 value (display)",
1110     "     //typeof(string),  // 5 both (tooltip)",
1111     "    ",
1112     "     ",
1113     "    ",
1114     "    // really need a way to sort the hashmap...",
1115     "    var m = this.model.el;",
1116     "    ",
1117     "    var miter = node.listeners.map_iterator();",
1118     "    var i = 0;",
1119     "    ",
1120     "    while(miter.next()) {",
1121     "        i++;",
1122     "        m.append(out iter,null);",
1123     "        ",
1124     "        this.updateIter(iter,  \"listener\", miter.get_key(), miter.get_value());",
1125     "        ",
1126     "         ",
1127     "     }",
1128     "     ",
1129     "      ",
1130     "    miter = node.props.map_iterator();",
1131     "    ",
1132     "    ",
1133     "   while(miter.next()) {",
1134     "           i++;",
1135     "        m.append(out iter,null);",
1136     "         this.updateIter(iter,  \"prop\", miter.get_key(), miter.get_value());",
1137     "         ",
1138     "   }",
1139     "   GLib.debug(\"clear selection\\n\");",
1140     "   // clear selection?",
1141     "   this.model.el.set_sort_column_id(6,Gtk.SortType.ASCENDING); // sort by real key..",
1142     "   ",
1143     "   this.view.el.get_selection().unselect_all();",
1144     "   ",
1145     "   ",
1146     "   /**",
1147     "   ",
1148     "   make outerpane = {current width of left pane} + width of props",
1149     "   make innerpane = {current width of left pane}",
1150     "   ",
1151     "   ",
1152     "   ",
1153     "   ",
1154     "   ",
1155     "   var outerpane = _this.main_window.leftpane.el;",
1156     "   var pane = _this.main_window.editpane.el;",
1157     "   ",
1158     "  ",
1159     "   ",
1160     "    var try_size = (i * 25) + 60; // est. 20px per line + 40px header",
1161     "    GLib.Timeout.add_seconds(1, () => { ",
1162     "\t\t// max 80%...",
1163     "\t\tpane.set_position( ",
1164     "\t\t     ((try_size * 1.0f) /  (pane.max_position * 1.0f))  > 0.8f  ? ",
1165     "\t\t    (int) (pane.max_position * 0.2f) :",
1166     "\t\t    pane.max_position-try_size);",
1167     "\t    return GLib.Source.REMOVE;",
1168     "\t});",
1169     "\t*/",
1170     "   ",
1171     "}",
1172     ""
1173    ],
1174    "|              void startEditingKey" : [
1175     "( Gtk.TreePath path) {",
1176     "    ",
1177     "     if (!this.stop_editor()) {",
1178     "        return;",
1179     "     }",
1180     "  ",
1181     "    // others... - fill in options for true/false?",
1182     "    ",
1183     "       ",
1184     "    GLib.Timeout.add_full(GLib.Priority.DEFAULT,10 , () => {",
1185     "        this.allow_edit  = true;",
1186     "        this.keyrender.el.editable = true;",
1187     "     ",
1188     "        this.view.el.set_cursor_on_cell(",
1189     "            path,",
1190     "            this.keycol.el,",
1191     "            this.keyrender.el,",
1192     "            true",
1193     "        );",
1194     "               ",
1195     "        return false;",
1196     "    });",
1197     "      ",
1198     "    ",
1199     "}",
1200     ""
1201    ],
1202    "|              void updateIter" : [
1203     "(Gtk.TreeIter iter,  string type, string key, string kvalue) {",
1204     "",
1205     "    //print(\"update Iter %s, %s\\n\", key,kvalue);",
1206     "    //typeof(string),  // 0 key type",
1207     "     //typeof(string),  // 1 key",
1208     "     //typeof(string),  // 2 key (display)",
1209     "     //typeof(string),  // 3 value",
1210     "     //typeof(string),  // 4 value (display)",
1211     "     //typeof(string),  // 5 both (tooltip)",
1212     "     //typeof(string),  // 6 key (sort)",
1213     "    ",
1214     "    var dl = kvalue.strip().split(\"\\n\");",
1215     "",
1216     "    var dis_val = dl.length > 1 ? (dl[0].strip()+ \"...\") : dl[0];",
1217     "    ",
1218     "    if (type == \"listener\") {",
1219     "     ",
1220     "       ",
1221     "        ",
1222     "        this.model.el.set(iter, ",
1223     "                0, type,",
1224     "            1, key,",
1225     "            2, this.keyFormat(key ,type),",
1226     "            3, kvalue,",
1227     "            4, dis_val,",
1228     "            5, \"<tt>\" +  GLib.Markup.escape_text(key + \" \" +kvalue) + \"</tt>\",",
1229     "            6,  \"0 \" + key",
1230     "        ); ",
1231     "        return;",
1232     "    }",
1233     "    ",
1234     "",
1235     "",
1236     "    this.model.el.set(iter, ",
1237     "            0, \"props\",",
1238     "            1, key,",
1239     "            2,  this.keyFormat(key , \"prop\"),",
1240     "            3, kvalue,",
1241     "            4, dis_val,",
1242     "             5, \"<tt>\" + GLib.Markup.escape_text(key + \" \" + kvalue) + \"</tt>\",",
1243     "             6,  this.keySortFormat(key)",
1244     "        ); ",
1245     "}"
1246    ],
1247    "| bool startEditingValue" : [
1248     "( Gtk.TreePath path) {",
1249     "",
1250     "     // ONLY return true if editing is allowed - eg. combo..",
1251     "",
1252     "    GLib.debug(\"start editing?\\n\");",
1253     "    if (!this.stop_editor()) {",
1254     "        GLib.debug(\"stop editor failed\\n\");",
1255     "        return false;",
1256     "    }",
1257     "    ",
1258     "    Gtk.TreeIter iter;",
1259     "",
1260     "    var mod = this.model.el;",
1261     "    mod.get_iter (out iter, path);",
1262     "     ",
1263     "    /*",
1264     "        m.set(iter, ",
1265     "                0, \"listener\",",
1266     "                1, miter.get_key(),",
1267     "                2, \"<b>\" + miter.get_key() + \"</b>\",",
1268     "                3, miter.get_value()",
1269     "            ); ",
1270     "     ",
1271     "    */",
1272     "    GLib.Value gval;",
1273     "    mod.get_value(iter, 3 , out gval);",
1274     "    var val = (string)gval;",
1275     "",
1276     "    mod.get_value(iter, 1 , out gval);",
1277     "    var key = (string)gval;",
1278     "    ",
1279     "    ",
1280     "    string kname, kflag, ktype;",
1281     "    this.node.normalize_key(key, out kname, out kflag, out ktype);",
1282     "     ",
1283     "    ",
1284     "    mod.get_value(iter, 0 , out gval);",
1285     "    var type = (string)gval; // listerner or prop..",
1286     "    ",
1287     "   ",
1288     "    ",
1289     "    var use_textarea = false;",
1290     "",
1291     "    //------------ things that require the text editor...",
1292     "    ",
1293     "    if (type == \"listener\") {",
1294     "        use_textarea = true;",
1295     "    }",
1296     "    if (key.length > 0 && key[0] == '|') { // user defined method",
1297     "        use_textarea = true;",
1298     "    }",
1299     "    if (key.length > 0 && key[0] == '$') { // raw string",
1300     "        use_textarea = true;",
1301     "    }",
1302     "    if (key.length > 0 && key == \"* init\") {",
1303     "        use_textarea = true;",
1304     "    }",
1305     "    if (val.length > 40) { // long value...",
1306     "        use_textarea = true;",
1307     "    }",
1308     "    ",
1309     "    ",
1310     "    ",
1311     "    if (use_textarea) {",
1312     "        GLib.debug(\"Call show editor\\n\");",
1313     "        GLib.Timeout.add_full(GLib.Priority.DEFAULT,10 , () => {",
1314     "            this.view.el.get_selection().select_path(path);",
1315     "            ",
1316     "            this.show_editor(file, node, type, key);",
1317     "            ",
1318     "            return false;",
1319     "        });",
1320     "       ",
1321     "        ",
1322     "        return false;",
1323     "    }",
1324     "    ",
1325     "     var pal = this.file.project.palete;",
1326     "    ",
1327     "    string[] opts;",
1328     "    var has_opts = pal.typeOptions(this.node.fqn(), kname, ktype, out opts);",
1329     "    ",
1330     "    ",
1331     "    ",
1332     "    // others... - fill in options for true/false?",
1333     "    GLib.debug(\"turn on editing %s \\n\" , mod.get_path(iter).to_string());",
1334     "   ",
1335     "       GLib.debug (ktype.up());",
1336     "    if (has_opts) {",
1337     "            GLib.debug(\"start editing try/false)???\");",
1338     "            this.valrender.el.has_entry = false;",
1339     "          ",
1340     "            this.valrender.setOptions(opts);",
1341     "            ",
1342     "            this.valrender.el.has_entry = false;",
1343     "            this.valrender.el.editable = true;",
1344     "             this.allow_edit  = true;",
1345     "             GLib.Timeout.add_full(GLib.Priority.DEFAULT,100 , () => {",
1346     "                 this.view.el.set_cursor_on_cell(",
1347     "                    path,",
1348     "                    this.valcol.el,",
1349     "                    this.valrender.el,",
1350     "                    true",
1351     "                );",
1352     "                return false;",
1353     "            });",
1354     "            return true;",
1355     "    }",
1356     "                              ",
1357     "       // see if type is a Enum.",
1358     "       ",
1359     "       ",
1360     "   ",
1361     "        ",
1362     "   ",
1363     "     opts =  {  };",
1364     "    this.valrender.setOptions(opts);",
1365     "   ",
1366     "   GLib.Timeout.add_full(GLib.Priority.DEFAULT,10 , () => {",
1367     "        ",
1368     "        // at this point - work out the type...",
1369     "        // if its' a combo... then show the options..",
1370     "        this.valrender.el.has_entry = true;",
1371     "        ",
1372     "        this.valrender.el.editable = true;            ",
1373     "    ",
1374     "        ",
1375     "        this.allow_edit  = true;",
1376     "        ",
1377     "        ",
1378     "        ",
1379     "        ",
1380     "",
1381     "        this.view.el.set_cursor_on_cell(",
1382     "            path,",
1383     "            this.valcol.el,",
1384     "            this.valrender.el,",
1385     "            true",
1386     "        );",
1387     "        return false;",
1388     "    });",
1389     "    return false;",
1390     "}",
1391     ""
1392    ],
1393    "| void updateKey" : [
1394     "(string oldkey,  string type, string key ) {",
1395     "",
1396     " ",
1397     "\t",
1398     "\t_this.model.el.foreach((mod, path,  iter) => {",
1399     "\t\t ",
1400     "        ",
1401     "        \t  ",
1402     "       ",
1403     "\t\t GLib.Value gvaltype, gval,kvalue;",
1404     "\t\t mod.get_value(iter, 1 , out gval); // one is key..",
1405     "\t\t",
1406     "\t     mod.get_value(iter,0, out gvaltype);",
1407     "\t     ",
1408     " \t     mod.get_value(iter,3, out kvalue);",
1409     "\t     ",
1410     "\t      if (oldkey == ((string)gval) && type == ((string)gvaltype)) {",
1411     "\t      ",
1412     "\t\t  \t  //print(\"update iter type=%s, key=%s value=%s\\n\", type, key,(string) kvalue);",
1413     "\t      ",
1414     "   \t \t      this.updateIter(iter, type, key, (string)kvalue);",
1415     "   \t \t      return true;",
1416     "\t \t  }",
1417     "\t     ",
1418     "",
1419     "\t\treturn false;",
1420     "\t});",
1421     "\t",
1422     "\tthis.changed();",
1423     "",
1424     "",
1425     "}",
1426     ""
1427    ]
1428   }
1429  ],
1430  "modOrder" : "",
1431  "name" : "WindowLeftProps",
1432  "parent" : "",
1433  "path" : "/home/alan/gitlive/roobuilder/src/Builder4/WindowLeftProps.bjs",
1434  "permname" : "",
1435  "title" : ""
1436 }