    {-# LANGUAGE TypeApplications #-}

    -- | Copyright  : Will Thompson and Iñaki García Etxebarria
    -- License    : LGPL-2.1
    -- Maintainer : Iñaki García Etxebarria
    --
    -- Sorts items via a callback function.

    #if !defined(__HADDOCK_VERSION__)
    #define ENABLE_OVERLOADING
    #endif

    module GI.Gtk.Objects.CustomSorter
        (

    -- * Exported types
        CustomSorter(..)                        ,
        IsCustomSorter                          ,
        toCustomSorter                          ,

     -- * Methods
    -- |
    --
    --  === __Click to display all available methods, including inherited ones__
    -- ==== Methods
    -- [bindProperty]("GI.GObject.Objects.Object#g:method:bindProperty"), [bindPropertyFull]("GI.GObject.Objects.Object#g:method:bindPropertyFull"), [changed]("GI.Gtk.Objects.Sorter#g:method:changed"), [compare]("GI.Gtk.Objects.Sorter#g:method:compare"), [forceFloating]("GI.GObject.Objects.Object#g:method:forceFloating"), [freezeNotify]("GI.GObject.Objects.Object#g:method:freezeNotify"), [getv]("GI.GObject.Objects.Object#g:method:getv"), [isFloating]("GI.GObject.Objects.Object#g:method:isFloating"), [notify]("GI.GObject.Objects.Object#g:method:notify"), [notifyByPspec]("GI.GObject.Objects.Object#g:method:notifyByPspec"), [ref]("GI.GObject.Objects.Object#g:method:ref"), [refSink]("GI.GObject.Objects.Object#g:method:refSink"), [runDispose]("GI.GObject.Objects.Object#g:method:runDispose"), [stealData]("GI.GObject.Objects.Object#g:method:stealData"), [stealQdata]("GI.GObject.Objects.Object#g:method:stealQdata"), [thawNotify]("GI.GObject.Objects.Object#g:method:thawNotify"), [unref]("GI.GObject.Objects.Object#g:method:unref"), [watchClosure]("GI.GObject.Objects.Object#g:method:watchClosure").
    --
    -- ==== Getters
    -- [getData]("GI.GObject.Objects.Object#g:method:getData"), [getOrder]("GI.Gtk.Objects.Sorter#g:method:getOrder"), [getProperty]("GI.GObject.Objects.Object#g:method:getProperty"), [getQdata]("GI.GObject.Objects.Object#g:method:getQdata").
    --
    -- ==== Setters
    -- [setData]("GI.GObject.Objects.Object#g:method:setData"), [setDataFull]("GI.GObject.Objects.Object#g:method:setDataFull"), [setProperty]("GI.GObject.Objects.Object#g:method:setProperty"), [setSortFunc]("GI.Gtk.Objects.CustomSorter#g:method:setSortFunc").

    #if defined(ENABLE_OVERLOADING)
        ResolveCustomSorterMethod               ,
    #endif

    -- ** new #method:new#

        customSorterNew                         ,

    -- ** setSortFunc #method:setSortFunc#

    #if defined(ENABLE_OVERLOADING)
        CustomSorterSetSortFuncMethodInfo       ,
    #endif
        customSorterSetSortFunc                 ,

        ) where

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

    import qualified Data.GI.Base.Attributes as GI.Attributes
    import qualified Data.GI.Base.BasicTypes as B.Types
    import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
    import qualified Data.GI.Base.GArray as B.GArray
    import qualified Data.GI.Base.GClosure as B.GClosure
    import qualified Data.GI.Base.GError as B.GError
    import qualified Data.GI.Base.GHashTable as B.GHT
    import qualified Data.GI.Base.GVariant as B.GVariant
    import qualified Data.GI.Base.GValue as B.GValue
    import qualified Data.GI.Base.GParamSpec as B.GParamSpec
    import qualified Data.GI.Base.CallStack as B.CallStack
    import qualified Data.GI.Base.Properties as B.Properties
    import qualified Data.GI.Base.Signals as B.Signals
    import qualified Control.Monad.IO.Class as MIO
    import qualified Data.Coerce as Coerce
    import qualified Data.Text as T
    import qualified Data.Kind as DK
    import qualified Data.ByteString.Char8 as B
    import qualified Data.Map as Map
    import qualified Foreign.Ptr as FP
    import qualified GHC.OverloadedLabels as OL
    import qualified GHC.Records as R
    import qualified Data.Word as DW
    import qualified Data.Int as DI
    import qualified System.Posix.Types as SPT
    import qualified Foreign.C.Types as FCT

    -- Workaround for https://gitlab.haskell.org/ghc/ghc/-/issues/23392
    #if MIN_VERSION_base(4,18,0)
    import qualified GI.GLib.Callbacks as GLib.Callbacks
    import qualified GI.GObject.Objects.Object as GObject.Object
    import {-# SOURCE #-} qualified GI.Gtk.Enums as Gtk.Enums
    import {-# SOURCE #-} qualified GI.Gtk.Objects.Sorter as Gtk.Sorter

    #else
    import qualified GI.GLib.Callbacks as GLib.Callbacks
    import qualified GI.GObject.Objects.Object as GObject.Object
    import {-# SOURCE #-} qualified GI.Gtk.Objects.Sorter as Gtk.Sorter

    #endif

    -- | Memory-managed wrapper type.
    newtype CustomSorter = CustomSorter (SP.ManagedPtr CustomSorter)
        deriving (CustomSorter -> CustomSorter -> Bool
    (CustomSorter -> CustomSorter -> Bool)
    -> (CustomSorter -> CustomSorter -> Bool) -> Eq CustomSorter
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: CustomSorter -> CustomSorter -> Bool
    == :: CustomSorter -> CustomSorter -> Bool
    $c/= :: CustomSorter -> CustomSorter -> Bool
    /= :: CustomSorter -> CustomSorter -> Bool
    Eq)

    instance SP.ManagedPtrNewtype CustomSorter where
        toManagedPtr :: CustomSorter -> ManagedPtr CustomSorter
    toManagedPtr (CustomSorter ManagedPtr CustomSorter
    p) = ManagedPtr CustomSorter
    p

    foreign import ccall "gtk_custom_sorter_get_type"
        c_gtk_custom_sorter_get_type :: IO B.Types.GType

    instance B.Types.TypedObject CustomSorter where
        glibType :: IO GType
    glibType = IO GType
    c_gtk_custom_sorter_get_type

    instance B.Types.GObject CustomSorter

    -- | Type class for types which can be safely cast to t'CustomSorter', for instance with `toCustomSorter`.
    class (SP.GObject o, O.IsDescendantOf CustomSorter o) => IsCustomSorter o
    instance (SP.GObject o, O.IsDescendantOf CustomSorter o) => IsCustomSorter o

    instance O.HasParentTypes CustomSorter
    type instance O.ParentTypes CustomSorter = '[Gtk.Sorter.Sorter, GObject.Object.Object]

    -- | Cast to t'CustomSorter', for types for which this is known to be safe. For general casts, use 'Data.GI.Base.ManagedPtr.castTo'.
    toCustomSorter :: (MIO.MonadIO m, IsCustomSorter o) => o -> m CustomSorter
    toCustomSorter :: forall (m :: * -> *) o.
    (MonadIO m, IsCustomSorter o) =>
    o -> m CustomSorter
    toCustomSorter = IO CustomSorter -> m CustomSorter
    forall a. IO a -> m a
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
    MIO.liftIO (IO CustomSorter -> m CustomSorter)
    -> (o -> IO CustomSorter) -> o -> m CustomSorter
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (ManagedPtr CustomSorter -> CustomSorter) -> o -> IO CustomSorter
    forall o o'.
    (HasCallStack, ManagedPtrNewtype o, TypedObject o,
     ManagedPtrNewtype o', TypedObject o') =>
    (ManagedPtr o' -> o') -> o -> IO o'
    B.ManagedPtr.unsafeCastTo ManagedPtr CustomSorter -> CustomSorter
    CustomSorter

    -- | Convert t'CustomSorter' to and from t'Data.GI.Base.GValue.GValue'. See 'Data.GI.Base.GValue.toGValue' and 'Data.GI.Base.GValue.fromGValue'.
    instance B.GValue.IsGValue (Maybe CustomSorter) where
        gvalueGType_ :: IO GType
    gvalueGType_ = IO GType
    c_gtk_custom_sorter_get_type
        gvalueSet_ :: Ptr GValue -> Maybe CustomSorter -> IO ()
    gvalueSet_ Ptr GValue
    gv Maybe CustomSorter
    P.Nothing = Ptr GValue -> Ptr CustomSorter -> IO ()
    forall a. GObject a => Ptr GValue -> Ptr a -> IO ()
    B.GValue.set_object Ptr GValue
    gv (Ptr CustomSorter
    forall a. Ptr a
    FP.nullPtr :: FP.Ptr CustomSorter)
        gvalueSet_ Ptr GValue
    gv (P.Just CustomSorter
    obj) = CustomSorter -> (Ptr CustomSorter -> IO ()) -> IO ()
    forall a c.
    (HasCallStack, ManagedPtrNewtype a) =>
    a -> (Ptr a -> IO c) -> IO c
    B.ManagedPtr.withManagedPtr CustomSorter
    obj (Ptr GValue -> Ptr CustomSorter -> IO ()
    forall a. GObject a => Ptr GValue -> Ptr a -> IO ()
    B.GValue.set_object Ptr GValue
    gv)
        gvalueGet_ :: Ptr GValue -> IO (Maybe CustomSorter)
    gvalueGet_ Ptr GValue
    gv = do
            ptr <- Ptr GValue -> IO (Ptr CustomSorter)
    forall a. GObject a => Ptr GValue -> IO (Ptr a)
    B.GValue.get_object Ptr GValue
    gv :: IO (FP.Ptr CustomSorter)
            if ptr /= FP.nullPtr
            then P.Just <$> B.ManagedPtr.newObject CustomSorter ptr
            else return P.Nothing

    #if defined(ENABLE_OVERLOADING)
    type family ResolveCustomSorterMethod (t :: Symbol) (o :: DK.Type) :: DK.Type where
        ResolveCustomSorterMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
        ResolveCustomSorterMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
        ResolveCustomSorterMethod "changed" o = Gtk.Sorter.SorterChangedMethodInfo
        ResolveCustomSorterMethod "compare" o = Gtk.Sorter.SorterCompareMethodInfo
        ResolveCustomSorterMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
        ResolveCustomSorterMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
        ResolveCustomSorterMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
        ResolveCustomSorterMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
        ResolveCustomSorterMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
        ResolveCustomSorterMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
        ResolveCustomSorterMethod "ref" o = GObject.Object.ObjectRefMethodInfo
        ResolveCustomSorterMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
        ResolveCustomSorterMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
        ResolveCustomSorterMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
        ResolveCustomSorterMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
        ResolveCustomSorterMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
        ResolveCustomSorterMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
        ResolveCustomSorterMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
        ResolveCustomSorterMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
        ResolveCustomSorterMethod "getOrder" o = Gtk.Sorter.SorterGetOrderMethodInfo
        ResolveCustomSorterMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
        ResolveCustomSorterMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
        ResolveCustomSorterMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
        ResolveCustomSorterMethod "setDataFull" o = GObject.Object.ObjectSetDataFullMethodInfo
        ResolveCustomSorterMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
        ResolveCustomSorterMethod "setSortFunc" o = CustomSorterSetSortFuncMethodInfo
        ResolveCustomSorterMethod l o = O.MethodResolutionFailed l o

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

    #if MIN_VERSION_base(4,13,0)
    instance (info ~ ResolveCustomSorterMethod t CustomSorter, O.OverloadedMethod info CustomSorter p, R.HasField t CustomSorter p) => R.HasField t CustomSorter p where
        getField = O.overloadedMethod @info

    #endif

    instance (info ~ ResolveCustomSorterMethod t CustomSorter, O.OverloadedMethodInfo info CustomSorter) => OL.IsLabel t (O.MethodProxy info CustomSorter) where
    #if MIN_VERSION_base(4,10,0)
        fromLabel = O.MethodProxy
    #else
        fromLabel _ = O.MethodProxy
    #endif

    #endif

    #if defined(ENABLE_OVERLOADING)
    instance O.HasAttributeList CustomSorter
    type instance O.AttributeList CustomSorter = CustomSorterAttributeList
    type CustomSorterAttributeList = ('[ ] :: [(Symbol, DK.Type)])
    #endif

    #if defined(ENABLE_OVERLOADING)
    #endif

    #if defined(ENABLE_OVERLOADING)
    type instance O.SignalList CustomSorter = CustomSorterSignalList
    type CustomSorterSignalList = ('[ '("changed", Gtk.Sorter.SorterChangedSignalInfo), '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, DK.Type)])

    #endif

    -- method CustomSorter::new
    -- method type : Constructor
    -- Args: [ Arg
    --           { argCName = "sort_func"
    --           , argType =
    --               TInterface Name { namespace = "GLib" , name = "CompareDataFunc" }
    --           , argCType = Just "GCompareDataFunc"
    --           , direction = DirectionIn
    --           , mayBeNull = True
    --           , argDoc =
    --               Documentation
    --                 { rawDocText = Just "the `GCompareDataFunc` to use for sorting"
    --                 , sinceVersion = Nothing
    --                 }
    --           , argScope = ScopeTypeNotified
    --           , argClosure = 1
    --           , argDestroy = 2
    --           , argCallerAllocates = False
    --           , argCallbackUserData = False
    --           , transfer = TransferNothing
    --           }
    --       , Arg
    --           { argCName = "user_data"
    --           , argType = TBasicType TPtr
    --           , argCType = Just "gpointer"
    --           , direction = DirectionIn
    --           , mayBeNull = True
    --           , argDoc =
    --               Documentation
    --                 { rawDocText = Just "user data to pass to @sort_func"
    --                 , sinceVersion = Nothing
    --                 }
    --           , argScope = ScopeTypeInvalid
    --           , argClosure = -1
    --           , argDestroy = -1
    --           , argCallerAllocates = False
    --           , argCallbackUserData = False
    --           , transfer = TransferNothing
    --           }
    --       , Arg
    --           { argCName = "user_destroy"
    --           , argType =
    --               TInterface Name { namespace = "GLib" , name = "DestroyNotify" }
    --           , argCType = Just "GDestroyNotify"
    --           , direction = DirectionIn
    --           , mayBeNull = True
    --           , argDoc =
    --               Documentation
    --                 { rawDocText = Just "destroy notify for @user_data"
    --                 , sinceVersion = Nothing
    --                 }
    --           , argScope = ScopeTypeAsync
    --           , argClosure = -1
    --           , argDestroy = -1
    --           , argCallerAllocates = False
    --           , argCallbackUserData = False
    --           , transfer = TransferNothing
    --           }
    --       ]
    -- Lengths: []
    -- returnType: Just
    --               (TInterface Name { namespace = "Gtk" , name = "CustomSorter" })
    -- throws : False
    -- Skip return : False

    foreign import ccall "gtk_custom_sorter_new" gtk_custom_sorter_new ::
        FunPtr GLib.Callbacks.C_CompareDataFunc -> -- sort_func : TInterface (Name {namespace = "GLib", name = "CompareDataFunc"})
        Ptr () ->                               -- user_data : TBasicType TPtr
        FunPtr GLib.Callbacks.C_DestroyNotify -> -- user_destroy : TInterface (Name {namespace = "GLib", name = "DestroyNotify"})
        IO (Ptr CustomSorter)

    -- | Creates a new @GtkSorter@ that works by calling
    -- /@sortFunc@/ to compare items.
    --
    -- If /@sortFunc@/ is 'P.Nothing', all items are considered equal.
    customSorterNew ::
        (B.CallStack.HasCallStack, MonadIO m) =>
        Maybe (GLib.Callbacks.CompareDataFunc)
        -- ^ /@sortFunc@/: the @GCompareDataFunc@ to use for sorting
        -> m CustomSorter
        -- ^ __Returns:__ a new @GtkCustomSorter@
    customSorterNew :: forall (m :: * -> *).
    (HasCallStack, MonadIO m) =>
    Maybe CompareDataFunc -> m CustomSorter
    customSorterNew Maybe CompareDataFunc
    sortFunc = IO CustomSorter -> m CustomSorter
    forall a. IO a -> m a
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
    liftIO (IO CustomSorter -> m CustomSorter)
    -> IO CustomSorter -> m CustomSorter
    forall a b. (a -> b) -> a -> b
    $ do
        maybeSortFunc <- case Maybe CompareDataFunc
    sortFunc of
            Maybe CompareDataFunc
    Nothing -> FunPtr C_CompareDataFunc -> IO (FunPtr C_CompareDataFunc)
    forall a. a -> IO a
    forall (m :: * -> *) a. Monad m => a -> m a
    return FunPtr C_CompareDataFunc
    forall a. FunPtr a
    FP.nullFunPtr
            Just CompareDataFunc
    jSortFunc -> do
                jSortFunc' <- C_CompareDataFunc -> IO (FunPtr C_CompareDataFunc)
    GLib.Callbacks.mk_CompareDataFunc (Maybe (Ptr (FunPtr C_CompareDataFunc))
    -> C_CompareDataFunc -> C_CompareDataFunc
    GLib.Callbacks.wrap_CompareDataFunc Maybe (Ptr (FunPtr C_CompareDataFunc))
    forall a. Maybe a
    Nothing (CompareDataFunc -> C_CompareDataFunc
    GLib.Callbacks.drop_closures_CompareDataFunc CompareDataFunc
    jSortFunc))
                return jSortFunc'
        let userData = FunPtr C_CompareDataFunc -> Ptr ()
    forall a b. FunPtr a -> Ptr b
    castFunPtrToPtr FunPtr C_CompareDataFunc
    maybeSortFunc
        let userDestroy = FunPtr (Ptr a -> IO ())
    forall a. FunPtr (Ptr a -> IO ())
    SP.safeFreeFunPtrPtr
        result <- gtk_custom_sorter_new maybeSortFunc userData userDestroy
        checkUnexpectedReturnNULL "customSorterNew" result
        result' <- (wrapObject CustomSorter) result
        return result'

    #if defined(ENABLE_OVERLOADING)
    #endif

    -- method CustomSorter::set_sort_func
    -- method type : OrdinaryMethod
    -- Args: [ Arg
    --           { argCName = "self"
    --           , argType =
    --               TInterface Name { namespace = "Gtk" , name = "CustomSorter" }
    --           , argCType = Just "GtkCustomSorter*"
    --           , direction = DirectionIn
    --           , mayBeNull = False
    --           , argDoc =
    --               Documentation
    --                 { rawDocText = Just "a `GtkCustomSorter`"
    --                 , sinceVersion = Nothing
    --                 }
    --           , argScope = ScopeTypeInvalid
    --           , argClosure = -1
    --           , argDestroy = -1
    --           , argCallerAllocates = False
    --           , argCallbackUserData = False
    --           , transfer = TransferNothing
    --           }
    --       , Arg
    --           { argCName = "sort_func"
    --           , argType =
    --               TInterface Name { namespace = "GLib" , name = "CompareDataFunc" }
    --           , argCType = Just "GCompareDataFunc"
    --           , direction = DirectionIn
    --           , mayBeNull = True
    --           , argDoc =
    --               Documentation
    --                 { rawDocText = Just "function to sort items"
    --                 , sinceVersion = Nothing
    --                 }
    --           , argScope = ScopeTypeNotified
    --           , argClosure = 2
    --           , argDestroy = 3
    --           , argCallerAllocates = False
    --           , argCallbackUserData = False
    --           , transfer = TransferNothing
    --           }
    --       , Arg
    --           { argCName = "user_data"
    --           , argType = TBasicType TPtr
    --           , argCType = Just "gpointer"
    --           , direction = DirectionIn
    --           , mayBeNull = True
    --           , argDoc =
    --               Documentation
    --                 { rawDocText = Just "user data to pass to @match_func"
    --                 , sinceVersion = Nothing
    --                 }
    --           , argScope = ScopeTypeInvalid
    --           , argClosure = -1
    --           , argDestroy = -1
    --           , argCallerAllocates = False
    --           , argCallbackUserData = False
    --           , transfer = TransferNothing
    --           }
    --       , Arg
    --           { argCName = "user_destroy"
    --           , argType =
    --               TInterface Name { namespace = "GLib" , name = "DestroyNotify" }
    --           , argCType = Just "GDestroyNotify"
    --           , direction = DirectionIn
    --           , mayBeNull = False
    --           , argDoc =
    --               Documentation
    --                 { rawDocText = Just "destroy notify for @user_data"
    --                 , sinceVersion = Nothing
    --                 }
    --           , argScope = ScopeTypeAsync
    --           , argClosure = -1
    --           , argDestroy = -1
    --           , argCallerAllocates = False
    --           , argCallbackUserData = False
    --           , transfer = TransferNothing
    --           }
    --       ]
    -- Lengths: []
    -- returnType: Nothing
    -- throws : False
    -- Skip return : False

    foreign import ccall "gtk_custom_sorter_set_sort_func" gtk_custom_sorter_set_sort_func ::
        Ptr CustomSorter ->                     -- self : TInterface (Name {namespace = "Gtk", name = "CustomSorter"})
        FunPtr GLib.Callbacks.C_CompareDataFunc -> -- sort_func : TInterface (Name {namespace = "GLib", name = "CompareDataFunc"})
        Ptr () ->                               -- user_data : TBasicType TPtr
        FunPtr GLib.Callbacks.C_DestroyNotify -> -- user_destroy : TInterface (Name {namespace = "GLib", name = "DestroyNotify"})
        IO ()

    -- | Sets (or unsets) the function used for sorting items.
    --
    -- If /@sortFunc@/ is 'P.Nothing', all items are considered equal.
    --
    -- If the sort func changes its sorting behavior,
    -- 'GI.Gtk.Objects.Sorter.sorterChanged' needs to be called.
    --
    -- If a previous function was set, its /@userDestroy@/ will be
    -- called now.
    customSorterSetSortFunc ::
        (B.CallStack.HasCallStack, MonadIO m, IsCustomSorter a) =>
        a
        -- ^ /@self@/: a @GtkCustomSorter@
        -> Maybe (GLib.Callbacks.CompareDataFunc)
        -- ^ /@sortFunc@/: function to sort items
        -> m ()
    customSorterSetSortFunc :: forall (m :: * -> *) a.
    (HasCallStack, MonadIO m, IsCustomSorter a) =>
    a -> Maybe CompareDataFunc -> m ()
    customSorterSetSortFunc a
    self Maybe CompareDataFunc
    sortFunc = IO () -> m ()
    forall a. IO a -> m a
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
    liftIO (IO () -> m ()) -> IO () -> m ()
    forall a b. (a -> b) -> a -> b
    $ do
        self' <- a -> IO (Ptr CustomSorter)
    forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
    unsafeManagedPtrCastPtr a
    self
        maybeSortFunc <- case sortFunc of
            Maybe CompareDataFunc
    Nothing -> FunPtr C_CompareDataFunc -> IO (FunPtr C_CompareDataFunc)
    forall a. a -> IO a
    forall (m :: * -> *) a. Monad m => a -> m a
    return FunPtr C_CompareDataFunc
    forall a. FunPtr a
    FP.nullFunPtr
            Just CompareDataFunc
    jSortFunc -> do
                jSortFunc' <- C_CompareDataFunc -> IO (FunPtr C_CompareDataFunc)
    GLib.Callbacks.mk_CompareDataFunc (Maybe (Ptr (FunPtr C_CompareDataFunc))
    -> C_CompareDataFunc -> C_CompareDataFunc
    GLib.Callbacks.wrap_CompareDataFunc Maybe (Ptr (FunPtr C_CompareDataFunc))
    forall a. Maybe a
    Nothing (CompareDataFunc -> C_CompareDataFunc
    GLib.Callbacks.drop_closures_CompareDataFunc CompareDataFunc
    jSortFunc))
                return jSortFunc'
        let userData = FunPtr C_CompareDataFunc -> Ptr ()
    forall a b. FunPtr a -> Ptr b
    castFunPtrToPtr FunPtr C_CompareDataFunc
    maybeSortFunc
        let userDestroy = FunPtr (Ptr a -> IO ())
    forall a. FunPtr (Ptr a -> IO ())
    SP.safeFreeFunPtrPtr
        gtk_custom_sorter_set_sort_func self' maybeSortFunc userData userDestroy
        touchManagedPtr self
        return ()

    #if defined(ENABLE_OVERLOADING)
    data CustomSorterSetSortFuncMethodInfo
    instance (signature ~ (Maybe (GLib.Callbacks.CompareDataFunc) -> m ()), MonadIO m, IsCustomSorter a) => O.OverloadedMethod CustomSorterSetSortFuncMethodInfo a signature where
        overloadedMethod = customSorterSetSortFunc

    instance O.OverloadedMethodInfo CustomSorterSetSortFuncMethodInfo a where
        overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
            O.resolvedSymbolName = "GI.Gtk.Objects.CustomSorter.customSorterSetSortFunc",
            O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-gtk4-4.0.12/docs/GI-Gtk-Objects-CustomSorter.html#v:customSorterSetSortFunc"
            })

    #endif