From 620ee38139e97134e83a90d239a2e2b990dee050 Mon Sep 17 00:00:00 2001 From: postsolar <120750161+postsolar@users.noreply.github.com> Date: Sat, 24 Feb 2024 23:53:34 +0200 Subject: [PATCH] Add `Utils.lookupIcon` and `Gtk.IconInfo.filename` (#6) * Add `Utils.lookupIcon` * Add `Gtk.IconInfo.filename` --- src/AGS/Utils/Icon.js | 2 ++ src/AGS/Utils/Icon.purs | 16 ++++++++++++++++ src/Gtk/IconInfo.js | 4 ++++ src/Gtk/IconInfo.purs | 14 ++++++++++++++ 4 files changed, 36 insertions(+) create mode 100644 src/AGS/Utils/Icon.js create mode 100644 src/AGS/Utils/Icon.purs create mode 100644 src/Gtk/IconInfo.js create mode 100644 src/Gtk/IconInfo.purs diff --git a/src/AGS/Utils/Icon.js b/src/AGS/Utils/Icon.js new file mode 100644 index 0000000..e4a829a --- /dev/null +++ b/src/AGS/Utils/Icon.js @@ -0,0 +1,2 @@ +export const lookupIconImpl = Utils.lookUpIcon + diff --git a/src/AGS/Utils/Icon.purs b/src/AGS/Utils/Icon.purs new file mode 100644 index 0000000..30d7217 --- /dev/null +++ b/src/AGS/Utils/Icon.purs @@ -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) + diff --git a/src/Gtk/IconInfo.js b/src/Gtk/IconInfo.js new file mode 100644 index 0000000..8b70af3 --- /dev/null +++ b/src/Gtk/IconInfo.js @@ -0,0 +1,4 @@ +export const getFilenameImpl = + iconInfo => + iconInfo.get_filename() + diff --git a/src/Gtk/IconInfo.purs b/src/Gtk/IconInfo.purs new file mode 100644 index 0000000..3db037b --- /dev/null +++ b/src/Gtk/IconInfo.purs @@ -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 +