Fix #7420 - deprication warnings
[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              "    try {",
141              "    \tvar f = JsRender.JsRender.factory(_this.selectedProject.xtype,  _this.selectedProject, \"\");",
142              "     \t_this.win.windowstate.file_details.show( f, this.el, _this.new_window );",
143              "     } catch (JsRender.Error e) {}",
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             "   ",
181             "        ",
182             "this.css = new Gtk.CssProvider();",
183             "try {",
184             "\tthis.css.load_from_data(\"#popover-files-view { font-size: 10px;}\");",
185             "} catch (Error e) {}",
186             "this.el.get_style_context().add_provider(this.css,Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);",
187             "        ",
188             "        ",
189             "        ",
190             "        ",
191             "var selection = this.el.get_selection();",
192             "selection.set_mode( Gtk.SelectionMode.SINGLE);",
193             "",
194             "",
195             "    ",
196             "   ",
197             " "
198            ],
199            "* pack" : "add",
200            "Gtk.CssProvider css" : "",
201            "id" : "view",
202            "items" : [
203             {
204              "$ columns" : "typeof(string), typeof(Object)",
205              "$ xns" : "Gtk",
206              "* init" : [
207               "{",
208               "   this.el.set_sort_func(0, (mod,a,b) => {",
209               "       GLib.Value ga, gb;",
210               "       mod.get_value(a,0, out ga);",
211               "       mod.get_value(b,0, out gb);",
212               "        ",
213               "        if ((string)ga == (string)gb) {",
214               "            return 0;",
215               "        }",
216               "        return (string)ga > (string)gb ? 1 : -1;",
217               "   }); ",
218               "",
219               "",
220               "}",
221               ""
222              ],
223              "* pack" : "set_model",
224              "id" : "model",
225              "n_columns" : 2,
226              "xtype" : "ListStore"
227             },
228             {
229              "$ xns" : "Gtk",
230              "* init" : [
231               "",
232               "    this.el.add_attribute(_this.namecol.el , \"markup\", 0  );",
233               " "
234              ],
235              "* pack" : "append_column",
236              "items" : [
237               {
238                "$ xns" : "Gtk",
239                "* pack" : "pack_start,true",
240                "id" : "namecol",
241                "xtype" : "CellRendererText"
242               }
243              ],
244              "utf8 title" : "Projects",
245              "xtype" : "TreeViewColumn"
246             }
247            ],
248            "listeners" : {
249             "cursor_changed" : [
250              " () => {",
251              "    if (_this.is_loading) {",
252              "        return;",
253              "    }",
254              "    ",
255              "    Gtk.TreeIter iter;",
256              "    Gtk.TreeModel mod;",
257              "            ",
258              "    var s = this.el.get_selection();",
259              "    if (!s.get_selected(out mod, out iter)) {",
260              "        return;",
261              "    }",
262              "    ",
263              "    GLib.Value gval;",
264              "",
265              "    mod.get_value(iter, 1 , out gval);",
266              "    var project = (Project.Project)gval.get_object();",
267              "    ",
268              "    _this.onProjectSelected(project);",
269              "    ",
270              "}  "
271             ]
272            },
273            "string name" : "popover-files-view",
274            "xtype" : "TreeView"
275           }
276          ],
277          "xtype" : "ScrolledWindow"
278         },
279         {
280          "$ xns" : "Gtk",
281          "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
282          "bool expand" : true,
283          "int spacing" : 0,
284          "int width_request" : 600,
285          "items" : [
286           {
287            "$ xns" : "Gtk",
288            "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
289            "bool hexpand" : true,
290            "int spacing" : 0,
291            "items" : [
292             {
293              "$ xns" : "Gtk",
294              "* init" : [
295               " ",
296               "",
297               "this.css = new Gtk.CssProvider();",
298               "try {",
299               "\tthis.css.load_from_data(\"#popover-files-iconsearch { font: monospace 10px;}\");",
300               "} catch (Error e) {}",
301               "this.el.get_style_context().add_provider(this.css,Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);",
302               "        ",
303               "        ",
304               ""
305              ],
306              "Gtk.CssProvider css" : "",
307              "bool hexpand" : true,
308              "id" : "iconsearch",
309              "listeners" : {
310               "changed" : [
311                "( ) => {",
312                "\tGLib.debug(\"Got '%s'\", this.el.text);",
313                "\t",
314                "\tif (this.el.text.down() != _this.lastfilter) {",
315                "\t\t_this.loadIconView();",
316                "\t\t_this.loadTreeView();",
317                "\t}",
318                "}",
319                ""
320               ]
321              },
322              "string name" : "popover-files-iconsearch",
323              "string placeholder_text" : "type to filter results",
324              "xtype" : "SearchEntry"
325             }
326            ],
327            "xtype" : "Box"
328           },
329           {
330            "$ xns" : "Gtk",
331            "* init" : [
332             "  this.el.set_policy (Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC);",
333             "  "
334            ],
335            "* pack" : "add",
336            "Gtk.ShadowType shadow_type" : "Gtk.ShadowType.IN",
337            "bool expand" : true,
338            "id" : "iconscroll",
339            "int width_request" : 600,
340            "items" : [
341             {
342              "$ xns" : "Gtk",
343              "* init" : [
344               "{",
345               " ",
346               "}",
347               ""
348              ],
349              "* pack" : "add",
350              "bool has_tooltip" : true,
351              "id" : "iconview",
352              "int item_width" : 100,
353              "int markup_column" : 1,
354              "int pixbuf_column" : 3,
355              "items" : [
356               {
357                "$ columns" : "typeof(Object), typeof(string), typeof(string), typeof(Gdk.Pixbuf), typeof(Gdk.Pixbuf) ",
358                "$ xns" : "Gtk",
359                "* prop" : "model",
360                "id" : "iconmodel",
361                "int n_columns" : 4,
362                "xtype" : "ListStore"
363               }
364              ],
365              "listeners" : {
366               "item_activated" : [
367                "(path) => {",
368                "    ",
369                "    _this.win.windowstate.project = _this.selectedProject;",
370                "    _this.el.hide();",
371                "    ",
372                "    ",
373                " \tGtk.TreeIter iter;",
374                "   ",
375                "            ",
376                "\tthis.el.model.get_iter(out iter, path);",
377                "    ",
378                "    GLib.Value gval;",
379                "",
380                "    this.el.model.get_value(iter, 0 , out gval);",
381                "    var file = (JsRender.JsRender)gval;",
382                "    ",
383                "    ",
384                "    _this.win.windowstate.fileViewOpen(file, _this.new_window);",
385                "",
386                "    ",
387                "    ",
388                "}"
389               ],
390               "query_tooltip" : [
391                "(x, y, keyboard_tooltip, tooltip) => {",
392                "",
393                "\tGtk.TreePath path;",
394                "\tGtk.CellRenderer cell;",
395                "\t_this.iconview.el.get_item_at_pos(x,y + (int) _this.iconscroll.el.vadjustment.value, out path, out cell);",
396                "\t",
397                "\t",
398                "   // GLib.debug(\"Tooltip? %d,%d scroll: %d\",x,y, (int)_this.iconscroll.el.vadjustment.value);",
399                "\t ",
400                "\t",
401                "\tif (path == null) {",
402                "\t\t// GLib.debug(\"Tooltip? - no path\");",
403                "\t\treturn false;",
404                "\t}",
405                "\t",
406                "\tGtk.TreeIter iter;",
407                "\t_this.iconmodel.el.get_iter(out iter, path);",
408                "\tGLib.Value val;",
409                "\t_this.iconmodel.el.get_value(iter, 4, out val);",
410                "\t",
411                "\ttooltip.set_icon((Gdk.Pixbuf) val.get_object());",
412                "\t _this.iconview.el.set_tooltip_item(tooltip, path);",
413                "\treturn true;",
414                "}",
415                ""
416               ]
417              },
418              "xtype" : "IconView"
419             }
420            ],
421            "xtype" : "ScrolledWindow"
422           }
423          ],
424          "xtype" : "Box"
425         },
426         {
427          "$ xns" : "Gtk",
428          "* init" : "  this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);",
429          "* pack" : "add",
430          "Gtk.ShadowType shadow_type" : "Gtk.ShadowType.IN",
431          "bool expand" : true,
432          "bool visible" : false,
433          "id" : "file_container",
434          "int width_request" : 100,
435          "items" : [
436           {
437            "$ enable_tree_lines" : true,
438            "$ headers_visible" : true,
439            "$ xns" : "Gtk",
440            "* init" : [
441             "",
442             "this.css = new Gtk.CssProvider();",
443             "try {",
444             "\tthis.css.load_from_data(\"#popover-files-fileview { font-size: 12px;}\");",
445             "} catch (Error e) {}",
446             "this.el.get_style_context().add_provider(this.css,Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);",
447             "        ",
448             "        ",
449             "        ",
450             " ",
451             "                ",
452             "var selection = this.el.get_selection();",
453             "selection.set_mode( Gtk.SelectionMode.SINGLE);",
454             "",
455             "",
456             "",
457             "",
458             ""
459            ],
460            "* pack" : "add",
461            "Gtk.CssProvider css" : "",
462            "bool activate_on_single_click" : false,
463            "bool expand" : true,
464            "id" : "fileview",
465            "items" : [
466             {
467              "$ columns" : "typeof(string), typeof(string)",
468              "$ xns" : "Gtk",
469              "* init" : [
470               "{",
471               "   this.el.set_sort_func(0, (mod,a,b) => {",
472               "       GLib.Value ga, gb;",
473               "       mod.get_value(a,0, out ga);",
474               "       mod.get_value(b,0, out gb);",
475               "        ",
476               "        if ((string)ga == (string)gb) {",
477               "            return 0;",
478               "        }",
479               "        return (string)ga > (string)gb ? 1 : -1;",
480               "   }); ",
481               " ",
482               "",
483               "}",
484               ""
485              ],
486              "* pack" : "set_model",
487              "id" : "filemodel",
488              "n_columns" : 2,
489              "xtype" : "TreeStore"
490             },
491             {
492              "$ xns" : "Gtk",
493              "* init" : [
494               "",
495               "    this.el.add_attribute(_this.filenamecol.el , \"markup\", 0  );",
496               " "
497              ],
498              "* pack" : "append_column",
499              "items" : [
500               {
501                "$ xns" : "Gtk",
502                "* pack" : "pack_start,true",
503                "id" : "filenamecol",
504                "xtype" : "CellRendererText"
505               }
506              ],
507              "utf8 title" : "File",
508              "xtype" : "TreeViewColumn"
509             }
510            ],
511            "listeners" : {
512             "cursor_changed" : [
513              " () => {",
514              " /*",
515              "    if (_this.is_loading) {",
516              "        return;",
517              "    }",
518              "    ",
519              "    Gtk.TreeIter iter;",
520              "    Gtk.TreeModel mod;",
521              "            ",
522              "    var s = this.el.get_selection();",
523              "    if (!s.get_selected(out mod, out iter)) {",
524              "        return;",
525              "    }",
526              "    ",
527              "    GLib.Value gval;",
528              "",
529              "    mod.get_value(iter, 1 , out gval);",
530              "    var project = (Project.Project)gval.get_object();",
531              "    ",
532              "    _this.project_selected(project);",
533              "    */",
534              "}  "
535             ],
536             "row_activated" : [
537              "(path, col) => {",
538              "",
539              "\tGtk.TreeIter iter;",
540              "   ",
541              "            ",
542              "\tthis.el.model.get_iter(out iter, path);",
543              "    ",
544              "    GLib.Value gval;",
545              "",
546              "    this.el.model.get_value(iter, 1 , out gval);",
547              "   var fn = (string)gval;",
548              "    if (fn.length < 1) {",
549              "    \treturn;",
550              "\t}",
551              "    _this.win.windowstate.project = _this.selectedProject;",
552              "     _this.el.hide();",
553              "    try {",
554              "\t\tvar f = JsRender.JsRender.factory(\"PlainFile\", _this.selectedProject, fn);",
555              "\t\t_this.win.windowstate.fileViewOpen(f, _this.new_window);",
556              "\t} catch (JsRender.Error e) {}   ",
557              "    ",
558              "}"
559             ]
560            },
561            "string name" : "popover-files-fileview",
562            "xtype" : "TreeView"
563           }
564          ],
565          "xtype" : "ScrolledWindow"
566         }
567        ],
568        "xtype" : "Box"
569       }
570      ],
571      "xtype" : "Box"
572     }
573    ],
574    "listeners" : {
575     "hide" : [
576      "( ) => {",
577      "\t// save...",
578      "\t//this.load();",
579      "\t//if (project != null) {",
580      "//\t\tthis.selectProject(project);",
581      "//\t}",
582      " \tif (_this.win.windowstate.project == null) {",
583      " \t\tthis.el.show();",
584      "\t}",
585      "}"
586     ]
587    },
588    "string lastfilter" : "\"\"",
589    "xtype" : "Popover",
590    "| void load" : [
591     "() {",
592     "     // clear list...",
593     "    ",
594     "     if (_this.is_loaded) {",
595     "         return;",
596     "     }",
597     "     _this.is_loading = true;",
598     "        ",
599     "     _this.is_loaded = true;",
600     "     ",
601     "     Project.Project.loadAll();",
602     "     var projects = Project.Project.allProjectsByName();",
603     "     ",
604     "     Gtk.TreeIter iter;",
605     "     var m = this.model.el;",
606     "     m.clear();",
607     "          ",
608     "     for (var i = 0; i < projects.size; i++) {",
609     "        m.append(out iter);",
610     "        m.set(iter,   0,projects.get(i).name );",
611     "        ",
612     "        var o =  GLib.Value(typeof(Object));",
613     "        o.set_object((Object)projects.get(i));",
614     "                   ",
615     "        m.set_value(iter, 1, o);",
616     "     ",
617     "     }",
618     "     m.set_sort_column_id(0, Gtk.SortType.ASCENDING);",
619     "     _this.is_loading = false;      ",
620     "}",
621     ""
622    ],
623    "| void loadIconView" : [
624     "() {",
625     "\t",
626     "\tif (_this.image_cache == null) {",
627     "\t\t_this.image_cache = new Gee.HashMap<string,Gdk.Pixbuf>();",
628     "\t}",
629     "\t",
630     "\t var project =  this.selectedProject;",
631     " ",
632     " \t Gdk.Pixbuf pixbuf = null;",
633     "  \t Gdk.Pixbuf bigpixbuf = null;",
634     "\t Gtk.TreeIter iter;",
635     "     var m = this.iconmodel.el;",
636     "     m.clear();",
637     " ",
638     " ",
639     " \tvar filter = _this.iconsearch.el.text.down();",
640     " \tthis.lastfilter = filter;",
641     " ",
642     "    var fiter = project.sortedFiles().list_iterator();",
643     "    ",
644     "    ",
645     "      try {",
646     "\t        if (_this.missing_thumb_pixbuf == null) {",
647     "\t            var icon_theme = Gtk.IconTheme.get_default ();",
648     "\t            _this.missing_thumb_pixbuf = icon_theme.load_icon (\"package-x-generic\", 92, 0);",
649     "\t            _this.missing_thumb_pixbuf.ref();",
650     "\t        }",
651     "\t        ",
652     "",
653     "\t    } catch (Error e) {",
654     "\t        // noop?",
655     "\t    }",
656     "    ",
657     "",
658     "    ",
659     "    while (fiter.next()) {",
660     "    ",
661     "        var file = fiter.get();",
662     "        if (filter != \"\") {",
663     "        \tif (!file.name.down().contains(filter)) {",
664     "        \t\tcontinue;",
665     "    \t\t}",
666     "        ",
667     "        }    ",
668     "    \t",
669     "    ",
670     "    ",
671     "        m.append(out iter);",
672     "",
673     "        m.set(iter,   0,file ); // zero contains the file reference",
674     "        m.set(iter,   1,file.nickType() + \"\\n\" + file.nickName()); // marked up title?",
675     "        m.set(iter,   2,file.nickType() ); // file type?",
676     "        ",
677     "       ",
678     " ",
679     "\t    ",
680     "\t    pixbuf = file.getIcon(92);",
681     "\t\tbigpixbuf = file.getIcon(368);",
682     "",
683     "\t\t ",
684     "         ",
685     "        if (pixbuf == null) {",
686     "        \tGLib.debug(\"PIXBUF is null? %s\", file.name);",
687     "\t\t    pixbuf = _this.missing_thumb_pixbuf;",
688     "        \tbigpixbuf = _this.missing_thumb_pixbuf;",
689     "\t\t}",
690     "\t\t",
691     "\t\t",
692     "\t\t",
693     "        m.set(iter,   3,pixbuf);",
694     "        m.set(iter,   4,bigpixbuf);",
695     "      ",
696     "        // this needs to add to the iconview?",
697     "        ",
698     "        //var a = new Xcls_fileitem(this,fiter.get());",
699     "        //this.fileitems.add(a);",
700     "",
701     "        //this.filelayout.el.add_child(a.el);",
702     "    }",
703     "}"
704    ],
705    "| void loadTreeView" : [
706     "() {",
707     "  var project =  this.selectedProject;",
708     "  ",
709     "  this.filemodel.el.clear();",
710     "    ",
711     "    // folders...",
712     "    ",
713     "    if (!(project is Project.Gtk)) {",
714     "        //print (\"not gtk... skipping files\");",
715     "        this.file_container.el.hide();",
716     "        return;",
717     "    }",
718     "    ",
719     "    ",
720     "    ",
721     "    var filter = _this.iconsearch.el.text.down();",
722     "    ",
723     "    this.file_container.el.show();",
724     "    var gpr = (Project.Gtk)project;",
725     "     var def = gpr.compilegroups.get(\"_default_\");",
726     "     // not sure why the above is returng null!??",
727     "     if (def == null) {",
728     " \t\tdef = new Project.GtkValaSettings(\"_default_\"); ",
729     " \t\tgpr.compilegroups.set(\"_default_\", def);",
730     "     }",
731     "\t var items  = def.sources;",
732     "\t\t ",
733     "\t Gtk.TreeIter citer;  // folder iter",
734     "\t  Gtk.TreeIter fxiter;  // file iter",
735     "\tfor(var i =0 ; i < items.size; i++) {",
736     "\t    // print (\"cheking folder %s\\n\", items.get(i));",
737     "\t     var files = gpr.filesForOpen(items.get(i));",
738     "\t     ",
739     "\t     ",
740     "\t     ",
741     "\t     ",
742     "\t     ",
743     "\t     if (files.size < 1) {",
744     "\t        continue;",
745     "\t     }",
746     "\t     var nf = 0;",
747     "\t     for(var j =0 ; j < files.size; j++) {",
748     "\t    ",
749     "\t    \tif (filter != \"\") {",
750     "\t    \t\tvar ff = GLib.Path.get_basename(files.get(j)).down();",
751     "\t    \t\tvar dp = ff.last_index_of(\".\");",
752     "\t\t    \tif (!ff.substring(0,dp  < 0 ? ff.length :dp ).contains(filter)) {",
753     "\t\t    \t\tcontinue;",
754     "\t\t\t\t}",
755     "\t\t    ",
756     "\t\t    }  ",
757     "\t\t    nf++;",
758     "\t    }",
759     "\t    if (nf < 1) {",
760     "\t    \tcontinue;",
761     "    \t} ",
762     "\t     ",
763     "\t\t this.filemodel.el.append(out citer,null);",
764     "\t\t this.filemodel.el.set(citer, 0, GLib.Path.get_basename(items.get(i)));",
765     "\t\t this.filemodel.el.set(citer, 1, null); // parent (empty as it's a folder)",
766     "\t\t",
767     "\t\t",
768     "\t    // add the directory... items.get(i);",
769     "\t    //var x = new Xcls_folderitem(this,items.get(i));",
770     "\t    //this.fileitems.add(x);",
771     "\t    //this.filelayout.el.add_child(x.el);",
772     "\t    ",
773     "\t    ",
774     "\t    for(var j =0 ; j < files.size; j++) {",
775     "\t    ",
776     "\t    \tif (filter != \"\") {",
777     "\t    \t\tvar ff = GLib.Path.get_basename(files.get(j)).down();",
778     "\t    \t\tvar dp = ff.last_index_of(\".\");",
779     "\t\t    \tif (!ff.substring(0,dp  < 0 ? ff.length :dp ).contains(filter)) {",
780     "\t\t    \t\tcontinue;",
781     "\t\t\t\t}",
782     "\t\t    ",
783     "\t\t    }  ",
784     "\t    ",
785     "\t\t    this.filemodel.el.insert(out fxiter,citer, -1);",
786     "\t     \tthis.filemodel.el.set(fxiter, 0,  GLib.Path.get_basename(files.get(j))); // filename",
787     "\t\t \tthis.filemodel.el.set(fxiter, 1, files.get(j)); // Folder?",
788     "\t         ",
789     "\t        ",
790     "\t    }",
791     "\t    ",
792     "\t    ",
793     "\t    //this.el.set_value(citer, 1,   items.get(i) );",
794     "\t}",
795     "    _this.fileview.el.expand_all();",
796     "}"
797    ],
798    "| void onProjectSelected" : [
799     "(Project.Project project) ",
800     "{",
801     "\tif (this.in_onprojectselected) { ",
802     "\t\treturn;",
803     "\t}",
804     "\tthis.in_onprojectselected = true;",
805     "\t",
806     "\t",
807     "\tthis.selectedProject = project;",
808     "\tproject.scanDirs();",
809     "\t//this.clutterfiles.loadProject(proj);",
810     "\t",
811     "\t",
812     "\t",
813     "\t_this.iconsearch.el.text = \"\";",
814     "\t",
815     "\t ",
816     "\t",
817     "    ",
818     "    ",
819     "    //this.project_title_name.el.text = pr.name;",
820     "    //this.project_title_path.el.text = pr.firstPath();",
821     "    ",
822     "    // file items contains a reference until we reload ...",
823     "  \t this.loadIconView();",
824     "  \t ",
825     "  \t ",
826     "  \t GLib.Timeout.add(500, () => {",
827     "\t     _this.iconsearch.el.grab_focus();",
828     "\t     return false;",
829     "     });",
830     "    ",
831     "    ",
832     "",
833     "\tthis.loadTreeView();",
834     "\tthis.in_onprojectselected = false;\t",
835     "}",
836     ""
837    ],
838    "| void selectProject" : [
839     "(Project.Project project) {",
840     "    ",
841     "    var sel = _this.view.el.get_selection();",
842     "    ",
843     "    sel.unselect_all();",
844     "    ",
845     "    var found = false;",
846     "    _this.model.el.foreach((mod, path, iter) => {",
847     "        GLib.Value val;",
848     "    ",
849     "        mod.get_value(iter, 1, out val);",
850     "        if ( ( (Project.Project)val.get_object()).fn != project.fn) {",
851     "            print(\"SKIP %s != %s\\n\", ((Project.Project)val.get_object()).name , project.name);",
852     "            return false;//continue",
853     "        }",
854     "        sel.select_iter(iter);",
855     "\t\tthis.selectedProject = project;",
856     "        this.onProjectSelected(project);",
857     "        found = true;",
858     "        return true;",
859     "        ",
860     "    ",
861     "    });",
862     "     if (!found) {",
863     "\t    print(\"tried to select %s, could not find it\", project.name);",
864     "    }",
865     "}",
866     ""
867    ],
868    "| void setMainWindow" : [
869     "(Xcls_MainWindow win) {",
870     "\tthis.win = win;",
871     "\t ",
872     "}",
873     ""
874    ],
875    "| void show" : [
876     "(Gtk.Widget on_el, Project.Project? project, bool new_window) {",
877     "\t//this.editor.show( file, node, ptype, key);",
878     "\t",
879     "\tthis.new_window = new_window;",
880     "\t\t// save...",
881     "\tthis.load();",
882     "\tthis.el.show_all(); // show first - so we can hide stuff later.\t",
883     "\tif (project != null) {",
884     "\t",
885     "\t\tthis.selectProject(project);",
886     "\t}",
887     "\t",
888     "\t",
889     "    int w,h;",
890     "    this.win.el.get_size(out w, out h);",
891     "    ",
892     "    // left tree = 250, editor area = 500?",
893     "    ",
894     "    // min 450?",
895     "\t// max hieght ...",
896     "\t",
897     "\t//var  ww =  on_el.get_allocated_width();",
898     "\t",
899     "\t// width = should be max = w-ww , or 600 at best..?",
900     "\t ",
901     "    this.el.set_size_request( w, h); // same as parent...",
902     "",
903     "",
904     "\tthis.el.set_modal(true);",
905     "\tthis.el.set_relative_to(on_el);",
906     "",
907     "\t ",
908     "",
909     "}",
910     ""
911    ]
912   }
913  ],
914  "modOrder" : "",
915  "name" : "PopoverFiles",
916  "parent" : "",
917  "path" : "/home/alan/gitlive/roobuilder/src/Builder4/PopoverFiles.bjs",
918  "permname" : "",
919  "title" : ""
920 }