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 signal void open (JsRender.JsRender file);
23 public Xcls_ClutterFiles()
26 this.el = new Clutter.ScrollActor();
31 this.el.scroll_mode = Clutter.ScrollMode.VERTICALLY;
32 this.el.reactive = true;
33 var child_0 = new Xcls_filelayout( _this );
35 this.el.add_child ( child_0.el );
39 this.fileitems = new Gee.ArrayList<Xcls_fileitem>();
41 this.el.scroll_event.connect( ( event) => {
42 //Sprint("scroll event");
43 var y = this.filelayout.el.y;
44 var dir = event.direction;
46 case Clutter.ScrollDirection.UP:
49 case Clutter.ScrollDirection.DOWN:
55 // range of scroll -- can go up -- eg.. -ve value.
59 // to work out the max -ve number
60 // height of filelayout
61 // height of scrollactor..
63 var last_child_bottom = this.filelayout.el.last_child.y + this.filelayout.el.last_child.height;
64 if ( (-1 * (y+200)) > ( last_child_bottom - this.el.height)) {
71 // print("\nlast child - this height = %f ==== new y %f\n ".printf(
72 // last_child_bottom - this.el.height,
74 // y = float.min(0, y); //??
75 // print("scroll event of %f - new y = %f ".printf(event.y, y));
76 this.filelayout.el.y = y;
82 // user defined functions
83 public void clearFiles () {
85 this.filelayout.el.remove_all_children();
86 // we need to unref all the chidren that we loaded though...
89 public void loadProject (Project.Project pr) {
90 // list all the files, and create new Xcls_fileitem for each one.
92 // LEAK --- we should unref all the chilren...
93 this.filelayout.el.y = 0;
96 print("clutter files - load project: " + pr.name +"\n");
97 // should unref.. them hopefully.
98 this.fileitems = new Gee.ArrayList<Xcls_fileitem>();
102 var fiter = pr.sortedFiles().list_iterator();
103 while (fiter.next()) {
104 var a = new Xcls_fileitem(this,fiter.get());
105 this.fileitems.add(a);
108 print("add to clutter file view: " + fiter.get().name + "\n");
109 this.filelayout.el.add_child(a.el);
116 public void set_size (float w, float h)
118 if (this.el == null) {
119 print("object not ready yet?");
122 _this.filelayout_manager.el.max_column_width = w - 150;
123 this.el.set_size(this.el.get_stage().width-150,
124 this.el.get_stage().height);
125 this.el.set_position(100,50);
127 public class Xcls_filelayout : Object
129 public Clutter.Actor el;
130 private Xcls_ClutterFiles _this;
136 public Xcls_filelayout(Xcls_ClutterFiles _owner )
139 _this.filelayout = this;
140 this.el = new Clutter.Actor();
144 // set gobject values
145 this.el.reactive = true;
146 var child_0 = new Xcls_filelayout_manager( _this );
148 this.el.layout_manager = child_0.el;
152 this.el.add_constraint(
153 new Clutter.BindConstraint(_this.el,Clutter.BindCoordinate.SIZE, 0.0f)
156 // user defined functions
158 public class Xcls_filelayout_manager : Object
160 public Clutter.FlowLayout el;
161 private Xcls_ClutterFiles _this;
167 public Xcls_filelayout_manager(Xcls_ClutterFiles _owner )
170 _this.filelayout_manager = this;
171 this.el = new Clutter.FlowLayout( Clutter.FlowOrientation.HORIZONTAL );
175 // set gobject values
176 this.el.homogeneous = true;
177 this.el.row_spacing = 20f;
178 this.el.column_spacing = 20f;
181 // user defined functions
183 public class Xcls_fileitem : Object
185 public Clutter.Actor el;
186 private Xcls_ClutterFiles _this;
190 public JsRender.JsRender file;
191 public Xcls_image image;
192 public Xcls_typetitle typetitle;
193 public Xcls_title title;
196 public Xcls_fileitem(Xcls_ClutterFiles _owner , JsRender.JsRender file)
199 this.el = new Clutter.Actor();
203 // set gobject values
204 this.el.reactive = true;
205 var child_0 = new Xcls_BoxLayout5( _this );
207 this.el.layout_manager = child_0.el;
208 var child_1 = new Xcls_image( _this ,file);
210 this.el.add_child ( child_1.el );
211 this.image = child_1;
212 var child_2 = new Xcls_typetitle( _this ,file);
214 this.el.add_child ( child_2.el );
215 this.typetitle = child_2;
216 var child_3 = new Xcls_title( _this ,file);
218 this.el.add_child ( child_3.el );
219 this.title = child_3;
224 this.el.set_size(100,100);
226 this.el.button_press_event.connect( ( event) => {
227 _this.open(this.file);
230 this.el.enter_event.connect( ( event) => {
231 this.el.background_color = new Clutter.Color.from_string("#333");
234 this.el.leave_event.connect( ( event) => {
235 this.el.background_color = new Clutter.Color.from_string("#000");
240 // user defined functions
242 public class Xcls_BoxLayout5 : Object
244 public Clutter.BoxLayout el;
245 private Xcls_ClutterFiles _this;
251 public Xcls_BoxLayout5(Xcls_ClutterFiles _owner )
254 this.el = new Clutter.BoxLayout();
258 // set gobject values
260 this.el.orientation = Clutter.Orientation.VERTICAL;
263 // user defined functions
265 public class Xcls_image : Object
267 public Clutter.Actor el;
268 private Xcls_ClutterFiles _this;
274 public Xcls_image(Xcls_ClutterFiles _owner , JsRender.JsRender file)
277 this.el = new Clutter.Actor();
281 // set gobject values
282 this.el.margin_right = 5f;
283 this.el.margin_left = 5f;
284 this.el.x_align = Clutter.ActorAlign.START;
285 this.el.x_expand = true;
286 this.el.y_align = Clutter.ActorAlign.START;
287 this.el.margin_top = 5f;
288 this.el.y_expand = true;
294 var fname = file.getIconFileName(false);
296 if (FileUtils.test(fname, FileTest.EXISTS)) {
297 pixbuf = new Gdk.Pixbuf.from_file(fname);
299 var icon_theme = Gtk.IconTheme.get_default ();
300 pixbuf = icon_theme.load_icon ("package-x-generic", 92, 0);
304 var img = new Clutter.Image();
305 img.set_data(pixbuf.get_pixels(),
307 ? Cogl.PixelFormat.RGBA_8888
308 : Cogl.PixelFormat.RGB_888,
310 pixbuf.get_height (),
311 pixbuf.get_rowstride ()
313 this.el.set_content(img);
314 // should probably do smarter scaling...
317 this.el.set_size(90, 70);
320 // user defined functions
322 public class Xcls_typetitle : Object
324 public Clutter.Text el;
325 private Xcls_ClutterFiles _this;
331 public Xcls_typetitle(Xcls_ClutterFiles _owner , JsRender.JsRender file)
334 this.el = new Clutter.Text.full("Sans 10px", file.nickType(),new Clutter.Color.from_string("#fff"));
338 // set gobject values
339 this.el.y_align = Clutter.ActorAlign.START;
340 this.el.x_align = Clutter.ActorAlign.START;
341 this.el.x_expand = true;
342 this.el.y_expand = true;
345 // user defined functions
347 public class Xcls_title : Object
349 public Clutter.Text el;
350 private Xcls_ClutterFiles _this;
356 public Xcls_title(Xcls_ClutterFiles _owner , JsRender.JsRender file)
359 this.el = new Clutter.Text.full("Sans 10px", file.nickName(),new Clutter.Color.from_string("#fff"));
363 // set gobject values
364 this.el.y_align = Clutter.ActorAlign.START;
365 this.el.x_align = Clutter.ActorAlign.START;
366 this.el.x_expand = true;
367 this.el.y_expand = true;
370 // user defined functions