X-Git-Url: http://git.roojs.org/?a=blobdiff_plain;f=XObjectBase%2FGtkListStore.js;h=382ba196b998741b2b5295bcfa1848e6a8eec1ce;hb=3a1d6f2dcc9b4b4d75f50411ff8b784247979a85;hp=b426cfa8e8497c182827ce30c2e538c503c9d875;hpb=b7b51a1f8e30f30ee91b223c11c12d40cdf7eca2;p=app.Builder.js diff --git a/XObjectBase/GtkListStore.js b/XObjectBase/GtkListStore.js index b426cfa8e..382ba196b 100644 --- a/XObjectBase/GtkListStore.js +++ b/XObjectBase/GtkListStore.js @@ -5,6 +5,8 @@ XObject = imports.XObject.XObject GObject = imports.gi.GObject; //GtkClutter.Embed.. +Gtk= imports.gi.Gtk; + // children are not added at init / but at show stage.. // listener is added on show.. // we should really add a hock to destroy it.. @@ -19,6 +21,7 @@ GtkListStore = XObject.define( pack : 'set_model', init : function() { + XObject.prototype.init.call(this); this.el.set_column_types ( 6, [ GObject.TYPE_STRING, GObject.TYPE_STRING, @@ -27,6 +30,45 @@ GtkListStore = XObject.define( GObject.TYPE_STRING, GObject.TYPE_STRING ] ); + + }, + append : function( values ) { + var iter = new Gtk.TreeIter(); + this.el.append(iter); + for (var i = 0; i < values.length; i++) { + this.el.set_value(iter,i,values[i]); + } + + }, + getValue : function ( path, col) + { + // not very type safe... + var tpath = path; + if (typeof(path) == 'string' ) { + tpath = new Gtk.TreePath.from_string(path); + + } + + var iter = new Gtk.TreeIter(); + + this.el.get_iter (iter, tpath) ; + + var gval = new GObject.Value( [this.el.get_column_type(col), null ]); + this.el.get_value( iter, col, gval); + print("GET VALUE RETURNED: " + gval.value); + return gval.value; + }, + setValue : function ( path, col, val) + { + var tpath = path; + if (typeof(path) == 'string' ) { + tpath = new Gtk.TreePath.from_string(path); + } + var iter = new Gtk.TreeIter(); + this.el.get_iter (iter, tpath) ; + this.el.set_value(iter,col,val); } + + } );