Fix #7982 - roo javascript completion
[roobuilder] / src / Builder4 / PopoverFiles.vala
1 static Xcls_PopoverFiles  _PopoverFiles;
2
3 public class Xcls_PopoverFiles : Object
4 {
5     public Gtk.Window el;
6     private Xcls_PopoverFiles  _this;
7
8     public static Xcls_PopoverFiles singleton()
9     {
10         if (_PopoverFiles == null) {
11             _PopoverFiles= new Xcls_PopoverFiles();
12         }
13         return _PopoverFiles;
14     }
15     public Xcls_view view;
16     public Xcls_model model;
17     public Xcls_namecol namecol;
18     public Xcls_iconsearch iconsearch;
19     public Xcls_iconscroll iconscroll;
20     public Xcls_iconview iconview;
21     public Xcls_iconmodel iconmodel;
22     public Xcls_file_container file_container;
23     public Xcls_fileview fileview;
24     public Xcls_filemodel filemodel;
25     public Xcls_filenamecol filenamecol;
26
27         // my vars (def)
28     public Xcls_MainWindow win;
29     public string lastfilter;
30     public bool in_onprojectselected;
31     public bool is_loading;
32     public bool new_window;
33     public Project.Project selectedProject;
34     public Gtk.PositionType position;
35     public Gdk.Pixbuf missing_thumb_pixbuf;
36     public Gee.HashMap<string,Gdk.Pixbuf> image_cache;
37     public bool active;
38     public bool is_loaded;
39
40     // ctor
41     public Xcls_PopoverFiles()
42     {
43         _this = this;
44         this.el = new Gtk.Window();
45
46         // my vars (dec)
47         this.lastfilter = "";
48         this.in_onprojectselected = false;
49         this.is_loading = false;
50         this.new_window = false;
51         this.position = Gtk.PositionType.TOP;
52         this.image_cache = null;
53         this.active = false;
54         this.is_loaded = false;
55
56         // set gobject values
57         this.el.width_request = 900;
58         this.el.title = "Select Project /File";
59         this.el.height_request = 800;
60         this.el.hexpand = false;
61         this.el.modal = true;
62         var child_1 = new Xcls_Box2( _this );
63         child_1.ref();
64         this.el.set_child ( child_1.el  );
65
66         //listeners
67         this.el.hide.connect( ( ) => {
68                 // save...
69                 //this.load();
70                 //if (project != null) {
71         //              this.selectProject(project);
72         //      }
73                 //if (_this.win.windowstate.project == null) {
74                 //      this.el.show();
75                 //}
76         });
77     }
78
79     // user defined functions
80     public void onProjectSelected (Project.Project project) 
81     {
82         if (this.in_onprojectselected) { 
83                 return;
84         }
85         this.in_onprojectselected = true;
86         
87         
88         this.selectedProject = project;
89         project.scanDirs();
90         //this.clutterfiles.loadProject(proj);
91         
92         
93         
94         _this.iconsearch.el.text = "";
95         
96          
97         
98         
99         
100         //this.project_title_name.el.text = pr.name;
101         //this.project_title_path.el.text = pr.firstPath();
102         
103         // file items contains a reference until we reload ...
104          this.loadIconView();
105          
106          
107          GLib.Timeout.add(500, () => {
108              _this.iconsearch.el.grab_focus();
109              return false;
110          });
111         
112         
113     
114         this.loadTreeView();
115         this.in_onprojectselected = false;      
116     }
117     public void selectProject (Project.Project project) {
118         
119         var sel = _this.view.el.get_selection();
120         
121         sel.unselect_all();
122         
123         var found = false;
124         _this.model.el.foreach((mod, path, iter) => {
125             GLib.Value val;
126         
127             mod.get_value(iter, 1, out val);
128             if ( ( (Project.Project)val.get_object()).fn != project.fn) {
129                 print("SKIP %s != %s\n", ((Project.Project)val.get_object()).name , project.name);
130                 return false;//continue
131             }
132             sel.select_iter(iter);
133                 this.selectedProject = project;
134             this.onProjectSelected(project);
135             found = true;
136             return true;
137             
138         
139         });
140          if (!found) {
141             print("tried to select %s, could not find it", project.name);
142         }
143     }
144     public void show (Gtk.Widget? on_el, Project.Project? project, bool new_window) {
145         //this.editor.show( file, node, ptype, key);
146         
147         this.new_window = new_window;
148                 // save...
149         this.load();
150         if (on_el != null) {
151                 this.el.set_parent(on_el);
152         }
153          // show first - so we can hide stuff later.    
154         if (project != null) {
155         
156                 this.selectProject(project);
157         }
158         
159         
160       //   var win = this.win.el;
161       //  var  w = win.get_width();
162       //  var h = win.get_height();
163     
164         // left tree = 250, editor area = 500?
165         
166         // min 450?
167         // max hieght ...
168         
169         //var  ww =  on_el.get_allocated_width();
170         
171         // width = should be max = w-ww , or 600 at best..?
172          
173         //this.el.set_size_request( w - 100, h - 100); // same as parent...
174     
175     
176         //this.el.set_autohide(true); // can hide
177         //Gtk.Allocation rect;
178         //on_el.get_allocation(out rect);
179        // this.el.set_pointing_to(rect);
180         //this.el.set_offset(200,0);
181         //this.el.set_position(Gtk.PositionType.BOTTOM);
182         this.el.show();
183           
184     }
185     public void load () {
186          // clear list...
187         
188          if (_this.is_loaded) {
189              return;
190          }
191          _this.is_loading = true;
192             
193          _this.is_loaded = true;
194          
195          Project.Project.loadAll();
196          var projects = Project.Project.allProjectsByName();
197          
198          Gtk.TreeIter iter;
199          var m = this.model.el;
200          m.clear();
201               
202          for (var i = 0; i < projects.size; i++) {
203             m.append(out iter);
204             m.set(iter,   0,projects.get(i).name );
205             
206             var o =  GLib.Value(typeof(Object));
207             o.set_object((Object)projects.get(i));
208                        
209             m.set_value(iter, 1, o);
210          
211          }
212          m.set_sort_column_id(0, Gtk.SortType.ASCENDING);
213          _this.is_loading = false;      
214     }
215     public void loadTreeView () {
216       var project =  this.selectedProject;
217       
218       this.filemodel.el.clear();
219         
220         // folders...
221         
222         if (!(project is Project.Gtk)) {
223             //print ("not gtk... skipping files");
224             this.file_container.el.hide();
225             return;
226         }
227         
228         
229         
230         var filter = _this.iconsearch.el.text.down();
231         
232         this.file_container.el.show();
233         var gpr = (Project.Gtk)project;
234          var def = gpr.compilegroups.get("_default_");
235          // not sure why the above is returng null!??
236          if (def == null) {
237                 def = new Project.GtkValaSettings("_default_"); 
238                 gpr.compilegroups.set("_default_", def);
239          }
240          var items  = def.sources;
241                  
242          Gtk.TreeIter citer;  // folder iter
243           Gtk.TreeIter fxiter;  // file iter
244         for(var i =0 ; i < items.size; i++) {
245             // print ("cheking folder %s\n", items.get(i));
246              var files = gpr.filesForOpen(items.get(i));
247              
248              
249              
250              
251              
252              if (files.size < 1) {
253                 continue;
254              }
255              var nf = 0;
256              for(var j =0 ; j < files.size; j++) {
257             
258                 if (filter != "") {
259                         var ff = GLib.Path.get_basename(files.get(j)).down();
260                         var dp = ff.last_index_of(".");
261                         if (!ff.substring(0,dp  < 0 ? ff.length :dp ).contains(filter)) {
262                                 continue;
263                                 }
264                     
265                     }  
266                     nf++;
267             }
268             if (nf < 1) {
269                 continue;
270                 } 
271              
272                  this.filemodel.el.append(out citer,null);
273                  this.filemodel.el.set(citer, 0, GLib.Path.get_basename(items.get(i)));
274                  this.filemodel.el.set(citer, 1, null); // parent (empty as it's a folder)
275                 
276                 
277             // add the directory... items.get(i);
278             //var x = new Xcls_folderitem(this,items.get(i));
279             //this.fileitems.add(x);
280             //this.filelayout.el.add_child(x.el);
281             
282             
283             for(var j =0 ; j < files.size; j++) {
284             
285                 if (filter != "") {
286                         var ff = GLib.Path.get_basename(files.get(j)).down();
287                         var dp = ff.last_index_of(".");
288                         if (!ff.substring(0,dp  < 0 ? ff.length :dp ).contains(filter)) {
289                                 continue;
290                                 }
291                     
292                     }  
293             
294                     this.filemodel.el.insert(out fxiter,citer, -1);
295                 this.filemodel.el.set(fxiter, 0,  GLib.Path.get_basename(files.get(j))); // filename
296                         this.filemodel.el.set(fxiter, 1, files.get(j)); // Folder?
297                  
298                 
299             }
300             
301             
302             //this.el.set_value(citer, 1,   items.get(i) );
303         }
304         _this.fileview.el.expand_all();
305     }
306     public void loadIconView () {
307         
308         if (_this.image_cache == null) {
309                 _this.image_cache = new Gee.HashMap<string,Gdk.Pixbuf>();
310         }
311         
312          var project =  this.selectedProject;
313      
314          Gdk.Pixbuf pixbuf = null;
315          Gdk.Pixbuf bigpixbuf = null;
316          Gtk.TreeIter iter;
317          var m = this.iconmodel.el;
318          m.clear();
319      
320      
321         var filter = _this.iconsearch.el.text.down();
322         this.lastfilter = filter;
323      
324         var fiter = project.sortedFiles().list_iterator();
325         
326         
327           try {
328             if (_this.missing_thumb_pixbuf == null) {
329             
330                 var icon_theme = Gtk.IconTheme.get_for_display(this.el.get_display());
331                  var icon = icon_theme.lookup_icon ("package-x-generic", null,  92,1, 
332                                          Gtk.TextDirection.NONE, 0);
333                         _this.missing_thumb_pixbuf = (new Gdk.Pixbuf.from_file (icon.file.get_path())).scale_simple(
334                                 92, 92  , Gdk.InterpType.NEAREST) ;
335                 _this.missing_thumb_pixbuf.ref();
336             }
337                 
338     
339             } catch (Error e) {
340                 // noop?
341             }
342         
343     
344         
345         while (fiter.next()) {
346         
347             var file = fiter.get();
348             if (filter != "") {
349                 if (!file.name.down().contains(filter)) {
350                         continue;
351                         }
352             
353             }    
354                 
355         
356         
357             m.append(out iter);
358     
359             m.set(iter,   0,file ); // zero contains the file reference
360             m.set(iter,   1,file.nickType() + "\n" + file.nickName()); // marked up title?
361             m.set(iter,   2,file.nickType() ); // file type?
362             
363            
364      
365             
366             pixbuf = file.getIcon(92);
367                 bigpixbuf = file.getIcon(368);
368     
369                  
370              
371             if (pixbuf == null) {
372                 GLib.debug("PIXBUF is null? %s", file.name);
373                     pixbuf = _this.missing_thumb_pixbuf;
374                 bigpixbuf = _this.missing_thumb_pixbuf;
375                 }
376                 
377                 
378                 
379             m.set(iter,   3,pixbuf);
380             m.set(iter,   4,bigpixbuf);
381           
382             // this needs to add to the iconview?
383             
384             //var a = new Xcls_fileitem(this,fiter.get());
385             //this.fileitems.add(a);
386     
387             //this.filelayout.el.add_child(a.el);
388         }
389     }
390     public void setMainWindow (Xcls_MainWindow win) {
391         this.win = win;
392         this.el.set_transient_for(win.el);
393         this.el.application = BuilderApplication.singleton({});
394     }
395     public class Xcls_Box2 : Object
396     {
397         public Gtk.Box el;
398         private Xcls_PopoverFiles  _this;
399
400
401             // my vars (def)
402
403         // ctor
404         public Xcls_Box2(Xcls_PopoverFiles _owner )
405         {
406             _this = _owner;
407             this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
408
409             // my vars (dec)
410
411             // set gobject values
412             this.el.hexpand = true;
413             this.el.vexpand = true;
414             var child_1 = new Xcls_Box3( _this );
415             child_1.ref();
416             this.el.append( child_1.el );
417             var child_2 = new Xcls_Box12( _this );
418             child_2.ref();
419             this.el.append( child_2.el );
420         }
421
422         // user defined functions
423     }
424     public class Xcls_Box3 : Object
425     {
426         public Gtk.Box el;
427         private Xcls_PopoverFiles  _this;
428
429
430             // my vars (def)
431
432         // ctor
433         public Xcls_Box3(Xcls_PopoverFiles _owner )
434         {
435             _this = _owner;
436             this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
437
438             // my vars (dec)
439
440             // set gobject values
441             this.el.hexpand = true;
442             var child_1 = new Xcls_Box4( _this );
443             child_1.ref();
444             this.el.append( child_1.el );
445         }
446
447         // user defined functions
448     }
449     public class Xcls_Box4 : Object
450     {
451         public Gtk.Box el;
452         private Xcls_PopoverFiles  _this;
453
454
455             // my vars (def)
456
457         // ctor
458         public Xcls_Box4(Xcls_PopoverFiles _owner )
459         {
460             _this = _owner;
461             this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
462
463             // my vars (dec)
464
465             // set gobject values
466             var child_1 = new Xcls_Button5( _this );
467             child_1.ref();
468             this.el.append( child_1.el );
469             var child_2 = new Xcls_Button9( _this );
470             child_2.ref();
471             this.el.append( child_2.el );
472             var child_3 = new Xcls_Button10( _this );
473             child_3.ref();
474             this.el.append( child_3.el );
475             var child_4 = new Xcls_Button11( _this );
476             child_4.ref();
477             this.el.append( child_4.el );
478         }
479
480         // user defined functions
481     }
482     public class Xcls_Button5 : Object
483     {
484         public Gtk.Button el;
485         private Xcls_PopoverFiles  _this;
486
487
488             // my vars (def)
489
490         // ctor
491         public Xcls_Button5(Xcls_PopoverFiles _owner )
492         {
493             _this = _owner;
494             this.el = new Gtk.Button();
495
496             // my vars (dec)
497
498             // set gobject values
499             this.el.label = "New Project";
500             var child_1 = new Xcls_Box6( _this );
501             this.el.child = child_1.el;
502
503             //listeners
504             this.el.clicked.connect( ( ) => {
505               
506                 // create a new file in project..
507                 //Xcls_DialogNewComponent.singleton().show(
508                var  pe =      EditProject.singleton();
509                pe.el.application = _this.win.el.application;
510                 pe.el.set_transient_for( _this.win.el );
511              
512                _this.el.hide();
513                
514                 pe.selected.connect((pr) => {
515                         
516                      _this.is_loaded = false;
517                      _this.show(null, pr, _this.new_window);
518             
519                 });
520                 
521                 pe.canceled.connect((pr) => {
522                         
523              
524                      _this.show(null, null, _this.new_window);
525             
526                 });
527                 
528                 pe.showIt();
529                
530             
531             });
532         }
533
534         // user defined functions
535     }
536     public class Xcls_Box6 : Object
537     {
538         public Gtk.Box el;
539         private Xcls_PopoverFiles  _this;
540
541
542             // my vars (def)
543
544         // ctor
545         public Xcls_Box6(Xcls_PopoverFiles _owner )
546         {
547             _this = _owner;
548             this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
549
550             // my vars (dec)
551
552             // set gobject values
553             var child_1 = new Xcls_Image7( _this );
554             child_1.ref();
555             this.el.append( child_1.el );
556             var child_2 = new Xcls_Label8( _this );
557             child_2.ref();
558             this.el.append( child_2.el );
559         }
560
561         // user defined functions
562     }
563     public class Xcls_Image7 : Object
564     {
565         public Gtk.Image el;
566         private Xcls_PopoverFiles  _this;
567
568
569             // my vars (def)
570
571         // ctor
572         public Xcls_Image7(Xcls_PopoverFiles _owner )
573         {
574             _this = _owner;
575             this.el = new Gtk.Image();
576
577             // my vars (dec)
578
579             // set gobject values
580             this.el.icon_name = "folder-new";
581             this.el.margin_end = 4;
582             this.el.icon_size = Gtk.IconSize.NORMAL;
583         }
584
585         // user defined functions
586     }
587
588     public class Xcls_Label8 : Object
589     {
590         public Gtk.Label el;
591         private Xcls_PopoverFiles  _this;
592
593
594             // my vars (def)
595
596         // ctor
597         public Xcls_Label8(Xcls_PopoverFiles _owner )
598         {
599             _this = _owner;
600             this.el = new Gtk.Label( "New Project" );
601
602             // my vars (dec)
603
604             // set gobject values
605         }
606
607         // user defined functions
608     }
609
610
611
612     public class Xcls_Button9 : Object
613     {
614         public Gtk.Button el;
615         private Xcls_PopoverFiles  _this;
616
617
618             // my vars (def)
619
620         // ctor
621         public Xcls_Button9(Xcls_PopoverFiles _owner )
622         {
623             _this = _owner;
624             this.el = new Gtk.Button();
625
626             // my vars (dec)
627
628             // set gobject values
629             this.el.icon_name = "emblem-system";
630             this.el.label = "Project Properties";
631
632             //listeners
633             this.el.clicked.connect( ( ) => {
634               // should disable the button really.
635                if (_this.selectedProject == null) {
636                    return;
637                }
638                 _this.win.windowstate.projectPopoverShow(this.el, _this.selectedProject);
639              });
640         }
641
642         // user defined functions
643     }
644
645     public class Xcls_Button10 : Object
646     {
647         public Gtk.Button el;
648         private Xcls_PopoverFiles  _this;
649
650
651             // my vars (def)
652
653         // ctor
654         public Xcls_Button10(Xcls_PopoverFiles _owner )
655         {
656             _this = _owner;
657             this.el = new Gtk.Button();
658
659             // my vars (dec)
660
661             // set gobject values
662             this.el.icon_name = "user-trash";
663             this.el.label = "Delete Project";
664
665             //listeners
666             this.el.clicked.connect( ( ) => {
667               /*
668                var cd = DialogConfirm.singleton();
669                  cd.el.set_transient_for(_this.el);
670                 cd.el.set_modal(true);
671             
672                  var project =   _this.windowstate.left_projects.getSelectedProject();
673                 if (project == null) {
674                     print("SKIP - no project\n");
675                     return;
676                 }
677                 
678                     
679                  if (Gtk.ResponseType.YES != cd.show("Confirm", 
680                     "Are you sure you want to delete project %s".printf(project.name))) {
681                     return;
682                 }
683                  
684             
685                 // confirm?
686                 Project.Project.remove(project);
687                 _this.project = null;
688                 
689                 _this.windowstate.left_projects.is_loaded =  false;
690                 _this.windowstate.left_projects.load();
691                 _this.windowstate.clutterfiles.clearFiles();
692             */
693             
694             });
695         }
696
697         // user defined functions
698     }
699
700     public class Xcls_Button11 : Object
701     {
702         public Gtk.Button el;
703         private Xcls_PopoverFiles  _this;
704
705
706             // my vars (def)
707
708         // ctor
709         public Xcls_Button11(Xcls_PopoverFiles _owner )
710         {
711             _this = _owner;
712             this.el = new Gtk.Button();
713
714             // my vars (dec)
715
716             // set gobject values
717             this.el.icon_name = "document-new";
718             this.el.label = "New File";
719
720             //listeners
721             this.el.clicked.connect( () => {
722                 // create a new file in project..
723                 print("add file selected\n");
724                 
725                 if (_this.selectedProject == null) {
726                         return;
727                 }
728                 try {
729                         var f = JsRender.JsRender.factory(_this.selectedProject.xtype,  _this.selectedProject, "");
730                         _this.win.windowstate.file_details.show( f, this.el, _this.new_window );
731                  } catch (JsRender.Error e) {}
732             
733             });
734         }
735
736         // user defined functions
737     }
738
739
740
741     public class Xcls_Box12 : Object
742     {
743         public Gtk.Box el;
744         private Xcls_PopoverFiles  _this;
745
746
747             // my vars (def)
748
749         // ctor
750         public Xcls_Box12(Xcls_PopoverFiles _owner )
751         {
752             _this = _owner;
753             this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
754
755             // my vars (dec)
756
757             // set gobject values
758             this.el.homogeneous = false;
759             this.el.hexpand = true;
760             this.el.vexpand = true;
761             var child_1 = new Xcls_ScrolledWindow13( _this );
762             child_1.ref();
763             this.el.append( child_1.el );
764             var child_2 = new Xcls_Box18( _this );
765             child_2.ref();
766             this.el.append( child_2.el );
767             var child_3 = new Xcls_file_container( _this );
768             this.el.append( child_3.el );
769         }
770
771         // user defined functions
772     }
773     public class Xcls_ScrolledWindow13 : Object
774     {
775         public Gtk.ScrolledWindow el;
776         private Xcls_PopoverFiles  _this;
777
778
779             // my vars (def)
780         public bool expand;
781
782         // ctor
783         public Xcls_ScrolledWindow13(Xcls_PopoverFiles _owner )
784         {
785             _this = _owner;
786             this.el = new Gtk.ScrolledWindow();
787
788             // my vars (dec)
789             this.expand = true;
790
791             // set gobject values
792             this.el.width_request = 150;
793             this.el.has_frame = true;
794             this.el.hexpand = true;
795             this.el.vexpand = true;
796             var child_1 = new Xcls_view( _this );
797             this.el.set_child ( child_1.el  );
798
799             // init method
800
801             this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
802         }
803
804         // user defined functions
805     }
806     public class Xcls_view : Object
807     {
808         public Gtk.TreeView el;
809         private Xcls_PopoverFiles  _this;
810
811
812             // my vars (def)
813         public Gtk.CssProvider css;
814
815         // ctor
816         public Xcls_view(Xcls_PopoverFiles _owner )
817         {
818             _this = _owner;
819             _this.view = this;
820             this.el = new Gtk.TreeView();
821
822             // my vars (dec)
823
824             // set gobject values
825             this.el.name = "popover-files-view";
826             this.el.hexpand = true;
827             this.el.vexpand = true;
828             this.el.enable_tree_lines = true;
829             this.el.headers_visible = true;
830             var child_1 = new Xcls_model( _this );
831             this.el.set_model ( child_1.el  );
832             var child_2 = new Xcls_TreeViewColumn16( _this );
833             child_2.ref();
834             this.el.append_column ( child_2.el  );
835
836             // init method
837
838             this.css = new Gtk.CssProvider();
839             try {
840                 this.css.load_from_data("#popover-files-view { font-size: 10px;}".data);
841             } catch (Error e) {}
842             this.el.get_style_context().add_provider(this.css,Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
843                     
844                     
845                     
846                     
847             var selection = this.el.get_selection();
848             selection.set_mode( Gtk.SelectionMode.SINGLE);
849
850             //listeners
851             this.el.cursor_changed.connect( () => {
852                 if (_this.is_loading) {
853                     return;
854                 }
855                 
856                 Gtk.TreeIter iter;
857                 Gtk.TreeModel mod;
858                         
859                 var s = this.el.get_selection();
860                 if (!s.get_selected(out mod, out iter)) {
861                     return;
862                 }
863                 
864                 GLib.Value gval;
865             
866                 mod.get_value(iter, 1 , out gval);
867                 var project = (Project.Project)gval.get_object();
868                 
869                 _this.onProjectSelected(project);
870                 
871             });
872         }
873
874         // user defined functions
875     }
876     public class Xcls_model : Object
877     {
878         public Gtk.ListStore el;
879         private Xcls_PopoverFiles  _this;
880
881
882             // my vars (def)
883
884         // ctor
885         public Xcls_model(Xcls_PopoverFiles _owner )
886         {
887             _this = _owner;
888             _this.model = this;
889             this.el = new Gtk.ListStore.newv(  { typeof(string), typeof(Object) }  );
890
891             // my vars (dec)
892
893             // set gobject values
894
895             // init method
896
897             {
898                this.el.set_sort_func(0, (mod,a,b) => {
899                    GLib.Value ga, gb;
900                    mod.get_value(a,0, out ga);
901                    mod.get_value(b,0, out gb);
902                     
903                     if ((string)ga == (string)gb) {
904                         return 0;
905                     }
906                     return (string)ga > (string)gb ? 1 : -1;
907                }); 
908             
909             
910             }
911         }
912
913         // user defined functions
914     }
915
916     public class Xcls_TreeViewColumn16 : Object
917     {
918         public Gtk.TreeViewColumn el;
919         private Xcls_PopoverFiles  _this;
920
921
922             // my vars (def)
923
924         // ctor
925         public Xcls_TreeViewColumn16(Xcls_PopoverFiles _owner )
926         {
927             _this = _owner;
928             this.el = new Gtk.TreeViewColumn();
929
930             // my vars (dec)
931
932             // set gobject values
933             this.el.title = "Projects";
934             var child_1 = new Xcls_namecol( _this );
935             this.el.pack_start ( child_1.el , true );
936
937             // init method
938
939             this.el.add_attribute(_this.namecol.el , "markup", 0  );
940         }
941
942         // user defined functions
943     }
944     public class Xcls_namecol : Object
945     {
946         public Gtk.CellRendererText el;
947         private Xcls_PopoverFiles  _this;
948
949
950             // my vars (def)
951
952         // ctor
953         public Xcls_namecol(Xcls_PopoverFiles _owner )
954         {
955             _this = _owner;
956             _this.namecol = this;
957             this.el = new Gtk.CellRendererText();
958
959             // my vars (dec)
960
961             // set gobject values
962         }
963
964         // user defined functions
965     }
966
967
968
969
970     public class Xcls_Box18 : Object
971     {
972         public Gtk.Box el;
973         private Xcls_PopoverFiles  _this;
974
975
976             // my vars (def)
977
978         // ctor
979         public Xcls_Box18(Xcls_PopoverFiles _owner )
980         {
981             _this = _owner;
982             this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
983
984             // my vars (dec)
985
986             // set gobject values
987             this.el.width_request = 600;
988             this.el.hexpand = true;
989             this.el.vexpand = true;
990             var child_1 = new Xcls_Box19( _this );
991             child_1.ref();
992             this.el.append( child_1.el );
993             var child_2 = new Xcls_iconscroll( _this );
994             this.el.append( child_2.el );
995         }
996
997         // user defined functions
998     }
999     public class Xcls_Box19 : Object
1000     {
1001         public Gtk.Box el;
1002         private Xcls_PopoverFiles  _this;
1003
1004
1005             // my vars (def)
1006
1007         // ctor
1008         public Xcls_Box19(Xcls_PopoverFiles _owner )
1009         {
1010             _this = _owner;
1011             this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
1012
1013             // my vars (dec)
1014
1015             // set gobject values
1016             this.el.hexpand = true;
1017             var child_1 = new Xcls_iconsearch( _this );
1018             this.el.append( child_1.el );
1019         }
1020
1021         // user defined functions
1022     }
1023     public class Xcls_iconsearch : Object
1024     {
1025         public Gtk.SearchEntry el;
1026         private Xcls_PopoverFiles  _this;
1027
1028
1029             // my vars (def)
1030         public Gtk.CssProvider css;
1031
1032         // ctor
1033         public Xcls_iconsearch(Xcls_PopoverFiles _owner )
1034         {
1035             _this = _owner;
1036             _this.iconsearch = this;
1037             this.el = new Gtk.SearchEntry();
1038
1039             // my vars (dec)
1040
1041             // set gobject values
1042             this.el.name = "popover-files-iconsearch";
1043             this.el.hexpand = true;
1044             this.el.placeholder_text = "type to filter results";
1045
1046             // init method
1047
1048             this.css = new Gtk.CssProvider();
1049             try {
1050                 this.css.load_from_data("#popover-files-iconsearch { font:  10px monospace;}".data);
1051             } catch (Error e) {}
1052             this.el.get_style_context().add_provider(this.css,Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
1053
1054             //listeners
1055             this.el.changed.connect( ( ) => {
1056                 GLib.debug("Got '%s'", this.el.text);
1057                 
1058                 if (this.el.text.down() != _this.lastfilter) {
1059                         _this.loadIconView();
1060                         _this.loadTreeView();
1061                 }
1062             });
1063         }
1064
1065         // user defined functions
1066     }
1067
1068
1069     public class Xcls_iconscroll : Object
1070     {
1071         public Gtk.ScrolledWindow el;
1072         private Xcls_PopoverFiles  _this;
1073
1074
1075             // my vars (def)
1076
1077         // ctor
1078         public Xcls_iconscroll(Xcls_PopoverFiles _owner )
1079         {
1080             _this = _owner;
1081             _this.iconscroll = this;
1082             this.el = new Gtk.ScrolledWindow();
1083
1084             // my vars (dec)
1085
1086             // set gobject values
1087             this.el.width_request = 600;
1088             this.el.has_frame = true;
1089             this.el.hexpand = true;
1090             this.el.vexpand = true;
1091             var child_1 = new Xcls_iconview( _this );
1092             this.el.set_child ( child_1.el  );
1093
1094             // init method
1095
1096             this.el.set_policy (Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC);
1097         }
1098
1099         // user defined functions
1100     }
1101     public class Xcls_iconview : Object
1102     {
1103         public Gtk.IconView el;
1104         private Xcls_PopoverFiles  _this;
1105
1106
1107             // my vars (def)
1108
1109         // ctor
1110         public Xcls_iconview(Xcls_PopoverFiles _owner )
1111         {
1112             _this = _owner;
1113             _this.iconview = this;
1114             this.el = new Gtk.IconView();
1115
1116             // my vars (dec)
1117
1118             // set gobject values
1119             this.el.markup_column = 1;
1120             this.el.hexpand = true;
1121             this.el.vexpand = true;
1122             this.el.pixbuf_column = 3;
1123             this.el.has_tooltip = true;
1124             this.el.item_width = 100;
1125             var child_1 = new Xcls_iconmodel( _this );
1126             this.el.model = child_1.el;
1127
1128             // init method
1129
1130             {
1131              
1132             }
1133
1134             //listeners
1135             this.el.item_activated.connect( (path) => {
1136                 
1137                 _this.win.windowstate.project = _this.selectedProject;
1138                 _this.el.hide();
1139                 
1140                 
1141                 Gtk.TreeIter iter;
1142                
1143                         
1144                 this.el.model.get_iter(out iter, path);
1145                 
1146                 GLib.Value gval;
1147             
1148                 this.el.model.get_value(iter, 0 , out gval);
1149                 var file = (JsRender.JsRender)gval;
1150                 
1151                 
1152                 _this.win.windowstate.fileViewOpen(file, _this.new_window);
1153             
1154                 
1155                 
1156             });
1157             this.el.query_tooltip.connect( (x, y, keyboard_tooltip, tooltip) => {
1158             
1159                 Gtk.TreePath path;
1160                 Gtk.CellRenderer cell;
1161                 _this.iconview.el.get_item_at_pos(x,y + (int) _this.iconscroll.el.vadjustment.value, out path, out cell);
1162                 
1163                 
1164                // GLib.debug("Tooltip? %d,%d scroll: %d",x,y, (int)_this.iconscroll.el.vadjustment.value);
1165                  
1166                 
1167                 if (path == null) {
1168                         // GLib.debug("Tooltip? - no path");
1169                         return false;
1170                 }
1171                 
1172                 Gtk.TreeIter iter;
1173                 _this.iconmodel.el.get_iter(out iter, path);
1174                 GLib.Value val;
1175                 _this.iconmodel.el.get_value(iter, 4, out val);
1176                 
1177                 tooltip.set_icon(  Gdk.Texture.for_pixbuf(
1178                         (Gdk.Pixbuf) val.get_object()
1179                 ));
1180                  _this.iconview.el.set_tooltip_item(tooltip, path);
1181                 return true;
1182             });
1183         }
1184
1185         // user defined functions
1186     }
1187     public class Xcls_iconmodel : Object
1188     {
1189         public Gtk.ListStore el;
1190         private Xcls_PopoverFiles  _this;
1191
1192
1193             // my vars (def)
1194
1195         // ctor
1196         public Xcls_iconmodel(Xcls_PopoverFiles _owner )
1197         {
1198             _this = _owner;
1199             _this.iconmodel = this;
1200             this.el = new Gtk.ListStore.newv(  { typeof(Object), typeof(string), typeof(string), typeof(Gdk.Pixbuf), typeof(Gdk.Pixbuf)  }  );
1201
1202             // my vars (dec)
1203
1204             // set gobject values
1205         }
1206
1207         // user defined functions
1208     }
1209
1210
1211
1212
1213     public class Xcls_file_container : Object
1214     {
1215         public Gtk.ScrolledWindow el;
1216         private Xcls_PopoverFiles  _this;
1217
1218
1219             // my vars (def)
1220
1221         // ctor
1222         public Xcls_file_container(Xcls_PopoverFiles _owner )
1223         {
1224             _this = _owner;
1225             _this.file_container = this;
1226             this.el = new Gtk.ScrolledWindow();
1227
1228             // my vars (dec)
1229
1230             // set gobject values
1231             this.el.width_request = 200;
1232             this.el.has_frame = true;
1233             this.el.hexpand = true;
1234             this.el.vexpand = true;
1235             this.el.visible = false;
1236             var child_1 = new Xcls_fileview( _this );
1237             this.el.set_child ( child_1.el  );
1238
1239             // init method
1240
1241             this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
1242         }
1243
1244         // user defined functions
1245     }
1246     public class Xcls_fileview : Object
1247     {
1248         public Gtk.TreeView el;
1249         private Xcls_PopoverFiles  _this;
1250
1251
1252             // my vars (def)
1253         public Gtk.CssProvider css;
1254
1255         // ctor
1256         public Xcls_fileview(Xcls_PopoverFiles _owner )
1257         {
1258             _this = _owner;
1259             _this.fileview = this;
1260             this.el = new Gtk.TreeView();
1261
1262             // my vars (dec)
1263
1264             // set gobject values
1265             this.el.name = "popover-files-fileview";
1266             this.el.activate_on_single_click = false;
1267             this.el.hexpand = true;
1268             this.el.vexpand = true;
1269             this.el.enable_tree_lines = true;
1270             this.el.headers_visible = true;
1271             var child_1 = new Xcls_filemodel( _this );
1272             this.el.set_model ( child_1.el  );
1273             var child_2 = new Xcls_TreeViewColumn27( _this );
1274             child_2.ref();
1275             this.el.append_column ( child_2.el  );
1276
1277             // init method
1278
1279             this.css = new Gtk.CssProvider();
1280             try {
1281                 this.css.load_from_data("#popover-files-fileview { font-size: 12px;}".data);
1282             } catch (Error e) {}
1283             this.el.get_style_context().add_provider(this.css,Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
1284                     
1285                     
1286                     
1287              
1288                             
1289             var selection = this.el.get_selection();
1290             selection.set_mode( Gtk.SelectionMode.SINGLE);
1291
1292             //listeners
1293             this.el.row_activated.connect( (path, col) => {
1294             
1295                 Gtk.TreeIter iter;
1296                
1297                         
1298                 this.el.model.get_iter(out iter, path);
1299                 
1300                 GLib.Value gval;
1301             
1302                 this.el.model.get_value(iter, 1 , out gval);
1303                var fn = (string)gval;
1304                 if (fn.length < 1) {
1305                         return;
1306                 }
1307                 _this.win.windowstate.project = _this.selectedProject;
1308                  _this.el.hide();
1309                 try {
1310                         var f = JsRender.JsRender.factory("PlainFile", _this.selectedProject, fn);
1311                         _this.win.windowstate.fileViewOpen(f, _this.new_window);
1312                 } catch (JsRender.Error e) {}   
1313                 
1314             });
1315             this.el.cursor_changed.connect( () => {
1316              /*
1317                 if (_this.is_loading) {
1318                     return;
1319                 }
1320                 
1321                 Gtk.TreeIter iter;
1322                 Gtk.TreeModel mod;
1323                         
1324                 var s = this.el.get_selection();
1325                 if (!s.get_selected(out mod, out iter)) {
1326                     return;
1327                 }
1328                 
1329                 GLib.Value gval;
1330             
1331                 mod.get_value(iter, 1 , out gval);
1332                 var project = (Project.Project)gval.get_object();
1333                 
1334                 _this.project_selected(project);
1335                 */
1336             });
1337         }
1338
1339         // user defined functions
1340     }
1341     public class Xcls_filemodel : Object
1342     {
1343         public Gtk.TreeStore el;
1344         private Xcls_PopoverFiles  _this;
1345
1346
1347             // my vars (def)
1348
1349         // ctor
1350         public Xcls_filemodel(Xcls_PopoverFiles _owner )
1351         {
1352             _this = _owner;
1353             _this.filemodel = this;
1354             this.el = new Gtk.TreeStore.newv(  { typeof(string), typeof(string) }  );
1355
1356             // my vars (dec)
1357
1358             // set gobject values
1359
1360             // init method
1361
1362             {
1363                this.el.set_sort_func(0, (mod,a,b) => {
1364                    GLib.Value ga, gb;
1365                    mod.get_value(a,0, out ga);
1366                    mod.get_value(b,0, out gb);
1367                     
1368                     if ((string)ga == (string)gb) {
1369                         return 0;
1370                     }
1371                     return (string)ga > (string)gb ? 1 : -1;
1372                }); 
1373              
1374             
1375             }
1376         }
1377
1378         // user defined functions
1379     }
1380
1381     public class Xcls_TreeViewColumn27 : Object
1382     {
1383         public Gtk.TreeViewColumn el;
1384         private Xcls_PopoverFiles  _this;
1385
1386
1387             // my vars (def)
1388
1389         // ctor
1390         public Xcls_TreeViewColumn27(Xcls_PopoverFiles _owner )
1391         {
1392             _this = _owner;
1393             this.el = new Gtk.TreeViewColumn();
1394
1395             // my vars (dec)
1396
1397             // set gobject values
1398             this.el.title = "File";
1399             var child_1 = new Xcls_filenamecol( _this );
1400             this.el.pack_start ( child_1.el , true );
1401
1402             // init method
1403
1404             this.el.add_attribute(_this.filenamecol.el , "markup", 0  );
1405         }
1406
1407         // user defined functions
1408     }
1409     public class Xcls_filenamecol : Object
1410     {
1411         public Gtk.CellRendererText el;
1412         private Xcls_PopoverFiles  _this;
1413
1414
1415             // my vars (def)
1416
1417         // ctor
1418         public Xcls_filenamecol(Xcls_PopoverFiles _owner )
1419         {
1420             _this = _owner;
1421             _this.filenamecol = this;
1422             this.el = new Gtk.CellRendererText();
1423
1424             // my vars (dec)
1425
1426             // set gobject values
1427         }
1428
1429         // user defined functions
1430     }
1431
1432
1433
1434
1435
1436
1437 }