//<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(','));
- this.el = new (this.xtype)(this.config);
+ try {
+ 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,null,4));
+ print(JSON.stringify(this.config,null,4));
+ print(e.stack);
+
+ throw {
+ name: "ArgumentError",
+ message :"Error creating object from xtype(object)"
+ };
+ }
+
}
//print(this.el);
if (!this.el) {
print('missing el?');
- print(this.cfg);
- print(this.init);
- }
+ print(fn);
+ print(JSON.stringify(this.cfg));
+ }
if (typeof(Seed) != 'undefined') {
}
},
-
+ /**
+ * 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
}
XObject.log("TRYING BASE OBJECT : " + gname);
+
// in the situation where we have been called and there is a base object
// defining the behavior..
// then we should copy the prototypes from the base object into this..