2023-10-02 12:06:35 -04:00
|
|
|
import { Mpris, Widget } from '../../imports.js';
|
2023-10-08 00:43:35 -04:00
|
|
|
const { Box, Label, Revealer, Icon } = Widget;
|
2023-10-02 12:06:35 -04:00
|
|
|
|
|
|
|
import Gtk from 'gi://Gtk';
|
2023-09-12 14:22:21 -04:00
|
|
|
|
2023-10-17 13:47:02 -04:00
|
|
|
import ButtonGrid from './button-grid.js';
|
|
|
|
import SliderBox from './slider-box.js';
|
|
|
|
import Player from '../media-player/player.js';
|
|
|
|
import EventBox from '../misc/cursorbox.js';
|
|
|
|
import PopupWindow from '../misc/popup.js';
|
2023-09-12 14:22:21 -04:00
|
|
|
|
2023-10-02 12:06:35 -04:00
|
|
|
|
2023-10-17 13:47:02 -04:00
|
|
|
const QuickSettingsWidget = () => Box({
|
2023-09-21 20:01:14 -04:00
|
|
|
className: 'qs-container',
|
|
|
|
vertical: true,
|
|
|
|
children: [
|
2023-09-12 14:22:21 -04:00
|
|
|
|
2023-09-21 20:01:14 -04:00
|
|
|
Box({
|
|
|
|
className: 'quick-settings',
|
|
|
|
vertical: true,
|
|
|
|
children: [
|
|
|
|
|
|
|
|
Label({
|
|
|
|
label: 'Control Center',
|
|
|
|
className: 'title',
|
|
|
|
halign: 'start',
|
|
|
|
style: 'margin-left: 20px'
|
|
|
|
}),
|
2023-09-12 14:22:21 -04:00
|
|
|
|
2023-10-17 13:47:02 -04:00
|
|
|
ButtonGrid(),
|
2023-09-12 14:22:21 -04:00
|
|
|
|
2023-10-17 13:47:02 -04:00
|
|
|
SliderBox(),
|
2023-09-12 14:22:21 -04:00
|
|
|
|
2023-09-21 20:01:14 -04:00
|
|
|
EventBox({
|
2023-10-02 12:06:35 -04:00
|
|
|
child: Widget({
|
|
|
|
type: Gtk.ToggleButton,
|
2023-09-22 12:24:20 -04:00
|
|
|
setup: btn => {
|
2023-10-02 12:06:35 -04:00
|
|
|
const id = Mpris.connect('changed', () => {
|
2023-09-22 12:24:20 -04:00
|
|
|
btn.set_active(Mpris.players.length > 0);
|
2023-10-02 12:06:35 -04:00
|
|
|
Mpris.disconnect(id);
|
2023-09-22 12:24:20 -04:00
|
|
|
});
|
|
|
|
},
|
2023-09-21 20:01:14 -04:00
|
|
|
connections: [['toggled', button => {
|
2023-10-17 13:47:02 -04:00
|
|
|
let rev = button.get_parent().get_parent().get_parent().children[1];
|
|
|
|
|
2023-09-21 20:01:14 -04:00
|
|
|
if (button.get_active()) {
|
|
|
|
button.child.setStyle("-gtk-icon-transform: rotate(0deg);");
|
2023-10-17 13:47:02 -04:00
|
|
|
rev.revealChild = true;
|
2023-09-21 20:01:14 -04:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
button.child.setStyle('-gtk-icon-transform: rotate(180deg);');
|
2023-10-17 13:47:02 -04:00
|
|
|
rev.revealChild = false;
|
2023-09-21 20:01:14 -04:00
|
|
|
}
|
|
|
|
}]],
|
|
|
|
child: Icon({
|
2023-10-03 23:11:12 -04:00
|
|
|
icon: 'go-down-symbolic',
|
2023-09-21 20:01:14 -04:00
|
|
|
className: 'arrow',
|
|
|
|
style: `-gtk-icon-transform: rotate(180deg);`,
|
2023-09-15 23:22:16 -04:00
|
|
|
}),
|
|
|
|
}),
|
2023-09-21 20:01:14 -04:00
|
|
|
}),
|
2023-09-15 23:22:16 -04:00
|
|
|
|
2023-09-21 20:01:14 -04:00
|
|
|
],
|
|
|
|
}),
|
2023-09-12 14:22:21 -04:00
|
|
|
|
2023-09-21 20:01:14 -04:00
|
|
|
Revealer({
|
|
|
|
transition: 'slide_down',
|
|
|
|
child: Player(),
|
|
|
|
})
|
2023-09-12 14:22:21 -04:00
|
|
|
|
2023-09-21 20:01:14 -04:00
|
|
|
],
|
|
|
|
});
|
|
|
|
|
2023-10-16 18:11:19 -04:00
|
|
|
export default () => PopupWindow({
|
2023-09-21 20:01:14 -04:00
|
|
|
name: 'quick-settings',
|
2023-10-07 21:02:23 -04:00
|
|
|
anchor: [ 'top', 'right' ],
|
2023-09-21 20:01:14 -04:00
|
|
|
margin: [ 8, 5, 0, ],
|
2023-10-17 13:47:02 -04:00
|
|
|
child: QuickSettingsWidget(),
|
2023-09-12 14:22:21 -04:00
|
|
|
});
|