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