mirror of
https://github.com/Rafostar/clapper.git
synced 2025-08-31 08:21:59 +02:00
Fix volume button icon behaviour
This commit is contained in:
37
clapper_src/controls.js
vendored
37
clapper_src/controls.js
vendored
@@ -29,7 +29,16 @@ class ClapperControls extends Gtk.HBox
|
||||
this.positionAdjustment = this.positionScale.get_adjustment();
|
||||
|
||||
this.volumeButton = new Gtk.ScaleButton({
|
||||
icons: ['audio-volume-muted-symbolic'],
|
||||
icons: [
|
||||
'audio-volume-muted-symbolic',
|
||||
'audio-volume-overamplified-symbolic',
|
||||
'audio-volume-low-symbolic',
|
||||
'audio-volume-medium-symbolic',
|
||||
'audio-volume-high-symbolic',
|
||||
'audio-volume-overamplified-symbolic',
|
||||
'audio-volume-overamplified-symbolic',
|
||||
'audio-volume-overamplified-symbolic',
|
||||
],
|
||||
size: Gtk.IconSize.SMALL_TOOLBAR
|
||||
});
|
||||
this.volumeButtonImage = this.volumeButton.get_child();
|
||||
@@ -55,14 +64,10 @@ class ClapperControls extends Gtk.HBox
|
||||
|
||||
_prepareVolumeButton()
|
||||
{
|
||||
this.volumeAdjustment.set_upper(2);
|
||||
this.volumeAdjustment.set_upper(2.001);
|
||||
this.volumeAdjustment.set_step_increment(0.05);
|
||||
this.volumeAdjustment.set_page_increment(0.05);
|
||||
|
||||
this.volumeButton.connect(
|
||||
'value-changed', this._onVolumeValueChanged.bind(this)
|
||||
);
|
||||
|
||||
let popup = this.volumeButton.get_popup();
|
||||
let box = popup.get_child();
|
||||
let boxChildren = box.get_children();
|
||||
@@ -72,29 +77,11 @@ class ClapperControls extends Gtk.HBox
|
||||
box.remove(child);
|
||||
else if(child.constructor === Gtk.Scale) {
|
||||
child.height_request = 200;
|
||||
child.round_digits = 2;
|
||||
child.add_mark(0, Gtk.PositionType.LEFT, '0%');
|
||||
child.add_mark(1, Gtk.PositionType.LEFT, '100%');
|
||||
child.add_mark(2, Gtk.PositionType.LEFT, '200%');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_onVolumeValueChanged(widget, value)
|
||||
{
|
||||
if(value <= 0)
|
||||
return;
|
||||
|
||||
let iconName = (value <= 0.33)
|
||||
? 'audio-volume-low-symbolic'
|
||||
: (value <= 0.66)
|
||||
? 'audio-volume-medium-symbolic'
|
||||
: (value <= 1)
|
||||
? 'audio-volume-high-symbolic'
|
||||
: 'audio-volume-overamplified-symbolic';
|
||||
|
||||
if(this.volumeButtonImage.icon_name === iconName)
|
||||
return;
|
||||
|
||||
this.volumeButtonImage.icon_name = iconName;
|
||||
}
|
||||
});
|
||||
|
Reference in New Issue
Block a user