b0975dd1382943a469c1e2adb7de034b9c27d7d0
[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_Box9( _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         }
463
464         // user defined functions
465     }
466     public class Xcls_ToolButton5 : Object
467     {
468         public Gtk.ToolButton el;
469         private Xcls_PopoverFiles  _this;
470
471
472             // my vars (def)
473
474         // ctor
475         public Xcls_ToolButton5(Xcls_PopoverFiles _owner )
476         {
477             _this = _owner;
478             this.el = new Gtk.ToolButton( null, "New Project" );
479
480             // my vars (dec)
481
482             // set gobject values
483             this.el.icon_name = "folder-new";
484
485             //listeners
486             this.el.clicked.connect( ( ) => {
487               
488                 // create a new file in project..
489                 //Xcls_DialogNewComponent.singleton().show(
490                var  pe =      EditProject.singleton();
491                 //pe.el.set_transient_for(_this.el);
492                 pe.el.set_modal(true);   
493                
494                 var p  = pe.show();
495             
496                 if (p == null) {
497                     return;
498                 }
499                 
500                 /*
501                 _this.win.windowstate.left_projects.is_loaded = false;    
502                 _this.win.windowstate.left_projects.load();
503                 _this.win.windowstate.left_projects.selectProject(p);
504                 */
505                 return  ;    
506             
507             });
508         }
509
510         // user defined functions
511     }
512
513     public class Xcls_ToolButton6 : Object
514     {
515         public Gtk.ToolButton el;
516         private Xcls_PopoverFiles  _this;
517
518
519             // my vars (def)
520
521         // ctor
522         public Xcls_ToolButton6(Xcls_PopoverFiles _owner )
523         {
524             _this = _owner;
525             this.el = new Gtk.ToolButton( null, "Project Properties" );
526
527             // my vars (dec)
528
529             // set gobject values
530             this.el.icon_name = "emblem-system";
531
532             //listeners
533             this.el.clicked.connect( ( ) => {
534               // should disable the button really.
535                if (_this.selectedProject == null) {
536                    return;
537                }
538                 _this.win.windowstate.projectPopoverShow(this.el, _this.selectedProject);
539              });
540         }
541
542         // user defined functions
543     }
544
545     public class Xcls_ToolButton7 : Object
546     {
547         public Gtk.ToolButton el;
548         private Xcls_PopoverFiles  _this;
549
550
551             // my vars (def)
552
553         // ctor
554         public Xcls_ToolButton7(Xcls_PopoverFiles _owner )
555         {
556             _this = _owner;
557             this.el = new Gtk.ToolButton( null, "Delete Project" );
558
559             // my vars (dec)
560
561             // set gobject values
562             this.el.icon_name = "user-trash";
563
564             //listeners
565             this.el.clicked.connect( ( ) => {
566               /*
567                var cd = DialogConfirm.singleton();
568                  cd.el.set_transient_for(_this.el);
569                 cd.el.set_modal(true);
570             
571                  var project =   _this.windowstate.left_projects.getSelectedProject();
572                 if (project == null) {
573                     print("SKIP - no project\n");
574                     return;
575                 }
576                 
577                     
578                  if (Gtk.ResponseType.YES != cd.show("Confirm", 
579                     "Are you sure you want to delete project %s".printf(project.name))) {
580                     return;
581                 }
582                  
583             
584                 // confirm?
585                 Project.Project.remove(project);
586                 _this.project = null;
587                 
588                 _this.windowstate.left_projects.is_loaded =  false;
589                 _this.windowstate.left_projects.load();
590                 _this.windowstate.clutterfiles.clearFiles();
591             */
592             
593             });
594         }
595
596         // user defined functions
597     }
598
599     public class Xcls_ToolButton8 : Object
600     {
601         public Gtk.ToolButton el;
602         private Xcls_PopoverFiles  _this;
603
604
605             // my vars (def)
606
607         // ctor
608         public Xcls_ToolButton8(Xcls_PopoverFiles _owner )
609         {
610             _this = _owner;
611             this.el = new Gtk.ToolButton( null, "New File" );
612
613             // my vars (dec)
614
615             // set gobject values
616             this.el.icon_name = "document-new";
617
618             //listeners
619             this.el.clicked.connect( () => {
620                 // create a new file in project..
621                 print("add file selected\n");
622                 
623                 if (_this.selectedProject == null) {
624                         return;
625                 }
626                 try {
627                         var f = JsRender.JsRender.factory(_this.selectedProject.xtype,  _this.selectedProject, "");
628                         _this.win.windowstate.file_details.show( f, this.el, _this.new_window );
629                  } catch (JsRender.Error e) {}
630             
631             });
632         }
633
634         // user defined functions
635     }
636
637
638
639     public class Xcls_Box9 : Object
640     {
641         public Gtk.Box el;
642         private Xcls_PopoverFiles  _this;
643
644
645             // my vars (def)
646
647         // ctor
648         public Xcls_Box9(Xcls_PopoverFiles _owner )
649         {
650             _this = _owner;
651             this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
652
653             // my vars (dec)
654
655             // set gobject values
656             this.el.homogeneous = false;
657             var child_0 = new Xcls_ScrolledWindow10( _this );
658             child_0.ref();
659             this.el.add (  child_0.el  );
660             var child_1 = new Xcls_Box15( _this );
661             child_1.ref();
662             this.el.add(  child_1.el );
663             var child_2 = new Xcls_file_container( _this );
664             child_2.ref();
665             this.el.add (  child_2.el  );
666         }
667
668         // user defined functions
669     }
670     public class Xcls_ScrolledWindow10 : Object
671     {
672         public Gtk.ScrolledWindow el;
673         private Xcls_PopoverFiles  _this;
674
675
676             // my vars (def)
677
678         // ctor
679         public Xcls_ScrolledWindow10(Xcls_PopoverFiles _owner )
680         {
681             _this = _owner;
682             this.el = new Gtk.ScrolledWindow( null, null );
683
684             // my vars (dec)
685
686             // set gobject values
687             this.el.width_request = 150;
688             this.el.expand = true;
689             this.el.shadow_type = Gtk.ShadowType.IN;
690             var child_0 = new Xcls_view( _this );
691             child_0.ref();
692             this.el.add (  child_0.el  );
693
694             // init method
695
696             this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
697         }
698
699         // user defined functions
700     }
701     public class Xcls_view : Object
702     {
703         public Gtk.TreeView el;
704         private Xcls_PopoverFiles  _this;
705
706
707             // my vars (def)
708
709         // ctor
710         public Xcls_view(Xcls_PopoverFiles _owner )
711         {
712             _this = _owner;
713             _this.view = this;
714             this.el = new Gtk.TreeView();
715
716             // my vars (dec)
717
718             // set gobject values
719             this.el.enable_tree_lines = true;
720             this.el.headers_visible = true;
721             var child_0 = new Xcls_model( _this );
722             child_0.ref();
723             this.el.set_model (  child_0.el  );
724             var child_1 = new Xcls_TreeViewColumn13( _this );
725             child_1.ref();
726             this.el.append_column (  child_1.el  );
727
728             // init method
729
730             var description = new Pango.FontDescription();
731                  description.set_size(9000);
732                 this.el.override_font(description);     
733                                 
734                 var selection = this.el.get_selection();
735                 selection.set_mode( Gtk.SelectionMode.SINGLE);
736
737             //listeners
738             this.el.cursor_changed.connect( () => {
739                 if (_this.is_loading) {
740                     return;
741                 }
742                 
743                 Gtk.TreeIter iter;
744                 Gtk.TreeModel mod;
745                         
746                 var s = this.el.get_selection();
747                 if (!s.get_selected(out mod, out iter)) {
748                     return;
749                 }
750                 
751                 GLib.Value gval;
752             
753                 mod.get_value(iter, 1 , out gval);
754                 var project = (Project.Project)gval.get_object();
755                 
756                 _this.onProjectSelected(project);
757                 
758             });
759         }
760
761         // user defined functions
762     }
763     public class Xcls_model : Object
764     {
765         public Gtk.ListStore el;
766         private Xcls_PopoverFiles  _this;
767
768
769             // my vars (def)
770
771         // ctor
772         public Xcls_model(Xcls_PopoverFiles _owner )
773         {
774             _this = _owner;
775             _this.model = this;
776             this.el = new Gtk.ListStore.newv(  { typeof(string), typeof(Object) }  );
777
778             // my vars (dec)
779
780             // set gobject values
781
782             // init method
783
784             {
785                this.el.set_sort_func(0, (mod,a,b) => {
786                    GLib.Value ga, gb;
787                    mod.get_value(a,0, out ga);
788                    mod.get_value(b,0, out gb);
789                     
790                     if ((string)ga == (string)gb) {
791                         return 0;
792                     }
793                     return (string)ga > (string)gb ? 1 : -1;
794                }); 
795             
796             
797             }
798         }
799
800         // user defined functions
801     }
802
803     public class Xcls_TreeViewColumn13 : Object
804     {
805         public Gtk.TreeViewColumn el;
806         private Xcls_PopoverFiles  _this;
807
808
809             // my vars (def)
810
811         // ctor
812         public Xcls_TreeViewColumn13(Xcls_PopoverFiles _owner )
813         {
814             _this = _owner;
815             this.el = new Gtk.TreeViewColumn();
816
817             // my vars (dec)
818
819             // set gobject values
820             this.el.title = "Projects";
821             var child_0 = new Xcls_namecol( _this );
822             child_0.ref();
823             this.el.pack_start (  child_0.el , true );
824
825             // init method
826
827             this.el.add_attribute(_this.namecol.el , "markup", 0  );
828         }
829
830         // user defined functions
831     }
832     public class Xcls_namecol : Object
833     {
834         public Gtk.CellRendererText el;
835         private Xcls_PopoverFiles  _this;
836
837
838             // my vars (def)
839
840         // ctor
841         public Xcls_namecol(Xcls_PopoverFiles _owner )
842         {
843             _this = _owner;
844             _this.namecol = this;
845             this.el = new Gtk.CellRendererText();
846
847             // my vars (dec)
848
849             // set gobject values
850         }
851
852         // user defined functions
853     }
854
855
856
857
858     public class Xcls_Box15 : Object
859     {
860         public Gtk.Box el;
861         private Xcls_PopoverFiles  _this;
862
863
864             // my vars (def)
865
866         // ctor
867         public Xcls_Box15(Xcls_PopoverFiles _owner )
868         {
869             _this = _owner;
870             this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
871
872             // my vars (dec)
873
874             // set gobject values
875             this.el.width_request = 600;
876             this.el.expand = true;
877             var child_0 = new Xcls_Box16( _this );
878             child_0.ref();
879             this.el.add(  child_0.el );
880             var child_1 = new Xcls_iconscroll( _this );
881             child_1.ref();
882             this.el.add (  child_1.el  );
883         }
884
885         // user defined functions
886     }
887     public class Xcls_Box16 : Object
888     {
889         public Gtk.Box el;
890         private Xcls_PopoverFiles  _this;
891
892
893             // my vars (def)
894
895         // ctor
896         public Xcls_Box16(Xcls_PopoverFiles _owner )
897         {
898             _this = _owner;
899             this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
900
901             // my vars (dec)
902
903             // set gobject values
904             this.el.hexpand = true;
905             var child_0 = new Xcls_iconsearch( _this );
906             child_0.ref();
907             this.el.add(  child_0.el );
908         }
909
910         // user defined functions
911     }
912     public class Xcls_iconsearch : Object
913     {
914         public Gtk.SearchEntry el;
915         private Xcls_PopoverFiles  _this;
916
917
918             // my vars (def)
919
920         // ctor
921         public Xcls_iconsearch(Xcls_PopoverFiles _owner )
922         {
923             _this = _owner;
924             _this.iconsearch = this;
925             this.el = new Gtk.SearchEntry();
926
927             // my vars (dec)
928
929             // set gobject values
930             this.el.hexpand = true;
931             this.el.placeholder_text = "type to filter results";
932
933             // init method
934
935             var description =   Pango.FontDescription.from_string("monospace");
936                 description.set_size(8000);
937                  this.el.override_font(description);
938
939             //listeners
940             this.el.changed.connect( ( ) => {
941                 GLib.debug("Got '%s'", this.el.text);
942                 
943                 if (this.el.text.down() != _this.lastfilter) {
944                         _this.loadIconView();
945                         _this.loadTreeView();
946                 }
947             });
948         }
949
950         // user defined functions
951     }
952
953
954     public class Xcls_iconscroll : Object
955     {
956         public Gtk.ScrolledWindow el;
957         private Xcls_PopoverFiles  _this;
958
959
960             // my vars (def)
961
962         // ctor
963         public Xcls_iconscroll(Xcls_PopoverFiles _owner )
964         {
965             _this = _owner;
966             _this.iconscroll = this;
967             this.el = new Gtk.ScrolledWindow( null, null );
968
969             // my vars (dec)
970
971             // set gobject values
972             this.el.width_request = 600;
973             this.el.expand = true;
974             this.el.shadow_type = Gtk.ShadowType.IN;
975             var child_0 = new Xcls_iconview( _this );
976             child_0.ref();
977             this.el.add (  child_0.el  );
978
979             // init method
980
981             this.el.set_policy (Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC);
982         }
983
984         // user defined functions
985     }
986     public class Xcls_iconview : Object
987     {
988         public Gtk.IconView el;
989         private Xcls_PopoverFiles  _this;
990
991
992             // my vars (def)
993
994         // ctor
995         public Xcls_iconview(Xcls_PopoverFiles _owner )
996         {
997             _this = _owner;
998             _this.iconview = this;
999             this.el = new Gtk.IconView();
1000
1001             // my vars (dec)
1002
1003             // set gobject values
1004             this.el.markup_column = 1;
1005             this.el.pixbuf_column = 3;
1006             this.el.has_tooltip = true;
1007             this.el.item_width = 100;
1008             var child_0 = new Xcls_iconmodel( _this );
1009             child_0.ref();
1010             this.el.model = child_0.el;
1011
1012             // init method
1013
1014             {
1015              
1016             }
1017
1018             //listeners
1019             this.el.item_activated.connect( (path) => {
1020                 
1021                 _this.win.windowstate.project = _this.selectedProject;
1022                 _this.el.hide();
1023                 
1024                 
1025                 Gtk.TreeIter iter;
1026                
1027                         
1028                 this.el.model.get_iter(out iter, path);
1029                 
1030                 GLib.Value gval;
1031             
1032                 this.el.model.get_value(iter, 0 , out gval);
1033                 var file = (JsRender.JsRender)gval;
1034                 
1035                 
1036                 _this.win.windowstate.fileViewOpen(file, _this.new_window);
1037             
1038                 
1039                 
1040             });
1041             this.el.query_tooltip.connect( (x, y, keyboard_tooltip, tooltip) => {
1042             
1043                 Gtk.TreePath path;
1044                 Gtk.CellRenderer cell;
1045                 _this.iconview.el.get_item_at_pos(x,y + (int) _this.iconscroll.el.vadjustment.value, out path, out cell);
1046                 
1047                 
1048                // GLib.debug("Tooltip? %d,%d scroll: %d",x,y, (int)_this.iconscroll.el.vadjustment.value);
1049                  
1050                 
1051                 if (path == null) {
1052                         // GLib.debug("Tooltip? - no path");
1053                         return false;
1054                 }
1055                 
1056                 Gtk.TreeIter iter;
1057                 _this.iconmodel.el.get_iter(out iter, path);
1058                 GLib.Value val;
1059                 _this.iconmodel.el.get_value(iter, 4, out val);
1060                 
1061                 tooltip.set_icon((Gdk.Pixbuf) val.get_object());
1062                  _this.iconview.el.set_tooltip_item(tooltip, path);
1063                 return true;
1064             });
1065         }
1066
1067         // user defined functions
1068     }
1069     public class Xcls_iconmodel : Object
1070     {
1071         public Gtk.ListStore el;
1072         private Xcls_PopoverFiles  _this;
1073
1074
1075             // my vars (def)
1076
1077         // ctor
1078         public Xcls_iconmodel(Xcls_PopoverFiles _owner )
1079         {
1080             _this = _owner;
1081             _this.iconmodel = this;
1082             this.el = new Gtk.ListStore.newv(  { typeof(Object), typeof(string), typeof(string), typeof(Gdk.Pixbuf), typeof(Gdk.Pixbuf)  }  );
1083
1084             // my vars (dec)
1085
1086             // set gobject values
1087         }
1088
1089         // user defined functions
1090     }
1091
1092
1093
1094
1095     public class Xcls_file_container : Object
1096     {
1097         public Gtk.ScrolledWindow el;
1098         private Xcls_PopoverFiles  _this;
1099
1100
1101             // my vars (def)
1102
1103         // ctor
1104         public Xcls_file_container(Xcls_PopoverFiles _owner )
1105         {
1106             _this = _owner;
1107             _this.file_container = this;
1108             this.el = new Gtk.ScrolledWindow( null, null );
1109
1110             // my vars (dec)
1111
1112             // set gobject values
1113             this.el.width_request = 100;
1114             this.el.expand = true;
1115             this.el.shadow_type = Gtk.ShadowType.IN;
1116             this.el.visible = false;
1117             var child_0 = new Xcls_fileview( _this );
1118             child_0.ref();
1119             this.el.add (  child_0.el  );
1120
1121             // init method
1122
1123             this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
1124         }
1125
1126         // user defined functions
1127     }
1128     public class Xcls_fileview : Object
1129     {
1130         public Gtk.TreeView el;
1131         private Xcls_PopoverFiles  _this;
1132
1133
1134             // my vars (def)
1135
1136         // ctor
1137         public Xcls_fileview(Xcls_PopoverFiles _owner )
1138         {
1139             _this = _owner;
1140             _this.fileview = this;
1141             this.el = new Gtk.TreeView();
1142
1143             // my vars (dec)
1144
1145             // set gobject values
1146             this.el.activate_on_single_click = false;
1147             this.el.expand = true;
1148             this.el.enable_tree_lines = true;
1149             this.el.headers_visible = true;
1150             var child_0 = new Xcls_filemodel( _this );
1151             child_0.ref();
1152             this.el.set_model (  child_0.el  );
1153             var child_1 = new Xcls_TreeViewColumn24( _this );
1154             child_1.ref();
1155             this.el.append_column (  child_1.el  );
1156
1157             // init method
1158
1159             var description = new Pango.FontDescription();
1160                  description.set_size(9000);
1161                 this.el.override_font(description);     
1162                                 
1163                 var selection = this.el.get_selection();
1164                 selection.set_mode( Gtk.SelectionMode.SINGLE);
1165
1166             //listeners
1167             this.el.row_activated.connect( (path, col) => {
1168             
1169                 Gtk.TreeIter iter;
1170                
1171                         
1172                 this.el.model.get_iter(out iter, path);
1173                 
1174                 GLib.Value gval;
1175             
1176                 this.el.model.get_value(iter, 1 , out gval);
1177                var fn = (string)gval;
1178                 if (fn.length < 1) {
1179                         return;
1180                 }
1181                 _this.win.windowstate.project = _this.selectedProject;
1182                  _this.el.hide();
1183                 try {
1184                         var f = JsRender.JsRender.factory("PlainFile", _this.selectedProject, fn);
1185                         _this.win.windowstate.fileViewOpen(f, _this.new_window);
1186                 } catch (JsRender.Error e) {}   
1187                 
1188             });
1189             this.el.cursor_changed.connect( () => {
1190              /*
1191                 if (_this.is_loading) {
1192                     return;
1193                 }
1194                 
1195                 Gtk.TreeIter iter;
1196                 Gtk.TreeModel mod;
1197                         
1198                 var s = this.el.get_selection();
1199                 if (!s.get_selected(out mod, out iter)) {
1200                     return;
1201                 }
1202                 
1203                 GLib.Value gval;
1204             
1205                 mod.get_value(iter, 1 , out gval);
1206                 var project = (Project.Project)gval.get_object();
1207                 
1208                 _this.project_selected(project);
1209                 */
1210             });
1211         }
1212
1213         // user defined functions
1214     }
1215     public class Xcls_filemodel : Object
1216     {
1217         public Gtk.TreeStore el;
1218         private Xcls_PopoverFiles  _this;
1219
1220
1221             // my vars (def)
1222
1223         // ctor
1224         public Xcls_filemodel(Xcls_PopoverFiles _owner )
1225         {
1226             _this = _owner;
1227             _this.filemodel = this;
1228             this.el = new Gtk.TreeStore.newv(  { typeof(string), typeof(string) }  );
1229
1230             // my vars (dec)
1231
1232             // set gobject values
1233
1234             // init method
1235
1236             {
1237                this.el.set_sort_func(0, (mod,a,b) => {
1238                    GLib.Value ga, gb;
1239                    mod.get_value(a,0, out ga);
1240                    mod.get_value(b,0, out gb);
1241                     
1242                     if ((string)ga == (string)gb) {
1243                         return 0;
1244                     }
1245                     return (string)ga > (string)gb ? 1 : -1;
1246                }); 
1247              
1248             
1249             }
1250         }
1251
1252         // user defined functions
1253     }
1254
1255     public class Xcls_TreeViewColumn24 : Object
1256     {
1257         public Gtk.TreeViewColumn el;
1258         private Xcls_PopoverFiles  _this;
1259
1260
1261             // my vars (def)
1262
1263         // ctor
1264         public Xcls_TreeViewColumn24(Xcls_PopoverFiles _owner )
1265         {
1266             _this = _owner;
1267             this.el = new Gtk.TreeViewColumn();
1268
1269             // my vars (dec)
1270
1271             // set gobject values
1272             this.el.title = "File";
1273             var child_0 = new Xcls_filenamecol( _this );
1274             child_0.ref();
1275             this.el.pack_start (  child_0.el , true );
1276
1277             // init method
1278
1279             this.el.add_attribute(_this.filenamecol.el , "markup", 0  );
1280         }
1281
1282         // user defined functions
1283     }
1284     public class Xcls_filenamecol : Object
1285     {
1286         public Gtk.CellRendererText el;
1287         private Xcls_PopoverFiles  _this;
1288
1289
1290             // my vars (def)
1291
1292         // ctor
1293         public Xcls_filenamecol(Xcls_PopoverFiles _owner )
1294         {
1295             _this = _owner;
1296             _this.filenamecol = this;
1297             this.el = new Gtk.CellRendererText();
1298
1299             // my vars (dec)
1300
1301             // set gobject values
1302         }
1303
1304         // user defined functions
1305     }
1306
1307
1308
1309
1310
1311
1312 }