1 static Xcls_ClutterFiles _ClutterFiles;
3 public class Xcls_ClutterFiles : Object
5 public Clutter.Actor el;
6 private Xcls_ClutterFiles _this;
8 public static Xcls_ClutterFiles singleton()
10 if (_ClutterFiles == null) {
11 _ClutterFiles= new Xcls_ClutterFiles();
15 public Xcls_project_title project_title;
16 public Xcls_project_title_manager project_title_manager;
17 public Xcls_project_title_name project_title_name;
18 public Xcls_project_title_path project_title_path;
19 public Xcls_scoller scoller;
20 public Xcls_filelayout filelayout;
21 public Xcls_filelayout_manager filelayout_manager;
24 public Gee.ArrayList<Xcls_fileitem> fileitems;
25 public Clutter.ScrollMode scroll_mode;
26 public Gdk.Pixbuf missing_thumb_pixbuf;
27 public signal void open (JsRender.JsRender file);
30 public Xcls_ClutterFiles()
33 this.el = new Clutter.Actor();
36 this.fileitems = new Gee.ArrayList<Xcls_fileitem>();
37 this.scroll_mode = Clutter.ScrollMode.VERTICALLY;
38 this.missing_thumb_pixbuf = null;
41 this.el.reactive = true;
42 var child_0 = new Xcls_project_title( _this );
44 this.el.add_child ( child_0.el );
45 var child_1 = new Xcls_scoller( _this );
47 this.el.add_child ( child_1.el );
50 // user defined functions
51 public void clearFiles () {
53 this.filelayout.el.remove_all_children();
54 // we need to unref all the chidren that we loaded though...
57 public void loadProject (Project.Project pr) {
58 // list all the files, and create new Xcls_fileitem for each one.
60 // LEAK --- we should unref all the chilren...
61 this.filelayout.el.y = 0;
64 print("clutter files - load project: " + pr.name +"\n");
65 // should unref.. them hopefully.
67 this.project_title_name.el.text = pr.name;
68 this.project_title_path.el.text = pr.firstPath();
70 this.fileitems = new Gee.ArrayList<Xcls_fileitem>();
74 var fiter = pr.sortedFiles().list_iterator();
75 while (fiter.next()) {
76 var a = new Xcls_fileitem(this,fiter.get());
77 this.fileitems.add(a);
80 print("add to clutter file view: " + fiter.get().name + "\n");
81 this.filelayout.el.add_child(a.el);
86 if (!(pr is Project.Gtk)) {
89 var gpr = (Project.Gtk)pr;
90 var def = gpr.compilegroups.get("_default_");
91 var items = def.sources;
95 for(var i =0 ; i < items.size; i++) {
97 var files = gpr.files(items.get(i));
102 // add the directory... items.get(i);
103 var x = new Xcls_folderitem(this,items.get(i));
108 for(var j =0 ; j < files.size; j++) {
109 // add file to files.get(j);
114 //this.el.set_value(citer, 1, items.get(i) );
116 this.el.set_sort_column_id(0,Gtk.SortType.ASCENDING);
122 public void set_size (float w, float h)
125 // called by window resize... with is alreaddy -50 (for the buttons?)
128 if (this.el == null) {
129 print("object not ready yet?");
132 _this.filelayout_manager.el.max_column_width = w - 75;
135 // this.el.get_stage().width-150,
137 h // this.el.get_stage().height
140 // 100 right for buttons ..
141 this.el.set_position(0,0);
144 this.scoller.el.set_size(
145 // this.el.get_stage().width-150,
147 h // this.el.get_stage().height
150 // 100 right for buttons ..
151 this.scoller.el.set_position(75,50);
153 public class Xcls_project_title : Object
155 public Clutter.Actor el;
156 private Xcls_ClutterFiles _this;
162 public Xcls_project_title(Xcls_ClutterFiles _owner )
165 _this.project_title = this;
166 this.el = new Clutter.Actor();
170 // set gobject values
171 this.el.reactive = true;
172 var child_0 = new Xcls_project_title_manager( _this );
174 this.el.layout_manager = child_0.el;
175 var child_1 = new Xcls_FixedLayout4( _this );
177 this.el.layout_manager = child_1.el;
178 var child_2 = new Xcls_project_title_name( _this );
180 this.el.add_child ( child_2.el );
181 var child_3 = new Xcls_project_title_path( _this );
183 this.el.add_child ( child_3.el );
187 this.el.add_constraint(
188 new Clutter.BindConstraint(_this.el,Clutter.BindCoordinate.SIZE, 0.0f)
190 this.el.set_position(75,0);
193 // user defined functions
195 public class Xcls_project_title_manager : Object
197 public Clutter.FlowLayout el;
198 private Xcls_ClutterFiles _this;
204 public Xcls_project_title_manager(Xcls_ClutterFiles _owner )
207 _this.project_title_manager = this;
208 this.el = new Clutter.FlowLayout( Clutter.FlowOrientation.HORIZONTAL );
212 // set gobject values
213 this.el.homogeneous = false;
214 this.el.row_spacing = 5f;
215 this.el.column_spacing = 20f;
218 // user defined functions
221 public class Xcls_FixedLayout4 : Object
223 public Clutter.FixedLayout el;
224 private Xcls_ClutterFiles _this;
230 public Xcls_FixedLayout4(Xcls_ClutterFiles _owner )
233 this.el = new Clutter.FixedLayout();
237 // set gobject values
240 // user defined functions
243 public class Xcls_project_title_name : Object
245 public Clutter.Text el;
246 private Xcls_ClutterFiles _this;
252 public Xcls_project_title_name(Xcls_ClutterFiles _owner )
255 _this.project_title_name = this;
256 this.el = new Clutter.Text.full("Sans 20px", "", Clutter.Color.from_string("#eee"));
260 // set gobject values
263 this.el.x_expand = false;
266 // user defined functions
269 public class Xcls_project_title_path : Object
271 public Clutter.Text el;
272 private Xcls_ClutterFiles _this;
278 public Xcls_project_title_path(Xcls_ClutterFiles _owner )
281 _this.project_title_path = this;
282 this.el = new Clutter.Text.full("Sans 10px", "", Clutter.Color.from_string("#ccc"));
286 // set gobject values
291 // user defined functions
295 public class Xcls_scoller : Object
297 public Clutter.ScrollActor el;
298 private Xcls_ClutterFiles _this;
302 public Gee.ArrayList<Xcls_fileitem> fileitems;
303 public Gdk.Pixbuf missing_thumb_pixbuf;
306 public Xcls_scoller(Xcls_ClutterFiles _owner )
309 _this.scoller = this;
310 this.el = new Clutter.ScrollActor();
313 this.fileitems = new Gee.ArrayList<Xcls_fileitem>();
314 this.missing_thumb_pixbuf = null;
316 // set gobject values
317 this.el.scroll_mode = Clutter.ScrollMode.VERTICALLY;
318 this.el.reactive = true;
319 var child_0 = new Xcls_filelayout( _this );
321 this.el.add_child ( child_0.el );
324 this.el.scroll_event.connect( ( event) => {
325 //Sprint("scroll event");
326 var y = _this.filelayout.el.y;
327 var dir = event.direction;
329 case Clutter.ScrollDirection.UP:
332 case Clutter.ScrollDirection.DOWN:
338 // range of scroll -- can go up -- eg.. -ve value.
342 // to work out the max -ve number
343 // height of filelayout
344 // height of scrollactor..
346 var last_child_bottom = _this.filelayout.el.last_child.y + _this.filelayout.el.last_child.height;
347 if ( (-1 * (y+200)) > ( last_child_bottom - this.el.height)) {
354 // print("\nlast child - this height = %f ==== new y %f\n ".printf(
355 // last_child_bottom - this.el.height,
357 // y = float.min(0, y); //??
358 // print("scroll event of %f - new y = %f ".printf(event.y, y));
359 _this.filelayout.el.y = y;
365 // user defined functions
367 public class Xcls_filelayout : Object
369 public Clutter.Actor el;
370 private Xcls_ClutterFiles _this;
376 public Xcls_filelayout(Xcls_ClutterFiles _owner )
379 _this.filelayout = this;
380 this.el = new Clutter.Actor();
384 // set gobject values
385 this.el.reactive = true;
386 var child_0 = new Xcls_filelayout_manager( _this );
388 this.el.layout_manager = child_0.el;
392 this.el.add_constraint(
393 new Clutter.BindConstraint(_this.el,Clutter.BindCoordinate.SIZE, 0.0f)
397 // user defined functions
399 public class Xcls_filelayout_manager : Object
401 public Clutter.FlowLayout el;
402 private Xcls_ClutterFiles _this;
408 public Xcls_filelayout_manager(Xcls_ClutterFiles _owner )
411 _this.filelayout_manager = this;
412 this.el = new Clutter.FlowLayout( Clutter.FlowOrientation.HORIZONTAL );
416 // set gobject values
417 this.el.homogeneous = true;
418 this.el.row_spacing = 20f;
419 this.el.column_spacing = 20f;
422 // user defined functions
425 public class Xcls_fileitem : Object
427 public Clutter.Actor el;
428 private Xcls_ClutterFiles _this;
432 public JsRender.JsRender file;
433 public Xcls_image image;
434 public Xcls_typetitle typetitle;
435 public Xcls_title title;
438 public Xcls_fileitem(Xcls_ClutterFiles _owner , JsRender.JsRender file)
441 this.el = new Clutter.Actor();
445 // set gobject values
446 this.el.reactive = true;
447 var child_0 = new Xcls_BoxLayout11( _this );
449 this.el.layout_manager = child_0.el;
450 var child_1 = new Xcls_image( _this ,file);
452 this.el.add_child ( child_1.el );
453 this.image = child_1;
454 var child_2 = new Xcls_typetitle( _this ,file);
456 this.el.add_child ( child_2.el );
457 this.typetitle = child_2;
458 var child_3 = new Xcls_title( _this ,file);
460 this.el.add_child ( child_3.el );
461 this.title = child_3;
466 this.el.set_size(100,100);
469 this.el.button_press_event.connect( ( event) => {
470 _this.open(this.file);
473 this.el.enter_event.connect( ( event) => {
474 this.el.background_color = Clutter.Color.from_string("#333");
477 this.el.leave_event.connect( ( event) => {
478 this.el.background_color = Clutter.Color.from_string("#000");
483 // user defined functions
485 public class Xcls_BoxLayout11 : Object
487 public Clutter.BoxLayout el;
488 private Xcls_ClutterFiles _this;
494 public Xcls_BoxLayout11(Xcls_ClutterFiles _owner )
497 this.el = new Clutter.BoxLayout();
501 // set gobject values
503 this.el.orientation = Clutter.Orientation.VERTICAL;
506 // user defined functions
509 public class Xcls_image : Object
511 public Clutter.Actor el;
512 private Xcls_ClutterFiles _this;
518 public Xcls_image(Xcls_ClutterFiles _owner , JsRender.JsRender file)
521 this.el = new Clutter.Actor();
525 // set gobject values
526 this.el.margin_right = 5f;
527 this.el.margin_left = 5f;
528 this.el.x_align = Clutter.ActorAlign.START;
529 this.el.x_expand = true;
530 this.el.y_align = Clutter.ActorAlign.START;
531 this.el.margin_top = 5f;
532 this.el.y_expand = true;
537 Gdk.Pixbuf pixbuf= null;
539 var fname = file.getIconFileName(false);
542 if (FileUtils.test(fname, FileTest.EXISTS)) {
543 pixbuf = new Gdk.Pixbuf.from_file(fname);
549 if (pixbuf == null) {
552 if (_this.missing_thumb_pixbuf == null) {
553 var icon_theme = Gtk.IconTheme.get_default ();
554 _this.missing_thumb_pixbuf = icon_theme.load_icon ("package-x-generic", 92, 0);
555 _this.missing_thumb_pixbuf.ref();
557 pixbuf = _this.missing_thumb_pixbuf;
564 var img = new Clutter.Image();
565 img.set_data(pixbuf.get_pixels(),
567 ? Cogl.PixelFormat.RGBA_8888
568 : Cogl.PixelFormat.RGB_888,
570 pixbuf.get_height (),
571 pixbuf.get_rowstride ()
573 this.el.set_content(img);
577 // should probably do smarter scaling...
580 this.el.set_size(90, 70);
584 // user defined functions
587 public class Xcls_typetitle : Object
589 public Clutter.Text el;
590 private Xcls_ClutterFiles _this;
596 public Xcls_typetitle(Xcls_ClutterFiles _owner , JsRender.JsRender file)
599 this.el = new Clutter.Text.full("Sans 10px", file.nickType(), Clutter.Color.from_string("#fff"));
603 // set gobject values
604 this.el.x_align = Clutter.ActorAlign.START;
605 this.el.x_expand = true;
606 this.el.y_align = Clutter.ActorAlign.START;
607 this.el.y_expand = true;
610 // user defined functions
613 public class Xcls_title : Object
615 public Clutter.Text el;
616 private Xcls_ClutterFiles _this;
622 public Xcls_title(Xcls_ClutterFiles _owner , JsRender.JsRender file)
625 this.el = new Clutter.Text.full("Sans 10px", file.nickName(), Clutter.Color.from_string("#fff"));
629 // set gobject values
630 this.el.x_align = Clutter.ActorAlign.START;
631 this.el.x_expand = true;
632 this.el.y_align = Clutter.ActorAlign.START;
633 this.el.y_expand = true;
636 // user defined functions
640 public class Xcls_folderitem : Object
642 public Clutter.Actor el;
643 private Xcls_ClutterFiles _this;
647 public Xcls_foldertitle foldertitle;
650 public Xcls_folderitem(Xcls_ClutterFiles _owner , string folderpath)
653 this.el = new Clutter.Actor();
657 // set gobject values
658 this.el.reactive = true;
659 var child_0 = new Xcls_BoxLayout16( _this );
661 this.el.layout_manager = child_0.el;
662 var child_1 = new Xcls_foldertitle( _this ,folderpath);
664 this.el.add_child ( child_1.el );
665 this.foldertitle = child_1;
669 //this.el.set_size(100,100);
672 // user defined functions
674 public class Xcls_BoxLayout16 : Object
676 public Clutter.BoxLayout el;
677 private Xcls_ClutterFiles _this;
683 public Xcls_BoxLayout16(Xcls_ClutterFiles _owner )
686 this.el = new Clutter.BoxLayout();
690 // set gobject values
692 this.el.orientation = Clutter.Orientation.VERTICAL;
695 // user defined functions
698 public class Xcls_foldertitle : Object
700 public Clutter.Text el;
701 private Xcls_ClutterFiles _this;
707 public Xcls_foldertitle(Xcls_ClutterFiles _owner , string folderpath)
710 this.el = new Clutter.Text.full("Sans 14px", GLib.Path.get_basename(folderpath), Clutter.Color.from_string("#fff"));
714 // set gobject values
715 this.el.x_align = Clutter.ActorAlign.START;
716 this.el.x_expand = true;
717 this.el.y_align = Clutter.ActorAlign.START;
718 this.el.y_expand = true;
721 // user defined functions
724 public class Xcls_folderfile : Object
726 public Clutter.Text el;
727 private Xcls_ClutterFiles _this;
731 public string filepath;
734 public Xcls_folderfile(Xcls_ClutterFiles _owner , string filepath)
737 this.el = new Clutter.Text.full("Sans 10px", GLib.Path.get_basename(filepath), Clutter.Color.from_string("#fff"));
741 // set gobject values
742 this.el.x_align = Clutter.ActorAlign.START;
743 this.el.x_expand = true;
744 this.el.y_align = Clutter.ActorAlign.START;
745 this.el.y_expand = true;
750 this.filepath = filepath;
754 this.el.button_press_event.connect( ( event) => {
755 // _this.open(this.filepath);
758 this.el.enter_event.connect( ( event) => {
759 this.el.background_color = Clutter.Color.from_string("#333");
762 this.el.leave_event.connect( ( event) => {
763 this.el.background_color = Clutter.Color.from_string("#000");
768 // user defined functions