{- |
Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License    : LGPL-2.1
Maintainer : Iñaki García Etxebarria (garetxe@gmail.com)

The 'GI.Gtk.Objects.Clipboard.Clipboard' object represents a clipboard of data shared
between different processes or between different widgets in
the same process. Each clipboard is identified by a name encoded as a
'GI.Gdk.Structs.Atom.Atom'. (Conversion to and from strings can be done with
'GI.Gdk.Functions.atomIntern' and 'GI.Gdk.Structs.Atom.atomName'.) The default clipboard
corresponds to the “CLIPBOARD” atom; another commonly used clipboard
is the “PRIMARY” clipboard, which, in X, traditionally contains
the currently selected text.

To support having a number of different formats on the clipboard
at the same time, the clipboard mechanism allows providing
callbacks instead of the actual data.  When you set the contents
of the clipboard, you can either supply the data directly (via
functions like 'GI.Gtk.Objects.Clipboard.clipboardSetText'), or you can supply a
callback to be called at a later time when the data is needed (via
@/gtk_clipboard_set_with_data()/@ or @/gtk_clipboard_set_with_owner()/@.)
Providing a callback also avoids having to make copies of the data
when it is not needed.

@/gtk_clipboard_set_with_data()/@ and @/gtk_clipboard_set_with_owner()/@
are quite similar; the choice between the two depends mostly on
which is more convenient in a particular situation.
The former is most useful when you want to have a blob of data
with callbacks to convert it into the various data types that you
advertise. When the /@clearFunc@/ you provided is called, you
simply free the data blob. The latter is more useful when the
contents of clipboard reflect the internal state of a 'GI.GObject.Objects.Object.Object'
(As an example, for the PRIMARY clipboard, when an entry widget
provides the clipboard’s contents the contents are simply the
text within the selected region.) If the contents change, the
entry widget can call @/gtk_clipboard_set_with_owner()/@ to update
the timestamp for clipboard ownership, without having to worry
about /@clearFunc@/ being called.

Requesting the data from the clipboard is essentially
asynchronous. If the contents of the clipboard are provided within
the same process, then a direct function call will be made to
retrieve the data, but if they are provided by another process,
then the data needs to be retrieved from the other process, which
may take some time. To avoid blocking the user interface, the call
to request the selection, 'GI.Gtk.Objects.Clipboard.clipboardRequestContents' takes a
callback that will be called when the contents are received (or
when the request fails.) If you don’t want to deal with providing
a separate callback, you can also use 'GI.Gtk.Objects.Clipboard.clipboardWaitForContents'.
What this does is run the GLib main loop recursively waiting for
the contents. This can simplify the code flow, but you still have
to be aware that other callbacks in your program can be called
while this recursive mainloop is running.

Along with the functions to get the clipboard contents as an
arbitrary data chunk, there are also functions to retrieve
it as text, 'GI.Gtk.Objects.Clipboard.clipboardRequestText' and
'GI.Gtk.Objects.Clipboard.clipboardWaitForText'. These functions take care of
determining which formats are advertised by the clipboard
provider, asking for the clipboard in the best available format
and converting the results into the UTF-8 encoding. (The standard
form for representing strings in GTK+.)
-}

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

module GI.Gtk.Objects.Clipboard
    (
#if ENABLE_OVERLOADING
    ClipboardWaitForRichTextMethodInfo      ,
#endif

-- * Exported types
    Clipboard(..)                           ,
    IsClipboard                             ,
    toClipboard                             ,
    noClipboard                             ,


 -- * Methods
-- ** clear #method:clear#

#if ENABLE_OVERLOADING
    ClipboardClearMethodInfo                ,
#endif
    clipboardClear                          ,


-- ** get #method:get#

    clipboardGet                            ,


-- ** getDefault #method:getDefault#

    clipboardGetDefault                     ,


-- ** getDisplay #method:getDisplay#

#if ENABLE_OVERLOADING
    ClipboardGetDisplayMethodInfo           ,
#endif
    clipboardGetDisplay                     ,


-- ** getForDisplay #method:getForDisplay#

    clipboardGetForDisplay                  ,


-- ** getOwner #method:getOwner#

#if ENABLE_OVERLOADING
    ClipboardGetOwnerMethodInfo             ,
#endif
    clipboardGetOwner                       ,


-- ** requestContents #method:requestContents#

#if ENABLE_OVERLOADING
    ClipboardRequestContentsMethodInfo      ,
#endif
    clipboardRequestContents                ,


-- ** requestImage #method:requestImage#

#if ENABLE_OVERLOADING
    ClipboardRequestImageMethodInfo         ,
#endif
    clipboardRequestImage                   ,


-- ** requestRichText #method:requestRichText#

#if ENABLE_OVERLOADING
    ClipboardRequestRichTextMethodInfo      ,
#endif
    clipboardRequestRichText                ,


-- ** requestTargets #method:requestTargets#

#if ENABLE_OVERLOADING
    ClipboardRequestTargetsMethodInfo       ,
#endif
    clipboardRequestTargets                 ,


-- ** requestText #method:requestText#

#if ENABLE_OVERLOADING
    ClipboardRequestTextMethodInfo          ,
#endif
    clipboardRequestText                    ,


-- ** requestUris #method:requestUris#

#if ENABLE_OVERLOADING
    ClipboardRequestUrisMethodInfo          ,
#endif
    clipboardRequestUris                    ,


-- ** setCanStore #method:setCanStore#

#if ENABLE_OVERLOADING
    ClipboardSetCanStoreMethodInfo          ,
#endif
    clipboardSetCanStore                    ,


-- ** setImage #method:setImage#

#if ENABLE_OVERLOADING
    ClipboardSetImageMethodInfo             ,
#endif
    clipboardSetImage                       ,


-- ** setText #method:setText#

#if ENABLE_OVERLOADING
    ClipboardSetTextMethodInfo              ,
#endif
    clipboardSetText                        ,


-- ** store #method:store#

#if ENABLE_OVERLOADING
    ClipboardStoreMethodInfo                ,
#endif
    clipboardStore                          ,


-- ** waitForContents #method:waitForContents#

#if ENABLE_OVERLOADING
    ClipboardWaitForContentsMethodInfo      ,
#endif
    clipboardWaitForContents                ,


-- ** waitForImage #method:waitForImage#

#if ENABLE_OVERLOADING
    ClipboardWaitForImageMethodInfo         ,
#endif
    clipboardWaitForImage                   ,


-- ** waitForTargets #method:waitForTargets#

#if ENABLE_OVERLOADING
    ClipboardWaitForTargetsMethodInfo       ,
#endif
    clipboardWaitForTargets                 ,


-- ** waitForText #method:waitForText#

#if ENABLE_OVERLOADING
    ClipboardWaitForTextMethodInfo          ,
#endif
    clipboardWaitForText                    ,


-- ** waitForUris #method:waitForUris#

#if ENABLE_OVERLOADING
    ClipboardWaitForUrisMethodInfo          ,
#endif
    clipboardWaitForUris                    ,


-- ** waitIsImageAvailable #method:waitIsImageAvailable#

#if ENABLE_OVERLOADING
    ClipboardWaitIsImageAvailableMethodInfo ,
#endif
    clipboardWaitIsImageAvailable           ,


-- ** waitIsRichTextAvailable #method:waitIsRichTextAvailable#

#if ENABLE_OVERLOADING
    ClipboardWaitIsRichTextAvailableMethodInfo,
#endif
    clipboardWaitIsRichTextAvailable        ,


-- ** waitIsTargetAvailable #method:waitIsTargetAvailable#

#if ENABLE_OVERLOADING
    ClipboardWaitIsTargetAvailableMethodInfo,
#endif
    clipboardWaitIsTargetAvailable          ,


-- ** waitIsTextAvailable #method:waitIsTextAvailable#

#if ENABLE_OVERLOADING
    ClipboardWaitIsTextAvailableMethodInfo  ,
#endif
    clipboardWaitIsTextAvailable            ,


-- ** waitIsUrisAvailable #method:waitIsUrisAvailable#

#if ENABLE_OVERLOADING
    ClipboardWaitIsUrisAvailableMethodInfo  ,
#endif
    clipboardWaitIsUrisAvailable            ,




 -- * Signals
-- ** ownerChange #signal:ownerChange#

    C_ClipboardOwnerChangeCallback          ,
    ClipboardOwnerChangeCallback            ,
#if ENABLE_OVERLOADING
    ClipboardOwnerChangeSignalInfo          ,
#endif
    afterClipboardOwnerChange               ,
    genClosure_ClipboardOwnerChange         ,
    mk_ClipboardOwnerChangeCallback         ,
    noClipboardOwnerChangeCallback          ,
    onClipboardOwnerChange                  ,
    wrap_ClipboardOwnerChangeCallback       ,




    ) 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.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.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP

import qualified GI.GObject.Objects.Object as GObject.Object
import qualified GI.Gdk.Objects.Display as Gdk.Display
import qualified GI.Gdk.Structs.Atom as Gdk.Atom
import qualified GI.Gdk.Structs.EventOwnerChange as Gdk.EventOwnerChange
import qualified GI.GdkPixbuf.Objects.Pixbuf as GdkPixbuf.Pixbuf
import qualified GI.Gtk.Callbacks as Gtk.Callbacks
import {-# SOURCE #-} qualified GI.Gtk.Objects.TextBuffer as Gtk.TextBuffer
import {-# SOURCE #-} qualified GI.Gtk.Structs.SelectionData as Gtk.SelectionData
import {-# SOURCE #-} qualified GI.Gtk.Structs.TargetEntry as Gtk.TargetEntry

-- | Memory-managed wrapper type.
newtype Clipboard = Clipboard (ManagedPtr Clipboard)
foreign import ccall "gtk_clipboard_get_type"
    c_gtk_clipboard_get_type :: IO GType

instance GObject Clipboard where
    gobjectType _ = c_gtk_clipboard_get_type


-- | Type class for types which can be safely cast to `Clipboard`, for instance with `toClipboard`.
class GObject o => IsClipboard o
#if MIN_VERSION_base(4,9,0)
instance {-# OVERLAPPABLE #-} (GObject a, O.UnknownAncestorError Clipboard a) =>
    IsClipboard a
#endif
instance IsClipboard Clipboard
instance GObject.Object.IsObject Clipboard

-- | Cast to `Clipboard`, for types for which this is known to be safe. For general casts, use `Data.GI.Base.ManagedPtr.castTo`.
toClipboard :: (MonadIO m, IsClipboard o) => o -> m Clipboard
toClipboard = liftIO . unsafeCastTo Clipboard

-- | A convenience alias for `Nothing` :: `Maybe` `Clipboard`.
noClipboard :: Maybe Clipboard
noClipboard = Nothing

#if ENABLE_OVERLOADING
type family ResolveClipboardMethod (t :: Symbol) (o :: *) :: * where
    ResolveClipboardMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveClipboardMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveClipboardMethod "clear" o = ClipboardClearMethodInfo
    ResolveClipboardMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveClipboardMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveClipboardMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
    ResolveClipboardMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveClipboardMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveClipboardMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveClipboardMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveClipboardMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveClipboardMethod "requestContents" o = ClipboardRequestContentsMethodInfo
    ResolveClipboardMethod "requestImage" o = ClipboardRequestImageMethodInfo
    ResolveClipboardMethod "requestRichText" o = ClipboardRequestRichTextMethodInfo
    ResolveClipboardMethod "requestTargets" o = ClipboardRequestTargetsMethodInfo
    ResolveClipboardMethod "requestText" o = ClipboardRequestTextMethodInfo
    ResolveClipboardMethod "requestUris" o = ClipboardRequestUrisMethodInfo
    ResolveClipboardMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveClipboardMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveClipboardMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveClipboardMethod "store" o = ClipboardStoreMethodInfo
    ResolveClipboardMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveClipboardMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveClipboardMethod "waitForContents" o = ClipboardWaitForContentsMethodInfo
    ResolveClipboardMethod "waitForImage" o = ClipboardWaitForImageMethodInfo
    ResolveClipboardMethod "waitForRichText" o = ClipboardWaitForRichTextMethodInfo
    ResolveClipboardMethod "waitForTargets" o = ClipboardWaitForTargetsMethodInfo
    ResolveClipboardMethod "waitForText" o = ClipboardWaitForTextMethodInfo
    ResolveClipboardMethod "waitForUris" o = ClipboardWaitForUrisMethodInfo
    ResolveClipboardMethod "waitIsImageAvailable" o = ClipboardWaitIsImageAvailableMethodInfo
    ResolveClipboardMethod "waitIsRichTextAvailable" o = ClipboardWaitIsRichTextAvailableMethodInfo
    ResolveClipboardMethod "waitIsTargetAvailable" o = ClipboardWaitIsTargetAvailableMethodInfo
    ResolveClipboardMethod "waitIsTextAvailable" o = ClipboardWaitIsTextAvailableMethodInfo
    ResolveClipboardMethod "waitIsUrisAvailable" o = ClipboardWaitIsUrisAvailableMethodInfo
    ResolveClipboardMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveClipboardMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveClipboardMethod "getDisplay" o = ClipboardGetDisplayMethodInfo
    ResolveClipboardMethod "getOwner" o = ClipboardGetOwnerMethodInfo
    ResolveClipboardMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveClipboardMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveClipboardMethod "setCanStore" o = ClipboardSetCanStoreMethodInfo
    ResolveClipboardMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveClipboardMethod "setImage" o = ClipboardSetImageMethodInfo
    ResolveClipboardMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveClipboardMethod "setText" o = ClipboardSetTextMethodInfo
    ResolveClipboardMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveClipboardMethod t Clipboard, O.MethodInfo info Clipboard p) => O.IsLabelProxy t (Clipboard -> p) where
    fromLabelProxy _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)

#if MIN_VERSION_base(4,9,0)
instance (info ~ ResolveClipboardMethod t Clipboard, O.MethodInfo info Clipboard p) => O.IsLabel t (Clipboard -> p) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#else
    fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#endif
#endif

#endif

-- signal Clipboard::owner-change
{- |
The ::owner-change signal is emitted when GTK+ receives an
event that indicates that the ownership of the selection
associated with /@clipboard@/ has changed.

/Since: 2.6/
-}
type ClipboardOwnerChangeCallback =
    Gdk.EventOwnerChange.EventOwnerChange
    {- ^ /@event@/: the /@gdkEventOwnerChange@/ event -}
    -> IO ()

-- | A convenience synonym for @`Nothing` :: `Maybe` `ClipboardOwnerChangeCallback`@.
noClipboardOwnerChangeCallback :: Maybe ClipboardOwnerChangeCallback
noClipboardOwnerChangeCallback = Nothing

-- | Type for the callback on the (unwrapped) C side.
type C_ClipboardOwnerChangeCallback =
    Ptr () ->                               -- object
    Ptr Gdk.EventOwnerChange.EventOwnerChange ->
    Ptr () ->                               -- user_data
    IO ()

-- | Generate a function pointer callable from C code, from a `C_ClipboardOwnerChangeCallback`.
foreign import ccall "wrapper"
    mk_ClipboardOwnerChangeCallback :: C_ClipboardOwnerChangeCallback -> IO (FunPtr C_ClipboardOwnerChangeCallback)

-- | Wrap the callback into a `Closure`.
genClosure_ClipboardOwnerChange :: ClipboardOwnerChangeCallback -> IO Closure
genClosure_ClipboardOwnerChange cb = do
    let cb' = wrap_ClipboardOwnerChangeCallback cb
    mk_ClipboardOwnerChangeCallback cb' >>= newCClosure


-- | Wrap a `ClipboardOwnerChangeCallback` into a `C_ClipboardOwnerChangeCallback`.
wrap_ClipboardOwnerChangeCallback ::
    ClipboardOwnerChangeCallback ->
    C_ClipboardOwnerChangeCallback
wrap_ClipboardOwnerChangeCallback _cb _ event _ = do
    event' <- (newPtr Gdk.EventOwnerChange.EventOwnerChange) event
    _cb  event'


{- |
Connect a signal handler for the “@owner-change@” signal, to be run before the default handler.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Signals.on' clipboard #ownerChange callback
@
-}
onClipboardOwnerChange :: (IsClipboard a, MonadIO m) => a -> ClipboardOwnerChangeCallback -> m SignalHandlerId
onClipboardOwnerChange obj cb = liftIO $ do
    let cb' = wrap_ClipboardOwnerChangeCallback cb
    cb'' <- mk_ClipboardOwnerChangeCallback cb'
    connectSignalFunPtr obj "owner-change" cb'' SignalConnectBefore

{- |
Connect a signal handler for the “@owner-change@” signal, to be run after the default handler.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Signals.after' clipboard #ownerChange callback
@
-}
afterClipboardOwnerChange :: (IsClipboard a, MonadIO m) => a -> ClipboardOwnerChangeCallback -> m SignalHandlerId
afterClipboardOwnerChange obj cb = liftIO $ do
    let cb' = wrap_ClipboardOwnerChangeCallback cb
    cb'' <- mk_ClipboardOwnerChangeCallback cb'
    connectSignalFunPtr obj "owner-change" cb'' SignalConnectAfter


#if ENABLE_OVERLOADING
instance O.HasAttributeList Clipboard
type instance O.AttributeList Clipboard = ClipboardAttributeList
type ClipboardAttributeList = ('[ ] :: [(Symbol, *)])
#endif

#if ENABLE_OVERLOADING
#endif

#if ENABLE_OVERLOADING
data ClipboardOwnerChangeSignalInfo
instance SignalInfo ClipboardOwnerChangeSignalInfo where
    type HaskellCallbackType ClipboardOwnerChangeSignalInfo = ClipboardOwnerChangeCallback
    connectSignal _ obj cb connectMode = do
        let cb' = wrap_ClipboardOwnerChangeCallback cb
        cb'' <- mk_ClipboardOwnerChangeCallback cb'
        connectSignalFunPtr obj "owner-change" cb'' connectMode

type instance O.SignalList Clipboard = ClipboardSignalList
type ClipboardSignalList = ('[ '("notify", GObject.Object.ObjectNotifySignalInfo), '("ownerChange", ClipboardOwnerChangeSignalInfo)] :: [(Symbol, *)])

#endif

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

foreign import ccall "gtk_clipboard_clear" gtk_clipboard_clear ::
    Ptr Clipboard ->                        -- clipboard : TInterface (Name {namespace = "Gtk", name = "Clipboard"})
    IO ()

{- |
Clears the contents of the clipboard. Generally this should only
be called between the time you call @/gtk_clipboard_set_with_owner()/@
or @/gtk_clipboard_set_with_data()/@,
and when the /@clearFunc@/ you supplied is called. Otherwise, the
clipboard may be owned by someone else.
-}
clipboardClear ::
    (B.CallStack.HasCallStack, MonadIO m, IsClipboard a) =>
    a
    {- ^ /@clipboard@/: a 'GI.Gtk.Objects.Clipboard.Clipboard' -}
    -> m ()
clipboardClear clipboard = liftIO $ do
    clipboard' <- unsafeManagedPtrCastPtr clipboard
    gtk_clipboard_clear clipboard'
    touchManagedPtr clipboard
    return ()

#if ENABLE_OVERLOADING
data ClipboardClearMethodInfo
instance (signature ~ (m ()), MonadIO m, IsClipboard a) => O.MethodInfo ClipboardClearMethodInfo a signature where
    overloadedMethod _ = clipboardClear

#endif

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

foreign import ccall "gtk_clipboard_get_display" gtk_clipboard_get_display ::
    Ptr Clipboard ->                        -- clipboard : TInterface (Name {namespace = "Gtk", name = "Clipboard"})
    IO (Ptr Gdk.Display.Display)

{- |
Gets the 'GI.Gdk.Objects.Display.Display' associated with /@clipboard@/

/Since: 2.2/
-}
clipboardGetDisplay ::
    (B.CallStack.HasCallStack, MonadIO m, IsClipboard a) =>
    a
    {- ^ /@clipboard@/: a 'GI.Gtk.Objects.Clipboard.Clipboard' -}
    -> m Gdk.Display.Display
    {- ^ __Returns:__ the 'GI.Gdk.Objects.Display.Display' associated with /@clipboard@/ -}
clipboardGetDisplay clipboard = liftIO $ do
    clipboard' <- unsafeManagedPtrCastPtr clipboard
    result <- gtk_clipboard_get_display clipboard'
    checkUnexpectedReturnNULL "clipboardGetDisplay" result
    result' <- (newObject Gdk.Display.Display) result
    touchManagedPtr clipboard
    return result'

#if ENABLE_OVERLOADING
data ClipboardGetDisplayMethodInfo
instance (signature ~ (m Gdk.Display.Display), MonadIO m, IsClipboard a) => O.MethodInfo ClipboardGetDisplayMethodInfo a signature where
    overloadedMethod _ = clipboardGetDisplay

#endif

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

foreign import ccall "gtk_clipboard_get_owner" gtk_clipboard_get_owner ::
    Ptr Clipboard ->                        -- clipboard : TInterface (Name {namespace = "Gtk", name = "Clipboard"})
    IO (Ptr GObject.Object.Object)

{- |
If the clipboard contents callbacks were set with
@/gtk_clipboard_set_with_owner()/@, and the @/gtk_clipboard_set_with_data()/@ or
'GI.Gtk.Objects.Clipboard.clipboardClear' has not subsequently called, returns the owner set
by @/gtk_clipboard_set_with_owner()/@.
-}
clipboardGetOwner ::
    (B.CallStack.HasCallStack, MonadIO m, IsClipboard a) =>
    a
    {- ^ /@clipboard@/: a 'GI.Gtk.Objects.Clipboard.Clipboard' -}
    -> m (Maybe GObject.Object.Object)
    {- ^ __Returns:__ the owner of the clipboard, if any;
    otherwise 'Nothing'. -}
clipboardGetOwner clipboard = liftIO $ do
    clipboard' <- unsafeManagedPtrCastPtr clipboard
    result <- gtk_clipboard_get_owner clipboard'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- (newObject GObject.Object.Object) result'
        return result''
    touchManagedPtr clipboard
    return maybeResult

#if ENABLE_OVERLOADING
data ClipboardGetOwnerMethodInfo
instance (signature ~ (m (Maybe GObject.Object.Object)), MonadIO m, IsClipboard a) => O.MethodInfo ClipboardGetOwnerMethodInfo a signature where
    overloadedMethod _ = clipboardGetOwner

#endif

-- method Clipboard::request_contents
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "clipboard", argType = TInterface (Name {namespace = "Gtk", name = "Clipboard"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkClipboard", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "target", argType = TInterface (Name {namespace = "Gdk", name = "Atom"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "an atom representing the form into which the clipboard\n    owner should convert the selection.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "callback", argType = TInterface (Name {namespace = "Gtk", name = "ClipboardReceivedFunc"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A function to call when the results are received\n    (or the retrieval fails). If the retrieval fails the length field of\n    @selection_data will be negative.", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = 3, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user data to pass to @callback", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gtk_clipboard_request_contents" gtk_clipboard_request_contents ::
    Ptr Clipboard ->                        -- clipboard : TInterface (Name {namespace = "Gtk", name = "Clipboard"})
    Ptr Gdk.Atom.Atom ->                    -- target : TInterface (Name {namespace = "Gdk", name = "Atom"})
    FunPtr Gtk.Callbacks.C_ClipboardReceivedFunc -> -- callback : TInterface (Name {namespace = "Gtk", name = "ClipboardReceivedFunc"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    IO ()

{- |
Requests the contents of clipboard as the given target.
When the results of the result are later received the supplied callback
will be called.
-}
clipboardRequestContents ::
    (B.CallStack.HasCallStack, MonadIO m, IsClipboard a) =>
    a
    {- ^ /@clipboard@/: a 'GI.Gtk.Objects.Clipboard.Clipboard' -}
    -> Gdk.Atom.Atom
    {- ^ /@target@/: an atom representing the form into which the clipboard
    owner should convert the selection. -}
    -> Gtk.Callbacks.ClipboardReceivedFunc
    {- ^ /@callback@/: A function to call when the results are received
    (or the retrieval fails). If the retrieval fails the length field of
    /@selectionData@/ will be negative. -}
    -> m ()
clipboardRequestContents clipboard target callback = liftIO $ do
    clipboard' <- unsafeManagedPtrCastPtr clipboard
    target' <- unsafeManagedPtrGetPtr target
    ptrcallback <- callocMem :: IO (Ptr (FunPtr Gtk.Callbacks.C_ClipboardReceivedFunc))
    callback' <- Gtk.Callbacks.mk_ClipboardReceivedFunc (Gtk.Callbacks.wrap_ClipboardReceivedFunc (Just ptrcallback) (Gtk.Callbacks.drop_closures_ClipboardReceivedFunc callback))
    poke ptrcallback callback'
    let userData = nullPtr
    gtk_clipboard_request_contents clipboard' target' callback' userData
    touchManagedPtr clipboard
    touchManagedPtr target
    return ()

#if ENABLE_OVERLOADING
data ClipboardRequestContentsMethodInfo
instance (signature ~ (Gdk.Atom.Atom -> Gtk.Callbacks.ClipboardReceivedFunc -> m ()), MonadIO m, IsClipboard a) => O.MethodInfo ClipboardRequestContentsMethodInfo a signature where
    overloadedMethod _ = clipboardRequestContents

#endif

-- method Clipboard::request_image
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "clipboard", argType = TInterface (Name {namespace = "Gtk", name = "Clipboard"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkClipboard", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "callback", argType = TInterface (Name {namespace = "Gtk", name = "ClipboardImageReceivedFunc"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a function to call when the image is received,\n    or the retrieval fails. (It will always be called one way or the other.)", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = 2, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user data to pass to @callback.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gtk_clipboard_request_image" gtk_clipboard_request_image ::
    Ptr Clipboard ->                        -- clipboard : TInterface (Name {namespace = "Gtk", name = "Clipboard"})
    FunPtr Gtk.Callbacks.C_ClipboardImageReceivedFunc -> -- callback : TInterface (Name {namespace = "Gtk", name = "ClipboardImageReceivedFunc"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    IO ()

{- |
Requests the contents of the clipboard as image. When the image is
later received, it will be converted to a 'GI.GdkPixbuf.Objects.Pixbuf.Pixbuf', and
/@callback@/ will be called.

The /@pixbuf@/ parameter to /@callback@/ will contain the resulting
'GI.GdkPixbuf.Objects.Pixbuf.Pixbuf' if the request succeeded, or 'Nothing' if it failed. This
could happen for various reasons, in particular if the clipboard
was empty or if the contents of the clipboard could not be
converted into an image.

/Since: 2.6/
-}
clipboardRequestImage ::
    (B.CallStack.HasCallStack, MonadIO m, IsClipboard a) =>
    a
    {- ^ /@clipboard@/: a 'GI.Gtk.Objects.Clipboard.Clipboard' -}
    -> Gtk.Callbacks.ClipboardImageReceivedFunc
    {- ^ /@callback@/: a function to call when the image is received,
    or the retrieval fails. (It will always be called one way or the other.) -}
    -> m ()
clipboardRequestImage clipboard callback = liftIO $ do
    clipboard' <- unsafeManagedPtrCastPtr clipboard
    ptrcallback <- callocMem :: IO (Ptr (FunPtr Gtk.Callbacks.C_ClipboardImageReceivedFunc))
    callback' <- Gtk.Callbacks.mk_ClipboardImageReceivedFunc (Gtk.Callbacks.wrap_ClipboardImageReceivedFunc (Just ptrcallback) (Gtk.Callbacks.drop_closures_ClipboardImageReceivedFunc callback))
    poke ptrcallback callback'
    let userData = nullPtr
    gtk_clipboard_request_image clipboard' callback' userData
    touchManagedPtr clipboard
    return ()

#if ENABLE_OVERLOADING
data ClipboardRequestImageMethodInfo
instance (signature ~ (Gtk.Callbacks.ClipboardImageReceivedFunc -> m ()), MonadIO m, IsClipboard a) => O.MethodInfo ClipboardRequestImageMethodInfo a signature where
    overloadedMethod _ = clipboardRequestImage

#endif

-- method Clipboard::request_rich_text
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "clipboard", argType = TInterface (Name {namespace = "Gtk", name = "Clipboard"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkClipboard", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "buffer", argType = TInterface (Name {namespace = "Gtk", name = "TextBuffer"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkTextBuffer", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "callback", argType = TInterface (Name {namespace = "Gtk", name = "ClipboardRichTextReceivedFunc"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a function to call when the text is received,\n    or the retrieval fails. (It will always be called one way or the other.)", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = 3, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user data to pass to @callback.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gtk_clipboard_request_rich_text" gtk_clipboard_request_rich_text ::
    Ptr Clipboard ->                        -- clipboard : TInterface (Name {namespace = "Gtk", name = "Clipboard"})
    Ptr Gtk.TextBuffer.TextBuffer ->        -- buffer : TInterface (Name {namespace = "Gtk", name = "TextBuffer"})
    FunPtr Gtk.Callbacks.C_ClipboardRichTextReceivedFunc -> -- callback : TInterface (Name {namespace = "Gtk", name = "ClipboardRichTextReceivedFunc"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    IO ()

{- |
Requests the contents of the clipboard as rich text. When the rich
text is later received, /@callback@/ will be called.

The /@text@/ parameter to /@callback@/ will contain the resulting rich
text if the request succeeded, or 'Nothing' if it failed. The /@length@/
parameter will contain /@text@/’s length. This function can fail for
various reasons, in particular if the clipboard was empty or if the
contents of the clipboard could not be converted into rich text form.

/Since: 2.10/
-}
clipboardRequestRichText ::
    (B.CallStack.HasCallStack, MonadIO m, IsClipboard a, Gtk.TextBuffer.IsTextBuffer b) =>
    a
    {- ^ /@clipboard@/: a 'GI.Gtk.Objects.Clipboard.Clipboard' -}
    -> b
    {- ^ /@buffer@/: a 'GI.Gtk.Objects.TextBuffer.TextBuffer' -}
    -> Gtk.Callbacks.ClipboardRichTextReceivedFunc
    {- ^ /@callback@/: a function to call when the text is received,
    or the retrieval fails. (It will always be called one way or the other.) -}
    -> m ()
clipboardRequestRichText clipboard buffer callback = liftIO $ do
    clipboard' <- unsafeManagedPtrCastPtr clipboard
    buffer' <- unsafeManagedPtrCastPtr buffer
    ptrcallback <- callocMem :: IO (Ptr (FunPtr Gtk.Callbacks.C_ClipboardRichTextReceivedFunc))
    callback' <- Gtk.Callbacks.mk_ClipboardRichTextReceivedFunc (Gtk.Callbacks.wrap_ClipboardRichTextReceivedFunc (Just ptrcallback) (Gtk.Callbacks.drop_closures_ClipboardRichTextReceivedFunc callback))
    poke ptrcallback callback'
    let userData = nullPtr
    gtk_clipboard_request_rich_text clipboard' buffer' callback' userData
    touchManagedPtr clipboard
    touchManagedPtr buffer
    return ()

#if ENABLE_OVERLOADING
data ClipboardRequestRichTextMethodInfo
instance (signature ~ (b -> Gtk.Callbacks.ClipboardRichTextReceivedFunc -> m ()), MonadIO m, IsClipboard a, Gtk.TextBuffer.IsTextBuffer b) => O.MethodInfo ClipboardRequestRichTextMethodInfo a signature where
    overloadedMethod _ = clipboardRequestRichText

#endif

-- method Clipboard::request_targets
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "clipboard", argType = TInterface (Name {namespace = "Gtk", name = "Clipboard"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkClipboard", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "callback", argType = TInterface (Name {namespace = "Gtk", name = "ClipboardTargetsReceivedFunc"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a function to call when the targets are\n    received, or the retrieval fails. (It will always be called\n    one way or the other.)", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = 2, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user data to pass to @callback.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gtk_clipboard_request_targets" gtk_clipboard_request_targets ::
    Ptr Clipboard ->                        -- clipboard : TInterface (Name {namespace = "Gtk", name = "Clipboard"})
    FunPtr Gtk.Callbacks.C_ClipboardTargetsReceivedFunc -> -- callback : TInterface (Name {namespace = "Gtk", name = "ClipboardTargetsReceivedFunc"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    IO ()

{- |
Requests the contents of the clipboard as list of supported targets.
When the list is later received, /@callback@/ will be called.

The /@targets@/ parameter to /@callback@/ will contain the resulting targets if
the request succeeded, or 'Nothing' if it failed.

/Since: 2.4/
-}
clipboardRequestTargets ::
    (B.CallStack.HasCallStack, MonadIO m, IsClipboard a) =>
    a
    {- ^ /@clipboard@/: a 'GI.Gtk.Objects.Clipboard.Clipboard' -}
    -> Gtk.Callbacks.ClipboardTargetsReceivedFunc
    {- ^ /@callback@/: a function to call when the targets are
    received, or the retrieval fails. (It will always be called
    one way or the other.) -}
    -> m ()
clipboardRequestTargets clipboard callback = liftIO $ do
    clipboard' <- unsafeManagedPtrCastPtr clipboard
    ptrcallback <- callocMem :: IO (Ptr (FunPtr Gtk.Callbacks.C_ClipboardTargetsReceivedFunc))
    callback' <- Gtk.Callbacks.mk_ClipboardTargetsReceivedFunc (Gtk.Callbacks.wrap_ClipboardTargetsReceivedFunc (Just ptrcallback) (Gtk.Callbacks.drop_closures_ClipboardTargetsReceivedFunc callback))
    poke ptrcallback callback'
    let userData = nullPtr
    gtk_clipboard_request_targets clipboard' callback' userData
    touchManagedPtr clipboard
    return ()

#if ENABLE_OVERLOADING
data ClipboardRequestTargetsMethodInfo
instance (signature ~ (Gtk.Callbacks.ClipboardTargetsReceivedFunc -> m ()), MonadIO m, IsClipboard a) => O.MethodInfo ClipboardRequestTargetsMethodInfo a signature where
    overloadedMethod _ = clipboardRequestTargets

#endif

-- method Clipboard::request_text
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "clipboard", argType = TInterface (Name {namespace = "Gtk", name = "Clipboard"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkClipboard", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "callback", argType = TInterface (Name {namespace = "Gtk", name = "ClipboardTextReceivedFunc"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a function to call when the text is received,\n    or the retrieval fails. (It will always be called one way or the other.)", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = 2, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user data to pass to @callback.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gtk_clipboard_request_text" gtk_clipboard_request_text ::
    Ptr Clipboard ->                        -- clipboard : TInterface (Name {namespace = "Gtk", name = "Clipboard"})
    FunPtr Gtk.Callbacks.C_ClipboardTextReceivedFunc -> -- callback : TInterface (Name {namespace = "Gtk", name = "ClipboardTextReceivedFunc"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    IO ()

{- |
Requests the contents of the clipboard as text. When the text is
later received, it will be converted to UTF-8 if necessary, and
/@callback@/ will be called.

The /@text@/ parameter to /@callback@/ will contain the resulting text if
the request succeeded, or 'Nothing' if it failed. This could happen for
various reasons, in particular if the clipboard was empty or if the
contents of the clipboard could not be converted into text form.
-}
clipboardRequestText ::
    (B.CallStack.HasCallStack, MonadIO m, IsClipboard a) =>
    a
    {- ^ /@clipboard@/: a 'GI.Gtk.Objects.Clipboard.Clipboard' -}
    -> Gtk.Callbacks.ClipboardTextReceivedFunc
    {- ^ /@callback@/: a function to call when the text is received,
    or the retrieval fails. (It will always be called one way or the other.) -}
    -> m ()
clipboardRequestText clipboard callback = liftIO $ do
    clipboard' <- unsafeManagedPtrCastPtr clipboard
    ptrcallback <- callocMem :: IO (Ptr (FunPtr Gtk.Callbacks.C_ClipboardTextReceivedFunc))
    callback' <- Gtk.Callbacks.mk_ClipboardTextReceivedFunc (Gtk.Callbacks.wrap_ClipboardTextReceivedFunc (Just ptrcallback) (Gtk.Callbacks.drop_closures_ClipboardTextReceivedFunc callback))
    poke ptrcallback callback'
    let userData = nullPtr
    gtk_clipboard_request_text clipboard' callback' userData
    touchManagedPtr clipboard
    return ()

#if ENABLE_OVERLOADING
data ClipboardRequestTextMethodInfo
instance (signature ~ (Gtk.Callbacks.ClipboardTextReceivedFunc -> m ()), MonadIO m, IsClipboard a) => O.MethodInfo ClipboardRequestTextMethodInfo a signature where
    overloadedMethod _ = clipboardRequestText

#endif

-- method Clipboard::request_uris
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "clipboard", argType = TInterface (Name {namespace = "Gtk", name = "Clipboard"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkClipboard", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "callback", argType = TInterface (Name {namespace = "Gtk", name = "ClipboardURIReceivedFunc"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a function to call when the URIs are received,\n    or the retrieval fails. (It will always be called one way or the other.)", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = 2, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user data to pass to @callback.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gtk_clipboard_request_uris" gtk_clipboard_request_uris ::
    Ptr Clipboard ->                        -- clipboard : TInterface (Name {namespace = "Gtk", name = "Clipboard"})
    FunPtr Gtk.Callbacks.C_ClipboardURIReceivedFunc -> -- callback : TInterface (Name {namespace = "Gtk", name = "ClipboardURIReceivedFunc"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    IO ()

{- |
Requests the contents of the clipboard as URIs. When the URIs are
later received /@callback@/ will be called.

The /@uris@/ parameter to /@callback@/ will contain the resulting array of
URIs if the request succeeded, or 'Nothing' if it failed. This could happen
for various reasons, in particular if the clipboard was empty or if the
contents of the clipboard could not be converted into URI form.

/Since: 2.14/
-}
clipboardRequestUris ::
    (B.CallStack.HasCallStack, MonadIO m, IsClipboard a) =>
    a
    {- ^ /@clipboard@/: a 'GI.Gtk.Objects.Clipboard.Clipboard' -}
    -> Gtk.Callbacks.ClipboardURIReceivedFunc
    {- ^ /@callback@/: a function to call when the URIs are received,
    or the retrieval fails. (It will always be called one way or the other.) -}
    -> m ()
clipboardRequestUris clipboard callback = liftIO $ do
    clipboard' <- unsafeManagedPtrCastPtr clipboard
    ptrcallback <- callocMem :: IO (Ptr (FunPtr Gtk.Callbacks.C_ClipboardURIReceivedFunc))
    callback' <- Gtk.Callbacks.mk_ClipboardURIReceivedFunc (Gtk.Callbacks.wrap_ClipboardURIReceivedFunc (Just ptrcallback) (Gtk.Callbacks.drop_closures_ClipboardURIReceivedFunc callback))
    poke ptrcallback callback'
    let userData = nullPtr
    gtk_clipboard_request_uris clipboard' callback' userData
    touchManagedPtr clipboard
    return ()

#if ENABLE_OVERLOADING
data ClipboardRequestUrisMethodInfo
instance (signature ~ (Gtk.Callbacks.ClipboardURIReceivedFunc -> m ()), MonadIO m, IsClipboard a) => O.MethodInfo ClipboardRequestUrisMethodInfo a signature where
    overloadedMethod _ = clipboardRequestUris

#endif

-- method Clipboard::set_can_store
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "clipboard", argType = TInterface (Name {namespace = "Gtk", name = "Clipboard"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkClipboard", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "targets", argType = TCArray False (-1) 2 (TInterface (Name {namespace = "Gtk", name = "TargetEntry"})), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "array containing\n          information about which forms should be stored or %NULL\n          to indicate that all forms should be stored.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "n_targets", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "number of elements in @targets", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : [Arg {argCName = "n_targets", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "number of elements in @targets", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gtk_clipboard_set_can_store" gtk_clipboard_set_can_store ::
    Ptr Clipboard ->                        -- clipboard : TInterface (Name {namespace = "Gtk", name = "Clipboard"})
    Ptr Gtk.TargetEntry.TargetEntry ->      -- targets : TCArray False (-1) 2 (TInterface (Name {namespace = "Gtk", name = "TargetEntry"}))
    Int32 ->                                -- n_targets : TBasicType TInt
    IO ()

{- |
Hints that the clipboard data should be stored somewhere when the
application exits or when gtk_clipboard_store () is called.

This value is reset when the clipboard owner changes.
Where the clipboard data is stored is platform dependent,
see gdk_display_store_clipboard () for more information.

/Since: 2.6/
-}
clipboardSetCanStore ::
    (B.CallStack.HasCallStack, MonadIO m, IsClipboard a) =>
    a
    {- ^ /@clipboard@/: a 'GI.Gtk.Objects.Clipboard.Clipboard' -}
    -> Maybe ([Gtk.TargetEntry.TargetEntry])
    {- ^ /@targets@/: array containing
          information about which forms should be stored or 'Nothing'
          to indicate that all forms should be stored. -}
    -> m ()
clipboardSetCanStore clipboard targets = liftIO $ do
    let nTargets = case targets of
            Nothing -> 0
            Just jTargets -> fromIntegral $ length jTargets
    clipboard' <- unsafeManagedPtrCastPtr clipboard
    maybeTargets <- case targets of
        Nothing -> return nullPtr
        Just jTargets -> do
            jTargets' <- mapM unsafeManagedPtrGetPtr jTargets
            jTargets'' <- packBlockArray 16 jTargets'
            return jTargets''
    gtk_clipboard_set_can_store clipboard' maybeTargets nTargets
    touchManagedPtr clipboard
    whenJust targets (mapM_ touchManagedPtr)
    freeMem maybeTargets
    return ()

#if ENABLE_OVERLOADING
data ClipboardSetCanStoreMethodInfo
instance (signature ~ (Maybe ([Gtk.TargetEntry.TargetEntry]) -> m ()), MonadIO m, IsClipboard a) => O.MethodInfo ClipboardSetCanStoreMethodInfo a signature where
    overloadedMethod _ = clipboardSetCanStore

#endif

-- method Clipboard::set_image
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "clipboard", argType = TInterface (Name {namespace = "Gtk", name = "Clipboard"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkClipboard object", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "pixbuf", argType = TInterface (Name {namespace = "GdkPixbuf", name = "Pixbuf"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GdkPixbuf", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gtk_clipboard_set_image" gtk_clipboard_set_image ::
    Ptr Clipboard ->                        -- clipboard : TInterface (Name {namespace = "Gtk", name = "Clipboard"})
    Ptr GdkPixbuf.Pixbuf.Pixbuf ->          -- pixbuf : TInterface (Name {namespace = "GdkPixbuf", name = "Pixbuf"})
    IO ()

{- |
Sets the contents of the clipboard to the given 'GI.GdkPixbuf.Objects.Pixbuf.Pixbuf'.
GTK+ will take responsibility for responding for requests
for the image, and for converting the image into the
requested format.

/Since: 2.6/
-}
clipboardSetImage ::
    (B.CallStack.HasCallStack, MonadIO m, IsClipboard a, GdkPixbuf.Pixbuf.IsPixbuf b) =>
    a
    {- ^ /@clipboard@/: a 'GI.Gtk.Objects.Clipboard.Clipboard' object -}
    -> b
    {- ^ /@pixbuf@/: a 'GI.GdkPixbuf.Objects.Pixbuf.Pixbuf' -}
    -> m ()
clipboardSetImage clipboard pixbuf = liftIO $ do
    clipboard' <- unsafeManagedPtrCastPtr clipboard
    pixbuf' <- unsafeManagedPtrCastPtr pixbuf
    gtk_clipboard_set_image clipboard' pixbuf'
    touchManagedPtr clipboard
    touchManagedPtr pixbuf
    return ()

#if ENABLE_OVERLOADING
data ClipboardSetImageMethodInfo
instance (signature ~ (b -> m ()), MonadIO m, IsClipboard a, GdkPixbuf.Pixbuf.IsPixbuf b) => O.MethodInfo ClipboardSetImageMethodInfo a signature where
    overloadedMethod _ = clipboardSetImage

#endif

-- method Clipboard::set_text
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "clipboard", argType = TInterface (Name {namespace = "Gtk", name = "Clipboard"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkClipboard object", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "text", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a UTF-8 string.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "len", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "length of @text, in bytes, or -1, in which case\n            the length will be determined with strlen().", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gtk_clipboard_set_text" gtk_clipboard_set_text ::
    Ptr Clipboard ->                        -- clipboard : TInterface (Name {namespace = "Gtk", name = "Clipboard"})
    CString ->                              -- text : TBasicType TUTF8
    Int32 ->                                -- len : TBasicType TInt
    IO ()

{- |
Sets the contents of the clipboard to the given UTF-8 string. GTK+ will
make a copy of the text and take responsibility for responding
for requests for the text, and for converting the text into
the requested format.
-}
clipboardSetText ::
    (B.CallStack.HasCallStack, MonadIO m, IsClipboard a) =>
    a
    {- ^ /@clipboard@/: a 'GI.Gtk.Objects.Clipboard.Clipboard' object -}
    -> T.Text
    {- ^ /@text@/: a UTF-8 string. -}
    -> Int32
    {- ^ /@len@/: length of /@text@/, in bytes, or -1, in which case
            the length will be determined with @/strlen()/@. -}
    -> m ()
clipboardSetText clipboard text len = liftIO $ do
    clipboard' <- unsafeManagedPtrCastPtr clipboard
    text' <- textToCString text
    gtk_clipboard_set_text clipboard' text' len
    touchManagedPtr clipboard
    freeMem text'
    return ()

#if ENABLE_OVERLOADING
data ClipboardSetTextMethodInfo
instance (signature ~ (T.Text -> Int32 -> m ()), MonadIO m, IsClipboard a) => O.MethodInfo ClipboardSetTextMethodInfo a signature where
    overloadedMethod _ = clipboardSetText

#endif

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

foreign import ccall "gtk_clipboard_store" gtk_clipboard_store ::
    Ptr Clipboard ->                        -- clipboard : TInterface (Name {namespace = "Gtk", name = "Clipboard"})
    IO ()

{- |
Stores the current clipboard data somewhere so that it will stay
around after the application has quit.

/Since: 2.6/
-}
clipboardStore ::
    (B.CallStack.HasCallStack, MonadIO m, IsClipboard a) =>
    a
    {- ^ /@clipboard@/: a 'GI.Gtk.Objects.Clipboard.Clipboard' -}
    -> m ()
clipboardStore clipboard = liftIO $ do
    clipboard' <- unsafeManagedPtrCastPtr clipboard
    gtk_clipboard_store clipboard'
    touchManagedPtr clipboard
    return ()

#if ENABLE_OVERLOADING
data ClipboardStoreMethodInfo
instance (signature ~ (m ()), MonadIO m, IsClipboard a) => O.MethodInfo ClipboardStoreMethodInfo a signature where
    overloadedMethod _ = clipboardStore

#endif

-- method Clipboard::wait_for_contents
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "clipboard", argType = TInterface (Name {namespace = "Gtk", name = "Clipboard"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkClipboard", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "target", argType = TInterface (Name {namespace = "Gdk", name = "Atom"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "an atom representing the form into which the clipboard\n         owner should convert the selection.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gtk", name = "SelectionData"}))
-- throws : False
-- Skip return : False

foreign import ccall "gtk_clipboard_wait_for_contents" gtk_clipboard_wait_for_contents ::
    Ptr Clipboard ->                        -- clipboard : TInterface (Name {namespace = "Gtk", name = "Clipboard"})
    Ptr Gdk.Atom.Atom ->                    -- target : TInterface (Name {namespace = "Gdk", name = "Atom"})
    IO (Ptr Gtk.SelectionData.SelectionData)

{- |
Requests the contents of the clipboard using the given target.
This function waits for the data to be received using the main
loop, so events, timeouts, etc, may be dispatched during the wait.
-}
clipboardWaitForContents ::
    (B.CallStack.HasCallStack, MonadIO m, IsClipboard a) =>
    a
    {- ^ /@clipboard@/: a 'GI.Gtk.Objects.Clipboard.Clipboard' -}
    -> Gdk.Atom.Atom
    {- ^ /@target@/: an atom representing the form into which the clipboard
         owner should convert the selection. -}
    -> m (Maybe Gtk.SelectionData.SelectionData)
    {- ^ __Returns:__ a newly-allocated 'GI.Gtk.Structs.SelectionData.SelectionData' object or 'Nothing'
              if retrieving the given target failed. If non-'Nothing',
              this value must be freed with 'GI.Gtk.Structs.SelectionData.selectionDataFree'
              when you are finished with it. -}
clipboardWaitForContents clipboard target = liftIO $ do
    clipboard' <- unsafeManagedPtrCastPtr clipboard
    target' <- unsafeManagedPtrGetPtr target
    result <- gtk_clipboard_wait_for_contents clipboard' target'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- (wrapBoxed Gtk.SelectionData.SelectionData) result'
        return result''
    touchManagedPtr clipboard
    touchManagedPtr target
    return maybeResult

#if ENABLE_OVERLOADING
data ClipboardWaitForContentsMethodInfo
instance (signature ~ (Gdk.Atom.Atom -> m (Maybe Gtk.SelectionData.SelectionData)), MonadIO m, IsClipboard a) => O.MethodInfo ClipboardWaitForContentsMethodInfo a signature where
    overloadedMethod _ = clipboardWaitForContents

#endif

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

foreign import ccall "gtk_clipboard_wait_for_image" gtk_clipboard_wait_for_image ::
    Ptr Clipboard ->                        -- clipboard : TInterface (Name {namespace = "Gtk", name = "Clipboard"})
    IO (Ptr GdkPixbuf.Pixbuf.Pixbuf)

{- |
Requests the contents of the clipboard as image and converts
the result to a 'GI.GdkPixbuf.Objects.Pixbuf.Pixbuf'. This function waits for
the data to be received using the main loop, so events,
timeouts, etc, may be dispatched during the wait.

/Since: 2.6/
-}
clipboardWaitForImage ::
    (B.CallStack.HasCallStack, MonadIO m, IsClipboard a) =>
    a
    {- ^ /@clipboard@/: a 'GI.Gtk.Objects.Clipboard.Clipboard' -}
    -> m (Maybe GdkPixbuf.Pixbuf.Pixbuf)
    {- ^ __Returns:__ a newly-allocated 'GI.GdkPixbuf.Objects.Pixbuf.Pixbuf'
    object which must be disposed with 'GI.GObject.Objects.Object.objectUnref', or
    'Nothing' if retrieving the selection data failed. (This could
    happen for various reasons, in particular if the clipboard
    was empty or if the contents of the clipboard could not be
    converted into an image.) -}
clipboardWaitForImage clipboard = liftIO $ do
    clipboard' <- unsafeManagedPtrCastPtr clipboard
    result <- gtk_clipboard_wait_for_image clipboard'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- (wrapObject GdkPixbuf.Pixbuf.Pixbuf) result'
        return result''
    touchManagedPtr clipboard
    return maybeResult

#if ENABLE_OVERLOADING
data ClipboardWaitForImageMethodInfo
instance (signature ~ (m (Maybe GdkPixbuf.Pixbuf.Pixbuf)), MonadIO m, IsClipboard a) => O.MethodInfo ClipboardWaitForImageMethodInfo a signature where
    overloadedMethod _ = clipboardWaitForImage

#endif

-- XXX Could not generate method Clipboard::wait_for_rich_text
-- Error was : Not implemented: "Don't know how to allocate \"format\" of type TInterface (Name {namespace = \"Gdk\", name = \"Atom\"})"
#if ENABLE_OVERLOADING
-- XXX: Dummy instance, since code generation failed.
-- Please file a bug at http://github.com/haskell-gi/haskell-gi.
data ClipboardWaitForRichTextMethodInfo
instance (p ~ (), o ~ O.MethodResolutionFailed "waitForRichText" Clipboard) => O.MethodInfo ClipboardWaitForRichTextMethodInfo o p where
    overloadedMethod _ = undefined
#endif

-- method Clipboard::wait_for_targets
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "clipboard", argType = TInterface (Name {namespace = "Gtk", name = "Clipboard"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkClipboard", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "targets", argType = TCArray False (-1) 2 (TInterface (Name {namespace = "Gdk", name = "Atom"})), direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "location\n          to store an array of targets. The result stored here must\n          be freed with g_free().", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferContainer},Arg {argCName = "n_targets", argType = TBasicType TInt, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "location to store number of items in @targets.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
-- Lengths : [Arg {argCName = "n_targets", argType = TBasicType TInt, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "location to store number of items in @targets.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "gtk_clipboard_wait_for_targets" gtk_clipboard_wait_for_targets ::
    Ptr Clipboard ->                        -- clipboard : TInterface (Name {namespace = "Gtk", name = "Clipboard"})
    Ptr (Ptr (Ptr Gdk.Atom.Atom)) ->        -- targets : TCArray False (-1) 2 (TInterface (Name {namespace = "Gdk", name = "Atom"}))
    Ptr Int32 ->                            -- n_targets : TBasicType TInt
    IO CInt

{- |
Returns a list of targets that are present on the clipboard, or 'Nothing'
if there aren’t any targets available. The returned list must be
freed with 'GI.GLib.Functions.free'.
This function waits for the data to be received using the main
loop, so events, timeouts, etc, may be dispatched during the wait.

/Since: 2.4/
-}
clipboardWaitForTargets ::
    (B.CallStack.HasCallStack, MonadIO m, IsClipboard a) =>
    a
    {- ^ /@clipboard@/: a 'GI.Gtk.Objects.Clipboard.Clipboard' -}
    -> m ((Bool, [Gdk.Atom.Atom]))
    {- ^ __Returns:__ 'True' if any targets are present on the clipboard,
              otherwise 'False'. -}
clipboardWaitForTargets clipboard = liftIO $ do
    clipboard' <- unsafeManagedPtrCastPtr clipboard
    targets <- allocMem :: IO (Ptr (Ptr (Ptr Gdk.Atom.Atom)))
    nTargets <- allocMem :: IO (Ptr Int32)
    result <- gtk_clipboard_wait_for_targets clipboard' targets nTargets
    nTargets' <- peek nTargets
    let result' = (/= 0) result
    targets' <- peek targets
    targets'' <- (unpackPtrArrayWithLength nTargets') targets'
    targets''' <- mapM (newPtr Gdk.Atom.Atom) targets''
    freeMem targets'
    touchManagedPtr clipboard
    freeMem targets
    freeMem nTargets
    return (result', targets''')

#if ENABLE_OVERLOADING
data ClipboardWaitForTargetsMethodInfo
instance (signature ~ (m ((Bool, [Gdk.Atom.Atom]))), MonadIO m, IsClipboard a) => O.MethodInfo ClipboardWaitForTargetsMethodInfo a signature where
    overloadedMethod _ = clipboardWaitForTargets

#endif

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

foreign import ccall "gtk_clipboard_wait_for_text" gtk_clipboard_wait_for_text ::
    Ptr Clipboard ->                        -- clipboard : TInterface (Name {namespace = "Gtk", name = "Clipboard"})
    IO CString

{- |
Requests the contents of the clipboard as text and converts
the result to UTF-8 if necessary. This function waits for
the data to be received using the main loop, so events,
timeouts, etc, may be dispatched during the wait.
-}
clipboardWaitForText ::
    (B.CallStack.HasCallStack, MonadIO m, IsClipboard a) =>
    a
    {- ^ /@clipboard@/: a 'GI.Gtk.Objects.Clipboard.Clipboard' -}
    -> m (Maybe T.Text)
    {- ^ __Returns:__ a newly-allocated UTF-8 string which must
              be freed with 'GI.GLib.Functions.free', or 'Nothing' if retrieving
              the selection data failed. (This could happen
              for various reasons, in particular if the
              clipboard was empty or if the contents of the
              clipboard could not be converted into text form.) -}
clipboardWaitForText clipboard = liftIO $ do
    clipboard' <- unsafeManagedPtrCastPtr clipboard
    result <- gtk_clipboard_wait_for_text clipboard'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- cstringToText result'
        freeMem result'
        return result''
    touchManagedPtr clipboard
    return maybeResult

#if ENABLE_OVERLOADING
data ClipboardWaitForTextMethodInfo
instance (signature ~ (m (Maybe T.Text)), MonadIO m, IsClipboard a) => O.MethodInfo ClipboardWaitForTextMethodInfo a signature where
    overloadedMethod _ = clipboardWaitForText

#endif

-- method Clipboard::wait_for_uris
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "clipboard", argType = TInterface (Name {namespace = "Gtk", name = "Clipboard"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkClipboard", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TCArray True (-1) (-1) (TBasicType TUTF8))
-- throws : False
-- Skip return : False

foreign import ccall "gtk_clipboard_wait_for_uris" gtk_clipboard_wait_for_uris ::
    Ptr Clipboard ->                        -- clipboard : TInterface (Name {namespace = "Gtk", name = "Clipboard"})
    IO (Ptr CString)

{- |
Requests the contents of the clipboard as URIs. This function waits
for the data to be received using the main loop, so events,
timeouts, etc, may be dispatched during the wait.

/Since: 2.14/
-}
clipboardWaitForUris ::
    (B.CallStack.HasCallStack, MonadIO m, IsClipboard a) =>
    a
    {- ^ /@clipboard@/: a 'GI.Gtk.Objects.Clipboard.Clipboard' -}
    -> m (Maybe [T.Text])
    {- ^ __Returns:__ 
    a newly-allocated 'Nothing'-terminated array of strings which must
    be freed with 'GI.GLib.Functions.strfreev', or 'Nothing' if retrieving the
    selection data failed. (This could happen for various reasons,
    in particular if the clipboard was empty or if the contents of
    the clipboard could not be converted into URI form.) -}
clipboardWaitForUris clipboard = liftIO $ do
    clipboard' <- unsafeManagedPtrCastPtr clipboard
    result <- gtk_clipboard_wait_for_uris clipboard'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- unpackZeroTerminatedUTF8CArray result'
        mapZeroTerminatedCArray freeMem result'
        freeMem result'
        return result''
    touchManagedPtr clipboard
    return maybeResult

#if ENABLE_OVERLOADING
data ClipboardWaitForUrisMethodInfo
instance (signature ~ (m (Maybe [T.Text])), MonadIO m, IsClipboard a) => O.MethodInfo ClipboardWaitForUrisMethodInfo a signature where
    overloadedMethod _ = clipboardWaitForUris

#endif

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

foreign import ccall "gtk_clipboard_wait_is_image_available" gtk_clipboard_wait_is_image_available ::
    Ptr Clipboard ->                        -- clipboard : TInterface (Name {namespace = "Gtk", name = "Clipboard"})
    IO CInt

{- |
Test to see if there is an image available to be pasted
This is done by requesting the TARGETS atom and checking
if it contains any of the supported image targets. This function
waits for the data to be received using the main loop, so events,
timeouts, etc, may be dispatched during the wait.

This function is a little faster than calling
'GI.Gtk.Objects.Clipboard.clipboardWaitForImage' since it doesn’t need to retrieve
the actual image data.

/Since: 2.6/
-}
clipboardWaitIsImageAvailable ::
    (B.CallStack.HasCallStack, MonadIO m, IsClipboard a) =>
    a
    {- ^ /@clipboard@/: a 'GI.Gtk.Objects.Clipboard.Clipboard' -}
    -> m Bool
    {- ^ __Returns:__ 'True' is there is an image available, 'False' otherwise. -}
clipboardWaitIsImageAvailable clipboard = liftIO $ do
    clipboard' <- unsafeManagedPtrCastPtr clipboard
    result <- gtk_clipboard_wait_is_image_available clipboard'
    let result' = (/= 0) result
    touchManagedPtr clipboard
    return result'

#if ENABLE_OVERLOADING
data ClipboardWaitIsImageAvailableMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsClipboard a) => O.MethodInfo ClipboardWaitIsImageAvailableMethodInfo a signature where
    overloadedMethod _ = clipboardWaitIsImageAvailable

#endif

-- method Clipboard::wait_is_rich_text_available
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "clipboard", argType = TInterface (Name {namespace = "Gtk", name = "Clipboard"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkClipboard", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "buffer", argType = TInterface (Name {namespace = "Gtk", name = "TextBuffer"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkTextBuffer", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "gtk_clipboard_wait_is_rich_text_available" gtk_clipboard_wait_is_rich_text_available ::
    Ptr Clipboard ->                        -- clipboard : TInterface (Name {namespace = "Gtk", name = "Clipboard"})
    Ptr Gtk.TextBuffer.TextBuffer ->        -- buffer : TInterface (Name {namespace = "Gtk", name = "TextBuffer"})
    IO CInt

{- |
Test to see if there is rich text available to be pasted
This is done by requesting the TARGETS atom and checking
if it contains any of the supported rich text targets. This function
waits for the data to be received using the main loop, so events,
timeouts, etc, may be dispatched during the wait.

This function is a little faster than calling
'GI.Gtk.Objects.Clipboard.clipboardWaitForRichText' since it doesn’t need to retrieve
the actual text.

/Since: 2.10/
-}
clipboardWaitIsRichTextAvailable ::
    (B.CallStack.HasCallStack, MonadIO m, IsClipboard a, Gtk.TextBuffer.IsTextBuffer b) =>
    a
    {- ^ /@clipboard@/: a 'GI.Gtk.Objects.Clipboard.Clipboard' -}
    -> b
    {- ^ /@buffer@/: a 'GI.Gtk.Objects.TextBuffer.TextBuffer' -}
    -> m Bool
    {- ^ __Returns:__ 'True' is there is rich text available, 'False' otherwise. -}
clipboardWaitIsRichTextAvailable clipboard buffer = liftIO $ do
    clipboard' <- unsafeManagedPtrCastPtr clipboard
    buffer' <- unsafeManagedPtrCastPtr buffer
    result <- gtk_clipboard_wait_is_rich_text_available clipboard' buffer'
    let result' = (/= 0) result
    touchManagedPtr clipboard
    touchManagedPtr buffer
    return result'

#if ENABLE_OVERLOADING
data ClipboardWaitIsRichTextAvailableMethodInfo
instance (signature ~ (b -> m Bool), MonadIO m, IsClipboard a, Gtk.TextBuffer.IsTextBuffer b) => O.MethodInfo ClipboardWaitIsRichTextAvailableMethodInfo a signature where
    overloadedMethod _ = clipboardWaitIsRichTextAvailable

#endif

-- method Clipboard::wait_is_target_available
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "clipboard", argType = TInterface (Name {namespace = "Gtk", name = "Clipboard"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkClipboard", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "target", argType = TInterface (Name {namespace = "Gdk", name = "Atom"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A #GdkAtom indicating which target to look for.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "gtk_clipboard_wait_is_target_available" gtk_clipboard_wait_is_target_available ::
    Ptr Clipboard ->                        -- clipboard : TInterface (Name {namespace = "Gtk", name = "Clipboard"})
    Ptr Gdk.Atom.Atom ->                    -- target : TInterface (Name {namespace = "Gdk", name = "Atom"})
    IO CInt

{- |
Checks if a clipboard supports pasting data of a given type. This
function can be used to determine if a “Paste” menu item should be
insensitive or not.

If you want to see if there’s text available on the clipboard, use
gtk_clipboard_wait_is_text_available () instead.

/Since: 2.6/
-}
clipboardWaitIsTargetAvailable ::
    (B.CallStack.HasCallStack, MonadIO m, IsClipboard a) =>
    a
    {- ^ /@clipboard@/: a 'GI.Gtk.Objects.Clipboard.Clipboard' -}
    -> Gdk.Atom.Atom
    {- ^ /@target@/: A 'GI.Gdk.Structs.Atom.Atom' indicating which target to look for. -}
    -> m Bool
    {- ^ __Returns:__ 'True' if the target is available, 'False' otherwise. -}
clipboardWaitIsTargetAvailable clipboard target = liftIO $ do
    clipboard' <- unsafeManagedPtrCastPtr clipboard
    target' <- unsafeManagedPtrGetPtr target
    result <- gtk_clipboard_wait_is_target_available clipboard' target'
    let result' = (/= 0) result
    touchManagedPtr clipboard
    touchManagedPtr target
    return result'

#if ENABLE_OVERLOADING
data ClipboardWaitIsTargetAvailableMethodInfo
instance (signature ~ (Gdk.Atom.Atom -> m Bool), MonadIO m, IsClipboard a) => O.MethodInfo ClipboardWaitIsTargetAvailableMethodInfo a signature where
    overloadedMethod _ = clipboardWaitIsTargetAvailable

#endif

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

foreign import ccall "gtk_clipboard_wait_is_text_available" gtk_clipboard_wait_is_text_available ::
    Ptr Clipboard ->                        -- clipboard : TInterface (Name {namespace = "Gtk", name = "Clipboard"})
    IO CInt

{- |
Test to see if there is text available to be pasted
This is done by requesting the TARGETS atom and checking
if it contains any of the supported text targets. This function
waits for the data to be received using the main loop, so events,
timeouts, etc, may be dispatched during the wait.

This function is a little faster than calling
'GI.Gtk.Objects.Clipboard.clipboardWaitForText' since it doesn’t need to retrieve
the actual text.
-}
clipboardWaitIsTextAvailable ::
    (B.CallStack.HasCallStack, MonadIO m, IsClipboard a) =>
    a
    {- ^ /@clipboard@/: a 'GI.Gtk.Objects.Clipboard.Clipboard' -}
    -> m Bool
    {- ^ __Returns:__ 'True' is there is text available, 'False' otherwise. -}
clipboardWaitIsTextAvailable clipboard = liftIO $ do
    clipboard' <- unsafeManagedPtrCastPtr clipboard
    result <- gtk_clipboard_wait_is_text_available clipboard'
    let result' = (/= 0) result
    touchManagedPtr clipboard
    return result'

#if ENABLE_OVERLOADING
data ClipboardWaitIsTextAvailableMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsClipboard a) => O.MethodInfo ClipboardWaitIsTextAvailableMethodInfo a signature where
    overloadedMethod _ = clipboardWaitIsTextAvailable

#endif

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

foreign import ccall "gtk_clipboard_wait_is_uris_available" gtk_clipboard_wait_is_uris_available ::
    Ptr Clipboard ->                        -- clipboard : TInterface (Name {namespace = "Gtk", name = "Clipboard"})
    IO CInt

{- |
Test to see if there is a list of URIs available to be pasted
This is done by requesting the TARGETS atom and checking
if it contains the URI targets. This function
waits for the data to be received using the main loop, so events,
timeouts, etc, may be dispatched during the wait.

This function is a little faster than calling
'GI.Gtk.Objects.Clipboard.clipboardWaitForUris' since it doesn’t need to retrieve
the actual URI data.

/Since: 2.14/
-}
clipboardWaitIsUrisAvailable ::
    (B.CallStack.HasCallStack, MonadIO m, IsClipboard a) =>
    a
    {- ^ /@clipboard@/: a 'GI.Gtk.Objects.Clipboard.Clipboard' -}
    -> m Bool
    {- ^ __Returns:__ 'True' is there is an URI list available, 'False' otherwise. -}
clipboardWaitIsUrisAvailable clipboard = liftIO $ do
    clipboard' <- unsafeManagedPtrCastPtr clipboard
    result <- gtk_clipboard_wait_is_uris_available clipboard'
    let result' = (/= 0) result
    touchManagedPtr clipboard
    return result'

#if ENABLE_OVERLOADING
data ClipboardWaitIsUrisAvailableMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsClipboard a) => O.MethodInfo ClipboardWaitIsUrisAvailableMethodInfo a signature where
    overloadedMethod _ = clipboardWaitIsUrisAvailable

#endif

-- method Clipboard::get
-- method type : MemberFunction
-- Args : [Arg {argCName = "selection", argType = TInterface (Name {namespace = "Gdk", name = "Atom"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GdkAtom which identifies the clipboard to use", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gtk", name = "Clipboard"}))
-- throws : False
-- Skip return : False

foreign import ccall "gtk_clipboard_get" gtk_clipboard_get ::
    Ptr Gdk.Atom.Atom ->                    -- selection : TInterface (Name {namespace = "Gdk", name = "Atom"})
    IO (Ptr Clipboard)

{- |
Returns the clipboard object for the given selection.
See 'GI.Gtk.Objects.Clipboard.clipboardGetForDisplay' for complete details.
-}
clipboardGet ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Gdk.Atom.Atom
    {- ^ /@selection@/: a 'GI.Gdk.Structs.Atom.Atom' which identifies the clipboard to use -}
    -> m Clipboard
    {- ^ __Returns:__ the appropriate clipboard object. If no clipboard
    already exists, a new one will be created. Once a clipboard
    object has been created, it is persistent and, since it is
    owned by GTK+, must not be freed or unreffed. -}
clipboardGet selection = liftIO $ do
    selection' <- unsafeManagedPtrGetPtr selection
    result <- gtk_clipboard_get selection'
    checkUnexpectedReturnNULL "clipboardGet" result
    result' <- (newObject Clipboard) result
    touchManagedPtr selection
    return result'

#if ENABLE_OVERLOADING
#endif

-- method Clipboard::get_default
-- method type : MemberFunction
-- Args : [Arg {argCName = "display", argType = TInterface (Name {namespace = "Gdk", name = "Display"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GdkDisplay for which the clipboard is to be retrieved.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gtk", name = "Clipboard"}))
-- throws : False
-- Skip return : False

foreign import ccall "gtk_clipboard_get_default" gtk_clipboard_get_default ::
    Ptr Gdk.Display.Display ->              -- display : TInterface (Name {namespace = "Gdk", name = "Display"})
    IO (Ptr Clipboard)

{- |
Returns the default clipboard object for use with cut\/copy\/paste menu items
and keyboard shortcuts.

/Since: 3.16/
-}
clipboardGetDefault ::
    (B.CallStack.HasCallStack, MonadIO m, Gdk.Display.IsDisplay a) =>
    a
    {- ^ /@display@/: the 'GI.Gdk.Objects.Display.Display' for which the clipboard is to be retrieved. -}
    -> m Clipboard
    {- ^ __Returns:__ the default clipboard object. -}
clipboardGetDefault display = liftIO $ do
    display' <- unsafeManagedPtrCastPtr display
    result <- gtk_clipboard_get_default display'
    checkUnexpectedReturnNULL "clipboardGetDefault" result
    result' <- (newObject Clipboard) result
    touchManagedPtr display
    return result'

#if ENABLE_OVERLOADING
#endif

-- method Clipboard::get_for_display
-- method type : MemberFunction
-- Args : [Arg {argCName = "display", argType = TInterface (Name {namespace = "Gdk", name = "Display"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GdkDisplay for which the clipboard is to be retrieved or created.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "selection", argType = TInterface (Name {namespace = "Gdk", name = "Atom"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GdkAtom which identifies the clipboard to use.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gtk", name = "Clipboard"}))
-- throws : False
-- Skip return : False

foreign import ccall "gtk_clipboard_get_for_display" gtk_clipboard_get_for_display ::
    Ptr Gdk.Display.Display ->              -- display : TInterface (Name {namespace = "Gdk", name = "Display"})
    Ptr Gdk.Atom.Atom ->                    -- selection : TInterface (Name {namespace = "Gdk", name = "Atom"})
    IO (Ptr Clipboard)

{- |
Returns the clipboard object for the given selection.
Cut\/copy\/paste menu items and keyboard shortcuts should use
the default clipboard, returned by passing @/GDK_SELECTION_CLIPBOARD/@ for /@selection@/.
(@/GDK_NONE/@ is supported as a synonym for GDK_SELECTION_CLIPBOARD
for backwards compatibility reasons.)
The currently-selected object or text should be provided on the clipboard
identified by @/GDK_SELECTION_PRIMARY/@. Cut\/copy\/paste menu items
conceptually copy the contents of the @/GDK_SELECTION_PRIMARY/@ clipboard
to the default clipboard, i.e. they copy the selection to what the
user sees as the clipboard.

(Passing @/GDK_NONE/@ is the same as using @gdk_atom_intern
(\"CLIPBOARD\", FALSE)@.

See the
<http://www.freedesktop.org/Standards/clipboards-spec FreeDesktop Clipboard Specification>
for a detailed discussion of the “CLIPBOARD” vs. “PRIMARY”
selections under the X window system. On Win32 the
@/GDK_SELECTION_PRIMARY/@ clipboard is essentially ignored.)

It’s possible to have arbitrary named clipboards; if you do invent
new clipboards, you should prefix the selection name with an
underscore (because the ICCCM requires that nonstandard atoms are
underscore-prefixed), and namespace it as well. For example,
if your application called “Foo” has a special-purpose
clipboard, you might call it “_FOO_SPECIAL_CLIPBOARD”.

/Since: 2.2/
-}
clipboardGetForDisplay ::
    (B.CallStack.HasCallStack, MonadIO m, Gdk.Display.IsDisplay a) =>
    a
    {- ^ /@display@/: the 'GI.Gdk.Objects.Display.Display' for which the clipboard is to be retrieved or created. -}
    -> Gdk.Atom.Atom
    {- ^ /@selection@/: a 'GI.Gdk.Structs.Atom.Atom' which identifies the clipboard to use. -}
    -> m Clipboard
    {- ^ __Returns:__ the appropriate clipboard object. If no
  clipboard already exists, a new one will be created. Once a clipboard
  object has been created, it is persistent and, since it is owned by
  GTK+, must not be freed or unrefd. -}
clipboardGetForDisplay display selection = liftIO $ do
    display' <- unsafeManagedPtrCastPtr display
    selection' <- unsafeManagedPtrGetPtr selection
    result <- gtk_clipboard_get_for_display display' selection'
    checkUnexpectedReturnNULL "clipboardGetForDisplay" result
    result' <- (newObject Clipboard) result
    touchManagedPtr display
    touchManagedPtr selection
    return result'

#if ENABLE_OVERLOADING
#endif