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