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>();
43 this.el.scroll_event.connect( ( event) => {
44 //Sprint("scroll event");
45 var y = this.filelayout.el.y;
46 var dir = event.direction;
48 case Clutter.ScrollDirection.UP:
51 case Clutter.ScrollDirection.DOWN:
57 // range of scroll -- can go up -- eg.. -ve value.
61 // to work out the max -ve number
62 // height of filelayout
63 // height of scrollactor..
65 var last_child_bottom = this.filelayout.el.last_child.y + this.filelayout.el.last_child.height;
66 if ( (-1 * (y+200)) > ( last_child_bottom - this.el.height)) {
73 // print("\nlast child - this height = %f ==== new y %f\n ".printf(
74 // last_child_bottom - this.el.height,
76 // y = float.min(0, y); //??
77 // print("scroll event of %f - new y = %f ".printf(event.y, y));
78 this.filelayout.el.y = y;
84 // user defined functions
85 public void clearFiles () {
87 this.filelayout.el.remove_all_children();
88 // we need to unref all the chidren that we loaded though...
91 public void loadProject (Project.Project pr) {
92 // list all the files, and create new Xcls_fileitem for each one.
94 // LEAK --- we should unref all the chilren...
95 this.filelayout.el.y = 0;
98 print("clutter files - load project: " + pr.name +"\n");
99 // should unref.. them hopefully.
100 this.fileitems = new Gee.ArrayList<Xcls_fileitem>();
104 var fiter = pr.sortedFiles().list_iterator();
105 while (fiter.next()) {
106 var a = new Xcls_fileitem(this,fiter.get());
107 this.fileitems.add(a);
110 print("add to clutter file view: " + fiter.get().name + "\n");
111 this.filelayout.el.add_child(a.el);
118 public void set_size (float w, float h)
120 if (this.el == null) {
121 print("object not ready yet?");
124 _this.filelayout_manager.el.max_column_width = w - 150;
125 this.el.set_size(this.el.get_stage().width-150,
126 this.el.get_stage().height);
127 this.el.set_position(100,50);
129 public class Xcls_filelayout : Object
131 public Clutter.Actor el;
132 private Xcls_ClutterFiles _this;
138 public Xcls_filelayout(Xcls_ClutterFiles _owner )
141 _this.filelayout = this;
142 this.el = new Clutter.Actor();
146 // set gobject values
147 this.el.reactive = true;
148 var child_0 = new Xcls_filelayout_manager( _this );
150 this.el.layout_manager = child_0.el;
154 this.el.add_constraint(
155 new Clutter.BindConstraint(_this.el,Clutter.BindCoordinate.SIZE, 0.0f)
158 // user defined functions
160 public class Xcls_filelayout_manager : Object
162 public Clutter.FlowLayout el;
163 private Xcls_ClutterFiles _this;
169 public Xcls_filelayout_manager(Xcls_ClutterFiles _owner )
172 _this.filelayout_manager = this;
173 this.el = new Clutter.FlowLayout( Clutter.FlowOrientation.HORIZONTAL );
177 // set gobject values
178 this.el.homogeneous = true;
179 this.el.row_spacing = 20f;
180 this.el.column_spacing = 20f;
183 // user defined functions
185 public class Xcls_fileitem : Object
187 public Clutter.Actor el;
188 private Xcls_ClutterFiles _this;
192 public JsRender.JsRender file;
193 public Xcls_image image;
194 public Xcls_typetitle typetitle;
195 public Xcls_title title;
198 public Xcls_fileitem(Xcls_ClutterFiles _owner , JsRender.JsRender file)
201 this.el = new Clutter.Actor();
205 // set gobject values
206 this.el.reactive = true;
207 var child_0 = new Xcls_BoxLayout5( _this );
209 this.el.layout_manager = child_0.el;
210 var child_1 = new Xcls_image( _this ,file);
212 this.el.add_child ( child_1.el );
213 this.image = child_1;
214 var child_2 = new Xcls_typetitle( _this ,file);
216 this.el.add_child ( child_2.el );
217 this.typetitle = child_2;
218 var child_3 = new Xcls_title( _this ,file);
220 this.el.add_child ( child_3.el );
221 this.title = child_3;
226 this.el.set_size(100,100);
228 this.el.button_press_event.connect( ( event) => {
229 _this.open(this.file);
232 this.el.enter_event.connect( ( event) => {
233 this.el.background_color = new Clutter.Color.from_string("#333");
236 this.el.leave_event.connect( ( event) => {
237 this.el.background_color = new Clutter.Color.from_string("#000");
242 // user defined functions
244 public class Xcls_BoxLayout5 : Object
246 public Clutter.BoxLayout el;
247 private Xcls_ClutterFiles _this;
253 public Xcls_BoxLayout5(Xcls_ClutterFiles _owner )
256 this.el = new Clutter.BoxLayout();
260 // set gobject values
262 this.el.orientation = Clutter.Orientation.VERTICAL;
265 // user defined functions
267 public class Xcls_image : Object
269 public Clutter.Actor el;
270 private Xcls_ClutterFiles _this;
276 public Xcls_image(Xcls_ClutterFiles _owner , JsRender.JsRender file)
279 this.el = new Clutter.Actor();
283 // set gobject values
284 this.el.margin_right = 5f;
285 this.el.margin_left = 5f;
286 this.el.x_align = Clutter.ActorAlign.START;
287 this.el.x_expand = true;
288 this.el.y_align = Clutter.ActorAlign.START;
289 this.el.margin_top = 5f;
290 this.el.y_expand = true;
296 var fname = file.getIconFileName(false);
298 if (FileUtils.test(fname, FileTest.EXISTS)) {
299 pixbuf = new Gdk.Pixbuf.from_file(fname);
301 if (_this.missing_thumb_pixbuf == null) {
302 var icon_theme = Gtk.IconTheme.get_default ();
303 _this.missing_thumb_pixbuf = icon_theme.load_icon ("package-x-generic", 92, 0);
304 _this.missing_thumb_pixbuf.ref();
306 pixbuf = _this.missing_thumb_pixbuf;
310 var img = new Clutter.Image();
311 img.set_data(pixbuf.get_pixels(),
313 ? Cogl.PixelFormat.RGBA_8888
314 : Cogl.PixelFormat.RGB_888,
316 pixbuf.get_height (),
317 pixbuf.get_rowstride ()
319 this.el.set_content(img);
320 // should probably do smarter scaling...
323 this.el.set_size(90, 70);
326 // user defined functions
328 public class Xcls_typetitle : Object
330 public Clutter.Text el;
331 private Xcls_ClutterFiles _this;
337 public Xcls_typetitle(Xcls_ClutterFiles _owner , JsRender.JsRender file)
340 this.el = new Clutter.Text.full("Sans 10px", file.nickType(),new Clutter.Color.from_string("#fff"));
344 // set gobject values
345 this.el.y_align = Clutter.ActorAlign.START;
346 this.el.x_align = Clutter.ActorAlign.START;
347 this.el.x_expand = true;
348 this.el.y_expand = true;
351 // user defined functions
353 public class Xcls_title : Object
355 public Clutter.Text el;
356 private Xcls_ClutterFiles _this;
362 public Xcls_title(Xcls_ClutterFiles _owner , JsRender.JsRender file)
365 this.el = new Clutter.Text.full("Sans 10px", file.nickName(),new Clutter.Color.from_string("#fff"));
369 // set gobject values
370 this.el.y_align = Clutter.ActorAlign.START;
371 this.el.x_align = Clutter.ActorAlign.START;
372 this.el.x_expand = true;
373 this.el.y_expand = true;
376 // user defined functions