2023-10-02 12:06:35 -04:00
|
|
|
import { Mpris, Widget } from '../../imports.js';
|
|
|
|
const { Window, Box, Label, Revealer, Icon } = Widget;
|
|
|
|
|
|
|
|
import Gtk from 'gi://Gtk';
|
2023-09-12 14:22:21 -04:00
|
|
|
|
|
|
|
import { ButtonGrid } from './button-grid.js';
|
2023-09-12 15:27:39 -04:00
|
|
|
import { SliderBox } from './slider-box.js';
|
2023-09-15 23:22:16 -04:00
|
|
|
import Player from '../media-player/player.js';
|
|
|
|
import { EventBox } from '../misc/cursorbox.js';
|
2023-09-21 20:01:14 -04:00
|
|
|
import { PopUp } from '../misc/popup.js';
|
2023-09-12 14:22:21 -04:00
|
|
|
|
2023-10-02 12:06:35 -04:00
|
|
|
|
2023-09-21 20:01:14 -04:00
|
|
|
const QuickSettingsWidget = Box({
|
|
|
|
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-09-21 20:01:14 -04:00
|
|
|
ButtonGrid,
|
2023-09-12 14:22:21 -04:00
|
|
|
|
2023-09-21 20:01:14 -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 => {
|
|
|
|
if (button.get_active()) {
|
|
|
|
button.child.setStyle("-gtk-icon-transform: rotate(0deg);");
|
|
|
|
button.get_parent().get_parent().get_parent().children[1].revealChild = true;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
button.child.setStyle('-gtk-icon-transform: rotate(180deg);');
|
|
|
|
button.get_parent().get_parent().get_parent().children[1].revealChild = false;
|
|
|
|
}
|
|
|
|
}]],
|
|
|
|
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
|
|
|
],
|
|
|
|
});
|
|
|
|
|
|
|
|
export const QuickSettings = Window({
|
|
|
|
name: 'quick-settings',
|
|
|
|
layer: 'overlay',
|
2023-10-07 21:02:23 -04:00
|
|
|
anchor: [ 'top', 'right' ],
|
2023-09-25 12:30:32 -04:00
|
|
|
popup: true,
|
2023-09-21 20:01:14 -04:00
|
|
|
margin: [ 8, 5, 0, ],
|
|
|
|
child: PopUp({
|
|
|
|
name: 'quick-settings',
|
|
|
|
child: QuickSettingsWidget,
|
2023-09-12 14:22:21 -04:00
|
|
|
}),
|
|
|
|
});
|