1 static Xcls_PopoverFiles _PopoverFiles;
3 public class Xcls_PopoverFiles : Object
6 private Xcls_PopoverFiles _this;
8 public static Xcls_PopoverFiles singleton()
10 if (_PopoverFiles == null) {
11 _PopoverFiles= new Xcls_PopoverFiles();
15 public Xcls_view view;
16 public Xcls_model model;
17 public Xcls_namecol namecol;
18 public Xcls_iconscroll iconscroll;
19 public Xcls_iconview iconview;
20 public Xcls_iconmodel iconmodel;
21 public Xcls_file_container file_container;
22 public Xcls_fileview fileview;
23 public Xcls_filemodel filemodel;
24 public Xcls_filenamecol filenamecol;
27 public Xcls_MainWindow win;
28 public Project.Project selectedProject;
29 public bool is_loading;
30 public bool new_window;
31 public Gdk.Pixbuf missing_thumb_pixbuf;
33 public bool is_loaded;
36 public Xcls_PopoverFiles()
39 this.el = new Gtk.Popover( null );
42 this.is_loading = false;
43 this.new_window = false;
45 this.is_loaded = false;
48 this.el.width_request = 900;
49 this.el.height_request = 800;
50 this.el.hexpand = false;
52 this.el.position = Gtk.PositionType.TOP;
53 var child_0 = new Xcls_Box2( _this );
55 this.el.add ( child_0.el );
58 this.el.hide.connect( ( ) => {
61 //if (project != null) {
62 // this.selectProject(project);
64 if (_this.win.windowstate.project == null) {
70 // user defined functions
71 public void onProjectSelected (Project.Project project) {
72 this.selectedProject = project;
74 //this.clutterfiles.loadProject(proj);
81 //this.project_title_name.el.text = pr.name;
82 //this.project_title_path.el.text = pr.firstPath();
84 // file items contains a reference until we reload ...
85 Gdk.Pixbuf pixbuf = null;
86 Gdk.Pixbuf bigpixbuf = null;
88 var m = this.iconmodel.el;
91 var fiter = project.sortedFiles().list_iterator();
92 while (fiter.next()) {
94 var file = fiter.get();
95 m.set(iter, 0,file ); // zero contains the file reference
96 m.set(iter, 1,file.nickType() + "\n" + file.nickName()); // marked up title?
97 m.set(iter, 2,file.nickType() ); // file type?
100 var fname = file.getIconFileName(false);
102 if (FileUtils.test(fname, FileTest.EXISTS)) {
103 var npixbuf = new Gdk.Pixbuf.from_file(fname);
104 pixbuf = npixbuf.scale_simple(92, (int) (npixbuf.height * 92.0 /npixbuf.width * 1.0 )
105 , Gdk.InterpType.NEAREST) ;
106 bigpixbuf = npixbuf.scale_simple(368, (int) (npixbuf.height * 368.0 /npixbuf.width * 1.0 )
107 , Gdk.InterpType.NEAREST) ;
114 if (pixbuf == null) {
117 if (_this.missing_thumb_pixbuf == null) {
118 var icon_theme = Gtk.IconTheme.get_default ();
119 _this.missing_thumb_pixbuf = icon_theme.load_icon ("package-x-generic", 92, 0);
120 _this.missing_thumb_pixbuf.ref();
122 pixbuf = _this.missing_thumb_pixbuf;
123 bigpixbuf = _this.missing_thumb_pixbuf;
132 m.set(iter, 3,pixbuf);
133 m.set(iter, 4,bigpixbuf);
135 // this needs to add to the iconview?
137 //var a = new Xcls_fileitem(this,fiter.get());
138 //this.fileitems.add(a);
140 //this.filelayout.el.add_child(a.el);
144 this.filemodel.el.clear();
148 if (!(project is Project.Gtk)) {
149 print ("not gtk... skipping files");
150 this.file_container.el.hide();
153 this.file_container.el.show();
154 var gpr = (Project.Gtk)project;
155 var def = gpr.compilegroups.get("_default_");
156 // not sure why the above is returng null!??
158 def = new Project.GtkValaSettings("_default_");
159 gpr.compilegroups.set("_default_", def);
161 var items = def.sources;
163 Gtk.TreeIter citer; // folder iter
164 Gtk.TreeIter fxiter; // file iter
165 for(var i =0 ; i < items.size; i++) {
166 print ("cheking folder %s\n", items.get(i));
167 var files = gpr.filesForOpen(items.get(i));
168 if (files.size < 1) {
171 this.filemodel.el.append(out citer,null);
172 this.filemodel.el.set(citer, 0, GLib.Path.get_basename(items.get(i)));
173 this.filemodel.el.set(citer, 1, null); // parent (empty as it's a folder)
176 // add the directory... items.get(i);
177 //var x = new Xcls_folderitem(this,items.get(i));
178 //this.fileitems.add(x);
179 //this.filelayout.el.add_child(x.el);
182 for(var j =0 ; j < files.size; j++) {
184 this.filemodel.el.insert(out fxiter,citer, -1);
185 this.filemodel.el.set(fxiter, 0, GLib.Path.get_basename(files.get(j))); // filename
186 this.filemodel.el.set(fxiter, 1, files.get(j)); // Folder?
192 //this.el.set_value(citer, 1, items.get(i) );
194 _this.fileview.el.expand_all();
198 public void selectProject (Project.Project project) {
200 var sel = _this.view.el.get_selection();
205 _this.model.el.foreach((mod, path, iter) => {
208 mod.get_value(iter, 1, out val);
209 if ( ( (Project.Project)val.get_object()).fn != project.fn) {
210 print("SKIP %s != %s\n", ((Project.Project)val.get_object()).name , project.name);
211 return false;//continue
213 sel.select_iter(iter);
214 this.selectedProject = project;
215 this.onProjectSelected(project);
222 print("tried to select %s, could not find it", project.name);
225 public void show (Gtk.Widget on_el, Project.Project? project, bool new_window) {
226 //this.editor.show( file, node, ptype, key);
228 this.new_window = new_window;
231 if (project != null) {
232 this.selectProject(project);
237 this.win.el.get_size(out w, out h);
239 // left tree = 250, editor area = 500?
244 var ww = on_el.get_allocated_width();
246 // width = should be max = w-ww , or 600 at best..?
248 this.el.set_size_request( w, h); // same as parent...
251 this.el.set_modal(true);
252 this.el.set_relative_to(on_el);
254 //this.el.set_position(Gtk.PositionType.BOTTOM);
259 //while(Gtk.events_pending()) {
260 // Gtk.main_iteration(); // why?
264 public void load () {
267 if (_this.is_loaded) {
270 _this.is_loading = true;
272 _this.is_loaded = true;
274 Project.Project.loadAll();
275 var projects = Project.Project.allProjectsByName();
278 var m = this.model.el;
281 for (var i = 0; i < projects.size; i++) {
283 m.set(iter, 0,projects.get(i).name );
285 var o = GLib.Value(typeof(Object));
286 o.set_object((Object)projects.get(i));
288 m.set_value(iter, 1, o);
291 m.set_sort_column_id(0, Gtk.SortType.ASCENDING);
292 _this.is_loading = false;
294 public void setMainWindow (Xcls_MainWindow win) {
298 public class Xcls_Box2 : Object
301 private Xcls_PopoverFiles _this;
307 public Xcls_Box2(Xcls_PopoverFiles _owner )
310 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
314 // set gobject values
315 var child_0 = new Xcls_Box3( _this );
317 this.el.add ( child_0.el );
318 var child_1 = new Xcls_Box9( _this );
320 this.el.add ( child_1.el );
323 // user defined functions
325 public class Xcls_Box3 : Object
328 private Xcls_PopoverFiles _this;
334 public Xcls_Box3(Xcls_PopoverFiles _owner )
337 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
341 // set gobject values
342 var child_0 = new Xcls_Toolbar4( _this );
344 this.el.add ( child_0.el );
347 // user defined functions
349 public class Xcls_Toolbar4 : Object
351 public Gtk.Toolbar el;
352 private Xcls_PopoverFiles _this;
358 public Xcls_Toolbar4(Xcls_PopoverFiles _owner )
361 this.el = new Gtk.Toolbar();
365 // set gobject values
366 this.el.toolbar_style = Gtk.ToolbarStyle.BOTH;
367 var child_0 = new Xcls_ToolButton5( _this );
369 this.el.add ( child_0.el );
370 var child_1 = new Xcls_ToolButton6( _this );
372 this.el.add ( child_1.el );
373 var child_2 = new Xcls_ToolButton7( _this );
375 this.el.add ( child_2.el );
376 var child_3 = new Xcls_ToolButton8( _this );
378 this.el.add ( child_3.el );
381 // user defined functions
383 public class Xcls_ToolButton5 : Object
385 public Gtk.ToolButton el;
386 private Xcls_PopoverFiles _this;
392 public Xcls_ToolButton5(Xcls_PopoverFiles _owner )
395 this.el = new Gtk.ToolButton( null, "New Project" );
399 // set gobject values
400 this.el.icon_name = "folder-new";
403 this.el.clicked.connect( ( ) => {
405 // create a new file in project..
406 //Xcls_DialogNewComponent.singleton().show(
407 var pe = EditProject.singleton();
408 //pe.el.set_transient_for(_this.el);
409 pe.el.set_modal(true);
418 _this.win.windowstate.left_projects.is_loaded = false;
419 _this.win.windowstate.left_projects.load();
420 _this.win.windowstate.left_projects.selectProject(p);
427 // user defined functions
430 public class Xcls_ToolButton6 : Object
432 public Gtk.ToolButton el;
433 private Xcls_PopoverFiles _this;
439 public Xcls_ToolButton6(Xcls_PopoverFiles _owner )
442 this.el = new Gtk.ToolButton( null, "Project Properties" );
446 // set gobject values
447 this.el.icon_name = "emblem-system";
450 this.el.clicked.connect( ( ) => {
451 // should disable the button really.
452 if (_this.selectedProject == null) {
455 _this.win.windowstate.projectPopoverShow(this.el, _this.selectedProject);
459 // user defined functions
462 public class Xcls_ToolButton7 : Object
464 public Gtk.ToolButton el;
465 private Xcls_PopoverFiles _this;
471 public Xcls_ToolButton7(Xcls_PopoverFiles _owner )
474 this.el = new Gtk.ToolButton( null, "Delete Project" );
478 // set gobject values
479 this.el.icon_name = "user-trash";
482 this.el.clicked.connect( ( ) => {
484 var cd = DialogConfirm.singleton();
485 cd.el.set_transient_for(_this.el);
486 cd.el.set_modal(true);
488 var project = _this.windowstate.left_projects.getSelectedProject();
489 if (project == null) {
490 print("SKIP - no project\n");
495 if (Gtk.ResponseType.YES != cd.show("Confirm",
496 "Are you sure you want to delete project %s".printf(project.name))) {
502 Project.Project.remove(project);
503 _this.project = null;
505 _this.windowstate.left_projects.is_loaded = false;
506 _this.windowstate.left_projects.load();
507 _this.windowstate.clutterfiles.clearFiles();
513 // user defined functions
516 public class Xcls_ToolButton8 : Object
518 public Gtk.ToolButton el;
519 private Xcls_PopoverFiles _this;
525 public Xcls_ToolButton8(Xcls_PopoverFiles _owner )
528 this.el = new Gtk.ToolButton( null, "New File" );
532 // set gobject values
533 this.el.icon_name = "document-new";
536 this.el.clicked.connect( () => {
537 // create a new file in project..
538 print("add file selected\n");
540 if (_this.selectedProject == null) {
544 var f = JsRender.JsRender.factory(_this.selectedProject.xtype, _this.selectedProject, "");
545 _this.win.windowstate.file_details.show( f, this.el, _this.new_window );
550 // user defined functions
555 public class Xcls_Box9 : Object
558 private Xcls_PopoverFiles _this;
564 public Xcls_Box9(Xcls_PopoverFiles _owner )
567 this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
571 // set gobject values
572 this.el.homogeneous = false;
573 var child_0 = new Xcls_ScrolledWindow10( _this );
575 this.el.add ( child_0.el );
576 var child_1 = new Xcls_iconscroll( _this );
578 this.el.add ( child_1.el );
579 var child_2 = new Xcls_file_container( _this );
581 this.el.add ( child_2.el );
584 // user defined functions
586 public class Xcls_ScrolledWindow10 : Object
588 public Gtk.ScrolledWindow el;
589 private Xcls_PopoverFiles _this;
595 public Xcls_ScrolledWindow10(Xcls_PopoverFiles _owner )
598 this.el = new Gtk.ScrolledWindow( null, null );
602 // set gobject values
603 this.el.width_request = 150;
604 this.el.expand = true;
605 this.el.shadow_type = Gtk.ShadowType.IN;
606 var child_0 = new Xcls_view( _this );
608 this.el.add ( child_0.el );
612 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
615 // user defined functions
617 public class Xcls_view : Object
619 public Gtk.TreeView el;
620 private Xcls_PopoverFiles _this;
626 public Xcls_view(Xcls_PopoverFiles _owner )
630 this.el = new Gtk.TreeView();
634 // set gobject values
635 this.el.enable_tree_lines = true;
636 this.el.headers_visible = true;
637 var child_0 = new Xcls_model( _this );
639 this.el.set_model ( child_0.el );
640 var child_1 = new Xcls_TreeViewColumn13( _this );
642 this.el.append_column ( child_1.el );
646 var description = new Pango.FontDescription();
647 description.set_size(9000);
648 this.el.override_font(description);
650 var selection = this.el.get_selection();
651 selection.set_mode( Gtk.SelectionMode.SINGLE);
654 this.el.cursor_changed.connect( () => {
655 if (_this.is_loading) {
662 var s = this.el.get_selection();
663 if (!s.get_selected(out mod, out iter)) {
669 mod.get_value(iter, 1 , out gval);
670 var project = (Project.Project)gval.get_object();
672 _this.onProjectSelected(project);
677 // user defined functions
679 public class Xcls_model : Object
681 public Gtk.ListStore el;
682 private Xcls_PopoverFiles _this;
688 public Xcls_model(Xcls_PopoverFiles _owner )
692 this.el = new Gtk.ListStore.newv( { typeof(string), typeof(Object) } );
696 // set gobject values
701 this.el.set_sort_func(0, (mod,a,b) => {
703 mod.get_value(a,0, out ga);
704 mod.get_value(b,0, out gb);
706 if ((string)ga == (string)gb) {
709 return (string)ga > (string)gb ? 1 : -1;
716 // user defined functions
719 public class Xcls_TreeViewColumn13 : Object
721 public Gtk.TreeViewColumn el;
722 private Xcls_PopoverFiles _this;
728 public Xcls_TreeViewColumn13(Xcls_PopoverFiles _owner )
731 this.el = new Gtk.TreeViewColumn();
735 // set gobject values
736 this.el.title = "Projects";
737 var child_0 = new Xcls_namecol( _this );
739 this.el.pack_start ( child_0.el , true );
743 this.el.add_attribute(_this.namecol.el , "markup", 0 );
746 // user defined functions
748 public class Xcls_namecol : Object
750 public Gtk.CellRendererText el;
751 private Xcls_PopoverFiles _this;
757 public Xcls_namecol(Xcls_PopoverFiles _owner )
760 _this.namecol = this;
761 this.el = new Gtk.CellRendererText();
765 // set gobject values
768 // user defined functions
774 public class Xcls_iconscroll : Object
776 public Gtk.ScrolledWindow el;
777 private Xcls_PopoverFiles _this;
783 public Xcls_iconscroll(Xcls_PopoverFiles _owner )
786 _this.iconscroll = this;
787 this.el = new Gtk.ScrolledWindow( null, null );
791 // set gobject values
792 this.el.width_request = 600;
793 this.el.expand = true;
794 this.el.shadow_type = Gtk.ShadowType.IN;
795 var child_0 = new Xcls_iconview( _this );
797 this.el.add ( child_0.el );
801 this.el.set_policy (Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC);
804 // user defined functions
806 public class Xcls_iconview : Object
808 public Gtk.IconView el;
809 private Xcls_PopoverFiles _this;
815 public Xcls_iconview(Xcls_PopoverFiles _owner )
818 _this.iconview = this;
819 this.el = new Gtk.IconView();
823 // set gobject values
824 this.el.markup_column = 1;
825 this.el.pixbuf_column = 3;
826 this.el.has_tooltip = true;
827 this.el.item_width = 100;
828 var child_0 = new Xcls_iconmodel( _this );
830 this.el.model = child_0.el;
839 this.el.item_activated.connect( (path) => {
841 _this.win.windowstate.project = _this.selectedProject;
848 this.el.model.get_iter(out iter, path);
852 this.el.model.get_value(iter, 0 , out gval);
853 var file = (JsRender.JsRender)gval;
856 _this.win.windowstate.fileViewOpen(file, _this.new_window);
861 this.el.query_tooltip.connect( (x, y, keyboard_tooltip, tooltip) => {
864 Gtk.CellRenderer cell;
865 var s = _this.iconview.el.get_item_at_pos(x,y + (int) _this.iconscroll.el.vadjustment.value, out path, out cell);
868 // GLib.debug("Tooltip? %d,%d scroll: %d",x,y, (int)_this.iconscroll.el.vadjustment.value);
872 // GLib.debug("Tooltip? - no path");
877 _this.iconmodel.el.get_iter(out iter, path);
879 _this.iconmodel.el.get_value(iter, 4, out val);
881 tooltip.set_icon((Gdk.Pixbuf) val.get_object());
882 _this.iconview.el.set_tooltip_item(tooltip, path);
887 // user defined functions
889 public class Xcls_iconmodel : Object
891 public Gtk.ListStore el;
892 private Xcls_PopoverFiles _this;
898 public Xcls_iconmodel(Xcls_PopoverFiles _owner )
901 _this.iconmodel = this;
902 this.el = new Gtk.ListStore.newv( { typeof(Object), typeof(string), typeof(string), typeof(Gdk.Pixbuf), typeof(Gdk.Pixbuf) } );
906 // set gobject values
909 // user defined functions
914 public class Xcls_file_container : Object
916 public Gtk.ScrolledWindow el;
917 private Xcls_PopoverFiles _this;
923 public Xcls_file_container(Xcls_PopoverFiles _owner )
926 _this.file_container = this;
927 this.el = new Gtk.ScrolledWindow( null, null );
931 // set gobject values
932 this.el.width_request = 100;
933 this.el.expand = true;
934 this.el.shadow_type = Gtk.ShadowType.IN;
935 this.el.visible = false;
936 var child_0 = new Xcls_fileview( _this );
938 this.el.add ( child_0.el );
942 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
945 // user defined functions
947 public class Xcls_fileview : Object
949 public Gtk.TreeView el;
950 private Xcls_PopoverFiles _this;
956 public Xcls_fileview(Xcls_PopoverFiles _owner )
959 _this.fileview = this;
960 this.el = new Gtk.TreeView();
964 // set gobject values
965 this.el.activate_on_single_click = false;
966 this.el.expand = true;
967 this.el.enable_tree_lines = true;
968 this.el.headers_visible = true;
969 var child_0 = new Xcls_filemodel( _this );
971 this.el.set_model ( child_0.el );
972 var child_1 = new Xcls_TreeViewColumn21( _this );
974 this.el.append_column ( child_1.el );
978 var description = new Pango.FontDescription();
979 description.set_size(9000);
980 this.el.override_font(description);
982 var selection = this.el.get_selection();
983 selection.set_mode( Gtk.SelectionMode.SINGLE);
986 this.el.row_activated.connect( (path, col) => {
991 this.el.model.get_iter(out iter, path);
995 this.el.model.get_value(iter, 1 , out gval);
996 var fn = (string)gval;
1000 _this.win.windowstate.project = _this.selectedProject;
1003 var f = JsRender.JsRender.factory("PlainFile", _this.selectedProject, fn);
1006 _this.win.windowstate.fileViewOpen(f, _this.new_window);
1010 this.el.cursor_changed.connect( () => {
1012 if (_this.is_loading) {
1019 var s = this.el.get_selection();
1020 if (!s.get_selected(out mod, out iter)) {
1026 mod.get_value(iter, 1 , out gval);
1027 var project = (Project.Project)gval.get_object();
1029 _this.project_selected(project);
1034 // user defined functions
1036 public class Xcls_filemodel : Object
1038 public Gtk.TreeStore el;
1039 private Xcls_PopoverFiles _this;
1045 public Xcls_filemodel(Xcls_PopoverFiles _owner )
1048 _this.filemodel = this;
1049 this.el = new Gtk.TreeStore.newv( { typeof(string), typeof(string) } );
1053 // set gobject values
1058 this.el.set_sort_func(0, (mod,a,b) => {
1060 mod.get_value(a,0, out ga);
1061 mod.get_value(b,0, out gb);
1063 if ((string)ga == (string)gb) {
1066 return (string)ga > (string)gb ? 1 : -1;
1073 // user defined functions
1076 public class Xcls_TreeViewColumn21 : Object
1078 public Gtk.TreeViewColumn el;
1079 private Xcls_PopoverFiles _this;
1085 public Xcls_TreeViewColumn21(Xcls_PopoverFiles _owner )
1088 this.el = new Gtk.TreeViewColumn();
1092 // set gobject values
1093 this.el.title = "File";
1094 var child_0 = new Xcls_filenamecol( _this );
1096 this.el.pack_start ( child_0.el , true );
1100 this.el.add_attribute(_this.filenamecol.el , "markup", 0 );
1103 // user defined functions
1105 public class Xcls_filenamecol : Object
1107 public Gtk.CellRendererText el;
1108 private Xcls_PopoverFiles _this;
1114 public Xcls_filenamecol(Xcls_PopoverFiles _owner )
1117 _this.filenamecol = this;
1118 this.el = new Gtk.CellRendererText();
1122 // set gobject values
1125 // user defined functions