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.items[0].init();
27             this.list = this.items[0];
28             this.el = new Gtk.TreeModelFilter.c_new(this.items[0].el, null);
29             XObject.prototype.init.call(this);
30           
31         },
32         append : function( values ) {
33             this.list.append(values);
34         },
35           getValue  : function ( path, col)
36         {
37             // not very type safe...
38             var tpath = path;
39             if (typeof(path) == 'string' ) {
40                 tpath = new Gtk.TreePath.from_string(path);
41                  
42             }
43             
44             var iter = new Gtk.TreeIter();
45             
46             this.el.get_iter (iter, tpath) ;
47              
48             var gval = new GObject.Value(  [this.el.get_column_type(col), null ]);
49             this.list.el.get_value( iter, col, gval);
50             print("GET VALUE RETURNED: " + gval.value);
51             return gval.value;
52         },
53         setValue  : function ( path, col, val)
54         {
55             var tpath = path;
56             if (typeof(path) == 'string' ) {
57                 tpath = new Gtk.TreePath.from_string(path);
58             }
59             var iter = new Gtk.TreeIter();
60             this.el.get_iter (iter, tpath) ;
61             this.list.el.set_value(iter,col,val);
62         }
63                 
64         
65     }
66 );