16 lines
489 B
TypeScript
16 lines
489 B
TypeScript
import { Gtk, Gdk } from "astal/gtk4";
|
|
|
|
export type If<Condition, Then, Else> = Condition extends true ? Then : Else;
|
|
export type Belongs<T, U> = {
|
|
[K in keyof T]: T[K] extends U ? K : never;
|
|
}[keyof T];
|
|
|
|
export const hideWindow = (self: Gtk.Window, keyval: number) => {
|
|
if (keyval === Gdk.KEY_Escape) self.hide();
|
|
}
|
|
|
|
export const openOnButton = (event: Gdk.ButtonEvent, keyval: number) => (action: () => void) => {
|
|
if (event.get_button() !== keyval) return;
|
|
|
|
action();
|
|
} |