From 5b7d241c62069501f9a8c72ba27e4fe446ca9c40 Mon Sep 17 00:00:00 2001 From: Emery Hemingway Date: Tue, 1 Aug 2023 13:01:39 +0100 Subject: [PATCH] Glib is from a bunch of worthless fucks --- src/libnotify_actor.nim | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/libnotify_actor.nim b/src/libnotify_actor.nim index c505955..7d13d50 100644 --- a/src/libnotify_actor.nim +++ b/src/libnotify_actor.nim @@ -16,16 +16,18 @@ const notifyHeader = "" type Notification {.importc: "NotifyNotification".} = ptr object discard - GError {.importc.} = ptr object + GError {.importc, header: "glib/gerror.h".} = object message: cstring +proc g_free(mem: pointer) {.importc.} +proc g_error_free(err: ptr GError) {.importc, header: "glib/gerror.h".} + proc init(appName: cstring): bool {.notify.} proc uninit() {.notify.} proc get_server_info(name, vendor, version, specVersion: ptr cstring): bool {.notify.} proc notification_new(summary, body, icon: cstring = nil): Notification {.notify.} -proc show(n: Notification; err: ptr GError): bool {.notification.} proc set_app_name(n: Notification; s: string) {.notification.} proc set_category(n: Notification; s: string) {.notification.} @@ -42,6 +44,15 @@ const appName = "libnotify_actor" if not init(appName): quit "failed to initialize libnotify" + proc show(n: Notification; err: ptr (ptr GError)): bool {.notification.} + var err: ptr GError + if not show(n, addr err): + doAssert not err.isNil, "GLIB shit itself without setting an error" + doAssert not err.message.isNil, "GLIB shit itself without setting an error message" + stderr.writeLine "show failed: ", err.message + if not err.isNil: + g_error_free(err) + proc assertServerInfo(turn: var Turn; ds: Ref) = var name, vendor, version, specVersion: cstring if get_server_info(addr name, addr vendor, addr version, addr specVersion):