diff --git a/indicatorStatusIcon.js b/indicatorStatusIcon.js index 5ef516c..a9e2ac7 100644 --- a/indicatorStatusIcon.js +++ b/indicatorStatusIcon.js @@ -276,15 +276,15 @@ class IndicatorStatusIcon extends BaseStatusIcon { yAlign: Clutter.ActorAlign.CENTER, }); this._label = new St.Label(); - this._labelBin.add_actor(this._label); - this._box.add_actor(this._labelBin); + Util.addActor(this._labelBin, this._label); + Util.addActor(this._box, this._labelBin); } this._label.set_text(label); if (!this._box.contains(this._labelBin)) - this._box.add_actor(this._labelBin); // FIXME: why is it suddenly necessary? + Util.addActor(this._box, this._labelBin); // FIXME: why is it suddenly necessary? } else if (this._label) { this._labelBin.destroy_all_children(); - this._box.remove_actor(this._labelBin); + Util.removeActor(this._box, this._labelBin); this._labelBin.destroy(); delete this._labelBin; delete this._label; diff --git a/util.js b/util.js index a793404..0aba244 100644 --- a/util.js +++ b/util.js @@ -375,6 +375,20 @@ export function tryCleanupOldIndicators() { new Set(indicators).forEach(i => i.destroy()); } +export function addActor(obj, actor) { + if (obj.add_actor) + obj.add_actor(actor); + else + obj.add_child(actor); +} + +export function removeActor(obj, actor) { + if (obj.remove_actor) + obj.remove_actor(actor); + else + obj.remove_child(actor); +} + export const CancellableChild = GObject.registerClass({ Properties: { 'parent': GObject.ParamSpec.object(