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_iconsearch iconsearch;
19 public Xcls_iconscroll iconscroll;
20 public Xcls_iconview iconview;
21 public Xcls_iconmodel iconmodel;
22 public Xcls_file_container file_container;
23 public Xcls_fileview fileview;
24 public Xcls_filemodel filemodel;
25 public Xcls_filenamecol filenamecol;
28 public Xcls_MainWindow win;
29 public string lastfilter;
30 public bool in_onprojectselected;
31 public Project.Project selectedProject;
32 public bool is_loading;
33 public bool new_window;
34 public Gdk.Pixbuf missing_thumb_pixbuf;
35 public Gee.HashMap<string,Gdk.Pixbuf> image_cache;
37 public bool is_loaded;
40 public Xcls_PopoverFiles()
43 this.el = new Gtk.Popover( null );
47 this.in_onprojectselected = false;
48 this.is_loading = false;
49 this.new_window = false;
50 this.image_cache = null;
52 this.is_loaded = false;
55 this.el.width_request = 900;
56 this.el.height_request = 800;
57 this.el.hexpand = false;
59 this.el.position = Gtk.PositionType.TOP;
60 var child_0 = new Xcls_Box2( _this );
62 this.el.add ( child_0.el );
65 this.el.hide.connect( ( ) => {
68 //if (project != null) {
69 // this.selectProject(project);
71 if (_this.win.windowstate.project == null) {
77 // user defined functions
78 public void onProjectSelected (Project.Project project)
80 if (this.in_onprojectselected) {
83 this.in_onprojectselected = true;
86 this.selectedProject = project;
88 //this.clutterfiles.loadProject(proj);
92 _this.iconsearch.el.text = "";
98 //this.project_title_name.el.text = pr.name;
99 //this.project_title_path.el.text = pr.firstPath();
101 // file items contains a reference until we reload ...
105 GLib.Timeout.add(500, () => {
106 _this.iconsearch.el.grab_focus();
110 this.filemodel.el.clear();
114 if (!(project is Project.Gtk)) {
115 print ("not gtk... skipping files");
116 this.file_container.el.hide();
117 this.in_onprojectselected = false;
120 this.file_container.el.show();
121 var gpr = (Project.Gtk)project;
122 var def = gpr.compilegroups.get("_default_");
123 // not sure why the above is returng null!??
125 def = new Project.GtkValaSettings("_default_");
126 gpr.compilegroups.set("_default_", def);
128 var items = def.sources;
130 Gtk.TreeIter citer; // folder iter
131 Gtk.TreeIter fxiter; // file iter
132 for(var i =0 ; i < items.size; i++) {
133 print ("cheking folder %s\n", items.get(i));
134 var files = gpr.filesForOpen(items.get(i));
135 if (files.size < 1) {
138 this.filemodel.el.append(out citer,null);
139 this.filemodel.el.set(citer, 0, GLib.Path.get_basename(items.get(i)));
140 this.filemodel.el.set(citer, 1, null); // parent (empty as it's a folder)
143 // add the directory... items.get(i);
144 //var x = new Xcls_folderitem(this,items.get(i));
145 //this.fileitems.add(x);
146 //this.filelayout.el.add_child(x.el);
149 for(var j =0 ; j < files.size; j++) {
151 this.filemodel.el.insert(out fxiter,citer, -1);
152 this.filemodel.el.set(fxiter, 0, GLib.Path.get_basename(files.get(j))); // filename
153 this.filemodel.el.set(fxiter, 1, files.get(j)); // Folder?
159 //this.el.set_value(citer, 1, items.get(i) );
161 _this.fileview.el.expand_all();
162 this.in_onprojectselected = false;
165 public void selectProject (Project.Project project) {
167 var sel = _this.view.el.get_selection();
172 _this.model.el.foreach((mod, path, iter) => {
175 mod.get_value(iter, 1, out val);
176 if ( ( (Project.Project)val.get_object()).fn != project.fn) {
177 print("SKIP %s != %s\n", ((Project.Project)val.get_object()).name , project.name);
178 return false;//continue
180 sel.select_iter(iter);
181 this.selectedProject = project;
182 this.onProjectSelected(project);
189 print("tried to select %s, could not find it", project.name);
192 public void show (Gtk.Widget on_el, Project.Project? project, bool new_window) {
193 //this.editor.show( file, node, ptype, key);
195 this.new_window = new_window;
198 this.el.show_all(); // show first - so we can hide stuff later.
199 if (project != null) {
201 this.selectProject(project);
206 this.win.el.get_size(out w, out h);
208 // left tree = 250, editor area = 500?
213 var ww = on_el.get_allocated_width();
215 // width = should be max = w-ww , or 600 at best..?
217 this.el.set_size_request( w, h); // same as parent...
220 this.el.set_modal(true);
221 this.el.set_relative_to(on_el);
226 public void load () {
229 if (_this.is_loaded) {
232 _this.is_loading = true;
234 _this.is_loaded = true;
236 Project.Project.loadAll();
237 var projects = Project.Project.allProjectsByName();
240 var m = this.model.el;
243 for (var i = 0; i < projects.size; i++) {
245 m.set(iter, 0,projects.get(i).name );
247 var o = GLib.Value(typeof(Object));
248 o.set_object((Object)projects.get(i));
250 m.set_value(iter, 1, o);
253 m.set_sort_column_id(0, Gtk.SortType.ASCENDING);
254 _this.is_loading = false;
256 public void setMainWindow (Xcls_MainWindow win) {
260 public void loadIconView () {
262 if (_this.image_cache == null) {
263 _this.image_cache = new Gee.HashMap<string,Gdk.Pixbuf>();
266 var project = this.selectedProject;
268 Gdk.Pixbuf pixbuf = null;
269 Gdk.Pixbuf bigpixbuf = null;
271 var m = this.iconmodel.el;
275 var filter = _this.iconsearch.el.text.down();
276 this.lastfilter = filter;
278 var fiter = project.sortedFiles().list_iterator();
282 if (_this.missing_thumb_pixbuf == null) {
283 var icon_theme = Gtk.IconTheme.get_default ();
284 _this.missing_thumb_pixbuf = icon_theme.load_icon ("package-x-generic", 92, 0);
285 _this.missing_thumb_pixbuf.ref();
295 while (fiter.next()) {
297 var file = fiter.get();
299 if (!file.name.down().contains(filter)) {
309 m.set(iter, 0,file ); // zero contains the file reference
310 m.set(iter, 1,file.nickType() + "\n" + file.nickName()); // marked up title?
311 m.set(iter, 2,file.nickType() ); // file type?
317 pixbuf = file.getIcon(92);
318 bigpixbuf = file.getIcon(368);
326 if (pixbuf == null) {
327 GLib.debug("PIXBUF is null? %s", file.name);
328 pixbuf = _this.missing_thumb_pixbuf;
329 bigpixbuf = _this.missing_thumb_pixbuf;
334 m.set(iter, 3,pixbuf);
335 m.set(iter, 4,bigpixbuf);
337 // this needs to add to the iconview?
339 //var a = new Xcls_fileitem(this,fiter.get());
340 //this.fileitems.add(a);
342 //this.filelayout.el.add_child(a.el);
345 public class Xcls_Box2 : Object
348 private Xcls_PopoverFiles _this;
354 public Xcls_Box2(Xcls_PopoverFiles _owner )
357 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
361 // set gobject values
362 var child_0 = new Xcls_Box3( _this );
364 this.el.add ( child_0.el );
365 var child_1 = new Xcls_Box9( _this );
367 this.el.add ( child_1.el );
370 // user defined functions
372 public class Xcls_Box3 : Object
375 private Xcls_PopoverFiles _this;
381 public Xcls_Box3(Xcls_PopoverFiles _owner )
384 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
388 // set gobject values
389 var child_0 = new Xcls_Toolbar4( _this );
391 this.el.add ( child_0.el );
394 // user defined functions
396 public class Xcls_Toolbar4 : Object
398 public Gtk.Toolbar el;
399 private Xcls_PopoverFiles _this;
405 public Xcls_Toolbar4(Xcls_PopoverFiles _owner )
408 this.el = new Gtk.Toolbar();
412 // set gobject values
413 this.el.toolbar_style = Gtk.ToolbarStyle.BOTH;
414 var child_0 = new Xcls_ToolButton5( _this );
416 this.el.add ( child_0.el );
417 var child_1 = new Xcls_ToolButton6( _this );
419 this.el.add ( child_1.el );
420 var child_2 = new Xcls_ToolButton7( _this );
422 this.el.add ( child_2.el );
423 var child_3 = new Xcls_ToolButton8( _this );
425 this.el.add ( child_3.el );
428 // user defined functions
430 public class Xcls_ToolButton5 : Object
432 public Gtk.ToolButton el;
433 private Xcls_PopoverFiles _this;
439 public Xcls_ToolButton5(Xcls_PopoverFiles _owner )
442 this.el = new Gtk.ToolButton( null, "New Project" );
446 // set gobject values
447 this.el.icon_name = "folder-new";
450 this.el.clicked.connect( ( ) => {
452 // create a new file in project..
453 //Xcls_DialogNewComponent.singleton().show(
454 var pe = EditProject.singleton();
455 //pe.el.set_transient_for(_this.el);
456 pe.el.set_modal(true);
465 _this.win.windowstate.left_projects.is_loaded = false;
466 _this.win.windowstate.left_projects.load();
467 _this.win.windowstate.left_projects.selectProject(p);
474 // user defined functions
477 public class Xcls_ToolButton6 : Object
479 public Gtk.ToolButton el;
480 private Xcls_PopoverFiles _this;
486 public Xcls_ToolButton6(Xcls_PopoverFiles _owner )
489 this.el = new Gtk.ToolButton( null, "Project Properties" );
493 // set gobject values
494 this.el.icon_name = "emblem-system";
497 this.el.clicked.connect( ( ) => {
498 // should disable the button really.
499 if (_this.selectedProject == null) {
502 _this.win.windowstate.projectPopoverShow(this.el, _this.selectedProject);
506 // user defined functions
509 public class Xcls_ToolButton7 : Object
511 public Gtk.ToolButton el;
512 private Xcls_PopoverFiles _this;
518 public Xcls_ToolButton7(Xcls_PopoverFiles _owner )
521 this.el = new Gtk.ToolButton( null, "Delete Project" );
525 // set gobject values
526 this.el.icon_name = "user-trash";
529 this.el.clicked.connect( ( ) => {
531 var cd = DialogConfirm.singleton();
532 cd.el.set_transient_for(_this.el);
533 cd.el.set_modal(true);
535 var project = _this.windowstate.left_projects.getSelectedProject();
536 if (project == null) {
537 print("SKIP - no project\n");
542 if (Gtk.ResponseType.YES != cd.show("Confirm",
543 "Are you sure you want to delete project %s".printf(project.name))) {
549 Project.Project.remove(project);
550 _this.project = null;
552 _this.windowstate.left_projects.is_loaded = false;
553 _this.windowstate.left_projects.load();
554 _this.windowstate.clutterfiles.clearFiles();
560 // user defined functions
563 public class Xcls_ToolButton8 : Object
565 public Gtk.ToolButton el;
566 private Xcls_PopoverFiles _this;
572 public Xcls_ToolButton8(Xcls_PopoverFiles _owner )
575 this.el = new Gtk.ToolButton( null, "New File" );
579 // set gobject values
580 this.el.icon_name = "document-new";
583 this.el.clicked.connect( () => {
584 // create a new file in project..
585 print("add file selected\n");
587 if (_this.selectedProject == null) {
591 var f = JsRender.JsRender.factory(_this.selectedProject.xtype, _this.selectedProject, "");
592 _this.win.windowstate.file_details.show( f, this.el, _this.new_window );
598 // user defined functions
603 public class Xcls_Box9 : Object
606 private Xcls_PopoverFiles _this;
612 public Xcls_Box9(Xcls_PopoverFiles _owner )
615 this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
619 // set gobject values
620 this.el.homogeneous = false;
621 var child_0 = new Xcls_ScrolledWindow10( _this );
623 this.el.add ( child_0.el );
624 var child_1 = new Xcls_Box15( _this );
626 this.el.add( child_1.el );
627 var child_2 = new Xcls_file_container( _this );
629 this.el.add ( child_2.el );
632 // user defined functions
634 public class Xcls_ScrolledWindow10 : Object
636 public Gtk.ScrolledWindow el;
637 private Xcls_PopoverFiles _this;
643 public Xcls_ScrolledWindow10(Xcls_PopoverFiles _owner )
646 this.el = new Gtk.ScrolledWindow( null, null );
650 // set gobject values
651 this.el.width_request = 150;
652 this.el.expand = true;
653 this.el.shadow_type = Gtk.ShadowType.IN;
654 var child_0 = new Xcls_view( _this );
656 this.el.add ( child_0.el );
660 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
663 // user defined functions
665 public class Xcls_view : Object
667 public Gtk.TreeView el;
668 private Xcls_PopoverFiles _this;
674 public Xcls_view(Xcls_PopoverFiles _owner )
678 this.el = new Gtk.TreeView();
682 // set gobject values
683 this.el.enable_tree_lines = true;
684 this.el.headers_visible = true;
685 var child_0 = new Xcls_model( _this );
687 this.el.set_model ( child_0.el );
688 var child_1 = new Xcls_TreeViewColumn13( _this );
690 this.el.append_column ( child_1.el );
694 var description = new Pango.FontDescription();
695 description.set_size(9000);
696 this.el.override_font(description);
698 var selection = this.el.get_selection();
699 selection.set_mode( Gtk.SelectionMode.SINGLE);
702 this.el.cursor_changed.connect( () => {
703 if (_this.is_loading) {
710 var s = this.el.get_selection();
711 if (!s.get_selected(out mod, out iter)) {
717 mod.get_value(iter, 1 , out gval);
718 var project = (Project.Project)gval.get_object();
720 _this.onProjectSelected(project);
725 // user defined functions
727 public class Xcls_model : Object
729 public Gtk.ListStore el;
730 private Xcls_PopoverFiles _this;
736 public Xcls_model(Xcls_PopoverFiles _owner )
740 this.el = new Gtk.ListStore.newv( { typeof(string), typeof(Object) } );
744 // set gobject values
749 this.el.set_sort_func(0, (mod,a,b) => {
751 mod.get_value(a,0, out ga);
752 mod.get_value(b,0, out gb);
754 if ((string)ga == (string)gb) {
757 return (string)ga > (string)gb ? 1 : -1;
764 // user defined functions
767 public class Xcls_TreeViewColumn13 : Object
769 public Gtk.TreeViewColumn el;
770 private Xcls_PopoverFiles _this;
776 public Xcls_TreeViewColumn13(Xcls_PopoverFiles _owner )
779 this.el = new Gtk.TreeViewColumn();
783 // set gobject values
784 this.el.title = "Projects";
785 var child_0 = new Xcls_namecol( _this );
787 this.el.pack_start ( child_0.el , true );
791 this.el.add_attribute(_this.namecol.el , "markup", 0 );
794 // user defined functions
796 public class Xcls_namecol : Object
798 public Gtk.CellRendererText el;
799 private Xcls_PopoverFiles _this;
805 public Xcls_namecol(Xcls_PopoverFiles _owner )
808 _this.namecol = this;
809 this.el = new Gtk.CellRendererText();
813 // set gobject values
816 // user defined functions
822 public class Xcls_Box15 : Object
825 private Xcls_PopoverFiles _this;
831 public Xcls_Box15(Xcls_PopoverFiles _owner )
834 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
838 // set gobject values
839 this.el.width_request = 600;
840 this.el.expand = true;
841 var child_0 = new Xcls_Box16( _this );
843 this.el.add( child_0.el );
844 var child_1 = new Xcls_iconscroll( _this );
846 this.el.add ( child_1.el );
849 // user defined functions
851 public class Xcls_Box16 : Object
854 private Xcls_PopoverFiles _this;
860 public Xcls_Box16(Xcls_PopoverFiles _owner )
863 this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
867 // set gobject values
868 this.el.hexpand = true;
869 var child_0 = new Xcls_iconsearch( _this );
871 this.el.add( child_0.el );
874 // user defined functions
876 public class Xcls_iconsearch : Object
878 public Gtk.SearchEntry el;
879 private Xcls_PopoverFiles _this;
885 public Xcls_iconsearch(Xcls_PopoverFiles _owner )
888 _this.iconsearch = this;
889 this.el = new Gtk.SearchEntry();
893 // set gobject values
894 this.el.hexpand = true;
895 this.el.placeholder_text = "type to filter results";
899 var description = Pango.FontDescription.from_string("monospace");
900 description.set_size(8000);
901 this.el.override_font(description);
904 this.el.changed.connect( ( ) => {
905 GLib.debug("Got '%s'", this.el.text);
907 if (this.el.text.down() != _this.lastfilter) {
908 _this.loadIconView();
913 // user defined functions
917 public class Xcls_iconscroll : Object
919 public Gtk.ScrolledWindow el;
920 private Xcls_PopoverFiles _this;
926 public Xcls_iconscroll(Xcls_PopoverFiles _owner )
929 _this.iconscroll = this;
930 this.el = new Gtk.ScrolledWindow( null, null );
934 // set gobject values
935 this.el.width_request = 600;
936 this.el.expand = true;
937 this.el.shadow_type = Gtk.ShadowType.IN;
938 var child_0 = new Xcls_iconview( _this );
940 this.el.add ( child_0.el );
944 this.el.set_policy (Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC);
947 // user defined functions
949 public class Xcls_iconview : Object
951 public Gtk.IconView el;
952 private Xcls_PopoverFiles _this;
958 public Xcls_iconview(Xcls_PopoverFiles _owner )
961 _this.iconview = this;
962 this.el = new Gtk.IconView();
966 // set gobject values
967 this.el.markup_column = 1;
968 this.el.pixbuf_column = 3;
969 this.el.has_tooltip = true;
970 this.el.item_width = 100;
971 var child_0 = new Xcls_iconmodel( _this );
973 this.el.model = child_0.el;
982 this.el.item_activated.connect( (path) => {
984 _this.win.windowstate.project = _this.selectedProject;
991 this.el.model.get_iter(out iter, path);
995 this.el.model.get_value(iter, 0 , out gval);
996 var file = (JsRender.JsRender)gval;
999 _this.win.windowstate.fileViewOpen(file, _this.new_window);
1004 this.el.query_tooltip.connect( (x, y, keyboard_tooltip, tooltip) => {
1007 Gtk.CellRenderer cell;
1008 var s = _this.iconview.el.get_item_at_pos(x,y + (int) _this.iconscroll.el.vadjustment.value, out path, out cell);
1011 // GLib.debug("Tooltip? %d,%d scroll: %d",x,y, (int)_this.iconscroll.el.vadjustment.value);
1015 // GLib.debug("Tooltip? - no path");
1020 _this.iconmodel.el.get_iter(out iter, path);
1022 _this.iconmodel.el.get_value(iter, 4, out val);
1024 tooltip.set_icon((Gdk.Pixbuf) val.get_object());
1025 _this.iconview.el.set_tooltip_item(tooltip, path);
1030 // user defined functions
1032 public class Xcls_iconmodel : Object
1034 public Gtk.ListStore el;
1035 private Xcls_PopoverFiles _this;
1041 public Xcls_iconmodel(Xcls_PopoverFiles _owner )
1044 _this.iconmodel = this;
1045 this.el = new Gtk.ListStore.newv( { typeof(Object), typeof(string), typeof(string), typeof(Gdk.Pixbuf), typeof(Gdk.Pixbuf) } );
1049 // set gobject values
1052 // user defined functions
1058 public class Xcls_file_container : Object
1060 public Gtk.ScrolledWindow el;
1061 private Xcls_PopoverFiles _this;
1067 public Xcls_file_container(Xcls_PopoverFiles _owner )
1070 _this.file_container = this;
1071 this.el = new Gtk.ScrolledWindow( null, null );
1075 // set gobject values
1076 this.el.width_request = 100;
1077 this.el.expand = true;
1078 this.el.shadow_type = Gtk.ShadowType.IN;
1079 this.el.visible = false;
1080 var child_0 = new Xcls_fileview( _this );
1082 this.el.add ( child_0.el );
1086 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
1089 // user defined functions
1091 public class Xcls_fileview : Object
1093 public Gtk.TreeView el;
1094 private Xcls_PopoverFiles _this;
1100 public Xcls_fileview(Xcls_PopoverFiles _owner )
1103 _this.fileview = this;
1104 this.el = new Gtk.TreeView();
1108 // set gobject values
1109 this.el.activate_on_single_click = false;
1110 this.el.expand = true;
1111 this.el.enable_tree_lines = true;
1112 this.el.headers_visible = true;
1113 var child_0 = new Xcls_filemodel( _this );
1115 this.el.set_model ( child_0.el );
1116 var child_1 = new Xcls_TreeViewColumn24( _this );
1118 this.el.append_column ( child_1.el );
1122 var description = new Pango.FontDescription();
1123 description.set_size(9000);
1124 this.el.override_font(description);
1126 var selection = this.el.get_selection();
1127 selection.set_mode( Gtk.SelectionMode.SINGLE);
1130 this.el.row_activated.connect( (path, col) => {
1135 this.el.model.get_iter(out iter, path);
1139 this.el.model.get_value(iter, 1 , out gval);
1140 var fn = (string)gval;
1141 if (fn.length < 1) {
1144 _this.win.windowstate.project = _this.selectedProject;
1147 var f = JsRender.JsRender.factory("PlainFile", _this.selectedProject, fn);
1150 _this.win.windowstate.fileViewOpen(f, _this.new_window);
1154 this.el.cursor_changed.connect( () => {
1156 if (_this.is_loading) {
1163 var s = this.el.get_selection();
1164 if (!s.get_selected(out mod, out iter)) {
1170 mod.get_value(iter, 1 , out gval);
1171 var project = (Project.Project)gval.get_object();
1173 _this.project_selected(project);
1178 // user defined functions
1180 public class Xcls_filemodel : Object
1182 public Gtk.TreeStore el;
1183 private Xcls_PopoverFiles _this;
1189 public Xcls_filemodel(Xcls_PopoverFiles _owner )
1192 _this.filemodel = this;
1193 this.el = new Gtk.TreeStore.newv( { typeof(string), typeof(string) } );
1197 // set gobject values
1202 this.el.set_sort_func(0, (mod,a,b) => {
1204 mod.get_value(a,0, out ga);
1205 mod.get_value(b,0, out gb);
1207 if ((string)ga == (string)gb) {
1210 return (string)ga > (string)gb ? 1 : -1;
1217 // user defined functions
1220 public class Xcls_TreeViewColumn24 : Object
1222 public Gtk.TreeViewColumn el;
1223 private Xcls_PopoverFiles _this;
1229 public Xcls_TreeViewColumn24(Xcls_PopoverFiles _owner )
1232 this.el = new Gtk.TreeViewColumn();
1236 // set gobject values
1237 this.el.title = "File";
1238 var child_0 = new Xcls_filenamecol( _this );
1240 this.el.pack_start ( child_0.el , true );
1244 this.el.add_attribute(_this.filenamecol.el , "markup", 0 );
1247 // user defined functions
1249 public class Xcls_filenamecol : Object
1251 public Gtk.CellRendererText el;
1252 private Xcls_PopoverFiles _this;
1258 public Xcls_filenamecol(Xcls_PopoverFiles _owner )
1261 _this.filenamecol = this;
1262 this.el = new Gtk.CellRendererText();
1266 // set gobject values
1269 // user defined functions