feat(ags): add battery and systray modules. change default outline to tray items
This commit is contained in:
parent
7ccf86d7a6
commit
fe2404d439
7 changed files with 174 additions and 10 deletions
config/ags/js/bar
|
@ -9,6 +9,8 @@ import { TabletToggle } from './tablet-toggle.js';
|
|||
import { QsToggle } from './quick-settings.js';
|
||||
import { NotifButton } from './notif-button.js';
|
||||
import { Clock } from './clock.js';
|
||||
import { SysTray } from './systray.js';
|
||||
import { BatteryLabel } from './battery.js';
|
||||
|
||||
export const Bar = Window({
|
||||
name: 'left-bar',
|
||||
|
@ -41,6 +43,10 @@ export const Bar = Window({
|
|||
|
||||
Separator(12),
|
||||
|
||||
SysTray,
|
||||
|
||||
Separator(12),
|
||||
|
||||
Workspaces,
|
||||
|
||||
],
|
||||
|
@ -53,6 +59,10 @@ export const Bar = Window({
|
|||
Box({
|
||||
halign: 'end',
|
||||
children: [
|
||||
BatteryLabel(),
|
||||
|
||||
Separator(12),
|
||||
|
||||
Clock,
|
||||
|
||||
Separator(12),
|
||||
|
|
47
config/ags/js/bar/systray.js
Normal file
47
config/ags/js/bar/systray.js
Normal file
|
@ -0,0 +1,47 @@
|
|||
const { SystemTray } = ags.Service;
|
||||
const { Box, Button, Icon, MenuItem } = ags.Widget;
|
||||
const { Gtk } = imports.gi;
|
||||
|
||||
// this one uses a MenuBar and shouldn't throw that destroyed widget warning
|
||||
const SysTrayItem = item => MenuItem({
|
||||
className: 'tray-item',
|
||||
child: Icon({
|
||||
size: 24,
|
||||
}),
|
||||
submenu: item.menu,
|
||||
connections: [[item, btn => {
|
||||
btn.child.icon = item.icon;
|
||||
btn.tooltipMarkup = item.tooltipMarkup;
|
||||
}]]
|
||||
});
|
||||
|
||||
export const SysTrayModule = () => ags.Widget({
|
||||
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;
|
||||
|
||||
const widget = SysTrayItem(item);
|
||||
box._items.set(id, widget);
|
||||
box.add(widget);
|
||||
box.show_all();
|
||||
}],
|
||||
['onRemoved', (box, id) => {
|
||||
if (!box._items.has(id))
|
||||
return;
|
||||
|
||||
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'],
|
||||
],
|
||||
});
|
||||
|
||||
export const SysTray = SysTrayModule();
|
Loading…
Add table
Add a link
Reference in a new issue