143 lines
4.8 KiB
JavaScript
143 lines
4.8 KiB
JavaScript
import Audio from 'resource:///com/github/Aylur/ags/service/audio.js';
|
|
|
|
import { Box, Slider, Icon } from 'resource:///com/github/Aylur/ags/widget.js';
|
|
|
|
const { Gdk } = imports.gi;
|
|
const display = Gdk.Display.get_default();
|
|
|
|
import Brightness from '../../services/brightness.js';
|
|
import { SpeakerIcon } from '../misc/audio-icons.js';
|
|
|
|
|
|
export default () => Box({
|
|
class_name: 'slider-box',
|
|
vertical: true,
|
|
hpack: 'center',
|
|
children: [
|
|
|
|
Box({
|
|
class_name: 'slider',
|
|
vpack: 'start',
|
|
hpack: 'center',
|
|
|
|
children: [
|
|
Icon({
|
|
size: 26,
|
|
class_name: 'slider-label',
|
|
icon: SpeakerIcon.bind(),
|
|
}),
|
|
|
|
Slider({
|
|
vpack: 'center',
|
|
max: 0.999,
|
|
draw_value: false,
|
|
|
|
on_change: ({ value }) => {
|
|
if (Audio.speaker) {
|
|
Audio.speaker.volume = value;
|
|
}
|
|
},
|
|
|
|
setup: (self) => {
|
|
self
|
|
.hook(Audio, () => {
|
|
self.value = Audio.speaker?.volume || 0;
|
|
}, 'speaker-changed')
|
|
|
|
// OnClick
|
|
.on('button-press-event', () => {
|
|
self.window.set_cursor(Gdk.Cursor.new_from_name(
|
|
display,
|
|
'grabbing',
|
|
));
|
|
})
|
|
|
|
// OnRelease
|
|
.on('button-release-event', () => {
|
|
self.window.set_cursor(Gdk.Cursor.new_from_name(
|
|
display,
|
|
'pointer',
|
|
));
|
|
})
|
|
|
|
// OnHover
|
|
.on('enter-notify-event', () => {
|
|
self.window.set_cursor(Gdk.Cursor.new_from_name(
|
|
display,
|
|
'pointer',
|
|
));
|
|
self.toggleClassName('hover', true);
|
|
})
|
|
|
|
// OnHoverLost
|
|
.on('leave-notify-event', () => {
|
|
self.window.set_cursor(null);
|
|
self.toggleClassName('hover', false);
|
|
});
|
|
},
|
|
}),
|
|
],
|
|
}),
|
|
|
|
Box({
|
|
class_name: 'slider',
|
|
vpack: 'start',
|
|
hpack: 'center',
|
|
|
|
children: [
|
|
Icon({
|
|
class_name: 'slider-label',
|
|
icon: Brightness.bind('screenIcon'),
|
|
}),
|
|
|
|
Slider({
|
|
vpack: 'center',
|
|
draw_value: false,
|
|
|
|
on_change: ({ value }) => {
|
|
Brightness.screen = value;
|
|
},
|
|
|
|
setup: (self) => {
|
|
self
|
|
.hook(Brightness, () => {
|
|
self.value = Brightness.screen;
|
|
}, 'screen')
|
|
|
|
// OnClick
|
|
.on('button-press-event', () => {
|
|
self.window.set_cursor(Gdk.Cursor.new_from_name(
|
|
display,
|
|
'grabbing',
|
|
));
|
|
})
|
|
|
|
// OnRelease
|
|
.on('button-release-event', () => {
|
|
self.window.set_cursor(Gdk.Cursor.new_from_name(
|
|
display,
|
|
'pointer',
|
|
));
|
|
})
|
|
|
|
// OnHover
|
|
.on('enter-notify-event', () => {
|
|
self.window.set_cursor(Gdk.Cursor.new_from_name(
|
|
display,
|
|
'pointer',
|
|
));
|
|
self.toggleClassName('hover', true);
|
|
})
|
|
|
|
// OnHoverLost
|
|
.on('leave-notify-event', () => {
|
|
self.window.set_cursor(null);
|
|
self.toggleClassName('hover', false);
|
|
});
|
|
},
|
|
}),
|
|
],
|
|
}),
|
|
|
|
],
|
|
});
|