2023-09-06 17:36:26 -04:00
|
|
|
const { SystemTray } = ags.Service;
|
|
|
|
const { Box, Button, Icon, MenuItem } = ags.Widget;
|
|
|
|
const { Gtk } = imports.gi;
|
2023-09-11 19:57:21 -04:00
|
|
|
|
|
|
|
import { EventBox } from '../misc/cursorbox.js';
|
2023-09-06 17:36:26 -04:00
|
|
|
|
|
|
|
const SysTrayItem = item => MenuItem({
|
2023-09-08 21:27:25 -04:00
|
|
|
className: 'tray-item',
|
|
|
|
child: Icon({
|
|
|
|
size: 24,
|
|
|
|
}),
|
|
|
|
submenu: item.menu,
|
|
|
|
connections: [[item, btn => {
|
|
|
|
btn.child.icon = item.icon;
|
|
|
|
btn.tooltipMarkup = item.tooltipMarkup;
|
|
|
|
}]]
|
2023-09-06 17:36:26 -04:00
|
|
|
});
|
|
|
|
|
2023-09-10 23:24:58 -04:00
|
|
|
export const SysTray = ags.Widget({
|
2023-09-08 21:27:25 -04:00
|
|
|
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;
|
2023-09-06 17:36:26 -04:00
|
|
|
|
2023-09-08 21:27:25 -04:00
|
|
|
const widget = SysTrayItem(item);
|
|
|
|
box._items.set(id, widget);
|
|
|
|
box.add(widget);
|
|
|
|
box.show_all();
|
|
|
|
}],
|
|
|
|
['onRemoved', (box, id) => {
|
|
|
|
if (!box._items.has(id))
|
|
|
|
return;
|
2023-09-06 17:36:26 -04:00
|
|
|
|
2023-09-08 21:27:25 -04:00
|
|
|
box._items.get(id).destroy();
|
|
|
|
box._items.delete(id);
|
|
|
|
}],
|
|
|
|
],
|
|
|
|
connections: [
|
|
|
|
[SystemTray, (box, id) => box._onAdded(box, id), 'added'],
|
|
|
|
[SystemTray, (box, id) => box._onRemoved(box, id), 'removed'],
|
|
|
|
],
|
2023-09-06 17:36:26 -04:00
|
|
|
});
|