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_scroller scroller;
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_scroller( _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)) {
88 print ("not gtk... skipping files");
91 var gpr = (Project.Gtk)pr;
92 var def = gpr.compilegroups.get("_default_");
93 var items = def.sources;
97 for(var i =0 ; i < items.size; i++) {
98 print ("cheking folder %s\n", items.get(i));
99 var files = gpr.files(items.get(i));
100 if (files.size < 1) {
104 // add the directory... items.get(i);
105 var x = new Xcls_folderitem(this,items.get(i));
106 this.fileitems.add(x);
107 this.filelayout.el.add_child(x.el);
109 for(var j =0 ; j < files.size; j++) {
110 print ("adding file %s\n", files.get(j));
112 var y = new Xcls_folderfile(this, files.get(j));
113 this.fileitems.add(y);
114 x.el.add_child(y.el);
116 // add file to files.get(j);
121 //this.el.set_value(citer, 1, items.get(i) );
128 public void set_size (float w, float h)
131 // called by window resize... with is alreaddy -50 (for the buttons?)
134 if (this.el == null) {
135 print("object not ready yet?");
138 //_this.filelayout_manager.el.max_column_width = w - 200;
139 _this.filelayout_manager.el.width = w - 200;
142 // this.el.get_stage().width-150,
144 h // this.el.get_stage().height
147 // 100 right for buttons ..
148 this.el.set_position(0,0);
151 this.scroller.el.set_size(
152 // this.el.get_stage().width-150,
154 h // this.el.get_stage().height
157 // 100 right for buttons ..
158 this.scroller.el.set_position(75,50);
160 public class Xcls_project_title : Object
162 public Clutter.Actor el;
163 private Xcls_ClutterFiles _this;
169 public Xcls_project_title(Xcls_ClutterFiles _owner )
172 _this.project_title = this;
173 this.el = new Clutter.Actor();
177 // set gobject values
178 this.el.reactive = true;
179 var child_0 = new Xcls_project_title_manager( _this );
181 this.el.layout_manager = child_0.el;
182 var child_1 = new Xcls_FixedLayout4( _this );
184 this.el.layout_manager = child_1.el;
185 var child_2 = new Xcls_project_title_name( _this );
187 this.el.add_child ( child_2.el );
188 var child_3 = new Xcls_project_title_path( _this );
190 this.el.add_child ( child_3.el );
194 this.el.add_constraint(
195 new Clutter.BindConstraint(_this.el,Clutter.BindCoordinate.SIZE, 0.0f)
197 this.el.set_position(75,0);
200 // user defined functions
202 public class Xcls_project_title_manager : Object
204 public Clutter.FlowLayout el;
205 private Xcls_ClutterFiles _this;
211 public Xcls_project_title_manager(Xcls_ClutterFiles _owner )
214 _this.project_title_manager = this;
215 this.el = new Clutter.FlowLayout( Clutter.FlowOrientation.HORIZONTAL );
219 // set gobject values
220 this.el.homogeneous = false;
221 this.el.row_spacing = 5f;
222 this.el.column_spacing = 20f;
225 // user defined functions
228 public class Xcls_FixedLayout4 : Object
230 public Clutter.FixedLayout el;
231 private Xcls_ClutterFiles _this;
237 public Xcls_FixedLayout4(Xcls_ClutterFiles _owner )
240 this.el = new Clutter.FixedLayout();
244 // set gobject values
247 // user defined functions
250 public class Xcls_project_title_name : Object
252 public Clutter.Text el;
253 private Xcls_ClutterFiles _this;
259 public Xcls_project_title_name(Xcls_ClutterFiles _owner )
262 _this.project_title_name = this;
263 this.el = new Clutter.Text.full("Sans 20px", "", Clutter.Color.from_string("#eee"));
267 // set gobject values
270 this.el.x_expand = false;
273 // user defined functions
276 public class Xcls_project_title_path : Object
278 public Clutter.Text el;
279 private Xcls_ClutterFiles _this;
285 public Xcls_project_title_path(Xcls_ClutterFiles _owner )
288 _this.project_title_path = this;
289 this.el = new Clutter.Text.full("Sans 10px", "", Clutter.Color.from_string("#ccc"));
293 // set gobject values
298 // user defined functions
302 public class Xcls_scroller : Object
304 public Clutter.ScrollActor el;
305 private Xcls_ClutterFiles _this;
309 public Gee.ArrayList<Xcls_fileitem> fileitems;
310 public Gdk.Pixbuf missing_thumb_pixbuf;
313 public Xcls_scroller(Xcls_ClutterFiles _owner )
316 _this.scroller = this;
317 this.el = new Clutter.ScrollActor();
320 this.fileitems = new Gee.ArrayList<Xcls_fileitem>();
321 this.missing_thumb_pixbuf = null;
323 // set gobject values
324 this.el.scroll_mode = Clutter.ScrollMode.VERTICALLY;
325 this.el.reactive = true;
326 var child_0 = new Xcls_filelayout( _this );
328 this.el.add_child ( child_0.el );
331 this.el.scroll_event.connect( ( event) => {
332 //Sprint("scroll event");
333 var y = _this.filelayout.el.y;
334 var dir = event.direction;
336 case Clutter.ScrollDirection.UP:
339 case Clutter.ScrollDirection.DOWN:
345 // range of scroll -- can go up -- eg.. -ve value.
349 // to work out the max -ve number
350 // height of filelayout
351 // height of scrollactor..
353 var last_child_bottom = _this.filelayout.el.last_child.y + _this.filelayout.el.last_child.height;
354 if ( (-1 * (y+200)) > ( last_child_bottom - this.el.height)) {
361 // print("\nlast child - this height = %f ==== new y %f\n ".printf(
362 // last_child_bottom - this.el.height,
364 // y = float.min(0, y); //??
365 // print("scroll event of %f - new y = %f ".printf(event.y, y));
366 _this.filelayout.el.y = y;
372 // user defined functions
374 public class Xcls_filelayout : Object
376 public Clutter.Actor el;
377 private Xcls_ClutterFiles _this;
383 public Xcls_filelayout(Xcls_ClutterFiles _owner )
386 _this.filelayout = this;
387 this.el = new Clutter.Actor();
391 // set gobject values
392 this.el.reactive = true;
393 var child_0 = new Xcls_filelayout_manager( _this );
395 this.el.layout_manager = child_0.el;
399 this.el.add_constraint(
400 new Clutter.BindConstraint(_this.el,Clutter.BindCoordinate.SIZE, 0.0f)
404 // user defined functions
406 public class Xcls_filelayout_manager : Object
408 public Clutter.FlowLayout el;
409 private Xcls_ClutterFiles _this;
415 public Xcls_filelayout_manager(Xcls_ClutterFiles _owner )
418 _this.filelayout_manager = this;
419 this.el = new Clutter.FlowLayout( Clutter.FlowOrientation.HORIZONTAL );
423 // set gobject values
424 this.el.homogeneous = true;
425 this.el.max_column_width = 120f;
426 this.el.row_spacing = 20f;
427 this.el.column_spacing = 20f;
430 // user defined functions
433 public class Xcls_fileitem : Object
435 public Clutter.Actor el;
436 private Xcls_ClutterFiles _this;
440 public JsRender.JsRender file;
441 public Xcls_image image;
442 public Xcls_typetitle typetitle;
443 public Xcls_title title;
446 public Xcls_fileitem(Xcls_ClutterFiles _owner , JsRender.JsRender file)
449 this.el = new Clutter.Actor();
453 // set gobject values
454 this.el.reactive = true;
455 var child_0 = new Xcls_BoxLayout11( _this );
457 this.el.layout_manager = child_0.el;
458 var child_1 = new Xcls_image( _this ,file);
460 this.el.add_child ( child_1.el );
461 this.image = child_1;
462 var child_2 = new Xcls_typetitle( _this ,file);
464 this.el.add_child ( child_2.el );
465 this.typetitle = child_2;
466 var child_3 = new Xcls_title( _this ,file);
468 this.el.add_child ( child_3.el );
469 this.title = child_3;
474 this.el.set_size(100,100);
477 this.el.button_press_event.connect( ( event) => {
478 _this.open(this.file);
481 this.el.enter_event.connect( ( event) => {
482 this.el.background_color = Clutter.Color.from_string("#333");
485 this.el.leave_event.connect( ( event) => {
486 this.el.background_color = Clutter.Color.from_string("#000");
491 // user defined functions
493 public class Xcls_BoxLayout11 : Object
495 public Clutter.BoxLayout el;
496 private Xcls_ClutterFiles _this;
502 public Xcls_BoxLayout11(Xcls_ClutterFiles _owner )
505 this.el = new Clutter.BoxLayout();
509 // set gobject values
511 this.el.orientation = Clutter.Orientation.VERTICAL;
514 // user defined functions
517 public class Xcls_image : Object
519 public Clutter.Actor el;
520 private Xcls_ClutterFiles _this;
526 public Xcls_image(Xcls_ClutterFiles _owner , JsRender.JsRender file)
529 this.el = new Clutter.Actor();
533 // set gobject values
534 this.el.margin_right = 5f;
535 this.el.margin_left = 5f;
536 this.el.x_align = Clutter.ActorAlign.START;
537 this.el.x_expand = false;
538 this.el.y_align = Clutter.ActorAlign.START;
539 this.el.margin_top = 5f;
540 this.el.y_expand = false;
545 Gdk.Pixbuf pixbuf= null;
547 var fname = file.getIconFileName(false);
550 if (FileUtils.test(fname, FileTest.EXISTS)) {
551 pixbuf = new Gdk.Pixbuf.from_file(fname);
557 if (pixbuf == null) {
560 if (_this.missing_thumb_pixbuf == null) {
561 var icon_theme = Gtk.IconTheme.get_default ();
562 _this.missing_thumb_pixbuf = icon_theme.load_icon ("package-x-generic", 92, 0);
563 _this.missing_thumb_pixbuf.ref();
565 pixbuf = _this.missing_thumb_pixbuf;
572 var img = new Clutter.Image();
573 img.set_data(pixbuf.get_pixels(),
575 ? Cogl.PixelFormat.RGBA_8888
576 : Cogl.PixelFormat.RGB_888,
578 pixbuf.get_height (),
579 pixbuf.get_rowstride ()
581 this.el.set_content(img);
585 // should probably do smarter scaling...
588 this.el.set_size(90, 70);
592 // user defined functions
595 public class Xcls_typetitle : Object
597 public Clutter.Text el;
598 private Xcls_ClutterFiles _this;
604 public Xcls_typetitle(Xcls_ClutterFiles _owner , JsRender.JsRender file)
607 this.el = new Clutter.Text.full("Sans 10px", file.nickType(), Clutter.Color.from_string("#fff"));
611 // set gobject values
612 this.el.x_align = Clutter.ActorAlign.START;
613 this.el.x_expand = false;
614 this.el.y_align = Clutter.ActorAlign.START;
615 this.el.y_expand = false;
618 // user defined functions
621 public class Xcls_title : Object
623 public Clutter.Text el;
624 private Xcls_ClutterFiles _this;
630 public Xcls_title(Xcls_ClutterFiles _owner , JsRender.JsRender file)
633 this.el = new Clutter.Text.full("Sans 10px", file.nickName(), Clutter.Color.from_string("#fff"));
637 // set gobject values
638 this.el.x_align = Clutter.ActorAlign.START;
639 this.el.x_expand = false;
640 this.el.y_align = Clutter.ActorAlign.START;
641 this.el.y_expand = false;
644 // user defined functions
648 public class Xcls_folderitem : Object
650 public Clutter.Actor el;
651 private Xcls_ClutterFiles _this;
655 public Xcls_foldertitle foldertitle;
658 public Xcls_folderitem(Xcls_ClutterFiles _owner , string folderpath)
661 this.el = new Clutter.Actor();
665 // set gobject values
666 this.el.reactive = true;
667 var child_0 = new Xcls_BoxLayout16( _this );
669 this.el.layout_manager = child_0.el;
670 var child_1 = new Xcls_foldertitle( _this ,folderpath);
672 this.el.add_child ( child_1.el );
673 this.foldertitle = child_1;
677 //this.el.set_size(100,100);
680 // user defined functions
682 public class Xcls_BoxLayout16 : Object
684 public Clutter.BoxLayout el;
685 private Xcls_ClutterFiles _this;
691 public Xcls_BoxLayout16(Xcls_ClutterFiles _owner )
694 this.el = new Clutter.BoxLayout();
698 // set gobject values
700 this.el.orientation = Clutter.Orientation.VERTICAL;
703 // user defined functions
706 public class Xcls_foldertitle : Object
708 public Clutter.Text el;
709 private Xcls_ClutterFiles _this;
715 public Xcls_foldertitle(Xcls_ClutterFiles _owner , string folderpath)
718 this.el = new Clutter.Text.full("Sans 14px", GLib.Path.get_basename(folderpath), Clutter.Color.from_string("#fff"));
722 // set gobject values
723 this.el.x_align = Clutter.ActorAlign.START;
724 this.el.x_expand = true;
725 this.el.y_align = Clutter.ActorAlign.START;
726 this.el.y_expand = false;
729 // user defined functions
732 public class Xcls_folderfile : Object
734 public Clutter.Text el;
735 private Xcls_ClutterFiles _this;
739 public string filepath;
742 public Xcls_folderfile(Xcls_ClutterFiles _owner , string filepath)
745 this.el = new Clutter.Text.full("Sans 10px", GLib.Path.get_basename(filepath), Clutter.Color.from_string("#fff"));
749 // set gobject values
750 this.el.x_align = Clutter.ActorAlign.START;
751 this.el.x_expand = true;
752 this.el.y_align = Clutter.ActorAlign.START;
753 this.el.reactive = true;
754 this.el.y_expand = false;
759 this.filepath = filepath;
763 this.el.button_press_event.connect( ( event) => {
764 // _this.open(this.filepath);
767 this.el.enter_event.connect( ( event) => {
768 this.el.background_color = Clutter.Color.from_string("#333");
771 this.el.leave_event.connect( ( event) => {
772 this.el.background_color = Clutter.Color.from_string("#000");
777 // user defined functions