Skip to content

Commit

Permalink
Refinements
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilippMDoerner committed Jun 15, 2024
1 parent fcceeb8 commit e119fe7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
3 changes: 0 additions & 3 deletions examples/widgets/adw/toast_overlay.nim
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,7 @@ proc buildToast(
useMarkup = state.useMarkup # Comment in if you compile with -d:adwminor=2 or higher
)

import std/importutils
privateAccess(ToastQueue)
method view(app: AppState): Widget =
echo "View: ", app.toastQueue.toasts.len
result = gui:
Window():
defaultSize = (800, 600)
Expand Down
8 changes: 4 additions & 4 deletions owlkettle/adw.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1395,7 +1395,7 @@ proc toGtk(toast: Toast): AdwToast =
adw_toast_set_use_markup(result, toast.useMarkup.cbool)

type ToastQueue* = ref object
toasts: seq[Toast]
initialToastBuffer: seq[Toast]
addToOverlay: proc(toast: Toast) {.closure.}

proc isInitialized(queue: ToastQueue): bool = not queue.addToOverlay.isNil()
Expand All @@ -1404,17 +1404,17 @@ proc add*(queue: ToastQueue, toast: Toast) =
if queue.isInitialized():
queue.addToOverlay(toast)
else:
queue.toasts.add(toast)
queue.initialToastBuffer.add(toast)

proc add*(queue: ToastQueue, toasts: openArray[Toast]) =
for toast in toasts:
queue.add(toast)

proc dumpStoredToasts(queue: ToastQueue) =
for toast in queue.toasts:
for toast in queue.initialToastBuffer:
queue.addToOverlay(toast)

queue.toasts = @[]
queue.initialToastBuffer = @[]

renderable ToastOverlay of BaseWidget:
## An overlay to display Toast messages that can be dismissed manually and automatically!<br>
Expand Down

0 comments on commit e119fe7

Please sign in to comment.