*
*
*
- * @arg xtype {String|Function} constructor or string.
- * @arg id {String} (optional) id for registry
- * @arg xns {String|Object} (optional) namespace eg. Gtk or 'Gtk' - used with xtype.
- * @arg items {Array} (optional) list of child elements which will be constructed.. using XObject
+ * @arg xtype {String|Function} constructor or string.
+ * @arg id {String} (optional) id for registry
+ * @arg xns {String|Object} (optional) namespace eg. Gtk or 'Gtk' - used with xtype.
+ * @arg items {Array} (optional) list of child elements which will be constructed.. using XObject
* @arg listeners {Object} (optional) map Gobject signals to functions
- * @arg pack {Function|String|Array} (optional) how this object gets added to it's parent
- * @arg el {Object} (optional) premade GObject
+ * @arg pack {Function|String|Array} (optional) how this object gets added to it's parent
+ * @arg el {Object} (optional) premade GObject
*
* --- needs a xdebug option!
*
if (cfg.init) {
this.init = cfg.init; // override!
}
-
-
}
-
-
XObject.prototype = {
/**
* @property el {GObject} the Gtk / etc. element.
for (var i in o) {
if ((typeof(o[i]) == 'object') ||
(typeof(o[i]) == 'function') ||
- i == 'pack' ||
- i == 'id' ||
- i == 'xtype' ||
+ i == 'pack' ||
+ i == 'id' ||
+ i == 'xtype' ||
i == 'xdebug' ||
i == 'xns'
) {
* @arg cfg {Object} same as XObject constructor.
*/
addItem : function(o) {
-
-
+
var item = (o.constructor == XObject) ? o : new XObject(o);
item.init();
item.parent = this;
if (item.pack===false) { // no
return;
}
+
if (typeof(item.pack) == 'function') {
// parent, child
item.pack.apply(o, [ o , o.items[i] ]);
item.parent = this;
return;
}
+
var args = [];
var pack_m = false;
if (typeof(item.pack) == 'string') {
if (pack_m) {
this.el[pack_m].apply(this.el, args);
}
-
-
-
},
+
/**
- * @method addListener
- * Connects a method to a signal. (gjs/Seed aware)
- *
- * @arg sig {String} name of signal
- * @arg fn {Function} handler.
- */
+ * @method addListener
+ * Connects a method to a signal. (gjs/Seed aware)
+ *
+ * @arg sig {String} name of signal
+ * @arg fn {Function} handler.
+ */
addListener : function(sig, fn)
{
} else {
this.el.connect( sig, _li);
}
-
-
},
- /**
- * @method get
- * Finds an object in the child elements using xid of object.
- * prefix with '.' to look up the tree.. multiple '..' to look further up..
- *
- * @arg name {String} name of signal
- * @return {XObject|false} the object if found.
- */
+
+ /**
+ * @method get
+ * Finds an object in the child elements using xid of object.
+ * prefix with '.' to look up the tree.. multiple '..' to look further up..
+ *
+ * @arg name {String} name of signal
+ * @return {XObject|false} the object if found.
+ */
get : function(xid)
{
var ret= false;
if (xid[0] == '.') {
return this.parent.get(xid.substring(1));
}
-
-
+
this.items.forEach(function(ch) {
if (ch.id == xid) {
ret = ch;
return true;
- }
- })
+ } else
+ return false;
+ });
+
if (ret) {
return ret;
}
+
// iterate children.
this.items.forEach(function(ch) {
ret = ch.get(xid);
if (ret) {
return true;
- }
- })
+ } else
+ return false;
+ });
+
return ret;
}
-
-
}
-
-
+
+
/**
* Copies all the properties of config to obj.
*
* @return {Object} returns obj
* @member XObject extend
*/
-
-
XObject.extend = function(o, c, defaults){
if(defaults){
// no "this" reference for friendly out of scope calls
* @return {Object} returns obj
* @member Object extendIf
*/
-
-
extendIf : function(o, c){
if(!o || !c || typeof c != 'object'){
return o;
}
+
for(var p in c){
if (typeof(o[p]) != 'undefined') {
continue;
}
o[p] = c[p];
}
+
return o;
},
-
-
/**
* Extends one class with another class and optionally overrides members with the passed literal. This class
* also adds the function "override()" to the class that can be used to override
* ... methods and properties.
* }
* });
+ *
* @param {Function} constructor The class inheriting the functionality
* @param {Object} superclass The class being extended
* @param {Object} overrides (optional) A literal with members
this[m] = o[m];
}
};
+
return function(sb, sp, overrides) {
if (typeof(sp) == 'undefined') {
// error condition - try and dump..
};
}(),
-
/**
* returns a list of keys of the object.
* @param {Object} obj object to inspect
* x = XObject.createDelegate(a, this);
*
*/
-
createDelegate : function(method, obj, args, appendArgs){
return function() {
callArgs = Array.prototype.slice.call(arguments, 0);
callArgs = callArgs.concat(args);
}else if(typeof appendArgs == "number"){
- callArgs = Array.prototype.slice.call(arguments, 0); // copy arguments first
- var applyArgs = [appendArgs, 0].concat(args); // create method call params
+ callArgs = Array.prototype.slice.call(arguments, 0); // copy arguments first
+ var applyArgs = [appendArgs, 0].concat(args); // create method call params
Array.prototype.splice.apply(callArgs, applyArgs); // splice them in
}
return method.apply(obj || window, callArgs);
};
}
-
-});
\ No newline at end of file
+});