gi-gtk-3.0.43: Gtk bindings

Copyright | Will Thompson and Iñaki García Etxebarria
License | LGPL-2.1
Maintainer | Iñaki García Etxebarria
Safe Haskell | None
Language | Haskell2010

GI.Gtk.Objects.FileFilter

Contents

- Exported types
- Methods
  - addCustom
  - addMimeType
  - addPattern
  - addPixbufFormats
  - filter
  - getName
  - getNeeded
  - new
  - newFromGvariant
  - setName
  - toGvariant

Description

A GtkFileFilter 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 `fileChooserAddFilter`, but it is also possible to manually use a filter on a file with `fileFilterFilter`.

# GtkFileFilter as GtkBuildable

The GtkFileFilter implementation of the GtkBuildable interface supports adding rules using the `<mime-types>`, `<patterns>` and `<applications>` 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:

### xml code

    <object class="GtkFileFilter">
      <mime-types>
        <mime-type>text/plain</mime-type>
        <mime-type>image/ *</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
- fileFilterAddCustom :: (HasCallStack, MonadIO m, IsFileFilter a) => a -> [FileFilterFlags] -> FileFilterFunc -> m ()
- 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 ()
- fileFilterFilter :: (HasCallStack, MonadIO m, IsFileFilter a) => a -> FileFilterInfo -> m Bool
- fileFilterGetName :: (HasCallStack, MonadIO m, IsFileFilter a) => a -> m (Maybe Text)
- fileFilterGetNeeded :: (HasCallStack, MonadIO m, IsFileFilter a) => a -> m [FileFilterFlags]
- 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

# Exported types

newtype FileFilter Source #

Memory-managed wrapper type.

Constructors

FileFilter (ManagedPtr FileFilter) |

#### Instances

Instances details

Eq FileFilter Source # |
Instance details Defined in GI.Gtk.Objects.FileFilter Methods (==) :: FileFilter -> FileFilter -> Bool Source # (/=) :: FileFilter -> FileFilter -> Bool Source #
GObject FileFilter Source # |
Instance details Defined in GI.Gtk.Objects.FileFilter
ManagedPtrNewtype FileFilter Source # |
Instance details Defined in GI.Gtk.Objects.FileFilter Methods toManagedPtr :: FileFilter -> ManagedPtr FileFilter Source #
TypedObject FileFilter Source # |
Instance details Defined in GI.Gtk.Objects.FileFilter Methods glibType :: IO GType Source #
HasParentTypes FileFilter Source # |
Instance details Defined in GI.Gtk.Objects.FileFilter
IsGValue (Maybe FileFilter) Source # | Convert `FileFilter` to and from `GValue`. See `toGValue` and `fromGValue`.
Instance details Defined in GI.Gtk.Objects.FileFilter Methods gvalueGType_ :: IO GType Source # gvalueSet_ :: Ptr GValue -> Maybe FileFilter -> IO () Source # gvalueGet_ :: Ptr GValue -> IO (Maybe FileFilter) Source #
type ParentTypes FileFilter Source # |
Instance details Defined in GI.Gtk.Objects.FileFilter type ParentTypes FileFilter = '[Object, Buildable]

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

Instances details

(GObject o, IsDescendantOf FileFilter o) => IsFileFilter o Source # |
Instance details 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

Expand

#### Methods

addChild, addCustom, addMimeType, addPattern, addPixbufFormats, bindProperty, bindPropertyFull, constructChild, customFinished, customTagEnd, customTagStart, filter, forceFloating, freezeNotify, getv, isFloating, notify, notifyByPspec, parserFinished, ref, refSink, runDispose, stealData, stealQdata, thawNotify, toGvariant, unref, watchClosure.

#### Getters

getData, getInternalChild, getName, getNeeded, getProperty, getQdata.

#### Setters

setBuildableProperty, setData, setDataFull, setName, setProperty.

## addCustom

fileFilterAddCustom Source #

Arguments

:: (HasCallStack, MonadIO m, IsFileFilter a) |
=> a | `filter`: a `FileFilter`
-> [FileFilterFlags] | `needed`: bitfield of flags indicating the information that the custom filter function needs.
-> FileFilterFunc | `func`: callback function; if the function returns `True`, then the file will be displayed.
-> m () |

Adds rule to a filter that allows files based on a custom callback function. The bitfield `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.

Since: 2.4

## addMimeType

fileFilterAddMimeType Source #

Arguments

:: (HasCallStack, MonadIO m, IsFileFilter a) |
=> a | `filter`: A `FileFilter`
-> Text | `mimeType`: name of a MIME type
-> m () |

Adds a rule allowing a given mime type to `filter`.

Since: 2.4

## addPattern

fileFilterAddPattern Source #

Arguments

:: (HasCallStack, MonadIO m, IsFileFilter a) |
=> a | `filter`: a `FileFilter`
-> Text | `pattern`: a shell style glob
-> m () |

Adds a rule allowing a shell style glob to a filter.

Since: 2.4

## addPixbufFormats

fileFilterAddPixbufFormats Source #

Arguments

:: (HasCallStack, MonadIO m, IsFileFilter a) |
=> a | `filter`: a `FileFilter`
-> m () |

Adds a rule allowing image files in the formats supported by GdkPixbuf.

Since: 2.6

## filter

fileFilterFilter Source #

Arguments

:: (HasCallStack, MonadIO m, IsFileFilter a) |
=> a | `filter`: a `FileFilter`
-> FileFilterInfo | `filterInfo`: a `FileFilterInfo` containing information about a file.
-> m Bool | Returns: `True` if the file should be displayed

Tests whether a file should be displayed according to `filter`. The `FileFilterInfo` `filterInfo` should include the fields returned from `fileFilterGetNeeded`.

This function will not typically be used by applications; it is intended principally for use in the implementation of `FileChooser`.

Since: 2.4

## getName

fileFilterGetName Source #

Arguments

:: (HasCallStack, MonadIO m, IsFileFilter a) |
=> a | `filter`: a `FileFilter`
-> m (Maybe Text) | Returns: The human-readable name of the filter, or `Nothing`. This value is owned by GTK+ and must not be modified or freed.

Gets the human-readable name for the filter. See `fileFilterSetName`.

Since: 2.4

## getNeeded

fileFilterGetNeeded Source #

Arguments

:: (HasCallStack, MonadIO m, IsFileFilter a) |
=> a | `filter`: a `FileFilter`
-> m [FileFilterFlags] | Returns: bitfield of flags indicating needed fields when calling `fileFilterFilter`

Gets the fields that need to be filled in for the `FileFilterInfo` passed to `fileFilterFilter`

This function will not typically be used by applications; it is intended principally for use in the implementation of `FileChooser`.

Since: 2.4

## new

fileFilterNew Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> m FileFilter | Returns: a new `FileFilter`

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`. To create a filter that accepts any file, use:

### C code

    GtkFileFilter *filter = gtk_file_filter_new ();
    gtk_file_filter_add_pattern (filter, "*");

Since: 2.4

## newFromGvariant

fileFilterNewFromGvariant Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> GVariant | `variant`: an a{sv} `GVariant`
-> m FileFilter | Returns: a new `FileFilter` object

Deserialize a file filter from an a{sv} variant in the format produced by `fileFilterToGvariant`.

Since: 3.22

## setName

fileFilterSetName Source #

Arguments

:: (HasCallStack, MonadIO m, IsFileFilter a) |
=> a | `filter`: a `FileFilter`
-> Maybe Text | `name`: the human-readable-name for the filter, or `Nothing` to remove any existing name.
-> m () |

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.

Since: 2.4

## toGvariant

fileFilterToGvariant Source #

Arguments

:: (HasCallStack, MonadIO m, IsFileFilter a) |
=> a | `filter`: a `FileFilter`
-> m GVariant | Returns: a new, floating, `GVariant`

Serialize a file filter to an a{sv} variant.

Since: 3.22