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