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);
32 public Xcls_ClutterFiles()
36 this.el = new Clutter.ScrollActor();
41 this.el.reactive = true;
42 var child_0 = new Xcls_filelayout( _this );
44 this.el.add_child ( child_0.el );
47 this.el.scroll_event.connect( ( event) => {
49 //Sprint("scroll event");
50 var y = this.filelayout.el.y;
51 var dir = event.direction;
53 case Clutter.ScrollDirection.UP:
56 case Clutter.ScrollDirection.DOWN:
62 // range of scroll -- can go up -- eg.. -ve value.
66 // to work out the max -ve number
67 // height of filelayout
68 // height of scrollactor..
70 var last_child_bottom = this.filelayout.el.last_child.y + this.filelayout.el.last_child.height;
71 if ( (-1 * (y+200)) > ( last_child_bottom - this.el.height)) {
78 // print("\nlast child - this height = %f ==== new y %f\n ".printf(
79 // last_child_bottom - this.el.height,
81 // y = float.min(0, y); //??
82 // print("scroll event of %f - new y = %f ".printf(event.y, y));
83 this.filelayout.el.y = y;
89 // userdefined functions
90 public void clearFiles() {
92 this.filelayout.el.remove_all_children();
95 public void loadProject(Project.Project pr) {
96 // list all the files, and create new Xcls_fileitem for each one.
98 // LEAK --- we should unref all the chilren...
101 print("clutter files - load project: " + pr.name +"\n");
102 var fiter = pr.files.map_iterator();
103 while (fiter.next()) {
104 var a = new Xcls_fileitem(this,fiter.get_value());
106 print("add to clutter file view: " + fiter.get_value().name + "\n");
107 this.filelayout.el.add_child(a.el);
111 public void set_size(float w, float h)
113 if (this.el == null) {
114 print("object not ready yet?");
117 _this.filelayout_manager.el.max_column_width = w - 150;
118 this.el.set_size(this.el.get_stage().width-150,
119 this.el.get_stage().height);
120 this.el.set_position(100,50);
123 // skip |xns - no return type
124 public class Xcls_filelayout : Object
126 public Clutter.Actor el;
127 private Xcls_ClutterFiles _this;
133 public Xcls_filelayout(Xcls_ClutterFiles _owner )
136 _this.filelayout = this;
137 this.el = new Clutter.Actor();
141 // set gobject values
142 this.el.reactive = true;
143 var child_0 = new Xcls_filelayout_manager( _this );
145 this.el.layout_manager = child_0.el;
148 this.el.add_constraint(
149 new Clutter.BindConstraint(_this.el,Clutter.BindCoordinate.SIZE, 0.0f)
153 // userdefined functions
155 // skip |xns - no return type
157 public class Xcls_filelayout_manager : Object
159 public Clutter.FlowLayout el;
160 private Xcls_ClutterFiles _this;
166 public Xcls_filelayout_manager(Xcls_ClutterFiles _owner )
169 _this.filelayout_manager = this;
170 this.el = new Clutter.FlowLayout( Clutter.FlowOrientation.HORIZONTAL );
174 // set gobject values
175 this.el.column_spacing = 20;
176 this.el.homogeneous = true;
177 this.el.row_spacing = 20;
180 // userdefined functions
182 // skip |xns - no return type
184 public class Xcls_fileitem : Object
186 public Clutter.Actor el;
187 private Xcls_ClutterFiles _this;
191 public JsRender.JsRender file;
192 public Xcls_image image;
193 public Xcls_typetitle typetitle;
194 public Xcls_title title;
197 public Xcls_fileitem(Xcls_ClutterFiles _owner , JsRender.JsRender file)
200 this.el = new Clutter.Actor();
204 // set gobject values
205 this.el.reactive = true;
206 var child_0 = new Xcls_BoxLayout5( _this );
208 this.el.layout_manager = child_0.el;
209 var child_1 = new Xcls_image( _this ,file);
211 this.el.add_child ( child_1.el );
212 this.image = child_1;
213 var child_2 = new Xcls_typetitle( _this ,file);
215 this.el.add_child ( child_2.el );
216 this.typetitle = child_2;
217 var child_3 = new Xcls_title( _this ,file);
219 this.el.add_child ( child_3.el );
220 this.title = child_3;
224 this.el.set_size(100,100);
227 this.el.enter_event.connect( ( event) => {
228 this.el.background_color = new Clutter.Color.from_string("#333");
231 this.el.leave_event.connect( ( event) => {
232 this.el.background_color = new Clutter.Color.from_string("#000");
235 this.el.button_press_event.connect( ( event) => {
236 _this.open(this.file);
241 // userdefined functions
243 // skip |xns - no return type
245 public class Xcls_BoxLayout5 : Object
247 public Clutter.BoxLayout el;
248 private Xcls_ClutterFiles _this;
254 public Xcls_BoxLayout5(Xcls_ClutterFiles _owner )
257 this.el = new Clutter.BoxLayout();
261 // set gobject values
262 this.el.orientation = Clutter.Orientation.VERTICAL;
266 // userdefined functions
268 // skip |xns - no return type
270 public class Xcls_image : Object
272 public Clutter.Texture el;
273 private Xcls_ClutterFiles _this;
279 public Xcls_image(Xcls_ClutterFiles _owner , JsRender.JsRender file)
282 this.el = new Clutter.Texture.from_file(file.getIconFile());
286 // set gobject values
287 this.el.margin_left = 5;
288 this.el.margin_right = 5;
289 this.el.margin_top = 5;
290 this.el.x_align = Clutter.ActorAlign.START;
291 this.el.x_expand = true;
292 this.el.y_align = Clutter.ActorAlign.START;
293 this.el.y_expand = false;
296 // userdefined functions
298 // skip |xns - no return type
300 public class Xcls_typetitle : Object
302 public Clutter.Text el;
303 private Xcls_ClutterFiles _this;
309 public Xcls_typetitle(Xcls_ClutterFiles _owner , JsRender.JsRender file)
312 this.el = new Clutter.Text.full("Sans 10px", file.nickType(),new Clutter.Color.from_string("#fff"));
316 // set gobject values
317 this.el.x_align = Clutter.ActorAlign.START;
318 this.el.x_expand = true;
319 this.el.y_align = Clutter.ActorAlign.START;
320 this.el.y_expand = false;
323 // userdefined functions
325 // skip |xns - no return type
327 public class Xcls_title : Object
329 public Clutter.Text el;
330 private Xcls_ClutterFiles _this;
336 public Xcls_title(Xcls_ClutterFiles _owner , JsRender.JsRender file)
339 this.el = new Clutter.Text.full("Sans 10px", file.nickName(),new Clutter.Color.from_string("#fff"));
343 // set gobject values
344 this.el.x_align = Clutter.ActorAlign.START;
345 this.el.x_expand = true;
346 this.el.y_align = Clutter.ActorAlign.START;
347 this.el.y_expand = false;
350 // userdefined functions
352 // skip |xns - no return type