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)
73 this.selectedProject = project;
75 //this.clutterfiles.loadProject(proj);
82 //this.project_title_name.el.text = pr.name;
83 //this.project_title_path.el.text = pr.firstPath();
85 // file items contains a reference until we reload ...
86 Gdk.Pixbuf pixbuf = null;
87 Gdk.Pixbuf bigpixbuf = null;
89 var m = this.iconmodel.el;
92 var fiter = project.sortedFiles().list_iterator();
93 while (fiter.next()) {
95 var file = fiter.get();
96 m.set(iter, 0,file ); // zero contains the file reference
97 m.set(iter, 1,file.nickType() + "\n" + file.nickName()); // marked up title?
98 m.set(iter, 2,file.nickType() ); // file type?
101 var fname = file.getIconFileName(false);
103 if (FileUtils.test(fname, FileTest.EXISTS)) {
104 var npixbuf = new Gdk.Pixbuf.from_file(fname);
105 pixbuf = npixbuf.scale_simple(92, (int) (npixbuf.height * 92.0 /npixbuf.width * 1.0 )
106 , Gdk.InterpType.NEAREST) ;
107 bigpixbuf = npixbuf.scale_simple(368, (int) (npixbuf.height * 368.0 /npixbuf.width * 1.0 )
108 , Gdk.InterpType.NEAREST) ;
115 if (pixbuf == null) {
118 if (_this.missing_thumb_pixbuf == null) {
119 var icon_theme = Gtk.IconTheme.get_default ();
120 _this.missing_thumb_pixbuf = icon_theme.load_icon ("package-x-generic", 92, 0);
121 _this.missing_thumb_pixbuf.ref();
123 pixbuf = _this.missing_thumb_pixbuf;
124 bigpixbuf = _this.missing_thumb_pixbuf;
133 m.set(iter, 3,pixbuf);
134 m.set(iter, 4,bigpixbuf);
136 // this needs to add to the iconview?
138 //var a = new Xcls_fileitem(this,fiter.get());
139 //this.fileitems.add(a);
141 //this.filelayout.el.add_child(a.el);
145 this.filemodel.el.clear();
149 if (!(project is Project.Gtk)) {
150 print ("not gtk... skipping files");
151 this.file_container.el.hide();
154 this.file_container.el.show();
155 var gpr = (Project.Gtk)project;
156 var def = gpr.compilegroups.get("_default_");
157 // not sure why the above is returng null!??
159 def = new Project.GtkValaSettings("_default_");
160 gpr.compilegroups.set("_default_", def);
162 var items = def.sources;
164 Gtk.TreeIter citer; // folder iter
165 Gtk.TreeIter fxiter; // file iter
166 for(var i =0 ; i < items.size; i++) {
167 print ("cheking folder %s\n", items.get(i));
168 var files = gpr.filesForOpen(items.get(i));
169 if (files.size < 1) {
172 this.filemodel.el.append(out citer,null);
173 this.filemodel.el.set(citer, 0, GLib.Path.get_basename(items.get(i)));
174 this.filemodel.el.set(citer, 1, null); // parent (empty as it's a folder)
177 // add the directory... items.get(i);
178 //var x = new Xcls_folderitem(this,items.get(i));
179 //this.fileitems.add(x);
180 //this.filelayout.el.add_child(x.el);
183 for(var j =0 ; j < files.size; j++) {
185 this.filemodel.el.insert(out fxiter,citer, -1);
186 this.filemodel.el.set(fxiter, 0, GLib.Path.get_basename(files.get(j))); // filename
187 this.filemodel.el.set(fxiter, 1, files.get(j)); // Folder?
193 //this.el.set_value(citer, 1, items.get(i) );
195 _this.fileview.el.expand_all();
199 public void selectProject (Project.Project project) {
201 var sel = _this.view.el.get_selection();
206 _this.model.el.foreach((mod, path, iter) => {
209 mod.get_value(iter, 1, out val);
210 if ( ( (Project.Project)val.get_object()).fn != project.fn) {
211 print("SKIP %s != %s\n", ((Project.Project)val.get_object()).name , project.name);
212 return false;//continue
214 sel.select_iter(iter);
215 this.selectedProject = project;
216 this.onProjectSelected(project);
223 print("tried to select %s, could not find it", project.name);
226 public void show (Gtk.Widget on_el, Project.Project? project, bool new_window) {
227 //this.editor.show( file, node, ptype, key);
229 this.new_window = new_window;
232 this.el.show_all(); // show first - so we can hide stuff later.
233 if (project != null) {
235 this.selectProject(project);
240 this.win.el.get_size(out w, out h);
242 // left tree = 250, editor area = 500?
247 var ww = on_el.get_allocated_width();
249 // width = should be max = w-ww , or 600 at best..?
251 this.el.set_size_request( w, h); // same as parent...
254 this.el.set_modal(true);
255 this.el.set_relative_to(on_el);
260 public void load () {
263 if (_this.is_loaded) {
266 _this.is_loading = true;
268 _this.is_loaded = true;
270 Project.Project.loadAll();
271 var projects = Project.Project.allProjectsByName();
274 var m = this.model.el;
277 for (var i = 0; i < projects.size; i++) {
279 m.set(iter, 0,projects.get(i).name );
281 var o = GLib.Value(typeof(Object));
282 o.set_object((Object)projects.get(i));
284 m.set_value(iter, 1, o);
287 m.set_sort_column_id(0, Gtk.SortType.ASCENDING);
288 _this.is_loading = false;
290 public void setMainWindow (Xcls_MainWindow win) {
294 public class Xcls_Box2 : Object
297 private Xcls_PopoverFiles _this;
303 public Xcls_Box2(Xcls_PopoverFiles _owner )
306 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
310 // set gobject values
311 var child_0 = new Xcls_Box3( _this );
313 this.el.add ( child_0.el );
314 var child_1 = new Xcls_Box9( _this );
316 this.el.add ( child_1.el );
319 // user defined functions
321 public class Xcls_Box3 : Object
324 private Xcls_PopoverFiles _this;
330 public Xcls_Box3(Xcls_PopoverFiles _owner )
333 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
337 // set gobject values
338 var child_0 = new Xcls_Toolbar4( _this );
340 this.el.add ( child_0.el );
343 // user defined functions
345 public class Xcls_Toolbar4 : Object
347 public Gtk.Toolbar el;
348 private Xcls_PopoverFiles _this;
354 public Xcls_Toolbar4(Xcls_PopoverFiles _owner )
357 this.el = new Gtk.Toolbar();
361 // set gobject values
362 this.el.toolbar_style = Gtk.ToolbarStyle.BOTH;
363 var child_0 = new Xcls_ToolButton5( _this );
365 this.el.add ( child_0.el );
366 var child_1 = new Xcls_ToolButton6( _this );
368 this.el.add ( child_1.el );
369 var child_2 = new Xcls_ToolButton7( _this );
371 this.el.add ( child_2.el );
372 var child_3 = new Xcls_ToolButton8( _this );
374 this.el.add ( child_3.el );
377 // user defined functions
379 public class Xcls_ToolButton5 : Object
381 public Gtk.ToolButton el;
382 private Xcls_PopoverFiles _this;
388 public Xcls_ToolButton5(Xcls_PopoverFiles _owner )
391 this.el = new Gtk.ToolButton( null, "New Project" );
395 // set gobject values
396 this.el.icon_name = "folder-new";
399 this.el.clicked.connect( ( ) => {
401 // create a new file in project..
402 //Xcls_DialogNewComponent.singleton().show(
403 var pe = EditProject.singleton();
404 //pe.el.set_transient_for(_this.el);
405 pe.el.set_modal(true);
414 _this.win.windowstate.left_projects.is_loaded = false;
415 _this.win.windowstate.left_projects.load();
416 _this.win.windowstate.left_projects.selectProject(p);
423 // user defined functions
426 public class Xcls_ToolButton6 : Object
428 public Gtk.ToolButton el;
429 private Xcls_PopoverFiles _this;
435 public Xcls_ToolButton6(Xcls_PopoverFiles _owner )
438 this.el = new Gtk.ToolButton( null, "Project Properties" );
442 // set gobject values
443 this.el.icon_name = "emblem-system";
446 this.el.clicked.connect( ( ) => {
447 // should disable the button really.
448 if (_this.selectedProject == null) {
451 _this.win.windowstate.projectPopoverShow(this.el, _this.selectedProject);
455 // user defined functions
458 public class Xcls_ToolButton7 : Object
460 public Gtk.ToolButton el;
461 private Xcls_PopoverFiles _this;
467 public Xcls_ToolButton7(Xcls_PopoverFiles _owner )
470 this.el = new Gtk.ToolButton( null, "Delete Project" );
474 // set gobject values
475 this.el.icon_name = "user-trash";
478 this.el.clicked.connect( ( ) => {
480 var cd = DialogConfirm.singleton();
481 cd.el.set_transient_for(_this.el);
482 cd.el.set_modal(true);
484 var project = _this.windowstate.left_projects.getSelectedProject();
485 if (project == null) {
486 print("SKIP - no project\n");
491 if (Gtk.ResponseType.YES != cd.show("Confirm",
492 "Are you sure you want to delete project %s".printf(project.name))) {
498 Project.Project.remove(project);
499 _this.project = null;
501 _this.windowstate.left_projects.is_loaded = false;
502 _this.windowstate.left_projects.load();
503 _this.windowstate.clutterfiles.clearFiles();
509 // user defined functions
512 public class Xcls_ToolButton8 : Object
514 public Gtk.ToolButton el;
515 private Xcls_PopoverFiles _this;
521 public Xcls_ToolButton8(Xcls_PopoverFiles _owner )
524 this.el = new Gtk.ToolButton( null, "New File" );
528 // set gobject values
529 this.el.icon_name = "document-new";
532 this.el.clicked.connect( () => {
533 // create a new file in project..
534 print("add file selected\n");
536 if (_this.selectedProject == null) {
540 var f = JsRender.JsRender.factory(_this.selectedProject.xtype, _this.selectedProject, "");
541 _this.win.windowstate.file_details.show( f, this.el, _this.new_window );
547 // user defined functions
552 public class Xcls_Box9 : Object
555 private Xcls_PopoverFiles _this;
561 public Xcls_Box9(Xcls_PopoverFiles _owner )
564 this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
568 // set gobject values
569 this.el.homogeneous = false;
570 var child_0 = new Xcls_ScrolledWindow10( _this );
572 this.el.add ( child_0.el );
573 var child_1 = new Xcls_iconscroll( _this );
575 this.el.add ( child_1.el );
576 var child_2 = new Xcls_file_container( _this );
578 this.el.add ( child_2.el );
581 // user defined functions
583 public class Xcls_ScrolledWindow10 : Object
585 public Gtk.ScrolledWindow el;
586 private Xcls_PopoverFiles _this;
592 public Xcls_ScrolledWindow10(Xcls_PopoverFiles _owner )
595 this.el = new Gtk.ScrolledWindow( null, null );
599 // set gobject values
600 this.el.width_request = 150;
601 this.el.expand = true;
602 this.el.shadow_type = Gtk.ShadowType.IN;
603 var child_0 = new Xcls_view( _this );
605 this.el.add ( child_0.el );
609 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
612 // user defined functions
614 public class Xcls_view : Object
616 public Gtk.TreeView el;
617 private Xcls_PopoverFiles _this;
623 public Xcls_view(Xcls_PopoverFiles _owner )
627 this.el = new Gtk.TreeView();
631 // set gobject values
632 this.el.enable_tree_lines = true;
633 this.el.headers_visible = true;
634 var child_0 = new Xcls_model( _this );
636 this.el.set_model ( child_0.el );
637 var child_1 = new Xcls_TreeViewColumn13( _this );
639 this.el.append_column ( child_1.el );
643 var description = new Pango.FontDescription();
644 description.set_size(9000);
645 this.el.override_font(description);
647 var selection = this.el.get_selection();
648 selection.set_mode( Gtk.SelectionMode.SINGLE);
651 this.el.cursor_changed.connect( () => {
652 if (_this.is_loading) {
659 var s = this.el.get_selection();
660 if (!s.get_selected(out mod, out iter)) {
666 mod.get_value(iter, 1 , out gval);
667 var project = (Project.Project)gval.get_object();
669 _this.onProjectSelected(project);
674 // user defined functions
676 public class Xcls_model : Object
678 public Gtk.ListStore el;
679 private Xcls_PopoverFiles _this;
685 public Xcls_model(Xcls_PopoverFiles _owner )
689 this.el = new Gtk.ListStore.newv( { typeof(string), typeof(Object) } );
693 // set gobject values
698 this.el.set_sort_func(0, (mod,a,b) => {
700 mod.get_value(a,0, out ga);
701 mod.get_value(b,0, out gb);
703 if ((string)ga == (string)gb) {
706 return (string)ga > (string)gb ? 1 : -1;
713 // user defined functions
716 public class Xcls_TreeViewColumn13 : Object
718 public Gtk.TreeViewColumn el;
719 private Xcls_PopoverFiles _this;
725 public Xcls_TreeViewColumn13(Xcls_PopoverFiles _owner )
728 this.el = new Gtk.TreeViewColumn();
732 // set gobject values
733 this.el.title = "Projects";
734 var child_0 = new Xcls_namecol( _this );
736 this.el.pack_start ( child_0.el , true );
740 this.el.add_attribute(_this.namecol.el , "markup", 0 );
743 // user defined functions
745 public class Xcls_namecol : Object
747 public Gtk.CellRendererText el;
748 private Xcls_PopoverFiles _this;
754 public Xcls_namecol(Xcls_PopoverFiles _owner )
757 _this.namecol = this;
758 this.el = new Gtk.CellRendererText();
762 // set gobject values
765 // user defined functions
771 public class Xcls_iconscroll : Object
773 public Gtk.ScrolledWindow el;
774 private Xcls_PopoverFiles _this;
780 public Xcls_iconscroll(Xcls_PopoverFiles _owner )
783 _this.iconscroll = this;
784 this.el = new Gtk.ScrolledWindow( null, null );
788 // set gobject values
789 this.el.width_request = 600;
790 this.el.expand = true;
791 this.el.shadow_type = Gtk.ShadowType.IN;
792 var child_0 = new Xcls_iconview( _this );
794 this.el.add ( child_0.el );
798 this.el.set_policy (Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC);
801 // user defined functions
803 public class Xcls_iconview : Object
805 public Gtk.IconView el;
806 private Xcls_PopoverFiles _this;
812 public Xcls_iconview(Xcls_PopoverFiles _owner )
815 _this.iconview = this;
816 this.el = new Gtk.IconView();
820 // set gobject values
821 this.el.markup_column = 1;
822 this.el.pixbuf_column = 3;
823 this.el.has_tooltip = true;
824 this.el.item_width = 100;
825 var child_0 = new Xcls_iconmodel( _this );
827 this.el.model = child_0.el;
836 this.el.item_activated.connect( (path) => {
838 _this.win.windowstate.project = _this.selectedProject;
845 this.el.model.get_iter(out iter, path);
849 this.el.model.get_value(iter, 0 , out gval);
850 var file = (JsRender.JsRender)gval;
853 _this.win.windowstate.fileViewOpen(file, _this.new_window);
858 this.el.query_tooltip.connect( (x, y, keyboard_tooltip, tooltip) => {
861 Gtk.CellRenderer cell;
862 var s = _this.iconview.el.get_item_at_pos(x,y + (int) _this.iconscroll.el.vadjustment.value, out path, out cell);
865 // GLib.debug("Tooltip? %d,%d scroll: %d",x,y, (int)_this.iconscroll.el.vadjustment.value);
869 // GLib.debug("Tooltip? - no path");
874 _this.iconmodel.el.get_iter(out iter, path);
876 _this.iconmodel.el.get_value(iter, 4, out val);
878 tooltip.set_icon((Gdk.Pixbuf) val.get_object());
879 _this.iconview.el.set_tooltip_item(tooltip, path);
884 // user defined functions
886 public class Xcls_iconmodel : Object
888 public Gtk.ListStore el;
889 private Xcls_PopoverFiles _this;
895 public Xcls_iconmodel(Xcls_PopoverFiles _owner )
898 _this.iconmodel = this;
899 this.el = new Gtk.ListStore.newv( { typeof(Object), typeof(string), typeof(string), typeof(Gdk.Pixbuf), typeof(Gdk.Pixbuf) } );
903 // set gobject values
906 // user defined functions
911 public class Xcls_file_container : Object
913 public Gtk.ScrolledWindow el;
914 private Xcls_PopoverFiles _this;
920 public Xcls_file_container(Xcls_PopoverFiles _owner )
923 _this.file_container = this;
924 this.el = new Gtk.ScrolledWindow( null, null );
928 // set gobject values
929 this.el.width_request = 100;
930 this.el.expand = true;
931 this.el.shadow_type = Gtk.ShadowType.IN;
932 this.el.visible = false;
933 var child_0 = new Xcls_fileview( _this );
935 this.el.add ( child_0.el );
939 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
942 // user defined functions
944 public class Xcls_fileview : Object
946 public Gtk.TreeView el;
947 private Xcls_PopoverFiles _this;
953 public Xcls_fileview(Xcls_PopoverFiles _owner )
956 _this.fileview = this;
957 this.el = new Gtk.TreeView();
961 // set gobject values
962 this.el.activate_on_single_click = false;
963 this.el.expand = true;
964 this.el.enable_tree_lines = true;
965 this.el.headers_visible = true;
966 var child_0 = new Xcls_filemodel( _this );
968 this.el.set_model ( child_0.el );
969 var child_1 = new Xcls_TreeViewColumn21( _this );
971 this.el.append_column ( child_1.el );
975 var description = new Pango.FontDescription();
976 description.set_size(9000);
977 this.el.override_font(description);
979 var selection = this.el.get_selection();
980 selection.set_mode( Gtk.SelectionMode.SINGLE);
983 this.el.row_activated.connect( (path, col) => {
988 this.el.model.get_iter(out iter, path);
992 this.el.model.get_value(iter, 1 , out gval);
993 var fn = (string)gval;
997 _this.win.windowstate.project = _this.selectedProject;
1000 var f = JsRender.JsRender.factory("PlainFile", _this.selectedProject, fn);
1003 _this.win.windowstate.fileViewOpen(f, _this.new_window);
1007 this.el.cursor_changed.connect( () => {
1009 if (_this.is_loading) {
1016 var s = this.el.get_selection();
1017 if (!s.get_selected(out mod, out iter)) {
1023 mod.get_value(iter, 1 , out gval);
1024 var project = (Project.Project)gval.get_object();
1026 _this.project_selected(project);
1031 // user defined functions
1033 public class Xcls_filemodel : Object
1035 public Gtk.TreeStore el;
1036 private Xcls_PopoverFiles _this;
1042 public Xcls_filemodel(Xcls_PopoverFiles _owner )
1045 _this.filemodel = this;
1046 this.el = new Gtk.TreeStore.newv( { typeof(string), typeof(string) } );
1050 // set gobject values
1055 this.el.set_sort_func(0, (mod,a,b) => {
1057 mod.get_value(a,0, out ga);
1058 mod.get_value(b,0, out gb);
1060 if ((string)ga == (string)gb) {
1063 return (string)ga > (string)gb ? 1 : -1;
1070 // user defined functions
1073 public class Xcls_TreeViewColumn21 : Object
1075 public Gtk.TreeViewColumn el;
1076 private Xcls_PopoverFiles _this;
1082 public Xcls_TreeViewColumn21(Xcls_PopoverFiles _owner )
1085 this.el = new Gtk.TreeViewColumn();
1089 // set gobject values
1090 this.el.title = "File";
1091 var child_0 = new Xcls_filenamecol( _this );
1093 this.el.pack_start ( child_0.el , true );
1097 this.el.add_attribute(_this.filenamecol.el , "markup", 0 );
1100 // user defined functions
1102 public class Xcls_filenamecol : Object
1104 public Gtk.CellRendererText el;
1105 private Xcls_PopoverFiles _this;
1111 public Xcls_filenamecol(Xcls_PopoverFiles _owner )
1114 _this.filenamecol = this;
1115 this.el = new Gtk.CellRendererText();
1119 // set gobject values
1122 // user defined functions