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...
110 print("clutter files - load project: " + pr.name +"\n");
111 // should unref.. them hopefully.
112 this.fileitems = new Gee.ArrayList<Xcls_fileitem>();
114 var fiter = pr.files.map_iterator();
115 while (fiter.next()) {
116 var a = new Xcls_fileitem(this,fiter.get_value());
117 this.fileitems.add(a);
120 print("add to clutter file view: " + fiter.get_value().name + "\n");
121 this.filelayout.el.add_child(a.el);
125 public void set_size(float w, float h)
127 if (this.el == null) {
128 print("object not ready yet?");
131 _this.filelayout_manager.el.max_column_width = w - 150;
132 this.el.set_size(this.el.get_stage().width-150,
133 this.el.get_stage().height);
134 this.el.set_position(100,50);
137 // skip |xns - no return type
138 public class Xcls_filelayout : Object
140 public Clutter.Actor el;
141 private Xcls_ClutterFiles _this;
147 public Xcls_filelayout(Xcls_ClutterFiles _owner )
150 _this.filelayout = this;
151 this.el = new Clutter.Actor();
155 // set gobject values
156 this.el.reactive = true;
157 var child_0 = new Xcls_filelayout_manager( _this );
159 this.el.layout_manager = child_0.el;
162 this.el.add_constraint(
163 new Clutter.BindConstraint(_this.el,Clutter.BindCoordinate.SIZE, 0.0f)
167 // userdefined functions
169 // skip |xns - no return type
171 public class Xcls_filelayout_manager : Object
173 public Clutter.FlowLayout el;
174 private Xcls_ClutterFiles _this;
180 public Xcls_filelayout_manager(Xcls_ClutterFiles _owner )
183 _this.filelayout_manager = this;
184 this.el = new Clutter.FlowLayout( Clutter.FlowOrientation.HORIZONTAL );
188 // set gobject values
189 this.el.column_spacing = 20;
190 this.el.homogeneous = true;
191 this.el.row_spacing = 20;
194 // userdefined functions
196 // skip |xns - no return type
198 public class Xcls_fileitem : Object
200 public Clutter.Actor el;
201 private Xcls_ClutterFiles _this;
205 public JsRender.JsRender file;
206 public Xcls_image image;
207 public Xcls_typetitle typetitle;
208 public Xcls_title title;
211 public Xcls_fileitem(Xcls_ClutterFiles _owner , JsRender.JsRender file)
214 this.el = new Clutter.Actor();
218 // set gobject values
219 this.el.reactive = true;
220 var child_0 = new Xcls_BoxLayout5( _this );
222 this.el.layout_manager = child_0.el;
223 var child_1 = new Xcls_image( _this ,file);
225 this.el.add_child ( child_1.el );
226 this.image = child_1;
227 var child_2 = new Xcls_typetitle( _this ,file);
229 this.el.add_child ( child_2.el );
230 this.typetitle = child_2;
231 var child_3 = new Xcls_title( _this ,file);
233 this.el.add_child ( child_3.el );
234 this.title = child_3;
238 this.el.set_size(100,100);
241 this.el.enter_event.connect( ( event) => {
242 this.el.background_color = new Clutter.Color.from_string("#333");
245 this.el.leave_event.connect( ( event) => {
246 this.el.background_color = new Clutter.Color.from_string("#000");
249 this.el.button_press_event.connect( ( event) => {
250 _this.open(this.file);
255 // userdefined functions
257 // skip |xns - no return type
259 public class Xcls_BoxLayout5 : Object
261 public Clutter.BoxLayout el;
262 private Xcls_ClutterFiles _this;
268 public Xcls_BoxLayout5(Xcls_ClutterFiles _owner )
271 this.el = new Clutter.BoxLayout();
275 // set gobject values
276 this.el.orientation = Clutter.Orientation.VERTICAL;
280 // userdefined functions
282 // skip |xns - no return type
284 public class Xcls_image : Object
286 public Clutter.Texture el;
287 private Xcls_ClutterFiles _this;
293 public Xcls_image(Xcls_ClutterFiles _owner , JsRender.JsRender file)
296 this.el = new Clutter.Texture.from_file(file.getIconFileName(true));
300 // set gobject values
301 this.el.margin_left = 5;
302 this.el.margin_right = 5;
303 this.el.margin_top = 5;
304 this.el.x_align = Clutter.ActorAlign.START;
305 this.el.x_expand = true;
306 this.el.y_align = Clutter.ActorAlign.START;
307 this.el.y_expand = false;
310 // userdefined functions
312 // skip |xns - no return type
314 public class Xcls_typetitle : Object
316 public Clutter.Text el;
317 private Xcls_ClutterFiles _this;
323 public Xcls_typetitle(Xcls_ClutterFiles _owner , JsRender.JsRender file)
326 this.el = new Clutter.Text.full("Sans 10px", file.nickType(),new Clutter.Color.from_string("#fff"));
330 // set gobject values
331 this.el.x_align = Clutter.ActorAlign.START;
332 this.el.x_expand = true;
333 this.el.y_align = Clutter.ActorAlign.START;
334 this.el.y_expand = false;
337 // userdefined functions
339 // skip |xns - no return type
341 public class Xcls_title : Object
343 public Clutter.Text el;
344 private Xcls_ClutterFiles _this;
350 public Xcls_title(Xcls_ClutterFiles _owner , JsRender.JsRender file)
353 this.el = new Clutter.Text.full("Sans 10px", file.nickName(),new Clutter.Color.from_string("#fff"));
357 // set gobject values
358 this.el.x_align = Clutter.ActorAlign.START;
359 this.el.x_expand = true;
360 this.el.y_align = Clutter.ActorAlign.START;
361 this.el.y_expand = false;
364 // userdefined functions
366 // skip |xns - no return type