resources/RooUsage.txt
[app.Builder.js] / old-javascript / 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         
16         this.columns = cfg.columns = cfg.columns || false;
17         delete cfg.columns;
18         XObject.call(this, cfg);
19         // this is an example...
20        
21     }, 
22     XObject,
23     {
24         pack : 'set_model',
25         init : function() 
26         {
27             XObject.prototype.init.call(this);
28             
29             if (!this.columns) { 
30                 
31                 this.el.set_column_types ( 6, [
32                     GObject.TYPE_STRING, 
33                     GObject.TYPE_STRING, 
34                     GObject.TYPE_STRING, 
35                     GObject.TYPE_STRING, 
36                     GObject.TYPE_STRING, 
37                     GObject.TYPE_STRING 
38                 ] );
39             } else {
40                  this.el.set_column_types ( this.columns.length, this.columns);
41                   
42                 
43             }
44         },
45         append : function( values ) {
46             var iter = new Gtk.TreeIter();
47             this.el.append(iter);
48             for (var i = 0; i < values.length; i++) {
49                 this.el.set_value(iter,i,values[i]);
50             }
51             
52         },
53         nextPath : function(path)
54         {
55             if (path === false) {
56                 var iter = new Gtk.TreeIter();
57                 this.el.get_iter_first(iter);
58                 return this.el.get_path(iter);    
59             }
60             var tpath = path;
61             if (typeof(path) == 'string' ) {
62                 tpath = new Gtk.TreePath.from_string(path);     
63             }
64             var iter = new Gtk.TreeIter();
65             
66             this.el.get_iter (iter, tpath) ;
67             
68             if (!this.el.iter_next(iter)) {
69                 return false;
70             };
71             return this.el.get_path(iter);
72         },
73         
74         getValue  : function ( path, col)
75         {
76             // not very type safe...
77             var tpath = path;
78             if (typeof(path) == 'string' ) {
79                 tpath = new Gtk.TreePath.from_string(path);
80                  
81             }
82             
83             var iter = new Gtk.TreeIter();
84             
85             this.el.get_iter (iter, tpath) ;
86              
87             var gval = new GObject.Value(  [this.el.get_column_type(col), null ]);
88             this.el.get_value( iter, col, gval);
89             print("GET VALUE RETURNED: " + gval.value);
90             return gval.value;
91         },
92         setValue  : function ( path, col, val)
93         {
94             var tpath = path;
95             if (typeof(path) == 'string' ) {
96                 tpath = new Gtk.TreePath.from_string(path);
97             }
98             var iter = new Gtk.TreeIter();
99             this.el.get_iter (iter, tpath) ;
100             this.el.set_value(iter,col,val);
101         }
102                 
103         
104     }
105 );