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
91 // skip | - no return type
92 public void loadProject(Project.Project pr) {
93 // list all the files, and create new Xcls_fileitem for each one.
95 // LEAK --- we should unref all the chilren...
96 this.filelayout.el.remove_all_children();
98 print("clutter files - load project: " + pr.name +"\n");
99 var fiter = pr.files.map_iterator();
100 while (fiter.next()) {
101 var a = new Xcls_fileitem(this,fiter.get_value());
103 print("add to clutter file view: " + fiter.get_value().name + "\n");
104 this.filelayout.el.add_child(a.el);
108 public void set_size(float w, float h)
110 if (this.el == null) {
111 print("object not ready yet?");
114 _this.filelayout_manager.el.max_column_width = w - 150;
115 this.el.set_size(this.el.get_stage().width-150,
116 this.el.get_stage().height);
117 this.el.set_position(100,50);
120 // skip |xns - no return type
121 public class Xcls_filelayout : Object
123 public Clutter.Actor el;
124 private Xcls_ClutterFiles _this;
130 public Xcls_filelayout(Xcls_ClutterFiles _owner )
133 _this.filelayout = this;
134 this.el = new Clutter.Actor();
138 // set gobject values
139 this.el.reactive = true;
140 var child_0 = new Xcls_filelayout_manager( _this );
142 this.el.layout_manager = child_0.el;
145 this.el.add_constraint(
146 new Clutter.BindConstraint(_this.el,Clutter.BindCoordinate.SIZE, 0.0f)
150 // userdefined functions
152 // skip |xns - no return type
154 public class Xcls_filelayout_manager : Object
156 public Clutter.FlowLayout el;
157 private Xcls_ClutterFiles _this;
163 public Xcls_filelayout_manager(Xcls_ClutterFiles _owner )
166 _this.filelayout_manager = this;
167 this.el = new Clutter.FlowLayout( Clutter.FlowOrientation.HORIZONTAL );
171 // set gobject values
172 this.el.column_spacing = 20;
173 this.el.homogeneous = true;
174 this.el.row_spacing = 20;
177 // userdefined functions
179 // skip |xns - no return type
181 public class Xcls_fileitem : Object
183 public Clutter.Actor el;
184 private Xcls_ClutterFiles _this;
188 public JsRender.JsRender file;
189 public Xcls_image image;
190 public Xcls_title title;
193 public Xcls_fileitem(Xcls_ClutterFiles _owner , JsRender.JsRender file)
196 this.el = new Clutter.Actor();
200 // set gobject values
201 this.el.reactive = true;
202 var child_0 = new Xcls_BoxLayout5( _this );
204 this.el.layout_manager = child_0.el;
205 var child_1 = new Xcls_image( _this ,file);
207 this.el.add_child ( child_1.el );
208 this.image = child_1;
209 var child_2 = new Xcls_title( _this ,file);
211 this.el.add_child ( child_2.el );
212 this.title = child_2;
216 this.el.set_size(100,100);
219 this.el.enter_event.connect( ( event) => {
220 this.el.background_color = new Clutter.Color.from_string("#333");
223 this.el.leave_event.connect( ( event) => {
224 this.el.background_color = new Clutter.Color.from_string("#000");
227 this.el.button_press_event.connect( ( event) => {
228 _this.open(this.file);
233 // userdefined functions
235 // skip |xns - no return type
237 public class Xcls_BoxLayout5 : Object
239 public Clutter.BoxLayout el;
240 private Xcls_ClutterFiles _this;
246 public Xcls_BoxLayout5(Xcls_ClutterFiles _owner )
249 this.el = new Clutter.BoxLayout();
253 // set gobject values
254 this.el.orientation = Clutter.Orientation.VERTICAL;
258 // userdefined functions
260 // skip |xns - no return type
262 public class Xcls_image : Object
264 public Clutter.Texture el;
265 private Xcls_ClutterFiles _this;
271 public Xcls_image(Xcls_ClutterFiles _owner , JsRender.JsRender file)
274 this.el = new Clutter.Texture.from_file(file.getIconFile());
278 // set gobject values
279 this.el.margin_left = 5;
280 this.el.margin_right = 5;
281 this.el.margin_top = 5;
282 this.el.x_align = Clutter.ActorAlign.START;
283 this.el.x_expand = true;
284 this.el.y_align = Clutter.ActorAlign.START;
285 this.el.y_expand = false;
288 // userdefined functions
290 // skip |xns - no return type
292 public class Xcls_title : Object
294 public Clutter.Text el;
295 private Xcls_ClutterFiles _this;
301 public Xcls_title(Xcls_ClutterFiles _owner , JsRender.JsRender file)
304 this.el = new Clutter.Text.full("Sans 10px", file.nickName(),new Clutter.Color.from_string("#fff"));
308 // set gobject values
309 this.el.x_align = Clutter.ActorAlign.START;
310 this.el.x_expand = true;
311 this.el.y_align = Clutter.ActorAlign.START;
312 this.el.y_expand = false;
315 // userdefined functions
317 // skip |xns - no return type