c7412a0fd323b36d06e44fcc433396d166b7d621
[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\tif (str.length < 1) {",
664                     "\t\t\treturn true;",
665                     "\t\t}",
666                     "\t\tfor (var i =0 ; i < j.childfiles.n_items; i++) {",
667                     "\t\t\tvar f = (JsRender.JsRender) j.childfiles.get_item(i);",
668                     "\t\t\tif (f.xtype != \"PlainFile\") {",
669                     "\t\t\t\tcontinue;",
670                     "\t\t\t}",
671                     "\t\t\tif (f.name.down().contains(str)) {",
672                     "\t\t\t\treturn true;",
673                     "\t\t\t}",
674                     "\t\t}",
675                     "\t\treturn false;",
676                     "\t}",
677                     "\tif (j.xtype != \"PlainFile\") {",
678                     "\t\treturn false;",
679                     "\t}",
680                     "",
681                     "\tif (str.length < 1) {",
682                     "\t\treturn true;",
683                     "\t}",
684                     "\tif (j.name.down().contains(str)) {",
685                     "\t\treturn true;",
686                     "\t}",
687                     "\treturn false; ",
688                     "",
689                     "}"
690                    ],
691                    "id" : "treefilter",
692                    "xtype" : "CustomFilter"
693                   }
694                  ],
695                  "xtype" : "FilterListModel"
696                 }
697                ],
698                "listeners" : {
699                 "notify[\"selected\"]" : [
700                  "() => {",
701                  "\tif (this.el.selected == Gtk.INVALID_LIST_POSITION) {",
702                  "\t\tif (_this.iconsel.el.selected == Gtk.INVALID_LIST_POSITION) {",
703                  "\t\t\t_this.btn_delfile.el.hide();",
704                  "\t\t}",
705                  "\t\treturn;",
706                  "\t}",
707                  "\t",
708                  "\tvar tr = (Gtk.TreeListRow)_this.treeselmodel.el.selected_item;",
709                  "\tGLib.debug(\"SELECTED = %s\", tr.item.get_type().name());",
710                  "\tvar f = (JsRender.JsRender) tr.item;",
711                  "\tif (f.xtype == \"Dir\") {",
712                  "\t\t_this.btn_delfile.el.hide();\t",
713                  "\t} else {",
714                  "\t\t_this.btn_delfile.el.show();",
715                  "\t}",
716                  "",
717                  "\t_this.iconsel.el.selected = Gtk.INVALID_LIST_POSITION;",
718                  "",
719                  "",
720                  "}",
721                  " ",
722                  " ",
723                  " "
724                 ]
725                },
726                "xtype" : "SingleSelection",
727                "| JsRender.JsRender? selectedFile" : [
728                 "() {",
729                 "",
730                 "\tif (this.el.selected == Gtk.INVALID_LIST_POSITION) {",
731                 "\t\treturn null;",
732                 "\t}",
733                 "\tvar tr = (Gtk.TreeListRow) this.el.selected_item;",
734                 "",
735                 "\treturn  (JsRender.JsRender) tr.item;",
736                 "}"
737                ]
738               },
739               {
740                "$ xns" : "Gtk",
741                "* init" : [
742                 "{",
743                 "\t// this.el.set_sorter(  new Gtk.StringSorter(",
744                 "\t// \tnew Gtk.PropertyExpression(typeof(JsRender.NodeProp), null, \"name\")",
745                 " //\t));",
746                 "\t\t",
747                 "}",
748                 ""
749                ],
750                "* pack" : "append_column",
751                "bool expand" : true,
752                "bool resizable" : true,
753                "id" : "name",
754                "items" : [
755                 {
756                  "$ xns" : "Gtk",
757                  "* prop" : "factory",
758                  "listeners" : {
759                   "bind" : [
760                    "(listitem) => {",
761                    "\t",
762                    "\t //GLib.debug(\"listitme is is %s\", ((Gtk.ListItem)listitem).get_type().name());",
763                    "                \t",
764                    "            \t",
765                    "            \t",
766                    "        \t//var expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child();",
767                    "    \tvar expand = (Gtk.TreeExpander)  ((Gtk.ListItem)listitem).get_child();",
768                    "    \t  ",
769                    "     \tvar hbox = (Gtk.Box) expand.child;",
770                    " ",
771                    "\t",
772                    "\t\tvar img = (Gtk.Image) hbox.get_first_child();",
773                    "\t\tvar lbl = (Gtk.Label) img.get_next_sibling();",
774                    "",
775                    " ",
776                    "    \t",
777                    "    \t if (lbl.label != \"\") { // do not update",
778                    "    \t \treturn;",
779                    "     \t}",
780                    "    \tvar lr = (Gtk.TreeListRow)((Gtk.ListItem)listitem).get_item();",
781                    "    \t//GLib.debug(\"LR = %s\", lr.get_type().name());",
782                    "    ",
783                    "    \t",
784                    "    \tvar jr =(JsRender.JsRender) lr.get_item();",
785                    "    \t//GLib.debug(\"JR = %s\", jr.get_type().name());\t\t",
786                    "    \t",
787                    "    \t if (jr == null) {",
788                    "    \t\t GLib.debug(\"Problem getting item\"); ",
789                    "    \t\t return;",
790                    "    \t }",
791                    "",
792                    "\t\tjr.bind_property(\"icon\",",
793                    "                img, \"gicon\",",
794                    "               GLib.BindingFlags.SYNC_CREATE);",
795                    "",
796                    "    \t//GLib.debug(\"change  %s to %s\", lbl.label, np.name);",
797                    "    \tlbl.label = jr.name; // for dir's we could hsow the sub path..",
798                    "    \tlbl.tooltip_markup = jr.path;",
799                    "    \t ",
800                    "        expand.set_hide_expander(  jr.xtype != \"Dir\" );",
801                    "     \t expand.set_list_row(lr);",
802                    "     ",
803                    "         \t ",
804                    "                 \t// bind image...",
805                    "}",
806                    ""
807                   ],
808                   "setup" : [
809                    "(listitem) => {",
810                    "\t",
811                    "\tvar expand = new Gtk.TreeExpander();",
812                    "\t ",
813                    "\texpand.set_indent_for_depth(true);",
814                    "\texpand.set_indent_for_icon(true);",
815                    "\tvar hbox = new Gtk.Box(Gtk.Orientation.HORIZONTAL,0);",
816                    "\tvar icon = new Gtk.Image();",
817                    "\ticon.margin_end = 4;",
818                    "\tvar lbl = new Gtk.Label(\"\");",
819                    "\tlbl.use_markup = true;",
820                    "\t",
821                    "\t",
822                    " \tlbl.justify = Gtk.Justification.LEFT;",
823                    " \tlbl.xalign = 0;",
824                    "",
825                    " \thbox.append(icon);",
826                    "\thbox.append(lbl);",
827                    "\texpand.set_child(hbox);",
828                    "\t((Gtk.ListItem)listitem).set_child(expand);",
829                    "\t((Gtk.ListItem)listitem).activatable = false;",
830                    "}",
831                    ""
832                   ]
833                  },
834                  "xtype" : "SignalListItemFactory"
835                 }
836                ],
837                "string title" : "General Files",
838                "xtype" : "ColumnViewColumn"
839               }
840              ],
841              "string name" : "file-list",
842              "xtype" : "ColumnView"
843             }
844            ],
845            "xtype" : "ScrolledWindow"
846           }
847          ],
848          "xtype" : "Paned"
849         }
850        ],
851        "xtype" : "Paned"
852       }
853      ],
854      "xtype" : "Box"
855     },
856     {
857      "$ xns" : "Gtk",
858      "* prop" : "titlebar",
859      "* title" : "Select Project / File",
860      "bool show_title_buttons" : false,
861      "items" : [
862       {
863        "$ xns" : "Gtk",
864        "* pack" : "pack_end",
865        "listeners" : {
866         "clicked" : [
867          "( ) => {",
868          "\tif (BuilderApplication.windows.size < 2 && ",
869          "\t\t_this.win.windowstate.file == null",
870          "\t) { ",
871          "\t\tBuilderApplication.singleton(null).quit();",
872          "\t\treturn;",
873          "\t}",
874          "",
875          "\t_this.el.hide();",
876          "\t",
877          "\t if (_this.win.windowstate.file == null) {\t\t ",
878          "\t\tBuilderApplication.removeWindow(_this.win);",
879          "\t\t ",
880          "\t\t ",
881          "\t\t",
882          "\t}",
883          "",
884          "}",
885          ""
886         ]
887        },
888        "string label" : "Close / Cancel",
889        "xtype" : "Button"
890       },
891       {
892        "$ xns" : "Gtk",
893        "* pack" : "pack_start",
894        "id" : "btn_newproj",
895        "items" : [
896         {
897          "$ Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
898          "$ xns" : "Gtk",
899          "* prop" : "child",
900          "items" : [
901           {
902            "$ Gtk.IconSize icon_size" : "Gtk.IconSize.NORMAL",
903            "$ xns" : "Gtk",
904            "int margin_end" : 4,
905            "string icon_name" : "folder-new",
906            "xtype" : "Image"
907           },
908           {
909            "$ Gtk.Align halign" : "Gtk.Align.START",
910            "$ xns" : "Gtk",
911            "string label" : "New Project",
912            "xtype" : "Label"
913           }
914          ],
915          "xtype" : "Box"
916         }
917        ],
918        "listeners" : {
919         "clicked" : [
920          "  ( ) => {",
921          "  ",
922          "    // create a new file in project..",
923          "    //Xcls_DialogNewComponent.singleton().show(",
924          "   var  pe =      EditProject.singleton();",
925          "   pe.windowstate = _this.win.windowstate;",
926          "   ",
927          "   pe.el.application = _this.win.el.application;",
928          "    pe.el.set_transient_for( _this.el );",
929          " ",
930          "    var cb = new Project.Callback();",
931          "    cb.call.connect((pr) => {",
932          "    \t_this.show(  pr , _this.new_window);",
933          "\t});",
934          "      ",
935          "    pe.show( cb);",
936          "   ",
937          "",
938          "}"
939         ]
940        },
941        "xtype" : "Button",
942        "| void onCreated" : [
943         "() {",
944         "\tvar pe =      EditProject.singleton();",
945         "",
946         "\t_this.show(  pe.result , _this.new_window);",
947         "}"
948        ]
949       },
950       {
951        "$ xns" : "Gtk",
952        "* pack" : "pack_start",
953        "id" : "btn_projprop",
954        "items" : [
955         {
956          "$ xns" : "Gtk",
957          "* prop" : "child",
958          "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
959          "int spacing" : 0,
960          "items" : [
961           {
962            "$ xns" : "Gtk",
963            "int margin_end" : 4,
964            "string icon_name" : "emblem-system",
965            "xtype" : "Image"
966           },
967           {
968            "$ xns" : "Gtk",
969            "string label" : "Project Properties",
970            "xtype" : "Label"
971           }
972          ],
973          "xtype" : "Box"
974         }
975        ],
976        "listeners" : {
977         "clicked" : [
978          "  ( ) => {",
979          "  // should disable the button really.",
980          "   if (_this.selectedProject == null) {",
981          "\t   return;",
982          "   }",
983          "\t_this.win.windowstate.projectPopoverShow(_this.el, _this.selectedProject, null);",
984          " }"
985         ]
986        },
987        "xtype" : "Button"
988       },
989       {
990        "$ xns" : "Gtk",
991        "* pack" : "pack_start",
992        "DialogConfirm confirm" : "null",
993        "id" : "btn_delproj",
994        "items" : [
995         {
996          "$ xns" : "Gtk",
997          "* prop" : "child",
998          "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
999          "int spacing" : 0,
1000          "items" : [
1001           {
1002            "$ xns" : "Gtk",
1003            "string icon_name" : "user-trash",
1004            "xtype" : "Image"
1005           },
1006           {
1007            "$ xns" : "Gtk",
1008            "string label" : "Delete Project",
1009            "xtype" : "Label"
1010           }
1011          ],
1012          "xtype" : "Box"
1013         }
1014        ],
1015        "listeners" : {
1016         "clicked" : [
1017          "  ( ) => {",
1018          "  ",
1019          "  ",
1020          "  \tif (this.confirm == null) {",
1021          "  \t\tthis.confirm = new DialogConfirm();",
1022          "   \t\tthis.confirm.el.set_transient_for(_this.el);",
1023          "\t}",
1024          "\t",
1025          "\tvar project  = (Project.Project) _this.projectsort.el.get_item(",
1026          "\t\t_this.projectselection.el.selected",
1027          "\t\t);",
1028          "\t",
1029          "\tthis.confirm.el.response.connect((res) => {",
1030          "\t\tthis.confirm.el.hide();",
1031          "\t\tif (res == Gtk.ResponseType.CANCEL) {",
1032          "\t\t\treturn;",
1033          "\t\t}",
1034          "\t   project  = (Project.Project) _this.projectsort.el.get_item(",
1035          "\t\t\t_this.projectselection.el.selected",
1036          "\t\t);",
1037          "\t\tProject.Project.remove(project);",
1038          "\t  _this.projectmodel.remove(project);",
1039          "\t\t_this.projectselection.el.selected = Gtk.INVALID_LIST_POSITION;",
1040          "\t",
1041          "\t});",
1042          "  \tthis.confirm.showIt(\"Confirm Delete Project\", \"Are you sure you want to delete this project?\");",
1043          "}"
1044         ]
1045        },
1046        "xtype" : "Button"
1047       },
1048       {
1049        "$ xns" : "Gtk",
1050        "* pack" : "pack_start",
1051        "id" : "btn_addfile",
1052        "items" : [
1053         {
1054          "$ xns" : "Gtk",
1055          "* prop" : "child",
1056          "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
1057          "int spacing" : 0,
1058          "items" : [
1059           {
1060            "$ xns" : "Gtk",
1061            "int margin_end" : 4,
1062            "string icon_name" : "document-new",
1063            "xtype" : "Image"
1064           },
1065           {
1066            "$ xns" : "Gtk",
1067            "string label" : "New File",
1068            "xtype" : "Label"
1069           }
1070          ],
1071          "xtype" : "Box"
1072         }
1073        ],
1074        "listeners" : {
1075         "clicked" : [
1076          " () => {",
1077          "    // create a new file in project..",
1078          "    print(\"add file selected\\n\");",
1079          "    ",
1080          "    if (_this.selectedProject == null) {",
1081          "    \treturn;",
1082          "    }",
1083          "    try {",
1084          "    \tvar f = JsRender.JsRender.factory(_this.selectedProject.xtype,  _this.selectedProject, \"\");",
1085          "     \t_this.win.windowstate.file_details.show( f, _this.el, _this.new_window );",
1086          "     } catch (JsRender.Error e) {}",
1087          "",
1088          "}"
1089         ]
1090        },
1091        "xtype" : "Button"
1092       },
1093       {
1094        "$ xns" : "Gtk",
1095        "* pack" : "pack_start",
1096        "DialogConfirm confirm" : "null",
1097        "id" : "btn_delfile",
1098        "items" : [
1099         {
1100          "$ xns" : "Gtk",
1101          "* prop" : "child",
1102          "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
1103          "int spacing" : 0,
1104          "items" : [
1105           {
1106            "$ xns" : "Gtk",
1107            "string icon_name" : "user-trash",
1108            "xtype" : "Image"
1109           },
1110           {
1111            "$ xns" : "Gtk",
1112            "string label" : "Delete File",
1113            "xtype" : "Label"
1114           }
1115          ],
1116          "xtype" : "Box"
1117         }
1118        ],
1119        "listeners" : {
1120         "clicked" : [
1121          "  ( ) => {",
1122          "  ",
1123          "  \tif (this.confirm == null) {",
1124          "  \t\tthis.confirm = new DialogConfirm();",
1125          "  \t\tthis.confirm.el.set_transient_for(_this.el);",
1126          " ",
1127          "\t}",
1128          "\tGLib.debug(\"DELETE\");",
1129          "\tvar is_icon = true;",
1130          "  \tvar isel = _this.iconsel.selectedFile();",
1131          "  \t ",
1132          "  \tif (isel == null) {",
1133          "  \t\tGLib.debug(\"DELETE - no icons selected\");",
1134          "\t  \tis_icon = false;",
1135          "\t  \tisel = _this.treeselmodel.selectedFile();",
1136          "  \t}",
1137          "  \tif (isel == null) {",
1138          "  \t  \t\tGLib.debug(\"DELETE - no tree item selected\");",
1139          "  \t\treturn; // should nto happen..",
1140          "\t}",
1141          "\t",
1142          "\tGLib.debug(\"DELETE - calling confirm.\");",
1143          "\tthis.confirm.el.response.connect((res) => {",
1144          "\t\tthis.confirm.el.hide();",
1145          "\t\tif (res == Gtk.ResponseType.CANCEL) {",
1146          "\t\t\treturn;",
1147          "\t\t}",
1148          "\t\tis_icon = true;",
1149          "\t  \tisel = _this.iconsel.selectedFile();",
1150          "\t  \tif (isel == null) {",
1151          "\t\t  \tis_icon = false;",
1152          "\t\t  \tisel = _this.treeselmodel.selectedFile();",
1153          "\t  \t}",
1154          "\t  \tif (isel == null) {",
1155          "\t  \t\treturn; // should nto happen..",
1156          "\t\t}",
1157          "\t\t",
1158          "\t  \tif (is_icon) {",
1159          "\t\t  \tisel.project.deleteFile(isel);",
1160          "\t  \t\t_this.gridmodel.remove(isel);",
1161          "\t  \t\treturn;",
1162          "  \t\t}",
1163          "  \t\tisel.project.deleteFile(isel);  \t\t",
1164          "\t",
1165          "\t});",
1166          "\t  \tthis.confirm.showIt(\"Confirm Delete File\",",
1167          "\t  \t\t\"Are you sure you want to delete this file?\");",
1168          "  \t",
1169          " ",
1170          "",
1171          "}  "
1172         ]
1173        },
1174        "xtype" : "Button"
1175       }
1176      ],
1177      "xtype" : "HeaderBar"
1178     }
1179    ],
1180    "name" : "DialogFiles",
1181    "string lastfilter" : "",
1182    "title" : "Select Project / File",
1183    "xtype" : "Window",
1184    "| void load" : [
1185     "() {",
1186     "     // cl list...",
1187     "     ",
1188     "     _this.is_loading = true;",
1189     "         ",
1190     "     Project.Project.loadAll();",
1191     "     _this.project_list.el.set_model(new Gtk.SingleSelection(null));",
1192     "     Project.Project.loadIntoStore(this.projectmodel.el);",
1193     "",
1194     "\t_this.project_list.el.set_model(_this.projectselection.el);",
1195     "\t",
1196     "\t_this.is_loading = false;",
1197     "    ",
1198     "    _this.projectselection.el.selected = Gtk.INVALID_LIST_POSITION; ",
1199     "\t_this.btn_delfile.el.hide();",
1200     "}",
1201     ""
1202    ],
1203    "| void onProjectSelected" : [
1204     "(Project.Project? project) ",
1205     "{",
1206     "\tif (this.in_onprojectselected) { ",
1207     "\t\treturn;",
1208     "\t}",
1209     "\tthis.selectedProject = project;",
1210     "\t",
1211     "\tif (project == null) {",
1212     "\t\tGLib.debug(\"Hide project files\");",
1213     "\t\t_this.mainpane.el.set_end_child(null);",
1214     "\t\t_this.filepane.el.hide();",
1215     "\t\treturn;",
1216     "\t\t",
1217     "\t}",
1218     "\t",
1219     "\tGLib.debug(\"Show project files\");",
1220     "\t_this.mainpane.el.set_end_child(_this.filepane.el);",
1221     "\t",
1222     "\t_this.filepane.el.show();\t",
1223     "\tthis.in_onprojectselected = true;",
1224     "\t",
1225     "\t",
1226     "",
1227     "\tproject.load();",
1228     "\t ",
1229     "\t",
1230     "\t_this.searchbox.el.text = \"\";",
1231     "\t _this.gridview.el.set_model(new Gtk.SingleSelection(null));",
1232     "\t _this.selectedProject.loadFilesIntoStore(_this.gridmodel.el);",
1233     "\t _this.iconsel.el.selected = Gtk.INVALID_LIST_POSITION;",
1234     "  \t \t",
1235     "\t _this.gridview.el.set_model(_this.iconsel.el);",
1236     "\t   ",
1237     "  \t ",
1238     "  \t GLib.Timeout.add(500, () => {",
1239     " \t\t_this.iconsel.el.selected = Gtk.INVALID_LIST_POSITION;",
1240     "  \t \t _this.treeselmodel.el.selected = Gtk.INVALID_LIST_POSITION;\t\t ",
1241     "\t ",
1242     "\t     _this.searchbox.el.grab_focus();",
1243     "\t\t   return false;",
1244     "     });",
1245     "\t _this.treeview.el.set_model(new Gtk.SingleSelection(null));",
1246     "    ",
1247     "    this.selectedProject.loadDirsIntoStore(_this.treemodel.el);",
1248     "    ",
1249     "    _this.treeview.el.set_model(_this.treeselmodel.el);",
1250     "    ",
1251     " \t _this.treeselmodel.el.selected = Gtk.INVALID_LIST_POSITION;",
1252     " \tthis.treescroll.el.vadjustment.value = 0;",
1253     "\tthis.in_onprojectselected = false;\t",
1254     "}",
1255     ""
1256    ],
1257    "| void selectProject" : [
1258     "(Project.Project? project) {",
1259     "    ",
1260     "\t",
1261     "\t ",
1262     "\tvar sm = this.projectselection.el;",
1263     "\tif (project == null) {",
1264     "\t\tsm.selected = Gtk.INVALID_LIST_POSITION;",
1265     "\t\tthis.onProjectSelected(null);",
1266     "\t\treturn;",
1267     "\t}",
1268     "",
1269     "\t",
1270     "\tfor (var i =0; i < sm.n_items; i++) {",
1271     "\t\tvar p = (Project.Project) sm.get_item(i);",
1272     "\t\tif (p.path == project.path) {",
1273     "\t\t\tGLib.debug(\"Select Project %s => %d\", project.name, i);",
1274     "\t\t\tsm.selected = i;",
1275     "\t\t\tbreak;",
1276     "\t\t}",
1277     "\t} ",
1278     "\t",
1279     "}",
1280     ""
1281    ],
1282    "| void show" : [
1283     "(Project.Project? project, bool new_window) {",
1284     "      ",
1285     " \tthis.new_window = new_window;",
1286     "",
1287     "    this.projectscroll.el.vadjustment.value = 0; // scroll to top?",
1288     "    ",
1289     "  ",
1290     "\t  //var win = this.win.el;",
1291     "      //var  w = win.get_width();",
1292     "      //var h = win.get_height();",
1293     " ",
1294     "\t",
1295     "\t this.el.show();",
1296     " this.load();",
1297     "\tthis.selectProject(project);",
1298     "\tthis.onProjectSelected(project);   //?? twice?",
1299     "\t ",
1300     "\t    GLib.Timeout.add(500, () => {",
1301     "\t    \tif (project == null) {",
1302     "    \t   \t\t_this.projectselection.el.selected = Gtk.INVALID_LIST_POSITION;",
1303     "\t\t\t\tthis.onProjectSelected(null); ",
1304     "\t",
1305     "\t\t\t} ",
1306     "\t          this.el.set_size_request( 800 , 750);  // ?? based on default ",
1307     "\t     return false;",
1308     "     });",
1309     "\t ",
1310     "}//"
1311    ]
1312   }
1313  ],
1314  "name" : "DialogFiles"
1315 }