2023-10-31 08:32:40 -04:00
|
|
|
import Mpris from 'resource:///com/github/Aylur/ags/service/mpris.js';
|
|
|
|
import { Icon } from 'resource:///com/github/Aylur/ags/widget.js';
|
2023-10-18 11:53:49 -04:00
|
|
|
|
|
|
|
import Gtk from 'gi://Gtk';
|
2023-10-31 08:32:40 -04:00
|
|
|
import EventBox from '../misc/cursorbox.js';
|
2023-10-18 11:53:49 -04:00
|
|
|
|
|
|
|
export default () => {
|
2023-10-20 23:11:21 -04:00
|
|
|
const widget = EventBox({});
|
|
|
|
|
|
|
|
const toggleButton = Gtk.ToggleButton.new();
|
|
|
|
toggleButton.add(Icon({
|
|
|
|
icon: 'go-down-symbolic',
|
|
|
|
className: 'arrow',
|
2023-11-06 18:37:23 -05:00
|
|
|
css: '-gtk-icon-transform: rotate(180deg);',
|
2023-10-20 23:11:21 -04:00
|
|
|
}));
|
|
|
|
|
|
|
|
// Setup
|
|
|
|
const id = Mpris.connect('changed', () => {
|
|
|
|
toggleButton.set_active(Mpris.players.length > 0);
|
|
|
|
Mpris.disconnect(id);
|
|
|
|
});
|
|
|
|
|
|
|
|
// Connections
|
|
|
|
toggleButton.connect('toggled', () => {
|
|
|
|
const rev = toggleButton.get_parent().get_parent().get_parent().children[1];
|
|
|
|
|
|
|
|
if (toggleButton.get_active()) {
|
|
|
|
toggleButton.get_children()[0]
|
2023-11-06 18:37:23 -05:00
|
|
|
.setCss('-gtk-icon-transform: rotate(0deg);');
|
2023-10-20 23:11:21 -04:00
|
|
|
rev.revealChild = true;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
toggleButton.get_children()[0]
|
2023-11-06 18:37:23 -05:00
|
|
|
.setCss('-gtk-icon-transform: rotate(180deg);');
|
2023-10-20 23:11:21 -04:00
|
|
|
rev.revealChild = false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
widget.add(toggleButton);
|
|
|
|
|
|
|
|
return widget;
|
|
|
|
};
|