{-# LANGUAGE TypeApplications #-}


-- | Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
-- License    : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria
-- 
-- t'GI.Gio.Objects.DBusActionGroup.DBusActionGroup' is an implementation of the t'GI.Gio.Interfaces.ActionGroup.ActionGroup'
-- interface that can be used as a proxy for an action group
-- that is exported over D-Bus with 'GI.Gio.Objects.DBusConnection.dBusConnectionExportActionGroup'.

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

module GI.Gio.Objects.DBusActionGroup
    ( 

-- * Exported types
    DBusActionGroup(..)                     ,
    IsDBusActionGroup                       ,
    toDBusActionGroup                       ,


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

#if defined(ENABLE_OVERLOADING)
    ResolveDBusActionGroupMethod            ,
#endif


-- ** get #method:get#

    dBusActionGroupGet                      ,




    ) 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.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 GI.GObject.Objects.Object as GObject.Object
import {-# SOURCE #-} qualified GI.Gio.Interfaces.ActionGroup as Gio.ActionGroup
import {-# SOURCE #-} qualified GI.Gio.Interfaces.RemoteActionGroup as Gio.RemoteActionGroup
import {-# SOURCE #-} qualified GI.Gio.Objects.DBusConnection as Gio.DBusConnection

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

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

foreign import ccall "g_dbus_action_group_get_type"
    c_g_dbus_action_group_get_type :: IO B.Types.GType

instance B.Types.TypedObject DBusActionGroup where
    glibType :: IO GType
glibType = IO GType
c_g_dbus_action_group_get_type

instance B.Types.GObject DBusActionGroup

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

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

instance O.HasParentTypes DBusActionGroup
type instance O.ParentTypes DBusActionGroup = '[GObject.Object.Object, Gio.ActionGroup.ActionGroup, Gio.RemoteActionGroup.RemoteActionGroup]

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

#if defined(ENABLE_OVERLOADING)
type family ResolveDBusActionGroupMethod (t :: Symbol) (o :: *) :: * where
    ResolveDBusActionGroupMethod "actionAdded" o = Gio.ActionGroup.ActionGroupActionAddedMethodInfo
    ResolveDBusActionGroupMethod "actionEnabledChanged" o = Gio.ActionGroup.ActionGroupActionEnabledChangedMethodInfo
    ResolveDBusActionGroupMethod "actionRemoved" o = Gio.ActionGroup.ActionGroupActionRemovedMethodInfo
    ResolveDBusActionGroupMethod "actionStateChanged" o = Gio.ActionGroup.ActionGroupActionStateChangedMethodInfo
    ResolveDBusActionGroupMethod "activateAction" o = Gio.ActionGroup.ActionGroupActivateActionMethodInfo
    ResolveDBusActionGroupMethod "activateActionFull" o = Gio.RemoteActionGroup.RemoteActionGroupActivateActionFullMethodInfo
    ResolveDBusActionGroupMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveDBusActionGroupMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveDBusActionGroupMethod "changeActionState" o = Gio.ActionGroup.ActionGroupChangeActionStateMethodInfo
    ResolveDBusActionGroupMethod "changeActionStateFull" o = Gio.RemoteActionGroup.RemoteActionGroupChangeActionStateFullMethodInfo
    ResolveDBusActionGroupMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveDBusActionGroupMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveDBusActionGroupMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
    ResolveDBusActionGroupMethod "hasAction" o = Gio.ActionGroup.ActionGroupHasActionMethodInfo
    ResolveDBusActionGroupMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveDBusActionGroupMethod "listActions" o = Gio.ActionGroup.ActionGroupListActionsMethodInfo
    ResolveDBusActionGroupMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveDBusActionGroupMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveDBusActionGroupMethod "queryAction" o = Gio.ActionGroup.ActionGroupQueryActionMethodInfo
    ResolveDBusActionGroupMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveDBusActionGroupMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveDBusActionGroupMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveDBusActionGroupMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveDBusActionGroupMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveDBusActionGroupMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveDBusActionGroupMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveDBusActionGroupMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveDBusActionGroupMethod "getActionEnabled" o = Gio.ActionGroup.ActionGroupGetActionEnabledMethodInfo
    ResolveDBusActionGroupMethod "getActionParameterType" o = Gio.ActionGroup.ActionGroupGetActionParameterTypeMethodInfo
    ResolveDBusActionGroupMethod "getActionState" o = Gio.ActionGroup.ActionGroupGetActionStateMethodInfo
    ResolveDBusActionGroupMethod "getActionStateHint" o = Gio.ActionGroup.ActionGroupGetActionStateHintMethodInfo
    ResolveDBusActionGroupMethod "getActionStateType" o = Gio.ActionGroup.ActionGroupGetActionStateTypeMethodInfo
    ResolveDBusActionGroupMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveDBusActionGroupMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveDBusActionGroupMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveDBusActionGroupMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveDBusActionGroupMethod "setDataFull" o = GObject.Object.ObjectSetDataFullMethodInfo
    ResolveDBusActionGroupMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveDBusActionGroupMethod l o = O.MethodResolutionFailed l o

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

#endif

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

#if defined(ENABLE_OVERLOADING)
#endif

#if defined(ENABLE_OVERLOADING)
type instance O.SignalList DBusActionGroup = DBusActionGroupSignalList
type DBusActionGroupSignalList = ('[ '("actionAdded", Gio.ActionGroup.ActionGroupActionAddedSignalInfo), '("actionEnabledChanged", Gio.ActionGroup.ActionGroupActionEnabledChangedSignalInfo), '("actionRemoved", Gio.ActionGroup.ActionGroupActionRemovedSignalInfo), '("actionStateChanged", Gio.ActionGroup.ActionGroupActionStateChangedSignalInfo), '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])

#endif

-- method DBusActionGroup::get
-- method type : MemberFunction
-- Args: [ Arg
--           { argCName = "connection"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "DBusConnection" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "A #GDBusConnection" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "bus_name"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "the bus name which exports the action\n    group or %NULL if @connection is not a message bus connection"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "object_path"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "the object path at which the action group is exported"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just
--               (TInterface Name { namespace = "Gio" , name = "DBusActionGroup" })
-- throws : False
-- Skip return : False

foreign import ccall "g_dbus_action_group_get" g_dbus_action_group_get :: 
    Ptr Gio.DBusConnection.DBusConnection -> -- connection : TInterface (Name {namespace = "Gio", name = "DBusConnection"})
    CString ->                              -- bus_name : TBasicType TUTF8
    CString ->                              -- object_path : TBasicType TUTF8
    IO (Ptr DBusActionGroup)

-- | Obtains a t'GI.Gio.Objects.DBusActionGroup.DBusActionGroup' for the action group which is exported at
-- the given /@busName@/ and /@objectPath@/.
-- 
-- The thread default main context is taken at the time of this call.
-- All signals on the menu model (and any linked models) are reported
-- with respect to this context.  All calls on the returned menu model
-- (and linked models) must also originate from this same context, with
-- the thread default main context unchanged.
-- 
-- This call is non-blocking.  The returned action group may or may not
-- already be filled in.  The correct thing to do is connect the signals
-- for the action group to monitor for changes and then to call
-- 'GI.Gio.Interfaces.ActionGroup.actionGroupListActions' to get the initial list.
-- 
-- /Since: 2.32/
dBusActionGroupGet ::
    (B.CallStack.HasCallStack, MonadIO m, Gio.DBusConnection.IsDBusConnection a) =>
    a
    -- ^ /@connection@/: A t'GI.Gio.Objects.DBusConnection.DBusConnection'
    -> Maybe (T.Text)
    -- ^ /@busName@/: the bus name which exports the action
    --     group or 'P.Nothing' if /@connection@/ is not a message bus connection
    -> T.Text
    -- ^ /@objectPath@/: the object path at which the action group is exported
    -> m DBusActionGroup
    -- ^ __Returns:__ a t'GI.Gio.Objects.DBusActionGroup.DBusActionGroup'
dBusActionGroupGet :: a -> Maybe Text -> Text -> m DBusActionGroup
dBusActionGroupGet a
connection Maybe Text
busName Text
objectPath = IO DBusActionGroup -> m DBusActionGroup
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO DBusActionGroup -> m DBusActionGroup)
-> IO DBusActionGroup -> m DBusActionGroup
forall a b. (a -> b) -> a -> b
$ do
    Ptr DBusConnection
connection' <- a -> IO (Ptr DBusConnection)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
connection
    Ptr CChar
maybeBusName <- case Maybe Text
busName of
        Maybe Text
Nothing -> Ptr CChar -> IO (Ptr CChar)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr CChar
forall a. Ptr a
nullPtr
        Just Text
jBusName -> do
            Ptr CChar
jBusName' <- Text -> IO (Ptr CChar)
textToCString Text
jBusName
            Ptr CChar -> IO (Ptr CChar)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr CChar
jBusName'
    Ptr CChar
objectPath' <- Text -> IO (Ptr CChar)
textToCString Text
objectPath
    Ptr DBusActionGroup
result <- Ptr DBusConnection
-> Ptr CChar -> Ptr CChar -> IO (Ptr DBusActionGroup)
g_dbus_action_group_get Ptr DBusConnection
connection' Ptr CChar
maybeBusName Ptr CChar
objectPath'
    Text -> Ptr DBusActionGroup -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"dBusActionGroupGet" Ptr DBusActionGroup
result
    DBusActionGroup
result' <- ((ManagedPtr DBusActionGroup -> DBusActionGroup)
-> Ptr DBusActionGroup -> IO DBusActionGroup
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
wrapObject ManagedPtr DBusActionGroup -> DBusActionGroup
DBusActionGroup) Ptr DBusActionGroup
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
connection
    Ptr CChar -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CChar
maybeBusName
    Ptr CChar -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CChar
objectPath'
    DBusActionGroup -> IO DBusActionGroup
forall (m :: * -> *) a. Monad m => a -> m a
return DBusActionGroup
result'

#if defined(ENABLE_OVERLOADING)
#endif