1 static Xcls_ClutterFiles _ClutterFiles;
3 public class Xcls_ClutterFiles : Object
5 public Clutter.ScrollActor el;
6 private Xcls_ClutterFiles _this;
8 public static Xcls_ClutterFiles singleton()
10 if (_ClutterFiles == null) {
11 _ClutterFiles= new Xcls_ClutterFiles();
15 public Xcls_filelayout filelayout;
16 public Xcls_filelayout_manager filelayout_manager;
19 public Gee.ArrayList<Xcls_fileitem> fileitems;
20 public Gdk.Pixbuf missing_thumb_pixbuf;
21 public signal void open (JsRender.JsRender file);
24 public Xcls_ClutterFiles()
27 this.el = new Clutter.ScrollActor();
30 this.missing_thumb_pixbuf = null;
33 this.el.scroll_mode = Clutter.ScrollMode.VERTICALLY;
34 this.el.reactive = true;
35 var child_0 = new Xcls_filelayout( _this );
37 this.el.add_child ( child_0.el );
41 this.fileitems = new Gee.ArrayList<Xcls_fileitem>();
44 this.el.scroll_event.connect( ( event) => {
45 //Sprint("scroll event");
46 var y = this.filelayout.el.y;
47 var dir = event.direction;
49 case Clutter.ScrollDirection.UP:
52 case Clutter.ScrollDirection.DOWN:
58 // range of scroll -- can go up -- eg.. -ve value.
62 // to work out the max -ve number
63 // height of filelayout
64 // height of scrollactor..
66 var last_child_bottom = this.filelayout.el.last_child.y + this.filelayout.el.last_child.height;
67 if ( (-1 * (y+200)) > ( last_child_bottom - this.el.height)) {
74 // print("\nlast child - this height = %f ==== new y %f\n ".printf(
75 // last_child_bottom - this.el.height,
77 // y = float.min(0, y); //??
78 // print("scroll event of %f - new y = %f ".printf(event.y, y));
79 this.filelayout.el.y = y;
85 // user defined functions
86 public void clearFiles () {
88 this.filelayout.el.remove_all_children();
89 // we need to unref all the chidren that we loaded though...
92 public void loadProject (Project.Project pr) {
93 // list all the files, and create new Xcls_fileitem for each one.
95 // LEAK --- we should unref all the chilren...
96 this.filelayout.el.y = 0;
99 print("clutter files - load project: " + pr.name +"\n");
100 // should unref.. them hopefully.
101 this.fileitems = new Gee.ArrayList<Xcls_fileitem>();
105 var fiter = pr.sortedFiles().list_iterator();
106 while (fiter.next()) {
107 var a = new Xcls_fileitem(this,fiter.get());
108 this.fileitems.add(a);
111 print("add to clutter file view: " + fiter.get().name + "\n");
112 this.filelayout.el.add_child(a.el);
119 public void set_size (float w, float h)
121 if (this.el == null) {
122 print("object not ready yet?");
125 _this.filelayout_manager.el.max_column_width = w - 150;
126 this.el.set_size(this.el.get_stage().width-150,
127 this.el.get_stage().height);
128 this.el.set_position(100,50);
130 public class Xcls_filelayout : Object
132 public Clutter.Actor el;
133 private Xcls_ClutterFiles _this;
139 public Xcls_filelayout(Xcls_ClutterFiles _owner )
142 _this.filelayout = this;
143 this.el = new Clutter.Actor();
147 // set gobject values
148 this.el.reactive = true;
149 var child_0 = new Xcls_filelayout_manager( _this );
151 this.el.layout_manager = child_0.el;
155 this.el.add_constraint(
156 new Clutter.BindConstraint(_this.el,Clutter.BindCoordinate.SIZE, 0.0f)
160 // user defined functions
162 public class Xcls_filelayout_manager : Object
164 public Clutter.FlowLayout el;
165 private Xcls_ClutterFiles _this;
171 public Xcls_filelayout_manager(Xcls_ClutterFiles _owner )
174 _this.filelayout_manager = this;
175 this.el = new Clutter.FlowLayout( Clutter.FlowOrientation.HORIZONTAL );
179 // set gobject values
180 this.el.homogeneous = true;
181 this.el.row_spacing = 20f;
182 this.el.column_spacing = 20f;
185 // user defined functions
187 public class Xcls_fileitem : Object
189 public Clutter.Actor el;
190 private Xcls_ClutterFiles _this;
194 public JsRender.JsRender file;
195 public Xcls_image image;
196 public Xcls_typetitle typetitle;
197 public Xcls_title title;
200 public Xcls_fileitem(Xcls_ClutterFiles _owner , JsRender.JsRender file)
203 this.el = new Clutter.Actor();
207 // set gobject values
208 this.el.reactive = true;
209 var child_0 = new Xcls_BoxLayout5( _this );
211 this.el.layout_manager = child_0.el;
212 var child_1 = new Xcls_image( _this ,file);
214 this.el.add_child ( child_1.el );
215 this.image = child_1;
216 var child_2 = new Xcls_typetitle( _this ,file);
218 this.el.add_child ( child_2.el );
219 this.typetitle = child_2;
220 var child_3 = new Xcls_title( _this ,file);
222 this.el.add_child ( child_3.el );
223 this.title = child_3;
228 this.el.set_size(100,100);
231 this.el.button_press_event.connect( ( event) => {
232 _this.open(this.file);
235 this.el.enter_event.connect( ( event) => {
236 this.el.background_color = new Clutter.Color.from_string("#333");
239 this.el.leave_event.connect( ( event) => {
240 this.el.background_color = new Clutter.Color.from_string("#000");
245 // user defined functions
247 public class Xcls_BoxLayout5 : Object
249 public Clutter.BoxLayout el;
250 private Xcls_ClutterFiles _this;
256 public Xcls_BoxLayout5(Xcls_ClutterFiles _owner )
259 this.el = new Clutter.BoxLayout();
263 // set gobject values
265 this.el.orientation = Clutter.Orientation.VERTICAL;
268 // user defined functions
270 public class Xcls_image : Object
272 public Clutter.Actor el;
273 private Xcls_ClutterFiles _this;
279 public Xcls_image(Xcls_ClutterFiles _owner , JsRender.JsRender file)
282 this.el = new Clutter.Actor();
286 // set gobject values
287 this.el.margin_right = 5f;
288 this.el.margin_left = 5f;
289 this.el.x_align = Clutter.ActorAlign.START;
290 this.el.x_expand = true;
291 this.el.y_align = Clutter.ActorAlign.START;
292 this.el.margin_top = 5f;
293 this.el.y_expand = true;
299 var fname = file.getIconFileName(false);
301 if (FileUtils.test(fname, FileTest.EXISTS)) {
302 pixbuf = new Gdk.Pixbuf.from_file(fname);
304 if (_this.missing_thumb_pixbuf == null) {
305 var icon_theme = Gtk.IconTheme.get_default ();
306 _this.missing_thumb_pixbuf = icon_theme.load_icon ("package-x-generic", 92, 0);
307 _this.missing_thumb_pixbuf.ref();
309 pixbuf = _this.missing_thumb_pixbuf;
313 var img = new Clutter.Image();
314 img.set_data(pixbuf.get_pixels(),
316 ? Cogl.PixelFormat.RGBA_8888
317 : Cogl.PixelFormat.RGB_888,
319 pixbuf.get_height (),
320 pixbuf.get_rowstride ()
322 this.el.set_content(img);
323 // should probably do smarter scaling...
326 this.el.set_size(90, 70);
330 // user defined functions
332 public class Xcls_typetitle : Object
334 public Clutter.Text el;
335 private Xcls_ClutterFiles _this;
341 public Xcls_typetitle(Xcls_ClutterFiles _owner , JsRender.JsRender file)
344 this.el = new Clutter.Text.full("Sans 10px", file.nickType(),new Clutter.Color.from_string("#fff"));
348 // set gobject values
349 this.el.x_align = Clutter.ActorAlign.START;
350 this.el.x_expand = true;
351 this.el.y_align = Clutter.ActorAlign.START;
352 this.el.y_expand = true;
355 // user defined functions
357 public class Xcls_title : Object
359 public Clutter.Text el;
360 private Xcls_ClutterFiles _this;
366 public Xcls_title(Xcls_ClutterFiles _owner , JsRender.JsRender file)
369 this.el = new Clutter.Text.full("Sans 10px", file.nickName(),new Clutter.Color.from_string("#fff"));
373 // set gobject values
374 this.el.x_align = Clutter.ActorAlign.START;
375 this.el.x_expand = true;
376 this.el.y_align = Clutter.ActorAlign.START;
377 this.el.y_expand = true;
380 // user defined functions