{-# LANGUAGE TypeApplications #-}


-- | Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
-- License    : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria
-- 
-- GtkWidgetPaintable is an implementation of the t'GI.Gdk.Interfaces.Paintable.Paintable' interface
-- that allows displaying the contents of a t'GI.Gtk.Objects.Widget.Widget'.
-- 
-- GtkWidgetPaintable will also take care of the widget not being in a
-- state where it can be drawn (like when it isn\'t shown) and just draw
-- nothing or where it does not have a size (like when it is hidden) and
-- report no size in that case.
-- 
-- Of course, GtkWidgetPaintable allows you to monitor widgets for size
-- changes by emitting the [invalidateSize]("GI.Gdk.Interfaces.Paintable#signal:invalidateSize") signal whenever
-- the size of the widget changes as well as for visual changes by
-- emitting the [invalidateContents]("GI.Gdk.Interfaces.Paintable#signal:invalidateContents") signal whenever the
-- widget changes.
-- 
-- You can of course use a GtkWidgetPaintable everywhere a
-- t'GI.Gdk.Interfaces.Paintable.Paintable' is allowed, including using it on a t'GI.Gtk.Objects.Picture.Picture' (or one
-- of its parents) that it was set on itself via 'GI.Gtk.Objects.Picture.pictureSetPaintable'.
-- The paintable will take care of recursion when this happens. If you do
-- this however, ensure the t'GI.Gtk.Objects.Picture.Picture':@/can-shrink/@ property is set to
-- 'P.True' or you might end up with an infinitely growing widget.

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

module GI.Gtk.Objects.WidgetPaintable
    ( 

-- * Exported types
    WidgetPaintable(..)                     ,
    IsWidgetPaintable                       ,
    toWidgetPaintable                       ,
    noWidgetPaintable                       ,


 -- * Methods
-- ** Overloaded methods #method:Overloaded methods#

#if defined(ENABLE_OVERLOADING)
    ResolveWidgetPaintableMethod            ,
#endif


-- ** getWidget #method:getWidget#

#if defined(ENABLE_OVERLOADING)
    WidgetPaintableGetWidgetMethodInfo      ,
#endif
    widgetPaintableGetWidget                ,


-- ** new #method:new#

    widgetPaintableNew                      ,


-- ** setWidget #method:setWidget#

#if defined(ENABLE_OVERLOADING)
    WidgetPaintableSetWidgetMethodInfo      ,
#endif
    widgetPaintableSetWidget                ,




 -- * Properties
-- ** widget #attr:widget#
-- | The observed widget or 'P.Nothing' if none.

#if defined(ENABLE_OVERLOADING)
    WidgetPaintableWidgetPropertyInfo       ,
#endif
    clearWidgetPaintableWidget              ,
    constructWidgetPaintableWidget          ,
    getWidgetPaintableWidget                ,
    setWidgetPaintableWidget                ,
#if defined(ENABLE_OVERLOADING)
    widgetPaintableWidget                   ,
#endif




    ) 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.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GClosure as B.GClosure
import qualified Data.GI.Base.GError as B.GError
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 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 GI.GObject.Objects.Object as GObject.Object
import qualified GI.Gdk.Interfaces.Paintable as Gdk.Paintable
import {-# SOURCE #-} qualified GI.Gtk.Objects.Widget as Gtk.Widget

-- | Memory-managed wrapper type.
newtype WidgetPaintable = WidgetPaintable (ManagedPtr WidgetPaintable)
    deriving (WidgetPaintable -> WidgetPaintable -> Bool
(WidgetPaintable -> WidgetPaintable -> Bool)
-> (WidgetPaintable -> WidgetPaintable -> Bool)
-> Eq WidgetPaintable
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: WidgetPaintable -> WidgetPaintable -> Bool
$c/= :: WidgetPaintable -> WidgetPaintable -> Bool
== :: WidgetPaintable -> WidgetPaintable -> Bool
$c== :: WidgetPaintable -> WidgetPaintable -> Bool
Eq)
foreign import ccall "gtk_widget_paintable_get_type"
    c_gtk_widget_paintable_get_type :: IO GType

instance GObject WidgetPaintable where
    gobjectType :: IO GType
gobjectType = IO GType
c_gtk_widget_paintable_get_type
    

-- | Convert 'WidgetPaintable' to and from 'Data.GI.Base.GValue.GValue' with 'Data.GI.Base.GValue.toGValue' and 'Data.GI.Base.GValue.fromGValue'.
instance B.GValue.IsGValue WidgetPaintable where
    toGValue :: WidgetPaintable -> IO GValue
toGValue o :: WidgetPaintable
o = do
        GType
gtype <- IO GType
c_gtk_widget_paintable_get_type
        WidgetPaintable -> (Ptr WidgetPaintable -> IO GValue) -> IO GValue
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr WidgetPaintable
o (GType
-> (GValue -> Ptr WidgetPaintable -> IO ())
-> Ptr WidgetPaintable
-> IO GValue
forall a. GType -> (GValue -> a -> IO ()) -> a -> IO GValue
B.GValue.buildGValue GType
gtype GValue -> Ptr WidgetPaintable -> IO ()
forall a. GObject a => GValue -> Ptr a -> IO ()
B.GValue.set_object)
        
    fromGValue :: GValue -> IO WidgetPaintable
fromGValue gv :: GValue
gv = do
        Ptr WidgetPaintable
ptr <- GValue -> IO (Ptr WidgetPaintable)
forall b. GObject b => GValue -> IO (Ptr b)
B.GValue.get_object GValue
gv :: IO (Ptr WidgetPaintable)
        (ManagedPtr WidgetPaintable -> WidgetPaintable)
-> Ptr WidgetPaintable -> IO WidgetPaintable
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
B.ManagedPtr.newObject ManagedPtr WidgetPaintable -> WidgetPaintable
WidgetPaintable Ptr WidgetPaintable
ptr
        
    

-- | Type class for types which can be safely cast to `WidgetPaintable`, for instance with `toWidgetPaintable`.
class (GObject o, O.IsDescendantOf WidgetPaintable o) => IsWidgetPaintable o
instance (GObject o, O.IsDescendantOf WidgetPaintable o) => IsWidgetPaintable o

instance O.HasParentTypes WidgetPaintable
type instance O.ParentTypes WidgetPaintable = '[GObject.Object.Object, Gdk.Paintable.Paintable]

-- | Cast to `WidgetPaintable`, for types for which this is known to be safe. For general casts, use `Data.GI.Base.ManagedPtr.castTo`.
toWidgetPaintable :: (MonadIO m, IsWidgetPaintable o) => o -> m WidgetPaintable
toWidgetPaintable :: o -> m WidgetPaintable
toWidgetPaintable = IO WidgetPaintable -> m WidgetPaintable
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO WidgetPaintable -> m WidgetPaintable)
-> (o -> IO WidgetPaintable) -> o -> m WidgetPaintable
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ManagedPtr WidgetPaintable -> WidgetPaintable)
-> o -> IO WidgetPaintable
forall o o'.
(HasCallStack, GObject o, GObject o') =>
(ManagedPtr o' -> o') -> o -> IO o'
unsafeCastTo ManagedPtr WidgetPaintable -> WidgetPaintable
WidgetPaintable

-- | A convenience alias for `Nothing` :: `Maybe` `WidgetPaintable`.
noWidgetPaintable :: Maybe WidgetPaintable
noWidgetPaintable :: Maybe WidgetPaintable
noWidgetPaintable = Maybe WidgetPaintable
forall a. Maybe a
Nothing

#if defined(ENABLE_OVERLOADING)
type family ResolveWidgetPaintableMethod (t :: Symbol) (o :: *) :: * where
    ResolveWidgetPaintableMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveWidgetPaintableMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveWidgetPaintableMethod "computeConcreteSize" o = Gdk.Paintable.PaintableComputeConcreteSizeMethodInfo
    ResolveWidgetPaintableMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveWidgetPaintableMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveWidgetPaintableMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
    ResolveWidgetPaintableMethod "invalidateContents" o = Gdk.Paintable.PaintableInvalidateContentsMethodInfo
    ResolveWidgetPaintableMethod "invalidateSize" o = Gdk.Paintable.PaintableInvalidateSizeMethodInfo
    ResolveWidgetPaintableMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveWidgetPaintableMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveWidgetPaintableMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveWidgetPaintableMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveWidgetPaintableMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveWidgetPaintableMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveWidgetPaintableMethod "snapshot" o = Gdk.Paintable.PaintableSnapshotMethodInfo
    ResolveWidgetPaintableMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveWidgetPaintableMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveWidgetPaintableMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveWidgetPaintableMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveWidgetPaintableMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveWidgetPaintableMethod "getCurrentImage" o = Gdk.Paintable.PaintableGetCurrentImageMethodInfo
    ResolveWidgetPaintableMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveWidgetPaintableMethod "getFlags" o = Gdk.Paintable.PaintableGetFlagsMethodInfo
    ResolveWidgetPaintableMethod "getIntrinsicAspectRatio" o = Gdk.Paintable.PaintableGetIntrinsicAspectRatioMethodInfo
    ResolveWidgetPaintableMethod "getIntrinsicHeight" o = Gdk.Paintable.PaintableGetIntrinsicHeightMethodInfo
    ResolveWidgetPaintableMethod "getIntrinsicWidth" o = Gdk.Paintable.PaintableGetIntrinsicWidthMethodInfo
    ResolveWidgetPaintableMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveWidgetPaintableMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveWidgetPaintableMethod "getWidget" o = WidgetPaintableGetWidgetMethodInfo
    ResolveWidgetPaintableMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveWidgetPaintableMethod "setDataFull" o = GObject.Object.ObjectSetDataFullMethodInfo
    ResolveWidgetPaintableMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveWidgetPaintableMethod "setWidget" o = WidgetPaintableSetWidgetMethodInfo
    ResolveWidgetPaintableMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveWidgetPaintableMethod t WidgetPaintable, O.MethodInfo info WidgetPaintable p) => OL.IsLabel t (WidgetPaintable -> p) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.overloadedMethod @info
#else
    fromLabel _ = O.overloadedMethod @info
#endif

#endif

-- VVV Prop "widget"
   -- Type: TInterface (Name {namespace = "Gtk", name = "Widget"})
   -- Flags: [PropertyReadable,PropertyWritable]
   -- Nullable: (Just True,Just True)

-- | Get the value of the “@widget@” property.
-- When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
-- 
-- @
-- 'Data.GI.Base.Attributes.get' widgetPaintable #widget
-- @
getWidgetPaintableWidget :: (MonadIO m, IsWidgetPaintable o) => o -> m (Maybe Gtk.Widget.Widget)
getWidgetPaintableWidget :: o -> m (Maybe Widget)
getWidgetPaintableWidget obj :: o
obj = IO (Maybe Widget) -> m (Maybe Widget)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Widget) -> m (Maybe Widget))
-> IO (Maybe Widget) -> m (Maybe Widget)
forall a b. (a -> b) -> a -> b
$ o -> String -> (ManagedPtr Widget -> Widget) -> IO (Maybe Widget)
forall a b.
(GObject a, GObject b) =>
a -> String -> (ManagedPtr b -> b) -> IO (Maybe b)
B.Properties.getObjectPropertyObject o
obj "widget" ManagedPtr Widget -> Widget
Gtk.Widget.Widget

-- | Set the value of the “@widget@” property.
-- When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
-- 
-- @
-- 'Data.GI.Base.Attributes.set' widgetPaintable [ #widget 'Data.GI.Base.Attributes.:=' value ]
-- @
setWidgetPaintableWidget :: (MonadIO m, IsWidgetPaintable o, Gtk.Widget.IsWidget a) => o -> a -> m ()
setWidgetPaintableWidget :: o -> a -> m ()
setWidgetPaintableWidget obj :: o
obj val :: a
val = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ o -> String -> Maybe a -> IO ()
forall a b.
(GObject a, GObject b) =>
a -> String -> Maybe b -> IO ()
B.Properties.setObjectPropertyObject o
obj "widget" (a -> Maybe a
forall a. a -> Maybe a
Just a
val)

-- | Construct a `GValueConstruct` with valid value for the “@widget@” property. This is rarely needed directly, but it is used by `Data.GI.Base.Constructible.new`.
constructWidgetPaintableWidget :: (IsWidgetPaintable o, Gtk.Widget.IsWidget a) => a -> IO (GValueConstruct o)
constructWidgetPaintableWidget :: a -> IO (GValueConstruct o)
constructWidgetPaintableWidget val :: a
val = String -> Maybe a -> IO (GValueConstruct o)
forall a o.
GObject a =>
String -> Maybe a -> IO (GValueConstruct o)
B.Properties.constructObjectPropertyObject "widget" (a -> Maybe a
forall a. a -> Maybe a
Just a
val)

-- | Set the value of the “@widget@” property to `Nothing`.
-- When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
-- 
-- @
-- 'Data.GI.Base.Attributes.clear' #widget
-- @
clearWidgetPaintableWidget :: (MonadIO m, IsWidgetPaintable o) => o -> m ()
clearWidgetPaintableWidget :: o -> m ()
clearWidgetPaintableWidget obj :: o
obj = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ o -> String -> Maybe Widget -> IO ()
forall a b.
(GObject a, GObject b) =>
a -> String -> Maybe b -> IO ()
B.Properties.setObjectPropertyObject o
obj "widget" (Maybe Widget
forall a. Maybe a
Nothing :: Maybe Gtk.Widget.Widget)

#if defined(ENABLE_OVERLOADING)
data WidgetPaintableWidgetPropertyInfo
instance AttrInfo WidgetPaintableWidgetPropertyInfo where
    type AttrAllowedOps WidgetPaintableWidgetPropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet, 'AttrClear]
    type AttrBaseTypeConstraint WidgetPaintableWidgetPropertyInfo = IsWidgetPaintable
    type AttrSetTypeConstraint WidgetPaintableWidgetPropertyInfo = Gtk.Widget.IsWidget
    type AttrTransferTypeConstraint WidgetPaintableWidgetPropertyInfo = Gtk.Widget.IsWidget
    type AttrTransferType WidgetPaintableWidgetPropertyInfo = Gtk.Widget.Widget
    type AttrGetType WidgetPaintableWidgetPropertyInfo = (Maybe Gtk.Widget.Widget)
    type AttrLabel WidgetPaintableWidgetPropertyInfo = "widget"
    type AttrOrigin WidgetPaintableWidgetPropertyInfo = WidgetPaintable
    attrGet = getWidgetPaintableWidget
    attrSet = setWidgetPaintableWidget
    attrTransfer _ v = do
        unsafeCastTo Gtk.Widget.Widget v
    attrConstruct = constructWidgetPaintableWidget
    attrClear = clearWidgetPaintableWidget
#endif

#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList WidgetPaintable
type instance O.AttributeList WidgetPaintable = WidgetPaintableAttributeList
type WidgetPaintableAttributeList = ('[ '("widget", WidgetPaintableWidgetPropertyInfo)] :: [(Symbol, *)])
#endif

#if defined(ENABLE_OVERLOADING)
widgetPaintableWidget :: AttrLabelProxy "widget"
widgetPaintableWidget = AttrLabelProxy

#endif

#if defined(ENABLE_OVERLOADING)
type instance O.SignalList WidgetPaintable = WidgetPaintableSignalList
type WidgetPaintableSignalList = ('[ '("invalidateContents", Gdk.Paintable.PaintableInvalidateContentsSignalInfo), '("invalidateSize", Gdk.Paintable.PaintableInvalidateSizeSignalInfo), '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])

#endif

-- method WidgetPaintable::new
-- method type : Constructor
-- Args: [ Arg
--           { argCName = "widget"
--           , argType = TInterface Name { namespace = "Gtk" , name = "Widget" }
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GtkWidget or %NULL"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just
--               (TInterface Name { namespace = "Gtk" , name = "WidgetPaintable" })
-- throws : False
-- Skip return : False

foreign import ccall "gtk_widget_paintable_new" gtk_widget_paintable_new :: 
    Ptr Gtk.Widget.Widget ->                -- widget : TInterface (Name {namespace = "Gtk", name = "Widget"})
    IO (Ptr WidgetPaintable)

-- | Creates a new widget paintable observing the given widget.
widgetPaintableNew ::
    (B.CallStack.HasCallStack, MonadIO m, Gtk.Widget.IsWidget a) =>
    Maybe (a)
    -- ^ /@widget@/: a t'GI.Gtk.Objects.Widget.Widget' or 'P.Nothing'
    -> m WidgetPaintable
    -- ^ __Returns:__ a new t'GI.Gtk.Objects.WidgetPaintable.WidgetPaintable'
widgetPaintableNew :: Maybe a -> m WidgetPaintable
widgetPaintableNew widget :: Maybe a
widget = IO WidgetPaintable -> m WidgetPaintable
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO WidgetPaintable -> m WidgetPaintable)
-> IO WidgetPaintable -> m WidgetPaintable
forall a b. (a -> b) -> a -> b
$ do
    Ptr Widget
maybeWidget <- case Maybe a
widget of
        Nothing -> Ptr Widget -> IO (Ptr Widget)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Widget
forall a. Ptr a
nullPtr
        Just jWidget :: a
jWidget -> do
            Ptr Widget
jWidget' <- a -> IO (Ptr Widget)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
jWidget
            Ptr Widget -> IO (Ptr Widget)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Widget
jWidget'
    Ptr WidgetPaintable
result <- Ptr Widget -> IO (Ptr WidgetPaintable)
gtk_widget_paintable_new Ptr Widget
maybeWidget
    Text -> Ptr WidgetPaintable -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "widgetPaintableNew" Ptr WidgetPaintable
result
    WidgetPaintable
result' <- ((ManagedPtr WidgetPaintable -> WidgetPaintable)
-> Ptr WidgetPaintable -> IO WidgetPaintable
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
wrapObject ManagedPtr WidgetPaintable -> WidgetPaintable
WidgetPaintable) Ptr WidgetPaintable
result
    Maybe a -> (a -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe a
widget a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
    WidgetPaintable -> IO WidgetPaintable
forall (m :: * -> *) a. Monad m => a -> m a
return WidgetPaintable
result'

#if defined(ENABLE_OVERLOADING)
#endif

-- method WidgetPaintable::get_widget
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "self"
--           , argType =
--               TInterface Name { namespace = "Gtk" , name = "WidgetPaintable" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GtkWidgetPaintable"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "Gtk" , name = "Widget" })
-- throws : False
-- Skip return : False

foreign import ccall "gtk_widget_paintable_get_widget" gtk_widget_paintable_get_widget :: 
    Ptr WidgetPaintable ->                  -- self : TInterface (Name {namespace = "Gtk", name = "WidgetPaintable"})
    IO (Ptr Gtk.Widget.Widget)

-- | Returns the widget that is observed or 'P.Nothing'
-- if none.
widgetPaintableGetWidget ::
    (B.CallStack.HasCallStack, MonadIO m, IsWidgetPaintable a) =>
    a
    -- ^ /@self@/: a t'GI.Gtk.Objects.WidgetPaintable.WidgetPaintable'
    -> m (Maybe Gtk.Widget.Widget)
    -- ^ __Returns:__ the observed widget.
widgetPaintableGetWidget :: a -> m (Maybe Widget)
widgetPaintableGetWidget self :: a
self = IO (Maybe Widget) -> m (Maybe Widget)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Widget) -> m (Maybe Widget))
-> IO (Maybe Widget) -> m (Maybe Widget)
forall a b. (a -> b) -> a -> b
$ do
    Ptr WidgetPaintable
self' <- a -> IO (Ptr WidgetPaintable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
self
    Ptr Widget
result <- Ptr WidgetPaintable -> IO (Ptr Widget)
gtk_widget_paintable_get_widget Ptr WidgetPaintable
self'
    Maybe Widget
maybeResult <- Ptr Widget -> (Ptr Widget -> IO Widget) -> IO (Maybe Widget)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull Ptr Widget
result ((Ptr Widget -> IO Widget) -> IO (Maybe Widget))
-> (Ptr Widget -> IO Widget) -> IO (Maybe Widget)
forall a b. (a -> b) -> a -> b
$ \result' :: Ptr Widget
result' -> do
        Widget
result'' <- ((ManagedPtr Widget -> Widget) -> Ptr Widget -> IO Widget
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
newObject ManagedPtr Widget -> Widget
Gtk.Widget.Widget) Ptr Widget
result'
        Widget -> IO Widget
forall (m :: * -> *) a. Monad m => a -> m a
return Widget
result''
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
self
    Maybe Widget -> IO (Maybe Widget)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Widget
maybeResult

#if defined(ENABLE_OVERLOADING)
data WidgetPaintableGetWidgetMethodInfo
instance (signature ~ (m (Maybe Gtk.Widget.Widget)), MonadIO m, IsWidgetPaintable a) => O.MethodInfo WidgetPaintableGetWidgetMethodInfo a signature where
    overloadedMethod = widgetPaintableGetWidget

#endif

-- method WidgetPaintable::set_widget
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "self"
--           , argType =
--               TInterface Name { namespace = "Gtk" , name = "WidgetPaintable" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GtkWidgetPaintable"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "widget"
--           , argType = TInterface Name { namespace = "Gtk" , name = "Widget" }
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the widget to observe or %NULL"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gtk_widget_paintable_set_widget" gtk_widget_paintable_set_widget :: 
    Ptr WidgetPaintable ->                  -- self : TInterface (Name {namespace = "Gtk", name = "WidgetPaintable"})
    Ptr Gtk.Widget.Widget ->                -- widget : TInterface (Name {namespace = "Gtk", name = "Widget"})
    IO ()

-- | Sets the widget that should be observed.
widgetPaintableSetWidget ::
    (B.CallStack.HasCallStack, MonadIO m, IsWidgetPaintable a, Gtk.Widget.IsWidget b) =>
    a
    -- ^ /@self@/: a t'GI.Gtk.Objects.WidgetPaintable.WidgetPaintable'
    -> Maybe (b)
    -- ^ /@widget@/: the widget to observe or 'P.Nothing'
    -> m ()
widgetPaintableSetWidget :: a -> Maybe b -> m ()
widgetPaintableSetWidget self :: a
self widget :: Maybe b
widget = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr WidgetPaintable
self' <- a -> IO (Ptr WidgetPaintable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
self
    Ptr Widget
maybeWidget <- case Maybe b
widget of
        Nothing -> Ptr Widget -> IO (Ptr Widget)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Widget
forall a. Ptr a
nullPtr
        Just jWidget :: b
jWidget -> do
            Ptr Widget
jWidget' <- b -> IO (Ptr Widget)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
jWidget
            Ptr Widget -> IO (Ptr Widget)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Widget
jWidget'
    Ptr WidgetPaintable -> Ptr Widget -> IO ()
gtk_widget_paintable_set_widget Ptr WidgetPaintable
self' Ptr Widget
maybeWidget
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
self
    Maybe b -> (b -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe b
widget b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if defined(ENABLE_OVERLOADING)
data WidgetPaintableSetWidgetMethodInfo
instance (signature ~ (Maybe (b) -> m ()), MonadIO m, IsWidgetPaintable a, Gtk.Widget.IsWidget b) => O.MethodInfo WidgetPaintableSetWidgetMethodInfo a signature where
    overloadedMethod = widgetPaintableSetWidget

#endif