Copyright | Will Thompson Iñaki García Etxebarria and Jonas Platte |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria |
Safe Haskell | None |
Language | Haskell2010 |
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: > >class="GtkRecentFilter" > mime-types > mime-typetextplain<mime-type> > mime-typeimagepng<mime-type> > /mime-types > patterns > pattern*.txt/pattern > pattern*.png/pattern > /patterns > applications > applicationgimp/application > applicationgedit/application > applicationglade/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.
Instances
Eq RecentFilter Source # | |
Defined in GI.Gtk.Objects.RecentFilter (==) :: RecentFilter -> RecentFilter -> Bool # (/=) :: RecentFilter -> RecentFilter -> Bool # | |
IsGValue RecentFilter Source # | Convert |
Defined in GI.Gtk.Objects.RecentFilter toGValue :: RecentFilter -> IO GValue # fromGValue :: GValue -> IO RecentFilter # | |
ManagedPtrNewtype RecentFilter Source # | |
Defined in GI.Gtk.Objects.RecentFilter | |
TypedObject RecentFilter Source # | |
Defined in GI.Gtk.Objects.RecentFilter | |
GObject RecentFilter Source # | |
Defined in GI.Gtk.Objects.RecentFilter | |
HasParentTypes RecentFilter Source # | |
Defined in GI.Gtk.Objects.RecentFilter | |
type ParentTypes RecentFilter Source # | |
Defined in GI.Gtk.Objects.RecentFilter |
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
(GObject o, IsDescendantOf RecentFilter o) => IsRecentFilter o Source # | |
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
Overloaded methods
addAge
:: (HasCallStack, MonadIO m, IsRecentFilter a) | |
=> a |
|
-> Int32 |
|
-> 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 #
:: (HasCallStack, MonadIO m, IsRecentFilter a) | |
=> a |
|
-> Text |
|
-> m () |
Adds a rule that allows resources based on the name of the application that has registered them.
Since: 2.10
addCustom
recentFilterAddCustom Source #
:: (HasCallStack, MonadIO m, IsRecentFilter a) | |
=> a |
|
-> [RecentFilterFlags] |
|
-> RecentFilterFunc |
|
-> 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
:: (HasCallStack, MonadIO m, IsRecentFilter a) | |
=> a |
|
-> Text |
|
-> m () |
Adds a rule that allows resources based on the name of the group to which they belong
Since: 2.10
addMimeType
recentFilterAddMimeType Source #
:: (HasCallStack, MonadIO m, IsRecentFilter a) | |
=> a |
|
-> Text |
|
-> m () |
Adds a rule that allows resources based on their registered MIME type.
Since: 2.10
addPattern
recentFilterAddPattern Source #
:: (HasCallStack, MonadIO m, IsRecentFilter a) | |
=> a |
|
-> Text |
|
-> m () |
Adds a rule that allows resources based on a pattern matching their display name.
Since: 2.10
addPixbufFormats
recentFilterAddPixbufFormats Source #
:: (HasCallStack, MonadIO m, IsRecentFilter a) | |
=> a |
|
-> m () |
Adds a rule allowing image files in the formats supported by GdkPixbuf.
Since: 2.10
filter
:: (HasCallStack, MonadIO m, IsRecentFilter a) | |
=> a |
|
-> RecentFilterInfo |
|
-> m Bool | Returns: |
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
:: (HasCallStack, MonadIO m, IsRecentFilter a) | |
=> a |
|
-> m (Maybe Text) | Returns: the name of the filter, or |
Gets the human-readable name for the filter.
See recentFilterSetName
.
Since: 2.10
getNeeded
recentFilterGetNeeded Source #
:: (HasCallStack, MonadIO m, IsRecentFilter a) | |
=> a |
|
-> m [RecentFilterFlags] | Returns: bitfield of flags indicating needed fields when
calling |
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
:: (HasCallStack, MonadIO m) | |
=> m RecentFilter | Returns: a new |
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
:: (HasCallStack, MonadIO m, IsRecentFilter a) | |
=> a |
|
-> Text |
|
-> 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