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 // LEAK --- we should unref all the chilren...
105 this.filelayout.el.remove_all_children();
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);
118 // skip |xns - no return type
119 public class Xcls_filelayout : Object
121 public Clutter.Actor el;
122 private Xcls_ClutterFiles _this;
128 public Xcls_filelayout(Xcls_ClutterFiles _owner )
131 _this.filelayout = this;
132 this.el = new Clutter.Actor();
136 // set gobject values
137 this.el.reactive = true;
138 var child_0 = new Xcls_filelayout_manager( _this );
140 this.el.layout_manager = child_0.el;
143 this.el.add_constraint(
144 new Clutter.BindConstraint(_this.el,Clutter.BindCoordinate.SIZE, 0.0f)
148 // userdefined functions
150 // skip |xns - no return type
152 public class Xcls_filelayout_manager : Object
154 public Clutter.FlowLayout el;
155 private Xcls_ClutterFiles _this;
161 public Xcls_filelayout_manager(Xcls_ClutterFiles _owner )
164 _this.filelayout_manager = this;
165 this.el = new Clutter.FlowLayout( Clutter.FlowOrientation.HORIZONTAL );
169 // set gobject values
170 this.el.column_spacing = 20;
171 this.el.homogeneous = true;
172 this.el.row_spacing = 20;
175 // userdefined functions
177 // skip |xns - no return type
179 public class Xcls_fileitem : Object
181 public Clutter.Actor el;
182 private Xcls_ClutterFiles _this;
186 public JsRender.JsRender file;
187 public Xcls_image image;
188 public Xcls_title title;
191 public Xcls_fileitem(Xcls_ClutterFiles _owner , JsRender.JsRender file)
194 this.el = new Clutter.Actor();
198 // set gobject values
199 this.el.reactive = true;
200 var child_0 = new Xcls_BoxLayout5( _this );
202 this.el.layout_manager = child_0.el;
203 var child_1 = new Xcls_image( _this ,file);
205 this.el.add_child ( child_1.el );
206 this.image = child_1;
207 var child_2 = new Xcls_title( _this ,file);
209 this.el.add_child ( child_2.el );
210 this.title = child_2;
214 this.el.set_size(100,100);
217 this.el.enter_event.connect( ( event) => {
218 this.el.background_color = new Clutter.Color.from_string("#333");
221 this.el.leave_event.connect( ( event) => {
222 this.el.background_color = new Clutter.Color.from_string("#000");
225 this.el.button_press_event.connect( ( event) => {
226 _this.open(this.file);
231 // userdefined functions
233 // skip |xns - no return type
235 public class Xcls_BoxLayout5 : Object
237 public Clutter.BoxLayout el;
238 private Xcls_ClutterFiles _this;
244 public Xcls_BoxLayout5(Xcls_ClutterFiles _owner )
247 this.el = new Clutter.BoxLayout();
251 // set gobject values
252 this.el.orientation = Clutter.Orientation.VERTICAL;
256 // userdefined functions
258 // skip |xns - no return type
260 public class Xcls_image : Object
262 public Clutter.Texture el;
263 private Xcls_ClutterFiles _this;
269 public Xcls_image(Xcls_ClutterFiles _owner , JsRender.JsRender file)
272 this.el = new Clutter.Texture.from_file(file.getIconFile());
276 // set gobject values
277 this.el.margin_left = 5;
278 this.el.margin_right = 5;
279 this.el.margin_top = 5;
280 this.el.x_align = Clutter.ActorAlign.START;
281 this.el.x_expand = true;
282 this.el.y_align = Clutter.ActorAlign.START;
283 this.el.y_expand = false;
286 // userdefined functions
288 // skip |xns - no return type
290 public class Xcls_title : Object
292 public Clutter.Text el;
293 private Xcls_ClutterFiles _this;
299 public Xcls_title(Xcls_ClutterFiles _owner , JsRender.JsRender file)
302 this.el = new Clutter.Text.full("Sans 10px", file.nickName(),new Clutter.Color.from_string("#fff"));
306 // set gobject values
307 this.el.x_align = Clutter.ActorAlign.START;
308 this.el.x_expand = true;
309 this.el.y_align = Clutter.ActorAlign.START;
310 this.el.y_expand = false;
313 // userdefined functions
315 // skip |xns - no return type