Fix #7378 - search bar in files brower
[roobuilder] / src / Builder4 / PopoverFiles.bjs
1 {
2  "build_module" : "",
3  "items" : [
4   {
5    "# Gdk.Pixbuf missing_thumb_pixbuf" : "",
6    "# Gee.HashMap<string,Gdk.Pixbuf> image_cache" : "null",
7    "# Project.Project selectedProject" : "",
8    "# Xcls_MainWindow win" : "",
9    "# bool is_loaded" : false,
10    "# bool is_loading" : false,
11    "# bool new_window" : false,
12    "$ xns" : "Gtk",
13    "Gtk.PositionType position" : "Gtk.PositionType.TOP",
14    "bool active" : false,
15    "bool hexpand" : false,
16    "bool in_onprojectselected" : false,
17    "bool modal" : true,
18    "id" : "PopoverFiles",
19    "int height_request" : 800,
20    "int width_request" : 900,
21    "items" : [
22     {
23      "$ xns" : "Gtk",
24      "* pack" : "add",
25      "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
26      "items" : [
27       {
28        "$ xns" : "Gtk",
29        "* pack" : "add",
30        "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
31        "items" : [
32         {
33          "$ xns" : "Gtk",
34          "* pack" : "add",
35          "Gtk.ToolbarStyle toolbar_style" : "Gtk.ToolbarStyle.BOTH",
36          "items" : [
37           {
38            "$ xns" : "Gtk",
39            "* pack" : "add",
40            "listeners" : {
41             "clicked" : [
42              "  ( ) => {",
43              "  ",
44              "    // create a new file in project..",
45              "    //Xcls_DialogNewComponent.singleton().show(",
46              "   var  pe =      EditProject.singleton();",
47              "    //pe.el.set_transient_for(_this.el);",
48              "    pe.el.set_modal(true);   ",
49              "   ",
50              "    var p  = pe.show();",
51              "",
52              "    if (p == null) {",
53              "        return;",
54              "    }",
55              "    ",
56              "    /*",
57              "    _this.win.windowstate.left_projects.is_loaded = false;    ",
58              "    _this.win.windowstate.left_projects.load();",
59              "    _this.win.windowstate.left_projects.selectProject(p);",
60              "    */",
61              "    return  ;    ",
62              "",
63              "}"
64             ]
65            },
66            "string icon_name" : "folder-new",
67            "string label" : "New Project",
68            "xtype" : "ToolButton"
69           },
70           {
71            "$ xns" : "Gtk",
72            "* pack" : "add",
73            "listeners" : {
74             "clicked" : [
75              "  ( ) => {",
76              "  // should disable the button really.",
77              "   if (_this.selectedProject == null) {",
78              "\t   return;",
79              "   }",
80              "\t_this.win.windowstate.projectPopoverShow(this.el, _this.selectedProject);",
81              " }"
82             ]
83            },
84            "string icon_name" : "emblem-system",
85            "string label" : "Project Properties",
86            "xtype" : "ToolButton"
87           },
88           {
89            "$ xns" : "Gtk",
90            "* pack" : "add",
91            "listeners" : {
92             "clicked" : [
93              "  ( ) => {",
94              "  /*",
95              "   var cd = DialogConfirm.singleton();",
96              "     cd.el.set_transient_for(_this.el);",
97              "    cd.el.set_modal(true);",
98              "",
99              "     var project =   _this.windowstate.left_projects.getSelectedProject();",
100              "    if (project == null) {",
101              "        print(\"SKIP - no project\\n\");",
102              "        return;",
103              "    }",
104              "    ",
105              "        ",
106              "     if (Gtk.ResponseType.YES != cd.show(\"Confirm\", ",
107              "        \"Are you sure you want to delete project %s\".printf(project.name))) {",
108              "        return;",
109              "    }",
110              "     ",
111              "",
112              "    // confirm?",
113              "    Project.Project.remove(project);",
114              "    _this.project = null;",
115              "    ",
116              "    _this.windowstate.left_projects.is_loaded =  false;",
117              "    _this.windowstate.left_projects.load();",
118              "    _this.windowstate.clutterfiles.clearFiles();",
119              "*/",
120              "",
121              "}"
122             ]
123            },
124            "string icon_name" : "user-trash",
125            "string label" : "Delete Project",
126            "xtype" : "ToolButton"
127           },
128           {
129            "$ xns" : "Gtk",
130            "* pack" : "add",
131            "listeners" : {
132             "clicked" : [
133              " () => {",
134              "    // create a new file in project..",
135              "    print(\"add file selected\\n\");",
136              "    ",
137              "    if (_this.selectedProject == null) {",
138              "    \treturn;",
139              "    }",
140              "    ",
141              "    var f = JsRender.JsRender.factory(_this.selectedProject.xtype,  _this.selectedProject, \"\");",
142              "     _this.win.windowstate.file_details.show( f, this.el, _this.new_window );",
143              "     ",
144              "",
145              "}"
146             ]
147            },
148            "string icon_name" : "document-new",
149            "string label" : "New File",
150            "xtype" : "ToolButton"
151           }
152          ],
153          "xtype" : "Toolbar"
154         }
155        ],
156        "xtype" : "Box"
157       },
158       {
159        "$ xns" : "Gtk",
160        "* pack" : "add",
161        "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
162        "bool homogeneous" : false,
163        "items" : [
164         {
165          "$ shadow_type" : "Gtk.ShadowType.IN",
166          "$ xns" : "Gtk",
167          "* init" : [
168           "  this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);",
169           " "
170          ],
171          "* pack" : "add",
172          "bool expand" : true,
173          "int width_request" : 150,
174          "items" : [
175           {
176            "$ enable_tree_lines" : true,
177            "$ headers_visible" : true,
178            "$ xns" : "Gtk",
179            "* init" : [
180             "  var description = new Pango.FontDescription();",
181             "     description.set_size(9000);",
182             "    this.el.override_font(description);     ",
183             "                    ",
184             "    var selection = this.el.get_selection();",
185             "    selection.set_mode( Gtk.SelectionMode.SINGLE);",
186             " ",
187             "",
188             "    ",
189             "   ",
190             " "
191            ],
192            "* pack" : "add",
193            "id" : "view",
194            "items" : [
195             {
196              "$ columns" : "typeof(string), typeof(Object)",
197              "$ xns" : "Gtk",
198              "* init" : [
199               "{",
200               "   this.el.set_sort_func(0, (mod,a,b) => {",
201               "       GLib.Value ga, gb;",
202               "       mod.get_value(a,0, out ga);",
203               "       mod.get_value(b,0, out gb);",
204               "        ",
205               "        if ((string)ga == (string)gb) {",
206               "            return 0;",
207               "        }",
208               "        return (string)ga > (string)gb ? 1 : -1;",
209               "   }); ",
210               "",
211               "",
212               "}",
213               ""
214              ],
215              "* pack" : "set_model",
216              "id" : "model",
217              "n_columns" : 2,
218              "xtype" : "ListStore"
219             },
220             {
221              "$ xns" : "Gtk",
222              "* init" : [
223               "",
224               "    this.el.add_attribute(_this.namecol.el , \"markup\", 0  );",
225               " "
226              ],
227              "* pack" : "append_column",
228              "items" : [
229               {
230                "$ xns" : "Gtk",
231                "* pack" : "pack_start,true",
232                "id" : "namecol",
233                "xtype" : "CellRendererText"
234               }
235              ],
236              "utf8 title" : "Projects",
237              "xtype" : "TreeViewColumn"
238             }
239            ],
240            "listeners" : {
241             "cursor_changed" : [
242              " () => {",
243              "    if (_this.is_loading) {",
244              "        return;",
245              "    }",
246              "    ",
247              "    Gtk.TreeIter iter;",
248              "    Gtk.TreeModel mod;",
249              "            ",
250              "    var s = this.el.get_selection();",
251              "    if (!s.get_selected(out mod, out iter)) {",
252              "        return;",
253              "    }",
254              "    ",
255              "    GLib.Value gval;",
256              "",
257              "    mod.get_value(iter, 1 , out gval);",
258              "    var project = (Project.Project)gval.get_object();",
259              "    ",
260              "    _this.onProjectSelected(project);",
261              "    ",
262              "}  "
263             ]
264            },
265            "xtype" : "TreeView"
266           }
267          ],
268          "xtype" : "ScrolledWindow"
269         },
270         {
271          "$ xns" : "Gtk",
272          "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
273          "bool expand" : true,
274          "int spacing" : 0,
275          "int width_request" : 600,
276          "items" : [
277           {
278            "$ xns" : "Gtk",
279            "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
280            "bool hexpand" : true,
281            "int spacing" : 0,
282            "items" : [
283             {
284              "$ xns" : "Gtk",
285              "* init" : [
286               "var description =   Pango.FontDescription.from_string(\"monospace\");",
287               "\tdescription.set_size(8000);",
288               "\t this.el.override_font(description);",
289               "",
290               ""
291              ],
292              "bool hexpand" : true,
293              "id" : "iconsearch",
294              "listeners" : {
295               "changed" : [
296                "( ) => {",
297                "\tGLib.debug(\"Got '%s'\", this.el.text);",
298                "\t",
299                "\tif (this.el.text.down() != _this.lastfilter) {",
300                "\t\t_this.loadIconView();",
301                "\t}",
302                "}",
303                ""
304               ]
305              },
306              "string placeholder_text" : "type to filter results",
307              "xtype" : "SearchEntry"
308             }
309            ],
310            "xtype" : "Box"
311           },
312           {
313            "$ xns" : "Gtk",
314            "* init" : [
315             "  this.el.set_policy (Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC);",
316             "  "
317            ],
318            "* pack" : "add",
319            "Gtk.ShadowType shadow_type" : "Gtk.ShadowType.IN",
320            "bool expand" : true,
321            "id" : "iconscroll",
322            "int width_request" : 600,
323            "items" : [
324             {
325              "$ xns" : "Gtk",
326              "* init" : [
327               "{",
328               " ",
329               "}",
330               ""
331              ],
332              "* pack" : "add",
333              "bool has_tooltip" : true,
334              "id" : "iconview",
335              "int item_width" : 100,
336              "int markup_column" : 1,
337              "int pixbuf_column" : 3,
338              "items" : [
339               {
340                "$ columns" : "typeof(Object), typeof(string), typeof(string), typeof(Gdk.Pixbuf), typeof(Gdk.Pixbuf) ",
341                "$ xns" : "Gtk",
342                "* prop" : "model",
343                "id" : "iconmodel",
344                "int n_columns" : 4,
345                "xtype" : "ListStore"
346               }
347              ],
348              "listeners" : {
349               "item_activated" : [
350                "(path) => {",
351                "    ",
352                "    _this.win.windowstate.project = _this.selectedProject;",
353                "    _this.el.hide();",
354                "    ",
355                "    ",
356                " \tGtk.TreeIter iter;",
357                "   ",
358                "            ",
359                "\tthis.el.model.get_iter(out iter, path);",
360                "    ",
361                "    GLib.Value gval;",
362                "",
363                "    this.el.model.get_value(iter, 0 , out gval);",
364                "    var file = (JsRender.JsRender)gval;",
365                "    ",
366                "    ",
367                "    _this.win.windowstate.fileViewOpen(file, _this.new_window);",
368                "",
369                "    ",
370                "    ",
371                "}"
372               ],
373               "query_tooltip" : [
374                "(x, y, keyboard_tooltip, tooltip) => {",
375                "",
376                "\tGtk.TreePath path;",
377                "\tGtk.CellRenderer cell;",
378                "\tvar s = _this.iconview.el.get_item_at_pos(x,y + (int) _this.iconscroll.el.vadjustment.value, out path, out cell);",
379                "\t",
380                "\t",
381                "   // GLib.debug(\"Tooltip? %d,%d scroll: %d\",x,y, (int)_this.iconscroll.el.vadjustment.value);",
382                "\t ",
383                "\t",
384                "\tif (path == null) {",
385                "\t\t// GLib.debug(\"Tooltip? - no path\");",
386                "\t\treturn false;",
387                "\t}",
388                "\t",
389                "\tGtk.TreeIter iter;",
390                "\t_this.iconmodel.el.get_iter(out iter, path);",
391                "\tGLib.Value val;",
392                "\t_this.iconmodel.el.get_value(iter, 4, out val);",
393                "\t",
394                "\ttooltip.set_icon((Gdk.Pixbuf) val.get_object());",
395                "\t _this.iconview.el.set_tooltip_item(tooltip, path);",
396                "\treturn true;",
397                "}",
398                ""
399               ]
400              },
401              "xtype" : "IconView"
402             }
403            ],
404            "xtype" : "ScrolledWindow"
405           }
406          ],
407          "xtype" : "Box"
408         },
409         {
410          "$ xns" : "Gtk",
411          "* init" : "  this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);",
412          "* pack" : "add",
413          "Gtk.ShadowType shadow_type" : "Gtk.ShadowType.IN",
414          "bool expand" : true,
415          "bool visible" : false,
416          "id" : "file_container",
417          "int width_request" : 100,
418          "items" : [
419           {
420            "$ enable_tree_lines" : true,
421            "$ headers_visible" : true,
422            "$ xns" : "Gtk",
423            "* init" : [
424             "  var description = new Pango.FontDescription();",
425             "     description.set_size(9000);",
426             "    this.el.override_font(description);     ",
427             "                    ",
428             "    var selection = this.el.get_selection();",
429             "    selection.set_mode( Gtk.SelectionMode.SINGLE);",
430             " ",
431             "",
432             "    ",
433             "   ",
434             " "
435            ],
436            "* pack" : "add",
437            "bool activate_on_single_click" : false,
438            "bool expand" : true,
439            "id" : "fileview",
440            "items" : [
441             {
442              "$ columns" : "typeof(string), typeof(string)",
443              "$ xns" : "Gtk",
444              "* init" : [
445               "{",
446               "   this.el.set_sort_func(0, (mod,a,b) => {",
447               "       GLib.Value ga, gb;",
448               "       mod.get_value(a,0, out ga);",
449               "       mod.get_value(b,0, out gb);",
450               "        ",
451               "        if ((string)ga == (string)gb) {",
452               "            return 0;",
453               "        }",
454               "        return (string)ga > (string)gb ? 1 : -1;",
455               "   }); ",
456               " ",
457               "",
458               "}",
459               ""
460              ],
461              "* pack" : "set_model",
462              "id" : "filemodel",
463              "n_columns" : 2,
464              "xtype" : "TreeStore"
465             },
466             {
467              "$ xns" : "Gtk",
468              "* init" : [
469               "",
470               "    this.el.add_attribute(_this.filenamecol.el , \"markup\", 0  );",
471               " "
472              ],
473              "* pack" : "append_column",
474              "items" : [
475               {
476                "$ xns" : "Gtk",
477                "* pack" : "pack_start,true",
478                "id" : "filenamecol",
479                "xtype" : "CellRendererText"
480               }
481              ],
482              "utf8 title" : "File",
483              "xtype" : "TreeViewColumn"
484             }
485            ],
486            "listeners" : {
487             "cursor_changed" : [
488              " () => {",
489              " /*",
490              "    if (_this.is_loading) {",
491              "        return;",
492              "    }",
493              "    ",
494              "    Gtk.TreeIter iter;",
495              "    Gtk.TreeModel mod;",
496              "            ",
497              "    var s = this.el.get_selection();",
498              "    if (!s.get_selected(out mod, out iter)) {",
499              "        return;",
500              "    }",
501              "    ",
502              "    GLib.Value gval;",
503              "",
504              "    mod.get_value(iter, 1 , out gval);",
505              "    var project = (Project.Project)gval.get_object();",
506              "    ",
507              "    _this.project_selected(project);",
508              "    */",
509              "}  "
510             ],
511             "row_activated" : [
512              "(path, col) => {",
513              "",
514              "\tGtk.TreeIter iter;",
515              "   ",
516              "            ",
517              "\tthis.el.model.get_iter(out iter, path);",
518              "    ",
519              "    GLib.Value gval;",
520              "",
521              "    this.el.model.get_value(iter, 1 , out gval);",
522              "   var fn = (string)gval;",
523              "    if (fn.length < 1) {",
524              "    \treturn;",
525              "\t}",
526              "    _this.win.windowstate.project = _this.selectedProject;",
527              "     _this.el.hide();",
528              "    ",
529              "    var f = JsRender.JsRender.factory(\"PlainFile\", _this.selectedProject, fn);",
530              "   ",
531              "   ",
532              "    _this.win.windowstate.fileViewOpen(f, _this.new_window);",
533              "   ",
534              "    ",
535              "}"
536             ]
537            },
538            "xtype" : "TreeView"
539           }
540          ],
541          "xtype" : "ScrolledWindow"
542         }
543        ],
544        "xtype" : "Box"
545       }
546      ],
547      "xtype" : "Box"
548     }
549    ],
550    "listeners" : {
551     "hide" : [
552      "( ) => {",
553      "\t// save...",
554      "\t//this.load();",
555      "\t//if (project != null) {",
556      "//\t\tthis.selectProject(project);",
557      "//\t}",
558      " \tif (_this.win.windowstate.project == null) {",
559      " \t\tthis.el.show();",
560      "\t}",
561      "}"
562     ]
563    },
564    "string lastfilter" : "\"\"",
565    "xtype" : "Popover",
566    "| void load" : [
567     "() {",
568     "     // clear list...",
569     "    ",
570     "     if (_this.is_loaded) {",
571     "         return;",
572     "     }",
573     "     _this.is_loading = true;",
574     "        ",
575     "     _this.is_loaded = true;",
576     "     ",
577     "     Project.Project.loadAll();",
578     "     var projects = Project.Project.allProjectsByName();",
579     "     ",
580     "     Gtk.TreeIter iter;",
581     "     var m = this.model.el;",
582     "     m.clear();",
583     "          ",
584     "     for (var i = 0; i < projects.size; i++) {",
585     "        m.append(out iter);",
586     "        m.set(iter,   0,projects.get(i).name );",
587     "        ",
588     "        var o =  GLib.Value(typeof(Object));",
589     "        o.set_object((Object)projects.get(i));",
590     "                   ",
591     "        m.set_value(iter, 1, o);",
592     "     ",
593     "     }",
594     "     m.set_sort_column_id(0, Gtk.SortType.ASCENDING);",
595     "     _this.is_loading = false;      ",
596     "}",
597     ""
598    ],
599    "| void loadIconView" : [
600     "() {",
601     "\t",
602     "\tif (_this.image_cache == null) {",
603     "\t\t_this.image_cache = new Gee.HashMap<string,Gdk.Pixbuf>();",
604     "\t}",
605     "\t",
606     "\t var project =  this.selectedProject;",
607     " ",
608     " \t Gdk.Pixbuf pixbuf = null;",
609     "  \t Gdk.Pixbuf bigpixbuf = null;",
610     "\t Gtk.TreeIter iter;",
611     "     var m = this.iconmodel.el;",
612     "     m.clear();",
613     " ",
614     " ",
615     " \tvar filter = _this.iconsearch.el.text.down();",
616     " \tthis.lastfilter = filter;",
617     " ",
618     "    var fiter = project.sortedFiles().list_iterator();",
619     "    ",
620     "    ",
621     "      try {",
622     "\t        if (_this.missing_thumb_pixbuf == null) {",
623     "\t            var icon_theme = Gtk.IconTheme.get_default ();",
624     "\t            _this.missing_thumb_pixbuf = icon_theme.load_icon (\"package-x-generic\", 92, 0);",
625     "\t            _this.missing_thumb_pixbuf.ref();",
626     "\t        }",
627     "\t        ",
628     "",
629     "\t    } catch (Error e) {",
630     "\t        // noop?",
631     "\t    }",
632     "    ",
633     "",
634     "    ",
635     "    while (fiter.next()) {",
636     "    ",
637     "        var file = fiter.get();",
638     "        if (filter != \"\") {",
639     "        \tif (!file.name.down().contains(filter)) {",
640     "        \t\tcontinue;",
641     "    \t\t}",
642     "        ",
643     "        }    ",
644     "    \t",
645     "    ",
646     "    ",
647     "        m.append(out iter);",
648     "",
649     "        m.set(iter,   0,file ); // zero contains the file reference",
650     "        m.set(iter,   1,file.nickType() + \"\\n\" + file.nickName()); // marked up title?",
651     "        m.set(iter,   2,file.nickType() ); // file type?",
652     "        ",
653     "       ",
654     "",
655     "        try {",
656     "\t\t    ",
657     "\t\t    pixbuf = file.getIcon(92);",
658     "\t\t\tbigpixbuf = file.getIcon(368);",
659     "",
660     "\t\t} catch (Error e) {",
661     "\t\t    // noop",
662     "\t\t",
663     "\t\t} ",
664     "        ",
665     "         ",
666     "        if (pixbuf == null) {",
667     "        \tGLib.debug(\"PIXBUF is null? %s\", file.name);",
668     "\t\t    pixbuf = _this.missing_thumb_pixbuf;",
669     "        \tbigpixbuf = _this.missing_thumb_pixbuf;",
670     "\t\t}",
671     "\t\t",
672     "\t\t",
673     "\t\t",
674     "        m.set(iter,   3,pixbuf);",
675     "        m.set(iter,   4,bigpixbuf);",
676     "      ",
677     "        // this needs to add to the iconview?",
678     "        ",
679     "        //var a = new Xcls_fileitem(this,fiter.get());",
680     "        //this.fileitems.add(a);",
681     "",
682     "        //this.filelayout.el.add_child(a.el);",
683     "    }",
684     "}"
685    ],
686    "| void onProjectSelected" : [
687     "(Project.Project project) ",
688     "{",
689     "\tif (this.in_onprojectselected) { ",
690     "\t\treturn;",
691     "\t}",
692     "\tthis.in_onprojectselected = true;",
693     "\t",
694     "\t",
695     "\tthis.selectedProject = project;",
696     "\tproject.scanDirs();",
697     "\t//this.clutterfiles.loadProject(proj);",
698     "\t",
699     "\t",
700     "\t",
701     "\t_this.iconsearch.el.text = \"\";",
702     "\t",
703     "\t ",
704     "\t",
705     "    ",
706     "    ",
707     "    //this.project_title_name.el.text = pr.name;",
708     "    //this.project_title_path.el.text = pr.firstPath();",
709     "    ",
710     "    // file items contains a reference until we reload ...",
711     "  \t this.loadIconView();",
712     "  \t ",
713     "  \t ",
714     "  \t GLib.Timeout.add(500, () => {",
715     "\t     _this.iconsearch.el.grab_focus();",
716     "\t     return false;",
717     "     });",
718     "    ",
719     "     this.filemodel.el.clear();",
720     "    ",
721     "    // folders...",
722     "    ",
723     "    if (!(project is Project.Gtk)) {",
724     "        print (\"not gtk... skipping files\");",
725     "        this.file_container.el.hide();",
726     "    \tthis.in_onprojectselected = false;",
727     "        return;",
728     "    }",
729     "    this.file_container.el.show();",
730     "    var gpr = (Project.Gtk)project;",
731     "     var def = gpr.compilegroups.get(\"_default_\");",
732     "     // not sure why the above is returng null!??",
733     "     if (def == null) {",
734     " \t\tdef = new Project.GtkValaSettings(\"_default_\"); ",
735     " \t\tgpr.compilegroups.set(\"_default_\", def);",
736     "     }",
737     "\t var items  = def.sources;",
738     "\t\t ",
739     "\t Gtk.TreeIter citer;  // folder iter",
740     "\t  Gtk.TreeIter fxiter;  // file iter",
741     "\tfor(var i =0 ; i < items.size; i++) {",
742     "\t     print (\"cheking folder %s\\n\", items.get(i));",
743     "\t     var files = gpr.filesForOpen(items.get(i));",
744     "\t     if (files.size < 1) {",
745     "\t        continue;",
746     "\t     }",
747     "\t\t this.filemodel.el.append(out citer,null);",
748     "\t\t this.filemodel.el.set(citer, 0, GLib.Path.get_basename(items.get(i)));",
749     "\t\t this.filemodel.el.set(citer, 1, null); // parent (empty as it's a folder)",
750     "\t\t",
751     "\t\t",
752     "\t    // add the directory... items.get(i);",
753     "\t    //var x = new Xcls_folderitem(this,items.get(i));",
754     "\t    //this.fileitems.add(x);",
755     "\t    //this.filelayout.el.add_child(x.el);",
756     "\t    ",
757     "\t    ",
758     "\t    for(var j =0 ; j < files.size; j++) {",
759     "\t    ",
760     "\t\t    this.filemodel.el.insert(out fxiter,citer, -1);",
761     "\t     \tthis.filemodel.el.set(fxiter, 0,  GLib.Path.get_basename(files.get(j))); // filename",
762     "\t\t \tthis.filemodel.el.set(fxiter, 1, files.get(j)); // Folder?",
763     "\t         ",
764     "\t        ",
765     "\t    }",
766     "\t    ",
767     "\t    ",
768     "\t    //this.el.set_value(citer, 1,   items.get(i) );",
769     "\t}",
770     "    _this.fileview.el.expand_all();",
771     "    \tthis.in_onprojectselected = false;",
772     "\t",
773     "}",
774     ""
775    ],
776    "| void selectProject" : [
777     "(Project.Project project) {",
778     "    ",
779     "    var sel = _this.view.el.get_selection();",
780     "    ",
781     "    sel.unselect_all();",
782     "    ",
783     "    var found = false;",
784     "    _this.model.el.foreach((mod, path, iter) => {",
785     "        GLib.Value val;",
786     "    ",
787     "        mod.get_value(iter, 1, out val);",
788     "        if ( ( (Project.Project)val.get_object()).fn != project.fn) {",
789     "            print(\"SKIP %s != %s\\n\", ((Project.Project)val.get_object()).name , project.name);",
790     "            return false;//continue",
791     "        }",
792     "        sel.select_iter(iter);",
793     "\t\tthis.selectedProject = project;",
794     "        this.onProjectSelected(project);",
795     "        found = true;",
796     "        return true;",
797     "        ",
798     "    ",
799     "    });",
800     "     if (!found) {",
801     "\t    print(\"tried to select %s, could not find it\", project.name);",
802     "    }",
803     "}",
804     ""
805    ],
806    "| void setMainWindow" : [
807     "(Xcls_MainWindow win) {",
808     "\tthis.win = win;",
809     "\t ",
810     "}",
811     ""
812    ],
813    "| void show" : [
814     "(Gtk.Widget on_el, Project.Project? project, bool new_window) {",
815     "\t//this.editor.show( file, node, ptype, key);",
816     "\t",
817     "\tthis.new_window = new_window;",
818     "\t\t// save...",
819     "\tthis.load();",
820     "\tthis.el.show_all(); // show first - so we can hide stuff later.\t",
821     "\tif (project != null) {",
822     "\t",
823     "\t\tthis.selectProject(project);",
824     "\t}",
825     "\t",
826     "\t",
827     "    int w,h;",
828     "    this.win.el.get_size(out w, out h);",
829     "    ",
830     "    // left tree = 250, editor area = 500?",
831     "    ",
832     "    // min 450?",
833     "\t// max hieght ...",
834     "\t",
835     "\tvar  ww =  on_el.get_allocated_width();",
836     "\t",
837     "\t// width = should be max = w-ww , or 600 at best..?",
838     "\t ",
839     "    this.el.set_size_request( w, h); // same as parent...",
840     "",
841     "",
842     "\tthis.el.set_modal(true);",
843     "\tthis.el.set_relative_to(on_el);",
844     "",
845     "\t ",
846     "",
847     "}",
848     ""
849    ]
850   }
851  ],
852  "modOrder" : "",
853  "name" : "PopoverFiles",
854  "parent" : "",
855  "path" : "/home/alan/gitlive/roobuilder/src/Builder4/PopoverFiles.bjs",
856  "permname" : "",
857  "title" : ""
858 }