{-# LINE 2 "./Graphics/UI/Gtk/ModelView/CellLayout.chs" #-}
module Graphics.UI.Gtk.ModelView.CellLayout (
CellLayoutClass,
toCellLayout,
cellLayoutPackStart,
cellLayoutPackEnd,
cellLayoutReorder,
cellLayoutClear,
cellLayoutClearAttributes,
cellLayoutGetCells,
cellLayoutAddColumnAttribute,
cellLayoutSetAttributes,
cellLayoutSetAttributeFunc,
) where
import System.Glib.FFI
import System.Glib.GList
import System.Glib.Attributes
import System.Glib.GType
import Graphics.UI.Gtk.Types
{-# LINE 73 "./Graphics/UI/Gtk/ModelView/CellLayout.chs" #-}
import Graphics.UI.Gtk.ModelView.Types
{-# LINE 74 "./Graphics/UI/Gtk/ModelView/CellLayout.chs" #-}
import Graphics.UI.Gtk.ModelView.TreeModel
{-# LINE 75 "./Graphics/UI/Gtk/ModelView/CellLayout.chs" #-}
import Graphics.UI.Gtk.ModelView.CustomStore (treeModelGetRow)
{-# LINE 78 "./Graphics/UI/Gtk/ModelView/CellLayout.chs" #-}
instance CellLayoutClass CellView
instance CellLayoutClass IconView
instance CellLayoutClass EntryCompletion
instance CellLayoutClass TreeViewColumn
instance CellLayoutClass ComboBox
cellLayoutPackStart :: (CellLayoutClass self, CellRendererClass cell) => self
-> cell
-> Bool
-> IO ()
cellLayoutPackStart self cell expand =
(\(CellLayout arg1) (CellRenderer arg2) arg3 -> withForeignPtr arg1 $ \argPtr1 ->withForeignPtr arg2 $ \argPtr2 ->gtk_cell_layout_pack_start argPtr1 argPtr2 arg3)
{-# LINE 109 "./Graphics/UI/Gtk/ModelView/CellLayout.chs" #-}
(toCellLayout self)
(toCellRenderer cell)
(fromBool expand)
cellLayoutPackEnd :: (CellLayoutClass self, CellRendererClass cell) => self
-> cell
-> Bool
-> IO ()
cellLayoutPackEnd self cell expand =
(\(CellLayout arg1) (CellRenderer arg2) arg3 -> withForeignPtr arg1 $ \argPtr1 ->withForeignPtr arg2 $ \argPtr2 ->gtk_cell_layout_pack_end argPtr1 argPtr2 arg3)
{-# LINE 126 "./Graphics/UI/Gtk/ModelView/CellLayout.chs" #-}
(toCellLayout self)
(toCellRenderer cell)
(fromBool expand)
cellLayoutReorder :: (CellLayoutClass self, CellRendererClass cell) => self
-> cell
-> Int
-> IO ()
cellLayoutReorder self cell position =
(\(CellLayout arg1) (CellRenderer arg2) arg3 -> withForeignPtr arg1 $ \argPtr1 ->withForeignPtr arg2 $ \argPtr2 ->gtk_cell_layout_reorder argPtr1 argPtr2 arg3)
{-# LINE 139 "./Graphics/UI/Gtk/ModelView/CellLayout.chs" #-}
(toCellLayout self)
(toCellRenderer cell)
(fromIntegral position)
cellLayoutClear :: CellLayoutClass self => self -> IO ()
cellLayoutClear self =
(\(CellLayout arg1) -> withForeignPtr arg1 $ \argPtr1 ->gtk_cell_layout_clear argPtr1)
{-# LINE 148 "./Graphics/UI/Gtk/ModelView/CellLayout.chs" #-}
(toCellLayout self)
cellLayoutGetCells :: CellLayoutClass self => self
-> IO [CellRenderer]
cellLayoutGetCells self =
(\(CellLayout arg1) -> withForeignPtr arg1 $ \argPtr1 ->gtk_cell_layout_get_cells argPtr1)
{-# LINE 159 "./Graphics/UI/Gtk/ModelView/CellLayout.chs" #-}
(toCellLayout self)
>>= fromGList
>>= mapM (makeNewGObject mkCellRenderer . return)
cellLayoutAddColumnAttribute :: (CellLayoutClass self, CellRendererClass cell) => self
-> cell
-> ReadWriteAttr cell a v
-> ColumnId row v
-> IO ()
cellLayoutAddColumnAttribute self cell attr column =
withCString (show attr) $ \attributePtr ->
(\(CellLayout arg1) (CellRenderer arg2) arg3 arg4 -> withForeignPtr arg1 $ \argPtr1 ->withForeignPtr arg2 $ \argPtr2 ->gtk_cell_layout_add_attribute argPtr1 argPtr2 arg3 arg4)
{-# LINE 179 "./Graphics/UI/Gtk/ModelView/CellLayout.chs" #-}
(toCellLayout self)
(toCellRenderer cell)
attributePtr
(fromIntegral (columnIdToNumber column))
cellLayoutSetAttributes :: (CellLayoutClass self,
CellRendererClass cell,
TreeModelClass (model row),
TypedTreeModelClass model)
=> self
-> cell
-> model row
-> (row -> [AttrOp cell])
-> IO ()
cellLayoutSetAttributes self cell model attributes =
cellLayoutSetAttributeFunc self cell model $ \iter -> do
row <- treeModelGetRow model iter
set cell (attributes row)
cellLayoutSetAttributeFunc :: (CellLayoutClass self,
CellRendererClass cell,
TreeModelClass model)
=> self
-> cell
-> model
-> (TreeIter -> IO ())
-> IO ()
cellLayoutSetAttributeFunc self cell model func = do
fPtr <- mkSetAttributeFunc $ \_ cellPtr' modelPtr' iterPtr _ -> do
iter <- convertIterFromParentToChildModel iterPtr modelPtr'
(toTreeModel model)
let (CellRenderer cellPtr) = toCellRenderer cell
if unsafeForeignPtrToPtr cellPtr /= cellPtr' then
error ("cellLayoutSetAttributeFunc: attempt to set attributes of "++
"a different CellRenderer.")
else func iter
(\(CellLayout arg1) (CellRenderer arg2) arg3 arg4 arg5 -> withForeignPtr arg1 $ \argPtr1 ->withForeignPtr arg2 $ \argPtr2 ->gtk_cell_layout_set_cell_data_func argPtr1 argPtr2 arg3 arg4 arg5) (toCellLayout self)
(toCellRenderer cell) fPtr (castFunPtrToPtr fPtr) destroyFunPtr
type CellLayoutDataFunc = FunPtr (((Ptr CellLayout) -> ((Ptr CellRenderer) -> ((Ptr TreeModel) -> ((Ptr TreeIter) -> ((Ptr ()) -> (IO ())))))))
{-# LINE 239 "./Graphics/UI/Gtk/ModelView/CellLayout.chs" #-}
foreign import ccall "wrapper" mkSetAttributeFunc ::
(Ptr CellLayout -> Ptr CellRenderer -> Ptr TreeModel -> Ptr TreeIter ->
Ptr () -> IO ()) -> IO CellLayoutDataFunc
convertIterFromParentToChildModel ::
Ptr TreeIter
-> Ptr TreeModel
-> TreeModel
-> IO TreeIter
convertIterFromParentToChildModel iterPtr parentModelPtr childModel =
let (TreeModel modelFPtr) = childModel
modelPtr = unsafeForeignPtrToPtr modelFPtr in
if modelPtr==parentModelPtr then peek iterPtr else
if typeInstanceIsA (castPtr parentModelPtr) gTypeTreeModelFilter then
alloca $ \childIterPtr -> do
treeModelFilterConvertIterToChildIter parentModelPtr childIterPtr iterPtr
childPtr <- treeModelFilterGetModel parentModelPtr
if childPtr==modelPtr then peek childIterPtr else
convertIterFromParentToChildModel childIterPtr childPtr childModel
else if typeInstanceIsA (castPtr parentModelPtr) gTypeTreeModelSort then
alloca $ \childIterPtr -> do
treeModelSortConvertIterToChildIter parentModelPtr childIterPtr iterPtr
childPtr <- treeModelSortGetModel parentModelPtr
if childPtr==modelPtr then peek childIterPtr else
convertIterFromParentToChildModel childIterPtr childPtr childModel
else do
iter <- peek iterPtr
error ("CellLayout: don't know how to convert iter "++show iter++
" from model "++show parentModelPtr++" to model "++
show modelPtr++". Is it possible that you are setting the "++
"attributes of a CellRenderer using a different model than "++
"that which was set in the view?")
foreign import ccall unsafe "gtk_tree_model_filter_get_model"
treeModelFilterGetModel :: Ptr TreeModel -> IO (Ptr TreeModel)
foreign import ccall safe "gtk_tree_model_filter_convert_iter_to_child_iter"
treeModelFilterConvertIterToChildIter :: Ptr TreeModel -> Ptr TreeIter ->
Ptr TreeIter -> IO ()
foreign import ccall unsafe "gtk_tree_model_sort_get_model"
treeModelSortGetModel :: Ptr TreeModel -> IO (Ptr TreeModel)
foreign import ccall safe "gtk_tree_model_sort_convert_iter_to_child_iter"
treeModelSortConvertIterToChildIter :: Ptr TreeModel -> Ptr TreeIter ->
Ptr TreeIter -> IO ()
cellLayoutClearAttributes :: (CellLayoutClass self, CellRendererClass cell) => self
-> cell
-> IO ()
cellLayoutClearAttributes self cell =
(\(CellLayout arg1) (CellRenderer arg2) -> withForeignPtr arg1 $ \argPtr1 ->withForeignPtr arg2 $ \argPtr2 ->gtk_cell_layout_clear_attributes argPtr1 argPtr2)
{-# LINE 305 "./Graphics/UI/Gtk/ModelView/CellLayout.chs" #-}
(toCellLayout self)
(toCellRenderer cell)
foreign import ccall safe "gtk_cell_layout_pack_start"
gtk_cell_layout_pack_start :: ((Ptr CellLayout) -> ((Ptr CellRenderer) -> (CInt -> (IO ()))))
foreign import ccall safe "gtk_cell_layout_pack_end"
gtk_cell_layout_pack_end :: ((Ptr CellLayout) -> ((Ptr CellRenderer) -> (CInt -> (IO ()))))
foreign import ccall safe "gtk_cell_layout_reorder"
gtk_cell_layout_reorder :: ((Ptr CellLayout) -> ((Ptr CellRenderer) -> (CInt -> (IO ()))))
foreign import ccall safe "gtk_cell_layout_clear"
gtk_cell_layout_clear :: ((Ptr CellLayout) -> (IO ()))
foreign import ccall safe "gtk_cell_layout_get_cells"
gtk_cell_layout_get_cells :: ((Ptr CellLayout) -> (IO (Ptr ())))
foreign import ccall safe "gtk_cell_layout_add_attribute"
gtk_cell_layout_add_attribute :: ((Ptr CellLayout) -> ((Ptr CellRenderer) -> ((Ptr CChar) -> (CInt -> (IO ())))))
foreign import ccall safe "gtk_cell_layout_set_cell_data_func"
gtk_cell_layout_set_cell_data_func :: ((Ptr CellLayout) -> ((Ptr CellRenderer) -> ((FunPtr ((Ptr CellLayout) -> ((Ptr CellRenderer) -> ((Ptr TreeModel) -> ((Ptr TreeIter) -> ((Ptr ()) -> (IO ()))))))) -> ((Ptr ()) -> ((FunPtr ((Ptr ()) -> (IO ()))) -> (IO ()))))))
foreign import ccall safe "gtk_cell_layout_clear_attributes"
gtk_cell_layout_clear_attributes :: ((Ptr CellLayout) -> ((Ptr CellRenderer) -> (IO ())))