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