feat(ags): hide systray when no items
This commit is contained in:
parent
c431df1215
commit
931376fb67
2 changed files with 38 additions and 29 deletions
|
@ -41,8 +41,6 @@ export const Bar = Window({
|
||||||
|
|
||||||
SysTray,
|
SysTray,
|
||||||
|
|
||||||
Separator(12),
|
|
||||||
|
|
||||||
AudioIndicator,
|
AudioIndicator,
|
||||||
|
|
||||||
Separator(12),
|
Separator(12),
|
||||||
|
|
|
@ -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,31 +16,42 @@ const SysTrayItem = item => MenuItem({
|
||||||
}]]
|
}]]
|
||||||
});
|
});
|
||||||
|
|
||||||
export const SysTray = ags.Widget({
|
export const SysTray = Revealer({
|
||||||
type: Gtk.MenuBar,
|
transition: 'slide_right',
|
||||||
className: 'sys-tray',
|
connections: [[SystemTray, rev => {
|
||||||
properties: [
|
rev.revealChild = rev.child.children[0].get_children().length > 0;
|
||||||
['items', new Map()],
|
}]],
|
||||||
['onAdded', (box, id) => {
|
child: Box({
|
||||||
const item = SystemTray.getItem(id);
|
children: [
|
||||||
if (box._items.has(id) || !item)
|
ags.Widget({
|
||||||
return;
|
type: Gtk.MenuBar,
|
||||||
|
className: 'sys-tray',
|
||||||
|
properties: [
|
||||||
|
['items', new Map()],
|
||||||
|
['onAdded', (box, id) => {
|
||||||
|
const item = SystemTray.getItem(id);
|
||||||
|
if (box._items.has(id) || !item)
|
||||||
|
return;
|
||||||
|
|
||||||
const widget = SysTrayItem(item);
|
const widget = SysTrayItem(item);
|
||||||
box._items.set(id, widget);
|
box._items.set(id, widget);
|
||||||
box.add(widget);
|
box.add(widget);
|
||||||
box.show_all();
|
box.show_all();
|
||||||
}],
|
}],
|
||||||
['onRemoved', (box, id) => {
|
['onRemoved', (box, id) => {
|
||||||
if (!box._items.has(id))
|
if (!box._items.has(id))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
box._items.get(id).destroy();
|
box._items.get(id).destroy();
|
||||||
box._items.delete(id);
|
box._items.delete(id);
|
||||||
}],
|
}],
|
||||||
],
|
],
|
||||||
connections: [
|
connections: [
|
||||||
[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),
|
||||||
|
],
|
||||||
|
}),
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue