2bb597c5ea911135ddea4818efe1f73e6d43f39a
[app.Builder.js] / XObjectBase / GtkListStore.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 GtkListStore = 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             XObject.prototype.init.call(this);
25             this.el.set_column_types ( 6, [
26                 GObject.TYPE_STRING, 
27                 GObject.TYPE_STRING, 
28                 GObject.TYPE_STRING, 
29                 GObject.TYPE_STRING, 
30                 GObject.TYPE_STRING, 
31                 GObject.TYPE_STRING 
32             ] );
33             
34         },
35         append : function( values ) {
36             var iter = new Gtk.TreeIter();
37             this.el.append(iter);
38             for (var i = 0; i < values.length; i++) {
39                 this.el.set_value(iter,i,values[i]);
40             }
41             
42         },
43         getValue  : function ( path, col)
44         {
45             // not very type safe...
46             var tpath = path;
47             if (typeof(path) == 'string' ) {
48                 tpath = new Gtk.TreePath.from_string(path);
49             }
50             
51             var iter = new Gtk.TreeIter();
52             this.el.get_iter (iter, tpath) ;
53             print(iter.toString());
54             //print(XObject.type(iter));
55             
56             var gval = new GObject.Value(  [this.el.get_column_type(col), null ]);
57             this.el.get_value( iter, col, gval);
58             print("GET VALUE RETURNED: " + gval.value);
59             return gval.value;
60         },
61         setValue  : function ( path, col, val)
62         {
63             var tpath = path;
64             if (typeof(path) == 'string' ) {
65                 tpath = new Gtk.TreePath.from_string(path);
66             }
67             var iter = new Gtk.TreeIter();
68             this.el.get_iter (iter, tpath) ;
69             this.el.set_value(iter,col,val);
70         }
71                 
72         
73     }
74 );