Use latest libnotify library
This commit is contained in:
parent
f08fc033d2
commit
ffbe02898a
|
@ -2,8 +2,7 @@
|
|||
# SPDX-License-Identifier: Unlicense
|
||||
|
||||
import std/[asyncdispatch, strutils]
|
||||
import preserves, syndicate
|
||||
import ./private/libnotify
|
||||
import preserves, syndicate, libnotify
|
||||
import ./schema/notifications
|
||||
|
||||
proc render(a: Assertion): string =
|
||||
|
|
|
@ -1,87 +0,0 @@
|
|||
##
|
||||
## A minimalistic wrapper for libnotify
|
||||
## https://github.com/FedericoCeratto/nim-libnotify
|
||||
##
|
||||
## Wraps libnotify.so.4 https://developer.gnome.org/libnotify/
|
||||
##
|
||||
## Released under LGPLv3, see LICENSE file
|
||||
## 2015 - Federico Ceratto <federico.ceratto@gmail.com>
|
||||
##
|
||||
|
||||
{.deadCodeElim: on.}
|
||||
|
||||
import glib2
|
||||
|
||||
const libnotify_fn* = "libnotify.so.4"
|
||||
|
||||
type Notify = pointer
|
||||
|
||||
type NotificationUrgency* = enum
|
||||
Low, Normal, Critical
|
||||
|
||||
proc notify_init*(name: cstring): bool
|
||||
{.importc: "notify_init", dynlib: libnotify_fn.}
|
||||
|
||||
proc notify_uninit*(): void {.importc: "notify_uninit",
|
||||
dynlib: libnotify_fn.}
|
||||
|
||||
proc notify_is_initted(): bool
|
||||
{.importc: "notify_is_initted", dynlib: libnotify_fn.}
|
||||
|
||||
proc notify_get_app_name(): cstring
|
||||
{.importc: "notify_get_app_name", dynlib: libnotify_fn.}
|
||||
|
||||
proc notify_set_app_name(name: cstring): void
|
||||
{.importc: "notify_set_app_name", dynlib: libnotify_fn.}
|
||||
|
||||
proc notify_notification_new(a, b, c: cstring): Notify
|
||||
{.importc: "notify_notification_new", dynlib: libnotify_fn.}
|
||||
|
||||
proc notify_notification_show(notification: Notify, gerror: cint): gboolean
|
||||
{.importc: "notify_notification_show", dynlib: libnotify_fn.}
|
||||
|
||||
proc notify_notification_set_timeout(notification: Notify, timeout: cint): void
|
||||
{.importc: "notify_notification_set_timeout", dynlib: libnotify_fn.}
|
||||
|
||||
proc notify_notification_set_urgency(notification: Notify, urgency: NotificationUrgency): void
|
||||
{.importc: "notify_notification_set_urgency", dynlib: libnotify_fn.}
|
||||
|
||||
|
||||
|
||||
type NotifyClient* = ref object of RootObj
|
||||
|
||||
|
||||
proc newNotifyClient*(app_name: string): NotifyClient =
|
||||
## Initialize notification client
|
||||
if notify_is_initted() == false:
|
||||
doAssert notify_init(app_name)
|
||||
doAssert notify_is_initted()
|
||||
new(NotifyClient)
|
||||
|
||||
proc get_app_name*(self: NotifyClient): string =
|
||||
## Get application name
|
||||
return $notify_get_app_name()
|
||||
|
||||
proc set_app_name*(self: NotifyClient, app_name: string) =
|
||||
## Set application name
|
||||
notify_set_app_name(app_name.cstring)
|
||||
|
||||
proc send_new_notification*(self: NotifyClient, summary, body, icon_fname: string, timeout=0,
|
||||
urgency=NotificationUrgency.Normal) =
|
||||
## Show a notification. Optionally specify a timeout in milliseconds and an
|
||||
## urgency as a NotificationUrgency.Low / Normal / Critical
|
||||
let n = notify_notification_new(summary.cstring, body.cstring, icon_fname.cstring)
|
||||
|
||||
notify_notification_set_urgency(n, urgency)
|
||||
|
||||
if timeout != 0:
|
||||
notify_notification_set_timeout(n, timeout.cint)
|
||||
|
||||
let error: cint = 0
|
||||
doAssert notify_notification_show(n, error)
|
||||
if error != 0:
|
||||
raise newException(Exception, "Unhandled exception")
|
||||
|
||||
proc uninit*(self: NotifyClient) =
|
||||
## Uninitialize the library
|
||||
notify_uninit()
|
|
@ -1,6 +1,6 @@
|
|||
# Package
|
||||
|
||||
version = "0.1.0"
|
||||
version = "99999999"
|
||||
author = "Emery Hemingway"
|
||||
description = "Utilites for Syndicated Actors and Synit"
|
||||
license = "unlicense"
|
||||
|
@ -10,4 +10,4 @@ bin = @["http_translator", "json_socket_translator", "json_translator"
|
|||
|
||||
# Dependencies
|
||||
|
||||
requires "nim >= 1.6.6", "syndicate >= 0.3.1", "gtk2 >= 1.3"
|
||||
requires "nim >= 1.6.6", "syndicate >= 0.3.1", "libnotify"
|
||||
|
|
Loading…
Reference in New Issue