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