-- GENERATED by C->Haskell Compiler, version 0.13.13 (gtk2hs branch) "Bin IO", 27 May 2012 (Haskell)
-- Edit the ORIGNAL .chs file instead!


{-# LINE 1 "./Graphics/UI/Gtk/Abstract/ContainerChildProperties.chs" #-}
{-# OPTIONS_HADDOCK hide #-}
-- -*-haskell-*-
--  GIMP Toolkit (GTK) Container child Properties
--
--  Author : Duncan Coutts
--
--  Created: 16 April 2005
--
--  Copyright (C) 2005 Duncan Coutts
--
--  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.
--
-- #hide

-- |
-- Maintainer  : gtk2hs-users@lists.sourceforge.net
-- Stability   : provisional
-- Portability : portable (depends on GHC)
--
-- Functions for getting and setting container child properties
--
module Graphics.UI.Gtk.Abstract.ContainerChildProperties (
  containerChildGetPropertyBool,
  containerChildSetPropertyBool,

  newAttrFromContainerChildIntProperty,
  newAttrFromContainerChildUIntProperty,
  newAttrFromContainerChildBoolProperty,
  newAttrFromContainerChildEnumProperty,
  newAttrFromContainerChildFlagsProperty,
  newAttrFromContainerChildStringProperty,
  ) where

import Control.Monad (liftM)

import System.Glib.FFI
import System.Glib.UTFString
import System.Glib.Flags
import Graphics.UI.Gtk.Types
{-# LINE 47 "./Graphics/UI/Gtk/Abstract/ContainerChildProperties.chs" #-}
import System.Glib.GType
import qualified System.Glib.GTypeConstants as GType
import System.Glib.GValueTypes
import System.Glib.GValue           (GValue(GValue), allocaGValue, valueInit)
import System.Glib.Attributes           (Attr, newAttr)


{-# LINE 54 "./Graphics/UI/Gtk/Abstract/ContainerChildProperties.chs" #-}

containerChildSetPropertyInternal ::
 (ContainerClass container, WidgetClass child)
 => GType
 -> (GValue -> a -> IO ())
 -> String
 -> child
 -> container
 -> a
 -> IO ()
containerChildSetPropertyInternal :: forall container child a.
(ContainerClass container, WidgetClass child) =>
GType
-> (GValue -> a -> IO ())
-> String
-> child
-> container
-> a
-> IO ()
containerChildSetPropertyInternal GType
gtype GValue -> a -> IO ()
valueSet String
prop child
child container
container a
val =
  String -> (CString -> IO ()) -> IO ()
forall a. String -> (CString -> IO a) -> IO a
withCString String
prop ((CString -> IO ()) -> IO ()) -> (CString -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \CString
propertyNamePtr ->
  (GValue -> IO ()) -> IO ()
forall b. (GValue -> IO b) -> IO b
allocaGValue ((GValue -> IO ()) -> IO ()) -> (GValue -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \GValue
gvalue -> do
  GValue -> GType -> IO ()
valueInit GValue
gvalue GType
gtype
  GValue -> a -> IO ()
valueSet GValue
gvalue a
val
  (\(Container ForeignPtr Container
arg1) (Widget ForeignPtr Widget
arg2) CString
arg3 (GValue Ptr GValue
arg4) -> ForeignPtr Container -> (Ptr Container -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Container
arg1 ((Ptr Container -> IO ()) -> IO ())
-> (Ptr Container -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr Container
argPtr1 ->ForeignPtr Widget -> (Ptr Widget -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Widget
arg2 ((Ptr Widget -> IO ()) -> IO ()) -> (Ptr Widget -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr Widget
argPtr2 ->Ptr Container -> Ptr Widget -> CString -> Ptr GValue -> IO ()
gtk_container_child_set_property Ptr Container
argPtr1 Ptr Widget
argPtr2 CString
arg3 Ptr GValue
arg4)
{-# LINE 70 "./Graphics/UI/Gtk/Abstract/ContainerChildProperties.chs" #-}
    (toContainer container)
    (child -> Widget
forall o. WidgetClass o => o -> Widget
toWidget child
child)
    CString
propertyNamePtr
    GValue
gvalue

containerChildGetPropertyInternal ::
 (ContainerClass container, WidgetClass child)
 => GType
 -> (GValue -> IO a)
 -> String
 -> child
 -> container
 -> IO a
containerChildGetPropertyInternal :: forall container child a.
(ContainerClass container, WidgetClass child) =>
GType -> (GValue -> IO a) -> String -> child -> container -> IO a
containerChildGetPropertyInternal GType
gtype GValue -> IO a
valueGet String
prop child
child container
container =
  String -> (CString -> IO a) -> IO a
forall a. String -> (CString -> IO a) -> IO a
withCString String
prop ((CString -> IO a) -> IO a) -> (CString -> IO a) -> IO a
forall a b. (a -> b) -> a -> b
$ \CString
propertyNamePtr ->
  (GValue -> IO a) -> IO a
forall b. (GValue -> IO b) -> IO b
allocaGValue ((GValue -> IO a) -> IO a) -> (GValue -> IO a) -> IO a
forall a b. (a -> b) -> a -> b
$ \GValue
gvalue -> do
  GValue -> GType -> IO ()
valueInit GValue
gvalue GType
gtype
  (\(Container ForeignPtr Container
arg1) (Widget ForeignPtr Widget
arg2) CString
arg3 (GValue Ptr GValue
arg4) -> ForeignPtr Container -> (Ptr Container -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Container
arg1 ((Ptr Container -> IO ()) -> IO ())
-> (Ptr Container -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr Container
argPtr1 ->ForeignPtr Widget -> (Ptr Widget -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Widget
arg2 ((Ptr Widget -> IO ()) -> IO ()) -> (Ptr Widget -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr Widget
argPtr2 ->Ptr Container -> Ptr Widget -> CString -> Ptr GValue -> IO ()
gtk_container_child_get_property Ptr Container
argPtr1 Ptr Widget
argPtr2 CString
arg3 Ptr GValue
arg4)
{-# LINE 88 "./Graphics/UI/Gtk/Abstract/ContainerChildProperties.chs" #-}
    (toContainer container)
    (child -> Widget
forall o. WidgetClass o => o -> Widget
toWidget child
child)
    CString
propertyNamePtr
    GValue
gvalue
  GValue -> IO a
valueGet GValue
gvalue

-- Versions for specific types:
-- we actually don't use any others than bool at the moment
--

containerChildGetPropertyBool :: (ContainerClass container, WidgetClass child)
 => String -> child -> container -> IO Bool
containerChildGetPropertyBool :: forall container child.
(ContainerClass container, WidgetClass child) =>
String -> child -> container -> IO Bool
containerChildGetPropertyBool =
          GType
-> (GValue -> IO Bool) -> String -> child -> container -> IO Bool
forall container child a.
(ContainerClass container, WidgetClass child) =>
GType -> (GValue -> IO a) -> String -> child -> container -> IO a
containerChildGetPropertyInternal GType
GType.bool GValue -> IO Bool
valueGetBool

containerChildSetPropertyBool :: (ContainerClass container, WidgetClass child)
 => String -> child -> container -> Bool -> IO ()
containerChildSetPropertyBool :: forall container child.
(ContainerClass container, WidgetClass child) =>
String -> child -> container -> Bool -> IO ()
containerChildSetPropertyBool =
          GType
-> (GValue -> Bool -> IO ())
-> String
-> child
-> container
-> Bool
-> IO ()
forall container child a.
(ContainerClass container, WidgetClass child) =>
GType
-> (GValue -> a -> IO ())
-> String
-> child
-> container
-> a
-> IO ()
containerChildSetPropertyInternal GType
GType.bool GValue -> Bool -> IO ()
valueSetBool

-- Convenience functions to make attribute implementations in the other modules
-- shorter and more easily extensible.
--

newAttrFromContainerChildIntProperty ::
 (ContainerClass container, WidgetClass child)
 => String -> child -> Attr container Int
newAttrFromContainerChildIntProperty :: forall container child.
(ContainerClass container, WidgetClass child) =>
String -> child -> Attr container Int
newAttrFromContainerChildIntProperty String
propName child
child = (container -> IO Int)
-> (container -> Int -> IO ()) -> ReadWriteAttr container Int Int
forall o a b.
(o -> IO a) -> (o -> b -> IO ()) -> ReadWriteAttr o a b
newAttr
  (GType
-> (GValue -> IO Int) -> String -> child -> container -> IO Int
forall container child a.
(ContainerClass container, WidgetClass child) =>
GType -> (GValue -> IO a) -> String -> child -> container -> IO a
containerChildGetPropertyInternal GType
GType.int GValue -> IO Int
valueGetInt String
propName child
child)
  (GType
-> (GValue -> Int -> IO ())
-> String
-> child
-> container
-> Int
-> IO ()
forall container child a.
(ContainerClass container, WidgetClass child) =>
GType
-> (GValue -> a -> IO ())
-> String
-> child
-> container
-> a
-> IO ()
containerChildSetPropertyInternal GType
GType.int GValue -> Int -> IO ()
valueSetInt String
propName child
child)

newAttrFromContainerChildUIntProperty ::
 (ContainerClass container, WidgetClass child)
 => String -> child -> Attr container Int
newAttrFromContainerChildUIntProperty :: forall container child.
(ContainerClass container, WidgetClass child) =>
String -> child -> Attr container Int
newAttrFromContainerChildUIntProperty String
propName child
child = (container -> IO Int)
-> (container -> Int -> IO ()) -> ReadWriteAttr container Int Int
forall o a b.
(o -> IO a) -> (o -> b -> IO ()) -> ReadWriteAttr o a b
newAttr
  (GType
-> (GValue -> IO Int) -> String -> child -> container -> IO Int
forall container child a.
(ContainerClass container, WidgetClass child) =>
GType -> (GValue -> IO a) -> String -> child -> container -> IO a
containerChildGetPropertyInternal GType
GType.uint
    (\GValue
gv -> (Word -> Int) -> IO Word -> IO Int
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM Word -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (IO Word -> IO Int) -> IO Word -> IO Int
forall a b. (a -> b) -> a -> b
$ GValue -> IO Word
valueGetUInt GValue
gv) String
propName child
child)
  (GType
-> (GValue -> Int -> IO ())
-> String
-> child
-> container
-> Int
-> IO ()
forall container child a.
(ContainerClass container, WidgetClass child) =>
GType
-> (GValue -> a -> IO ())
-> String
-> child
-> container
-> a
-> IO ()
containerChildSetPropertyInternal GType
GType.uint
    (\GValue
gv Int
v -> GValue -> Word -> IO ()
valueSetUInt GValue
gv (Int -> Word
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
v)) String
propName child
child)

newAttrFromContainerChildBoolProperty ::
 (ContainerClass container, WidgetClass child)
 => String -> child -> Attr container Bool
newAttrFromContainerChildBoolProperty :: forall container child.
(ContainerClass container, WidgetClass child) =>
String -> child -> Attr container Bool
newAttrFromContainerChildBoolProperty String
propName child
child = (container -> IO Bool)
-> (container -> Bool -> IO ())
-> ReadWriteAttr container Bool Bool
forall o a b.
(o -> IO a) -> (o -> b -> IO ()) -> ReadWriteAttr o a b
newAttr
  (GType
-> (GValue -> IO Bool) -> String -> child -> container -> IO Bool
forall container child a.
(ContainerClass container, WidgetClass child) =>
GType -> (GValue -> IO a) -> String -> child -> container -> IO a
containerChildGetPropertyInternal GType
GType.bool GValue -> IO Bool
valueGetBool String
propName child
child)
  (GType
-> (GValue -> Bool -> IO ())
-> String
-> child
-> container
-> Bool
-> IO ()
forall container child a.
(ContainerClass container, WidgetClass child) =>
GType
-> (GValue -> a -> IO ())
-> String
-> child
-> container
-> a
-> IO ()
containerChildSetPropertyInternal GType
GType.bool GValue -> Bool -> IO ()
valueSetBool String
propName child
child)

newAttrFromContainerChildEnumProperty ::
 (ContainerClass container, WidgetClass child, Enum enum)
 => String -> GType -> child -> Attr container enum
newAttrFromContainerChildEnumProperty :: forall container child enum.
(ContainerClass container, WidgetClass child, Enum enum) =>
String -> GType -> child -> Attr container enum
newAttrFromContainerChildEnumProperty String
propName GType
gtype child
child = (container -> IO enum)
-> (container -> enum -> IO ())
-> ReadWriteAttr container enum enum
forall o a b.
(o -> IO a) -> (o -> b -> IO ()) -> ReadWriteAttr o a b
newAttr
  (GType
-> (GValue -> IO enum) -> String -> child -> container -> IO enum
forall container child a.
(ContainerClass container, WidgetClass child) =>
GType -> (GValue -> IO a) -> String -> child -> container -> IO a
containerChildGetPropertyInternal GType
gtype GValue -> IO enum
forall enum. Enum enum => GValue -> IO enum
valueGetEnum String
propName child
child)
  (GType
-> (GValue -> enum -> IO ())
-> String
-> child
-> container
-> enum
-> IO ()
forall container child a.
(ContainerClass container, WidgetClass child) =>
GType
-> (GValue -> a -> IO ())
-> String
-> child
-> container
-> a
-> IO ()
containerChildSetPropertyInternal GType
gtype GValue -> enum -> IO ()
forall enum. Enum enum => GValue -> enum -> IO ()
valueSetEnum String
propName child
child)

newAttrFromContainerChildFlagsProperty ::
 (ContainerClass container, WidgetClass child, Flags flag)
 => String -> GType -> child -> Attr container [flag]
newAttrFromContainerChildFlagsProperty :: forall container child flag.
(ContainerClass container, WidgetClass child, Flags flag) =>
String -> GType -> child -> Attr container [flag]
newAttrFromContainerChildFlagsProperty String
propName GType
gtype child
child = (container -> IO [flag])
-> (container -> [flag] -> IO ())
-> ReadWriteAttr container [flag] [flag]
forall o a b.
(o -> IO a) -> (o -> b -> IO ()) -> ReadWriteAttr o a b
newAttr
  (GType
-> (GValue -> IO [flag])
-> String
-> child
-> container
-> IO [flag]
forall container child a.
(ContainerClass container, WidgetClass child) =>
GType -> (GValue -> IO a) -> String -> child -> container -> IO a
containerChildGetPropertyInternal GType
gtype GValue -> IO [flag]
forall flag. Flags flag => GValue -> IO [flag]
valueGetFlags String
propName child
child)
  (GType
-> (GValue -> [flag] -> IO ())
-> String
-> child
-> container
-> [flag]
-> IO ()
forall container child a.
(ContainerClass container, WidgetClass child) =>
GType
-> (GValue -> a -> IO ())
-> String
-> child
-> container
-> a
-> IO ()
containerChildSetPropertyInternal GType
gtype GValue -> [flag] -> IO ()
forall flag. Flags flag => GValue -> [flag] -> IO ()
valueSetFlags String
propName child
child)

newAttrFromContainerChildStringProperty ::
 (ContainerClass container, WidgetClass child, GlibString string)
 => String -> child -> Attr container string
newAttrFromContainerChildStringProperty :: forall container child string.
(ContainerClass container, WidgetClass child, GlibString string) =>
String -> child -> Attr container string
newAttrFromContainerChildStringProperty String
propName child
child = (container -> IO string)
-> (container -> string -> IO ())
-> ReadWriteAttr container string string
forall o a b.
(o -> IO a) -> (o -> b -> IO ()) -> ReadWriteAttr o a b
newAttr
  (GType
-> (GValue -> IO string)
-> String
-> child
-> container
-> IO string
forall container child a.
(ContainerClass container, WidgetClass child) =>
GType -> (GValue -> IO a) -> String -> child -> container -> IO a
containerChildGetPropertyInternal GType
GType.string GValue -> IO string
forall string. GlibString string => GValue -> IO string
valueGetString String
propName child
child)
  (GType
-> (GValue -> string -> IO ())
-> String
-> child
-> container
-> string
-> IO ()
forall container child a.
(ContainerClass container, WidgetClass child) =>
GType
-> (GValue -> a -> IO ())
-> String
-> child
-> container
-> a
-> IO ()
containerChildSetPropertyInternal GType
GType.string GValue -> string -> IO ()
forall string. GlibString string => GValue -> string -> IO ()
valueSetString String
propName child
child)

foreign import ccall safe "gtk_container_child_set_property"
  gtk_container_child_set_property :: ((Ptr Container) -> ((Ptr Widget) -> ((Ptr CChar) -> ((Ptr GValue) -> (IO ())))))

foreign import ccall safe "gtk_container_child_get_property"
  gtk_container_child_get_property :: ((Ptr Container) -> ((Ptr Widget) -> ((Ptr CChar) -> ((Ptr GValue) -> (IO ())))))