{-# LINE 2 "./System/GIO/Icons/Icon.chs" #-}
module System.GIO.Icons.Icon (
Icon(..),
IconClass,
iconEqual,
iconToString,
iconNewForString,
) where
import Control.Monad
import Data.ByteString (ByteString)
import Data.ByteString (useAsCString)
import Data.ByteString.Unsafe (unsafePackCStringFinalizer)
import System.GIO.Enums
import System.Glib.FFI
import System.Glib.Flags
import System.Glib.GError
import System.Glib.GObject
import System.Glib.UTFString
import System.GIO.Types
{-# LINE 72 "./System/GIO/Icons/Icon.chs" #-}
{-# LINE 74 "./System/GIO/Icons/Icon.chs" #-}
iconEqual :: (IconClass icon1, IconClass icon2) => icon1 -> icon2
-> IO Bool
iconEqual :: forall icon1 icon2.
(IconClass icon1, IconClass icon2) =>
icon1 -> icon2 -> IO Bool
iconEqual icon1
icon1 icon2
icon2 =
(CInt -> Bool) -> IO CInt -> IO Bool
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM CInt -> Bool
forall a. (Eq a, Num a) => a -> Bool
toBool (IO CInt -> IO Bool) -> IO CInt -> IO Bool
forall a b. (a -> b) -> a -> b
$
(\(Icon ForeignPtr Icon
arg1) (Icon ForeignPtr Icon
arg2) -> ForeignPtr Icon -> (Ptr Icon -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Icon
arg1 ((Ptr Icon -> IO CInt) -> IO CInt)
-> (Ptr Icon -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr Icon
argPtr1 ->ForeignPtr Icon -> (Ptr Icon -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Icon
arg2 ((Ptr Icon -> IO CInt) -> IO CInt)
-> (Ptr Icon -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr Icon
argPtr2 ->Ptr Icon -> Ptr Icon -> IO CInt
g_icon_equal Ptr Icon
argPtr1 Ptr Icon
argPtr2) (icon1 -> Icon
forall o. IconClass o => o -> Icon
toIcon icon1
icon1) (icon2 -> Icon
forall o. IconClass o => o -> Icon
toIcon icon2
icon2)
iconToString :: IconClass icon => icon
-> IO ByteString
iconToString :: forall icon. IconClass icon => icon -> IO ByteString
iconToString icon
icon = do
Ptr CChar
sPtr <- (\(Icon ForeignPtr Icon
arg1) -> ForeignPtr Icon -> (Ptr Icon -> IO (Ptr CChar)) -> IO (Ptr CChar)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Icon
arg1 ((Ptr Icon -> IO (Ptr CChar)) -> IO (Ptr CChar))
-> (Ptr Icon -> IO (Ptr CChar)) -> IO (Ptr CChar)
forall a b. (a -> b) -> a -> b
$ \Ptr Icon
argPtr1 ->Ptr Icon -> IO (Ptr CChar)
g_icon_to_string Ptr Icon
argPtr1) (icon -> Icon
forall o. IconClass o => o -> Icon
toIcon icon
icon)
Int
sLen <- CChar -> Ptr CChar -> IO Int
forall a. (Storable a, Eq a) => a -> Ptr a -> IO Int
lengthArray0 CChar
0 Ptr CChar
sPtr
Ptr Word8 -> Int -> IO () -> IO ByteString
unsafePackCStringFinalizer (Ptr CChar -> Ptr Word8
forall a b. Ptr a -> Ptr b
castPtr Ptr CChar
sPtr) (Int -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
sLen)
(Ptr () -> IO ()
g_free (Ptr CChar -> Ptr ()
forall a b. Ptr a -> Ptr b
castPtr Ptr CChar
sPtr))
iconNewForString :: ByteString -> IO Icon
iconNewForString :: ByteString -> IO Icon
iconNewForString ByteString
str =
(ForeignPtr Icon -> Icon, FinalizerPtr Icon)
-> IO (Ptr Icon) -> IO Icon
forall obj.
GObjectClass obj =>
(ForeignPtr obj -> obj, FinalizerPtr obj) -> IO (Ptr obj) -> IO obj
wrapNewGObject (ForeignPtr Icon -> Icon, FinalizerPtr Icon)
forall {a}. (ForeignPtr Icon -> Icon, FinalizerPtr a)
mkIcon (IO (Ptr Icon) -> IO Icon) -> IO (Ptr Icon) -> IO Icon
forall a b. (a -> b) -> a -> b
$
ByteString -> (Ptr CChar -> IO (Ptr Icon)) -> IO (Ptr Icon)
forall a. ByteString -> (Ptr CChar -> IO a) -> IO a
useAsCString ByteString
str ((Ptr CChar -> IO (Ptr Icon)) -> IO (Ptr Icon))
-> (Ptr CChar -> IO (Ptr Icon)) -> IO (Ptr Icon)
forall a b. (a -> b) -> a -> b
$ \ Ptr CChar
strPtr ->
(Ptr (Ptr ()) -> IO (Ptr Icon)) -> IO (Ptr Icon)
forall a. (Ptr (Ptr ()) -> IO a) -> IO a
propagateGError (Ptr CChar -> Ptr (Ptr ()) -> IO (Ptr Icon)
g_icon_new_for_string Ptr CChar
strPtr)
foreign import ccall safe "g_icon_equal"
g_icon_equal :: ((Ptr Icon) -> ((Ptr Icon) -> (IO CInt)))
foreign import ccall safe "g_icon_to_string"
g_icon_to_string :: ((Ptr Icon) -> (IO (Ptr CChar)))
foreign import ccall unsafe "g_free"
g_free :: ((Ptr ()) -> (IO ()))
foreign import ccall safe "g_icon_new_for_string"
g_icon_new_for_string :: ((Ptr CChar) -> ((Ptr (Ptr ())) -> (IO (Ptr Icon))))