2023-10-02 12:06:35 -04:00
|
|
|
import { SystemTray, Widget } from '../../imports.js';
|
|
|
|
const { Box, Revealer, Icon, MenuItem } = Widget;
|
|
|
|
|
|
|
|
import Gtk from 'gi://Gtk';
|
2023-09-11 19:57:21 -04:00
|
|
|
|
2023-10-17 13:47:02 -04:00
|
|
|
import Separator from '../misc/separator.js';
|
2023-09-06 17:36:26 -04:00
|
|
|
|
2023-10-02 12:06:35 -04:00
|
|
|
|
2023-09-06 17:36:26 -04:00
|
|
|
const SysTrayItem = item => MenuItem({
|
2023-09-08 21:27:25 -04:00
|
|
|
className: 'tray-item',
|
2023-10-04 12:36:22 -04:00
|
|
|
child: Revealer({
|
|
|
|
transition: 'slide_right',
|
|
|
|
child: Icon({
|
|
|
|
size: 24,
|
|
|
|
}),
|
2023-09-08 21:27:25 -04:00
|
|
|
}),
|
|
|
|
submenu: item.menu,
|
|
|
|
connections: [[item, btn => {
|
2023-10-04 12:36:22 -04:00
|
|
|
btn.child.child.icon = item.icon;
|
2023-09-08 21:27:25 -04:00
|
|
|
btn.tooltipMarkup = item.tooltipMarkup;
|
|
|
|
}]]
|
2023-09-06 17:36:26 -04:00
|
|
|
});
|
|
|
|
|
2023-10-17 13:47:02 -04:00
|
|
|
export default () => Revealer({
|
2023-09-26 08:57:32 -04:00
|
|
|
transition: 'slide_right',
|
|
|
|
connections: [[SystemTray, rev => {
|
|
|
|
rev.revealChild = rev.child.children[0].get_children().length > 0;
|
|
|
|
}]],
|
|
|
|
child: Box({
|
|
|
|
children: [
|
2023-10-04 13:35:20 -04:00
|
|
|
Box({
|
2023-09-26 08:57:32 -04:00
|
|
|
className: 'sys-tray',
|
2023-10-04 13:35:20 -04:00
|
|
|
children: [
|
|
|
|
Widget({
|
|
|
|
type: Gtk.MenuBar,
|
|
|
|
properties: [
|
|
|
|
['items', new Map()],
|
|
|
|
['onAdded', (box, id) => {
|
|
|
|
const item = SystemTray.getItem(id);
|
|
|
|
if (box._items.has(id) || !item)
|
|
|
|
return;
|
2023-09-06 17:36:26 -04:00
|
|
|
|
2023-10-04 13:35:20 -04:00
|
|
|
const widget = SysTrayItem(item);
|
|
|
|
box._items.set(id, widget);
|
|
|
|
box.add(widget);
|
|
|
|
box.show_all();
|
|
|
|
widget.child.revealChild = true;
|
|
|
|
}],
|
2023-10-04 12:36:22 -04:00
|
|
|
|
2023-10-04 13:35:20 -04:00
|
|
|
['onRemoved', (box, id) => {
|
|
|
|
if (!box._items.has(id))
|
|
|
|
return;
|
2023-09-06 17:36:26 -04:00
|
|
|
|
2023-10-04 13:35:20 -04:00
|
|
|
box._items.get(id).child.revealChild = false;
|
|
|
|
setTimeout(() => {
|
|
|
|
box._items.get(id).destroy();
|
|
|
|
box._items.delete(id);
|
|
|
|
}, 400);
|
|
|
|
}],
|
|
|
|
],
|
|
|
|
connections: [
|
|
|
|
[SystemTray, (box, id) => box._onAdded(box, id), 'added'],
|
|
|
|
[SystemTray, (box, id) => box._onRemoved(box, id), 'removed'],
|
|
|
|
],
|
|
|
|
}),
|
2023-09-26 08:57:32 -04:00
|
|
|
],
|
|
|
|
}),
|
|
|
|
Separator(12),
|
|
|
|
],
|
|
|
|
}),
|
2023-09-06 17:36:26 -04:00
|
|
|
});
|