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