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