Copyright | Will Thompson Iñaki García Etxebarria and Jonas Platte |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
A GtkFileFilter can be used to restrict the files being shown in a
FileChooser
. Files can be filtered based on their name (with
fileFilterAddPattern
) or on their mime type (with
fileFilterAddMimeType
).
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, file filters are used by adding them to a FileChooser
(see fileChooserAddFilter
), but it is also possible to
manually use a file filter on any FilterListModel
containing
FileInfo
objects.
GtkFileFilter as GtkBuildable
The GtkFileFilter implementation of the GtkBuildable interface
supports adding rules using the <mime-types> and <patterns>
elements and listing the rules within. Specifying a <mime-type>
or <pattern> has the same effect as as calling
fileFilterAddMimeType
or fileFilterAddPattern
.
An example of a UI definition fragment specifying GtkFileFilter rules: > >class="GtkFileFilter" > name="name" translatable="yes"Text and Images/property > mime-types > mime-typetextplain<mime-type> > mime-typeimage *<mime-type> > /mime-types > patterns > pattern*.txt/pattern > pattern*.png/pattern > /patterns >/object
Synopsis
- newtype FileFilter = FileFilter (ManagedPtr FileFilter)
- class (GObject o, IsDescendantOf FileFilter o) => IsFileFilter o
- toFileFilter :: (MonadIO m, IsFileFilter o) => o -> m FileFilter
- fileFilterAddMimeType :: (HasCallStack, MonadIO m, IsFileFilter a) => a -> Text -> m ()
- fileFilterAddPattern :: (HasCallStack, MonadIO m, IsFileFilter a) => a -> Text -> m ()
- fileFilterAddPixbufFormats :: (HasCallStack, MonadIO m, IsFileFilter a) => a -> m ()
- fileFilterGetAttributes :: (HasCallStack, MonadIO m, IsFileFilter a) => a -> m [Text]
- fileFilterGetName :: (HasCallStack, MonadIO m, IsFileFilter a) => a -> m (Maybe Text)
- fileFilterNew :: (HasCallStack, MonadIO m) => m FileFilter
- fileFilterNewFromGvariant :: (HasCallStack, MonadIO m) => GVariant -> m FileFilter
- fileFilterSetName :: (HasCallStack, MonadIO m, IsFileFilter a) => a -> Maybe Text -> m ()
- fileFilterToGvariant :: (HasCallStack, MonadIO m, IsFileFilter a) => a -> m GVariant
- clearFileFilterName :: (MonadIO m, IsFileFilter o) => o -> m ()
- constructFileFilterName :: (IsFileFilter o, MonadIO m) => Text -> m (GValueConstruct o)
- getFileFilterName :: (MonadIO m, IsFileFilter o) => o -> m (Maybe Text)
- setFileFilterName :: (MonadIO m, IsFileFilter o) => o -> Text -> m ()
Exported types
newtype FileFilter Source #
Memory-managed wrapper type.
FileFilter (ManagedPtr FileFilter) |
Instances
Eq FileFilter Source # | |
Defined in GI.Gtk.Objects.FileFilter (==) :: FileFilter -> FileFilter -> Bool # (/=) :: FileFilter -> FileFilter -> Bool # | |
GObject FileFilter Source # | |
Defined in GI.Gtk.Objects.FileFilter | |
ManagedPtrNewtype FileFilter Source # | |
Defined in GI.Gtk.Objects.FileFilter toManagedPtr :: FileFilter -> ManagedPtr FileFilter | |
TypedObject FileFilter Source # | |
Defined in GI.Gtk.Objects.FileFilter | |
HasParentTypes FileFilter Source # | |
Defined in GI.Gtk.Objects.FileFilter | |
IsGValue (Maybe FileFilter) Source # | Convert |
Defined in GI.Gtk.Objects.FileFilter gvalueGType_ :: IO GType gvalueSet_ :: Ptr GValue -> Maybe FileFilter -> IO () gvalueGet_ :: Ptr GValue -> IO (Maybe FileFilter) | |
type ParentTypes FileFilter Source # | |
Defined in GI.Gtk.Objects.FileFilter |
class (GObject o, IsDescendantOf FileFilter o) => IsFileFilter o Source #
Type class for types which can be safely cast to FileFilter
, for instance with toFileFilter
.
Instances
(GObject o, IsDescendantOf FileFilter o) => IsFileFilter o Source # | |
Defined in GI.Gtk.Objects.FileFilter |
toFileFilter :: (MonadIO m, IsFileFilter o) => o -> m FileFilter Source #
Cast to FileFilter
, for types for which this is known to be safe. For general casts, use castTo
.
Methods
Click to display all available methods, including inherited ones
Methods
addMimeType, addPattern, addPixbufFormats, bindProperty, bindPropertyFull, changed, forceFloating, freezeNotify, getv, isFloating, match, notify, notifyByPspec, ref, refSink, runDispose, stealData, stealQdata, thawNotify, toGvariant, unref, watchClosure.
Getters
getAttributes, getBuildableId, getData, getName, getProperty, getQdata, getStrictness.
Setters
addMimeType
fileFilterAddMimeType Source #
:: (HasCallStack, MonadIO m, IsFileFilter a) | |
=> a |
|
-> Text |
|
-> m () |
Adds a rule allowing a given mime type to filter
.
addPattern
:: (HasCallStack, MonadIO m, IsFileFilter a) | |
=> a |
|
-> Text |
|
-> m () |
Adds a rule allowing a shell style glob to a filter.
addPixbufFormats
fileFilterAddPixbufFormats Source #
:: (HasCallStack, MonadIO m, IsFileFilter a) | |
=> a |
|
-> m () |
Adds a rule allowing image files in the formats supported by GdkPixbuf.
This is equivalent to calling fileFilterAddMimeType
for all the supported mime types.
getAttributes
fileFilterGetAttributes Source #
:: (HasCallStack, MonadIO m, IsFileFilter a) | |
=> a |
|
-> m [Text] | Returns: the attributes |
Gets the attributes that need to be filled in for the FileInfo
passed to this filter.
This function will not typically be used by applications;
it is intended principally for use in the implementation
of FileChooser
.
getName
:: (HasCallStack, MonadIO m, IsFileFilter a) | |
=> a |
|
-> m (Maybe Text) | Returns: The human-readable name of the filter,
or |
Gets the human-readable name for the filter. See fileFilterSetName
.
new
:: (HasCallStack, MonadIO m) | |
=> m FileFilter | Returns: a new |
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 fileFilterAddPixbufFormats
.
To create a filter that accepts any file, use:
C code
GtkFileFilter *filter = gtk_file_filter_new (); gtk_file_filter_add_pattern (filter, "*");
newFromGvariant
fileFilterNewFromGvariant Source #
:: (HasCallStack, MonadIO m) | |
=> GVariant |
|
-> m FileFilter | Returns: a new |
Deserialize a file filter from an a{sv} variant in
the format produced by fileFilterToGvariant
.
setName
:: (HasCallStack, MonadIO m, IsFileFilter a) | |
=> a |
|
-> Maybe Text |
|
-> m () |
Sets a human-readable name of the filter; this is the string that will be displayed in the file chooser if there is a selectable list of filters.
toGvariant
:: (HasCallStack, MonadIO m, IsFileFilter a) | |
=> a |
|
-> m GVariant | Returns: a new, floating, |
Serialize a file filter to an a{sv} variant.
Properties
name
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.
clearFileFilterName :: (MonadIO m, IsFileFilter o) => o -> m () Source #
Set the value of the “name
” property to Nothing
.
When overloading is enabled, this is equivalent to
clear
#name
constructFileFilterName :: (IsFileFilter o, MonadIO m) => Text -> m (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “name
” property. This is rarely needed directly, but it is used by new
.
getFileFilterName :: (MonadIO m, IsFileFilter o) => o -> m (Maybe Text) Source #
Get the value of the “name
” property.
When overloading is enabled, this is equivalent to
get
fileFilter #name
setFileFilterName :: (MonadIO m, IsFileFilter o) => o -> Text -> m () Source #
Set the value of the “name
” property.
When overloading is enabled, this is equivalent to
set
fileFilter [ #name:=
value ]