{-# LINE 2 "./System/GIO/Icons/FileIcon.chs" #-}
-- GIMP Toolkit (GTK) Binding for Haskell: binding to gio -*-haskell-*-
--
-- Author : Andy Stewart
-- Created: 30-Apirl-2010
--
-- Copyright (c) 2010 Andy Stewart
--
-- 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 3 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.
--
-- You should have received a copy of the GNU Lesser General Public
-- License along with this program. If not, see
-- <http:
--
-- GIO, the C library which this Haskell library depends on, is
-- available under LGPL Version 2. The documentation included with
-- this library is based on the original GIO documentation.
--
-- | Maintainer : gtk2hs-devel@lists.sourceforge.net
-- Stability : alpha
-- Portability : portable (depends on GHC)
module System.GIO.Icons.FileIcon (
-- * Details
--
-- | 'FileIcon' specifies an icon by pointing to an image file to be used as icon.

-- * Types
    FileIcon(..),
    FileIconClass,

-- * Methods
    fileIconNew,
    fileIconGetFile,
    ) where

import Control.Monad
import System.GIO.Enums
import System.Glib.FFI
import System.Glib.Flags
import System.Glib.GError
import System.Glib.GObject
import System.Glib.UTFString
import System.GIO.Types
{-# LINE 52 "./System/GIO/Icons/FileIcon.chs" #-}


{-# LINE 54 "./System/GIO/Icons/FileIcon.chs" #-}

-------------------
-- Methods
-- | Creates a new icon for a file.
fileIconNew :: FileClass file => file -> IO FileIcon
fileIconNew :: forall file. FileClass file => file -> IO FileIcon
fileIconNew file
file =
  (\(File ForeignPtr File
arg1) -> ForeignPtr File -> (Ptr File -> IO (Ptr Icon)) -> IO (Ptr Icon)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr File
arg1 ((Ptr File -> IO (Ptr Icon)) -> IO (Ptr Icon))
-> (Ptr File -> IO (Ptr Icon)) -> IO (Ptr Icon)
forall a b. (a -> b) -> a -> b
$ \Ptr File
argPtr1 ->Ptr File -> IO (Ptr Icon)
g_file_icon_new Ptr File
argPtr1) (file -> File
forall o. FileClass o => o -> File
toFile file
file)
  IO (Ptr Icon) -> (Ptr Icon -> IO FileIcon) -> IO FileIcon
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ((ForeignPtr FileIcon -> FileIcon, FinalizerPtr FileIcon)
-> IO (Ptr FileIcon) -> IO FileIcon
forall obj.
GObjectClass obj =>
(ForeignPtr obj -> obj, FinalizerPtr obj) -> IO (Ptr obj) -> IO obj
wrapNewGObject (ForeignPtr FileIcon -> FileIcon, FinalizerPtr FileIcon)
forall {a}. (ForeignPtr FileIcon -> FileIcon, FinalizerPtr a)
mkFileIcon (IO (Ptr FileIcon) -> IO FileIcon)
-> (Ptr FileIcon -> IO (Ptr FileIcon))
-> Ptr FileIcon
-> IO FileIcon
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Ptr FileIcon -> IO (Ptr FileIcon)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return) (Ptr FileIcon -> IO FileIcon)
-> (Ptr Icon -> Ptr FileIcon) -> Ptr Icon -> IO FileIcon
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Ptr Icon -> Ptr FileIcon
forall a b. Ptr a -> Ptr b
castPtr

-- | Gets the 'File' associated with the given icon.
fileIconGetFile :: FileIconClass icon => icon -> IO File
fileIconGetFile :: forall icon. FileIconClass icon => icon -> IO File
fileIconGetFile icon
icon =
  (ForeignPtr File -> File, FinalizerPtr File)
-> IO (Ptr File) -> IO File
forall obj.
GObjectClass obj =>
(ForeignPtr obj -> obj, FinalizerPtr obj) -> IO (Ptr obj) -> IO obj
makeNewGObject (ForeignPtr File -> File, FinalizerPtr File)
forall {a}. (ForeignPtr File -> File, FinalizerPtr a)
mkFile (IO (Ptr File) -> IO File) -> IO (Ptr File) -> IO File
forall a b. (a -> b) -> a -> b
$
  (\(FileIcon ForeignPtr FileIcon
arg1) -> ForeignPtr FileIcon
-> (Ptr FileIcon -> IO (Ptr File)) -> IO (Ptr File)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr FileIcon
arg1 ((Ptr FileIcon -> IO (Ptr File)) -> IO (Ptr File))
-> (Ptr FileIcon -> IO (Ptr File)) -> IO (Ptr File)
forall a b. (a -> b) -> a -> b
$ \Ptr FileIcon
argPtr1 ->Ptr FileIcon -> IO (Ptr File)
g_file_icon_get_file Ptr FileIcon
argPtr1) (icon -> FileIcon
forall o. FileIconClass o => o -> FileIcon
toFileIcon icon
icon)

foreign import ccall safe "g_file_icon_new"
  g_file_icon_new :: ((Ptr File) -> (IO (Ptr Icon)))

foreign import ccall safe "g_file_icon_get_file"
  g_file_icon_get_file :: ((Ptr FileIcon) -> (IO (Ptr File)))