gi-gtk-0.3.16.12: GI/Gtk/Objects/Switch.hs
{- |
Copyright : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License : LGPL-2.1
Maintainer : Iñaki García Etxebarria (garetxe@gmail.com)
-}
module GI.Gtk.Objects.Switch
(
-- * Exported types
Switch(..) ,
SwitchK ,
toSwitch ,
noSwitch ,
-- * Methods
-- ** switchGetActive
switchGetActive ,
-- ** switchGetState
switchGetState ,
-- ** switchNew
switchNew ,
-- ** switchSetActive
switchSetActive ,
-- ** switchSetState
switchSetState ,
-- * Properties
-- ** Active
SwitchActivePropertyInfo ,
constructSwitchActive ,
getSwitchActive ,
setSwitchActive ,
-- ** State
SwitchStatePropertyInfo ,
constructSwitchState ,
getSwitchState ,
setSwitchState ,
-- * Signals
-- ** Activate
SwitchActivateCallback ,
SwitchActivateCallbackC ,
SwitchActivateSignalInfo ,
afterSwitchActivate ,
mkSwitchActivateCallback ,
noSwitchActivateCallback ,
onSwitchActivate ,
switchActivateCallbackWrapper ,
switchActivateClosure ,
-- ** StateSet
SwitchStateSetCallback ,
SwitchStateSetCallbackC ,
SwitchStateSetSignalInfo ,
afterSwitchStateSet ,
mkSwitchStateSetCallback ,
noSwitchStateSetCallback ,
onSwitchStateSet ,
switchStateSetCallbackWrapper ,
switchStateSetClosure ,
) where
import Prelude ()
import Data.GI.Base.ShortPrelude
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import GI.Gtk.Types
import GI.Gtk.Callbacks
import qualified GI.Atk as Atk
import qualified GI.GObject as GObject
newtype Switch = Switch (ForeignPtr Switch)
foreign import ccall "gtk_switch_get_type"
c_gtk_switch_get_type :: IO GType
type instance ParentTypes Switch = SwitchParentTypes
type SwitchParentTypes = '[Widget, GObject.Object, Atk.ImplementorIface, Actionable, Activatable, Buildable]
instance GObject Switch where
gobjectIsInitiallyUnowned _ = True
gobjectType _ = c_gtk_switch_get_type
class GObject o => SwitchK o
instance (GObject o, IsDescendantOf Switch o) => SwitchK o
toSwitch :: SwitchK o => o -> IO Switch
toSwitch = unsafeCastTo Switch
noSwitch :: Maybe Switch
noSwitch = Nothing
-- signal Switch::activate
type SwitchActivateCallback =
IO ()
noSwitchActivateCallback :: Maybe SwitchActivateCallback
noSwitchActivateCallback = Nothing
type SwitchActivateCallbackC =
Ptr () -> -- object
Ptr () -> -- user_data
IO ()
foreign import ccall "wrapper"
mkSwitchActivateCallback :: SwitchActivateCallbackC -> IO (FunPtr SwitchActivateCallbackC)
switchActivateClosure :: SwitchActivateCallback -> IO Closure
switchActivateClosure cb = newCClosure =<< mkSwitchActivateCallback wrapped
where wrapped = switchActivateCallbackWrapper cb
switchActivateCallbackWrapper ::
SwitchActivateCallback ->
Ptr () ->
Ptr () ->
IO ()
switchActivateCallbackWrapper _cb _ _ = do
_cb
onSwitchActivate :: (GObject a, MonadIO m) => a -> SwitchActivateCallback -> m SignalHandlerId
onSwitchActivate obj cb = liftIO $ connectSwitchActivate obj cb SignalConnectBefore
afterSwitchActivate :: (GObject a, MonadIO m) => a -> SwitchActivateCallback -> m SignalHandlerId
afterSwitchActivate obj cb = connectSwitchActivate obj cb SignalConnectAfter
connectSwitchActivate :: (GObject a, MonadIO m) =>
a -> SwitchActivateCallback -> SignalConnectMode -> m SignalHandlerId
connectSwitchActivate obj cb after = liftIO $ do
cb' <- mkSwitchActivateCallback (switchActivateCallbackWrapper cb)
connectSignalFunPtr obj "activate" cb' after
-- signal Switch::state-set
type SwitchStateSetCallback =
Bool ->
IO Bool
noSwitchStateSetCallback :: Maybe SwitchStateSetCallback
noSwitchStateSetCallback = Nothing
type SwitchStateSetCallbackC =
Ptr () -> -- object
CInt ->
Ptr () -> -- user_data
IO CInt
foreign import ccall "wrapper"
mkSwitchStateSetCallback :: SwitchStateSetCallbackC -> IO (FunPtr SwitchStateSetCallbackC)
switchStateSetClosure :: SwitchStateSetCallback -> IO Closure
switchStateSetClosure cb = newCClosure =<< mkSwitchStateSetCallback wrapped
where wrapped = switchStateSetCallbackWrapper cb
switchStateSetCallbackWrapper ::
SwitchStateSetCallback ->
Ptr () ->
CInt ->
Ptr () ->
IO CInt
switchStateSetCallbackWrapper _cb _ state _ = do
let state' = (/= 0) state
result <- _cb state'
let result' = (fromIntegral . fromEnum) result
return result'
onSwitchStateSet :: (GObject a, MonadIO m) => a -> SwitchStateSetCallback -> m SignalHandlerId
onSwitchStateSet obj cb = liftIO $ connectSwitchStateSet obj cb SignalConnectBefore
afterSwitchStateSet :: (GObject a, MonadIO m) => a -> SwitchStateSetCallback -> m SignalHandlerId
afterSwitchStateSet obj cb = connectSwitchStateSet obj cb SignalConnectAfter
connectSwitchStateSet :: (GObject a, MonadIO m) =>
a -> SwitchStateSetCallback -> SignalConnectMode -> m SignalHandlerId
connectSwitchStateSet obj cb after = liftIO $ do
cb' <- mkSwitchStateSetCallback (switchStateSetCallbackWrapper cb)
connectSignalFunPtr obj "state-set" cb' after
-- VVV Prop "active"
-- Type: TBasicType TBoolean
-- Flags: [PropertyReadable,PropertyWritable]
getSwitchActive :: (MonadIO m, SwitchK o) => o -> m Bool
getSwitchActive obj = liftIO $ getObjectPropertyBool obj "active"
setSwitchActive :: (MonadIO m, SwitchK o) => o -> Bool -> m ()
setSwitchActive obj val = liftIO $ setObjectPropertyBool obj "active" val
constructSwitchActive :: Bool -> IO ([Char], GValue)
constructSwitchActive val = constructObjectPropertyBool "active" val
data SwitchActivePropertyInfo
instance AttrInfo SwitchActivePropertyInfo where
type AttrAllowedOps SwitchActivePropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet]
type AttrSetTypeConstraint SwitchActivePropertyInfo = (~) Bool
type AttrBaseTypeConstraint SwitchActivePropertyInfo = SwitchK
type AttrGetType SwitchActivePropertyInfo = Bool
type AttrLabel SwitchActivePropertyInfo = "Switch::active"
attrGet _ = getSwitchActive
attrSet _ = setSwitchActive
attrConstruct _ = constructSwitchActive
-- VVV Prop "state"
-- Type: TBasicType TBoolean
-- Flags: [PropertyReadable,PropertyWritable]
getSwitchState :: (MonadIO m, SwitchK o) => o -> m Bool
getSwitchState obj = liftIO $ getObjectPropertyBool obj "state"
setSwitchState :: (MonadIO m, SwitchK o) => o -> Bool -> m ()
setSwitchState obj val = liftIO $ setObjectPropertyBool obj "state" val
constructSwitchState :: Bool -> IO ([Char], GValue)
constructSwitchState val = constructObjectPropertyBool "state" val
data SwitchStatePropertyInfo
instance AttrInfo SwitchStatePropertyInfo where
type AttrAllowedOps SwitchStatePropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet]
type AttrSetTypeConstraint SwitchStatePropertyInfo = (~) Bool
type AttrBaseTypeConstraint SwitchStatePropertyInfo = SwitchK
type AttrGetType SwitchStatePropertyInfo = Bool
type AttrLabel SwitchStatePropertyInfo = "Switch::state"
attrGet _ = getSwitchState
attrSet _ = setSwitchState
attrConstruct _ = constructSwitchState
type instance AttributeList Switch = SwitchAttributeList
type SwitchAttributeList = ('[ '("action-name", ActionableActionNamePropertyInfo), '("action-target", ActionableActionTargetPropertyInfo), '("active", SwitchActivePropertyInfo), '("app-paintable", WidgetAppPaintablePropertyInfo), '("can-default", WidgetCanDefaultPropertyInfo), '("can-focus", WidgetCanFocusPropertyInfo), '("composite-child", WidgetCompositeChildPropertyInfo), '("double-buffered", WidgetDoubleBufferedPropertyInfo), '("events", WidgetEventsPropertyInfo), '("expand", WidgetExpandPropertyInfo), '("halign", WidgetHalignPropertyInfo), '("has-default", WidgetHasDefaultPropertyInfo), '("has-focus", WidgetHasFocusPropertyInfo), '("has-tooltip", WidgetHasTooltipPropertyInfo), '("height-request", WidgetHeightRequestPropertyInfo), '("hexpand", WidgetHexpandPropertyInfo), '("hexpand-set", WidgetHexpandSetPropertyInfo), '("is-focus", WidgetIsFocusPropertyInfo), '("margin", WidgetMarginPropertyInfo), '("margin-bottom", WidgetMarginBottomPropertyInfo), '("margin-end", WidgetMarginEndPropertyInfo), '("margin-left", WidgetMarginLeftPropertyInfo), '("margin-right", WidgetMarginRightPropertyInfo), '("margin-start", WidgetMarginStartPropertyInfo), '("margin-top", WidgetMarginTopPropertyInfo), '("name", WidgetNamePropertyInfo), '("no-show-all", WidgetNoShowAllPropertyInfo), '("opacity", WidgetOpacityPropertyInfo), '("parent", WidgetParentPropertyInfo), '("receives-default", WidgetReceivesDefaultPropertyInfo), '("related-action", ActivatableRelatedActionPropertyInfo), '("scale-factor", WidgetScaleFactorPropertyInfo), '("sensitive", WidgetSensitivePropertyInfo), '("state", SwitchStatePropertyInfo), '("style", WidgetStylePropertyInfo), '("tooltip-markup", WidgetTooltipMarkupPropertyInfo), '("tooltip-text", WidgetTooltipTextPropertyInfo), '("use-action-appearance", ActivatableUseActionAppearancePropertyInfo), '("valign", WidgetValignPropertyInfo), '("vexpand", WidgetVexpandPropertyInfo), '("vexpand-set", WidgetVexpandSetPropertyInfo), '("visible", WidgetVisiblePropertyInfo), '("width-request", WidgetWidthRequestPropertyInfo), '("window", WidgetWindowPropertyInfo)] :: [(Symbol, *)])
data SwitchActivateSignalInfo
instance SignalInfo SwitchActivateSignalInfo where
type HaskellCallbackType SwitchActivateSignalInfo = SwitchActivateCallback
connectSignal _ = connectSwitchActivate
data SwitchStateSetSignalInfo
instance SignalInfo SwitchStateSetSignalInfo where
type HaskellCallbackType SwitchStateSetSignalInfo = SwitchStateSetCallback
connectSignal _ = connectSwitchStateSet
type instance SignalList Switch = SwitchSignalList
type SwitchSignalList = ('[ '("accel-closures-changed", WidgetAccelClosuresChangedSignalInfo), '("activate", SwitchActivateSignalInfo), '("button-press-event", WidgetButtonPressEventSignalInfo), '("button-release-event", WidgetButtonReleaseEventSignalInfo), '("can-activate-accel", WidgetCanActivateAccelSignalInfo), '("child-notify", WidgetChildNotifySignalInfo), '("composited-changed", WidgetCompositedChangedSignalInfo), '("configure-event", WidgetConfigureEventSignalInfo), '("damage-event", WidgetDamageEventSignalInfo), '("delete-event", WidgetDeleteEventSignalInfo), '("destroy", WidgetDestroySignalInfo), '("destroy-event", WidgetDestroyEventSignalInfo), '("direction-changed", WidgetDirectionChangedSignalInfo), '("drag-begin", WidgetDragBeginSignalInfo), '("drag-data-delete", WidgetDragDataDeleteSignalInfo), '("drag-data-get", WidgetDragDataGetSignalInfo), '("drag-data-received", WidgetDragDataReceivedSignalInfo), '("drag-drop", WidgetDragDropSignalInfo), '("drag-end", WidgetDragEndSignalInfo), '("drag-failed", WidgetDragFailedSignalInfo), '("drag-leave", WidgetDragLeaveSignalInfo), '("drag-motion", WidgetDragMotionSignalInfo), '("draw", WidgetDrawSignalInfo), '("enter-notify-event", WidgetEnterNotifyEventSignalInfo), '("event", WidgetEventSignalInfo), '("event-after", WidgetEventAfterSignalInfo), '("focus", WidgetFocusSignalInfo), '("focus-in-event", WidgetFocusInEventSignalInfo), '("focus-out-event", WidgetFocusOutEventSignalInfo), '("grab-broken-event", WidgetGrabBrokenEventSignalInfo), '("grab-focus", WidgetGrabFocusSignalInfo), '("grab-notify", WidgetGrabNotifySignalInfo), '("hide", WidgetHideSignalInfo), '("hierarchy-changed", WidgetHierarchyChangedSignalInfo), '("key-press-event", WidgetKeyPressEventSignalInfo), '("key-release-event", WidgetKeyReleaseEventSignalInfo), '("keynav-failed", WidgetKeynavFailedSignalInfo), '("leave-notify-event", WidgetLeaveNotifyEventSignalInfo), '("map", WidgetMapSignalInfo), '("map-event", WidgetMapEventSignalInfo), '("mnemonic-activate", WidgetMnemonicActivateSignalInfo), '("motion-notify-event", WidgetMotionNotifyEventSignalInfo), '("move-focus", WidgetMoveFocusSignalInfo), '("notify", GObject.ObjectNotifySignalInfo), '("parent-set", WidgetParentSetSignalInfo), '("popup-menu", WidgetPopupMenuSignalInfo), '("property-notify-event", WidgetPropertyNotifyEventSignalInfo), '("proximity-in-event", WidgetProximityInEventSignalInfo), '("proximity-out-event", WidgetProximityOutEventSignalInfo), '("query-tooltip", WidgetQueryTooltipSignalInfo), '("realize", WidgetRealizeSignalInfo), '("screen-changed", WidgetScreenChangedSignalInfo), '("scroll-event", WidgetScrollEventSignalInfo), '("selection-clear-event", WidgetSelectionClearEventSignalInfo), '("selection-get", WidgetSelectionGetSignalInfo), '("selection-notify-event", WidgetSelectionNotifyEventSignalInfo), '("selection-received", WidgetSelectionReceivedSignalInfo), '("selection-request-event", WidgetSelectionRequestEventSignalInfo), '("show", WidgetShowSignalInfo), '("show-help", WidgetShowHelpSignalInfo), '("size-allocate", WidgetSizeAllocateSignalInfo), '("state-changed", WidgetStateChangedSignalInfo), '("state-flags-changed", WidgetStateFlagsChangedSignalInfo), '("state-set", SwitchStateSetSignalInfo), '("style-set", WidgetStyleSetSignalInfo), '("style-updated", WidgetStyleUpdatedSignalInfo), '("touch-event", WidgetTouchEventSignalInfo), '("unmap", WidgetUnmapSignalInfo), '("unmap-event", WidgetUnmapEventSignalInfo), '("unrealize", WidgetUnrealizeSignalInfo), '("visibility-notify-event", WidgetVisibilityNotifyEventSignalInfo), '("window-state-event", WidgetWindowStateEventSignalInfo), '("notify::[property]", GObjectNotifySignalInfo)] :: [(Symbol, *)])
-- method Switch::new
-- method type : Constructor
-- Args : []
-- Lengths : []
-- hInArgs : []
-- returnType : TInterface "Gtk" "Switch"
-- throws : False
-- Skip return : False
foreign import ccall "gtk_switch_new" gtk_switch_new ::
IO (Ptr Switch)
switchNew ::
(MonadIO m) =>
m Switch
switchNew = liftIO $ do
result <- gtk_switch_new
checkUnexpectedReturnNULL "gtk_switch_new" result
result' <- (newObject Switch) result
return result'
-- method Switch::get_active
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gtk" "Switch", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gtk" "Switch", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TBoolean
-- throws : False
-- Skip return : False
foreign import ccall "gtk_switch_get_active" gtk_switch_get_active ::
Ptr Switch -> -- _obj : TInterface "Gtk" "Switch"
IO CInt
switchGetActive ::
(MonadIO m, SwitchK a) =>
a -> -- _obj
m Bool
switchGetActive _obj = liftIO $ do
let _obj' = unsafeManagedPtrCastPtr _obj
result <- gtk_switch_get_active _obj'
let result' = (/= 0) result
touchManagedPtr _obj
return result'
-- method Switch::get_state
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gtk" "Switch", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gtk" "Switch", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TBoolean
-- throws : False
-- Skip return : False
foreign import ccall "gtk_switch_get_state" gtk_switch_get_state ::
Ptr Switch -> -- _obj : TInterface "Gtk" "Switch"
IO CInt
switchGetState ::
(MonadIO m, SwitchK a) =>
a -> -- _obj
m Bool
switchGetState _obj = liftIO $ do
let _obj' = unsafeManagedPtrCastPtr _obj
result <- gtk_switch_get_state _obj'
let result' = (/= 0) result
touchManagedPtr _obj
return result'
-- method Switch::set_active
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gtk" "Switch", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "is_active", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gtk" "Switch", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "is_active", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False
foreign import ccall "gtk_switch_set_active" gtk_switch_set_active ::
Ptr Switch -> -- _obj : TInterface "Gtk" "Switch"
CInt -> -- is_active : TBasicType TBoolean
IO ()
switchSetActive ::
(MonadIO m, SwitchK a) =>
a -> -- _obj
Bool -> -- is_active
m ()
switchSetActive _obj is_active = liftIO $ do
let _obj' = unsafeManagedPtrCastPtr _obj
let is_active' = (fromIntegral . fromEnum) is_active
gtk_switch_set_active _obj' is_active'
touchManagedPtr _obj
return ()
-- method Switch::set_state
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gtk" "Switch", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "state", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gtk" "Switch", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "state", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False
foreign import ccall "gtk_switch_set_state" gtk_switch_set_state ::
Ptr Switch -> -- _obj : TInterface "Gtk" "Switch"
CInt -> -- state : TBasicType TBoolean
IO ()
switchSetState ::
(MonadIO m, SwitchK a) =>
a -> -- _obj
Bool -> -- state
m ()
switchSetState _obj state = liftIO $ do
let _obj' = unsafeManagedPtrCastPtr _obj
let state' = (fromIntegral . fromEnum) state
gtk_switch_set_state _obj' state'
touchManagedPtr _obj
return ()