{-# LINE 2 "./Graphics/UI/Gtk/Selectors/FileFilter.chs" #-}-- -*-haskell-*--- GIMP Toolkit (GTK) Widget FileFilter---- Author : Duncan Coutts---- Created: 26 February 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.---- |-- Maintainer : gtk2hs-users@lists.sourceforge.net-- Stability : provisional-- Portability : portable (depends on GHC)---- A filter for selecting a file subset---- * Module available since Gtk+ version 2.4--moduleGraphics.UI.Gtk.Selectors.FileFilter(-- * Detail---- | A 'FileFilter' can be used to restrict the files being shown in a-- 'FileChooser'. Files can be filtered based on their name (with-- 'fileFilterAddPattern'), on their mime type (with 'fileFilterAddMimeType'),-- or by a custom filter function (with 'fileFilterAddCustom').---- Filtering by mime types handles aliasing and subclassing of mime types;-- e.g. a filter for \"text\/plain\" also matches a file with mime type-- \"application\/rtf\", since \"application\/rtf\" is a subclass of-- \"text\/plain\". Note that 'FileFilter' allows wildcards for the subtype of-- a mime type, so you can e.g. filter for \"image\/\*\".---- Normally, filters are used by adding them to a 'FileChooser', see-- 'Graphics.UI.Gtk.Selectors.FileChooser.fileChooserAddFilter'.-- * Class Hierarchy-- |-- @-- | 'GObject'-- | +----'Object'-- | +----FileFilter-- @-- * TypesFileFilter,FileFilterClass,castToFileFilter,gTypeFileFilter,toFileFilter,FileFilterFlags(..),-- * ConstructorsfileFilterNew,-- * MethodsfileFilterSetName,fileFilterGetName,fileFilterAddMimeType,fileFilterAddPattern,fileFilterAddCustom,fileFilterAddPixbufFormats,-- * AttributesfileFilterName,)whereimportControl.Monad(liftM)importSystem.Glib.FFIimportSystem.Glib.Flags(Flags,fromFlags)importSystem.Glib.UTFStringimportSystem.Glib.AttributesimportSystem.Glib.GObject(DestroyNotify,destroyFunPtr)importGraphics.UI.Gtk.Types{-# LINE 89 "./Graphics/UI/Gtk/Selectors/FileFilter.chs" #-}importGraphics.UI.Gtk.Abstract.Object(makeNewObject){-# LINE 92 "./Graphics/UI/Gtk/Selectors/FileFilter.chs" #-}dataFileFilterFlags=FileFilterFilename|FileFilterUri|FileFilterDisplayName|FileFilterMimeTypederiving(Bounded,Show,Eq)instanceEnumFileFilterFlagswherefromEnumFileFilterFilename=1fromEnumFileFilterUri=2fromEnumFileFilterDisplayName=4fromEnumFileFilterMimeType=8toEnum1=FileFilterFilenametoEnum2=FileFilterUritoEnum4=FileFilterDisplayNametoEnum8=FileFilterMimeTypetoEnumunmatched=error("FileFilterFlags.toEnum: Cannot match "++showunmatched)succFileFilterFilename=FileFilterUrisuccFileFilterUri=FileFilterDisplayNamesuccFileFilterDisplayName=FileFilterMimeTypesucc_=undefinedpredFileFilterUri=FileFilterFilenamepredFileFilterDisplayName=FileFilterUripredFileFilterMimeType=FileFilterDisplayNamepred_=undefinedenumFromToxy|fromEnumx==fromEnumy=[y]|otherwise=x:enumFromTo(succx)yenumFromx=enumFromToxFileFilterMimeTypeenumFromThen__=error"Enum FileFilterFlags: enumFromThen not implemented"enumFromThenTo___=error"Enum FileFilterFlags: enumFromThenTo not implemented"{-# LINE 96 "./Graphics/UI/Gtk/Selectors/FileFilter.chs" #-}instanceFlagsFileFilterFlags---------------------- Constructors-- | Creates a new 'FileFilter' with no rules added to it. Such a filter-- doesn't accept any files, so is not particularly useful until you add rules-- with 'fileFilterAddMimeType', 'fileFilterAddPattern', or-- 'fileFilterAddCustom'.--fileFilterNew::IOFileFilterfileFilterNew=makeNewObjectmkFileFilter$gtk_file_filter_new{-# LINE 110 "./Graphics/UI/Gtk/Selectors/FileFilter.chs" #-}---------------------- Methods-- | Sets the human-readable name of the filter; this is the string that will-- be displayed in the file selector user interface if there is a selectable-- list of filters.--fileFilterSetName::FileFilter->String-- ^ @name@ - the human-readable-name for the filter->IO()fileFilterSetNameselfname=withUTFStringname$\namePtr->(\(FileFilterarg1)arg2->withForeignPtrarg1$\argPtr1->gtk_file_filter_set_nameargPtr1arg2){-# LINE 124 "./Graphics/UI/Gtk/Selectors/FileFilter.chs" #-}selfnamePtr-- | Gets the human-readable name for the filter. See 'fileFilterSetName'.--fileFilterGetName::FileFilter->IOString-- ^ returns The human-readable name of the filterfileFilterGetNameself=(\(FileFilterarg1)->withForeignPtrarg1$\argPtr1->gtk_file_filter_get_nameargPtr1){-# LINE 133 "./Graphics/UI/Gtk/Selectors/FileFilter.chs" #-}self>>=peekUTFString-- | Adds a rule allowing a given mime type to @filter@.--fileFilterAddMimeType::FileFilter->String-- ^ @mimeType@ - name of a MIME type->IO()fileFilterAddMimeTypeselfmimeType=withUTFStringmimeType$\mimeTypePtr->(\(FileFilterarg1)arg2->withForeignPtrarg1$\argPtr1->gtk_file_filter_add_mime_typeargPtr1arg2){-# LINE 144 "./Graphics/UI/Gtk/Selectors/FileFilter.chs" #-}selfmimeTypePtr-- | Adds a rule allowing a shell style glob to a filter.--fileFilterAddPattern::FileFilter->String-- ^ @pattern@ - a shell style glob->IO()fileFilterAddPatternselfpattern=withUTFStringpattern$\patternPtr->(\(FileFilterarg1)arg2->withForeignPtrarg1$\argPtr1->gtk_file_filter_add_patternargPtr1arg2){-# LINE 155 "./Graphics/UI/Gtk/Selectors/FileFilter.chs" #-}selfpatternPtr-- | Adds rule to a filter that allows files based on a custom callback-- function. The list of flags @needed@ which is passed in provides information-- about what sorts of information that the filter function needs; this allows-- Gtk+ to avoid retrieving expensive information when it isn't needed by the-- filter.--fileFilterAddCustom::FileFilter->[FileFilterFlags]-- ^ @needed@ - list of flags indicating the-- information that the custom filter function needs.->(MaybeString-- filename->MaybeString-- uri->MaybeString-- display name->MaybeString-- mime type->IOBool)-- ^ @(\filename uri displayName mimeType -> ...)@ --- filter function; if the function-- returns @True@, then the file will be displayed.->IO()fileFilterAddCustomselfneededfunc=dohPtr<-mkHandler_GtkFileFilterFunc(\filterInfoPtr_->dofilenamePtr<-(\ptr->do{peekByteOffptr4::IO(PtrCChar)})filterInfoPtruriPtr<-(\ptr->do{peekByteOffptr8::IO(PtrCChar)})filterInfoPtrdisplayNamePtr<-(\ptr->do{peekByteOffptr12::IO(PtrCChar)})filterInfoPtrmimeTypePtr<-(\ptr->do{peekByteOffptr16::IO(PtrCChar)})filterInfoPtrfilename<-maybePeekpeekUTFStringfilenamePtruri<-maybePeekpeekUTFStringuriPtrdisplayName<-maybePeekpeekUTFStringdisplayNamePtrmimeType<-maybePeekpeekUTFStringmimeTypePtrliftMfromBool$funcfilenameuridisplayNamemimeType)(\(FileFilterarg1)arg2arg3arg4arg5->withForeignPtrarg1$\argPtr1->gtk_file_filter_add_customargPtr1arg2arg3arg4arg5){-# LINE 188 "./Graphics/UI/Gtk/Selectors/FileFilter.chs" #-}self((fromIntegral.fromFlags)needed)hPtr(castFunPtrToPtrhPtr)destroyFunPtrtypeGtkFileFilterInfoPtr=Ptr(()){-# LINE 195 "./Graphics/UI/Gtk/Selectors/FileFilter.chs" #-}typeGtkFileFilterFunc=GtkFileFilterInfoPtr->--GtkFileFilterInfo *filter_infoPtr()->--gpointer user_dataIOCIntforeignimportccall"wrapper"mkHandler_GtkFileFilterFunc::GtkFileFilterFunc->IO(FunPtrGtkFileFilterFunc)-- | Adds a rule allowing image files in the formats supported by 'Pixbuf'.---- * Available since Gtk+ version 2.6--fileFilterAddPixbufFormats::FileFilter->IO()fileFilterAddPixbufFormatsself=(\(FileFilterarg1)->withForeignPtrarg1$\argPtr1->gtk_file_filter_add_pixbuf_formatsargPtr1){-# LINE 213 "./Graphics/UI/Gtk/Selectors/FileFilter.chs" #-}self---------------------- Attributes-- | \'name\' property. See 'fileFilterGetName' and 'fileFilterSetName'--fileFilterName::AttrFileFilterStringfileFilterName=newAttrfileFilterGetNamefileFilterSetNameforeignimportccallsafe"gtk_file_filter_new"gtk_file_filter_new::(IO(PtrFileFilter))foreignimportccallsafe"gtk_file_filter_set_name"gtk_file_filter_set_name::((PtrFileFilter)->((PtrCChar)->(IO())))foreignimportccallsafe"gtk_file_filter_get_name"gtk_file_filter_get_name::((PtrFileFilter)->(IO(PtrCChar)))foreignimportccallsafe"gtk_file_filter_add_mime_type"gtk_file_filter_add_mime_type::((PtrFileFilter)->((PtrCChar)->(IO())))foreignimportccallsafe"gtk_file_filter_add_pattern"gtk_file_filter_add_pattern::((PtrFileFilter)->((PtrCChar)->(IO())))foreignimportccallsafe"gtk_file_filter_add_custom"gtk_file_filter_add_custom::((PtrFileFilter)->(CInt->((FunPtr((Ptr())->((Ptr())->(IOCInt))))->((Ptr())->((FunPtr((Ptr())->(IO())))->(IO()))))))foreignimportccallsafe"gtk_file_filter_add_pixbuf_formats"gtk_file_filter_add_pixbuf_formats::((PtrFileFilter)->(IO()))