-- | Copyright  : Will Thompson and Iñaki García Etxebarria
-- License    : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria

#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif

module GI.Rsvg.Functions
    ( 

 -- * Methods


-- ** cleanup #method:cleanup#

    cleanup                                 ,


-- ** init #method:init#

    init                                    ,


-- ** pixbufFromFile #method:pixbufFromFile#

    pixbufFromFile                          ,


-- ** pixbufFromFileAtMaxSize #method:pixbufFromFileAtMaxSize#

    pixbufFromFileAtMaxSize                 ,


-- ** pixbufFromFileAtSize #method:pixbufFromFileAtSize#

    pixbufFromFileAtSize                    ,


-- ** pixbufFromFileAtZoom #method:pixbufFromFileAtZoom#

    pixbufFromFileAtZoom                    ,


-- ** pixbufFromFileAtZoomWithMax #method:pixbufFromFileAtZoomWithMax#

    pixbufFromFileAtZoomWithMax             ,


-- ** setDefaultDpi #method:setDefaultDpi#

    setDefaultDpi                           ,


-- ** setDefaultDpiXY #method:setDefaultDpiXY#

    setDefaultDpiXY                         ,


-- ** term #method:term#

    term                                    ,




    ) where

import Data.GI.Base.ShortPrelude
import qualified Data.GI.Base.ShortPrelude as SP
import qualified Data.GI.Base.Overloading as O
import qualified Prelude as P

import qualified Data.GI.Base.Attributes as GI.Attributes
import qualified Data.GI.Base.BasicTypes as B.Types
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GArray as B.GArray
import qualified Data.GI.Base.GClosure as B.GClosure
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GHashTable as B.GHT
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GValue as B.GValue
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
import qualified Data.GI.Base.Properties as B.Properties
import qualified Data.GI.Base.Signals as B.Signals
import qualified Control.Monad.IO.Class as MIO
import qualified Data.Coerce as Coerce
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP
import qualified GHC.OverloadedLabels as OL
import qualified GHC.Records as R

import qualified GI.GdkPixbuf.Objects.Pixbuf as GdkPixbuf.Pixbuf

-- function term
-- Args: []
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "rsvg_term" rsvg_term :: 
    IO ()

{-# DEPRECATED term ["(Since version 2.36)","There is no need to de-initialize librsvg."] #-}
-- | This function does nothing.
-- 
-- /Since: 2.9/
term ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m ()
term :: forall (m :: * -> *). (HasCallStack, MonadIO m) => m ()
term  = IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    IO ()
rsvg_term
    () -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ()


-- function set_default_dpi_x_y
-- Args: [ Arg
--           { argCName = "dpi_x"
--           , argType = TBasicType TDouble
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "Dots Per Inch (aka Pixels Per Inch)"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "dpi_y"
--           , argType = TBasicType TDouble
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "Dots Per Inch (aka Pixels Per Inch)"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "rsvg_set_default_dpi_x_y" rsvg_set_default_dpi_x_y :: 
    CDouble ->                              -- dpi_x : TBasicType TDouble
    CDouble ->                              -- dpi_y : TBasicType TDouble
    IO ()

{-# DEPRECATED setDefaultDpiXY ["(Since version 2.42.3)","This function used to set a global default DPI.  However,","it only worked if it was called before any t'GI.Rsvg.Objects.Handle.Handle' objects had been","created; it would not work after that.  To avoid global mutable state, please","use 'GI.Rsvg.Objects.Handle.handleSetDpi' instead."] #-}
-- | Do not use this function.  Create an t'GI.Rsvg.Objects.Handle.Handle' and call
-- 'GI.Rsvg.Objects.Handle.handleSetDpiXY' on it instead.
-- 
-- /Since: 2.8/
setDefaultDpiXY ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Double
    -- ^ /@dpiX@/: Dots Per Inch (aka Pixels Per Inch)
    -> Double
    -- ^ /@dpiY@/: Dots Per Inch (aka Pixels Per Inch)
    -> m ()
setDefaultDpiXY :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Double -> Double -> m ()
setDefaultDpiXY Double
dpiX Double
dpiY = IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    let dpiX' :: CDouble
dpiX' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
dpiX
    let dpiY' :: CDouble
dpiY' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
dpiY
    CDouble -> CDouble -> IO ()
rsvg_set_default_dpi_x_y CDouble
dpiX' CDouble
dpiY'
    () -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ()


-- function set_default_dpi
-- Args: [ Arg
--           { argCName = "dpi"
--           , argType = TBasicType TDouble
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "Dots Per Inch (aka Pixels Per Inch)"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "rsvg_set_default_dpi" rsvg_set_default_dpi :: 
    CDouble ->                              -- dpi : TBasicType TDouble
    IO ()

{-# DEPRECATED setDefaultDpi ["(Since version 2.42.3)","This function used to set a global default DPI.  However,","it only worked if it was called before any t'GI.Rsvg.Objects.Handle.Handle' objects had been","created; it would not work after that.  To avoid global mutable state, please","use 'GI.Rsvg.Objects.Handle.handleSetDpi' instead."] #-}
-- | Do not use this function.  Create an t'GI.Rsvg.Objects.Handle.Handle' and call
-- 'GI.Rsvg.Objects.Handle.handleSetDpi' on it instead.
-- 
-- /Since: 2.8/
setDefaultDpi ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Double
    -- ^ /@dpi@/: Dots Per Inch (aka Pixels Per Inch)
    -> m ()
setDefaultDpi :: forall (m :: * -> *). (HasCallStack, MonadIO m) => Double -> m ()
setDefaultDpi Double
dpi = IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    let dpi' :: CDouble
dpi' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
dpi
    CDouble -> IO ()
rsvg_set_default_dpi CDouble
dpi'
    () -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ()


-- function pixbuf_from_file_at_zoom_with_max
-- Args: [ Arg
--           { argCName = "filename"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "A file name" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "x_zoom"
--           , argType = TBasicType TDouble
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "The horizontal zoom factor"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "y_zoom"
--           , argType = TBasicType TDouble
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "The vertical zoom factor"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "max_width"
--           , argType = TBasicType TInt
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "The requested max width"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "max_height"
--           , argType = TBasicType TInt
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "The requested max height"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just
--               (TInterface Name { namespace = "GdkPixbuf" , name = "Pixbuf" })
-- throws : True
-- Skip return : False

foreign import ccall "rsvg_pixbuf_from_file_at_zoom_with_max" rsvg_pixbuf_from_file_at_zoom_with_max :: 
    CString ->                              -- filename : TBasicType TUTF8
    CDouble ->                              -- x_zoom : TBasicType TDouble
    CDouble ->                              -- y_zoom : TBasicType TDouble
    Int32 ->                                -- max_width : TBasicType TInt
    Int32 ->                                -- max_height : TBasicType TInt
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr GdkPixbuf.Pixbuf.Pixbuf)

{-# DEPRECATED pixbufFromFileAtZoomWithMax ["Use 'GI.Rsvg.Objects.Handle.handleNewFromFile' and 'GI.Rsvg.Objects.Handle.handleRenderDocument' instead."] #-}
-- | Loads a new @GdkPixbuf@ from /@filename@/ and returns it.  This pixbuf is scaled
-- from the size indicated by the file by a factor of /@xZoom@/ and /@yZoom@/. If the
-- resulting pixbuf would be larger than max_width\/max_heigh it is uniformly scaled
-- down to fit in that rectangle. The caller must assume the reference to the
-- returned pixbuf. If an error occurred, /@error@/ is set and @NULL@ is returned.
pixbufFromFileAtZoomWithMax ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    -- ^ /@filename@/: A file name
    -> Double
    -- ^ /@xZoom@/: The horizontal zoom factor
    -> Double
    -- ^ /@yZoom@/: The vertical zoom factor
    -> Int32
    -- ^ /@maxWidth@/: The requested max width
    -> Int32
    -- ^ /@maxHeight@/: The requested max height
    -> m (Maybe GdkPixbuf.Pixbuf.Pixbuf)
    -- ^ __Returns:__ A pixbuf, or 'P.Nothing' on error. /(Can throw 'Data.GI.Base.GError.GError')/
pixbufFromFileAtZoomWithMax :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Text -> Double -> Double -> Int32 -> Int32 -> m (Maybe Pixbuf)
pixbufFromFileAtZoomWithMax Text
filename Double
xZoom Double
yZoom Int32
maxWidth Int32
maxHeight = IO (Maybe Pixbuf) -> m (Maybe Pixbuf)
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Pixbuf) -> m (Maybe Pixbuf))
-> IO (Maybe Pixbuf) -> m (Maybe Pixbuf)
forall a b. (a -> b) -> a -> b
$ do
    CString
filename' <- Text -> IO CString
textToCString Text
filename
    let xZoom' :: CDouble
xZoom' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
xZoom
    let yZoom' :: CDouble
yZoom' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
yZoom
    IO (Maybe Pixbuf) -> IO () -> IO (Maybe Pixbuf)
forall a b. IO a -> IO b -> IO a
onException (do
        Ptr Pixbuf
result <- (Ptr (Ptr GError) -> IO (Ptr Pixbuf)) -> IO (Ptr Pixbuf)
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO (Ptr Pixbuf)) -> IO (Ptr Pixbuf))
-> (Ptr (Ptr GError) -> IO (Ptr Pixbuf)) -> IO (Ptr Pixbuf)
forall a b. (a -> b) -> a -> b
$ CString
-> CDouble
-> CDouble
-> Int32
-> Int32
-> Ptr (Ptr GError)
-> IO (Ptr Pixbuf)
rsvg_pixbuf_from_file_at_zoom_with_max CString
filename' CDouble
xZoom' CDouble
yZoom' Int32
maxWidth Int32
maxHeight
        Maybe Pixbuf
maybeResult <- Ptr Pixbuf -> (Ptr Pixbuf -> IO Pixbuf) -> IO (Maybe Pixbuf)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull Ptr Pixbuf
result ((Ptr Pixbuf -> IO Pixbuf) -> IO (Maybe Pixbuf))
-> (Ptr Pixbuf -> IO Pixbuf) -> IO (Maybe Pixbuf)
forall a b. (a -> b) -> a -> b
$ \Ptr Pixbuf
result' -> do
            Pixbuf
result'' <- ((ManagedPtr Pixbuf -> Pixbuf) -> Ptr Pixbuf -> IO Pixbuf
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
wrapObject ManagedPtr Pixbuf -> Pixbuf
GdkPixbuf.Pixbuf.Pixbuf) Ptr Pixbuf
result'
            Pixbuf -> IO Pixbuf
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Pixbuf
result''
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
filename'
        Maybe Pixbuf -> IO (Maybe Pixbuf)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Pixbuf
maybeResult
     ) (do
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
filename'
     )


-- function pixbuf_from_file_at_zoom
-- Args: [ Arg
--           { argCName = "filename"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "A file name" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "x_zoom"
--           , argType = TBasicType TDouble
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "The horizontal zoom factor"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "y_zoom"
--           , argType = TBasicType TDouble
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "The vertical zoom factor"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just
--               (TInterface Name { namespace = "GdkPixbuf" , name = "Pixbuf" })
-- throws : True
-- Skip return : False

foreign import ccall "rsvg_pixbuf_from_file_at_zoom" rsvg_pixbuf_from_file_at_zoom :: 
    CString ->                              -- filename : TBasicType TUTF8
    CDouble ->                              -- x_zoom : TBasicType TDouble
    CDouble ->                              -- y_zoom : TBasicType TDouble
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr GdkPixbuf.Pixbuf.Pixbuf)

{-# DEPRECATED pixbufFromFileAtZoom ["Use 'GI.Rsvg.Objects.Handle.handleNewFromFile' and 'GI.Rsvg.Objects.Handle.handleRenderDocument' instead."] #-}
-- | Loads a new @GdkPixbuf@ from /@filename@/ and returns it.  This pixbuf is scaled
-- from the size indicated by the file by a factor of /@xZoom@/ and /@yZoom@/.  The
-- caller must assume the reference to the returned pixbuf. If an error
-- occurred, /@error@/ is set and @NULL@ is returned.
pixbufFromFileAtZoom ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    -- ^ /@filename@/: A file name
    -> Double
    -- ^ /@xZoom@/: The horizontal zoom factor
    -> Double
    -- ^ /@yZoom@/: The vertical zoom factor
    -> m (Maybe GdkPixbuf.Pixbuf.Pixbuf)
    -- ^ __Returns:__ A pixbuf, or 'P.Nothing' on error. /(Can throw 'Data.GI.Base.GError.GError')/
pixbufFromFileAtZoom :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Text -> Double -> Double -> m (Maybe Pixbuf)
pixbufFromFileAtZoom Text
filename Double
xZoom Double
yZoom = IO (Maybe Pixbuf) -> m (Maybe Pixbuf)
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Pixbuf) -> m (Maybe Pixbuf))
-> IO (Maybe Pixbuf) -> m (Maybe Pixbuf)
forall a b. (a -> b) -> a -> b
$ do
    CString
filename' <- Text -> IO CString
textToCString Text
filename
    let xZoom' :: CDouble
xZoom' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
xZoom
    let yZoom' :: CDouble
yZoom' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
yZoom
    IO (Maybe Pixbuf) -> IO () -> IO (Maybe Pixbuf)
forall a b. IO a -> IO b -> IO a
onException (do
        Ptr Pixbuf
result <- (Ptr (Ptr GError) -> IO (Ptr Pixbuf)) -> IO (Ptr Pixbuf)
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO (Ptr Pixbuf)) -> IO (Ptr Pixbuf))
-> (Ptr (Ptr GError) -> IO (Ptr Pixbuf)) -> IO (Ptr Pixbuf)
forall a b. (a -> b) -> a -> b
$ CString
-> CDouble -> CDouble -> Ptr (Ptr GError) -> IO (Ptr Pixbuf)
rsvg_pixbuf_from_file_at_zoom CString
filename' CDouble
xZoom' CDouble
yZoom'
        Maybe Pixbuf
maybeResult <- Ptr Pixbuf -> (Ptr Pixbuf -> IO Pixbuf) -> IO (Maybe Pixbuf)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull Ptr Pixbuf
result ((Ptr Pixbuf -> IO Pixbuf) -> IO (Maybe Pixbuf))
-> (Ptr Pixbuf -> IO Pixbuf) -> IO (Maybe Pixbuf)
forall a b. (a -> b) -> a -> b
$ \Ptr Pixbuf
result' -> do
            Pixbuf
result'' <- ((ManagedPtr Pixbuf -> Pixbuf) -> Ptr Pixbuf -> IO Pixbuf
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
wrapObject ManagedPtr Pixbuf -> Pixbuf
GdkPixbuf.Pixbuf.Pixbuf) Ptr Pixbuf
result'
            Pixbuf -> IO Pixbuf
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Pixbuf
result''
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
filename'
        Maybe Pixbuf -> IO (Maybe Pixbuf)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Pixbuf
maybeResult
     ) (do
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
filename'
     )


-- function pixbuf_from_file_at_size
-- Args: [ Arg
--           { argCName = "filename"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "A file name" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "width"
--           , argType = TBasicType TInt
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "The new width, or -1"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "height"
--           , argType = TBasicType TInt
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "The new height, or -1"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just
--               (TInterface Name { namespace = "GdkPixbuf" , name = "Pixbuf" })
-- throws : True
-- Skip return : False

foreign import ccall "rsvg_pixbuf_from_file_at_size" rsvg_pixbuf_from_file_at_size :: 
    CString ->                              -- filename : TBasicType TUTF8
    Int32 ->                                -- width : TBasicType TInt
    Int32 ->                                -- height : TBasicType TInt
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr GdkPixbuf.Pixbuf.Pixbuf)

{-# DEPRECATED pixbufFromFileAtSize ["Use 'GI.Rsvg.Objects.Handle.handleNewFromFile' and 'GI.Rsvg.Objects.Handle.handleRenderDocument' instead."] #-}
-- | Loads a new @GdkPixbuf@ from /@filename@/ and returns it.  This pixbuf is scaled
-- from the size indicated to the new size indicated by /@width@/ and /@height@/.  If
-- both of these are -1, then the default size of the image being loaded is
-- used.  The caller must assume the reference to the returned pixbuf. If an
-- error occurred, /@error@/ is set and @NULL@ is returned.
pixbufFromFileAtSize ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    -- ^ /@filename@/: A file name
    -> Int32
    -- ^ /@width@/: The new width, or -1
    -> Int32
    -- ^ /@height@/: The new height, or -1
    -> m (Maybe GdkPixbuf.Pixbuf.Pixbuf)
    -- ^ __Returns:__ A pixbuf, or 'P.Nothing' on error. /(Can throw 'Data.GI.Base.GError.GError')/
pixbufFromFileAtSize :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Text -> Int32 -> Int32 -> m (Maybe Pixbuf)
pixbufFromFileAtSize Text
filename Int32
width Int32
height = IO (Maybe Pixbuf) -> m (Maybe Pixbuf)
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Pixbuf) -> m (Maybe Pixbuf))
-> IO (Maybe Pixbuf) -> m (Maybe Pixbuf)
forall a b. (a -> b) -> a -> b
$ do
    CString
filename' <- Text -> IO CString
textToCString Text
filename
    IO (Maybe Pixbuf) -> IO () -> IO (Maybe Pixbuf)
forall a b. IO a -> IO b -> IO a
onException (do
        Ptr Pixbuf
result <- (Ptr (Ptr GError) -> IO (Ptr Pixbuf)) -> IO (Ptr Pixbuf)
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO (Ptr Pixbuf)) -> IO (Ptr Pixbuf))
-> (Ptr (Ptr GError) -> IO (Ptr Pixbuf)) -> IO (Ptr Pixbuf)
forall a b. (a -> b) -> a -> b
$ CString -> Int32 -> Int32 -> Ptr (Ptr GError) -> IO (Ptr Pixbuf)
rsvg_pixbuf_from_file_at_size CString
filename' Int32
width Int32
height
        Maybe Pixbuf
maybeResult <- Ptr Pixbuf -> (Ptr Pixbuf -> IO Pixbuf) -> IO (Maybe Pixbuf)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull Ptr Pixbuf
result ((Ptr Pixbuf -> IO Pixbuf) -> IO (Maybe Pixbuf))
-> (Ptr Pixbuf -> IO Pixbuf) -> IO (Maybe Pixbuf)
forall a b. (a -> b) -> a -> b
$ \Ptr Pixbuf
result' -> do
            Pixbuf
result'' <- ((ManagedPtr Pixbuf -> Pixbuf) -> Ptr Pixbuf -> IO Pixbuf
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
wrapObject ManagedPtr Pixbuf -> Pixbuf
GdkPixbuf.Pixbuf.Pixbuf) Ptr Pixbuf
result'
            Pixbuf -> IO Pixbuf
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Pixbuf
result''
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
filename'
        Maybe Pixbuf -> IO (Maybe Pixbuf)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Pixbuf
maybeResult
     ) (do
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
filename'
     )


-- function pixbuf_from_file_at_max_size
-- Args: [ Arg
--           { argCName = "filename"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "A file name" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "max_width"
--           , argType = TBasicType TInt
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "The requested max width"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "max_height"
--           , argType = TBasicType TInt
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "The requested max height"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just
--               (TInterface Name { namespace = "GdkPixbuf" , name = "Pixbuf" })
-- throws : True
-- Skip return : False

foreign import ccall "rsvg_pixbuf_from_file_at_max_size" rsvg_pixbuf_from_file_at_max_size :: 
    CString ->                              -- filename : TBasicType TUTF8
    Int32 ->                                -- max_width : TBasicType TInt
    Int32 ->                                -- max_height : TBasicType TInt
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr GdkPixbuf.Pixbuf.Pixbuf)

{-# DEPRECATED pixbufFromFileAtMaxSize ["Use 'GI.Rsvg.Objects.Handle.handleNewFromFile' and 'GI.Rsvg.Objects.Handle.handleRenderDocument' instead."] #-}
-- | Loads a new @GdkPixbuf@ from /@filename@/ and returns it.  This pixbuf is uniformly
-- scaled so that the it fits into a rectangle of size @max_width * max_height@. The
-- caller must assume the reference to the returned pixbuf. If an error occurred,
-- /@error@/ is set and @NULL@ is returned.
pixbufFromFileAtMaxSize ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    -- ^ /@filename@/: A file name
    -> Int32
    -- ^ /@maxWidth@/: The requested max width
    -> Int32
    -- ^ /@maxHeight@/: The requested max height
    -> m (Maybe GdkPixbuf.Pixbuf.Pixbuf)
    -- ^ __Returns:__ A pixbuf, or 'P.Nothing' on error. /(Can throw 'Data.GI.Base.GError.GError')/
pixbufFromFileAtMaxSize :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Text -> Int32 -> Int32 -> m (Maybe Pixbuf)
pixbufFromFileAtMaxSize Text
filename Int32
maxWidth Int32
maxHeight = IO (Maybe Pixbuf) -> m (Maybe Pixbuf)
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Pixbuf) -> m (Maybe Pixbuf))
-> IO (Maybe Pixbuf) -> m (Maybe Pixbuf)
forall a b. (a -> b) -> a -> b
$ do
    CString
filename' <- Text -> IO CString
textToCString Text
filename
    IO (Maybe Pixbuf) -> IO () -> IO (Maybe Pixbuf)
forall a b. IO a -> IO b -> IO a
onException (do
        Ptr Pixbuf
result <- (Ptr (Ptr GError) -> IO (Ptr Pixbuf)) -> IO (Ptr Pixbuf)
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO (Ptr Pixbuf)) -> IO (Ptr Pixbuf))
-> (Ptr (Ptr GError) -> IO (Ptr Pixbuf)) -> IO (Ptr Pixbuf)
forall a b. (a -> b) -> a -> b
$ CString -> Int32 -> Int32 -> Ptr (Ptr GError) -> IO (Ptr Pixbuf)
rsvg_pixbuf_from_file_at_max_size CString
filename' Int32
maxWidth Int32
maxHeight
        Maybe Pixbuf
maybeResult <- Ptr Pixbuf -> (Ptr Pixbuf -> IO Pixbuf) -> IO (Maybe Pixbuf)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull Ptr Pixbuf
result ((Ptr Pixbuf -> IO Pixbuf) -> IO (Maybe Pixbuf))
-> (Ptr Pixbuf -> IO Pixbuf) -> IO (Maybe Pixbuf)
forall a b. (a -> b) -> a -> b
$ \Ptr Pixbuf
result' -> do
            Pixbuf
result'' <- ((ManagedPtr Pixbuf -> Pixbuf) -> Ptr Pixbuf -> IO Pixbuf
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
wrapObject ManagedPtr Pixbuf -> Pixbuf
GdkPixbuf.Pixbuf.Pixbuf) Ptr Pixbuf
result'
            Pixbuf -> IO Pixbuf
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Pixbuf
result''
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
filename'
        Maybe Pixbuf -> IO (Maybe Pixbuf)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Pixbuf
maybeResult
     ) (do
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
filename'
     )


-- function pixbuf_from_file
-- Args: [ Arg
--           { argCName = "filename"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "A file name" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just
--               (TInterface Name { namespace = "GdkPixbuf" , name = "Pixbuf" })
-- throws : True
-- Skip return : False

foreign import ccall "rsvg_pixbuf_from_file" rsvg_pixbuf_from_file :: 
    CString ->                              -- filename : TBasicType TUTF8
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr GdkPixbuf.Pixbuf.Pixbuf)

{-# DEPRECATED pixbufFromFile ["Use 'GI.Rsvg.Objects.Handle.handleNewFromFile' and 'GI.Rsvg.Objects.Handle.handleRenderDocument' instead."] #-}
-- | Loads a new @GdkPixbuf@ from /@filename@/ and returns it.  The caller must
-- assume the reference to the reurned pixbuf. If an error occurred, /@error@/ is
-- set and @NULL@ is returned.
pixbufFromFile ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    -- ^ /@filename@/: A file name
    -> m (Maybe GdkPixbuf.Pixbuf.Pixbuf)
    -- ^ __Returns:__ A pixbuf, or 'P.Nothing' on error. /(Can throw 'Data.GI.Base.GError.GError')/
pixbufFromFile :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Text -> m (Maybe Pixbuf)
pixbufFromFile Text
filename = IO (Maybe Pixbuf) -> m (Maybe Pixbuf)
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Pixbuf) -> m (Maybe Pixbuf))
-> IO (Maybe Pixbuf) -> m (Maybe Pixbuf)
forall a b. (a -> b) -> a -> b
$ do
    CString
filename' <- Text -> IO CString
textToCString Text
filename
    IO (Maybe Pixbuf) -> IO () -> IO (Maybe Pixbuf)
forall a b. IO a -> IO b -> IO a
onException (do
        Ptr Pixbuf
result <- (Ptr (Ptr GError) -> IO (Ptr Pixbuf)) -> IO (Ptr Pixbuf)
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO (Ptr Pixbuf)) -> IO (Ptr Pixbuf))
-> (Ptr (Ptr GError) -> IO (Ptr Pixbuf)) -> IO (Ptr Pixbuf)
forall a b. (a -> b) -> a -> b
$ CString -> Ptr (Ptr GError) -> IO (Ptr Pixbuf)
rsvg_pixbuf_from_file CString
filename'
        Maybe Pixbuf
maybeResult <- Ptr Pixbuf -> (Ptr Pixbuf -> IO Pixbuf) -> IO (Maybe Pixbuf)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull Ptr Pixbuf
result ((Ptr Pixbuf -> IO Pixbuf) -> IO (Maybe Pixbuf))
-> (Ptr Pixbuf -> IO Pixbuf) -> IO (Maybe Pixbuf)
forall a b. (a -> b) -> a -> b
$ \Ptr Pixbuf
result' -> do
            Pixbuf
result'' <- ((ManagedPtr Pixbuf -> Pixbuf) -> Ptr Pixbuf -> IO Pixbuf
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
wrapObject ManagedPtr Pixbuf -> Pixbuf
GdkPixbuf.Pixbuf.Pixbuf) Ptr Pixbuf
result'
            Pixbuf -> IO Pixbuf
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Pixbuf
result''
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
filename'
        Maybe Pixbuf -> IO (Maybe Pixbuf)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Pixbuf
maybeResult
     ) (do
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
filename'
     )


-- function init
-- Args: []
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "rsvg_init" rsvg_init :: 
    IO ()

{-# DEPRECATED init ["(Since version 2.36)","There is no need to initialize librsvg."] #-}
-- | This function does nothing.
-- 
-- /Since: 2.9/
init ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m ()
init :: forall (m :: * -> *). (HasCallStack, MonadIO m) => m ()
init  = IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    IO ()
rsvg_init
    () -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ()


-- function cleanup
-- Args: []
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "rsvg_cleanup" rsvg_cleanup :: 
    IO ()

{-# DEPRECATED cleanup ["(Since version 2.46)","No-op. This function should not be called from normal programs."] #-}
-- | This function does nothing.
-- 
-- /Since: 2.36/
cleanup ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m ()
cleanup :: forall (m :: * -> *). (HasCallStack, MonadIO m) => m ()
cleanup  = IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    IO ()
rsvg_cleanup
    () -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ()