mirror of
https://github.com/end-4/dots-hyprland.git
synced 2026-06-06 07:19:27 -05:00
fix tray (naive solution) (#190)
This commit is contained in:
@@ -23,46 +23,67 @@ const SysTrayItem = (item) => Button({
|
||||
export const Tray = (props = {}) => {
|
||||
const trayContent = Box({
|
||||
className: 'margin-right-5 spacing-h-15',
|
||||
attribute: {
|
||||
items: new Map(),
|
||||
onAdded: (box, id) => {
|
||||
const item = SystemTray.getItem(id);
|
||||
if (!item) return;
|
||||
item.menu.className = 'menu';
|
||||
if (box.attribute.items.has(id) || !item)
|
||||
return;
|
||||
const widget = SysTrayItem(item);
|
||||
box.attribute.items.set(id, widget);
|
||||
box.add(widget);
|
||||
box.show_all();
|
||||
if (box.attribute.items.size === 1)
|
||||
trayRevealer.revealChild = true;
|
||||
},
|
||||
onRemoved: (box, id) => {
|
||||
if (!box.attribute.items.has(id))
|
||||
return;
|
||||
// attribute: {
|
||||
// items: new Map(),
|
||||
// addItem: (box, item) => {
|
||||
// if (!item) return;
|
||||
// console.log('init item:', item)
|
||||
|
||||
box.attribute.items.get(id).destroy();
|
||||
box.attribute.items.delete(id);
|
||||
if (box.attribute.items.size === 0)
|
||||
trayRevealer.revealChild = false;
|
||||
},
|
||||
},
|
||||
// item.menu.className = 'menu';
|
||||
// if (box.attribute.items.has(item.id) || !item)
|
||||
// return;
|
||||
// const widget = SysTrayItem(item);
|
||||
// box.attribute.items.set(item.id, widget);
|
||||
// box.add(widget);
|
||||
// box.show_all();
|
||||
// },
|
||||
// onAdded: (box, id) => {
|
||||
// console.log('supposed to add', id)
|
||||
// const item = SystemTray.getItem(id);
|
||||
// if (!item) return;
|
||||
// console.log('which is', box.attribute.items.get(id))
|
||||
|
||||
// item.menu.className = 'menu';
|
||||
// if (box.attribute.items.has(id) || !item)
|
||||
// return;
|
||||
// const widget = SysTrayItem(item);
|
||||
// box.attribute.items.set(id, widget);
|
||||
// box.add(widget);
|
||||
// box.show_all();
|
||||
// },
|
||||
// onRemoved: (box, id) => {
|
||||
// console.log('supposed to remove', id)
|
||||
// if (!box.attribute.items.has(id)) return;
|
||||
// console.log('which is', box.attribute.items.get(id))
|
||||
// box.attribute.items.get(id).destroy();
|
||||
// box.attribute.items.delete(id);
|
||||
// },
|
||||
// },
|
||||
// setup: (self) => {
|
||||
// // self.hook(SystemTray, (box, id) => box.attribute.onAdded(box, id), 'added')
|
||||
// // .hook(SystemTray, (box, id) => box.attribute.onRemoved(box, id), 'removed');
|
||||
// // SystemTray.items.forEach(item => self.attribute.addItem(self, item));
|
||||
// // self.chidren = SystemTray.items.map(item => SysTrayItem(item));
|
||||
// console.log(SystemTray.items.map(item => SysTrayItem(item)))
|
||||
// self.chidren = SystemTray.items.map(item => SysTrayItem(item));
|
||||
|
||||
// self.show_all();
|
||||
// },
|
||||
setup: (self) => self
|
||||
.hook(SystemTray, (box, id) => box.attribute.onAdded(box, id), 'added')
|
||||
.hook(SystemTray, (box, id) => box.attribute.onRemoved(box, id), 'removed')
|
||||
.hook(SystemTray, (self) => {
|
||||
self.children = SystemTray.items.map(SysTrayItem);
|
||||
self.show_all();
|
||||
})
|
||||
,
|
||||
});
|
||||
const trayRevealer = Widget.Revealer({
|
||||
revealChild: false,
|
||||
revealChild: true,
|
||||
transition: 'slide_left',
|
||||
transitionDuration: revealerDuration,
|
||||
child: trayContent,
|
||||
});
|
||||
return Box({
|
||||
...props,
|
||||
children: [
|
||||
trayRevealer,
|
||||
]
|
||||
children: [trayRevealer],
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user