feat(ags): hide systray when no items

This commit is contained in:
matt1432 2023-09-26 08:57:32 -04:00
parent c431df1215
commit 931376fb67
2 changed files with 38 additions and 29 deletions

View file

@ -41,8 +41,6 @@ export const Bar = Window({
SysTray, SysTray,
Separator(12),
AudioIndicator, AudioIndicator,
Separator(12), Separator(12),

View file

@ -1,8 +1,8 @@
const { SystemTray } = ags.Service; const { SystemTray } = ags.Service;
const { Box, Button, Icon, MenuItem } = ags.Widget; const { Box, Revealer, Icon, MenuItem } = ags.Widget;
const { Gtk } = imports.gi; const { Gtk } = imports.gi;
import { EventBox } from '../misc/cursorbox.js'; import { Separator } from '../misc/separator.js';
const SysTrayItem = item => MenuItem({ const SysTrayItem = item => MenuItem({
className: 'tray-item', className: 'tray-item',
@ -16,7 +16,14 @@ const SysTrayItem = item => MenuItem({
}]] }]]
}); });
export const SysTray = ags.Widget({ export const SysTray = Revealer({
transition: 'slide_right',
connections: [[SystemTray, rev => {
rev.revealChild = rev.child.children[0].get_children().length > 0;
}]],
child: Box({
children: [
ags.Widget({
type: Gtk.MenuBar, type: Gtk.MenuBar,
className: 'sys-tray', className: 'sys-tray',
properties: [ properties: [
@ -43,4 +50,8 @@ export const SysTray = ags.Widget({
[SystemTray, (box, id) => box._onAdded(box, id), 'added'], [SystemTray, (box, id) => box._onAdded(box, id), 'added'],
[SystemTray, (box, id) => box._onRemoved(box, id), 'removed'], [SystemTray, (box, id) => box._onRemoved(box, id), 'removed'],
], ],
}),
Separator(12),
],
}),
}); });