2 valac --pkg gio-2.0 --pkg posix --pkg gtk+-3.0 --pkg libnotify --pkg gtksourceview-3.0 --pkg libwnck-3.0 \
3 /tmp/ClutterFiles.vala -o /tmp/ClutterFiles
8 static int main (string[] args) {
10 new Xcls_ClutterFiles();
11 ClutterFiles.show_all();
18 public static Xcls_ClutterFiles ClutterFiles;
20 public class Xcls_ClutterFiles : Object
22 public Clutter.ScrollActor el;
23 private Xcls_ClutterFiles _this;
25 public static Xcls_ClutterFiles singleton()
27 if (ClutterFiles == null) {
28 ClutterFiles= new Xcls_ClutterFiles();
32 public Xcls_filelayout filelayout;
33 public Xcls_filelayout_manager filelayout_manager;
36 public Gee.ArrayList<Xcls_fileitem> fileitems;
37 public signal void open(JsRender.JsRender file);
40 public Xcls_ClutterFiles()
43 this.el = new Clutter.ScrollActor();
48 this.el.reactive = true;
49 var child_0 = new Xcls_filelayout( _this );
51 this.el.add_child ( child_0.el );
54 this.fileitems = new Gee.ArrayList<Xcls_fileitem>();
57 this.el.scroll_event.connect( ( event) => {
58 //Sprint("scroll event");
59 var y = this.filelayout.el.y;
60 var dir = event.direction;
62 case Clutter.ScrollDirection.UP:
65 case Clutter.ScrollDirection.DOWN:
71 // range of scroll -- can go up -- eg.. -ve value.
75 // to work out the max -ve number
76 // height of filelayout
77 // height of scrollactor..
79 var last_child_bottom = this.filelayout.el.last_child.y + this.filelayout.el.last_child.height;
80 if ( (-1 * (y+200)) > ( last_child_bottom - this.el.height)) {
87 // print("\nlast child - this height = %f ==== new y %f\n ".printf(
88 // last_child_bottom - this.el.height,
90 // y = float.min(0, y); //??
91 // print("scroll event of %f - new y = %f ".printf(event.y, y));
92 this.filelayout.el.y = y;
97 // userdefined functions
98 public void clearFiles() {
100 this.filelayout.el.remove_all_children();
101 // we need to unref all the chidren that we loaded though...
104 public void loadProject(Project.Project pr) {
105 // list all the files, and create new Xcls_fileitem for each one.
107 // LEAK --- we should unref all the chilren...
108 this.filelayout.el.y = 0;
111 print("clutter files - load project: " + pr.name +"\n");
112 // should unref.. them hopefully.
113 this.fileitems = new Gee.ArrayList<Xcls_fileitem>();
115 var fiter = pr.files.map_iterator();
116 while (fiter.next()) {
117 var a = new Xcls_fileitem(this,fiter.get_value());
118 this.fileitems.add(a);
121 print("add to clutter file view: " + fiter.get_value().name + "\n");
122 this.filelayout.el.add_child(a.el);
126 public void set_size(float w, float h)
128 if (this.el == null) {
129 print("object not ready yet?");
132 _this.filelayout_manager.el.max_column_width = w - 150;
133 this.el.set_size(this.el.get_stage().width-150,
134 this.el.get_stage().height);
135 this.el.set_position(100,50);
138 // skip |xns - no return type
139 public class Xcls_filelayout : Object
141 public Clutter.Actor el;
142 private Xcls_ClutterFiles _this;
148 public Xcls_filelayout(Xcls_ClutterFiles _owner )
151 _this.filelayout = this;
152 this.el = new Clutter.Actor();
156 // set gobject values
157 this.el.reactive = true;
158 var child_0 = new Xcls_filelayout_manager( _this );
160 this.el.layout_manager = child_0.el;
163 this.el.add_constraint(
164 new Clutter.BindConstraint(_this.el,Clutter.BindCoordinate.SIZE, 0.0f)
168 // userdefined functions
170 // skip |xns - no return type
172 public class Xcls_filelayout_manager : Object
174 public Clutter.FlowLayout el;
175 private Xcls_ClutterFiles _this;
181 public Xcls_filelayout_manager(Xcls_ClutterFiles _owner )
184 _this.filelayout_manager = this;
185 this.el = new Clutter.FlowLayout( Clutter.FlowOrientation.HORIZONTAL );
189 // set gobject values
190 this.el.column_spacing = 20;
191 this.el.homogeneous = true;
192 this.el.row_spacing = 20;
195 // userdefined functions
197 // skip |xns - no return type
199 public class Xcls_fileitem : Object
201 public Clutter.Actor el;
202 private Xcls_ClutterFiles _this;
206 public JsRender.JsRender file;
207 public Xcls_image image;
208 public Xcls_typetitle typetitle;
209 public Xcls_title title;
212 public Xcls_fileitem(Xcls_ClutterFiles _owner , JsRender.JsRender file)
215 this.el = new Clutter.Actor();
219 // set gobject values
220 this.el.reactive = true;
221 var child_0 = new Xcls_BoxLayout5( _this );
223 this.el.layout_manager = child_0.el;
224 var child_1 = new Xcls_image( _this ,file);
226 this.el.add_child ( child_1.el );
227 this.image = child_1;
228 var child_2 = new Xcls_typetitle( _this ,file);
230 this.el.add_child ( child_2.el );
231 this.typetitle = child_2;
232 var child_3 = new Xcls_title( _this ,file);
234 this.el.add_child ( child_3.el );
235 this.title = child_3;
239 this.el.set_size(100,100);
242 this.el.enter_event.connect( ( event) => {
243 this.el.background_color = new Clutter.Color.from_string("#333");
246 this.el.leave_event.connect( ( event) => {
247 this.el.background_color = new Clutter.Color.from_string("#000");
250 this.el.button_press_event.connect( ( event) => {
251 _this.open(this.file);
256 // userdefined functions
258 // skip |xns - no return type
260 public class Xcls_BoxLayout5 : Object
262 public Clutter.BoxLayout el;
263 private Xcls_ClutterFiles _this;
269 public Xcls_BoxLayout5(Xcls_ClutterFiles _owner )
272 this.el = new Clutter.BoxLayout();
276 // set gobject values
277 this.el.orientation = Clutter.Orientation.VERTICAL;
281 // userdefined functions
283 // skip |xns - no return type
285 public class Xcls_image : Object
287 public Clutter.Texture el;
288 private Xcls_ClutterFiles _this;
294 public Xcls_image(Xcls_ClutterFiles _owner , JsRender.JsRender file)
297 this.el = new Clutter.Texture.from_file(file.getIconFileName(true));
301 // set gobject values
302 this.el.margin_left = 5;
303 this.el.margin_right = 5;
304 this.el.margin_top = 5;
305 this.el.x_align = Clutter.ActorAlign.START;
306 this.el.x_expand = true;
307 this.el.y_align = Clutter.ActorAlign.START;
308 this.el.y_expand = false;
311 // userdefined functions
313 // skip |xns - no return type
315 public class Xcls_typetitle : Object
317 public Clutter.Text el;
318 private Xcls_ClutterFiles _this;
324 public Xcls_typetitle(Xcls_ClutterFiles _owner , JsRender.JsRender file)
327 this.el = new Clutter.Text.full("Sans 10px", file.nickType(),new Clutter.Color.from_string("#fff"));
331 // set gobject values
332 this.el.x_align = Clutter.ActorAlign.START;
333 this.el.x_expand = true;
334 this.el.y_align = Clutter.ActorAlign.START;
335 this.el.y_expand = false;
338 // userdefined functions
340 // skip |xns - no return type
342 public class Xcls_title : Object
344 public Clutter.Text el;
345 private Xcls_ClutterFiles _this;
351 public Xcls_title(Xcls_ClutterFiles _owner , JsRender.JsRender file)
354 this.el = new Clutter.Text.full("Sans 10px", file.nickName(),new Clutter.Color.from_string("#fff"));
358 // set gobject values
359 this.el.x_align = Clutter.ActorAlign.START;
360 this.el.x_expand = true;
361 this.el.y_align = Clutter.ActorAlign.START;
362 this.el.y_expand = false;
365 // userdefined functions
367 // skip |xns - no return type