eufon

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit ee3ee9968058da3b397ab1c38305e3b6e9a3ec7c
parent 2166db979c909f872e6144630b37f96bb2c27616
Author: Daniel Barlow <dan@telent.net>
Date:   Fri, 11 Feb 2022 23:30:28 +0000

delete notifications by clicking them

maybe we want to change this for swipe right? in android a click takes
you to the app that notified

Diffstat:
Mcrier/crier.fnl | 23+++++++++++++++++++----
1 file changed, 19 insertions(+), 4 deletions(-)

diff --git a/crier/crier.fnl b/crier/crier.fnl @@ -91,23 +91,37 @@ (print id (widget:get_parent)) (if (not (widget:get_parent)) (window.box:pack_start widget false false 5))) - (if (next notifications) (window.window:show_all) (window:hide))) + (if (next notifications) + (window.window:show_all) + (window.window:hide))) (var notification-id 10) (fn next-notification-id [] (set notification-id (+ notification-id 1)) notification-id) +(fn delete-notification [id] + (let [widget (. notifications id)] + (tset notifications id nil) + (print "delete " id widget (inspect notifications)) + (window.box:remove widget) + (update-window) + )) + (fn update-notification-widget [widget noti] (doto widget (: :set-summary noti.summary) (: :set-body noti.body) (: :set-icon noti.app-icon))) -(fn make-notification-widget [] +(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 + }) hbox (Gtk.Box { :name "notification" :orientation Gtk.Orientation.HORIZONTAL @@ -117,6 +131,7 @@ (vbox:pack_start body true false 0) (hbox:pack_start icon false false 0) (hbox:pack_start vbox true true 0) + (event-box:add hbox) { :set-summary (fn [self value] (set summary.label value)) @@ -129,12 +144,12 @@ value Gtk.IconSize.DND ))) - :widget hbox + :widget event-box })) (fn add-notification [noti] (let [id (if (= noti.id 0) (next-notification-id) noti.id) - widget (or (. notifications id) (make-notification-widget))] + widget (or (. notifications id) (make-notification-widget id))] (update-notification-widget widget noti) (tset notifications id widget.widget) (update-window)