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