2009-09-18 15:51:15 -04:00
|
|
|
/* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */
|
|
|
|
|
|
|
|
const St = imports.gi.St;
|
2009-11-14 12:08:27 -05:00
|
|
|
const Gettext_gtk20 = imports.gettext.domain('gtk20');
|
2009-09-18 15:51:15 -04:00
|
|
|
|
|
|
|
const Tweener = imports.ui.tweener;
|
|
|
|
|
2009-10-04 17:30:18 -04:00
|
|
|
const Format = imports.misc.format;
|
|
|
|
|
2009-09-18 15:51:15 -04:00
|
|
|
// "monkey patch" in some varargs ClutterContainer methods; we need
|
|
|
|
// to do this per-container class since there is no representation
|
|
|
|
// of interfaces in Javascript
|
|
|
|
function _patchContainerClass(containerClass) {
|
|
|
|
// This one is a straightforward mapping of the C method
|
|
|
|
containerClass.prototype.child_set = function(actor, props) {
|
|
|
|
let meta = this.get_child_meta(actor);
|
|
|
|
for (prop in props)
|
|
|
|
meta[prop] = props[prop];
|
|
|
|
};
|
|
|
|
|
|
|
|
// clutter_container_add() actually is a an add-many-actors
|
|
|
|
// method. We conveniently, but somewhat dubiously, take the
|
|
|
|
// this opportunity to make it do something more useful.
|
|
|
|
containerClass.prototype.add = function(actor, props) {
|
|
|
|
this.add_actor(actor);
|
|
|
|
if (props)
|
|
|
|
this.child_set(actor, props);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
_patchContainerClass(St.BoxLayout);
|
2009-09-30 00:04:42 -04:00
|
|
|
_patchContainerClass(St.Table);
|
2009-09-18 15:51:15 -04:00
|
|
|
|
|
|
|
function init() {
|
|
|
|
Tweener.init();
|
2009-10-04 17:30:18 -04:00
|
|
|
String.prototype.format = Format.format;
|
2009-11-14 12:08:27 -05:00
|
|
|
|
|
|
|
// Set the default direction for St widgets (this needs to be done before any use of St)
|
2010-05-13 15:46:04 -04:00
|
|
|
if (Gettext_gtk20.gettext('default:LTR') == 'default:RTL') {
|
2009-11-14 12:08:27 -05:00
|
|
|
St.Widget.set_default_direction(St.TextDirection.RTL);
|
|
|
|
}
|
2009-09-18 15:51:15 -04:00
|
|
|
}
|