module Graphics.UI.Gtk.Recent.RecentFilter (
RecentFilter,
RecentFilterClass,
castToRecentFilter,
toRecentFilter,
RecentFilterFlags(..),
recentFilterNew,
recentFilterGetName,
recentFilterSetName,
recentFilterAddMimeType,
recentFilterAddPattern,
recentFilterAddPixbufFormats,
recentFilterAddApplication,
recentFilterAddGroup,
recentFilterAddAge,
) where
import System.Glib.FFI
import System.Glib.UTFString
import Graphics.UI.Gtk.Abstract.Object (makeNewObject)
import Graphics.UI.Gtk.Types
data RecentFilterFlags = RecentFilterUri
| RecentFilterDisplayName
| RecentFilterMimeType
| RecentFilterApplication
| RecentFilterGroup
| RecentFilterAge
deriving (Bounded,Eq,Show)
instance Enum RecentFilterFlags where
fromEnum RecentFilterUri = 1
fromEnum RecentFilterDisplayName = 2
fromEnum RecentFilterMimeType = 4
fromEnum RecentFilterApplication = 8
fromEnum RecentFilterGroup = 16
fromEnum RecentFilterAge = 32
toEnum 1 = RecentFilterUri
toEnum 2 = RecentFilterDisplayName
toEnum 4 = RecentFilterMimeType
toEnum 8 = RecentFilterApplication
toEnum 16 = RecentFilterGroup
toEnum 32 = RecentFilterAge
toEnum unmatched = error ("RecentFilterFlags.toEnum: Cannot match " ++ show unmatched)
succ RecentFilterUri = RecentFilterDisplayName
succ RecentFilterDisplayName = RecentFilterMimeType
succ RecentFilterMimeType = RecentFilterApplication
succ RecentFilterApplication = RecentFilterGroup
succ RecentFilterGroup = RecentFilterAge
succ _ = undefined
pred RecentFilterDisplayName = RecentFilterUri
pred RecentFilterMimeType = RecentFilterDisplayName
pred RecentFilterApplication = RecentFilterMimeType
pred RecentFilterGroup = RecentFilterApplication
pred RecentFilterAge = RecentFilterGroup
pred _ = undefined
enumFromTo x y | fromEnum x == fromEnum y = [ y ]
| otherwise = x : enumFromTo (succ x) y
enumFrom x = enumFromTo x RecentFilterAge
enumFromThen _ _ = error "Enum RecentFilterFlags: enumFromThen not implemented"
enumFromThenTo _ _ _ = error "Enum RecentFilterFlags: enumFromThenTo not implemented"
recentFilterNew :: IO RecentFilter
recentFilterNew =
makeNewObject mkRecentFilter $
gtk_recent_filter_new
recentFilterGetName :: (RecentFilterClass self, GlibString string) => self
-> IO string
recentFilterGetName self =
(\(RecentFilter arg1) -> withForeignPtr arg1 $ \argPtr1 ->gtk_recent_filter_get_name argPtr1)
(toRecentFilter self)
>>= peekUTFString
recentFilterSetName :: (RecentFilterClass self, GlibString string) => self
-> string
-> IO ()
recentFilterSetName self name =
withUTFString name $ \namePtr ->
(\(RecentFilter arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->gtk_recent_filter_set_name argPtr1 arg2)
(toRecentFilter self)
namePtr
recentFilterAddMimeType :: (RecentFilterClass self, GlibString string) => self
-> string
-> IO ()
recentFilterAddMimeType self mimeType =
withUTFString mimeType $ \mimeTypePtr ->
(\(RecentFilter arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->gtk_recent_filter_add_mime_type argPtr1 arg2)
(toRecentFilter self)
mimeTypePtr
recentFilterAddPattern :: (RecentFilterClass self, GlibString string) => self
-> string
-> IO ()
recentFilterAddPattern self pattern =
withUTFString pattern $ \patternPtr ->
(\(RecentFilter arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->gtk_recent_filter_add_pattern argPtr1 arg2)
(toRecentFilter self)
patternPtr
recentFilterAddPixbufFormats :: RecentFilterClass self => self -> IO ()
recentFilterAddPixbufFormats self =
(\(RecentFilter arg1) -> withForeignPtr arg1 $ \argPtr1 ->gtk_recent_filter_add_pixbuf_formats argPtr1)
(toRecentFilter self)
recentFilterAddApplication :: (RecentFilterClass self, GlibString string) => self
-> string
-> IO ()
recentFilterAddApplication self application =
withUTFString application $ \applicationPtr ->
(\(RecentFilter arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->gtk_recent_filter_add_application argPtr1 arg2)
(toRecentFilter self)
applicationPtr
recentFilterAddGroup :: (RecentFilterClass self, GlibString string) => self
-> string
-> IO ()
recentFilterAddGroup self group =
withUTFString group $ \groupPtr ->
(\(RecentFilter arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->gtk_recent_filter_add_group argPtr1 arg2)
(toRecentFilter self)
groupPtr
recentFilterAddAge :: RecentFilterClass self => self
-> Int
-> IO ()
recentFilterAddAge self days =
(\(RecentFilter arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->gtk_recent_filter_add_age argPtr1 arg2)
(toRecentFilter self)
(fromIntegral days)
foreign import ccall safe "gtk_recent_filter_new"
gtk_recent_filter_new :: (IO (Ptr RecentFilter))
foreign import ccall safe "gtk_recent_filter_get_name"
gtk_recent_filter_get_name :: ((Ptr RecentFilter) -> (IO (Ptr CChar)))
foreign import ccall safe "gtk_recent_filter_set_name"
gtk_recent_filter_set_name :: ((Ptr RecentFilter) -> ((Ptr CChar) -> (IO ())))
foreign import ccall safe "gtk_recent_filter_add_mime_type"
gtk_recent_filter_add_mime_type :: ((Ptr RecentFilter) -> ((Ptr CChar) -> (IO ())))
foreign import ccall safe "gtk_recent_filter_add_pattern"
gtk_recent_filter_add_pattern :: ((Ptr RecentFilter) -> ((Ptr CChar) -> (IO ())))
foreign import ccall safe "gtk_recent_filter_add_pixbuf_formats"
gtk_recent_filter_add_pixbuf_formats :: ((Ptr RecentFilter) -> (IO ()))
foreign import ccall safe "gtk_recent_filter_add_application"
gtk_recent_filter_add_application :: ((Ptr RecentFilter) -> ((Ptr CChar) -> (IO ())))
foreign import ccall safe "gtk_recent_filter_add_group"
gtk_recent_filter_add_group :: ((Ptr RecentFilter) -> ((Ptr CChar) -> (IO ())))
foreign import ccall safe "gtk_recent_filter_add_age"
gtk_recent_filter_add_age :: ((Ptr RecentFilter) -> (CInt -> (IO ())))