feat(ags): open players by default if there's at least one at launch

This commit is contained in:
matt1432 2023-09-22 12:24:20 -04:00
parent d82b3cb765
commit b2ac299f05

View file

@ -1,5 +1,5 @@
const { Window, CenterBox, Box, Label, Revealer, Icon } = ags.Widget; const { Window, Box, Label, Revealer, Icon } = ags.Widget;
const { closeWindow } = ags.App; const { Mpris } = ags.Service;
const { ToggleButton } = imports.gi.Gtk; const { ToggleButton } = imports.gi.Gtk;
import { ButtonGrid } from './button-grid.js'; import { ButtonGrid } from './button-grid.js';
@ -32,6 +32,12 @@ const QuickSettingsWidget = Box({
EventBox({ EventBox({
child: ags.Widget({ child: ags.Widget({
type: ToggleButton, type: ToggleButton,
setup: btn => {
const id = Mpris.instance.connect('changed', () => {
btn.set_active(Mpris.players.length > 0);
Mpris.instance.disconnect(id);
});
},
connections: [['toggled', button => { connections: [['toggled', button => {
if (button.get_active()) { if (button.get_active()) {
button.child.setStyle("-gtk-icon-transform: rotate(0deg);"); button.child.setStyle("-gtk-icon-transform: rotate(0deg);");