Added the ability to assign shortcuts to all bar modules. (#278)
This commit is contained in:
@@ -4,9 +4,18 @@ import options from 'options';
|
||||
import { openMenu } from '../utils.js';
|
||||
import { BarBoxChild } from 'lib/types/bar.js';
|
||||
import Button from 'types/widgets/button.js';
|
||||
import { Child } from 'lib/types/widget.js';
|
||||
import { Attribute, Child } from 'lib/types/widget.js';
|
||||
import { runAsyncCommand, throttledScrollHandler } from 'customModules/utils.js';
|
||||
|
||||
const { label: networkLabel, truncation, truncation_size } = options.bar.network;
|
||||
const {
|
||||
label: networkLabel,
|
||||
truncation,
|
||||
truncation_size,
|
||||
rightClick,
|
||||
middleClick,
|
||||
scrollDown,
|
||||
scrollUp,
|
||||
} = options.bar.network;
|
||||
|
||||
const Network = (): BarBoxChild => {
|
||||
return {
|
||||
@@ -70,9 +79,27 @@ const Network = (): BarBoxChild => {
|
||||
isVisible: true,
|
||||
boxClass: 'network',
|
||||
props: {
|
||||
on_primary_click: (clicked: Button<Child, Child>, event: Gdk.Event): void => {
|
||||
on_primary_click: (clicked: Button<Child, Attribute>, event: Gdk.Event): void => {
|
||||
openMenu(clicked, event, 'networkmenu');
|
||||
},
|
||||
setup: (self: Button<Child, Attribute>): void => {
|
||||
self.hook(options.bar.scrollSpeed, () => {
|
||||
const throttledHandler = throttledScrollHandler(options.bar.scrollSpeed.value);
|
||||
|
||||
self.on_secondary_click = (clicked: Button<Child, Attribute>, event: Gdk.Event): void => {
|
||||
runAsyncCommand(rightClick.value, { clicked, event });
|
||||
};
|
||||
self.on_middle_click = (clicked: Button<Child, Attribute>, event: Gdk.Event): void => {
|
||||
runAsyncCommand(middleClick.value, { clicked, event });
|
||||
};
|
||||
self.on_scroll_up = (clicked: Button<Child, Attribute>, event: Gdk.Event): void => {
|
||||
throttledHandler(scrollUp.value, { clicked, event });
|
||||
};
|
||||
self.on_scroll_down = (clicked: Button<Child, Attribute>, event: Gdk.Event): void => {
|
||||
throttledHandler(scrollDown.value, { clicked, event });
|
||||
};
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user