feat(ags): add swipe gesture to open quick-settings

This commit is contained in:
matt1432 2023-09-18 16:14:11 -04:00
parent c66909efed
commit 7d45c18843
2 changed files with 73 additions and 38 deletions

View file

@ -0,0 +1,32 @@
const { Window, CenterBox, EventBox, Button } = ags.Widget;
const { openWindow } = ags.App;
const { Gtk, Gdk } = imports.gi;
const display = Gdk.Display.get_default();
export const Gesture = ({
child,
...params
}) => {
let w = EventBox({
...params,
});
let gesture = Gtk.GestureSwipe.new(w);
w.child = CenterBox({
children: [
child,
],
connections: [
[gesture, box => {
const velocity = gesture.get_velocity()[1];
if (velocity < -50)
openWindow('quick-settings');
}, 'update'],
],
});
return w;
};

View file

@ -12,6 +12,7 @@ import { SysTray } from './systray.js';
import { BatteryIndicator } from './battery.js';
import { Brightness } from './brightness.js';
import { AudioIndicator } from './audio.js';
import { Gesture } from './gesture.js';
export const Bar = Window({
name: 'bar',
@ -19,60 +20,62 @@ export const Bar = Window({
anchor: 'top left right',
exclusive: true,
child: CenterBox({
className: 'transparent',
halign: 'fill',
style: 'margin: 5px',
vertical: false,
child: Gesture({
child: CenterBox({
className: 'transparent',
halign: 'fill',
style: 'margin: 5px',
vertical: false,
startWidget: Box({
halign: 'start',
children: [
startWidget: Box({
halign: 'start',
children: [
OskToggle,
OskToggle,
Separator(12),
Separator(12),
TabletToggle,
TabletToggle,
Separator(12),
Separator(12),
SysTray,
SysTray,
Separator(12),
Separator(12),
AudioIndicator,
AudioIndicator,
Separator(12),
Separator(12),
Brightness,
Brightness,
Separator(12),
Separator(12),
Workspaces,
Workspaces,
],
}),
],
}),
centerWidget: CurrentWindow,
centerWidget: CurrentWindow,
endWidget: Box({
halign: 'end',
children: [
BatteryIndicator,
endWidget: Box({
halign: 'end',
children: [
BatteryIndicator,
Separator(12),
Separator(12),
Clock,
Clock,
Separator(12),
Separator(12),
NotifButton,
NotifButton,
Separator(12),
Separator(12),
QsToggle,
],
QsToggle,
],
}),
}),
}),
});