2023-11-21 01:29:46 -05:00
|
|
|
import App from 'resource:///com/github/Aylur/ags/app.js';
|
2023-10-31 08:32:40 -04:00
|
|
|
import Mpris from 'resource:///com/github/Aylur/ags/service/mpris.js';
|
2023-11-21 01:29:46 -05:00
|
|
|
|
2023-11-16 15:02:00 -05:00
|
|
|
import { CenterBox, Icon, ToggleButton } from 'resource:///com/github/Aylur/ags/widget.js';
|
2023-10-18 11:53:49 -04:00
|
|
|
|
|
|
|
|
2023-12-23 01:14:21 -05:00
|
|
|
/** @param {import('types/widgets/revealer').default} rev */
|
2023-11-21 01:29:46 -05:00
|
|
|
export default (rev) => CenterBox({
|
2023-11-16 15:02:00 -05:00
|
|
|
center_widget: ToggleButton({
|
|
|
|
cursor: 'pointer',
|
2023-11-21 01:29:46 -05:00
|
|
|
|
|
|
|
setup: (self) => {
|
2023-11-07 23:06:56 -05:00
|
|
|
// Open at startup if there are players
|
|
|
|
const id = Mpris.connect('changed', () => {
|
|
|
|
self.set_active(Mpris.players.length > 0);
|
|
|
|
Mpris.disconnect(id);
|
|
|
|
});
|
|
|
|
|
2023-12-17 00:01:58 -05:00
|
|
|
self.on('toggled', () => {
|
|
|
|
if (self.get_active()) {
|
2023-12-23 01:14:21 -05:00
|
|
|
self.child
|
|
|
|
// @ts-expect-error
|
|
|
|
?.setCss('-gtk-icon-transform: rotate(0deg);');
|
|
|
|
rev.reveal_child = true;
|
2023-12-17 00:01:58 -05:00
|
|
|
}
|
|
|
|
else {
|
2023-12-23 01:14:21 -05:00
|
|
|
self.child
|
|
|
|
// @ts-expect-error
|
|
|
|
?.setCss('-gtk-icon-transform: rotate(180deg);');
|
|
|
|
rev.reveal_child = false;
|
2023-12-17 00:01:58 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
2023-11-07 23:06:56 -05:00
|
|
|
|
|
|
|
child: Icon({
|
2023-11-21 01:29:46 -05:00
|
|
|
icon: `${App.configDir }/icons/down-large.svg`,
|
2023-12-23 01:14:21 -05:00
|
|
|
class_name: 'arrow',
|
2023-11-07 23:06:56 -05:00
|
|
|
css: '-gtk-icon-transform: rotate(180deg);',
|
|
|
|
}),
|
|
|
|
}),
|
|
|
|
});
|