nixos-configs/hosts/wim/config/ags/js/quick-settings/main.js

78 lines
2 KiB
JavaScript
Raw Normal View History

import { Mpris, Widget } from '../../imports.js';
const { Box, Label, Revealer, Icon } = Widget;
import Gtk from 'gi://Gtk';
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';
const QuickSettingsWidget = Box({
className: 'qs-container',
vertical: true,
children: [
Box({
className: 'quick-settings',
vertical: true,
children: [
Label({
label: 'Control Center',
className: 'title',
halign: 'start',
style: 'margin-left: 20px'
}),
ButtonGrid,
SliderBox,
EventBox({
child: Widget({
type: Gtk.ToggleButton,
setup: btn => {
const id = Mpris.connect('changed', () => {
btn.set_active(Mpris.players.length > 0);
Mpris.disconnect(id);
});
},
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({
icon: 'go-down-symbolic',
className: 'arrow',
style: `-gtk-icon-transform: rotate(180deg);`,
}),
}),
}),
],
}),
Revealer({
transition: 'slide_down',
child: Player(),
})
],
});
export const QuickSettings = PopupWindow({
name: 'quick-settings',
2023-10-07 21:02:23 -04:00
anchor: [ 'top', 'right' ],
margin: [ 8, 5, 0, ],
child: QuickSettingsWidget,
});