//<script type="text/javascript">
-GIRepository = imports.gi.GIRepository;
-GObject = imports.gi.GObject;
+const GIRepository = imports.gi.GIRepository;
+const GObject = imports.gi.GObject;
/**
* XObject
* Yet another attempt to create a usable object construction library for seed..
// xtype= Gtk.Menu ?? what about c_new stuff?
XObject.log("init: ID:"+ this.id +" typeof(xtype): " + typeof(this.xtype));
- if (!this.el && typeof(this.xtype) == 'function') {
+
+ var xtypeof = isSeed ? typeof(this.xtype) :
+ // oterhwise it's gjs, which case ctors are functions, not objects...
+ ( typeof(this.xtype) == 'function' ? 'object' : typeof(this.xtype) );
+
+ if (!this.el && xtypeof == 'function') {
XObject.log("func?" + XObject.keys(this.config).join(','));
this.el = this.xtype(this.config);
}
- if (!this.el && typeof(this.xtype) == 'object') {
+ if (!this.el && xtypeof == 'object') {
+ XObject.log(this.xtype.toString());
+
XObject.log("obj?" + XObject.keys(this.config).join(','));
try {
- this.el = new (this.xtype)(this.config);
+ if (!isSeed) {
+ // gjs does not like properties that do not exist..
+
+ this.el = new (this.xtype)({});
+ XObject.extend(this.el, this.config);
+
+ } else {
+
+ this.el = new (this.xtype)(this.config);
+ }
} catch(e) {
- print(JSON.stringify(e.stack, null,4));
+ print(JSON.stringify(e,null,4));
+ print(JSON.stringify(this.config,null,4));
+ print(e.stack);
+
throw {
name: "ArgumentError",
message :"Error creating object from xtype(object)"
}
},
-
+ /**
+ * usefull for compatibilyt.
+ *
+ */
+ isSeed : typeof(Seed) != 'undefined',
/**
* Copies all the properties of config to obj, if the do not exist.
* @param {Object} obj The receiver of the properties