Files
illogical-impulse/.config/ags/modules/bar/normal/tray.js
T
MoetaYuko 53e87eb12e ags: fix systray icon warning
take code snippet from ags wiki to fix:
```
(com.github.Aylur.ags:748022): Gjs-Console-WARNING **: 21:42:04.733: Error: can't assign "[object instance wrapper GIName:GdkPixbuf.Pixbuf jsobj@0x37f2745abd08 native@0x62e804712490]" as icon, it is not a file nor a named icon
```
2024-05-01 22:35:01 +08:00

37 lines
1.2 KiB
JavaScript

import Widget from 'resource:///com/github/Aylur/ags/widget.js';
import SystemTray from 'resource:///com/github/Aylur/ags/service/systemtray.js';
const { Box, Icon, Button, Revealer } = Widget;
const { Gravity } = imports.gi.Gdk;
const SysTrayItem = (item) => Button({
className: 'bar-systray-item',
child: Icon({hpack: 'center'}).bind('icon', item, 'icon'),
setup: (self) => self
.hook(item, (self) => self.tooltipMarkup = item['tooltip-markup'])
,
onPrimaryClick: (_, event) => item.activate(event),
onSecondaryClick: (btn, event) => item.menu.popup_at_widget(btn, Gravity.SOUTH, Gravity.NORTH, null),
});
export const Tray = (props = {}) => {
const trayContent = Box({
className: 'margin-right-5 spacing-h-15',
setup: (self) => self
.hook(SystemTray, (self) => {
self.children = SystemTray.items.map(SysTrayItem);
self.show_all();
})
,
});
const trayRevealer = Widget.Revealer({
revealChild: true,
transition: 'slide_left',
transitionDuration: userOptions.animations.durationLarge,
child: trayContent,
});
return Box({
...props,
children: [trayRevealer],
});
}