fix line numbering issues with vala generator - hopefully fixes completion in node...
[roobuilder] / src / Builder4 / DialogFiles.bjs
1 {
2  "build_module" : "builder",
3  "gen_extended" : false,
4  "items" : [
5   {
6    "# Xcls_MainWindow win" : "",
7    "$ xns" : "Gtk",
8    "Gdk.Pixbuf missing_thumb_pixbuf" : "",
9    "Gee.HashMap<string,Gdk.Pixbuf> image_cache" : "",
10    "Project.Project selectedProject" : "",
11    "bool in_onprojectselected" : false,
12    "bool is_loading" : false,
13    "bool modal" : true,
14    "bool new_window" : false,
15    "int default_height" : 550,
16    "int default_width" : 1000,
17    "items" : [
18     {
19      "$ homogeneous" : false,
20      "$ xns" : "Gtk",
21      "* prop" : "child",
22      "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
23      "bool expand" : true,
24      "int margin_bottom" : 10,
25      "int margin_end" : 10,
26      "int margin_start" : 10,
27      "int margin_top" : 10,
28      "items" : [
29       {
30        "$ xns" : "Gtk",
31        "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
32        "bool hexpand" : true,
33        "int spacing" : 0,
34        "xtype" : "Box"
35       },
36       {
37        "$ xns" : "Gtk",
38        "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
39        "bool hexpand" : true,
40        "bool homogeneous" : false,
41        "bool vexpand" : true,
42        "id" : "mainpane",
43        "int position" : 200,
44        "int spacing" : 0,
45        "items" : [
46         {
47          "$ xns" : "Gtk",
48          "* init" : [
49           "  this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);",
50           " "
51          ],
52          "* prop" : "start_child",
53          "bool expand" : true,
54          "bool has_frame" : true,
55          "bool hexpand" : true,
56          "bool vexpand" : true,
57          "id" : "projectscroll",
58          "int width_request" : 150,
59          "items" : [
60           {
61            "$ xns" : "Gtk",
62            "* init" : [
63             "{",
64             " ",
65             "\tthis.css = new Gtk.CssProvider();",
66             " ",
67             "\tthis.css.load_from_string(\"#project-list { font-size: 12px;}\");",
68             "",
69             "\tGtk.StyleContext.add_provider_for_display(",
70             "\t\tthis.el.get_display(),",
71             "\t\tthis.css,",
72             "\t\tGtk.STYLE_PROVIDER_PRIORITY_APPLICATION",
73             "\t);",
74             "\t\t",
75             "   ",
76             "}",
77             ""
78            ],
79            "* prop" : "child",
80            "Gtk.CssProvider css" : "",
81            "id" : "project_list",
82            "items" : [
83             {
84              "$ xns" : "Gtk",
85              "* prop" : "model",
86              "bool can_unselect" : true,
87              "id" : "projectselection",
88              "items" : [
89               {
90                "$ xns" : "Gtk",
91                "* prop" : "model",
92                "bool incremental" : true,
93                "id" : "projectsort",
94                "items" : [
95                 {
96                  "$ xns" : "GLib",
97                  "* prop" : "model",
98                  "GLib.Type item_type" : "typeof(Project.Project)",
99                  "id" : "projectmodel",
100                  "xtype" : "ListStore",
101                  "| void remove" : [
102                   "(Project.Project p) {",
103                   "",
104                   "\tfor (var i =0;i < this.el.n_items; i++ ) {",
105                   "\t\tvar pr = (Project.Project) this.el.get_item(i);",
106                   "\t\tif (p.path == pr.path) {",
107                   "\t\t\tthis.el.remove(i);",
108                   "\t\t\treturn;",
109                   "\t\t}",
110                   "\t}",
111                   "",
112                   "",
113                   "}"
114                  ]
115                 },
116                 {
117                  "$ xns" : "Gtk",
118                  "* prop" : "sorter",
119                  "items" : [
120                   {
121                    "$ xns" : "Gtk",
122                    "* prop" : "expression",
123                    "GLib.Type this_type" : "typeof(Project.Project)",
124                    "string property_name" : "name",
125                    "xtype" : "PropertyExpression"
126                   }
127                  ],
128                  "xtype" : "StringSorter"
129                 }
130                ],
131                "xtype" : "SortListModel"
132               }
133              ],
134              "listeners" : {
135               "notify[\"selected\"]" : [
136                "(position, n_items) => {",
137                "",
138                "    if (_this.is_loading) {",
139                "    \treturn;",
140                "\t}",
141                "  ",
142                "\tif (this.el.selected == Gtk.INVALID_LIST_POSITION) {",
143                "\t\t_this.btn_delproj.el.hide();",
144                "\t\t_this.btn_projprop.el.hide();",
145                "\t\t_this.btn_addfile.el.hide();",
146                "\t\t//_this.btn_delfile.el.hide();",
147                "\t\t ",
148                "\t} else {",
149                "\t\t_this.btn_delproj.el.show();",
150                "\t\t_this.btn_projprop.el.show();",
151                "\t\t_this.btn_addfile.el.show();",
152                "\t\t//_this.btn_delfile.el.show(); // ??",
153                "\t}",
154                " ",
155                " ",
156                " ",
157                "    ",
158                "    ",
159                "    if (_this.is_loading) {",
160                "        return;",
161                "    }",
162                "\t    ",
163                "\t Project.Project project  = this.el.selected == Gtk.INVALID_LIST_POSITION ? null :",
164                "\t\t \t(Project.Project) _this.projectsort.el.get_item(this.el.selected);",
165                "\t ",
166                "\t GLib.debug(\"selection changed to %s\", project == null ? \"none\" : project.name);",
167                "  ",
168                "    _this.onProjectSelected(project);",
169                "}",
170                ""
171               ]
172              },
173              "xtype" : "SingleSelection"
174             },
175             {
176              "$ xns" : "Gtk",
177              "* pack" : "append_column",
178              "bool expand" : true,
179              "items" : [
180               {
181                "$ xns" : "Gtk",
182                "* prop" : "factory",
183                "listeners" : {
184                 "bind" : [
185                  "(listitem) => {",
186                  " ",
187                  "\tvar lbl = (Gtk.Label)  ((Gtk.ListItem)listitem).get_child();",
188                  "\t   ",
189                  "\tvar item = (Project.Project)  ((Gtk.ListItem)listitem).get_item();",
190                  "",
191                  "\titem.bind_property(\"name\",",
192                  "                lbl, \"label\",",
193                  "           GLib.BindingFlags.SYNC_CREATE);",
194                  "",
195                  "\t  ",
196                  "}",
197                  ""
198                 ],
199                 "setup" : [
200                  "(item) => {",
201                  "\t//var j = (JsRender.JsRender) item;",
202                  "\tvar gi = (Gtk.ListItem)item;",
203                  "\t ",
204                  "\tvar lbl = new Gtk.Label(\"\");",
205                  "\tlbl.halign = Gtk.Align.START;",
206                  "\tgi.set_child(lbl);",
207                  "",
208                  "",
209                  "",
210                  "}",
211                  ""
212                 ]
213                },
214                "xtype" : "SignalListItemFactory"
215               }
216              ],
217              "string title" : "Project",
218              "xtype" : "ColumnViewColumn"
219             }
220            ],
221            "string name" : "project-list",
222            "xtype" : "ColumnView"
223           }
224          ],
225          "xtype" : "ScrolledWindow"
226         },
227         {
228          "$ xns" : "Gtk",
229          "* prop" : "end_child",
230          "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
231          "bool visible" : false,
232          "id" : "filepane",
233          "int position" : 200,
234          "items" : [
235           {
236            "$ xns" : "Gtk",
237            "* prop" : "end_child",
238            "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
239            "bool hexpand" : true,
240            "bool vexpand" : true,
241            "int spacing" : 0,
242            "items" : [
243             {
244              "$ xns" : "Gtk",
245              "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
246              "bool hexpand" : true,
247              "int spacing" : 0,
248              "items" : [
249               {
250                "$ xns" : "Gtk",
251                "* init" : [
252                 " ",
253                 "/*",
254                 "this.css = new Gtk.CssProvider();",
255                 "try {",
256                 "\tthis.css.load_from_data(\"#popover-files-iconsearch { font:  10px monospace;}\".data);",
257                 "} catch (Error e) {}",
258                 "this.el.get_style_context().add_provider(this.css,Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);",
259                 "        ",
260                 "        ",
261                 "*/"
262                ],
263                "Gtk.CssProvider css" : "",
264                "bool hexpand" : true,
265                "id" : "searchbox",
266                "listeners" : {
267                 "search_changed" : [
268                  "( ) => {",
269                  "",
270                  "\t_this.treefilter.el.changed(Gtk.FilterChange.DIFFERENT);",
271                  "\t_this.iconsearch.el.set_search(this.el.text);",
272                  "}",
273                  ""
274                 ]
275                },
276                "string name" : "popover-files-iconsearch",
277                "string placeholder_text" : "type to filter results",
278                "uint search_delay" : 1000,
279                "xtype" : "SearchEntry"
280               }
281              ],
282              "xtype" : "Box"
283             },
284             {
285              "$ xns" : "Gtk",
286              "* init" : [
287               "  this.el.set_policy (Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC);",
288               "  "
289              ],
290              "bool has_frame" : true,
291              "bool hexpand" : true,
292              "bool vexpand" : true,
293              "id" : "iconscroll",
294              "items" : [
295               {
296                "$ xns" : "Gtk",
297                "* prop" : "child",
298                "id" : "gridview",
299                "items" : [
300                 {
301                  "$ xns" : "Gtk",
302                  "listeners" : {
303                   "pressed" : [
304                    "(n_press, x, y) => {",
305                    "\tif (n_press == 2) {",
306                    "\t\tGLib.debug(\"double cliced\");",
307                    "\t} else {",
308                    "\t\treturn;",
309                    "\t}",
310                    "\tvar f = (JsRender.JsRender)_this.iconsel.el.selected_item;",
311                    "\t  ",
312                    "\tGLib.debug(\"Click %s\", f.name);",
313                    "\tif (f.xtype == \"Dir\") {",
314                    "\t\treturn;",
315                    "\t}",
316                    "\t",
317                    "\t",
318                    " \t_this.win.windowstate.fileViewOpen(f, _this.new_window);",
319                    "\t_this.el.hide();",
320                    "\t",
321                    "\t",
322                    "\t",
323                    "",
324                    "}",
325                    ""
326                   ]
327                  },
328                  "xtype" : "GestureClick"
329                 },
330                 {
331                  "$ xns" : "Gtk",
332                  "* prop" : "model",
333                  "bool can_unselect" : true,
334                  "id" : "iconsel",
335                  "items" : [
336                   {
337                    "$ xns" : "Gtk",
338                    "* prop" : "model",
339                    "items" : [
340                     {
341                      "$ xns" : "Gtk",
342                      "* prop" : "model",
343                      "id" : "gridsort",
344                      "items" : [
345                       {
346                        "$ xns" : "GLib",
347                        "* prop" : "model",
348                        "GLib.Type item_type" : "typeof(JsRender.JsRender)",
349                        "id" : "gridmodel",
350                        "xtype" : "ListStore",
351                        "| void remove" : [
352                         "(JsRender.JsRender p) {",
353                         "",
354                         "\tfor (var i =0;i < this.el.n_items; i++ ) {",
355                         "\t\tvar pr = (JsRender.JsRender) this.el.get_item(i);",
356                         "\t\tif (p.path == pr.path) {",
357                         "\t\t\tthis.el.remove(i);",
358                         "\t\t\treturn;",
359                         "\t\t}",
360                         "\t}",
361                         " ",
362                         "}"
363                        ]
364                       },
365                       {
366                        "$ xns" : "Gtk",
367                        "* prop" : "sorter",
368                        "bool ignore_case" : true,
369                        "items" : [
370                         {
371                          "$ xns" : "Gtk",
372                          "* prop" : "expression",
373                          "GLib.Type this_type" : "typeof(JsRender.JsRender)",
374                          "string property_name" : "name",
375                          "xtype" : "PropertyExpression"
376                         }
377                        ],
378                        "xtype" : "StringSorter"
379                       }
380                      ],
381                      "xtype" : "SortListModel"
382                     },
383                     {
384                      "$ Gtk.StringFilterMatchMode match_mode" : "Gtk.StringFilterMatchMode.SUBSTRING",
385                      "$ xns" : "Gtk",
386                      "* prop" : "filter",
387                      "bool ignore_case" : true,
388                      "id" : "iconsearch",
389                      "items" : [
390                       {
391                        "$ xns" : "Gtk",
392                        "* prop" : "expression",
393                        "GLib.Type this_type" : "typeof(JsRender.JsRender)",
394                        "string property_name" : "name",
395                        "xtype" : "PropertyExpression"
396                       }
397                      ],
398                      "xtype" : "StringFilter"
399                     }
400                    ],
401                    "xtype" : "FilterListModel"
402                   }
403                  ],
404                  "listeners" : {
405                   "notify[\"selected\"]" : [
406                    "() => {",
407                    "\tif (this.el.selected == Gtk.INVALID_LIST_POSITION) {",
408                    "\t\tif (_this.treeselmodel.el.selected == Gtk.INVALID_LIST_POSITION) {",
409                    "\t\t\t_this.btn_delfile.el.hide();",
410                    "\t\t}",
411                    "\t",
412                    "\t\treturn;",
413                    "\t}",
414                    "\t_this.btn_delfile.el.show();",
415                    "\t_this.treeselmodel.el.selected = Gtk.INVALID_LIST_POSITION;",
416                    "",
417                    "",
418                    "}",
419                    " ",
420                    " ",
421                    " "
422                   ]
423                  },
424                  "xtype" : "SingleSelection",
425                  "| JsRender.JsRender? selectedFile" : [
426                   "() {",
427                   "",
428                   "\tif (this.el.selected == Gtk.INVALID_LIST_POSITION) {",
429                   "\t\treturn null;",
430                   "\t}",
431                   "\treturn  (JsRender.JsRender)this.el.get_item(this.el.selected); ",
432                   "\t",
433                   " ",
434                   "}"
435                  ]
436                 },
437                 {
438                  "$ xns" : "Gtk",
439                  "* prop" : "factory",
440                  "listeners" : {
441                   "bind" : [
442                    "(listitem) => {",
443                    " ",
444                    "\tvar box = (Gtk.Box)  ((Gtk.ListItem)listitem).get_child();",
445                    "\t   ",
446                    "\tvar img = (Gtk.Image) box.get_first_child();",
447                    "\tvar lbl = (Gtk.Label)img.get_next_sibling();",
448                    "",
449                    "\tvar item = (JsRender.JsRender)  ((Gtk.ListItem)listitem).get_item();",
450                    "\t//GLib.debug(\"set label name to %s\", item.name);",
451                    "\t ",
452                    "\tvar ns = item.name.split(\".\");",
453                    "\tif (ns.length < 2) {",
454                    "\t\tlbl.label = item.name;",
455                    "\t} else {",
456                    "\t\tlbl.label =  ",
457                    "\t\t\titem.name.substring(0, item.name.length - ns[ns.length-1].length)",
458                    "\t\t \t + \"\\n\"+  ns[ns.length-1];",
459                    "\t}",
460                    "",
461                    "/*",
462                    "\titem.bind_property(\"name\",",
463                    "                lbl, \"label\",",
464                    "           GLib.BindingFlags.SYNC_CREATE);",
465                    "",
466                    "\t*/",
467                    "    img.set_from_file(item.getIconFileName());",
468                    "    ",
469                    "\t  ",
470                    "}",
471                    ""
472                   ],
473                   "setup" : [
474                    "(item) => {",
475                    "\t//var j = (JsRender.JsRender) item;",
476                    "\tvar gi = (Gtk.ListItem)item;",
477                    "\tvar b  = new Gtk.Box(Gtk.Orientation.VERTICAL,4);",
478                    "\tvar i = new Gtk.Image();",
479                    "\ti.pixel_size = 96;",
480                    "\tvar t = new Gtk.Label(\"\");",
481                    "\tb.append(i);",
482                    "\tb.append(t);",
483                    "\t",
484                    "\tgi.set_child(b);",
485                    "\tb.has_tooltip = true;",
486                    "\tb.query_tooltip.connect((x, y, keyboard_tooltip, tooltip) => {",
487                    "\t\tvar j = (JsRender.JsRender) gi.get_item();",
488                    "\t\t",
489                    "\t\tvar ti = new Gtk.Image.from_file ( j.getIconFileName());",
490                    "\t\tti.pixel_size = 368;",
491                    "\t\ttooltip.set_custom( ti );",
492                    "\t\treturn true;",
493                    "\t});",
494                    "",
495                    "",
496                    "}",
497                    ""
498                   ]
499                  },
500                  "xtype" : "SignalListItemFactory"
501                 }
502                ],
503                "xtype" : "GridView"
504               }
505              ],
506              "xtype" : "ScrolledWindow"
507             }
508            ],
509            "xtype" : "Box"
510           },
511           {
512            "$ xns" : "Gtk",
513            "* init" : "  this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);",
514            "* prop" : "start_child",
515            "bool has_frame" : true,
516            "bool hexpand" : true,
517            "bool vexpand" : true,
518            "bool visible" : true,
519            "id" : "treescroll",
520            "int width_request" : 200,
521            "items" : [
522             {
523              "$ xns" : "Gtk",
524              "* init" : [
525               "{",
526               " ",
527               "\tthis.css = new Gtk.CssProvider();",
528               " ",
529               "\tthis.css.load_from_string(\"#file-list { font-size: 12px;}\");",
530               "",
531               "\tGtk.StyleContext.add_provider_for_display(",
532               "\t\tthis.el.get_display(),",
533               "\t\tthis.css,",
534               "\t\tGtk.STYLE_PROVIDER_PRIORITY_APPLICATION",
535               "\t);",
536               "\t\t ",
537               "}",
538               ""
539              ],
540              "* prop" : "child",
541              "Gtk.CssProvider css" : "",
542              "id" : "treeview",
543              "items" : [
544               {
545                "$ xns" : "Gtk",
546                "listeners" : {
547                 "pressed" : [
548                  "(n_press, x, y) => {",
549                  "\tif (n_press == 2) {",
550                  "\t\tGLib.debug(\"double cliced\");",
551                  "\t} else {",
552                  "\t\treturn;",
553                  "\t}",
554                  "\tvar tr = (Gtk.TreeListRow)_this.treeselmodel.el.selected_item;",
555                  "\tGLib.debug(\"SELECTED = %s\", tr.item.get_type().name());",
556                  "\tvar f = (JsRender.JsRender) tr.item;",
557                  "\tGLib.debug(\"Click %s\", f.name);",
558                  "\tif (f.xtype == \"Dir\") {",
559                  "\t\treturn;",
560                  "\t}",
561                  "\t",
562                  "\t",
563                  " \t_this.win.windowstate.fileViewOpen(f, _this.new_window);",
564                  "\t",
565                  "\t_this.el.hide();",
566                  "\t",
567                  "\t",
568                  "",
569                  "}",
570                  ""
571                 ]
572                },
573                "xtype" : "GestureClick"
574               },
575               {
576                "$ xns" : "Gtk",
577                "* prop" : "model",
578                "bool can_unselect" : true,
579                "id" : "treeselmodel",
580                "items" : [
581                 {
582                  "$ xns" : "Gtk",
583                  "* prop" : "model",
584                  "items" : [
585                   {
586                    "$ xns" : "Gtk",
587                    "* prop" : "model",
588                    "bool incremental" : true,
589                    "id" : "treelistsort",
590                    "items" : [
591                     {
592                      "$ xns" : "Gtk",
593                      "* prop" : "model",
594                      "Gtk.TreeListModelCreateModelFunc create_func" : [
595                       "(item) => {",
596                       "\t//GLib.debug(\"liststore got %s\", item.get_type().name());",
597                       "\treturn ((JsRender.JsRender)item).childfiles;",
598                       "} "
599                      ],
600                      "bool autoexpand" : true,
601                      "bool passthrough" : false,
602                      "id" : "treelistmodel",
603                      "items" : [
604                       {
605                        "$ xns" : "GLib",
606                        "* prop" : "root",
607                        "GLib.Type item_type" : "typeof(JsRender.JsRender)",
608                        "id" : "treemodel",
609                        "xtype" : "ListStore"
610                       }
611                      ],
612                      "xtype" : "TreeListModel"
613                     },
614                     {
615                      "$ xns" : "Gtk",
616                      "* prop" : "sorter",
617                      "items" : [
618                       {
619                        "$ xns" : "Gtk",
620                        "* prop" : "sorter",
621                        "bool ignore_case" : true,
622                        "items" : [
623                         {
624                          "$ xns" : "Gtk",
625                          "* prop" : "expression",
626                          "GLib.Type this_type" : "typeof(JsRender.JsRender) ",
627                          "string property_name" : "name",
628                          "xtype" : "PropertyExpression"
629                         }
630                        ],
631                        "xtype" : "StringSorter"
632                       }
633                      ],
634                      "xtype" : "TreeListRowSorter"
635                     }
636                    ],
637                    "xtype" : "SortListModel"
638                   },
639                   {
640                    "$ xns" : "Gtk",
641                    "* prop" : "filter",
642                    "Gtk.CustomFilterFunc match_func" : [
643                     "(item) => { ",
644                     "\tvar tr = ((Gtk.TreeListRow)item).get_item();",
645                     "\t//GLib.debug(\"filter %s\", tr.get_type().name());",
646                     "\tvar j =  (JsRender.JsRender) tr;",
647                     "\tif (j.xtype == \"Dir\" && j.childfiles.n_items < 1) {",
648                     "\t\treturn false;",
649                     "\t}",
650                     "\tvar str = _this.searchbox.el.text.down();\t",
651                     "\tif (j.xtype == \"Dir\") {",
652                     "\t",
653                     "\t\tif (str.length < 1) {",
654                     "\t\t\treturn true;",
655                     "\t\t}",
656                     "\t\tfor (var i =0 ; i < j.childfiles.n_items; i++) {",
657                     "\t\t\tvar f = (JsRender.JsRender) j.childfiles.get_item(i);",
658                     "\t\t\tif (f.xtype != \"PlainFile\") {",
659                     "\t\t\t\tcontinue;",
660                     "\t\t\t}",
661                     "\t\t\tif (f.name.down().contains(str)) {",
662                     "\t\t\t\treturn true;",
663                     "\t\t\t}",
664                     "\t\t}",
665                     "\t\treturn false;",
666                     "\t}",
667                     "\tif (j.xtype != \"PlainFile\") {",
668                     "\t\treturn false;",
669                     "\t}",
670                     "",
671                     "\tif (str.length < 1) {",
672                     "\t\treturn true;",
673                     "\t}",
674                     "\tif (j.name.down().contains(str)) {",
675                     "\t\treturn true;",
676                     "\t}",
677                     "\treturn false; ",
678                     "",
679                     "}"
680                    ],
681                    "id" : "treefilter",
682                    "xtype" : "CustomFilter"
683                   }
684                  ],
685                  "xtype" : "FilterListModel"
686                 }
687                ],
688                "listeners" : {
689                 "notify[\"selected\"]" : [
690                  "() => {",
691                  "\tif (this.el.selected == Gtk.INVALID_LIST_POSITION) {",
692                  "\t\tif (_this.iconsel.el.selected == Gtk.INVALID_LIST_POSITION) {",
693                  "\t\t\t_this.btn_delfile.el.hide();",
694                  "\t\t}",
695                  "\t\treturn;",
696                  "\t}",
697                  "\t",
698                  "\tvar tr = (Gtk.TreeListRow)_this.treeselmodel.el.selected_item;",
699                  "\tGLib.debug(\"SELECTED = %s\", tr.item.get_type().name());",
700                  "\tvar f = (JsRender.JsRender) tr.item;",
701                  "\tif (f.xtype == \"Dir\") {",
702                  "\t\t_this.btn_delfile.el.hide();\t",
703                  "\t} else {",
704                  "\t\t_this.btn_delfile.el.show();",
705                  "\t}",
706                  "",
707                  "\t_this.iconsel.el.selected = Gtk.INVALID_LIST_POSITION;",
708                  "",
709                  "",
710                  "}",
711                  " ",
712                  " ",
713                  " "
714                 ]
715                },
716                "xtype" : "SingleSelection",
717                "| JsRender.JsRender? selectedFile" : [
718                 "() {",
719                 "",
720                 "\tif (this.el.selected == Gtk.INVALID_LIST_POSITION) {",
721                 "\t\treturn null;",
722                 "\t}",
723                 "\tvar tr = (Gtk.TreeListRow) this.el.selected_item;",
724                 "",
725                 "\treturn  (JsRender.JsRender) tr.item;",
726                 "}"
727                ]
728               },
729               {
730                "$ xns" : "Gtk",
731                "* init" : [
732                 "{",
733                 "\t// this.el.set_sorter(  new Gtk.StringSorter(",
734                 "\t// \tnew Gtk.PropertyExpression(typeof(JsRender.NodeProp), null, \"name\")",
735                 " //\t));",
736                 "\t\t",
737                 "}",
738                 ""
739                ],
740                "* pack" : "append_column",
741                "bool expand" : true,
742                "bool resizable" : true,
743                "id" : "name",
744                "items" : [
745                 {
746                  "$ xns" : "Gtk",
747                  "* prop" : "factory",
748                  "listeners" : {
749                   "bind" : [
750                    "(listitem) => {",
751                    "\t //GLib.debug(\"listitme is is %s\", ((Gtk.ListItem)listitem).get_type().name());",
752                    "\t",
753                    "\t",
754                    "\t",
755                    "\t//var expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child();",
756                    "\tvar expand = (Gtk.TreeExpander)  ((Gtk.ListItem)listitem).get_child();",
757                    "\t  ",
758                    " ",
759                    "\tvar lbl = (Gtk.Label) expand.child;",
760                    "\t",
761                    "\t if (lbl.label != \"\") { // do not update",
762                    "\t \treturn;",
763                    " \t}",
764                    "\tvar lr = (Gtk.TreeListRow)((Gtk.ListItem)listitem).get_item();",
765                    "\t//GLib.debug(\"LR = %s\", lr.get_type().name());",
766                    "",
767                    "\t",
768                    "\tvar jr =(JsRender.JsRender) lr.get_item();",
769                    "\t//GLib.debug(\"JR = %s\", jr.get_type().name());\t\t",
770                    "\t",
771                    "\t if (jr == null) {",
772                    "\t\t GLib.debug(\"Problem getting item\"); ",
773                    "\t\t return;",
774                    "\t }",
775                    "\t//GLib.debug(\"change  %s to %s\", lbl.label, np.name);",
776                    "\tlbl.label = jr.name; // for dir's we could hsow the sub path..",
777                    "\tlbl.tooltip_markup = jr.path;",
778                    "\t ",
779                    "    expand.set_hide_expander(  jr.xtype != \"Dir\" );",
780                    " \t expand.set_list_row(lr);",
781                    " ",
782                    " \t ",
783                    " \t// bind image...",
784                    " \t",
785                    "}",
786                    "",
787                    "",
788                    ""
789                   ],
790                   "setup" : [
791                    "(listitem) => {",
792                    "\t",
793                    "\tvar expand = new Gtk.TreeExpander();",
794                    "\t ",
795                    "\texpand.set_indent_for_depth(true);",
796                    "\texpand.set_indent_for_icon(true);",
797                    "\t ",
798                    "\tvar lbl = new Gtk.Label(\"\");",
799                    "\tlbl.use_markup = true;",
800                    "\t",
801                    "\t",
802                    " \tlbl.justify = Gtk.Justification.LEFT;",
803                    " \tlbl.xalign = 0;",
804                    "",
805                    " ",
806                    "\texpand.set_child(lbl);",
807                    "\t((Gtk.ListItem)listitem).set_child(expand);",
808                    "\t((Gtk.ListItem)listitem).activatable = false;",
809                    "}",
810                    ""
811                   ]
812                  },
813                  "xtype" : "SignalListItemFactory"
814                 }
815                ],
816                "string title" : "General Files",
817                "xtype" : "ColumnViewColumn"
818               }
819              ],
820              "string name" : "file-list",
821              "xtype" : "ColumnView"
822             }
823            ],
824            "xtype" : "ScrolledWindow"
825           }
826          ],
827          "xtype" : "Paned"
828         }
829        ],
830        "xtype" : "Paned"
831       }
832      ],
833      "xtype" : "Box"
834     },
835     {
836      "$ xns" : "Gtk",
837      "* prop" : "titlebar",
838      "* title" : "Select Project / File",
839      "bool show_title_buttons" : false,
840      "items" : [
841       {
842        "$ xns" : "Gtk",
843        "* pack" : "pack_end",
844        "listeners" : {
845         "clicked" : [
846          "( ) => {",
847          "\tif (BuilderApplication.windows.size < 2 && ",
848          "\t\t_this.win.windowstate.file == null",
849          "\t) { ",
850          "\t\tBuilderApplication.singleton(null).quit();",
851          "\t\treturn;",
852          "\t}",
853          "",
854          "\t_this.el.hide();",
855          "\t",
856          "\t if (_this.win.windowstate.file == null) {\t\t ",
857          "\t\tBuilderApplication.removeWindow(_this.win);",
858          "\t\t ",
859          "\t\t ",
860          "\t\t",
861          "\t}",
862          "",
863          "}",
864          ""
865         ]
866        },
867        "string label" : "Close / Cancel",
868        "xtype" : "Button"
869       },
870       {
871        "$ xns" : "Gtk",
872        "* pack" : "pack_start",
873        "id" : "btn_newproj",
874        "items" : [
875         {
876          "$ Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
877          "$ xns" : "Gtk",
878          "* prop" : "child",
879          "items" : [
880           {
881            "$ Gtk.IconSize icon_size" : "Gtk.IconSize.NORMAL",
882            "$ xns" : "Gtk",
883            "int margin_end" : 4,
884            "string icon_name" : "folder-new",
885            "xtype" : "Image"
886           },
887           {
888            "$ Gtk.Align halign" : "Gtk.Align.START",
889            "$ xns" : "Gtk",
890            "string label" : "New Project",
891            "xtype" : "Label"
892           }
893          ],
894          "xtype" : "Box"
895         }
896        ],
897        "listeners" : {
898         "clicked" : [
899          "  ( ) => {",
900          "  ",
901          "    // create a new file in project..",
902          "    //Xcls_DialogNewComponent.singleton().show(",
903          "   var  pe =      EditProject.singleton();",
904          "   pe.windowstate = _this.win.windowstate;",
905          "   ",
906          "   pe.el.application = _this.win.el.application;",
907          "    pe.el.set_transient_for( _this.el );",
908          " ",
909          "    var cb = new Project.Callback();",
910          "    cb.call.connect((pr) => {",
911          "    \t_this.show(  pr , _this.new_window);",
912          "\t});",
913          "      ",
914          "    pe.show( cb);",
915          "   ",
916          "",
917          "}"
918         ]
919        },
920        "xtype" : "Button",
921        "| void onCreated" : [
922         "() {",
923         "\tvar pe =      EditProject.singleton();",
924         "",
925         "\t_this.show(  pe.result , _this.new_window);",
926         "}"
927        ]
928       },
929       {
930        "$ xns" : "Gtk",
931        "* pack" : "pack_start",
932        "id" : "btn_projprop",
933        "items" : [
934         {
935          "$ xns" : "Gtk",
936          "* prop" : "child",
937          "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
938          "int spacing" : 0,
939          "items" : [
940           {
941            "$ xns" : "Gtk",
942            "int margin_end" : 4,
943            "string icon_name" : "emblem-system",
944            "xtype" : "Image"
945           },
946           {
947            "$ xns" : "Gtk",
948            "string label" : "Project Properties",
949            "xtype" : "Label"
950           }
951          ],
952          "xtype" : "Box"
953         }
954        ],
955        "listeners" : {
956         "clicked" : [
957          "  ( ) => {",
958          "  // should disable the button really.",
959          "   if (_this.selectedProject == null) {",
960          "\t   return;",
961          "   }",
962          "\t_this.win.windowstate.projectPopoverShow(_this.el, _this.selectedProject, null);",
963          " }"
964         ]
965        },
966        "xtype" : "Button"
967       },
968       {
969        "$ xns" : "Gtk",
970        "* pack" : "pack_start",
971        "DialogConfirm confirm" : "null",
972        "id" : "btn_delproj",
973        "items" : [
974         {
975          "$ xns" : "Gtk",
976          "* prop" : "child",
977          "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
978          "int spacing" : 0,
979          "items" : [
980           {
981            "$ xns" : "Gtk",
982            "string icon_name" : "user-trash",
983            "xtype" : "Image"
984           },
985           {
986            "$ xns" : "Gtk",
987            "string label" : "Delete Project",
988            "xtype" : "Label"
989           }
990          ],
991          "xtype" : "Box"
992         }
993        ],
994        "listeners" : {
995         "clicked" : [
996          "  ( ) => {",
997          "  ",
998          "  ",
999          "  \tif (this.confirm == null) {",
1000          "  \t\tthis.confirm = new DialogConfirm();",
1001          "   \t\tthis.confirm.el.set_transient_for(_this.el);",
1002          "\t}",
1003          "\t",
1004          "\tvar project  = (Project.Project) _this.projectsort.el.get_item(",
1005          "\t\t_this.projectselection.el.selected",
1006          "\t\t);",
1007          "\t",
1008          "\tthis.confirm.el.response.connect((res) => {",
1009          "\t\tthis.confirm.el.hide();",
1010          "\t\tif (res == Gtk.ResponseType.CANCEL) {",
1011          "\t\t\treturn;",
1012          "\t\t}",
1013          "\t   project  = (Project.Project) _this.projectsort.el.get_item(",
1014          "\t\t\t_this.projectselection.el.selected",
1015          "\t\t);",
1016          "\t\tProject.Project.remove(project);",
1017          "\t  _this.projectmodel.remove(project);",
1018          "\t\t_this.projectselection.el.selected = Gtk.INVALID_LIST_POSITION;",
1019          "\t",
1020          "\t});",
1021          "  \tthis.confirm.showIt(\"Confirm Delete Project\", \"Are you sure you want to delete this project?\");",
1022          "}"
1023         ]
1024        },
1025        "xtype" : "Button"
1026       },
1027       {
1028        "$ xns" : "Gtk",
1029        "* pack" : "pack_start",
1030        "id" : "btn_addfile",
1031        "items" : [
1032         {
1033          "$ xns" : "Gtk",
1034          "* prop" : "child",
1035          "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
1036          "int spacing" : 0,
1037          "items" : [
1038           {
1039            "$ xns" : "Gtk",
1040            "int margin_end" : 4,
1041            "string icon_name" : "document-new",
1042            "xtype" : "Image"
1043           },
1044           {
1045            "$ xns" : "Gtk",
1046            "string label" : "New File",
1047            "xtype" : "Label"
1048           }
1049          ],
1050          "xtype" : "Box"
1051         }
1052        ],
1053        "listeners" : {
1054         "clicked" : [
1055          " () => {",
1056          "    // create a new file in project..",
1057          "    print(\"add file selected\\n\");",
1058          "    ",
1059          "    if (_this.selectedProject == null) {",
1060          "    \treturn;",
1061          "    }",
1062          "    try {",
1063          "    \tvar f = JsRender.JsRender.factory(_this.selectedProject.xtype,  _this.selectedProject, \"\");",
1064          "     \t_this.win.windowstate.file_details.show( f, _this.el, _this.new_window );",
1065          "     } catch (JsRender.Error e) {}",
1066          "",
1067          "}"
1068         ]
1069        },
1070        "xtype" : "Button"
1071       },
1072       {
1073        "$ xns" : "Gtk",
1074        "* pack" : "pack_start",
1075        "DialogConfirm confirm" : "null",
1076        "id" : "btn_delfile",
1077        "items" : [
1078         {
1079          "$ xns" : "Gtk",
1080          "* prop" : "child",
1081          "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
1082          "int spacing" : 0,
1083          "items" : [
1084           {
1085            "$ xns" : "Gtk",
1086            "string icon_name" : "user-trash",
1087            "xtype" : "Image"
1088           },
1089           {
1090            "$ xns" : "Gtk",
1091            "string label" : "Delete File",
1092            "xtype" : "Label"
1093           }
1094          ],
1095          "xtype" : "Box"
1096         }
1097        ],
1098        "listeners" : {
1099         "clicked" : [
1100          "  ( ) => {",
1101          "  ",
1102          "  \tif (this.confirm == null) {",
1103          "  \t\tthis.confirm = new DialogConfirm();",
1104          "  \t\tthis.confirm.el.set_transient_for(_this.el);",
1105          " ",
1106          "\t}",
1107          "\tGLib.debug(\"DELETE\");",
1108          "\tvar is_icon = true;",
1109          "  \tvar isel = _this.iconsel.selectedFile();",
1110          "  \t ",
1111          "  \tif (isel == null) {",
1112          "  \t\tGLib.debug(\"DELETE - no icons selected\");",
1113          "\t  \tis_icon = false;",
1114          "\t  \tisel = _this.treeselmodel.selectedFile();",
1115          "  \t}",
1116          "  \tif (isel == null) {",
1117          "  \t  \t\tGLib.debug(\"DELETE - no tree item selected\");",
1118          "  \t\treturn; // should nto happen..",
1119          "\t}",
1120          "\t",
1121          "\tGLib.debug(\"DELETE - calling confirm.\");",
1122          "\tthis.confirm.el.response.connect((res) => {",
1123          "\t\tthis.confirm.el.hide();",
1124          "\t\tif (res == Gtk.ResponseType.CANCEL) {",
1125          "\t\t\treturn;",
1126          "\t\t}",
1127          "\t\tis_icon = true;",
1128          "\t  \tisel = _this.iconsel.selectedFile();",
1129          "\t  \tif (isel == null) {",
1130          "\t\t  \tis_icon = false;",
1131          "\t\t  \tisel = _this.treeselmodel.selectedFile();",
1132          "\t  \t}",
1133          "\t  \tif (isel == null) {",
1134          "\t  \t\treturn; // should nto happen..",
1135          "\t\t}",
1136          "\t\t",
1137          "\t  \tif (is_icon) {",
1138          "\t\t  \tisel.project.deleteFile(isel);",
1139          "\t  \t\t_this.gridmodel.remove(isel);",
1140          "\t  \t\treturn;",
1141          "  \t\t}",
1142          "  \t\tisel.project.deleteFile(isel);  \t\t",
1143          "\t",
1144          "\t});",
1145          "\t  \tthis.confirm.showIt(\"Confirm Delete File\",",
1146          "\t  \t\t\"Are you sure you want to delete this file?\");",
1147          "  \t",
1148          " ",
1149          "",
1150          "}  "
1151         ]
1152        },
1153        "xtype" : "Button"
1154       }
1155      ],
1156      "xtype" : "HeaderBar"
1157     }
1158    ],
1159    "name" : "DialogFiles",
1160    "string lastfilter" : "",
1161    "title" : "Select Project / File",
1162    "xtype" : "Window",
1163    "| void load" : [
1164     "() {",
1165     "     // clear list...",
1166     "    ",
1167     "      ",
1168     "     _this.is_loading = true;",
1169     "         ",
1170     "     ",
1171     "     Project.Project.loadAll();",
1172     "     _this.project_list.el.set_model(new Gtk.SingleSelection(null));",
1173     "     Project.Project.loadIntoStore(this.projectmodel.el);",
1174     "",
1175     "\t_this.project_list.el.set_model(_this.projectselection.el);",
1176     "\t",
1177     "\t_this.is_loading = false;",
1178     "    ",
1179     "    _this.projectselection.el.selected = Gtk.INVALID_LIST_POSITION; ",
1180     "\t_this.btn_delfile.el.hide();",
1181     "\t",
1182     "  ",
1183     "}",
1184     ""
1185    ],
1186    "| void onProjectSelected" : [
1187     "(Project.Project? project) ",
1188     "{",
1189     "\tif (this.in_onprojectselected) { ",
1190     "\t\treturn;",
1191     "\t}",
1192     "\tthis.selectedProject = project;",
1193     "\t",
1194     "\tif (project == null) {",
1195     "\t\tGLib.debug(\"Hide project files\");",
1196     "\t\t_this.mainpane.el.set_end_child(null);",
1197     "\t\t_this.filepane.el.hide();",
1198     "\t\treturn;",
1199     "\t\t",
1200     "\t}",
1201     "\t",
1202     "\tGLib.debug(\"Show project files\");",
1203     "\t_this.mainpane.el.set_end_child(_this.filepane.el);",
1204     "\t",
1205     "\t_this.filepane.el.show();\t",
1206     "\tthis.in_onprojectselected = true;",
1207     "\t",
1208     "\t",
1209     "",
1210     "\tproject.load();",
1211     "\t ",
1212     "\t",
1213     "\t_this.searchbox.el.text = \"\";",
1214     "\t _this.gridview.el.set_model(new Gtk.SingleSelection(null));",
1215     "\t _this.selectedProject.loadFilesIntoStore(_this.gridmodel.el);",
1216     "\t _this.iconsel.el.selected = Gtk.INVALID_LIST_POSITION;",
1217     "  \t \t",
1218     "\t _this.gridview.el.set_model(_this.iconsel.el);",
1219     "\t   ",
1220     "  \t ",
1221     "  \t GLib.Timeout.add(500, () => {",
1222     " \t\t_this.iconsel.el.selected = Gtk.INVALID_LIST_POSITION;",
1223     "  \t \t _this.treeselmodel.el.selected = Gtk.INVALID_LIST_POSITION;\t\t ",
1224     "\t ",
1225     "\t     _this.searchbox.el.grab_focus();",
1226     "\t\t   return false;",
1227     "     });",
1228     "\t _this.treeview.el.set_model(new Gtk.SingleSelection(null));",
1229     "    ",
1230     "    this.selectedProject.loadDirsIntoStore(_this.treemodel.el);",
1231     "    ",
1232     "    _this.treeview.el.set_model(_this.treeselmodel.el);",
1233     "    ",
1234     " \t _this.treeselmodel.el.selected = Gtk.INVALID_LIST_POSITION;",
1235     " \tthis.treescroll.el.vadjustment.value = 0;",
1236     "\tthis.in_onprojectselected = false;\t",
1237     "}",
1238     ""
1239    ],
1240    "| void selectProject" : [
1241     "(Project.Project? project) {",
1242     "    ",
1243     "\t",
1244     "\t ",
1245     "\tvar sm = this.projectselection.el;",
1246     "\tif (project == null) {",
1247     "\t\tsm.selected = Gtk.INVALID_LIST_POSITION;",
1248     "\t\tthis.onProjectSelected(null);",
1249     "\t\treturn;",
1250     "\t}",
1251     "",
1252     "\t",
1253     "\tfor (var i =0; i < sm.n_items; i++) {",
1254     "\t\tvar p = (Project.Project) sm.get_item(i);",
1255     "\t\tif (p.path == project.path) {",
1256     "\t\t\tGLib.debug(\"Select Project %s => %d\", project.name, i);",
1257     "\t\t\tsm.selected = i;",
1258     "\t\t\tbreak;",
1259     "\t\t}",
1260     "\t} ",
1261     "\t",
1262     "}",
1263     ""
1264    ],
1265    "| void show" : [
1266     "(Project.Project? project, bool new_window) {",
1267     "      ",
1268     " \tthis.new_window = new_window;",
1269     "",
1270     "    this.projectscroll.el.vadjustment.value = 0; // scroll to top?",
1271     "    ",
1272     "  ",
1273     "\t  //var win = this.win.el;",
1274     "      //var  w = win.get_width();",
1275     "      //var h = win.get_height();",
1276     " ",
1277     "\t",
1278     "\t this.el.show();",
1279     " this.load();",
1280     "\tthis.selectProject(project);",
1281     "\tthis.onProjectSelected(project);   //?? twice?",
1282     "\t ",
1283     "\t    GLib.Timeout.add(500, () => {",
1284     "\t    \tif (project == null) {",
1285     "    \t   \t\t_this.projectselection.el.selected = Gtk.INVALID_LIST_POSITION;",
1286     "\t\t\t\tthis.onProjectSelected(null); ",
1287     "\t",
1288     "\t\t\t} ",
1289     "\t          this.el.set_size_request( 800 , 750);  // ?? based on default ",
1290     "\t     return false;",
1291     "     });",
1292     "\t ",
1293     "}//"
1294    ]
1295   }
1296  ],
1297  "name" : "DialogFiles"
1298 }