I'm developing an extension to the gnome shell. My extension requires a slider bar to a indicator on the status area. I had some problems setting it, I was writing my code on this slightly outdated reference, the main problem was that the 'PopupSliderMenuItem' was missing in the source code. So i did some research and found out that it was deleted. This commit has more information.
So I tried to follow this (updated) code on the commit:
this._slider = new Slider.Slider(0);
this._slider.connect('value-changed', Lang.bind(this, this._sliderChanged));
this._slider.connect('drag-end', Lang.bind(this, this._notifyVolumeChange));
this.item = new PopupMenu.PopupBaseMenuItem({ activate: false });
this.item.addActor(this._slider.actor, { expand: true });
I refactored this code to my project, and it looks like this:
this.slider = new Slider.Slider(0.5);
this.slider.connect('value-changed', Lang.bind(this, this._sliderChanged));
this.slider.connect('drag-end', Lang.bind(this, this._setNewColorTemperature));
this.sliderContainer = new PopupMenu.PopupBaseMenuItem();
this.sliderContainer.addActor(this.slider.actor, { expand: true });
this.menu.addMenuItem(this.sliderContainer);
The first block is on the gnome-shell source code (it sets the volume slider). My code (the second block) is throwing this exception on the 'addActor' line:
Gjs-Message: JS LOG: Extension ****censored**** had error: TypeError: sliderContainer.addActor is not a function
Anyone has any idea why this error is happening? The strangest thing is that the source code for the PopupBaseMenuItem class has the function that I'm calling.
If you need any other information I'm happy to provide.
After looking with more attention to the source code, I found that the right way to set an actor is through the .actor property.
So my code is looking like this now (and it's working):
this.slider = new Slider.Slider(0.5);
this.slider.connect('value-changed', Lang.bind(this, this._sliderChanged));
this.slider.connect('drag-end', Lang.bind(this, this._setNewColorTemperature));
this.sliderContainer = new PopupMenu.PopupBaseMenuItem();
this.sliderContainer.actor = this.slider.actor;
this.menu.addMenuItem(this.sliderContainer);