fix(ags): get rid of Gtk error
This commit is contained in:
parent
5701873625
commit
3a3c9f2a70
4 changed files with 88 additions and 72 deletions
|
@ -21,6 +21,42 @@ const SysTrayItem = item => MenuItem({
|
|||
}]]
|
||||
});
|
||||
|
||||
const SysTray = () => {
|
||||
let widget = Gtk.MenuBar.new();
|
||||
|
||||
// Properties
|
||||
widget._items = new Map();
|
||||
|
||||
widget._onAdded = (id) => {
|
||||
const item = SystemTray.getItem(id);
|
||||
if (widget._items.has(id) || !item)
|
||||
return;
|
||||
|
||||
const w = SysTrayItem(item);
|
||||
widget._items.set(id, w);
|
||||
widget.add(w);
|
||||
widget.show_all();
|
||||
w.child.revealChild = true;
|
||||
};
|
||||
|
||||
widget._onRemoved = (id) => {
|
||||
if (!widget._items.has(id))
|
||||
return;
|
||||
|
||||
widget._items.get(id).child.revealChild = false;
|
||||
setTimeout(() => {
|
||||
widget._items.get(id).destroy();
|
||||
widget._items.delete(id);
|
||||
}, 400);
|
||||
};
|
||||
|
||||
// Connections
|
||||
SystemTray.connect('added', (_, id) => widget._onAdded(id));
|
||||
SystemTray.connect('removed', (_, id) => widget._onRemoved(id));
|
||||
|
||||
return widget;
|
||||
}
|
||||
|
||||
export default () => Revealer({
|
||||
transition: 'slide_right',
|
||||
connections: [[SystemTray, rev => {
|
||||
|
@ -31,38 +67,7 @@ export default () => Revealer({
|
|||
Box({
|
||||
className: 'sys-tray',
|
||||
children: [
|
||||
Widget({
|
||||
type: Gtk.MenuBar,
|
||||
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();
|
||||
widget.child.revealChild = true;
|
||||
}],
|
||||
|
||||
['onRemoved', (box, id) => {
|
||||
if (!box._items.has(id))
|
||||
return;
|
||||
|
||||
box._items.get(id).child.revealChild = false;
|
||||
setTimeout(() => {
|
||||
box._items.get(id).destroy();
|
||||
box._items.delete(id);
|
||||
}, 400);
|
||||
}],
|
||||
],
|
||||
connections: [
|
||||
[SystemTray, (box, id) => box._onAdded(box, id), 'added'],
|
||||
[SystemTray, (box, id) => box._onRemoved(box, id), 'removed'],
|
||||
],
|
||||
}),
|
||||
SysTray(),
|
||||
],
|
||||
}),
|
||||
Separator(12),
|
||||
|
|
|
@ -60,9 +60,7 @@ export const WorkspaceRow = (className, i) => Revealer({
|
|||
// TODO: please make this readable for the love of god
|
||||
const Workspace = (id, name, extra = false) => {
|
||||
let workspace;
|
||||
let fixed = Widget({
|
||||
type: Gtk.Fixed,
|
||||
});
|
||||
let fixed = Gtk.Fixed.new();
|
||||
|
||||
if (!extra) {
|
||||
workspace = Revealer({
|
||||
|
|
|
@ -1,13 +1,11 @@
|
|||
import { Mpris, Widget } from '../../imports.js';
|
||||
const { Box, Label, Revealer, Icon } = Widget;
|
||||
import { Widget } from '../../imports.js';
|
||||
const { Box, Label, Revealer } = Widget;
|
||||
|
||||
import Gtk from 'gi://Gtk';
|
||||
|
||||
import ButtonGrid from './button-grid.js';
|
||||
import SliderBox from './slider-box.js';
|
||||
import Player from '../media-player/player.js';
|
||||
import EventBox from '../misc/cursorbox.js';
|
||||
import PopupWindow from '../misc/popup.js';
|
||||
import ButtonGrid from './button-grid.js';
|
||||
import SliderBox from './slider-box.js';
|
||||
import Player from '../media-player/player.js';
|
||||
import PopupWindow from '../misc/popup.js';
|
||||
import ToggleButton from './toggle-button.js';
|
||||
|
||||
|
||||
const QuickSettingsWidget = () => Box({
|
||||
|
@ -31,34 +29,7 @@ const QuickSettingsWidget = () => Box({
|
|||
|
||||
SliderBox(),
|
||||
|
||||
EventBox({
|
||||
child: Widget({
|
||||
type: Gtk.ToggleButton,
|
||||
setup: btn => {
|
||||
const id = Mpris.connect('changed', () => {
|
||||
btn.set_active(Mpris.players.length > 0);
|
||||
Mpris.disconnect(id);
|
||||
});
|
||||
},
|
||||
connections: [['toggled', button => {
|
||||
let rev = button.get_parent().get_parent().get_parent().children[1];
|
||||
|
||||
if (button.get_active()) {
|
||||
button.child.setStyle("-gtk-icon-transform: rotate(0deg);");
|
||||
rev.revealChild = true;
|
||||
}
|
||||
else {
|
||||
button.child.setStyle('-gtk-icon-transform: rotate(180deg);');
|
||||
rev.revealChild = false;
|
||||
}
|
||||
}]],
|
||||
child: Icon({
|
||||
icon: 'go-down-symbolic',
|
||||
className: 'arrow',
|
||||
style: `-gtk-icon-transform: rotate(180deg);`,
|
||||
}),
|
||||
}),
|
||||
}),
|
||||
ToggleButton(),
|
||||
|
||||
],
|
||||
}),
|
||||
|
|
42
hosts/wim/config/ags/js/quick-settings/toggle-button.js
Normal file
42
hosts/wim/config/ags/js/quick-settings/toggle-button.js
Normal file
|
@ -0,0 +1,42 @@
|
|||
import { Mpris, Widget } from '../../imports.js';
|
||||
const { Icon } = Widget;
|
||||
|
||||
import Gtk from 'gi://Gtk';
|
||||
import EventBox from '../misc/cursorbox.js';
|
||||
|
||||
export default () => {
|
||||
let widget = EventBox({});
|
||||
|
||||
let toggleButton = Gtk.ToggleButton.new();
|
||||
toggleButton.add(Icon({
|
||||
icon: 'go-down-symbolic',
|
||||
className: 'arrow',
|
||||
style: `-gtk-icon-transform: rotate(180deg);`,
|
||||
}));
|
||||
|
||||
// Setup
|
||||
const id = Mpris.connect('changed', () => {
|
||||
toggleButton.set_active(Mpris.players.length > 0);
|
||||
Mpris.disconnect(id);
|
||||
});
|
||||
|
||||
// Connections
|
||||
toggleButton.connect('toggled', () => {
|
||||
let rev = toggleButton.get_parent().get_parent().get_parent().children[1];
|
||||
|
||||
if (toggleButton.get_active()) {
|
||||
toggleButton.get_children()[0]
|
||||
.setStyle("-gtk-icon-transform: rotate(0deg);");
|
||||
rev.revealChild = true;
|
||||
}
|
||||
else {
|
||||
toggleButton.get_children()[0]
|
||||
.setStyle('-gtk-icon-transform: rotate(180deg);');
|
||||
rev.revealChild = false;
|
||||
}
|
||||
});
|
||||
|
||||
widget.add(toggleButton);
|
||||
|
||||
return widget;
|
||||
}
|
Loading…
Reference in a new issue