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);
107 for(var j =0 ; j < files.size; j++) {
108 // add file to files.get(j);
113 //this.el.set_value(citer, 1, items.get(i) );
115 this.el.set_sort_column_id(0,Gtk.SortType.ASCENDING);
121 public void set_size (float w, float h)
124 // called by window resize... with is alreaddy -50 (for the buttons?)
127 if (this.el == null) {
128 print("object not ready yet?");
131 _this.filelayout_manager.el.max_column_width = w - 75;
134 // this.el.get_stage().width-150,
136 h // this.el.get_stage().height
139 // 100 right for buttons ..
140 this.el.set_position(0,0);
143 this.scoller.el.set_size(
144 // this.el.get_stage().width-150,
146 h // this.el.get_stage().height
149 // 100 right for buttons ..
150 this.scoller.el.set_position(75,50);
152 public class Xcls_project_title : Object
154 public Clutter.Actor el;
155 private Xcls_ClutterFiles _this;
161 public Xcls_project_title(Xcls_ClutterFiles _owner )
164 _this.project_title = this;
165 this.el = new Clutter.Actor();
169 // set gobject values
170 this.el.reactive = true;
171 var child_0 = new Xcls_project_title_manager( _this );
173 this.el.layout_manager = child_0.el;
174 var child_1 = new Xcls_FixedLayout4( _this );
176 this.el.layout_manager = child_1.el;
177 var child_2 = new Xcls_project_title_name( _this );
179 this.el.add_child ( child_2.el );
180 var child_3 = new Xcls_project_title_path( _this );
182 this.el.add_child ( child_3.el );
186 this.el.add_constraint(
187 new Clutter.BindConstraint(_this.el,Clutter.BindCoordinate.SIZE, 0.0f)
189 this.el.set_position(75,0);
192 // user defined functions
194 public class Xcls_project_title_manager : Object
196 public Clutter.FlowLayout el;
197 private Xcls_ClutterFiles _this;
203 public Xcls_project_title_manager(Xcls_ClutterFiles _owner )
206 _this.project_title_manager = this;
207 this.el = new Clutter.FlowLayout( Clutter.FlowOrientation.HORIZONTAL );
211 // set gobject values
212 this.el.homogeneous = false;
213 this.el.row_spacing = 5f;
214 this.el.column_spacing = 20f;
217 // user defined functions
220 public class Xcls_FixedLayout4 : Object
222 public Clutter.FixedLayout el;
223 private Xcls_ClutterFiles _this;
229 public Xcls_FixedLayout4(Xcls_ClutterFiles _owner )
232 this.el = new Clutter.FixedLayout();
236 // set gobject values
239 // user defined functions
242 public class Xcls_project_title_name : Object
244 public Clutter.Text el;
245 private Xcls_ClutterFiles _this;
251 public Xcls_project_title_name(Xcls_ClutterFiles _owner )
254 _this.project_title_name = this;
255 this.el = new Clutter.Text.full("Sans 20px", "", Clutter.Color.from_string("#eee"));
259 // set gobject values
262 this.el.x_expand = false;
265 // user defined functions
268 public class Xcls_project_title_path : Object
270 public Clutter.Text el;
271 private Xcls_ClutterFiles _this;
277 public Xcls_project_title_path(Xcls_ClutterFiles _owner )
280 _this.project_title_path = this;
281 this.el = new Clutter.Text.full("Sans 10px", "", Clutter.Color.from_string("#ccc"));
285 // set gobject values
290 // user defined functions
294 public class Xcls_scoller : Object
296 public Clutter.ScrollActor el;
297 private Xcls_ClutterFiles _this;
301 public Gee.ArrayList<Xcls_fileitem> fileitems;
302 public Gdk.Pixbuf missing_thumb_pixbuf;
305 public Xcls_scoller(Xcls_ClutterFiles _owner )
308 _this.scoller = this;
309 this.el = new Clutter.ScrollActor();
312 this.fileitems = new Gee.ArrayList<Xcls_fileitem>();
313 this.missing_thumb_pixbuf = null;
315 // set gobject values
316 this.el.scroll_mode = Clutter.ScrollMode.VERTICALLY;
317 this.el.reactive = true;
318 var child_0 = new Xcls_filelayout( _this );
320 this.el.add_child ( child_0.el );
323 this.el.scroll_event.connect( ( event) => {
324 //Sprint("scroll event");
325 var y = _this.filelayout.el.y;
326 var dir = event.direction;
328 case Clutter.ScrollDirection.UP:
331 case Clutter.ScrollDirection.DOWN:
337 // range of scroll -- can go up -- eg.. -ve value.
341 // to work out the max -ve number
342 // height of filelayout
343 // height of scrollactor..
345 var last_child_bottom = _this.filelayout.el.last_child.y + _this.filelayout.el.last_child.height;
346 if ( (-1 * (y+200)) > ( last_child_bottom - this.el.height)) {
353 // print("\nlast child - this height = %f ==== new y %f\n ".printf(
354 // last_child_bottom - this.el.height,
356 // y = float.min(0, y); //??
357 // print("scroll event of %f - new y = %f ".printf(event.y, y));
358 _this.filelayout.el.y = y;
364 // user defined functions
366 public class Xcls_filelayout : Object
368 public Clutter.Actor el;
369 private Xcls_ClutterFiles _this;
375 public Xcls_filelayout(Xcls_ClutterFiles _owner )
378 _this.filelayout = this;
379 this.el = new Clutter.Actor();
383 // set gobject values
384 this.el.reactive = true;
385 var child_0 = new Xcls_filelayout_manager( _this );
387 this.el.layout_manager = child_0.el;
391 this.el.add_constraint(
392 new Clutter.BindConstraint(_this.el,Clutter.BindCoordinate.SIZE, 0.0f)
396 // user defined functions
398 public class Xcls_filelayout_manager : Object
400 public Clutter.FlowLayout el;
401 private Xcls_ClutterFiles _this;
407 public Xcls_filelayout_manager(Xcls_ClutterFiles _owner )
410 _this.filelayout_manager = this;
411 this.el = new Clutter.FlowLayout( Clutter.FlowOrientation.HORIZONTAL );
415 // set gobject values
416 this.el.homogeneous = true;
417 this.el.row_spacing = 20f;
418 this.el.column_spacing = 20f;
421 // user defined functions
424 public class Xcls_fileitem : Object
426 public Clutter.Actor el;
427 private Xcls_ClutterFiles _this;
431 public JsRender.JsRender file;
432 public Xcls_image image;
433 public Xcls_typetitle typetitle;
434 public Xcls_title title;
437 public Xcls_fileitem(Xcls_ClutterFiles _owner , JsRender.JsRender file)
440 this.el = new Clutter.Actor();
444 // set gobject values
445 this.el.reactive = true;
446 var child_0 = new Xcls_BoxLayout11( _this );
448 this.el.layout_manager = child_0.el;
449 var child_1 = new Xcls_image( _this ,file);
451 this.el.add_child ( child_1.el );
452 this.image = child_1;
453 var child_2 = new Xcls_typetitle( _this ,file);
455 this.el.add_child ( child_2.el );
456 this.typetitle = child_2;
457 var child_3 = new Xcls_title( _this ,file);
459 this.el.add_child ( child_3.el );
460 this.title = child_3;
465 this.el.set_size(100,100);
468 this.el.button_press_event.connect( ( event) => {
469 _this.open(this.file);
472 this.el.enter_event.connect( ( event) => {
473 this.el.background_color = Clutter.Color.from_string("#333");
476 this.el.leave_event.connect( ( event) => {
477 this.el.background_color = Clutter.Color.from_string("#000");
482 // user defined functions
484 public class Xcls_BoxLayout11 : Object
486 public Clutter.BoxLayout el;
487 private Xcls_ClutterFiles _this;
493 public Xcls_BoxLayout11(Xcls_ClutterFiles _owner )
496 this.el = new Clutter.BoxLayout();
500 // set gobject values
502 this.el.orientation = Clutter.Orientation.VERTICAL;
505 // user defined functions
508 public class Xcls_image : Object
510 public Clutter.Actor el;
511 private Xcls_ClutterFiles _this;
517 public Xcls_image(Xcls_ClutterFiles _owner , JsRender.JsRender file)
520 this.el = new Clutter.Actor();
524 // set gobject values
525 this.el.margin_right = 5f;
526 this.el.margin_left = 5f;
527 this.el.x_align = Clutter.ActorAlign.START;
528 this.el.x_expand = true;
529 this.el.y_align = Clutter.ActorAlign.START;
530 this.el.margin_top = 5f;
531 this.el.y_expand = true;
536 Gdk.Pixbuf pixbuf= null;
538 var fname = file.getIconFileName(false);
541 if (FileUtils.test(fname, FileTest.EXISTS)) {
542 pixbuf = new Gdk.Pixbuf.from_file(fname);
548 if (pixbuf == null) {
551 if (_this.missing_thumb_pixbuf == null) {
552 var icon_theme = Gtk.IconTheme.get_default ();
553 _this.missing_thumb_pixbuf = icon_theme.load_icon ("package-x-generic", 92, 0);
554 _this.missing_thumb_pixbuf.ref();
556 pixbuf = _this.missing_thumb_pixbuf;
563 var img = new Clutter.Image();
564 img.set_data(pixbuf.get_pixels(),
566 ? Cogl.PixelFormat.RGBA_8888
567 : Cogl.PixelFormat.RGB_888,
569 pixbuf.get_height (),
570 pixbuf.get_rowstride ()
572 this.el.set_content(img);
576 // should probably do smarter scaling...
579 this.el.set_size(90, 70);
583 // user defined functions
586 public class Xcls_typetitle : Object
588 public Clutter.Text el;
589 private Xcls_ClutterFiles _this;
595 public Xcls_typetitle(Xcls_ClutterFiles _owner , JsRender.JsRender file)
598 this.el = new Clutter.Text.full("Sans 10px", file.nickType(), Clutter.Color.from_string("#fff"));
602 // set gobject values
603 this.el.x_align = Clutter.ActorAlign.START;
604 this.el.x_expand = true;
605 this.el.y_align = Clutter.ActorAlign.START;
606 this.el.y_expand = true;
609 // user defined functions
612 public class Xcls_title : Object
614 public Clutter.Text el;
615 private Xcls_ClutterFiles _this;
621 public Xcls_title(Xcls_ClutterFiles _owner , JsRender.JsRender file)
624 this.el = new Clutter.Text.full("Sans 10px", file.nickName(), Clutter.Color.from_string("#fff"));
628 // set gobject values
629 this.el.x_align = Clutter.ActorAlign.START;
630 this.el.x_expand = true;
631 this.el.y_align = Clutter.ActorAlign.START;
632 this.el.y_expand = true;
635 // user defined functions
639 public class Xcls_folderitem : Object
641 public Clutter.Actor el;
642 private Xcls_ClutterFiles _this;
646 public Xcls_foldertitle foldertitle;
649 public Xcls_folderitem(Xcls_ClutterFiles _owner , string folderpath)
652 this.el = new Clutter.Actor();
656 // set gobject values
657 this.el.reactive = true;
658 var child_0 = new Xcls_BoxLayout16( _this );
660 this.el.layout_manager = child_0.el;
661 var child_1 = new Xcls_foldertitle( _this ,folderpath);
663 this.el.add_child ( child_1.el );
664 this.foldertitle = child_1;
668 //this.el.set_size(100,100);
671 // user defined functions
673 public class Xcls_BoxLayout16 : Object
675 public Clutter.BoxLayout el;
676 private Xcls_ClutterFiles _this;
682 public Xcls_BoxLayout16(Xcls_ClutterFiles _owner )
685 this.el = new Clutter.BoxLayout();
689 // set gobject values
691 this.el.orientation = Clutter.Orientation.VERTICAL;
694 // user defined functions
697 public class Xcls_foldertitle : Object
699 public Clutter.Text el;
700 private Xcls_ClutterFiles _this;
706 public Xcls_foldertitle(Xcls_ClutterFiles _owner , string folderpath)
709 this.el = new Clutter.Text.full("Sans 14px", GLib.Path.get_basename(folderpath), Clutter.Color.from_string("#fff"));
713 // set gobject values
714 this.el.x_align = Clutter.ActorAlign.START;
715 this.el.x_expand = true;
716 this.el.y_align = Clutter.ActorAlign.START;
717 this.el.y_expand = true;
720 // user defined functions
723 public class Xcls_folderfile : Object
725 public Clutter.Text el;
726 private Xcls_ClutterFiles _this;
730 public string filepath;
733 public Xcls_folderfile(Xcls_ClutterFiles _owner , string filepath)
736 this.el = new Clutter.Text.full("Sans 10px", GLib.Path.get_basename(filepath), Clutter.Color.from_string("#fff"));
740 // set gobject values
741 this.el.x_align = Clutter.ActorAlign.START;
742 this.el.x_expand = true;
743 this.el.y_align = Clutter.ActorAlign.START;
744 this.el.y_expand = true;
749 this.filepath = filepath;
753 this.el.button_press_event.connect( ( event) => {
754 // _this.open(this.filepath);
757 this.el.enter_event.connect( ( event) => {
758 this.el.background_color = Clutter.Color.from_string("#333");
761 this.el.leave_event.connect( ( event) => {
762 this.el.background_color = Clutter.Color.from_string("#000");
767 // user defined functions