From 56a54b4d3134c378df0e8c09c5e5376ea846dcf4 Mon Sep 17 00:00:00 2001 From: Daniel Barlow Date: Sat, 12 Feb 2022 16:57:08 +0000 Subject: [PATCH] send ActionInvoked(default) when widget clicked --- crier/crier.fnl | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/crier/crier.fnl b/crier/crier.fnl index bf46ec5..edd6de0 100644 --- a/crier/crier.fnl +++ b/crier/crier.fnl @@ -113,13 +113,21 @@ (: :set-body noti.body) (: :set-icon noti.app-icon))) +(fn default-action [id] + (bus.connection:emit_signal + nil ; destination + dbus-service-attrs.path + dbus-service-attrs.interface + "ActionInvoked" + (GV "(us)" [id "default"]))) + (fn make-notification-widget [id] (let [summary (Gtk.Label { :name "summary" }) body (Gtk.Label) icon (Gtk.Image) cancel-me (fn [] (delete-notification id)) event-box (Gtk.EventBox { - :on_button_press_event cancel-me + :on_button_press_event #(default-action id) }) hbox (Gtk.Box { :name "notification" @@ -166,6 +174,12 @@ (update-window) id)) +(fn parse-actions [list] + (let [out {}] + (for [i 1 (# list) 2] + (tset out (. list i) (. list (+ 1 i)))) + out)) + (fn make-notification [params] { :sender (. params 1) @@ -173,7 +187,7 @@ :app-icon (. params 3) :summary (. params 4) :body (. params 5) - :actions (. params 6) + :actions (parse-actions (. params 6)) :hints (. params 7) :timeout (. params 8) }) @@ -183,7 +197,7 @@ (= interface dbus-service-attrs.interface)) (match method "GetCapabilities" - (invocation:return_value (GV "as" ["actions"])) + (invocation:return_value (GV "as" ["actions" "body" "persistence"])) "GetServerInformation" (invocation:return_value @@ -218,4 +232,13 @@ (lgi.GObject.Closure handle-dbus-get) (lgi.GObject.Closure (fn [a] (print "set")))) + +(add-notification { + :app-icon "dialog-information" + :body "This is an example notifiddcation." + :id 3 + :sender "notify-send" + :summary "Hello world!" + }) + (Gtk:main)