Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Utils.lookupIcon #6

Merged
merged 2 commits into from
Feb 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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

Loading