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