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.RecentFilter

Contents

- Exported types
- Methods
  - addAge
  - addApplication
  - addCustom
  - addGroup
  - addMimeType
  - addPattern
  - addPixbufFormats
  - filter
  - getName
  - getNeeded
  - new
  - setName

Description

A `RecentFilter` can be used to restrict the files being shown in a `RecentChooser`. Files can be filtered based on their name (with `recentFilterAddPattern`), on their mime type (with `fileFilterAddMimeType`), on the application that has registered them (with `recentFilterAddApplication`), or by a custom filter function (with `recentFilterAddCustom`).

Filtering by mime type 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 `RecentFilter` 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 `RecentChooser`, see `recentChooserAddFilter`, but it is also possible to manually use a filter on a file with `recentFilterFilter`.

Recently used files are supported since GTK+ 2.10.

## GtkRecentFilter as GtkBuildable

The GtkRecentFilter 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>`, `<pattern>` or `<application>` has the same effect as calling `recentFilterAddMimeType`, `recentFilterAddPattern` or `recentFilterAddApplication`.

An example of a UI definition fragment specifying `GtkRecentFilter` rules:

### xml code

    <object class="GtkRecentFilter">
      <mime-types>
        <mime-type>text/plain</mime-type>
        <mime-type>image/png</mime-type>
      </mime-types>
      <patterns>
        <pattern>*.txt</pattern>
        <pattern>*.png</pattern>
      </patterns>
      <applications>
        <application>gimp</application>
        <application>gedit</application>
        <application>glade</application>
      </applications>
    </object>

Synopsis

- newtype RecentFilter = RecentFilter (ManagedPtr RecentFilter)
- class (GObject o, IsDescendantOf RecentFilter o) => IsRecentFilter o
- toRecentFilter :: (MonadIO m, IsRecentFilter o) => o -> m RecentFilter
- recentFilterAddAge :: (HasCallStack, MonadIO m, IsRecentFilter a) => a -> Int32 -> m ()
- recentFilterAddApplication :: (HasCallStack, MonadIO m, IsRecentFilter a) => a -> Text -> m ()
- recentFilterAddCustom :: (HasCallStack, MonadIO m, IsRecentFilter a) => a -> [RecentFilterFlags] -> RecentFilterFunc -> m ()
- recentFilterAddGroup :: (HasCallStack, MonadIO m, IsRecentFilter a) => a -> Text -> m ()
- recentFilterAddMimeType :: (HasCallStack, MonadIO m, IsRecentFilter a) => a -> Text -> m ()
- recentFilterAddPattern :: (HasCallStack, MonadIO m, IsRecentFilter a) => a -> Text -> m ()
- recentFilterAddPixbufFormats :: (HasCallStack, MonadIO m, IsRecentFilter a) => a -> m ()
- recentFilterFilter :: (HasCallStack, MonadIO m, IsRecentFilter a) => a -> RecentFilterInfo -> m Bool
- recentFilterGetName :: (HasCallStack, MonadIO m, IsRecentFilter a) => a -> m (Maybe Text)
- recentFilterGetNeeded :: (HasCallStack, MonadIO m, IsRecentFilter a) => a -> m [RecentFilterFlags]
- recentFilterNew :: (HasCallStack, MonadIO m) => m RecentFilter
- recentFilterSetName :: (HasCallStack, MonadIO m, IsRecentFilter a) => a -> Text -> m ()

# Exported types

newtype RecentFilter Source #

Memory-managed wrapper type.

Constructors

RecentFilter (ManagedPtr RecentFilter) |

#### Instances

Instances details

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

class (GObject o, IsDescendantOf RecentFilter o) => IsRecentFilter o Source #

Type class for types which can be safely cast to `RecentFilter`, for instance with `toRecentFilter`.

#### Instances

Instances details

(GObject o, IsDescendantOf RecentFilter o) => IsRecentFilter o Source # |
Instance details Defined in GI.Gtk.Objects.RecentFilter

toRecentFilter :: (MonadIO m, IsRecentFilter o) => o -> m RecentFilter Source #

Cast to `RecentFilter`, 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

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

#### Getters

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

#### Setters

setBuildableProperty, setData, setDataFull, setName, setProperty.

## addAge

recentFilterAddAge Source #

Arguments

:: (HasCallStack, MonadIO m, IsRecentFilter a) |
=> a | `filter`: a `RecentFilter`
-> Int32 | `days`: number of days
-> m () |

Adds a rule that allows resources based on their age - that is, the number of days elapsed since they were last modified.

Since: 2.10

## addApplication

recentFilterAddApplication Source #

Arguments

:: (HasCallStack, MonadIO m, IsRecentFilter a) |
=> a | `filter`: a `RecentFilter`
-> Text | `application`: an application name
-> m () |

Adds a rule that allows resources based on the name of the application that has registered them.

Since: 2.10

## addCustom

recentFilterAddCustom Source #

Arguments

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

Adds a rule to a filter that allows resources 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.10

## addGroup

recentFilterAddGroup Source #

Arguments

:: (HasCallStack, MonadIO m, IsRecentFilter a) |
=> a | `filter`: a `RecentFilter`
-> Text | `group`: a group name
-> m () |

Adds a rule that allows resources based on the name of the group to which they belong

Since: 2.10

## addMimeType

recentFilterAddMimeType Source #

Arguments

:: (HasCallStack, MonadIO m, IsRecentFilter a) |
=> a | `filter`: a `RecentFilter`
-> Text | `mimeType`: a MIME type
-> m () |

Adds a rule that allows resources based on their registered MIME type.

Since: 2.10

## addPattern

recentFilterAddPattern Source #

Arguments

:: (HasCallStack, MonadIO m, IsRecentFilter a) |
=> a | `filter`: a `RecentFilter`
-> Text | `pattern`: a file pattern
-> m () |

Adds a rule that allows resources based on a pattern matching their display name.

Since: 2.10

## addPixbufFormats

recentFilterAddPixbufFormats Source #

Arguments

:: (HasCallStack, MonadIO m, IsRecentFilter a) |
=> a | `filter`: a `RecentFilter`
-> m () |

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

Since: 2.10

## filter

recentFilterFilter Source #

Arguments

:: (HasCallStack, MonadIO m, IsRecentFilter a) |
=> a | `filter`: a `RecentFilter`
-> RecentFilterInfo | `filterInfo`: a `RecentFilterInfo` containing information about a recently used resource
-> m Bool | Returns: `True` if the file should be displayed

Tests whether a file should be displayed according to `filter`. The `RecentFilterInfo` `filterInfo` should include the fields returned from `recentFilterGetNeeded`, and must set the `RecentFilterInfo`.`contains` field of `filterInfo` to indicate which fields have been set.

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

Since: 2.10

## getName

recentFilterGetName Source #

Arguments

:: (HasCallStack, MonadIO m, IsRecentFilter a) |
=> a | `filter`: a `RecentFilter`
-> m (Maybe Text) | Returns: the name of the filter, or `Nothing`. The returned string is owned by the filter object and should not be freed.

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

Since: 2.10

## getNeeded

recentFilterGetNeeded Source #

Arguments

:: (HasCallStack, MonadIO m, IsRecentFilter a) |
=> a | `filter`: a `RecentFilter`
-> m [RecentFilterFlags] | Returns: bitfield of flags indicating needed fields when calling `recentFilterFilter`

Gets the fields that need to be filled in for the `RecentFilterInfo` passed to `recentFilterFilter`

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

Since: 2.10

## new

recentFilterNew Source #

Arguments

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

Creates a new `RecentFilter` with no rules added to it. Such filter does not accept any recently used resources, so is not particularly useful until you add rules with `recentFilterAddPattern`, `recentFilterAddMimeType`, `recentFilterAddApplication`, `recentFilterAddAge`. To create a filter that accepts any recently used resource, use:

### C code

    GtkRecentFilter *filter = gtk_recent_filter_new ();
    gtk_recent_filter_add_pattern (filter, "*");

Since: 2.10

## setName

recentFilterSetName Source #

Arguments

:: (HasCallStack, MonadIO m, IsRecentFilter a) |
=> a | `filter`: a `RecentFilter`
-> Text | `name`: then human readable name of `filter`
-> m () |

Sets the human-readable name of the filter; this is the string that will be displayed in the recently used resources selector user interface if there is a selectable list of filters.

Since: 2.10