feat(ags): remove eventbox from systray because of bug

This commit is contained in:
matt1432 2023-09-08 21:27:25 -04:00
parent 7b8d0d4b54
commit 1488f4992f
3 changed files with 51 additions and 36 deletions

View file

@ -1,47 +1,47 @@
const { SystemTray } = ags.Service; const { SystemTray } = ags.Service;
const { Box, Button, Icon, MenuItem } = ags.Widget; const { Box, Button, Icon, MenuItem } = ags.Widget;
const { Gtk } = imports.gi; const { Gtk } = imports.gi;
import { EventBox } from '../common.js';
// this one uses a MenuBar and shouldn't throw that destroyed widget warning
const SysTrayItem = item => MenuItem({ const SysTrayItem = item => MenuItem({
className: 'tray-item', className: 'tray-item',
child: Icon({ child: Icon({
size: 24, size: 24,
}), }),
submenu: item.menu, submenu: item.menu,
connections: [[item, btn => { connections: [[item, btn => {
btn.child.icon = item.icon; btn.child.icon = item.icon;
btn.tooltipMarkup = item.tooltipMarkup; btn.tooltipMarkup = item.tooltipMarkup;
}]] }]]
}); });
export const SysTrayModule = () => ags.Widget({ const SysTrayModule = () => ags.Widget({
type: Gtk.MenuBar, type: Gtk.MenuBar,
className: 'sys-tray', className: 'sys-tray',
properties: [ properties: [
['items', new Map()], ['items', new Map()],
['onAdded', (box, id) => { ['onAdded', (box, id) => {
const item = SystemTray.getItem(id); const item = SystemTray.getItem(id);
if (box._items.has(id) || !item) if (box._items.has(id) || !item)
return; return;
const widget = SysTrayItem(item); const widget = SysTrayItem(item);
box._items.set(id, widget); box._items.set(id, widget);
box.add(widget); box.add(widget);
box.show_all(); box.show_all();
}], }],
['onRemoved', (box, id) => { ['onRemoved', (box, id) => {
if (!box._items.has(id)) if (!box._items.has(id))
return; return;
box._items.get(id).destroy(); box._items.get(id).destroy();
box._items.delete(id); box._items.delete(id);
}], }],
], ],
connections: [ connections: [
[SystemTray, (box, id) => box._onAdded(box, id), 'added'], [SystemTray, (box, id) => box._onAdded(box, id), 'added'],
[SystemTray, (box, id) => box._onRemoved(box, id), 'removed'], [SystemTray, (box, id) => box._onRemoved(box, id), 'removed'],
], ],
}); });
export const SysTray = SysTrayModule(); export const SysTray = SysTrayModule();

View file

@ -11,6 +11,15 @@
all: unset; all: unset;
padding: 0px 2px 0px 2px; padding: 0px 2px 0px 2px;
font-size: 25px; font-size: 25px;
border-radius: 100%;
transition: background-color 0.5s ease-in-out,
border 0.5s ease-in-out;
&:hover {
background: rgba(127, 132, 156, 0.4);
border-radius: 100%;
transition: background-color 0.5s ease-in-out,
border 0.5s ease-in-out;
}
} }
menu { menu {

View file

@ -138,7 +138,13 @@
.sys-tray .tray-item { .sys-tray .tray-item {
all: unset; all: unset;
padding: 0px 2px 0px 2px; padding: 0px 2px 0px 2px;
font-size: 25px; } font-size: 25px;
border-radius: 100%;
transition: background-color 0.5s ease-in-out, border 0.5s ease-in-out; }
.sys-tray .tray-item:hover {
background: rgba(127, 132, 156, 0.4);
border-radius: 100%;
transition: background-color 0.5s ease-in-out, border 0.5s ease-in-out; }
.sys-tray menu { .sys-tray menu {
background: #282a36; background: #282a36;
padding-top: 5px; padding-top: 5px;