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

Activatable widgets can be connected to a 'GI.Gtk.Objects.Action.Action' and reflects
the state of its action. A 'GI.Gtk.Interfaces.Activatable.Activatable' can also provide feedback
through its action, as they are responsible for activating their
related actions.

= Implementing GtkActivatable

When extending a class that is already 'GI.Gtk.Interfaces.Activatable.Activatable'; it is only
necessary to implement the 'GI.Gtk.Interfaces.Activatable.Activatable'->@/sync_action_properties()/@
and 'GI.Gtk.Interfaces.Activatable.Activatable'->@/update()/@ methods and chain up to the parent
implementation, however when introducing
a new 'GI.Gtk.Interfaces.Activatable.Activatable' class; the 'GI.Gtk.Interfaces.Activatable.Activatable':@/related-action/@ and
'GI.Gtk.Interfaces.Activatable.Activatable':@/use-action-appearance/@ properties need to be handled by
the implementor. Handling these properties is mostly a matter of installing
the action pointer and boolean flag on your instance, and calling
'GI.Gtk.Interfaces.Activatable.activatableDoSetRelatedAction' and
'GI.Gtk.Interfaces.Activatable.activatableSyncActionProperties' at the appropriate times.

## A class fragment implementing 'GI.Gtk.Interfaces.Activatable.Activatable'


=== /C code/
>
>
>enum {
>...
>
>PROP_ACTIVATABLE_RELATED_ACTION,
>PROP_ACTIVATABLE_USE_ACTION_APPEARANCE
>}
>
>struct _FooBarPrivate
>{
>
>  ...
>
>  GtkAction      *action;
>  gboolean        use_action_appearance;
>};
>
>...
>
>static void foo_bar_activatable_interface_init         (GtkActivatableIface  *iface);
>static void foo_bar_activatable_update                 (GtkActivatable       *activatable,
>						           GtkAction            *action,
>						           const gchar          *property_name);
>static void foo_bar_activatable_sync_action_properties (GtkActivatable       *activatable,
>						           GtkAction            *action);
>...
>
>
>static void
>foo_bar_class_init (FooBarClass *klass)
>{
>
>  ...
>
>  g_object_class_override_property (gobject_class, PROP_ACTIVATABLE_RELATED_ACTION, "related-action");
>  g_object_class_override_property (gobject_class, PROP_ACTIVATABLE_USE_ACTION_APPEARANCE, "use-action-appearance");
>
>  ...
>}
>
>
>static void
>foo_bar_activatable_interface_init (GtkActivatableIface  *iface)
>{
>  iface->update = foo_bar_activatable_update;
>  iface->sync_action_properties = foo_bar_activatable_sync_action_properties;
>}
>
>... Break the reference using gtk_activatable_do_set_related_action()...
>
>static void
>foo_bar_dispose (GObject *object)
>{
>  FooBar *bar = FOO_BAR (object);
>  FooBarPrivate *priv = FOO_BAR_GET_PRIVATE (bar);
>
>  ...
>
>  if (priv->action)
>    {
>      gtk_activatable_do_set_related_action (GTK_ACTIVATABLE (bar), NULL);
>      priv->action = NULL;
>    }
>  G_OBJECT_CLASS (foo_bar_parent_class)->dispose (object);
>}
>
>... Handle the “related-action” and “use-action-appearance” properties ...
>
>static void
>foo_bar_set_property (GObject         *object,
>                      guint            prop_id,
>                      const GValue    *value,
>                      GParamSpec      *pspec)
>{
>  FooBar *bar = FOO_BAR (object);
>  FooBarPrivate *priv = FOO_BAR_GET_PRIVATE (bar);
>
>  switch (prop_id)
>    {
>
>      ...
>
>    case PROP_ACTIVATABLE_RELATED_ACTION:
>      foo_bar_set_related_action (bar, g_value_get_object (value));
>      break;
>    case PROP_ACTIVATABLE_USE_ACTION_APPEARANCE:
>      foo_bar_set_use_action_appearance (bar, g_value_get_boolean (value));
>      break;
>    default:
>      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
>      break;
>    }
>}
>
>static void
>foo_bar_get_property (GObject         *object,
>                         guint            prop_id,
>                         GValue          *value,
>                         GParamSpec      *pspec)
>{
>  FooBar *bar = FOO_BAR (object);
>  FooBarPrivate *priv = FOO_BAR_GET_PRIVATE (bar);
>
>  switch (prop_id)
>    {
>
>      ...
>
>    case PROP_ACTIVATABLE_RELATED_ACTION:
>      g_value_set_object (value, priv->action);
>      break;
>    case PROP_ACTIVATABLE_USE_ACTION_APPEARANCE:
>      g_value_set_boolean (value, priv->use_action_appearance);
>      break;
>    default:
>      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
>      break;
>    }
>}
>
>
>static void
>foo_bar_set_use_action_appearance (FooBar   *bar,
>				   gboolean  use_appearance)
>{
>  FooBarPrivate *priv = FOO_BAR_GET_PRIVATE (bar);
>
>  if (priv->use_action_appearance != use_appearance)
>    {
>      priv->use_action_appearance = use_appearance;
>      
>      gtk_activatable_sync_action_properties (GTK_ACTIVATABLE (bar), priv->action);
>    }
>}
>
>... call gtk_activatable_do_set_related_action() and then assign the action pointer,
>no need to reference the action here since gtk_activatable_do_set_related_action() already
>holds a reference here for you...
>static void
>foo_bar_set_related_action (FooBar    *bar,
>			    GtkAction *action)
>{
>  FooBarPrivate *priv = FOO_BAR_GET_PRIVATE (bar);
>
>  if (priv->action == action)
>    return;
>
>  gtk_activatable_do_set_related_action (GTK_ACTIVATABLE (bar), action);
>
>  priv->action = action;
>}
>
>... Selectively reset and update activatable depending on the use-action-appearance property ...
>static void
>gtk_button_activatable_sync_action_properties (GtkActivatable       *activatable,
>		                                  GtkAction            *action)
>{
>  GtkButtonPrivate *priv = GTK_BUTTON_GET_PRIVATE (activatable);
>
>  if (!action)
>    return;
>
>  if (gtk_action_is_visible (action))
>    gtk_widget_show (GTK_WIDGET (activatable));
>  else
>    gtk_widget_hide (GTK_WIDGET (activatable));
>  
>  gtk_widget_set_sensitive (GTK_WIDGET (activatable), gtk_action_is_sensitive (action));
>
>  ...
>  
>  if (priv->use_action_appearance)
>    {
>      if (gtk_action_get_stock_id (action))
>	foo_bar_set_stock (button, gtk_action_get_stock_id (action));
>      else if (gtk_action_get_label (action))
>	foo_bar_set_label (button, gtk_action_get_label (action));
>
>      ...
>
>    }
>}
>
>static void
>foo_bar_activatable_update (GtkActivatable       *activatable,
>			       GtkAction            *action,
>			       const gchar          *property_name)
>{
>  FooBarPrivate *priv = FOO_BAR_GET_PRIVATE (activatable);
>
>  if (strcmp (property_name, "visible") == 0)
>    {
>      if (gtk_action_is_visible (action))
>	gtk_widget_show (GTK_WIDGET (activatable));
>      else
>	gtk_widget_hide (GTK_WIDGET (activatable));
>    }
>  else if (strcmp (property_name, "sensitive") == 0)
>    gtk_widget_set_sensitive (GTK_WIDGET (activatable), gtk_action_is_sensitive (action));
>
>  ...
>
>  if (!priv->use_action_appearance)
>    return;
>
>  if (strcmp (property_name, "stock-id") == 0)
>    foo_bar_set_stock (button, gtk_action_get_stock_id (action));
>  else if (strcmp (property_name, "label") == 0)
>    foo_bar_set_label (button, gtk_action_get_label (action));
>
>  ...
>}

-}

module GI.Gtk.Interfaces.Activatable
    ( 

-- * Exported types
    Activatable(..)                         ,
    noActivatable                           ,
    IsActivatable                           ,
    toActivatable                           ,


 -- * Methods
-- ** doSetRelatedAction #method:doSetRelatedAction#
    ActivatableDoSetRelatedActionMethodInfo ,
    activatableDoSetRelatedAction           ,


-- ** getRelatedAction #method:getRelatedAction#
    ActivatableGetRelatedActionMethodInfo   ,
    activatableGetRelatedAction             ,


-- ** getUseActionAppearance #method:getUseActionAppearance#
    ActivatableGetUseActionAppearanceMethodInfo,
    activatableGetUseActionAppearance       ,


-- ** setRelatedAction #method:setRelatedAction#
    ActivatableSetRelatedActionMethodInfo   ,
    activatableSetRelatedAction             ,


-- ** setUseActionAppearance #method:setUseActionAppearance#
    ActivatableSetUseActionAppearanceMethodInfo,
    activatableSetUseActionAppearance       ,


-- ** syncActionProperties #method:syncActionProperties#
    ActivatableSyncActionPropertiesMethodInfo,
    activatableSyncActionProperties         ,




 -- * Properties
-- ** relatedAction #attr:relatedAction#
    ActivatableRelatedActionPropertyInfo    ,
    activatableRelatedAction                ,
    constructActivatableRelatedAction       ,
    getActivatableRelatedAction             ,
    setActivatableRelatedAction             ,


-- ** useActionAppearance #attr:useActionAppearance#
    ActivatableUseActionAppearancePropertyInfo,
    activatableUseActionAppearance          ,
    constructActivatableUseActionAppearance ,
    getActivatableUseActionAppearance       ,
    setActivatableUseActionAppearance       ,




    ) 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.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 {-# SOURCE #-} qualified GI.Gtk.Objects.Action as Gtk.Action

-- interface Activatable 
newtype Activatable = Activatable (ManagedPtr Activatable)
noActivatable :: Maybe Activatable
noActivatable = Nothing

type instance O.SignalList Activatable = ActivatableSignalList
type ActivatableSignalList = ('[ '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])

foreign import ccall "gtk_activatable_get_type"
    c_gtk_activatable_get_type :: IO GType

instance GObject Activatable where
    gobjectType _ = c_gtk_activatable_get_type
    

class GObject o => IsActivatable o
#if MIN_VERSION_base(4,9,0)
instance {-# OVERLAPPABLE #-} (GObject a, O.UnknownAncestorError Activatable a) =>
    IsActivatable a
#endif
instance IsActivatable Activatable
instance GObject.Object.IsObject Activatable

toActivatable :: IsActivatable o => o -> IO Activatable
toActivatable = unsafeCastTo Activatable

-- VVV Prop "related-action"
   -- Type: TInterface (Name {namespace = "Gtk", name = "Action"})
   -- Flags: [PropertyReadable,PropertyWritable]
   -- Nullable: (Just False,Just False)

getActivatableRelatedAction :: (MonadIO m, IsActivatable o) => o -> m Gtk.Action.Action
getActivatableRelatedAction obj = liftIO $ checkUnexpectedNothing "getActivatableRelatedAction" $ getObjectPropertyObject obj "related-action" Gtk.Action.Action

setActivatableRelatedAction :: (MonadIO m, IsActivatable o, Gtk.Action.IsAction a) => o -> a -> m ()
setActivatableRelatedAction obj val = liftIO $ setObjectPropertyObject obj "related-action" (Just val)

constructActivatableRelatedAction :: (IsActivatable o, Gtk.Action.IsAction a) => a -> IO (GValueConstruct o)
constructActivatableRelatedAction val = constructObjectPropertyObject "related-action" (Just val)

data ActivatableRelatedActionPropertyInfo
instance AttrInfo ActivatableRelatedActionPropertyInfo where
    type AttrAllowedOps ActivatableRelatedActionPropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint ActivatableRelatedActionPropertyInfo = Gtk.Action.IsAction
    type AttrBaseTypeConstraint ActivatableRelatedActionPropertyInfo = IsActivatable
    type AttrGetType ActivatableRelatedActionPropertyInfo = Gtk.Action.Action
    type AttrLabel ActivatableRelatedActionPropertyInfo = "related-action"
    type AttrOrigin ActivatableRelatedActionPropertyInfo = Activatable
    attrGet _ = getActivatableRelatedAction
    attrSet _ = setActivatableRelatedAction
    attrConstruct _ = constructActivatableRelatedAction
    attrClear _ = undefined

-- VVV Prop "use-action-appearance"
   -- Type: TBasicType TBoolean
   -- Flags: [PropertyReadable,PropertyWritable]
   -- Nullable: (Just False,Just False)

getActivatableUseActionAppearance :: (MonadIO m, IsActivatable o) => o -> m Bool
getActivatableUseActionAppearance obj = liftIO $ getObjectPropertyBool obj "use-action-appearance"

setActivatableUseActionAppearance :: (MonadIO m, IsActivatable o) => o -> Bool -> m ()
setActivatableUseActionAppearance obj val = liftIO $ setObjectPropertyBool obj "use-action-appearance" val

constructActivatableUseActionAppearance :: (IsActivatable o) => Bool -> IO (GValueConstruct o)
constructActivatableUseActionAppearance val = constructObjectPropertyBool "use-action-appearance" val

data ActivatableUseActionAppearancePropertyInfo
instance AttrInfo ActivatableUseActionAppearancePropertyInfo where
    type AttrAllowedOps ActivatableUseActionAppearancePropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint ActivatableUseActionAppearancePropertyInfo = (~) Bool
    type AttrBaseTypeConstraint ActivatableUseActionAppearancePropertyInfo = IsActivatable
    type AttrGetType ActivatableUseActionAppearancePropertyInfo = Bool
    type AttrLabel ActivatableUseActionAppearancePropertyInfo = "use-action-appearance"
    type AttrOrigin ActivatableUseActionAppearancePropertyInfo = Activatable
    attrGet _ = getActivatableUseActionAppearance
    attrSet _ = setActivatableUseActionAppearance
    attrConstruct _ = constructActivatableUseActionAppearance
    attrClear _ = undefined

instance O.HasAttributeList Activatable
type instance O.AttributeList Activatable = ActivatableAttributeList
type ActivatableAttributeList = ('[ '("relatedAction", ActivatableRelatedActionPropertyInfo), '("useActionAppearance", ActivatableUseActionAppearancePropertyInfo)] :: [(Symbol, *)])

activatableRelatedAction :: AttrLabelProxy "relatedAction"
activatableRelatedAction = AttrLabelProxy

activatableUseActionAppearance :: AttrLabelProxy "useActionAppearance"
activatableUseActionAppearance = AttrLabelProxy

type family ResolveActivatableMethod (t :: Symbol) (o :: *) :: * where
    ResolveActivatableMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveActivatableMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveActivatableMethod "doSetRelatedAction" o = ActivatableDoSetRelatedActionMethodInfo
    ResolveActivatableMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveActivatableMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveActivatableMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveActivatableMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveActivatableMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveActivatableMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveActivatableMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveActivatableMethod "replaceData" o = GObject.Object.ObjectReplaceDataMethodInfo
    ResolveActivatableMethod "replaceQdata" o = GObject.Object.ObjectReplaceQdataMethodInfo
    ResolveActivatableMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveActivatableMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveActivatableMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveActivatableMethod "syncActionProperties" o = ActivatableSyncActionPropertiesMethodInfo
    ResolveActivatableMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveActivatableMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveActivatableMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveActivatableMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveActivatableMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveActivatableMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveActivatableMethod "getRelatedAction" o = ActivatableGetRelatedActionMethodInfo
    ResolveActivatableMethod "getUseActionAppearance" o = ActivatableGetUseActionAppearanceMethodInfo
    ResolveActivatableMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveActivatableMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveActivatableMethod "setRelatedAction" o = ActivatableSetRelatedActionMethodInfo
    ResolveActivatableMethod "setUseActionAppearance" o = ActivatableSetUseActionAppearanceMethodInfo
    ResolveActivatableMethod l o = O.MethodResolutionFailed l o

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

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

-- method Activatable::do_set_related_action
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "activatable", argType = TInterface (Name {namespace = "Gtk", name = "Activatable"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkActivatable", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "action", argType = TInterface (Name {namespace = "Gtk", name = "Action"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GtkAction to set", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gtk_activatable_do_set_related_action" gtk_activatable_do_set_related_action :: 
    Ptr Activatable ->                      -- activatable : TInterface (Name {namespace = "Gtk", name = "Activatable"})
    Ptr Gtk.Action.Action ->                -- action : TInterface (Name {namespace = "Gtk", name = "Action"})
    IO ()

{-# DEPRECATED activatableDoSetRelatedAction ["(Since version 3.10)"] #-}
{- |
This is a utility function for 'GI.Gtk.Interfaces.Activatable.Activatable' implementors.

When implementing 'GI.Gtk.Interfaces.Activatable.Activatable' you must call this when
handling changes of the 'GI.Gtk.Interfaces.Activatable.Activatable':@/related-action/@, and
you must also use this to break references in 'GI.GObject.Objects.Object.Object'->@/dispose()/@.

This function adds a reference to the currently set related
action for you, it also makes sure the 'GI.Gtk.Interfaces.Activatable.Activatable'->@/update()/@
method is called when the related 'GI.Gtk.Objects.Action.Action' properties change
and registers to the action’s proxy list.

> Be careful to call this before setting the local
> copy of the 'GI.Gtk.Objects.Action.Action' property, since this function uses
> 'GI.Gtk.Interfaces.Activatable.activatableGetRelatedAction' to retrieve the
> previous action.

@since 2.16
-}
activatableDoSetRelatedAction ::
    (B.CallStack.HasCallStack, MonadIO m, IsActivatable a, Gtk.Action.IsAction b) =>
    a
    {- ^ /@activatable@/: a 'GI.Gtk.Interfaces.Activatable.Activatable' -}
    -> b
    {- ^ /@action@/: the 'GI.Gtk.Objects.Action.Action' to set -}
    -> m ()
activatableDoSetRelatedAction activatable action = liftIO $ do
    activatable' <- unsafeManagedPtrCastPtr activatable
    action' <- unsafeManagedPtrCastPtr action
    gtk_activatable_do_set_related_action activatable' action'
    touchManagedPtr activatable
    touchManagedPtr action
    return ()

data ActivatableDoSetRelatedActionMethodInfo
instance (signature ~ (b -> m ()), MonadIO m, IsActivatable a, Gtk.Action.IsAction b) => O.MethodInfo ActivatableDoSetRelatedActionMethodInfo a signature where
    overloadedMethod _ = activatableDoSetRelatedAction

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

foreign import ccall "gtk_activatable_get_related_action" gtk_activatable_get_related_action :: 
    Ptr Activatable ->                      -- activatable : TInterface (Name {namespace = "Gtk", name = "Activatable"})
    IO (Ptr Gtk.Action.Action)

{-# DEPRECATED activatableGetRelatedAction ["(Since version 3.10)"] #-}
{- |
Gets the related 'GI.Gtk.Objects.Action.Action' for /@activatable@/.

@since 2.16
-}
activatableGetRelatedAction ::
    (B.CallStack.HasCallStack, MonadIO m, IsActivatable a) =>
    a
    {- ^ /@activatable@/: a 'GI.Gtk.Interfaces.Activatable.Activatable' -}
    -> m Gtk.Action.Action
    {- ^ __Returns:__ the related 'GI.Gtk.Objects.Action.Action' if one is set. -}
activatableGetRelatedAction activatable = liftIO $ do
    activatable' <- unsafeManagedPtrCastPtr activatable
    result <- gtk_activatable_get_related_action activatable'
    checkUnexpectedReturnNULL "activatableGetRelatedAction" result
    result' <- (newObject Gtk.Action.Action) result
    touchManagedPtr activatable
    return result'

data ActivatableGetRelatedActionMethodInfo
instance (signature ~ (m Gtk.Action.Action), MonadIO m, IsActivatable a) => O.MethodInfo ActivatableGetRelatedActionMethodInfo a signature where
    overloadedMethod _ = activatableGetRelatedAction

-- method Activatable::get_use_action_appearance
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "activatable", argType = TInterface (Name {namespace = "Gtk", name = "Activatable"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkActivatable", 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_activatable_get_use_action_appearance" gtk_activatable_get_use_action_appearance :: 
    Ptr Activatable ->                      -- activatable : TInterface (Name {namespace = "Gtk", name = "Activatable"})
    IO CInt

{-# DEPRECATED activatableGetUseActionAppearance ["(Since version 3.10)"] #-}
{- |
Gets whether this activatable should reset its layout
and appearance when setting the related action or when
the action changes appearance.

@since 2.16
-}
activatableGetUseActionAppearance ::
    (B.CallStack.HasCallStack, MonadIO m, IsActivatable a) =>
    a
    {- ^ /@activatable@/: a 'GI.Gtk.Interfaces.Activatable.Activatable' -}
    -> m Bool
    {- ^ __Returns:__ whether /@activatable@/ uses its actions appearance. -}
activatableGetUseActionAppearance activatable = liftIO $ do
    activatable' <- unsafeManagedPtrCastPtr activatable
    result <- gtk_activatable_get_use_action_appearance activatable'
    let result' = (/= 0) result
    touchManagedPtr activatable
    return result'

data ActivatableGetUseActionAppearanceMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsActivatable a) => O.MethodInfo ActivatableGetUseActionAppearanceMethodInfo a signature where
    overloadedMethod _ = activatableGetUseActionAppearance

-- method Activatable::set_related_action
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "activatable", argType = TInterface (Name {namespace = "Gtk", name = "Activatable"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkActivatable", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "action", argType = TInterface (Name {namespace = "Gtk", name = "Action"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GtkAction to set", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gtk_activatable_set_related_action" gtk_activatable_set_related_action :: 
    Ptr Activatable ->                      -- activatable : TInterface (Name {namespace = "Gtk", name = "Activatable"})
    Ptr Gtk.Action.Action ->                -- action : TInterface (Name {namespace = "Gtk", name = "Action"})
    IO ()

{-# DEPRECATED activatableSetRelatedAction ["(Since version 3.10)"] #-}
{- |
Sets the related action on the /@activatable@/ object.

> 'GI.Gtk.Interfaces.Activatable.Activatable' implementors need to handle the 'GI.Gtk.Interfaces.Activatable.Activatable':@/related-action/@
> property and call 'GI.Gtk.Interfaces.Activatable.activatableDoSetRelatedAction' when it changes.

@since 2.16
-}
activatableSetRelatedAction ::
    (B.CallStack.HasCallStack, MonadIO m, IsActivatable a, Gtk.Action.IsAction b) =>
    a
    {- ^ /@activatable@/: a 'GI.Gtk.Interfaces.Activatable.Activatable' -}
    -> b
    {- ^ /@action@/: the 'GI.Gtk.Objects.Action.Action' to set -}
    -> m ()
activatableSetRelatedAction activatable action = liftIO $ do
    activatable' <- unsafeManagedPtrCastPtr activatable
    action' <- unsafeManagedPtrCastPtr action
    gtk_activatable_set_related_action activatable' action'
    touchManagedPtr activatable
    touchManagedPtr action
    return ()

data ActivatableSetRelatedActionMethodInfo
instance (signature ~ (b -> m ()), MonadIO m, IsActivatable a, Gtk.Action.IsAction b) => O.MethodInfo ActivatableSetRelatedActionMethodInfo a signature where
    overloadedMethod _ = activatableSetRelatedAction

-- method Activatable::set_use_action_appearance
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "activatable", argType = TInterface (Name {namespace = "Gtk", name = "Activatable"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkActivatable", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "use_appearance", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "whether to use the actions appearance", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gtk_activatable_set_use_action_appearance" gtk_activatable_set_use_action_appearance :: 
    Ptr Activatable ->                      -- activatable : TInterface (Name {namespace = "Gtk", name = "Activatable"})
    CInt ->                                 -- use_appearance : TBasicType TBoolean
    IO ()

{-# DEPRECATED activatableSetUseActionAppearance ["(Since version 3.10)"] #-}
{- |
Sets whether this activatable should reset its layout and appearance
when setting the related action or when the action changes appearance

> 'GI.Gtk.Interfaces.Activatable.Activatable' implementors need to handle the
> 'GI.Gtk.Interfaces.Activatable.Activatable':@/use-action-appearance/@ property and call
> 'GI.Gtk.Interfaces.Activatable.activatableSyncActionProperties' to update /@activatable@/
> if needed.

@since 2.16
-}
activatableSetUseActionAppearance ::
    (B.CallStack.HasCallStack, MonadIO m, IsActivatable a) =>
    a
    {- ^ /@activatable@/: a 'GI.Gtk.Interfaces.Activatable.Activatable' -}
    -> Bool
    {- ^ /@useAppearance@/: whether to use the actions appearance -}
    -> m ()
activatableSetUseActionAppearance activatable useAppearance = liftIO $ do
    activatable' <- unsafeManagedPtrCastPtr activatable
    let useAppearance' = (fromIntegral . fromEnum) useAppearance
    gtk_activatable_set_use_action_appearance activatable' useAppearance'
    touchManagedPtr activatable
    return ()

data ActivatableSetUseActionAppearanceMethodInfo
instance (signature ~ (Bool -> m ()), MonadIO m, IsActivatable a) => O.MethodInfo ActivatableSetUseActionAppearanceMethodInfo a signature where
    overloadedMethod _ = activatableSetUseActionAppearance

-- method Activatable::sync_action_properties
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "activatable", argType = TInterface (Name {namespace = "Gtk", name = "Activatable"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkActivatable", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "action", argType = TInterface (Name {namespace = "Gtk", name = "Action"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the related #GtkAction or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gtk_activatable_sync_action_properties" gtk_activatable_sync_action_properties :: 
    Ptr Activatable ->                      -- activatable : TInterface (Name {namespace = "Gtk", name = "Activatable"})
    Ptr Gtk.Action.Action ->                -- action : TInterface (Name {namespace = "Gtk", name = "Action"})
    IO ()

{-# DEPRECATED activatableSyncActionProperties ["(Since version 3.10)"] #-}
{- |
This is called to update the activatable completely, this is called
internally when the 'GI.Gtk.Interfaces.Activatable.Activatable':@/related-action/@ property is set
or unset and by the implementing class when
'GI.Gtk.Interfaces.Activatable.Activatable':@/use-action-appearance/@ changes.

@since 2.16
-}
activatableSyncActionProperties ::
    (B.CallStack.HasCallStack, MonadIO m, IsActivatable a, Gtk.Action.IsAction b) =>
    a
    {- ^ /@activatable@/: a 'GI.Gtk.Interfaces.Activatable.Activatable' -}
    -> Maybe (b)
    {- ^ /@action@/: the related 'GI.Gtk.Objects.Action.Action' or 'Nothing' -}
    -> m ()
activatableSyncActionProperties activatable action = liftIO $ do
    activatable' <- unsafeManagedPtrCastPtr activatable
    maybeAction <- case action of
        Nothing -> return nullPtr
        Just jAction -> do
            jAction' <- unsafeManagedPtrCastPtr jAction
            return jAction'
    gtk_activatable_sync_action_properties activatable' maybeAction
    touchManagedPtr activatable
    whenJust action touchManagedPtr
    return ()

data ActivatableSyncActionPropertiesMethodInfo
instance (signature ~ (Maybe (b) -> m ()), MonadIO m, IsActivatable a, Gtk.Action.IsAction b) => O.MethodInfo ActivatableSyncActionPropertiesMethodInfo a signature where
    overloadedMethod _ = activatableSyncActionProperties