XObjectBase/GtkClutterActor.js
[app.Builder.js] / XObjectBase / GtkClutterActor.js
1
2 //<Script type="Text/javascript">
3
4 XObject = imports.XObject.XObject
5 GtkClutter = imports.gi.GtkClutter;
6
7 //GtkClutter.Embed..
8 // children are not added at init / but at show stage..
9 // listener is added on show..
10 // we should really add a hock to destroy it..
11
12 GtkClutterActor = {
13     
14     pack : function(parent, item)
15     {
16         print('actor pack: ' +  XObject.type(parent.xtype));
17         if (XObject.type(parent.xtype) == 'GtkClutterWindow') {
18             var st = parent.el.getStage();
19             st.add_actor(this.el);
20         }
21         
22     },
23     
24     onConstruct : function() {
25         if (!this.items.length) {
26             XObject.fatal("Actor does not have any children");
27             return;
28         }
29         
30         this.items[0].pack = false;
31         
32     },
33     
34     init : function() {
35         print ("Actor init");
36         if (!this.items.length) {
37             print ("Actor does not have any children");
38             return;
39         }
40         var child = this.items[0];
41         child.init();
42         child.pack = false;
43         child.parent = this;
44         //var contents = new Gtk.Button({ label: 'test' }); 
45         
46        // print(JSON.stringify(this.items));
47         child.el.show();
48         
49         this.el = new GtkClutter.Actor.with_contents (  child.el) ;
50         
51         XObject.prototype.init.call(this);
52         this.el.show_all();
53     }
54
55 };