XObjectBase/GtkTreeModelFilter.js
[app.Builder.js] / XObjectBase / GtkTreeModelFilter.js
1
2 //<Script type="Text/javascript">
3
4 XObject = imports.XObject.XObject
5  
6 GObject = imports.gi.GObject;
7 //GtkClutter.Embed..
8 Gtk= imports.gi.Gtk;
9
10 // children are not added at init / but at show stage..
11 // listener is added on show..
12 // we should really add a hock to destroy it..
13 GtkTreeModelFilter = XObject.define(
14     function(cfg) {
15         XObject.call(this, cfg);
16         // this is an example...
17        
18     }, 
19     XObject,
20     {
21         pack :  'set_model',
22         init : function() 
23         {
24             // 
25             this.items[0].pack = false;
26             this.list = this.items[0];
27             this.el = new Gtk.TreeModelFilter.c_new(this.items[0].el, null);
28             XObject.prototype.init.call(this);
29           
30         },
31         append : function( values ) {
32             var iter = new Gtk.TreeIter();
33             this.el.append(iter);
34             for (var i = 0; i < values.length; i++) {
35                 this.el.set_value(iter,i,values[i]);
36             }
37             
38         },
39         getValue  : function ( path, col)
40         {
41             // not very type safe...
42             var tpath = path;
43             if (typeof(path) == 'string' ) {
44                 tpath = new Gtk.TreePath.from_string(path);
45             }
46             
47             var iter = new Gtk.TreeIter();
48             this.el.get_iter (iter, tpath) ;
49             var gval = new GObject.Value(  [this.el.get_column_type(col), null ]);
50             this.el.get_value( iter, col, gval);
51             print("GET VALUE RETURNED: " + gval.value);
52             return gval.value;
53         },
54         setValue  : function ( path, col, val)
55         {
56             var tpath = path;
57             if (typeof(path) == 'string' ) {
58                 tpath = new Gtk.TreePath.from_string(path);
59             }
60             var iter = new Gtk.TreeIter();
61             this.el.get_iter (iter, tpath) ;
62             this.el.set_value(iter,col,val);
63         }
64                 
65         
66     }
67 );