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 set_size(float w, float h)
92 if (this.el == null) {
93 print("object not ready yet?");
96 _this.filelayout_manager.el.max_column_width = w - 150;
97 this.el.set_size(this.el.get_stage().width-150,
98 this.el.get_stage().height);
99 this.el.set_position(100,50);
101 public void show(Project.Project pr) {
102 // list all the files, and create new Xcls_fileitem for each one.
104 var fiter = pr.files.map_iterator();
105 while (fiter.next()) {
106 var a = new Xcls_fileitem(this,fiter.get_value());
108 print("add " + fiter.get_value().name + "\n");
109 this.filelayout.el.add_child(a.el);
114 // skip |xns - no return type
115 public class Xcls_filelayout : Object
117 public Clutter.Actor el;
118 private Xcls_ClutterFiles _this;
124 public Xcls_filelayout(Xcls_ClutterFiles _owner )
127 _this.filelayout = this;
128 this.el = new Clutter.Actor();
132 // set gobject values
133 this.el.reactive = true;
134 var child_0 = new Xcls_filelayout_manager( _this );
136 this.el.layout_manager = child_0.el;
139 this.el.add_constraint(
140 new Clutter.BindConstraint(_this.el,Clutter.BindCoordinate.SIZE, 0.0f)
144 // userdefined functions
146 // skip |xns - no return type
148 public class Xcls_filelayout_manager : Object
150 public Clutter.FlowLayout el;
151 private Xcls_ClutterFiles _this;
157 public Xcls_filelayout_manager(Xcls_ClutterFiles _owner )
160 _this.filelayout_manager = this;
161 this.el = new Clutter.FlowLayout( Clutter.FlowOrientation.HORIZONTAL );
165 // set gobject values
166 this.el.column_spacing = 20;
167 this.el.homogeneous = true;
168 this.el.row_spacing = 20;
171 // userdefined functions
173 // skip |xns - no return type
175 public class Xcls_fileitem : Object
177 public Clutter.Actor el;
178 private Xcls_ClutterFiles _this;
182 public JsRender.JsRender file;
183 public Xcls_image image;
184 public Xcls_title title;
187 public Xcls_fileitem(Xcls_ClutterFiles _owner , JsRender.JsRender file)
190 this.el = new Clutter.Actor();
194 // set gobject values
195 this.el.reactive = true;
196 var child_0 = new Xcls_BoxLayout5( _this );
198 this.el.layout_manager = child_0.el;
199 var child_1 = new Xcls_image( _this ,file);
201 this.el.add_child ( child_1.el );
202 this.image = child_1;
203 var child_2 = new Xcls_title( _this ,file);
205 this.el.add_child ( child_2.el );
206 this.title = child_2;
210 this.el.set_size(100,100);
213 this.el.enter_event.connect( ( event) => {
214 this.el.background_color = new Clutter.Color.from_string("#333");
217 this.el.leave_event.connect( ( event) => {
218 this.el.background_color = new Clutter.Color.from_string("#000");
221 this.el.button_press_event.connect( ( event) => {
222 _this.open(this.file);
227 // userdefined functions
229 // skip |xns - no return type
231 public class Xcls_BoxLayout5 : Object
233 public Clutter.BoxLayout el;
234 private Xcls_ClutterFiles _this;
240 public Xcls_BoxLayout5(Xcls_ClutterFiles _owner )
243 this.el = new Clutter.BoxLayout();
247 // set gobject values
248 this.el.orientation = Clutter.Orientation.VERTICAL;
252 // userdefined functions
254 // skip |xns - no return type
256 public class Xcls_image : Object
258 public Clutter.Texture el;
259 private Xcls_ClutterFiles _this;
265 public Xcls_image(Xcls_ClutterFiles _owner , JsRender.JsRender file)
268 this.el = new Clutter.Texture.from_file(file.getIconFile());
272 // set gobject values
273 this.el.margin_left = 5;
274 this.el.margin_right = 5;
275 this.el.margin_top = 5;
276 this.el.x_align = Clutter.ActorAlign.START;
277 this.el.x_expand = true;
278 this.el.y_align = Clutter.ActorAlign.START;
279 this.el.y_expand = false;
282 // userdefined functions
284 // skip |xns - no return type
286 public class Xcls_title : Object
288 public Clutter.Text el;
289 private Xcls_ClutterFiles _this;
295 public Xcls_title(Xcls_ClutterFiles _owner , JsRender.JsRender file)
298 this.el = new Clutter.Text.full("Sans 10px", file.nickName(),new Clutter.Color.from_string("#fff"));
302 // set gobject values
303 this.el.x_align = Clutter.ActorAlign.START;
304 this.el.x_expand = true;
305 this.el.y_align = Clutter.ActorAlign.START;
306 this.el.y_expand = false;
309 // userdefined functions
311 // skip |xns - no return type