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 Clutter.ScrollMode scroll_mode;
25 public Gdk.Pixbuf missing_thumb_pixbuf;
26 public signal void open (JsRender.JsRender file);
27 public Gee.ArrayList<Object> fileitems;
30 public Xcls_ClutterFiles()
33 this.el = new Clutter.Actor();
36 this.scroll_mode = Clutter.ScrollMode.VERTICALLY;
37 this.missing_thumb_pixbuf = null;
38 this.fileitems = new Gee.ArrayList<Object>();
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 // file items contains a reference until we reload ...
71 this.fileitems = new Gee.ArrayList<Object>();
75 var fiter = pr.sortedFiles().list_iterator();
76 while (fiter.next()) {
77 var a = new Xcls_fileitem(this,fiter.get());
78 this.fileitems.add(a);
81 print("add to clutter file view: " + fiter.get().name + "\n");
82 this.filelayout.el.add_child(a.el);
87 if (!(pr is Project.Gtk)) {
90 var gpr = (Project.Gtk)pr;
91 var def = gpr.compilegroups.get("_default_");
92 var items = def.sources;
96 for(var i =0 ; i < items.size; i++) {
98 var files = gpr.files(items.get(i));
103 // add the directory... items.get(i);
104 var x = new Xcls_folderitem(this,items.get(i));
108 for(var j =0 ; j < files.size; j++) {
111 // add file to files.get(j);
116 //this.el.set_value(citer, 1, items.get(i) );
118 this.el.set_sort_column_id(0,Gtk.SortType.ASCENDING);
124 public void set_size (float w, float h)
127 // called by window resize... with is alreaddy -50 (for the buttons?)
130 if (this.el == null) {
131 print("object not ready yet?");
134 _this.filelayout_manager.el.max_column_width = w - 75;
137 // this.el.get_stage().width-150,
139 h // this.el.get_stage().height
142 // 100 right for buttons ..
143 this.el.set_position(0,0);
146 this.scoller.el.set_size(
147 // this.el.get_stage().width-150,
149 h // this.el.get_stage().height
152 // 100 right for buttons ..
153 this.scoller.el.set_position(75,50);
155 public class Xcls_project_title : Object
157 public Clutter.Actor el;
158 private Xcls_ClutterFiles _this;
164 public Xcls_project_title(Xcls_ClutterFiles _owner )
167 _this.project_title = this;
168 this.el = new Clutter.Actor();
172 // set gobject values
173 this.el.reactive = true;
174 var child_0 = new Xcls_project_title_manager( _this );
176 this.el.layout_manager = child_0.el;
177 var child_1 = new Xcls_FixedLayout4( _this );
179 this.el.layout_manager = child_1.el;
180 var child_2 = new Xcls_project_title_name( _this );
182 this.el.add_child ( child_2.el );
183 var child_3 = new Xcls_project_title_path( _this );
185 this.el.add_child ( child_3.el );
189 this.el.add_constraint(
190 new Clutter.BindConstraint(_this.el,Clutter.BindCoordinate.SIZE, 0.0f)
192 this.el.set_position(75,0);
195 // user defined functions
197 public class Xcls_project_title_manager : Object
199 public Clutter.FlowLayout el;
200 private Xcls_ClutterFiles _this;
206 public Xcls_project_title_manager(Xcls_ClutterFiles _owner )
209 _this.project_title_manager = this;
210 this.el = new Clutter.FlowLayout( Clutter.FlowOrientation.HORIZONTAL );
214 // set gobject values
215 this.el.homogeneous = false;
216 this.el.row_spacing = 5f;
217 this.el.column_spacing = 20f;
220 // user defined functions
223 public class Xcls_FixedLayout4 : Object
225 public Clutter.FixedLayout el;
226 private Xcls_ClutterFiles _this;
232 public Xcls_FixedLayout4(Xcls_ClutterFiles _owner )
235 this.el = new Clutter.FixedLayout();
239 // set gobject values
242 // user defined functions
245 public class Xcls_project_title_name : Object
247 public Clutter.Text el;
248 private Xcls_ClutterFiles _this;
254 public Xcls_project_title_name(Xcls_ClutterFiles _owner )
257 _this.project_title_name = this;
258 this.el = new Clutter.Text.full("Sans 20px", "", Clutter.Color.from_string("#eee"));
262 // set gobject values
265 this.el.x_expand = false;
268 // user defined functions
271 public class Xcls_project_title_path : Object
273 public Clutter.Text el;
274 private Xcls_ClutterFiles _this;
280 public Xcls_project_title_path(Xcls_ClutterFiles _owner )
283 _this.project_title_path = this;
284 this.el = new Clutter.Text.full("Sans 10px", "", Clutter.Color.from_string("#ccc"));
288 // set gobject values
293 // user defined functions
297 public class Xcls_scoller : Object
299 public Clutter.ScrollActor el;
300 private Xcls_ClutterFiles _this;
304 public Gee.ArrayList<Xcls_fileitem> fileitems;
305 public Gdk.Pixbuf missing_thumb_pixbuf;
308 public Xcls_scoller(Xcls_ClutterFiles _owner )
311 _this.scoller = this;
312 this.el = new Clutter.ScrollActor();
315 this.fileitems = new Gee.ArrayList<Xcls_fileitem>();
316 this.missing_thumb_pixbuf = null;
318 // set gobject values
319 this.el.scroll_mode = Clutter.ScrollMode.VERTICALLY;
320 this.el.reactive = true;
321 var child_0 = new Xcls_filelayout( _this );
323 this.el.add_child ( child_0.el );
326 this.el.scroll_event.connect( ( event) => {
327 //Sprint("scroll event");
328 var y = _this.filelayout.el.y;
329 var dir = event.direction;
331 case Clutter.ScrollDirection.UP:
334 case Clutter.ScrollDirection.DOWN:
340 // range of scroll -- can go up -- eg.. -ve value.
344 // to work out the max -ve number
345 // height of filelayout
346 // height of scrollactor..
348 var last_child_bottom = _this.filelayout.el.last_child.y + _this.filelayout.el.last_child.height;
349 if ( (-1 * (y+200)) > ( last_child_bottom - this.el.height)) {
356 // print("\nlast child - this height = %f ==== new y %f\n ".printf(
357 // last_child_bottom - this.el.height,
359 // y = float.min(0, y); //??
360 // print("scroll event of %f - new y = %f ".printf(event.y, y));
361 _this.filelayout.el.y = y;
367 // user defined functions
369 public class Xcls_filelayout : Object
371 public Clutter.Actor el;
372 private Xcls_ClutterFiles _this;
378 public Xcls_filelayout(Xcls_ClutterFiles _owner )
381 _this.filelayout = this;
382 this.el = new Clutter.Actor();
386 // set gobject values
387 this.el.reactive = true;
388 var child_0 = new Xcls_filelayout_manager( _this );
390 this.el.layout_manager = child_0.el;
394 this.el.add_constraint(
395 new Clutter.BindConstraint(_this.el,Clutter.BindCoordinate.SIZE, 0.0f)
399 // user defined functions
401 public class Xcls_filelayout_manager : Object
403 public Clutter.FlowLayout el;
404 private Xcls_ClutterFiles _this;
410 public Xcls_filelayout_manager(Xcls_ClutterFiles _owner )
413 _this.filelayout_manager = this;
414 this.el = new Clutter.FlowLayout( Clutter.FlowOrientation.HORIZONTAL );
418 // set gobject values
419 this.el.homogeneous = true;
420 this.el.row_spacing = 20f;
421 this.el.column_spacing = 20f;
424 // user defined functions
427 public class Xcls_fileitem : Object
429 public Clutter.Actor el;
430 private Xcls_ClutterFiles _this;
434 public JsRender.JsRender file;
435 public Xcls_image image;
436 public Xcls_typetitle typetitle;
437 public Xcls_title title;
440 public Xcls_fileitem(Xcls_ClutterFiles _owner , JsRender.JsRender file)
443 this.el = new Clutter.Actor();
447 // set gobject values
448 this.el.reactive = true;
449 var child_0 = new Xcls_BoxLayout11( _this );
451 this.el.layout_manager = child_0.el;
452 var child_1 = new Xcls_image( _this ,file);
454 this.el.add_child ( child_1.el );
455 this.image = child_1;
456 var child_2 = new Xcls_typetitle( _this ,file);
458 this.el.add_child ( child_2.el );
459 this.typetitle = child_2;
460 var child_3 = new Xcls_title( _this ,file);
462 this.el.add_child ( child_3.el );
463 this.title = child_3;
468 this.el.set_size(100,100);
471 this.el.button_press_event.connect( ( event) => {
472 _this.open(this.file);
475 this.el.enter_event.connect( ( event) => {
476 this.el.background_color = Clutter.Color.from_string("#333");
479 this.el.leave_event.connect( ( event) => {
480 this.el.background_color = Clutter.Color.from_string("#000");
485 // user defined functions
487 public class Xcls_BoxLayout11 : Object
489 public Clutter.BoxLayout el;
490 private Xcls_ClutterFiles _this;
496 public Xcls_BoxLayout11(Xcls_ClutterFiles _owner )
499 this.el = new Clutter.BoxLayout();
503 // set gobject values
505 this.el.orientation = Clutter.Orientation.VERTICAL;
508 // user defined functions
511 public class Xcls_image : Object
513 public Clutter.Actor el;
514 private Xcls_ClutterFiles _this;
520 public Xcls_image(Xcls_ClutterFiles _owner , JsRender.JsRender file)
523 this.el = new Clutter.Actor();
527 // set gobject values
528 this.el.margin_right = 5f;
529 this.el.margin_left = 5f;
530 this.el.x_align = Clutter.ActorAlign.START;
531 this.el.x_expand = true;
532 this.el.y_align = Clutter.ActorAlign.START;
533 this.el.margin_top = 5f;
534 this.el.y_expand = true;
539 Gdk.Pixbuf pixbuf= null;
541 var fname = file.getIconFileName(false);
544 if (FileUtils.test(fname, FileTest.EXISTS)) {
545 pixbuf = new Gdk.Pixbuf.from_file(fname);
551 if (pixbuf == null) {
554 if (_this.missing_thumb_pixbuf == null) {
555 var icon_theme = Gtk.IconTheme.get_default ();
556 _this.missing_thumb_pixbuf = icon_theme.load_icon ("package-x-generic", 92, 0);
557 _this.missing_thumb_pixbuf.ref();
559 pixbuf = _this.missing_thumb_pixbuf;
566 var img = new Clutter.Image();
567 img.set_data(pixbuf.get_pixels(),
569 ? Cogl.PixelFormat.RGBA_8888
570 : Cogl.PixelFormat.RGB_888,
572 pixbuf.get_height (),
573 pixbuf.get_rowstride ()
575 this.el.set_content(img);
579 // should probably do smarter scaling...
582 this.el.set_size(90, 70);
586 // user defined functions
589 public class Xcls_typetitle : Object
591 public Clutter.Text el;
592 private Xcls_ClutterFiles _this;
598 public Xcls_typetitle(Xcls_ClutterFiles _owner , JsRender.JsRender file)
601 this.el = new Clutter.Text.full("Sans 10px", file.nickType(), Clutter.Color.from_string("#fff"));
605 // set gobject values
606 this.el.x_align = Clutter.ActorAlign.START;
607 this.el.x_expand = true;
608 this.el.y_align = Clutter.ActorAlign.START;
609 this.el.y_expand = true;
612 // user defined functions
615 public class Xcls_title : Object
617 public Clutter.Text el;
618 private Xcls_ClutterFiles _this;
624 public Xcls_title(Xcls_ClutterFiles _owner , JsRender.JsRender file)
627 this.el = new Clutter.Text.full("Sans 10px", file.nickName(), Clutter.Color.from_string("#fff"));
631 // set gobject values
632 this.el.x_align = Clutter.ActorAlign.START;
633 this.el.x_expand = true;
634 this.el.y_align = Clutter.ActorAlign.START;
635 this.el.y_expand = true;
638 // user defined functions
642 public class Xcls_folderitem : Object
644 public Clutter.Actor el;
645 private Xcls_ClutterFiles _this;
649 public Xcls_foldertitle foldertitle;
652 public Xcls_folderitem(Xcls_ClutterFiles _owner , string folderpath)
655 this.el = new Clutter.Actor();
659 // set gobject values
660 this.el.reactive = true;
661 var child_0 = new Xcls_BoxLayout16( _this );
663 this.el.layout_manager = child_0.el;
664 var child_1 = new Xcls_foldertitle( _this ,folderpath);
666 this.el.add_child ( child_1.el );
667 this.foldertitle = child_1;
671 //this.el.set_size(100,100);
674 // user defined functions
676 public class Xcls_BoxLayout16 : Object
678 public Clutter.BoxLayout el;
679 private Xcls_ClutterFiles _this;
685 public Xcls_BoxLayout16(Xcls_ClutterFiles _owner )
688 this.el = new Clutter.BoxLayout();
692 // set gobject values
694 this.el.orientation = Clutter.Orientation.VERTICAL;
697 // user defined functions
700 public class Xcls_foldertitle : Object
702 public Clutter.Text el;
703 private Xcls_ClutterFiles _this;
709 public Xcls_foldertitle(Xcls_ClutterFiles _owner , string folderpath)
712 this.el = new Clutter.Text.full("Sans 14px", GLib.Path.get_basename(folderpath), Clutter.Color.from_string("#fff"));
716 // set gobject values
717 this.el.x_align = Clutter.ActorAlign.START;
718 this.el.x_expand = true;
719 this.el.y_align = Clutter.ActorAlign.START;
720 this.el.y_expand = true;
723 // user defined functions
726 public class Xcls_folderfile : Object
728 public Clutter.Text el;
729 private Xcls_ClutterFiles _this;
733 public string filepath;
736 public Xcls_folderfile(Xcls_ClutterFiles _owner , string filepath)
739 this.el = new Clutter.Text.full("Sans 10px", GLib.Path.get_basename(filepath), Clutter.Color.from_string("#fff"));
743 // set gobject values
744 this.el.x_align = Clutter.ActorAlign.START;
745 this.el.x_expand = true;
746 this.el.y_align = Clutter.ActorAlign.START;
747 this.el.y_expand = true;
752 this.filepath = filepath;
756 this.el.button_press_event.connect( ( event) => {
757 // _this.open(this.filepath);
760 this.el.enter_event.connect( ( event) => {
761 this.el.background_color = Clutter.Color.from_string("#333");
764 this.el.leave_event.connect( ( event) => {
765 this.el.background_color = Clutter.Color.from_string("#000");
770 // user defined functions