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         
17         if (XObject.type(parent.xtype) == 'GtkClutterWindow') {
18             var st = parent.el.get_stage();
19             st.add_actor(this.el);
20         }
21         XObject.fatal("do not know how to pack actor into " +  XObject.type(parent.xtype));
22         
23     },
24     
25     onConstruct : function() {
26         if (!this.items.length) {
27             XObject.fatal("Actor does not have any children");
28             return;
29         }
30         
31         this.items[0].pack = false;
32         
33     },
34     
35     init : function() {
36         print ("Actor init");
37         if (!this.items.length) {
38             print ("Actor does not have any children");
39             return;
40         }
41         var child = this.items[0];
42         child.init();
43         child.pack = false;
44         child.parent = this;
45         //var contents = new Gtk.Button({ label: 'test' }); 
46         
47        // print(JSON.stringify(this.items));
48         child.el.show();
49         
50         this.el = new GtkClutter.Actor.with_contents (  child.el) ;
51         
52         XObject.prototype.init.call(this);
53         this.el.show_all();
54     }
55
56 };