XObjectBase/GtkTreeViewColumn.js
[app.Builder.js] / XObjectBase / GtkTreeViewColumn.js
1
2 //<Script type="Text/javascript">
3
4 XObject = imports.XObject.XObject
5  
6 GObject = imports.gi.GObject;
7
8 // tree view column.. should really have a better way to determin stuff..
9
10 GtkTreeViewColumn = XObject.define(
11     function(cfg) {
12         XObject.call(this, cfg);
13         // this is an example...
14         GtkTreeViewColumn.ids++;
15         this.col_id = GtkTreeViewColumn.ids;
16         
17     }, 
18     XObject,
19     {
20         pack : function(parent, item) {
21             this.list = this.parent;
22             
23             parent.el.append_column(this.el);
24             var n = 0;
25             var _t = this;
26             var col = 0;
27             var found = false; 
28              
29             parent.items.forEach(function(e){
30                  
31                 if (found) {
32                     return true;
33                 }
34                  
35                 if (e.col_id == _t.col_id) {
36                     col = n;
37                     found = true;
38                     return;
39                 }
40                 if (XObject.type(e.xtype) == 'GtkTreeViewColumn') {
41                     n++;
42                 }
43             });
44             
45             
46             if (this.items.length) {
47                 print("child : " + XObject.type(this.items[0].xtype));
48                 this.items[0].list = this.list;
49                 switch (XObject.type(this.items[0].xtype)) {
50                     case "GtkCellRendererText":
51                         this.el.add_attribute(this.items[0].el , 'markup', col );
52                         break;
53                     case "GtkCellRendererToggle":
54                         print("toggle col : " + col);
55                         this.el.add_attribute(this.items[0].el , 'active', col ); // boolean???
56                         break;    
57                         
58                 }
59                 
60                 
61             }
62             
63             
64         }
65          
66     }
67 ); 
68 GtkTreeViewColumn.ids = 0;