Skip to content

Commit

Permalink
Add Utils.lookupIcon and Gtk.IconInfo.filename (#6)
Browse files Browse the repository at this point in the history
* Add `Utils.lookupIcon`

* Add `Gtk.IconInfo.filename`
  • Loading branch information
postsolar authored Feb 24, 2024
1 parent 2b88f14 commit 620ee38
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/AGS/Utils/Icon.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const lookupIconImpl = Utils.lookUpIcon

16 changes: 16 additions & 0 deletions src/AGS/Utils/Icon.purs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module AGS.Utils.Icon (lookupIcon) where

import Prelude

import Data.Maybe (Maybe)
import Data.Nullable (Nullable, toMaybe)
import Effect (Effect)
import Effect.Uncurried (EffectFn2, runEffectFn2)
import Gtk.IconInfo (GtkIconInfo)

-- | Look up an icon given its name and size.
lookupIcon String Int Effect (Maybe GtkIconInfo)
lookupIcon name size = map toMaybe (runEffectFn2 lookupIconImpl name size)

foreign import lookupIconImpl EffectFn2 String Int (Nullable GtkIconInfo)

4 changes: 4 additions & 0 deletions src/Gtk/IconInfo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export const getFilenameImpl =
iconInfo =>
iconInfo.get_filename()

14 changes: 14 additions & 0 deletions src/Gtk/IconInfo.purs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module Gtk.IconInfo (GtkIconInfo, filename) where

import Data.Maybe (Maybe)
import Data.Nullable (Nullable, toMaybe)
import Prelude ((<<<))

foreign import data GtkIconInfo Type

-- | Returns the full path to the icon, unless it's a builtin icon.
filename GtkIconInfo Maybe String
filename = toMaybe <<< getFilenameImpl

foreign import getFilenameImpl GtkIconInfo Nullable String

0 comments on commit 620ee38

Please sign in to comment.