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 Xcls_filelayout filelayout;
26 public Xcls_filelayout_manager filelayout_manager;
29 public signal void open(JsRender.JsRender file);
30 public Gee.ArrayList fileitems;
33 public Xcls_ClutterFiles()
37 this.el = new Clutter.ScrollActor();
40 this.fileitems = function() {
46 this.el.reactive = true;
47 var child_0 = new Xcls_filelayout( _this );
49 this.el.add_child ( child_0.el );
52 this.el.scroll_event.connect( ( event) => {
54 //Sprint("scroll event");
55 var y = this.filelayout.el.y;
56 var dir = event.direction;
58 case Clutter.ScrollDirection.UP:
61 case Clutter.ScrollDirection.DOWN:
67 // range of scroll -- can go up -- eg.. -ve value.
71 // to work out the max -ve number
72 // height of filelayout
73 // height of scrollactor..
75 var last_child_bottom = this.filelayout.el.last_child.y + this.filelayout.el.last_child.height;
76 if ( (-1 * (y+200)) > ( last_child_bottom - this.el.height)) {
83 // print("\nlast child - this height = %f ==== new y %f\n ".printf(
84 // last_child_bottom - this.el.height,
86 // y = float.min(0, y); //??
87 // print("scroll event of %f - new y = %f ".printf(event.y, y));
88 this.filelayout.el.y = y;
94 // userdefined functions
95 public void clearFiles() {
97 this.filelayout.el.remove_all_children();
98 // we need to unref all the chidren that we loaded though...
101 public void loadProject(Project.Project pr) {
102 // list all the files, and create new Xcls_fileitem for each one.
104 // LEAK --- we should unref all the chilren...
107 print("clutter files - load project: " + pr.name +"\n");
108 var fiter = pr.files.map_iterator();
109 while (fiter.next()) {
110 var a = new Xcls_fileitem(this,fiter.get_value());
112 print("add to clutter file view: " + fiter.get_value().name + "\n");
113 this.filelayout.el.add_child(a.el);
117 public void set_size(float w, float h)
119 if (this.el == null) {
120 print("object not ready yet?");
123 _this.filelayout_manager.el.max_column_width = w - 150;
124 this.el.set_size(this.el.get_stage().width-150,
125 this.el.get_stage().height);
126 this.el.set_position(100,50);
129 // skip |xns - no return type
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;
154 this.el.add_constraint(
155 new Clutter.BindConstraint(_this.el,Clutter.BindCoordinate.SIZE, 0.0f)
159 // userdefined functions
161 // skip |xns - no return type
163 public class Xcls_filelayout_manager : Object
165 public Clutter.FlowLayout el;
166 private Xcls_ClutterFiles _this;
172 public Xcls_filelayout_manager(Xcls_ClutterFiles _owner )
175 _this.filelayout_manager = this;
176 this.el = new Clutter.FlowLayout( Clutter.FlowOrientation.HORIZONTAL );
180 // set gobject values
181 this.el.column_spacing = 20;
182 this.el.homogeneous = true;
183 this.el.row_spacing = 20;
186 // userdefined functions
188 // skip |xns - no return type
190 public class Xcls_fileitem : Object
192 public Clutter.Actor el;
193 private Xcls_ClutterFiles _this;
197 public JsRender.JsRender file;
198 public Xcls_image image;
199 public Xcls_typetitle typetitle;
200 public Xcls_title title;
203 public Xcls_fileitem(Xcls_ClutterFiles _owner , JsRender.JsRender file)
206 this.el = new Clutter.Actor();
210 // set gobject values
211 this.el.reactive = true;
212 var child_0 = new Xcls_BoxLayout5( _this );
214 this.el.layout_manager = child_0.el;
215 var child_1 = new Xcls_image( _this ,file);
217 this.el.add_child ( child_1.el );
218 this.image = child_1;
219 var child_2 = new Xcls_typetitle( _this ,file);
221 this.el.add_child ( child_2.el );
222 this.typetitle = child_2;
223 var child_3 = new Xcls_title( _this ,file);
225 this.el.add_child ( child_3.el );
226 this.title = child_3;
230 this.el.set_size(100,100);
233 this.el.enter_event.connect( ( event) => {
234 this.el.background_color = new Clutter.Color.from_string("#333");
237 this.el.leave_event.connect( ( event) => {
238 this.el.background_color = new Clutter.Color.from_string("#000");
241 this.el.button_press_event.connect( ( event) => {
242 _this.open(this.file);
247 // userdefined functions
249 // skip |xns - no return type
251 public class Xcls_BoxLayout5 : Object
253 public Clutter.BoxLayout el;
254 private Xcls_ClutterFiles _this;
260 public Xcls_BoxLayout5(Xcls_ClutterFiles _owner )
263 this.el = new Clutter.BoxLayout();
267 // set gobject values
268 this.el.orientation = Clutter.Orientation.VERTICAL;
272 // userdefined functions
274 // skip |xns - no return type
276 public class Xcls_image : Object
278 public Clutter.Texture el;
279 private Xcls_ClutterFiles _this;
285 public Xcls_image(Xcls_ClutterFiles _owner , JsRender.JsRender file)
288 this.el = new Clutter.Texture.from_file(file.getIconFileName(true));
292 // set gobject values
293 this.el.margin_left = 5;
294 this.el.margin_right = 5;
295 this.el.margin_top = 5;
296 this.el.x_align = Clutter.ActorAlign.START;
297 this.el.x_expand = true;
298 this.el.y_align = Clutter.ActorAlign.START;
299 this.el.y_expand = false;
302 // userdefined functions
304 // skip |xns - no return type
306 public class Xcls_typetitle : Object
308 public Clutter.Text el;
309 private Xcls_ClutterFiles _this;
315 public Xcls_typetitle(Xcls_ClutterFiles _owner , JsRender.JsRender file)
318 this.el = new Clutter.Text.full("Sans 10px", file.nickType(),new Clutter.Color.from_string("#fff"));
322 // set gobject values
323 this.el.x_align = Clutter.ActorAlign.START;
324 this.el.x_expand = true;
325 this.el.y_align = Clutter.ActorAlign.START;
326 this.el.y_expand = false;
329 // userdefined functions
331 // skip |xns - no return type
333 public class Xcls_title : Object
335 public Clutter.Text el;
336 private Xcls_ClutterFiles _this;
342 public Xcls_title(Xcls_ClutterFiles _owner , JsRender.JsRender file)
345 this.el = new Clutter.Text.full("Sans 10px", file.nickName(),new Clutter.Color.from_string("#fff"));
349 // set gobject values
350 this.el.x_align = Clutter.ActorAlign.START;
351 this.el.x_expand = true;
352 this.el.y_align = Clutter.ActorAlign.START;
353 this.el.y_expand = false;
356 // userdefined functions
358 // skip |xns - no return type