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);
91 public void set_size (float w, float h)
94 // called by window resize... with is alreaddy -50 (for the buttons?)
97 if (this.el == null) {
98 print("object not ready yet?");
101 _this.filelayout_manager.el.max_column_width = w - 75;
104 // this.el.get_stage().width-150,
106 h // this.el.get_stage().height
109 // 100 right for buttons ..
110 this.el.set_position(0,0);
113 this.scoller.el.set_size(
114 // this.el.get_stage().width-150,
116 h // this.el.get_stage().height
119 // 100 right for buttons ..
120 this.scoller.el.set_position(75,50);
122 public class Xcls_project_title : Object
124 public Clutter.Actor el;
125 private Xcls_ClutterFiles _this;
131 public Xcls_project_title(Xcls_ClutterFiles _owner )
134 _this.project_title = this;
135 this.el = new Clutter.Actor();
139 // set gobject values
140 this.el.reactive = true;
141 var child_0 = new Xcls_project_title_manager( _this );
143 this.el.layout_manager = child_0.el;
144 var child_1 = new Xcls_FixedLayout4( _this );
146 this.el.layout_manager = child_1.el;
147 var child_2 = new Xcls_project_title_name( _this );
149 this.el.add_child ( child_2.el );
150 var child_3 = new Xcls_project_title_path( _this );
152 this.el.add_child ( child_3.el );
156 this.el.add_constraint(
157 new Clutter.BindConstraint(_this.el,Clutter.BindCoordinate.SIZE, 0.0f)
159 this.el.set_position(75,0);
162 // user defined functions
164 public class Xcls_project_title_manager : Object
166 public Clutter.FlowLayout el;
167 private Xcls_ClutterFiles _this;
173 public Xcls_project_title_manager(Xcls_ClutterFiles _owner )
176 _this.project_title_manager = this;
177 this.el = new Clutter.FlowLayout( Clutter.FlowOrientation.HORIZONTAL );
181 // set gobject values
182 this.el.homogeneous = false;
183 this.el.row_spacing = 5f;
184 this.el.column_spacing = 20f;
187 // user defined functions
190 public class Xcls_FixedLayout4 : Object
192 public Clutter.FixedLayout el;
193 private Xcls_ClutterFiles _this;
199 public Xcls_FixedLayout4(Xcls_ClutterFiles _owner )
202 this.el = new Clutter.FixedLayout();
206 // set gobject values
209 // user defined functions
212 public class Xcls_project_title_name : Object
214 public Clutter.Text el;
215 private Xcls_ClutterFiles _this;
221 public Xcls_project_title_name(Xcls_ClutterFiles _owner )
224 _this.project_title_name = this;
225 this.el = new Clutter.Text.full("Sans 20px", "", Clutter.Color.from_string("#eee"));
229 // set gobject values
232 this.el.x_expand = false;
235 // user defined functions
238 public class Xcls_project_title_path : Object
240 public Clutter.Text el;
241 private Xcls_ClutterFiles _this;
247 public Xcls_project_title_path(Xcls_ClutterFiles _owner )
250 _this.project_title_path = this;
251 this.el = new Clutter.Text.full("Sans 10px", "", Clutter.Color.from_string("#ccc"));
255 // set gobject values
260 // user defined functions
264 public class Xcls_scoller : Object
266 public Clutter.ScrollActor el;
267 private Xcls_ClutterFiles _this;
271 public Gee.ArrayList<Xcls_fileitem> fileitems;
272 public Gdk.Pixbuf missing_thumb_pixbuf;
275 public Xcls_scoller(Xcls_ClutterFiles _owner )
278 _this.scoller = this;
279 this.el = new Clutter.ScrollActor();
282 this.fileitems = new Gee.ArrayList<Xcls_fileitem>();
283 this.missing_thumb_pixbuf = null;
285 // set gobject values
286 this.el.scroll_mode = Clutter.ScrollMode.VERTICALLY;
287 this.el.reactive = true;
288 var child_0 = new Xcls_filelayout( _this );
290 this.el.add_child ( child_0.el );
293 this.el.scroll_event.connect( ( event) => {
294 //Sprint("scroll event");
295 var y = _this.filelayout.el.y;
296 var dir = event.direction;
298 case Clutter.ScrollDirection.UP:
301 case Clutter.ScrollDirection.DOWN:
307 // range of scroll -- can go up -- eg.. -ve value.
311 // to work out the max -ve number
312 // height of filelayout
313 // height of scrollactor..
315 var last_child_bottom = _this.filelayout.el.last_child.y + _this.filelayout.el.last_child.height;
316 if ( (-1 * (y+200)) > ( last_child_bottom - this.el.height)) {
323 // print("\nlast child - this height = %f ==== new y %f\n ".printf(
324 // last_child_bottom - this.el.height,
326 // y = float.min(0, y); //??
327 // print("scroll event of %f - new y = %f ".printf(event.y, y));
328 _this.filelayout.el.y = y;
334 // user defined functions
336 public class Xcls_filelayout : Object
338 public Clutter.Actor el;
339 private Xcls_ClutterFiles _this;
345 public Xcls_filelayout(Xcls_ClutterFiles _owner )
348 _this.filelayout = this;
349 this.el = new Clutter.Actor();
353 // set gobject values
354 this.el.reactive = true;
355 var child_0 = new Xcls_filelayout_manager( _this );
357 this.el.layout_manager = child_0.el;
361 this.el.add_constraint(
362 new Clutter.BindConstraint(_this.el,Clutter.BindCoordinate.SIZE, 0.0f)
366 // user defined functions
368 public class Xcls_filelayout_manager : Object
370 public Clutter.FlowLayout el;
371 private Xcls_ClutterFiles _this;
377 public Xcls_filelayout_manager(Xcls_ClutterFiles _owner )
380 _this.filelayout_manager = this;
381 this.el = new Clutter.FlowLayout( Clutter.FlowOrientation.HORIZONTAL );
385 // set gobject values
386 this.el.homogeneous = true;
387 this.el.row_spacing = 20f;
388 this.el.column_spacing = 20f;
391 // user defined functions
394 public class Xcls_fileitem : Object
396 public Clutter.Actor el;
397 private Xcls_ClutterFiles _this;
401 public JsRender.JsRender file;
402 public Xcls_image image;
403 public Xcls_typetitle typetitle;
404 public Xcls_title title;
407 public Xcls_fileitem(Xcls_ClutterFiles _owner , JsRender.JsRender file)
410 this.el = new Clutter.Actor();
414 // set gobject values
415 this.el.reactive = true;
416 var child_0 = new Xcls_BoxLayout11( _this );
418 this.el.layout_manager = child_0.el;
419 var child_1 = new Xcls_image( _this ,file);
421 this.el.add_child ( child_1.el );
422 this.image = child_1;
423 var child_2 = new Xcls_typetitle( _this ,file);
425 this.el.add_child ( child_2.el );
426 this.typetitle = child_2;
427 var child_3 = new Xcls_title( _this ,file);
429 this.el.add_child ( child_3.el );
430 this.title = child_3;
435 this.el.set_size(100,100);
438 this.el.button_press_event.connect( ( event) => {
439 _this.open(this.file);
442 this.el.enter_event.connect( ( event) => {
443 this.el.background_color = Clutter.Color.from_string("#333");
446 this.el.leave_event.connect( ( event) => {
447 this.el.background_color = Clutter.Color.from_string("#000");
452 // user defined functions
454 public class Xcls_BoxLayout11 : Object
456 public Clutter.BoxLayout el;
457 private Xcls_ClutterFiles _this;
463 public Xcls_BoxLayout11(Xcls_ClutterFiles _owner )
466 this.el = new Clutter.BoxLayout();
470 // set gobject values
472 this.el.orientation = Clutter.Orientation.VERTICAL;
475 // user defined functions
478 public class Xcls_image : Object
480 public Clutter.Actor el;
481 private Xcls_ClutterFiles _this;
487 public Xcls_image(Xcls_ClutterFiles _owner , JsRender.JsRender file)
490 this.el = new Clutter.Actor();
494 // set gobject values
495 this.el.margin_right = 5f;
496 this.el.margin_left = 5f;
497 this.el.x_align = Clutter.ActorAlign.START;
498 this.el.x_expand = true;
499 this.el.y_align = Clutter.ActorAlign.START;
500 this.el.margin_top = 5f;
501 this.el.y_expand = true;
506 Gdk.Pixbuf pixbuf= null;
508 var fname = file.getIconFileName(false);
511 if (FileUtils.test(fname, FileTest.EXISTS)) {
512 pixbuf = new Gdk.Pixbuf.from_file(fname);
518 if (pixbuf == null) {
521 if (_this.missing_thumb_pixbuf == null) {
522 var icon_theme = Gtk.IconTheme.get_default ();
523 _this.missing_thumb_pixbuf = icon_theme.load_icon ("package-x-generic", 92, 0);
524 _this.missing_thumb_pixbuf.ref();
526 pixbuf = _this.missing_thumb_pixbuf;
533 var img = new Clutter.Image();
534 img.set_data(pixbuf.get_pixels(),
536 ? Cogl.PixelFormat.RGBA_8888
537 : Cogl.PixelFormat.RGB_888,
539 pixbuf.get_height (),
540 pixbuf.get_rowstride ()
542 this.el.set_content(img);
546 // should probably do smarter scaling...
549 this.el.set_size(90, 70);
553 // user defined functions
556 public class Xcls_typetitle : Object
558 public Clutter.Text el;
559 private Xcls_ClutterFiles _this;
565 public Xcls_typetitle(Xcls_ClutterFiles _owner , JsRender.JsRender file)
568 this.el = new Clutter.Text.full("Sans 10px", file.nickType(), Clutter.Color.from_string("#fff"));
572 // set gobject values
573 this.el.x_align = Clutter.ActorAlign.START;
574 this.el.x_expand = true;
575 this.el.y_align = Clutter.ActorAlign.START;
576 this.el.y_expand = true;
579 // user defined functions
582 public class Xcls_title : Object
584 public Clutter.Text el;
585 private Xcls_ClutterFiles _this;
591 public Xcls_title(Xcls_ClutterFiles _owner , JsRender.JsRender file)
594 this.el = new Clutter.Text.full("Sans 10px", file.nickName(), Clutter.Color.from_string("#fff"));
598 // set gobject values
599 this.el.x_align = Clutter.ActorAlign.START;
600 this.el.x_expand = true;
601 this.el.y_align = Clutter.ActorAlign.START;
602 this.el.y_expand = true;
605 // user defined functions
609 public class Xcls_folderitem : Object
611 public Clutter.Actor el;
612 private Xcls_ClutterFiles _this;
616 public Xcls_foldertitle foldertitle;
619 public Xcls_folderitem(Xcls_ClutterFiles _owner , string folderpath)
622 this.el = new Clutter.Actor();
626 // set gobject values
627 this.el.reactive = true;
628 var child_0 = new Xcls_BoxLayout16( _this );
630 this.el.layout_manager = child_0.el;
631 var child_1 = new Xcls_foldertitle( _this ,folderpath);
633 this.el.add_child ( child_1.el );
634 this.foldertitle = child_1;
638 //this.el.set_size(100,100);
641 // user defined functions
643 public class Xcls_BoxLayout16 : Object
645 public Clutter.BoxLayout el;
646 private Xcls_ClutterFiles _this;
652 public Xcls_BoxLayout16(Xcls_ClutterFiles _owner )
655 this.el = new Clutter.BoxLayout();
659 // set gobject values
661 this.el.orientation = Clutter.Orientation.VERTICAL;
664 // user defined functions
667 public class Xcls_foldertitle : Object
669 public Clutter.Text el;
670 private Xcls_ClutterFiles _this;
676 public Xcls_foldertitle(Xcls_ClutterFiles _owner , string folderpath)
679 this.el = new Clutter.Text.full("Sans 14px", GLib.Path.get_basename(folderpath), Clutter.Color.from_string("#fff"));
683 // set gobject values
684 this.el.x_align = Clutter.ActorAlign.START;
685 this.el.x_expand = true;
686 this.el.y_align = Clutter.ActorAlign.START;
687 this.el.y_expand = true;
690 // user defined functions
693 public class Xcls_folderfile : Object
695 public Clutter.Text el;
696 private Xcls_ClutterFiles _this;
700 public string filepath;
703 public Xcls_folderfile(Xcls_ClutterFiles _owner , string filepath)
706 this.el = new Clutter.Text.full("Sans 10px", GLib.Path.get_basename(filepath), Clutter.Color.from_string("#fff"));
710 // set gobject values
711 this.el.x_align = Clutter.ActorAlign.START;
712 this.el.x_expand = true;
713 this.el.y_align = Clutter.ActorAlign.START;
714 this.el.y_expand = true;
719 this.filepath = filepath;
723 this.el.button_press_event.connect( ( event) => {
724 // _this.open(this.filepath);
727 this.el.enter_event.connect( ( event) => {
728 this.el.background_color = Clutter.Color.from_string("#333");
731 this.el.leave_event.connect( ( event) => {
732 this.el.background_color = Clutter.Color.from_string("#000");
737 // user defined functions