forked from Shinonome/dots-hyprland
fix tray (naive solution) (#190)
This commit is contained in:
@@ -23,46 +23,67 @@ const SysTrayItem = (item) => Button({
|
|||||||
export const Tray = (props = {}) => {
|
export const Tray = (props = {}) => {
|
||||||
const trayContent = Box({
|
const trayContent = Box({
|
||||||
className: 'margin-right-5 spacing-h-15',
|
className: 'margin-right-5 spacing-h-15',
|
||||||
attribute: {
|
// attribute: {
|
||||||
items: new Map(),
|
// items: new Map(),
|
||||||
onAdded: (box, id) => {
|
// addItem: (box, item) => {
|
||||||
const item = SystemTray.getItem(id);
|
// if (!item) return;
|
||||||
if (!item) return;
|
// console.log('init item:', item)
|
||||||
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;
|
|
||||||
|
|
||||||
box.attribute.items.get(id).destroy();
|
// item.menu.className = 'menu';
|
||||||
box.attribute.items.delete(id);
|
// if (box.attribute.items.has(item.id) || !item)
|
||||||
if (box.attribute.items.size === 0)
|
// return;
|
||||||
trayRevealer.revealChild = false;
|
// 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
|
setup: (self) => self
|
||||||
.hook(SystemTray, (box, id) => box.attribute.onAdded(box, id), 'added')
|
.hook(SystemTray, (self) => {
|
||||||
.hook(SystemTray, (box, id) => box.attribute.onRemoved(box, id), 'removed')
|
self.children = SystemTray.items.map(SysTrayItem);
|
||||||
|
self.show_all();
|
||||||
|
})
|
||||||
,
|
,
|
||||||
});
|
});
|
||||||
const trayRevealer = Widget.Revealer({
|
const trayRevealer = Widget.Revealer({
|
||||||
revealChild: false,
|
revealChild: true,
|
||||||
transition: 'slide_left',
|
transition: 'slide_left',
|
||||||
transitionDuration: revealerDuration,
|
transitionDuration: revealerDuration,
|
||||||
child: trayContent,
|
child: trayContent,
|
||||||
});
|
});
|
||||||
return Box({
|
return Box({
|
||||||
...props,
|
...props,
|
||||||
children: [
|
children: [trayRevealer],
|
||||||
trayRevealer,
|
|
||||||
]
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user