785b93e5933dac94824cc667e27e2ead92cf859b
[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     XObject,
18     {
19         pack : function(parent, item) {
20             parent.el.append_column(this.el);
21             var n = 0;
22             var _t = this;
23             var col = 0;
24             var found = false; 
25              
26             parent.items.forEach(function(e){
27                  
28                 if (found) {
29                     return true;
30                 }
31                  
32                 if (e.col_id == _t.col_id) {
33                     col = n;
34                     found = true;
35                     return;
36                 }
37                 if (XObject.type(e.xtype) == 'GtkTreeViewColumn') {
38                     n++;
39                 }
40             });
41             
42             
43             if (this.items.length) {
44                 print("child : " + XObject.type(this.items[0].xtype));
45                 switch (XObject.type(this.items[0].xtype)) {
46                     case "GtkCellRendererText":
47                         this.el.add_attribute(this.items[0].el , 'markup', col );
48                         break;
49                     case "GtkCellRendererToggle":
50                         print("toggle col : " + col);
51                         this.el.add_attribute(this.items[0].el , 'active', col ); // boolean???
52                         break;    
53                         
54                 }
55                 
56                 
57             }
58             
59             
60         }
61          
62     }
63 ); 
64 GtkTreeViewColumn.ids = 0;