{-# LINE 2 "./Graphics/UI/Gtk/Misc/Switch.chs" #-}
-- -*-haskell-*-
-- GIMP Toolkit (GTK) Widgets Switch
--
-- Author : Warlock <internalmike@gmail.com>
--
-- Created: 10 November 2017
--
-- Copyright (C) 2017 Warlock
--
-- This library is free software; you can redistribute it and/or
-- modify it under the terms of the GNU Lesser General Public
-- License as published by the Free Software Foundation; either
-- version 2.1 of the License, or (at your option) any later version.
--
-- This library is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-- Lesser General Public License for more details.
--
-- |
-- Maintainer : gtk2hs-users@lists.sourceforge.net
-- Stability : provisional
-- Portability : portable (depends on GHC)
--
-- A "light switch" style toggle
--
module Graphics.UI.Gtk.Misc.Switch (
-- * Detail
--
-- [...]
--
-- * Class Hierarchy
-- |
-- @
-- | 'GObject'
-- | +----'Object'
-- | +----'Widget'
-- | +----'Switch'
-- @

-- * Types

    Switch
  , castToSwitch
  , gTypeSwitch
  , toSwitch

-- * Constructors
  , switchNew

-- * Methods
  , switchSetActive
  , switchGetActive





-- * Attributes
  , switchActive




-- * Signals
  , switchActivate




) where



import Control.Monad (liftM)

import System.Glib.FFI
import System.Glib.Attributes
import System.Glib.Properties
import Graphics.UI.Gtk.Abstract.Object (makeNewObject)
import Graphics.UI.Gtk.Types
{-# LINE 83 "./Graphics/UI/Gtk/Misc/Switch.chs" #-}
import Graphics.UI.Gtk.Signals
{-# LINE 84 "./Graphics/UI/Gtk/Misc/Switch.chs" #-}


{-# LINE 86 "./Graphics/UI/Gtk/Misc/Switch.chs" #-}

--------------------
-- Constructors

-- | Creates a new 'Switch'.
--
switchNew :: IO Switch
switchNew =
  makeNewObject mkSwitch $
  liftM (castPtr :: Ptr Widget -> Ptr Switch) $
  gtk_switch_new
{-# LINE 97 "./Graphics/UI/Gtk/Misc/Switch.chs" #-}

--------------------
-- Methods

-- | Changes the state of control to the desired one.
-- See 'switchGetActive'.
switchSetActive :: SwitchClass self => self
 -> Bool
 -> IO ()
switchSetActive self is_active =
  (\(Switch arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->gtk_switch_set_active argPtr1 arg2)
{-# LINE 108 "./Graphics/UI/Gtk/Misc/Switch.chs" #-}
    (toSwitch self)
    (fromBool is_active)

-- | Gets whether the GtkSwitch is in its on or off state.
switchGetActive :: SwitchClass self => self
 -> IO Bool
switchGetActive self =
  liftM toBool $
  (\(Switch arg1) -> withForeignPtr arg1 $ \argPtr1 ->gtk_switch_get_active argPtr1)
{-# LINE 117 "./Graphics/UI/Gtk/Misc/Switch.chs" #-}
    (toSwitch self)
{-# LINE 144 "./Graphics/UI/Gtk/Misc/Switch.chs" #-}
--------------------
-- Attributes

-- | Whether the switch is in its on or off state.
--
-- Default value: @False@
--
switchActive :: SwitchClass self => Attr self Bool
switchActive = newAttr
  switchGetActive
  switchSetActive
{-# LINE 167 "./Graphics/UI/Gtk/Misc/Switch.chs" #-}
--------------------
-- Signals


-- | This signal on GtkSwitch is an action signal and emitting it causes
-- the switch to animate. Applications should never connect to this signal,
-- but use the notify::active signal.
--
switchActivate :: SwitchClass self => Signal self (IO ())
switchActivate = Signal (connect_NONE__NONE "activate")

foreign import ccall unsafe "gtk_switch_new"
  gtk_switch_new :: (IO (Ptr Widget))

foreign import ccall safe "gtk_switch_set_active"
  gtk_switch_set_active :: ((Ptr Switch) -> (CInt -> (IO ())))

foreign import ccall safe "gtk_switch_get_active"
  gtk_switch_get_active :: ((Ptr Switch) -> (IO CInt))