11e80aa05eedf7b0a6920894f7a29c53718b1e64
[roobuilder] / src / Builder4 / DialogFiles.vala
1 static DialogFiles  _DialogFiles;
2
3 public class DialogFiles : Object
4 {
5         public Gtk.Window el;
6         private DialogFiles  _this;
7
8         public static DialogFiles singleton()
9         {
10                 if (_DialogFiles == null) {
11                     _DialogFiles= new DialogFiles();
12                 }
13                 return _DialogFiles;
14         }
15         public Xcls_mainpane mainpane;
16         public Xcls_projectscroll projectscroll;
17         public Xcls_project_list project_list;
18         public Xcls_projectselection projectselection;
19         public Xcls_projectsort projectsort;
20         public Xcls_projectmodel projectmodel;
21         public Xcls_filepane filepane;
22         public Xcls_searchbox searchbox;
23         public Xcls_iconscroll iconscroll;
24         public Xcls_gridview gridview;
25         public Xcls_iconsel iconsel;
26         public Xcls_gridsort gridsort;
27         public Xcls_gridmodel gridmodel;
28         public Xcls_iconsearch iconsearch;
29         public Xcls_treescroll treescroll;
30         public Xcls_treeview treeview;
31         public Xcls_treeselmodel treeselmodel;
32         public Xcls_treelistsort treelistsort;
33         public Xcls_treelistmodel treelistmodel;
34         public Xcls_treemodel treemodel;
35         public Xcls_treefilter treefilter;
36         public Xcls_name name;
37         public Xcls_btn_newproj btn_newproj;
38         public Xcls_btn_projprop btn_projprop;
39         public Xcls_btn_delproj btn_delproj;
40         public Xcls_btn_addfile btn_addfile;
41         public Xcls_btn_delfile btn_delfile;
42
43                 // my vars (def)
44         public Xcls_MainWindow win;
45         public string lastfilter;
46         public bool in_onprojectselected;
47         public bool is_loading;
48         public bool new_window;
49         public Project.Project selectedProject;
50         public Gdk.Pixbuf missing_thumb_pixbuf;
51         public Gee.HashMap<string,Gdk.Pixbuf> image_cache;
52
53         // ctor
54         public DialogFiles()
55         {
56                 _this = this;
57                 this.el = new Gtk.Window();
58
59                 // my vars (dec)
60                 this.in_onprojectselected = false;
61                 this.is_loading = false;
62                 this.new_window = false;
63
64                 // set gobject values
65                 this.el.title = "Select Project / File";
66                 this.el.name = "DialogFiles";
67                 this.el.default_height = 550;
68                 this.el.default_width = 1000;
69                 this.el.modal = true;
70                 var child_1 = new Xcls_Box1( _this );
71                 this.el.child = child_1.el;
72                 var child_2 = new Xcls_HeaderBar43( _this );
73                 this.el.titlebar = child_2.el;
74
75                 // init method
76
77                 {
78                         var ev = new Gtk.EventControllerKey();
79                         ev.propagation_phase = Gtk.PropagationPhase.CAPTURE;
80                         // my vars (dec)
81                 
82                         // set gobject values
83                 
84                         //listeners
85                         ev.key_released.connect( (keyval, keycode, state) => {
86                         
87                                 // GLib.debug("key pressed %d", (int)keycode);
88                                 if (keycode != 9) {
89                                         return   ;
90                                 }
91                                 if (BuilderApplication.windows.size < 2 && 
92                                         _this.win.windowstate.file == null
93                                 ) { 
94                                         BuilderApplication.singleton(null).quit();
95                                         return  ;
96                                 }
97                         
98                                 _this.el.hide();
99                                 
100                                  if (_this.win.windowstate.file == null) {               
101                                         BuilderApplication.removeWindow(_this.win);
102                                             
103                                 }
104                         
105                                 return  ;
106                         });
107                         ev.ref(); //?? needed?
108                         (this.el as Gtk.Widget).add_controller(ev);
109                 }
110         }
111
112         // user defined functions
113         public void onProjectSelected (Project.Project? project) 
114         {
115                 if (this.in_onprojectselected) { 
116                         return;
117                 }
118                 this.selectedProject = project;
119                 
120                 if (project == null) {
121                         GLib.debug("Hide project files");
122                         _this.mainpane.el.set_end_child(null);
123                         _this.filepane.el.hide();
124                         return;
125                         
126                 }
127                 
128                 GLib.debug("Show project files");
129                 _this.mainpane.el.set_end_child(_this.filepane.el);
130                 
131                 _this.filepane.el.show();       
132                 this.in_onprojectselected = true;
133                 
134                 
135         
136                 project.load();
137                  
138                 
139                 _this.searchbox.el.text = "";
140                  _this.gridview.el.set_model(new Gtk.SingleSelection(null));
141                  _this.selectedProject.loadFilesIntoStore(_this.gridmodel.el);
142                  _this.iconsel.el.selected = Gtk.INVALID_LIST_POSITION;
143                         
144                  _this.gridview.el.set_model(_this.iconsel.el);
145                    
146                  
147                  GLib.Timeout.add(500, () => {
148                         _this.iconsel.el.selected = Gtk.INVALID_LIST_POSITION;
149                          _this.treeselmodel.el.selected = Gtk.INVALID_LIST_POSITION;             
150                  
151                      _this.searchbox.el.grab_focus();
152                            return false;
153              });
154                  _this.treeview.el.set_model(new Gtk.SingleSelection(null));
155             
156             this.selectedProject.loadDirsIntoStore(_this.treemodel.el);
157             
158             _this.treeview.el.set_model(_this.treeselmodel.el);
159             
160                  _this.treeselmodel.el.selected = Gtk.INVALID_LIST_POSITION;
161                 this.treescroll.el.vadjustment.value = 0;
162                 this.in_onprojectselected = false;      
163         }
164         public void selectProject (Project.Project? project) {
165             
166                 
167                  
168                 var sm = this.projectselection.el;
169                 if (project == null) {
170                         sm.selected = Gtk.INVALID_LIST_POSITION;
171                         this.onProjectSelected(null);
172                         return;
173                 }
174         
175                 
176                 for (var i =0; i < sm.n_items; i++) {
177                         var p = (Project.Project) sm.get_item(i);
178                         if (p.path == project.path) {
179                                 GLib.debug("Select Project %s => %d", project.name, i);
180                                 sm.selected = i;
181                                 break;
182                         }
183                 } 
184                 
185         }
186         public void show (Project.Project? project, bool new_window) {
187               
188                 this.new_window = new_window;
189         
190             this.projectscroll.el.vadjustment.value = 0; // scroll to top?
191             
192           
193                   //var win = this.win.el;
194               //var  w = win.get_width();
195               //var h = win.get_height();
196          
197                 
198                  this.el.show();
199          this.load();
200                 this.selectProject(project);
201                 this.onProjectSelected(project);   //?? twice?
202                  
203                     GLib.Timeout.add(500, () => {
204                         if (project == null) {
205                                 _this.projectselection.el.selected = Gtk.INVALID_LIST_POSITION;
206                                         this.onProjectSelected(null); 
207                 
208                                 } 
209                           this.el.set_size_request( 800 , 750);  // ?? based on default 
210                      return false;
211              });
212                  
213         }//
214         public void load () {
215              // cl list...
216             
217                
218              _this.is_loading = true;
219                 
220         
221              Project.Project.loadAll();
222              _this.project_list.el.set_model(new Gtk.SingleSelection(null));
223              Project.Project.loadIntoStore(this.projectmodel.el);
224         
225                 _this.project_list.el.set_model(_this.projectselection.el);
226                 
227                 _this.is_loading = false;
228             
229             _this.projectselection.el.selected = Gtk.INVALID_LIST_POSITION; 
230                 _this.btn_delfile.el.hide();
231          
232           
233         }
234         public class Xcls_Box1 : Object
235         {
236                 public Gtk.Box el;
237                 private DialogFiles  _this;
238
239
240                         // my vars (def)
241                 public bool expand;
242
243                 // ctor
244                 public Xcls_Box1(DialogFiles _owner )
245                 {
246                         _this = _owner;
247                         this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
248
249                         // my vars (dec)
250                         this.expand = true;
251
252                         // set gobject values
253                         this.el.homogeneous = false;
254                         this.el.margin_end = 10;
255                         this.el.margin_start = 10;
256                         this.el.margin_bottom = 10;
257                         this.el.margin_top = 10;
258                         var child_1 = new Xcls_Box2( _this );
259                         child_1.ref();
260                         this.el.append( child_1.el );
261                         new Xcls_mainpane( _this );
262                         this.el.append( _this.mainpane.el );
263                 }
264
265                 // user defined functions
266         }
267         public class Xcls_Box2 : Object
268         {
269                 public Gtk.Box el;
270                 private DialogFiles  _this;
271
272
273                         // my vars (def)
274
275                 // ctor
276                 public Xcls_Box2(DialogFiles _owner )
277                 {
278                         _this = _owner;
279                         this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
280
281                         // my vars (dec)
282
283                         // set gobject values
284                         this.el.hexpand = true;
285                 }
286
287                 // user defined functions
288         }
289
290         public class Xcls_mainpane : Object
291         {
292                 public Gtk.Paned el;
293                 private DialogFiles  _this;
294
295
296                         // my vars (def)
297                 public bool homogeneous;
298                 public int spacing;
299
300                 // ctor
301                 public Xcls_mainpane(DialogFiles _owner )
302                 {
303                         _this = _owner;
304                         _this.mainpane = this;
305                         this.el = new Gtk.Paned( Gtk.Orientation.HORIZONTAL );
306
307                         // my vars (dec)
308                         this.homogeneous = false;
309                         this.spacing = 0;
310
311                         // set gobject values
312                         this.el.hexpand = true;
313                         this.el.vexpand = true;
314                         this.el.position = 200;
315                         new Xcls_projectscroll( _this );
316                         this.el.start_child = _this.projectscroll.el;
317                         new Xcls_filepane( _this );
318                         this.el.end_child = _this.filepane.el;
319                         var child_3 = new Xcls_EventControllerKey411( _this );
320                         child_3.ref();
321                         this.el.add_controller(  child_3.el );
322                 }
323
324                 // user defined functions
325         }
326         public class Xcls_projectscroll : Object
327         {
328                 public Gtk.ScrolledWindow el;
329                 private DialogFiles  _this;
330
331
332                         // my vars (def)
333                 public bool expand;
334
335                 // ctor
336                 public Xcls_projectscroll(DialogFiles _owner )
337                 {
338                         _this = _owner;
339                         _this.projectscroll = this;
340                         this.el = new Gtk.ScrolledWindow();
341
342                         // my vars (dec)
343                         this.expand = true;
344
345                         // set gobject values
346                         this.el.width_request = 150;
347                         this.el.has_frame = true;
348                         this.el.hexpand = true;
349                         this.el.vexpand = true;
350                         new Xcls_project_list( _this );
351                         this.el.child = _this.project_list.el;
352
353                         // init method
354
355                         this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
356                 }
357
358                 // user defined functions
359         }
360         public class Xcls_project_list : Object
361         {
362                 public Gtk.ColumnView el;
363                 private DialogFiles  _this;
364
365
366                         // my vars (def)
367                 public Gtk.CssProvider css;
368
369                 // ctor
370                 public Xcls_project_list(DialogFiles _owner )
371                 {
372                         _this = _owner;
373                         _this.project_list = this;
374                         new Xcls_projectselection( _this );
375                         this.el = new Gtk.ColumnView( _this.projectselection.el );
376
377                         // my vars (dec)
378
379                         // set gobject values
380                         this.el.name = "project-list";
381                         var child_2 = new Xcls_ColumnViewColumn11( _this );
382                         child_2.ref();
383                         this.el.append_column ( child_2.el  );
384                 }
385
386                 // user defined functions
387         }
388         public class Xcls_projectselection : Object
389         {
390                 public Gtk.SingleSelection el;
391                 private DialogFiles  _this;
392
393
394                         // my vars (def)
395
396                 // ctor
397                 public Xcls_projectselection(DialogFiles _owner )
398                 {
399                         _this = _owner;
400                         _this.projectselection = this;
401                         new Xcls_projectsort( _this );
402                         this.el = new Gtk.SingleSelection( _this.projectsort.el );
403
404                         // my vars (dec)
405
406                         // set gobject values
407                         this.el.can_unselect = true;
408
409                         //listeners
410                         this.el.notify["selected"].connect( (position, n_items) => {
411                         
412                             if (_this.is_loading) {
413                                 return;
414                                 }
415                           
416                                 if (this.el.selected == Gtk.INVALID_LIST_POSITION) {
417                                         _this.btn_delproj.el.hide();
418                                         _this.btn_projprop.el.hide();
419                                         _this.btn_addfile.el.hide();
420                                         //_this.btn_delfile.el.hide();
421                                          
422                                 } else {
423                                         _this.btn_delproj.el.show();
424                                         _this.btn_projprop.el.show();
425                                         _this.btn_addfile.el.show();
426                                         //_this.btn_delfile.el.show(); // ??
427                                 }
428                          
429                          
430                          
431                             
432                             
433                             if (_this.is_loading) {
434                                 return;
435                             }
436                                     
437                                  Project.Project project  = this.el.selected == Gtk.INVALID_LIST_POSITION ? null :
438                                                 (Project.Project) _this.projectsort.el.get_item(this.el.selected);
439                                  
440                                  GLib.debug("selection changed to %s", project == null ? "none" : project.name);
441                           
442                             _this.onProjectSelected(project);
443                         });
444                 }
445
446                 // user defined functions
447         }
448         public class Xcls_projectsort : Object
449         {
450                 public Gtk.SortListModel el;
451                 private DialogFiles  _this;
452
453
454                         // my vars (def)
455
456                 // ctor
457                 public Xcls_projectsort(DialogFiles _owner )
458                 {
459                         _this = _owner;
460                         _this.projectsort = this;
461                         new Xcls_projectmodel( _this );
462                         var child_2 = new Xcls_StringSorter9( _this );
463                         child_2.ref();
464                         this.el = new Gtk.SortListModel( _this.projectmodel.el, child_2.el );
465
466                         // my vars (dec)
467
468                         // set gobject values
469                         this.el.incremental = true;
470                 }
471
472                 // user defined functions
473         }
474         public class Xcls_projectmodel : Object
475         {
476                 public GLib.ListStore el;
477                 private DialogFiles  _this;
478
479
480                         // my vars (def)
481
482                 // ctor
483                 public Xcls_projectmodel(DialogFiles _owner )
484                 {
485                         _this = _owner;
486                         _this.projectmodel = this;
487                         this.el = new GLib.ListStore( typeof(Project.Project) );
488
489                         // my vars (dec)
490
491                         // set gobject values
492                 }
493
494                 // user defined functions
495                 public void remove (Project.Project p) {
496                 
497                         for (var i =0;i < this.el.n_items; i++ ) {
498                                 var pr = (Project.Project) this.el.get_item(i);
499                                 if (p.path == pr.path) {
500                                         this.el.remove(i);
501                                         return;
502                                 }
503                         }
504                 
505                 
506                 }
507         }
508
509         public class Xcls_StringSorter9 : Object
510         {
511                 public Gtk.StringSorter el;
512                 private DialogFiles  _this;
513
514
515                         // my vars (def)
516
517                 // ctor
518                 public Xcls_StringSorter9(DialogFiles _owner )
519                 {
520                         _this = _owner;
521                         var child_1 = new Xcls_PropertyExpression10( _this );
522                         child_1.ref();
523                         this.el = new Gtk.StringSorter( child_1.el );
524
525                         // my vars (dec)
526
527                         // set gobject values
528                 }
529
530                 // user defined functions
531         }
532         public class Xcls_PropertyExpression10 : Object
533         {
534                 public Gtk.PropertyExpression el;
535                 private DialogFiles  _this;
536
537
538                         // my vars (def)
539
540                 // ctor
541                 public Xcls_PropertyExpression10(DialogFiles _owner )
542                 {
543                         _this = _owner;
544                         this.el = new Gtk.PropertyExpression( typeof(Project.Project), null, "name" );
545
546                         // my vars (dec)
547
548                         // set gobject values
549                 }
550
551                 // user defined functions
552         }
553
554
555
556
557         public class Xcls_ColumnViewColumn11 : Object
558         {
559                 public Gtk.ColumnViewColumn el;
560                 private DialogFiles  _this;
561
562
563                         // my vars (def)
564
565                 // ctor
566                 public Xcls_ColumnViewColumn11(DialogFiles _owner )
567                 {
568                         _this = _owner;
569                         var child_1 = new Xcls_SignalListItemFactory12( _this );
570                         child_1.ref();
571                         this.el = new Gtk.ColumnViewColumn( "Project", child_1.el );
572
573                         // my vars (dec)
574
575                         // set gobject values
576                         this.el.expand = true;
577                 }
578
579                 // user defined functions
580         }
581         public class Xcls_SignalListItemFactory12 : Object
582         {
583                 public Gtk.SignalListItemFactory el;
584                 private DialogFiles  _this;
585
586
587                         // my vars (def)
588
589                 // ctor
590                 public Xcls_SignalListItemFactory12(DialogFiles _owner )
591                 {
592                         _this = _owner;
593                         this.el = new Gtk.SignalListItemFactory();
594
595                         // my vars (dec)
596
597                         // set gobject values
598
599                         //listeners
600                         this.el.setup.connect( (item) => {
601                                 //var j = (JsRender.JsRender) item;
602                                 var gi = (Gtk.ListItem)item;
603                                  
604                                 var lbl = new Gtk.Label("");
605                                 lbl.halign = Gtk.Align.START;
606                                 gi.set_child(lbl);
607                         
608                         
609                         
610                         });
611                         this.el.bind.connect( (listitem) => {
612                          
613                                 var lbl = (Gtk.Label)  ((Gtk.ListItem)listitem).get_child();
614                                    
615                                 var item = (Project.Project)  ((Gtk.ListItem)listitem).get_item();
616                         
617                                 item.bind_property("name",
618                                         lbl, "label",
619                                    GLib.BindingFlags.SYNC_CREATE);
620                         
621                                   
622                         });
623                 }
624
625                 // user defined functions
626         }
627
628
629
630
631         public class Xcls_filepane : Object
632         {
633                 public Gtk.Paned el;
634                 private DialogFiles  _this;
635
636
637                         // my vars (def)
638
639                 // ctor
640                 public Xcls_filepane(DialogFiles _owner )
641                 {
642                         _this = _owner;
643                         _this.filepane = this;
644                         this.el = new Gtk.Paned( Gtk.Orientation.HORIZONTAL );
645
646                         // my vars (dec)
647
648                         // set gobject values
649                         this.el.position = 200;
650                         this.el.visible = false;
651                         var child_1 = new Xcls_Box14( _this );
652                         this.el.end_child = child_1.el;
653                         new Xcls_treescroll( _this );
654                         this.el.start_child = _this.treescroll.el;
655                 }
656
657                 // user defined functions
658         }
659         public class Xcls_Box14 : Object
660         {
661                 public Gtk.Box el;
662                 private DialogFiles  _this;
663
664
665                         // my vars (def)
666
667                 // ctor
668                 public Xcls_Box14(DialogFiles _owner )
669                 {
670                         _this = _owner;
671                         this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
672
673                         // my vars (dec)
674
675                         // set gobject values
676                         this.el.hexpand = true;
677                         this.el.vexpand = true;
678                         var child_1 = new Xcls_Box15( _this );
679                         child_1.ref();
680                         this.el.append( child_1.el );
681                         new Xcls_iconscroll( _this );
682                         this.el.append( _this.iconscroll.el );
683                 }
684
685                 // user defined functions
686         }
687         public class Xcls_Box15 : Object
688         {
689                 public Gtk.Box el;
690                 private DialogFiles  _this;
691
692
693                         // my vars (def)
694
695                 // ctor
696                 public Xcls_Box15(DialogFiles _owner )
697                 {
698                         _this = _owner;
699                         this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
700
701                         // my vars (dec)
702
703                         // set gobject values
704                         this.el.hexpand = true;
705                         new Xcls_searchbox( _this );
706                         this.el.append( _this.searchbox.el );
707                 }
708
709                 // user defined functions
710         }
711         public class Xcls_searchbox : Object
712         {
713                 public Gtk.SearchEntry el;
714                 private DialogFiles  _this;
715
716
717                         // my vars (def)
718                 public Gtk.CssProvider css;
719
720                 // ctor
721                 public Xcls_searchbox(DialogFiles _owner )
722                 {
723                         _this = _owner;
724                         _this.searchbox = this;
725                         this.el = new Gtk.SearchEntry();
726
727                         // my vars (dec)
728
729                         // set gobject values
730                         this.el.name = "popover-files-iconsearch";
731                         this.el.hexpand = true;
732                         this.el.placeholder_text = "type to filter results";
733                         this.el.search_delay = 1000;
734
735                         // init method
736
737                         /*
738                         this.css = new Gtk.CssProvider();
739                         try {
740                                 this.css.load_from_data("#popover-files-iconsearch { font:  10px monospace;}".data);
741                         } catch (Error e) {}
742                         this.el.get_style_context().add_provider(this.css,Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
743                                 
744                                 
745                         */
746
747                         //listeners
748                         this.el.search_changed.connect( ( ) => {
749                         
750                                 _this.treefilter.el.changed(Gtk.FilterChange.DIFFERENT);
751                                 _this.iconsearch.el.set_search(this.el.text);
752                         });
753                 }
754
755                 // user defined functions
756         }
757
758
759         public class Xcls_iconscroll : Object
760         {
761                 public Gtk.ScrolledWindow el;
762                 private DialogFiles  _this;
763
764
765                         // my vars (def)
766
767                 // ctor
768                 public Xcls_iconscroll(DialogFiles _owner )
769                 {
770                         _this = _owner;
771                         _this.iconscroll = this;
772                         this.el = new Gtk.ScrolledWindow();
773
774                         // my vars (dec)
775
776                         // set gobject values
777                         this.el.has_frame = true;
778                         this.el.hexpand = true;
779                         this.el.vexpand = true;
780                         new Xcls_gridview( _this );
781                         this.el.child = _this.gridview.el;
782
783                         // init method
784
785                         this.el.set_policy (Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC);
786                 }
787
788                 // user defined functions
789         }
790         public class Xcls_gridview : Object
791         {
792                 public Gtk.GridView el;
793                 private DialogFiles  _this;
794
795
796                         // my vars (def)
797
798                 // ctor
799                 public Xcls_gridview(DialogFiles _owner )
800                 {
801                         _this = _owner;
802                         _this.gridview = this;
803                         new Xcls_iconsel( _this );
804                         var child_2 = new Xcls_SignalListItemFactory28( _this );
805                         child_2.ref();
806                         this.el = new Gtk.GridView( _this.iconsel.el, child_2.el );
807
808                         // my vars (dec)
809
810                         // set gobject values
811                         var child_3 = new Xcls_GestureClick19( _this );
812                         child_3.ref();
813                         this.el.add_controller(  child_3.el );
814                 }
815
816                 // user defined functions
817         }
818         public class Xcls_GestureClick19 : Object
819         {
820                 public Gtk.GestureClick el;
821                 private DialogFiles  _this;
822
823
824                         // my vars (def)
825
826                 // ctor
827                 public Xcls_GestureClick19(DialogFiles _owner )
828                 {
829                         _this = _owner;
830                         this.el = new Gtk.GestureClick();
831
832                         // my vars (dec)
833
834                         // set gobject values
835
836                         //listeners
837                         this.el.pressed.connect( (n_press, x, y) => {
838                                 if (n_press == 2) {
839                                         GLib.debug("double cliced");
840                                 } else {
841                                         return;
842                                 }
843                                 var f = (JsRender.JsRender)_this.iconsel.el.selected_item;
844                                   
845                                 GLib.debug("Click %s", f.name);
846                                 if (f.xtype == "Dir") {
847                                         return;
848                                 }
849                                 
850                                 
851                                 _this.win.windowstate.fileViewOpen(f, _this.new_window);
852                                 _this.el.hide();
853                                 
854                                 
855                                 
856                         
857                         });
858                 }
859
860                 // user defined functions
861         }
862
863         public class Xcls_iconsel : Object
864         {
865                 public Gtk.SingleSelection el;
866                 private DialogFiles  _this;
867
868
869                         // my vars (def)
870
871                 // ctor
872                 public Xcls_iconsel(DialogFiles _owner )
873                 {
874                         _this = _owner;
875                         _this.iconsel = this;
876                         var child_1 = new Xcls_FilterListModel21( _this );
877                         child_1.ref();
878                         this.el = new Gtk.SingleSelection( child_1.el );
879
880                         // my vars (dec)
881
882                         // set gobject values
883                         this.el.can_unselect = true;
884
885                         //listeners
886                         this.el.notify["selected"].connect( () => {
887                                 if (this.el.selected == Gtk.INVALID_LIST_POSITION) {
888                                         if (_this.treeselmodel.el.selected == Gtk.INVALID_LIST_POSITION) {
889                                                 _this.btn_delfile.el.hide();
890                                         }
891                                 
892                                         return;
893                                 }
894                                 _this.btn_delfile.el.show();
895                                 _this.treeselmodel.el.selected = Gtk.INVALID_LIST_POSITION;
896                         
897                         
898                         });
899                 }
900
901                 // user defined functions
902                 public JsRender.JsRender? selectedFile () {
903                 
904                         if (this.el.selected == Gtk.INVALID_LIST_POSITION) {
905                                 return null;
906                         }
907                         return  (JsRender.JsRender)this.el.get_item(this.el.selected); 
908                         
909                  
910                 }
911         }
912         public class Xcls_FilterListModel21 : Object
913         {
914                 public Gtk.FilterListModel el;
915                 private DialogFiles  _this;
916
917
918                         // my vars (def)
919
920                 // ctor
921                 public Xcls_FilterListModel21(DialogFiles _owner )
922                 {
923                         _this = _owner;
924                         new Xcls_gridsort( _this );
925                         new Xcls_iconsearch( _this );
926                         this.el = new Gtk.FilterListModel( _this.gridsort.el, _this.iconsearch.el );
927
928                         // my vars (dec)
929
930                         // set gobject values
931                 }
932
933                 // user defined functions
934         }
935         public class Xcls_gridsort : Object
936         {
937                 public Gtk.SortListModel el;
938                 private DialogFiles  _this;
939
940
941                         // my vars (def)
942
943                 // ctor
944                 public Xcls_gridsort(DialogFiles _owner )
945                 {
946                         _this = _owner;
947                         _this.gridsort = this;
948                         new Xcls_gridmodel( _this );
949                         var child_2 = new Xcls_StringSorter24( _this );
950                         child_2.ref();
951                         this.el = new Gtk.SortListModel( _this.gridmodel.el, child_2.el );
952
953                         // my vars (dec)
954
955                         // set gobject values
956                 }
957
958                 // user defined functions
959         }
960         public class Xcls_gridmodel : Object
961         {
962                 public GLib.ListStore el;
963                 private DialogFiles  _this;
964
965
966                         // my vars (def)
967
968                 // ctor
969                 public Xcls_gridmodel(DialogFiles _owner )
970                 {
971                         _this = _owner;
972                         _this.gridmodel = this;
973                         this.el = new GLib.ListStore( typeof(JsRender.JsRender) );
974
975                         // my vars (dec)
976
977                         // set gobject values
978                 }
979
980                 // user defined functions
981                 public void remove (JsRender.JsRender p) {
982                 
983                         for (var i =0;i < this.el.n_items; i++ ) {
984                                 var pr = (JsRender.JsRender) this.el.get_item(i);
985                                 if (p.path == pr.path) {
986                                         this.el.remove(i);
987                                         return;
988                                 }
989                         }
990                  
991                 }
992         }
993
994         public class Xcls_StringSorter24 : Object
995         {
996                 public Gtk.StringSorter el;
997                 private DialogFiles  _this;
998
999
1000                         // my vars (def)
1001
1002                 // ctor
1003                 public Xcls_StringSorter24(DialogFiles _owner )
1004                 {
1005                         _this = _owner;
1006                         var child_1 = new Xcls_PropertyExpression25( _this );
1007                         child_1.ref();
1008                         this.el = new Gtk.StringSorter( child_1.el );
1009
1010                         // my vars (dec)
1011
1012                         // set gobject values
1013                         this.el.ignore_case = true;
1014                 }
1015
1016                 // user defined functions
1017         }
1018         public class Xcls_PropertyExpression25 : Object
1019         {
1020                 public Gtk.PropertyExpression el;
1021                 private DialogFiles  _this;
1022
1023
1024                         // my vars (def)
1025
1026                 // ctor
1027                 public Xcls_PropertyExpression25(DialogFiles _owner )
1028                 {
1029                         _this = _owner;
1030                         this.el = new Gtk.PropertyExpression( typeof(JsRender.JsRender), null, "name" );
1031
1032                         // my vars (dec)
1033
1034                         // set gobject values
1035                 }
1036
1037                 // user defined functions
1038         }
1039
1040
1041
1042         public class Xcls_iconsearch : Object
1043         {
1044                 public Gtk.StringFilter el;
1045                 private DialogFiles  _this;
1046
1047
1048                         // my vars (def)
1049
1050                 // ctor
1051                 public Xcls_iconsearch(DialogFiles _owner )
1052                 {
1053                         _this = _owner;
1054                         _this.iconsearch = this;
1055                         var child_1 = new Xcls_PropertyExpression27( _this );
1056                         child_1.ref();
1057                         this.el = new Gtk.StringFilter( child_1.el );
1058
1059                         // my vars (dec)
1060
1061                         // set gobject values
1062                         this.el.match_mode = Gtk.StringFilterMatchMode.SUBSTRING;
1063                         this.el.ignore_case = true;
1064                 }
1065
1066                 // user defined functions
1067         }
1068         public class Xcls_PropertyExpression27 : Object
1069         {
1070                 public Gtk.PropertyExpression el;
1071                 private DialogFiles  _this;
1072
1073
1074                         // my vars (def)
1075
1076                 // ctor
1077                 public Xcls_PropertyExpression27(DialogFiles _owner )
1078                 {
1079                         _this = _owner;
1080                         this.el = new Gtk.PropertyExpression( typeof(JsRender.JsRender), null, "name" );
1081
1082                         // my vars (dec)
1083
1084                         // set gobject values
1085                 }
1086
1087                 // user defined functions
1088         }
1089
1090
1091
1092
1093         public class Xcls_SignalListItemFactory28 : Object
1094         {
1095                 public Gtk.SignalListItemFactory el;
1096                 private DialogFiles  _this;
1097
1098
1099                         // my vars (def)
1100
1101                 // ctor
1102                 public Xcls_SignalListItemFactory28(DialogFiles _owner )
1103                 {
1104                         _this = _owner;
1105                         this.el = new Gtk.SignalListItemFactory();
1106
1107                         // my vars (dec)
1108
1109                         // set gobject values
1110
1111                         //listeners
1112                         this.el.setup.connect( (item) => {
1113                                 //var j = (JsRender.JsRender) item;
1114                                 var gi = (Gtk.ListItem)item;
1115                                 var b  = new Gtk.Box(Gtk.Orientation.VERTICAL,4);
1116                                 var i = new Gtk.Image();
1117                                 i.pixel_size = 96;
1118                                 var t = new Gtk.Label("");
1119                                 b.append(i);
1120                                 b.append(t);
1121                                 
1122                                 gi.set_child(b);
1123                                 b.has_tooltip = true;
1124                                 b.query_tooltip.connect((x, y, keyboard_tooltip, tooltip) => {
1125                                         var j = (JsRender.JsRender) gi.get_item();
1126                                         
1127                                         var ti = new Gtk.Image.from_file ( j.getIconFileName());
1128                                         ti.pixel_size = 368;
1129                                         tooltip.set_custom( ti );
1130                                         return true;
1131                                 });
1132                         
1133                         
1134                         });
1135                         this.el.bind.connect( (listitem) => {
1136                          
1137                                 var box = (Gtk.Box)  ((Gtk.ListItem)listitem).get_child();
1138                                    
1139                                 var img = (Gtk.Image) box.get_first_child();
1140                                 var lbl = (Gtk.Label)img.get_next_sibling();
1141                         
1142                                 var item = (JsRender.JsRender)  ((Gtk.ListItem)listitem).get_item();
1143                                 //GLib.debug("set label name to %s", item.name);
1144                                  
1145                                 var ns = item.name.split(".");
1146                                 if (ns.length < 2) {
1147                                         lbl.label = item.name;
1148                                 } else {
1149                                         lbl.label =  
1150                                                 item.name.substring(0, item.name.length - ns[ns.length-1].length)
1151                                                  + "\n"+  ns[ns.length-1];
1152                                 }
1153                         
1154                         /*
1155                                 item.bind_property("name",
1156                                         lbl, "label",
1157                                    GLib.BindingFlags.SYNC_CREATE);
1158                         
1159                                 */
1160                             img.set_from_file(item.getIconFileName());
1161                             
1162                                   
1163                         });
1164                 }
1165
1166                 // user defined functions
1167         }
1168
1169
1170
1171
1172         public class Xcls_treescroll : Object
1173         {
1174                 public Gtk.ScrolledWindow el;
1175                 private DialogFiles  _this;
1176
1177
1178                         // my vars (def)
1179
1180                 // ctor
1181                 public Xcls_treescroll(DialogFiles _owner )
1182                 {
1183                         _this = _owner;
1184                         _this.treescroll = this;
1185                         this.el = new Gtk.ScrolledWindow();
1186
1187                         // my vars (dec)
1188
1189                         // set gobject values
1190                         this.el.width_request = 200;
1191                         this.el.has_frame = true;
1192                         this.el.hexpand = true;
1193                         this.el.vexpand = true;
1194                         this.el.visible = true;
1195                         new Xcls_treeview( _this );
1196                         this.el.child = _this.treeview.el;
1197
1198                         // init method
1199
1200                         this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
1201                 }
1202
1203                 // user defined functions
1204         }
1205         public class Xcls_treeview : Object
1206         {
1207                 public Gtk.ColumnView el;
1208                 private DialogFiles  _this;
1209
1210
1211                         // my vars (def)
1212                 public Gtk.CssProvider css;
1213
1214                 // ctor
1215                 public Xcls_treeview(DialogFiles _owner )
1216                 {
1217                         _this = _owner;
1218                         _this.treeview = this;
1219                         new Xcls_treeselmodel( _this );
1220                         this.el = new Gtk.ColumnView( _this.treeselmodel.el );
1221
1222                         // my vars (dec)
1223
1224                         // set gobject values
1225                         this.el.name = "file-list";
1226                         var child_2 = new Xcls_GestureClick31( _this );
1227                         child_2.ref();
1228                         this.el.add_controller(  child_2.el );
1229                         new Xcls_name( _this );
1230                         this.el.append_column ( _this.name.el  );
1231
1232                         // init method
1233
1234                         {
1235                          
1236                                 this.css = new Gtk.CssProvider();
1237                          
1238                                 this.css.load_from_string("
1239                         #file-list { font-size: 12px;}
1240                         #file-list indent {
1241                         -gtk-icon-size : 2px;
1242                         }
1243                         #file-list indent:nth-last-child(2)  {
1244                         min-width: 24px;
1245                         }
1246                         ");
1247                         
1248                                 Gtk.StyleContext.add_provider_for_display(
1249                                         this.el.get_display(),
1250                                         this.css,
1251                                         Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
1252                                 );
1253                                          
1254                         }
1255                 }
1256
1257                 // user defined functions
1258         }
1259         public class Xcls_GestureClick31 : Object
1260         {
1261                 public Gtk.GestureClick el;
1262                 private DialogFiles  _this;
1263
1264
1265                         // my vars (def)
1266
1267                 // ctor
1268                 public Xcls_GestureClick31(DialogFiles _owner )
1269                 {
1270                         _this = _owner;
1271                         this.el = new Gtk.GestureClick();
1272
1273                         // my vars (dec)
1274
1275                         // set gobject values
1276
1277                         //listeners
1278                         this.el.pressed.connect( (n_press, x, y) => {
1279                                 if (n_press == 2) {
1280                                         GLib.debug("double cliced");
1281                                 } else {
1282                                         return;
1283                                 }
1284                                 var tr = (Gtk.TreeListRow)_this.treeselmodel.el.selected_item;
1285                                 GLib.debug("SELECTED = %s", tr.item.get_type().name());
1286                                 var f = (JsRender.JsRender) tr.item;
1287                                 GLib.debug("Click %s", f.name);
1288                                 if (f.xtype == "Dir") {
1289                                         return;
1290                                 }
1291                                 
1292                                 
1293                                 _this.win.windowstate.fileViewOpen(f, _this.new_window);
1294                                 
1295                                 _this.el.hide();
1296                                 
1297                                 
1298                         
1299                         });
1300                 }
1301
1302                 // user defined functions
1303         }
1304
1305         public class Xcls_treeselmodel : Object
1306         {
1307                 public Gtk.SingleSelection el;
1308                 private DialogFiles  _this;
1309
1310
1311                         // my vars (def)
1312
1313                 // ctor
1314                 public Xcls_treeselmodel(DialogFiles _owner )
1315                 {
1316                         _this = _owner;
1317                         _this.treeselmodel = this;
1318                         var child_1 = new Xcls_FilterListModel33( _this );
1319                         child_1.ref();
1320                         this.el = new Gtk.SingleSelection( child_1.el );
1321
1322                         // my vars (dec)
1323
1324                         // set gobject values
1325                         this.el.can_unselect = true;
1326
1327                         //listeners
1328                         this.el.notify["selected"].connect( () => {
1329                                 if (this.el.selected == Gtk.INVALID_LIST_POSITION) {
1330                                         if (_this.iconsel.el.selected == Gtk.INVALID_LIST_POSITION) {
1331                                                 _this.btn_delfile.el.hide();
1332                                         }
1333                                         return;
1334                                 }
1335                                 
1336                                 var tr = (Gtk.TreeListRow)_this.treeselmodel.el.selected_item;
1337                                 GLib.debug("SELECTED = %s", tr.item.get_type().name());
1338                                 var f = (JsRender.JsRender) tr.item;
1339                                 if (f.xtype == "Dir") {
1340                                         _this.btn_delfile.el.hide();    
1341                                 } else {
1342                                         _this.btn_delfile.el.show();
1343                                 }
1344                         
1345                                 _this.iconsel.el.selected = Gtk.INVALID_LIST_POSITION;
1346                         
1347                         
1348                         });
1349                 }
1350
1351                 // user defined functions
1352                 public JsRender.JsRender? selectedFile () {
1353                 
1354                         if (this.el.selected == Gtk.INVALID_LIST_POSITION) {
1355                                 return null;
1356                         }
1357                         var tr = (Gtk.TreeListRow) this.el.selected_item;
1358                 
1359                         return  (JsRender.JsRender) tr.item;
1360                 }
1361         }
1362         public class Xcls_FilterListModel33 : Object
1363         {
1364                 public Gtk.FilterListModel el;
1365                 private DialogFiles  _this;
1366
1367
1368                         // my vars (def)
1369
1370                 // ctor
1371                 public Xcls_FilterListModel33(DialogFiles _owner )
1372                 {
1373                         _this = _owner;
1374                         new Xcls_treelistsort( _this );
1375                         new Xcls_treefilter( _this );
1376                         this.el = new Gtk.FilterListModel( _this.treelistsort.el, _this.treefilter.el );
1377
1378                         // my vars (dec)
1379
1380                         // set gobject values
1381                 }
1382
1383                 // user defined functions
1384         }
1385         public class Xcls_treelistsort : Object
1386         {
1387                 public Gtk.SortListModel el;
1388                 private DialogFiles  _this;
1389
1390
1391                         // my vars (def)
1392
1393                 // ctor
1394                 public Xcls_treelistsort(DialogFiles _owner )
1395                 {
1396                         _this = _owner;
1397                         _this.treelistsort = this;
1398                         new Xcls_treelistmodel( _this );
1399                         var child_2 = new Xcls_TreeListRowSorter37( _this );
1400                         child_2.ref();
1401                         this.el = new Gtk.SortListModel( _this.treelistmodel.el, child_2.el );
1402
1403                         // my vars (dec)
1404
1405                         // set gobject values
1406                         this.el.incremental = true;
1407                 }
1408
1409                 // user defined functions
1410         }
1411         public class Xcls_treelistmodel : Object
1412         {
1413                 public Gtk.TreeListModel el;
1414                 private DialogFiles  _this;
1415
1416
1417                         // my vars (def)
1418
1419                 // ctor
1420                 public Xcls_treelistmodel(DialogFiles _owner )
1421                 {
1422                         _this = _owner;
1423                         _this.treelistmodel = this;
1424                         new Xcls_treemodel( _this );
1425                         this.el = new Gtk.TreeListModel( _this.treemodel.el, false, true, (item) => {
1426         //GLib.debug("liststore got %s", item.get_type().name());
1427         return ((JsRender.JsRender)item).childfiles;
1428 }  );
1429
1430                         // my vars (dec)
1431
1432                         // set gobject values
1433                 }
1434
1435                 // user defined functions
1436         }
1437         public class Xcls_treemodel : Object
1438         {
1439                 public GLib.ListStore el;
1440                 private DialogFiles  _this;
1441
1442
1443                         // my vars (def)
1444
1445                 // ctor
1446                 public Xcls_treemodel(DialogFiles _owner )
1447                 {
1448                         _this = _owner;
1449                         _this.treemodel = this;
1450                         this.el = new GLib.ListStore( typeof(JsRender.JsRender) );
1451
1452                         // my vars (dec)
1453
1454                         // set gobject values
1455                 }
1456
1457                 // user defined functions
1458         }
1459
1460
1461         public class Xcls_TreeListRowSorter37 : Object
1462         {
1463                 public Gtk.TreeListRowSorter el;
1464                 private DialogFiles  _this;
1465
1466
1467                         // my vars (def)
1468
1469                 // ctor
1470                 public Xcls_TreeListRowSorter37(DialogFiles _owner )
1471                 {
1472                         _this = _owner;
1473                         var child_1 = new Xcls_StringSorter38( _this );
1474                         child_1.ref();
1475                         this.el = new Gtk.TreeListRowSorter( child_1.el );
1476
1477                         // my vars (dec)
1478
1479                         // set gobject values
1480                 }
1481
1482                 // user defined functions
1483         }
1484         public class Xcls_StringSorter38 : Object
1485         {
1486                 public Gtk.StringSorter el;
1487                 private DialogFiles  _this;
1488
1489
1490                         // my vars (def)
1491
1492                 // ctor
1493                 public Xcls_StringSorter38(DialogFiles _owner )
1494                 {
1495                         _this = _owner;
1496                         var child_1 = new Xcls_PropertyExpression39( _this );
1497                         child_1.ref();
1498                         this.el = new Gtk.StringSorter( child_1.el );
1499
1500                         // my vars (dec)
1501
1502                         // set gobject values
1503                         this.el.ignore_case = true;
1504                 }
1505
1506                 // user defined functions
1507         }
1508         public class Xcls_PropertyExpression39 : Object
1509         {
1510                 public Gtk.PropertyExpression el;
1511                 private DialogFiles  _this;
1512
1513
1514                         // my vars (def)
1515
1516                 // ctor
1517                 public Xcls_PropertyExpression39(DialogFiles _owner )
1518                 {
1519                         _this = _owner;
1520                         this.el = new Gtk.PropertyExpression( typeof(JsRender.JsRender) , null, "name" );
1521
1522                         // my vars (dec)
1523
1524                         // set gobject values
1525                 }
1526
1527                 // user defined functions
1528         }
1529
1530
1531
1532
1533         public class Xcls_treefilter : Object
1534         {
1535                 public Gtk.CustomFilter el;
1536                 private DialogFiles  _this;
1537
1538
1539                         // my vars (def)
1540
1541                 // ctor
1542                 public Xcls_treefilter(DialogFiles _owner )
1543                 {
1544                         _this = _owner;
1545                         _this.treefilter = this;
1546                         this.el = new Gtk.CustomFilter( (item) => { 
1547         var tr = ((Gtk.TreeListRow)item).get_item();
1548         //GLib.debug("filter %s", tr.get_type().name());
1549         var j =  (JsRender.JsRender) tr;
1550         if (j.xtype == "Dir" && j.childfiles.n_items < 1) {
1551                 return false;
1552         }
1553         var str = _this.searchbox.el.text.down();       
1554         if (j.xtype == "Dir") {
1555         
1556                 
1557                 for (var i =0 ; i < j.childfiles.n_items; i++) {
1558                         var f = (JsRender.JsRender) j.childfiles.get_item(i);
1559                         if (f.xtype != "PlainFile") {
1560                                 continue;
1561                         }
1562                         if (f.content_type.contains("image")) {
1563                                 continue;
1564                         }
1565                         if (str.length < 1) {
1566                                 return true;
1567                         }
1568                         if (f.name.down().contains(str)) {
1569                                 return true;
1570                         }
1571                         
1572                 }
1573                  
1574                 return false;
1575         }
1576         if (j.xtype != "PlainFile") {
1577                 return false;
1578         }
1579         if (j.content_type.contains("image")) {
1580                 return false;
1581         }
1582                          
1583         if (str.length < 1) { // no search.
1584                 return true;
1585         }
1586         if (j.name.down().contains(str)) {
1587                 return true;
1588         }
1589         return false; 
1590
1591 } );
1592
1593                         // my vars (dec)
1594
1595                         // set gobject values
1596                 }
1597
1598                 // user defined functions
1599         }
1600
1601
1602
1603         public class Xcls_name : Object
1604         {
1605                 public Gtk.ColumnViewColumn el;
1606                 private DialogFiles  _this;
1607
1608
1609                         // my vars (def)
1610
1611                 // ctor
1612                 public Xcls_name(DialogFiles _owner )
1613                 {
1614                         _this = _owner;
1615                         _this.name = this;
1616                         var child_1 = new Xcls_SignalListItemFactory42( _this );
1617                         child_1.ref();
1618                         this.el = new Gtk.ColumnViewColumn( "General Files", child_1.el );
1619
1620                         // my vars (dec)
1621
1622                         // set gobject values
1623                         this.el.id = "name";
1624                         this.el.expand = true;
1625                         this.el.resizable = true;
1626
1627                         // init method
1628
1629                         {
1630                                 // this.el.set_sorter(  new Gtk.StringSorter(
1631                                 //      new Gtk.PropertyExpression(typeof(JsRender.NodeProp), null, "name")
1632                          //     ));
1633                                         
1634                         }
1635                 }
1636
1637                 // user defined functions
1638         }
1639         public class Xcls_SignalListItemFactory42 : Object
1640         {
1641                 public Gtk.SignalListItemFactory el;
1642                 private DialogFiles  _this;
1643
1644
1645                         // my vars (def)
1646
1647                 // ctor
1648                 public Xcls_SignalListItemFactory42(DialogFiles _owner )
1649                 {
1650                         _this = _owner;
1651                         this.el = new Gtk.SignalListItemFactory();
1652
1653                         // my vars (dec)
1654
1655                         // set gobject values
1656
1657                         //listeners
1658                         this.el.setup.connect( (listitem) => {
1659                                 
1660                                 var expand = new Gtk.TreeExpander();
1661                                  
1662                                 expand.set_indent_for_depth(true);
1663                                 expand.set_indent_for_icon(true);
1664                                 var hbox = new Gtk.Box(Gtk.Orientation.HORIZONTAL,0);
1665                                 var icon = new Gtk.Image();
1666                                 icon.margin_end = 4;
1667                                 var lbl = new Gtk.Label("");
1668                                 lbl.use_markup = true;
1669                                 
1670                                 
1671                                 lbl.justify = Gtk.Justification.LEFT;
1672                                 lbl.xalign = 0;
1673                         
1674                                 hbox.append(icon);
1675                                 hbox.append(lbl);
1676                                 expand.set_child(hbox);
1677                                 ((Gtk.ListItem)listitem).set_child(expand);
1678                                 ((Gtk.ListItem)listitem).activatable = false;
1679                         });
1680                         this.el.bind.connect( (listitem) => {
1681                                 
1682                                  //GLib.debug("listitme is is %s", ((Gtk.ListItem)listitem).get_type().name());
1683                                                 
1684                                         
1685                                         
1686                                         //var expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child();
1687                                 var expand = (Gtk.TreeExpander)  ((Gtk.ListItem)listitem).get_child();
1688                                   
1689                                 var hbox = (Gtk.Box) expand.child;
1690                          
1691                                 
1692                                         var img = (Gtk.Image) hbox.get_first_child();
1693                                         var lbl = (Gtk.Label) img.get_next_sibling();
1694                         
1695                          
1696                                 
1697                                  if (lbl.label != "") { // do not update
1698                                         return;
1699                                 }
1700                                 var lr = (Gtk.TreeListRow)((Gtk.ListItem)listitem).get_item();
1701                                 //GLib.debug("LR = %s", lr.get_type().name());
1702                             
1703                                 
1704                                 var jr =(JsRender.JsRender) lr.get_item();
1705                                 //GLib.debug("JR = %s", jr.get_type().name());          
1706                                 
1707                                  if (jr == null) {
1708                                          GLib.debug("Problem getting item"); 
1709                                          return;
1710                                  }
1711                         
1712                                         jr.bind_property("icon",
1713                                         img, "gicon",
1714                                        GLib.BindingFlags.SYNC_CREATE);
1715                         
1716                                 //GLib.debug("change  %s to %s", lbl.label, np.name);
1717                                 lbl.label = jr.name; // for dir's we could hsow the sub path..
1718                                 lbl.tooltip_markup = jr.path;
1719                                  
1720                                 expand.set_hide_expander(  jr.xtype != "Dir" );
1721                                  expand.set_list_row(lr);
1722                              
1723                                          
1724                                                 // bind image...
1725                         });
1726                 }
1727
1728                 // user defined functions
1729         }
1730
1731
1732
1733
1734
1735         public class Xcls_EventControllerKey411 : Object
1736         {
1737                 public Gtk.EventControllerKey el;
1738                 private DialogFiles  _this;
1739
1740
1741                         // my vars (def)
1742
1743                 // ctor
1744                 public Xcls_EventControllerKey411(DialogFiles _owner )
1745                 {
1746                         _this = _owner;
1747                         this.el = new Gtk.EventControllerKey();
1748
1749                         // my vars (dec)
1750
1751                         // set gobject values
1752
1753                         //listeners
1754                         this.el.key_pressed.connect( (keyval, keycode, state) => {
1755                         
1756                                 if (keycode != Gdk.Key.Escape) {
1757                                         return true;
1758                                 }
1759                                 if (BuilderApplication.windows.size < 2 && 
1760                                         _this.win.windowstate.file == null
1761                                 ) { 
1762                                         BuilderApplication.singleton(null).quit();
1763                                         return true;
1764                                 }
1765                         
1766                                 _this.el.hide();
1767                                 
1768                                  if (_this.win.windowstate.file == null) {               
1769                                         BuilderApplication.removeWindow(_this.win);
1770                                             
1771                                 }
1772                         
1773                                 return true;
1774                         });
1775                 }
1776
1777                 // user defined functions
1778         }
1779
1780
1781
1782         public class Xcls_HeaderBar43 : Object
1783         {
1784                 public Gtk.HeaderBar el;
1785                 private DialogFiles  _this;
1786
1787
1788                         // my vars (def)
1789
1790                 // ctor
1791                 public Xcls_HeaderBar43(DialogFiles _owner )
1792                 {
1793                         _this = _owner;
1794                         this.el = new Gtk.HeaderBar();
1795
1796                         // my vars (dec)
1797
1798                         // set gobject values
1799                         this.el.show_title_buttons = false;
1800                         var child_1 = new Xcls_Button44( _this );
1801                         child_1.ref();
1802                         this.el.pack_end ( child_1.el  );
1803                         new Xcls_btn_newproj( _this );
1804                         this.el.pack_start ( _this.btn_newproj.el  );
1805                         new Xcls_btn_projprop( _this );
1806                         this.el.pack_start ( _this.btn_projprop.el  );
1807                         new Xcls_btn_delproj( _this );
1808                         this.el.pack_start ( _this.btn_delproj.el  );
1809                         new Xcls_btn_addfile( _this );
1810                         this.el.pack_start ( _this.btn_addfile.el  );
1811                         new Xcls_btn_delfile( _this );
1812                         this.el.pack_start ( _this.btn_delfile.el  );
1813                 }
1814
1815                 // user defined functions
1816         }
1817         public class Xcls_Button44 : Object
1818         {
1819                 public Gtk.Button el;
1820                 private DialogFiles  _this;
1821
1822
1823                         // my vars (def)
1824
1825                 // ctor
1826                 public Xcls_Button44(DialogFiles _owner )
1827                 {
1828                         _this = _owner;
1829                         this.el = new Gtk.Button();
1830
1831                         // my vars (dec)
1832
1833                         // set gobject values
1834                         this.el.label = "Close / Cancel";
1835
1836                         //listeners
1837                         this.el.clicked.connect( ( ) => {
1838                                 if (BuilderApplication.windows.size < 2 && 
1839                                         _this.win.windowstate.file == null
1840                                 ) { 
1841                                         BuilderApplication.singleton(null).quit();
1842                                         return;
1843                                 }
1844                         
1845                                 _this.el.hide();
1846                                 
1847                                  if (_this.win.windowstate.file == null) {               
1848                                         BuilderApplication.removeWindow(_this.win);
1849                                          
1850                                          
1851                                         
1852                                 }
1853                         
1854                         });
1855                 }
1856
1857                 // user defined functions
1858         }
1859
1860         public class Xcls_btn_newproj : Object
1861         {
1862                 public Gtk.Button el;
1863                 private DialogFiles  _this;
1864
1865
1866                         // my vars (def)
1867
1868                 // ctor
1869                 public Xcls_btn_newproj(DialogFiles _owner )
1870                 {
1871                         _this = _owner;
1872                         _this.btn_newproj = this;
1873                         this.el = new Gtk.Button();
1874
1875                         // my vars (dec)
1876
1877                         // set gobject values
1878                         var child_1 = new Xcls_Box46( _this );
1879                         this.el.child = child_1.el;
1880
1881                         //listeners
1882                         this.el.clicked.connect( ( ) => {
1883                           
1884                             // create a new file in project..
1885                             //Xcls_DialogNewComponent.singleton().show(
1886                            var  pe =      EditProject.singleton();
1887                            pe.windowstate = _this.win.windowstate;
1888                            
1889                            pe.el.application = _this.win.el.application;
1890                             pe.el.set_transient_for( _this.el );
1891                          
1892                             var cb = new Project.Callback();
1893                             cb.call.connect((pr) => {
1894                                 _this.show(  pr , _this.new_window);
1895                                 });
1896                               
1897                             pe.show( cb);
1898                            
1899                         
1900                         });
1901                 }
1902
1903                 // user defined functions
1904                 public void onCreated () {
1905                         var pe =      EditProject.singleton();
1906                 
1907                         _this.show(  pe.result , _this.new_window);
1908                 }
1909         }
1910         public class Xcls_Box46 : Object
1911         {
1912                 public Gtk.Box el;
1913                 private DialogFiles  _this;
1914
1915
1916                         // my vars (def)
1917
1918                 // ctor
1919                 public Xcls_Box46(DialogFiles _owner )
1920                 {
1921                         _this = _owner;
1922                         this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
1923
1924                         // my vars (dec)
1925
1926                         // set gobject values
1927                         var child_1 = new Xcls_Image47( _this );
1928                         child_1.ref();
1929                         this.el.append( child_1.el );
1930                         var child_2 = new Xcls_Label48( _this );
1931                         child_2.ref();
1932                         this.el.append( child_2.el );
1933                 }
1934
1935                 // user defined functions
1936         }
1937         public class Xcls_Image47 : Object
1938         {
1939                 public Gtk.Image el;
1940                 private DialogFiles  _this;
1941
1942
1943                         // my vars (def)
1944
1945                 // ctor
1946                 public Xcls_Image47(DialogFiles _owner )
1947                 {
1948                         _this = _owner;
1949                         this.el = new Gtk.Image();
1950
1951                         // my vars (dec)
1952
1953                         // set gobject values
1954                         this.el.icon_name = "folder-new";
1955                         this.el.margin_end = 4;
1956                         this.el.icon_size = Gtk.IconSize.NORMAL;
1957                 }
1958
1959                 // user defined functions
1960         }
1961
1962         public class Xcls_Label48 : Object
1963         {
1964                 public Gtk.Label el;
1965                 private DialogFiles  _this;
1966
1967
1968                         // my vars (def)
1969
1970                 // ctor
1971                 public Xcls_Label48(DialogFiles _owner )
1972                 {
1973                         _this = _owner;
1974                         this.el = new Gtk.Label( "New Project" );
1975
1976                         // my vars (dec)
1977
1978                         // set gobject values
1979                         this.el.halign = Gtk.Align.START;
1980                 }
1981
1982                 // user defined functions
1983         }
1984
1985
1986
1987         public class Xcls_btn_projprop : Object
1988         {
1989                 public Gtk.Button el;
1990                 private DialogFiles  _this;
1991
1992
1993                         // my vars (def)
1994
1995                 // ctor
1996                 public Xcls_btn_projprop(DialogFiles _owner )
1997                 {
1998                         _this = _owner;
1999                         _this.btn_projprop = this;
2000                         this.el = new Gtk.Button();
2001
2002                         // my vars (dec)
2003
2004                         // set gobject values
2005                         var child_1 = new Xcls_Box50( _this );
2006                         this.el.child = child_1.el;
2007
2008                         //listeners
2009                         this.el.clicked.connect( ( ) => {
2010                           // should disable the button really.
2011                            if (_this.selectedProject == null) {
2012                                    return;
2013                            }
2014                                 _this.win.windowstate.projectPopoverShow(_this.el, _this.selectedProject, null);
2015                          });
2016                 }
2017
2018                 // user defined functions
2019         }
2020         public class Xcls_Box50 : Object
2021         {
2022                 public Gtk.Box el;
2023                 private DialogFiles  _this;
2024
2025
2026                         // my vars (def)
2027
2028                 // ctor
2029                 public Xcls_Box50(DialogFiles _owner )
2030                 {
2031                         _this = _owner;
2032                         this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
2033
2034                         // my vars (dec)
2035
2036                         // set gobject values
2037                         var child_1 = new Xcls_Image51( _this );
2038                         child_1.ref();
2039                         this.el.append( child_1.el );
2040                         var child_2 = new Xcls_Label52( _this );
2041                         child_2.ref();
2042                         this.el.append( child_2.el );
2043                 }
2044
2045                 // user defined functions
2046         }
2047         public class Xcls_Image51 : Object
2048         {
2049                 public Gtk.Image el;
2050                 private DialogFiles  _this;
2051
2052
2053                         // my vars (def)
2054
2055                 // ctor
2056                 public Xcls_Image51(DialogFiles _owner )
2057                 {
2058                         _this = _owner;
2059                         this.el = new Gtk.Image();
2060
2061                         // my vars (dec)
2062
2063                         // set gobject values
2064                         this.el.icon_name = "emblem-system";
2065                         this.el.margin_end = 4;
2066                 }
2067
2068                 // user defined functions
2069         }
2070
2071         public class Xcls_Label52 : Object
2072         {
2073                 public Gtk.Label el;
2074                 private DialogFiles  _this;
2075
2076
2077                         // my vars (def)
2078
2079                 // ctor
2080                 public Xcls_Label52(DialogFiles _owner )
2081                 {
2082                         _this = _owner;
2083                         this.el = new Gtk.Label( "Project Properties" );
2084
2085                         // my vars (dec)
2086
2087                         // set gobject values
2088                 }
2089
2090                 // user defined functions
2091         }
2092
2093
2094
2095         public class Xcls_btn_delproj : Object
2096         {
2097                 public Gtk.Button el;
2098                 private DialogFiles  _this;
2099
2100
2101                         // my vars (def)
2102                 public DialogConfirm confirm;
2103
2104                 // ctor
2105                 public Xcls_btn_delproj(DialogFiles _owner )
2106                 {
2107                         _this = _owner;
2108                         _this.btn_delproj = this;
2109                         this.el = new Gtk.Button();
2110
2111                         // my vars (dec)
2112                         this.confirm = null;
2113
2114                         // set gobject values
2115                         var child_1 = new Xcls_Box54( _this );
2116                         this.el.child = child_1.el;
2117
2118                         //listeners
2119                         this.el.clicked.connect( ( ) => {
2120                           
2121                           
2122                                 if (this.confirm == null) {
2123                                         this.confirm = new DialogConfirm();
2124                                         this.confirm.el.set_transient_for(_this.el);
2125                                 }
2126                                 
2127                                 var project  = (Project.Project) _this.projectsort.el.get_item(
2128                                         _this.projectselection.el.selected
2129                                         );
2130                                 
2131                                 this.confirm.el.response.connect((res) => {
2132                                         this.confirm.el.hide();
2133                                         if (res == Gtk.ResponseType.CANCEL) {
2134                                                 return;
2135                                         }
2136                                    project  = (Project.Project) _this.projectsort.el.get_item(
2137                                                 _this.projectselection.el.selected
2138                                         );
2139                                         Project.Project.remove(project);
2140                                   _this.projectmodel.remove(project);
2141                                         _this.projectselection.el.selected = Gtk.INVALID_LIST_POSITION;
2142                                 
2143                                 });
2144                                 this.confirm.showIt("Confirm Delete Project", "Are you sure you want to delete this project?");
2145                         });
2146                 }
2147
2148                 // user defined functions
2149         }
2150         public class Xcls_Box54 : Object
2151         {
2152                 public Gtk.Box el;
2153                 private DialogFiles  _this;
2154
2155
2156                         // my vars (def)
2157
2158                 // ctor
2159                 public Xcls_Box54(DialogFiles _owner )
2160                 {
2161                         _this = _owner;
2162                         this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
2163
2164                         // my vars (dec)
2165
2166                         // set gobject values
2167                         var child_1 = new Xcls_Image55( _this );
2168                         child_1.ref();
2169                         this.el.append( child_1.el );
2170                         var child_2 = new Xcls_Label56( _this );
2171                         child_2.ref();
2172                         this.el.append( child_2.el );
2173                 }
2174
2175                 // user defined functions
2176         }
2177         public class Xcls_Image55 : Object
2178         {
2179                 public Gtk.Image el;
2180                 private DialogFiles  _this;
2181
2182
2183                         // my vars (def)
2184
2185                 // ctor
2186                 public Xcls_Image55(DialogFiles _owner )
2187                 {
2188                         _this = _owner;
2189                         this.el = new Gtk.Image();
2190
2191                         // my vars (dec)
2192
2193                         // set gobject values
2194                         this.el.icon_name = "user-trash";
2195                 }
2196
2197                 // user defined functions
2198         }
2199
2200         public class Xcls_Label56 : Object
2201         {
2202                 public Gtk.Label el;
2203                 private DialogFiles  _this;
2204
2205
2206                         // my vars (def)
2207
2208                 // ctor
2209                 public Xcls_Label56(DialogFiles _owner )
2210                 {
2211                         _this = _owner;
2212                         this.el = new Gtk.Label( "Delete Project" );
2213
2214                         // my vars (dec)
2215
2216                         // set gobject values
2217                 }
2218
2219                 // user defined functions
2220         }
2221
2222
2223
2224         public class Xcls_btn_addfile : Object
2225         {
2226                 public Gtk.Button el;
2227                 private DialogFiles  _this;
2228
2229
2230                         // my vars (def)
2231
2232                 // ctor
2233                 public Xcls_btn_addfile(DialogFiles _owner )
2234                 {
2235                         _this = _owner;
2236                         _this.btn_addfile = this;
2237                         this.el = new Gtk.Button();
2238
2239                         // my vars (dec)
2240
2241                         // set gobject values
2242                         var child_1 = new Xcls_Box58( _this );
2243                         this.el.child = child_1.el;
2244
2245                         //listeners
2246                         this.el.clicked.connect( () => {
2247                             // create a new file in project..
2248                             print("add file selected\n");
2249                             
2250                             if (_this.selectedProject == null) {
2251                                 return;
2252                             }
2253                             try {
2254                                 var f = JsRender.JsRender.factory(_this.selectedProject.xtype,  _this.selectedProject, "");
2255                                 _this.win.windowstate.file_details.show( f, _this.el, _this.new_window );
2256                              } catch (JsRender.Error e) {}
2257                         
2258                         });
2259                 }
2260
2261                 // user defined functions
2262         }
2263         public class Xcls_Box58 : Object
2264         {
2265                 public Gtk.Box el;
2266                 private DialogFiles  _this;
2267
2268
2269                         // my vars (def)
2270
2271                 // ctor
2272                 public Xcls_Box58(DialogFiles _owner )
2273                 {
2274                         _this = _owner;
2275                         this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
2276
2277                         // my vars (dec)
2278
2279                         // set gobject values
2280                         var child_1 = new Xcls_Image59( _this );
2281                         child_1.ref();
2282                         this.el.append( child_1.el );
2283                         var child_2 = new Xcls_Label60( _this );
2284                         child_2.ref();
2285                         this.el.append( child_2.el );
2286                 }
2287
2288                 // user defined functions
2289         }
2290         public class Xcls_Image59 : Object
2291         {
2292                 public Gtk.Image el;
2293                 private DialogFiles  _this;
2294
2295
2296                         // my vars (def)
2297
2298                 // ctor
2299                 public Xcls_Image59(DialogFiles _owner )
2300                 {
2301                         _this = _owner;
2302                         this.el = new Gtk.Image();
2303
2304                         // my vars (dec)
2305
2306                         // set gobject values
2307                         this.el.icon_name = "document-new";
2308                         this.el.margin_end = 4;
2309                 }
2310
2311                 // user defined functions
2312         }
2313
2314         public class Xcls_Label60 : Object
2315         {
2316                 public Gtk.Label el;
2317                 private DialogFiles  _this;
2318
2319
2320                         // my vars (def)
2321
2322                 // ctor
2323                 public Xcls_Label60(DialogFiles _owner )
2324                 {
2325                         _this = _owner;
2326                         this.el = new Gtk.Label( "New File" );
2327
2328                         // my vars (dec)
2329
2330                         // set gobject values
2331                 }
2332
2333                 // user defined functions
2334         }
2335
2336
2337
2338         public class Xcls_btn_delfile : Object
2339         {
2340                 public Gtk.Button el;
2341                 private DialogFiles  _this;
2342
2343
2344                         // my vars (def)
2345                 public DialogConfirm confirm;
2346
2347                 // ctor
2348                 public Xcls_btn_delfile(DialogFiles _owner )
2349                 {
2350                         _this = _owner;
2351                         _this.btn_delfile = this;
2352                         this.el = new Gtk.Button();
2353
2354                         // my vars (dec)
2355                         this.confirm = null;
2356
2357                         // set gobject values
2358                         var child_1 = new Xcls_Box62( _this );
2359                         this.el.child = child_1.el;
2360
2361                         //listeners
2362                         this.el.clicked.connect( ( ) => {
2363                           
2364                                 if (this.confirm == null) {
2365                                         this.confirm = new DialogConfirm();
2366                                         this.confirm.el.set_transient_for(_this.el);
2367                          
2368                                 }
2369                                 GLib.debug("DELETE");
2370                                 var is_icon = true;
2371                                 var isel = _this.iconsel.selectedFile();
2372                                  
2373                                 if (isel == null) {
2374                                         GLib.debug("DELETE - no icons selected");
2375                                         is_icon = false;
2376                                         isel = _this.treeselmodel.selectedFile();
2377                                 }
2378                                 if (isel == null) {
2379                                                 GLib.debug("DELETE - no tree item selected");
2380                                         return; // should nto happen..
2381                                 }
2382                                 
2383                                 GLib.debug("DELETE - calling confirm.");
2384                                 this.confirm.el.response.connect((res) => {
2385                                         this.confirm.el.hide();
2386                                         if (res == Gtk.ResponseType.CANCEL) {
2387                                                 return;
2388                                         }
2389                                         is_icon = true;
2390                                         isel = _this.iconsel.selectedFile();
2391                                         if (isel == null) {
2392                                                 is_icon = false;
2393                                                 isel = _this.treeselmodel.selectedFile();
2394                                         }
2395                                         if (isel == null) {
2396                                                 return; // should nto happen..
2397                                         }
2398                                         
2399                                         if (is_icon) {
2400                                                 isel.project.deleteFile(isel);
2401                                                 _this.gridmodel.remove(isel);
2402                                                 return;
2403                                         }
2404                                         isel.project.deleteFile(isel);                  
2405                                 
2406                                 });
2407                                         this.confirm.showIt("Confirm Delete File",
2408                                                 "Are you sure you want to delete this file?");
2409                                 
2410                          
2411                         
2412                         });
2413                 }
2414
2415                 // user defined functions
2416         }
2417         public class Xcls_Box62 : Object
2418         {
2419                 public Gtk.Box el;
2420                 private DialogFiles  _this;
2421
2422
2423                         // my vars (def)
2424
2425                 // ctor
2426                 public Xcls_Box62(DialogFiles _owner )
2427                 {
2428                         _this = _owner;
2429                         this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
2430
2431                         // my vars (dec)
2432
2433                         // set gobject values
2434                         var child_1 = new Xcls_Image63( _this );
2435                         child_1.ref();
2436                         this.el.append( child_1.el );
2437                         var child_2 = new Xcls_Label64( _this );
2438                         child_2.ref();
2439                         this.el.append( child_2.el );
2440                 }
2441
2442                 // user defined functions
2443         }
2444         public class Xcls_Image63 : Object
2445         {
2446                 public Gtk.Image el;
2447                 private DialogFiles  _this;
2448
2449
2450                         // my vars (def)
2451
2452                 // ctor
2453                 public Xcls_Image63(DialogFiles _owner )
2454                 {
2455                         _this = _owner;
2456                         this.el = new Gtk.Image();
2457
2458                         // my vars (dec)
2459
2460                         // set gobject values
2461                         this.el.icon_name = "user-trash";
2462                 }
2463
2464                 // user defined functions
2465         }
2466
2467         public class Xcls_Label64 : Object
2468         {
2469                 public Gtk.Label el;
2470                 private DialogFiles  _this;
2471
2472
2473                         // my vars (def)
2474
2475                 // ctor
2476                 public Xcls_Label64(DialogFiles _owner )
2477                 {
2478                         _this = _owner;
2479                         this.el = new Gtk.Label( "Delete File" );
2480
2481                         // my vars (dec)
2482
2483                         // set gobject values
2484                 }
2485
2486                 // user defined functions
2487         }
2488
2489
2490
2491
2492 }