X-Git-Url: http://git.roojs.org/?a=blobdiff_plain;f=XObjectBase%2FGtkListStore.js;h=d33142f4b87c9f90f3b782fa9cef07c5e61e4c3c;hb=507e44b9f9eaf3d5bda7ba290a9cbef1a46b51d7;hp=22e4cc5a11a7a688e2128bce846a1c38d5987efa;hpb=c8398e727caa6601fb53900b5c6df0c634652a48;p=app.Builder.js diff --git a/XObjectBase/GtkListStore.js b/XObjectBase/GtkListStore.js index 22e4cc5a1..d33142f4b 100644 --- a/XObjectBase/GtkListStore.js +++ b/XObjectBase/GtkListStore.js @@ -3,7 +3,10 @@ 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.. @@ -11,19 +14,61 @@ GtkListStore = XObject.define( function(cfg) { XObject.call(this, cfg); // this is an example... - this.el.set_column_types ( 6, [ - GObject.TYPE_STRING, // real key - GObject.TYPE_STRING, // real type - GObject.TYPE_STRING, // docs ? - GObject.TYPE_STRING, // visable desc - GObject.TYPE_STRING, // function desc - GObject.TYPE_STRING // element type (event|prop) - - ] ); + }, XObject, { - pack : 'set_model' + pack : 'set_model', + init : function() + { + XObject.prototype.init.call(this); + this.el.set_column_types ( 6, [ + GObject.TYPE_STRING, + GObject.TYPE_STRING, + GObject.TYPE_STRING, + GObject.TYPE_STRING, + 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) ; + print(GObject.type_name_from_instance(iter)); + //print(XObject.type(iter)); + + 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); + } + + } - );