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