ags/lib/utils.ts

16 lines
489 B
TypeScript
Raw Permalink Normal View History

2025-02-06 12:05:55 +01:00
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();
}