{-# LANGUAGE TypeApplications #-}


-- | Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
-- License    : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria
-- 
-- A t'GI.Gtk.Objects.Filter.Filter' object describes the filtering to be performed by a
-- t'GI.Gtk.Objects.FilterListModel.FilterListModel'.
-- 
-- The model will use the filter to determine if it should include items
-- or not by calling 'GI.Gtk.Objects.Filter.filterMatch' for each item and only keeping the
-- ones that the function returns 'P.True' for.
-- 
-- Filters may change what items they match through their lifetime. In that
-- case, they will emit the [changed]("GI.Gtk.Objects.Filter#g:signal:changed") signal to notify that previous
-- filter results are no longer valid and that items should be checked again
-- via 'GI.Gtk.Objects.Filter.filterMatch'.
-- 
-- GTK provides various pre-made filter implementations for common filtering
-- operations. These filters often include properties that can be linked to
-- various widgets to easily allow searches.
-- 
-- However, in particular for large lists or complex search methods, it is
-- also possible to subclass t'GI.Gtk.Objects.Filter.Filter' and provide one\'s own filter.

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

module GI.Gtk.Objects.Filter
    ( 

-- * Exported types
    Filter(..)                              ,
    IsFilter                                ,
    toFilter                                ,


 -- * 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.Filter#g:method:changed"), [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"), [match]("GI.Gtk.Objects.Filter#g:method:match"), [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"), [getProperty]("GI.GObject.Objects.Object#g:method:getProperty"), [getQdata]("GI.GObject.Objects.Object#g:method:getQdata"), [getStrictness]("GI.Gtk.Objects.Filter#g:method:getStrictness").
-- 
-- ==== 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").

#if defined(ENABLE_OVERLOADING)
    ResolveFilterMethod                     ,
#endif

-- ** changed #method:changed#

#if defined(ENABLE_OVERLOADING)
    FilterChangedMethodInfo                 ,
#endif
    filterChanged                           ,


-- ** getStrictness #method:getStrictness#

#if defined(ENABLE_OVERLOADING)
    FilterGetStrictnessMethodInfo           ,
#endif
    filterGetStrictness                     ,


-- ** match #method:match#

#if defined(ENABLE_OVERLOADING)
    FilterMatchMethodInfo                   ,
#endif
    filterMatch                             ,




 -- * Signals


-- ** changed #signal:changed#

    C_FilterChangedCallback                 ,
    FilterChangedCallback                   ,
#if defined(ENABLE_OVERLOADING)
    FilterChangedSignalInfo                 ,
#endif
    afterFilterChanged                      ,
    genClosure_FilterChanged                ,
    mk_FilterChangedCallback                ,
    noFilterChangedCallback                 ,
    onFilterChanged                         ,
    wrap_FilterChangedCallback              ,




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

import qualified GI.GObject.Objects.Object as GObject.Object
import {-# SOURCE #-} qualified GI.Gtk.Enums as Gtk.Enums

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

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

foreign import ccall "gtk_filter_get_type"
    c_gtk_filter_get_type :: IO B.Types.GType

instance B.Types.TypedObject Filter where
    glibType :: IO GType
glibType = IO GType
c_gtk_filter_get_type

instance B.Types.GObject Filter

-- | Type class for types which can be safely cast to `Filter`, for instance with `toFilter`.
class (SP.GObject o, O.IsDescendantOf Filter o) => IsFilter o
instance (SP.GObject o, O.IsDescendantOf Filter o) => IsFilter o

instance O.HasParentTypes Filter
type instance O.ParentTypes Filter = '[GObject.Object.Object]

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

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

#if defined(ENABLE_OVERLOADING)
type family ResolveFilterMethod (t :: Symbol) (o :: *) :: * where
    ResolveFilterMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveFilterMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveFilterMethod "changed" o = FilterChangedMethodInfo
    ResolveFilterMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveFilterMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveFilterMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
    ResolveFilterMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveFilterMethod "match" o = FilterMatchMethodInfo
    ResolveFilterMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveFilterMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveFilterMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveFilterMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveFilterMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveFilterMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveFilterMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveFilterMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveFilterMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveFilterMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveFilterMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveFilterMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveFilterMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveFilterMethod "getStrictness" o = FilterGetStrictnessMethodInfo
    ResolveFilterMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveFilterMethod "setDataFull" o = GObject.Object.ObjectSetDataFullMethodInfo
    ResolveFilterMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveFilterMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveFilterMethod t Filter, O.OverloadedMethod info Filter p) => OL.IsLabel t (Filter -> 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 ~ ResolveFilterMethod t Filter, O.OverloadedMethod info Filter p, R.HasField t Filter p) => R.HasField t Filter p where
    getField = O.overloadedMethod @info

#endif

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

#endif

-- signal Filter::changed
-- | This signal is emitted whenever the filter changed. Users of the filter
-- should then check items again via 'GI.Gtk.Objects.Filter.filterMatch'.
-- 
-- t'GI.Gtk.Objects.FilterListModel.FilterListModel' handles this signal automatically.
-- 
-- Depending on the /@change@/ parameter, not all items need to be changed, but
-- only some. Refer to the t'GI.Gtk.Enums.FilterChange' documentation for details.
type FilterChangedCallback =
    Gtk.Enums.FilterChange
    -- ^ /@change@/: how the filter changed
    -> IO ()

-- | A convenience synonym for @`Nothing` :: `Maybe` `FilterChangedCallback`@.
noFilterChangedCallback :: Maybe FilterChangedCallback
noFilterChangedCallback :: Maybe FilterChangedCallback
noFilterChangedCallback = Maybe FilterChangedCallback
forall a. Maybe a
Nothing

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

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

-- | Wrap the callback into a `GClosure`.
genClosure_FilterChanged :: MonadIO m => FilterChangedCallback -> m (GClosure C_FilterChangedCallback)
genClosure_FilterChanged :: forall (m :: * -> *).
MonadIO m =>
FilterChangedCallback -> m (GClosure C_FilterChangedCallback)
genClosure_FilterChanged FilterChangedCallback
cb = IO (GClosure C_FilterChangedCallback)
-> m (GClosure C_FilterChangedCallback)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (GClosure C_FilterChangedCallback)
 -> m (GClosure C_FilterChangedCallback))
-> IO (GClosure C_FilterChangedCallback)
-> m (GClosure C_FilterChangedCallback)
forall a b. (a -> b) -> a -> b
$ do
    let cb' :: C_FilterChangedCallback
cb' = FilterChangedCallback -> C_FilterChangedCallback
wrap_FilterChangedCallback FilterChangedCallback
cb
    C_FilterChangedCallback -> IO (FunPtr C_FilterChangedCallback)
mk_FilterChangedCallback C_FilterChangedCallback
cb' IO (FunPtr C_FilterChangedCallback)
-> (FunPtr C_FilterChangedCallback
    -> IO (GClosure C_FilterChangedCallback))
-> IO (GClosure C_FilterChangedCallback)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= FunPtr C_FilterChangedCallback
-> IO (GClosure C_FilterChangedCallback)
forall (m :: * -> *) a. MonadIO m => FunPtr a -> m (GClosure a)
B.GClosure.newGClosure


-- | Wrap a `FilterChangedCallback` into a `C_FilterChangedCallback`.
wrap_FilterChangedCallback ::
    FilterChangedCallback ->
    C_FilterChangedCallback
wrap_FilterChangedCallback :: FilterChangedCallback -> C_FilterChangedCallback
wrap_FilterChangedCallback FilterChangedCallback
_cb Ptr ()
_ CUInt
change Ptr ()
_ = do
    let change' :: FilterChange
change' = (Int -> FilterChange
forall a. Enum a => Int -> a
toEnum (Int -> FilterChange) -> (CUInt -> Int) -> CUInt -> FilterChange
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CUInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral) CUInt
change
    FilterChangedCallback
_cb  FilterChange
change'


-- | Connect a signal handler for the [changed](#signal:changed) 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' filter #changed callback
-- @
-- 
-- 
onFilterChanged :: (IsFilter a, MonadIO m) => a -> FilterChangedCallback -> m SignalHandlerId
onFilterChanged :: forall a (m :: * -> *).
(IsFilter a, MonadIO m) =>
a -> FilterChangedCallback -> m SignalHandlerId
onFilterChanged a
obj FilterChangedCallback
cb = IO SignalHandlerId -> m SignalHandlerId
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO SignalHandlerId -> m SignalHandlerId)
-> IO SignalHandlerId -> m SignalHandlerId
forall a b. (a -> b) -> a -> b
$ do
    let cb' :: C_FilterChangedCallback
cb' = FilterChangedCallback -> C_FilterChangedCallback
wrap_FilterChangedCallback FilterChangedCallback
cb
    FunPtr C_FilterChangedCallback
cb'' <- C_FilterChangedCallback -> IO (FunPtr C_FilterChangedCallback)
mk_FilterChangedCallback C_FilterChangedCallback
cb'
    a
-> Text
-> FunPtr C_FilterChangedCallback
-> SignalConnectMode
-> Maybe Text
-> IO SignalHandlerId
forall o a.
GObject o =>
o
-> Text
-> FunPtr a
-> SignalConnectMode
-> Maybe Text
-> IO SignalHandlerId
connectSignalFunPtr a
obj Text
"changed" FunPtr C_FilterChangedCallback
cb'' SignalConnectMode
SignalConnectBefore Maybe Text
forall a. Maybe a
Nothing

-- | Connect a signal handler for the [changed](#signal:changed) 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' filter #changed callback
-- @
-- 
-- 
afterFilterChanged :: (IsFilter a, MonadIO m) => a -> FilterChangedCallback -> m SignalHandlerId
afterFilterChanged :: forall a (m :: * -> *).
(IsFilter a, MonadIO m) =>
a -> FilterChangedCallback -> m SignalHandlerId
afterFilterChanged a
obj FilterChangedCallback
cb = IO SignalHandlerId -> m SignalHandlerId
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO SignalHandlerId -> m SignalHandlerId)
-> IO SignalHandlerId -> m SignalHandlerId
forall a b. (a -> b) -> a -> b
$ do
    let cb' :: C_FilterChangedCallback
cb' = FilterChangedCallback -> C_FilterChangedCallback
wrap_FilterChangedCallback FilterChangedCallback
cb
    FunPtr C_FilterChangedCallback
cb'' <- C_FilterChangedCallback -> IO (FunPtr C_FilterChangedCallback)
mk_FilterChangedCallback C_FilterChangedCallback
cb'
    a
-> Text
-> FunPtr C_FilterChangedCallback
-> SignalConnectMode
-> Maybe Text
-> IO SignalHandlerId
forall o a.
GObject o =>
o
-> Text
-> FunPtr a
-> SignalConnectMode
-> Maybe Text
-> IO SignalHandlerId
connectSignalFunPtr a
obj Text
"changed" FunPtr C_FilterChangedCallback
cb'' SignalConnectMode
SignalConnectAfter Maybe Text
forall a. Maybe a
Nothing


#if defined(ENABLE_OVERLOADING)
data FilterChangedSignalInfo
instance SignalInfo FilterChangedSignalInfo where
    type HaskellCallbackType FilterChangedSignalInfo = FilterChangedCallback
    connectSignal obj cb connectMode detail = do
        let cb' = wrap_FilterChangedCallback cb
        cb'' <- mk_FilterChangedCallback cb'
        connectSignalFunPtr obj "changed" cb'' connectMode detail

#endif

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

#if defined(ENABLE_OVERLOADING)
#endif

#if defined(ENABLE_OVERLOADING)
type instance O.SignalList Filter = FilterSignalList
type FilterSignalList = ('[ '("changed", FilterChangedSignalInfo), '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])

#endif

-- method Filter::changed
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "self"
--           , argType = TInterface Name { namespace = "Gtk" , name = "Filter" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GtkFilter" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "change"
--           , argType =
--               TInterface Name { namespace = "Gtk" , name = "FilterChange" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "How the filter changed"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gtk_filter_changed" gtk_filter_changed :: 
    Ptr Filter ->                           -- self : TInterface (Name {namespace = "Gtk", name = "Filter"})
    CUInt ->                                -- change : TInterface (Name {namespace = "Gtk", name = "FilterChange"})
    IO ()

-- | Emits the [changed]("GI.Gtk.Objects.Filter#g:signal:changed") signal to notify all users of the filter that
-- the filter changed. Users of the filter should then check items again via
-- 'GI.Gtk.Objects.Filter.filterMatch'.
-- 
-- Depending on the /@change@/ parameter, not all items need to be changed, but
-- only some. Refer to the t'GI.Gtk.Enums.FilterChange' documentation for details.
-- 
-- This function is intended for implementors of t'GI.Gtk.Objects.Filter.Filter' subclasses and
-- should not be called from other functions.
filterChanged ::
    (B.CallStack.HasCallStack, MonadIO m, IsFilter a) =>
    a
    -- ^ /@self@/: a t'GI.Gtk.Objects.Filter.Filter'
    -> Gtk.Enums.FilterChange
    -- ^ /@change@/: How the filter changed
    -> m ()
filterChanged :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsFilter a) =>
a -> FilterChange -> m ()
filterChanged a
self FilterChange
change = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr Filter
self' <- a -> IO (Ptr Filter)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
self
    let change' :: CUInt
change' = (Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CUInt) -> (FilterChange -> Int) -> FilterChange -> CUInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FilterChange -> Int
forall a. Enum a => a -> Int
fromEnum) FilterChange
change
    Ptr Filter -> CUInt -> IO ()
gtk_filter_changed Ptr Filter
self' CUInt
change'
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
self
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if defined(ENABLE_OVERLOADING)
data FilterChangedMethodInfo
instance (signature ~ (Gtk.Enums.FilterChange -> m ()), MonadIO m, IsFilter a) => O.OverloadedMethod FilterChangedMethodInfo a signature where
    overloadedMethod = filterChanged

instance O.OverloadedMethodInfo FilterChangedMethodInfo a where
    overloadedMethodInfo = O.MethodInfo {
        O.overloadedMethodName = "GI.Gtk.Objects.Filter.filterChanged",
        O.overloadedMethodURL = "https://hackage.haskell.org/package/gi-gtk-4.0.4/docs/GI-Gtk-Objects-Filter.html#v:filterChanged"
        }


#endif

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

foreign import ccall "gtk_filter_get_strictness" gtk_filter_get_strictness :: 
    Ptr Filter ->                           -- self : TInterface (Name {namespace = "Gtk", name = "Filter"})
    IO CUInt

-- | Gets the known strictness of /@filters@/. If the strictness is not known,
-- 'GI.Gtk.Enums.FilterMatchSome' is returned.
-- 
-- This value may change after emission of the [changed]("GI.Gtk.Objects.Filter#g:signal:changed") signal.
-- 
-- This function is meant purely for optimization purposes, filters can
-- choose to omit implementing it, but t'GI.Gtk.Objects.FilterListModel.FilterListModel' uses it.
filterGetStrictness ::
    (B.CallStack.HasCallStack, MonadIO m, IsFilter a) =>
    a
    -- ^ /@self@/: a t'GI.Gtk.Objects.Filter.Filter'
    -> m Gtk.Enums.FilterMatch
    -- ^ __Returns:__ the strictness of /@self@/
filterGetStrictness :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsFilter a) =>
a -> m FilterMatch
filterGetStrictness a
self = IO FilterMatch -> m FilterMatch
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO FilterMatch -> m FilterMatch)
-> IO FilterMatch -> m FilterMatch
forall a b. (a -> b) -> a -> b
$ do
    Ptr Filter
self' <- a -> IO (Ptr Filter)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
self
    CUInt
result <- Ptr Filter -> IO CUInt
gtk_filter_get_strictness Ptr Filter
self'
    let result' :: FilterMatch
result' = (Int -> FilterMatch
forall a. Enum a => Int -> a
toEnum (Int -> FilterMatch) -> (CUInt -> Int) -> CUInt -> FilterMatch
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CUInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral) CUInt
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
self
    FilterMatch -> IO FilterMatch
forall (m :: * -> *) a. Monad m => a -> m a
return FilterMatch
result'

#if defined(ENABLE_OVERLOADING)
data FilterGetStrictnessMethodInfo
instance (signature ~ (m Gtk.Enums.FilterMatch), MonadIO m, IsFilter a) => O.OverloadedMethod FilterGetStrictnessMethodInfo a signature where
    overloadedMethod = filterGetStrictness

instance O.OverloadedMethodInfo FilterGetStrictnessMethodInfo a where
    overloadedMethodInfo = O.MethodInfo {
        O.overloadedMethodName = "GI.Gtk.Objects.Filter.filterGetStrictness",
        O.overloadedMethodURL = "https://hackage.haskell.org/package/gi-gtk-4.0.4/docs/GI-Gtk-Objects-Filter.html#v:filterGetStrictness"
        }


#endif

-- method Filter::match
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "self"
--           , argType = TInterface Name { namespace = "Gtk" , name = "Filter" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GtkFilter" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "item"
--           , argType =
--               TInterface Name { namespace = "GObject" , name = "Object" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "The item to check" , 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_filter_match" gtk_filter_match :: 
    Ptr Filter ->                           -- self : TInterface (Name {namespace = "Gtk", name = "Filter"})
    Ptr GObject.Object.Object ->            -- item : TInterface (Name {namespace = "GObject", name = "Object"})
    IO CInt

-- | Checks if the given /@item@/ is matched by the filter or not.
filterMatch ::
    (B.CallStack.HasCallStack, MonadIO m, IsFilter a, GObject.Object.IsObject b) =>
    a
    -- ^ /@self@/: a t'GI.Gtk.Objects.Filter.Filter'
    -> b
    -- ^ /@item@/: The item to check
    -> m Bool
    -- ^ __Returns:__ 'P.True' if the filter matches the item and a filter model should
    --     keep it, 'P.False' if not.
filterMatch :: forall (m :: * -> *) a b.
(HasCallStack, MonadIO m, IsFilter a, IsObject b) =>
a -> b -> m Bool
filterMatch a
self b
item = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    Ptr Filter
self' <- a -> IO (Ptr Filter)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
self
    Ptr Object
item' <- b -> IO (Ptr Object)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
item
    CInt
result <- Ptr Filter -> Ptr Object -> IO CInt
gtk_filter_match Ptr Filter
self' Ptr Object
item'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
self
    b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr b
item
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'

#if defined(ENABLE_OVERLOADING)
data FilterMatchMethodInfo
instance (signature ~ (b -> m Bool), MonadIO m, IsFilter a, GObject.Object.IsObject b) => O.OverloadedMethod FilterMatchMethodInfo a signature where
    overloadedMethod = filterMatch

instance O.OverloadedMethodInfo FilterMatchMethodInfo a where
    overloadedMethodInfo = O.MethodInfo {
        O.overloadedMethodName = "GI.Gtk.Objects.Filter.filterMatch",
        O.overloadedMethodURL = "https://hackage.haskell.org/package/gi-gtk-4.0.4/docs/GI-Gtk-Objects-Filter.html#v:filterMatch"
        }


#endif