XObjectBase/GtkTreeViewColumn.js
[app.Builder.js] / XObjectBase / GtkTreeViewColumn.js
index ebb828a..79d6e22 100644 (file)
@@ -4,33 +4,71 @@
 XObject = imports.XObject.XObject
  
 GObject = imports.gi.GObject;
-//GtkClutter.Embed..
-// children are not added at init / but at show stage..
-// listener is added on show..
-// we should really add a hock to destroy it..
-GtkListStore = XObject.define(
+
+// tree view column.. should really have a better way to determin stuff..
+
+GtkTreeViewColumn = XObject.define(
     function(cfg) {
         XObject.call(this, cfg);
         // this is an example...
-       
+        GtkTreeViewColumn.ids++;
+        this.col_id = GtkTreeViewColumn.ids;
+        
     }, 
     XObject,
     {
-        pack : false,
-        init : function() 
-        {
-            // this is done before pack?
-            this.el = new Gtk.TreeViewColumn();
-            this.parent.el.append_column(this.el);
+        list : false, // list goes here, 
+        pack : function(parent, item) {
+             
+            
+            parent.el.append_column(this.el);
+            var n = 0;
+            var _t = this;
+            var col = 0;
+            var found = false; 
+             
+            parent.items.forEach(function(e){
+                if ([ 'GtkListStore', 'GtkTreeStore', 'GtkTreeModelFilter' ].indexOf( XObject.type(e.xtype) ) > -1 ) {
+                    _t.list = e;
+                    return;
+                }
+                
+                
+                if (found) {
+                    return true;
+                }
+                 
+                if (e.col_id == _t.col_id) {
+                    col = n;
+                    found = true;
+                    return;
+                }
+                if (XObject.type(e.xtype) == 'GtkTreeViewColumn') {
+                    n++;
+                }
+            });
             
-            XObject.prototype.init.call(this);
             
             if (this.items.length) {
-                this.el.add_attribute(this.items[0].el , 'markup', 4  );
+                print("child : " + XObject.type(this.items[0].xtype));
+                this.items[0].list = this.list;
+                switch (XObject.type(this.items[0].xtype)) {
+                    case "GtkCellRendererText":
+                        this.el.add_attribute(this.items[0].el , 'markup', col );
+                        break;
+                    case "GtkCellRendererToggle":
+                        print("toggle col : " + col);
+                        this.el. (this.items[0].el , 'active', col ); // boolean???
+                        break;    
+                        
+                }
+                
+                
             }
             
-
             
         }
+         
     }
 ); 
+GtkTreeViewColumn.ids = 0;
\ No newline at end of file