[]Struct gtk::FileFilter

pub struct FileFilter(_, _);

A FileFilter can be used to restrict the files being shown in a FileChooser. Files can be filtered based on their name (with FileFilter::add_pattern), on their mime type (with FileFilter::add_mime_type), or by a custom filter function (with FileFilter::add_custom).

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 FileChooser::add_filter, but it is also possible to manually use a filter on a file with FileFilter::filter.

FileFilter as Buildable

The FileFilter implementation of the Buildable 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 FileFilter::add_mime_type or FileFilter::add_pattern.

An example of a UI definition fragment specifying FileFilter rules:

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

Implements

glib::object::ObjectExt, BuildableExt, BuildableExtManual

Implementations

impl FileFilter[src]

pub fn new() -> FileFilter[src]

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 FileFilter::add_mime_type, FileFilter::add_pattern, or FileFilter::add_custom. To create a filter that accepts any file, use:

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

Returns

a new FileFilter

pub fn from_gvariant(variant: &Variant) -> FileFilter[src]

pub fn add_mime_type(&self, mime_type: &str)[src]

Adds a rule allowing a given mime type to self.

mime_type

name of a MIME type

pub fn add_pattern(&self, pattern: &str)[src]

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

pattern

a shell style glob

pub fn add_pixbuf_formats(&self)[src]

Adds a rule allowing image files in the formats supported by gdk_pixbuf::Pixbuf.

pub fn get_name(&self) -> Option<GString>[src]

Gets the human-readable name for the filter. See FileFilter::set_name.

Returns

The human-readable name of the filter, or None. This value is owned by GTK+ and must not be modified or freed.

pub fn get_needed(&self) -> FileFilterFlags[src]

Gets the fields that need to be filled in for the FileFilterInfo passed to FileFilter::filter

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

Returns

bitfield of flags indicating needed fields when calling FileFilter::filter

pub fn set_name(&self, name: Option<&str>)[src]

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.

name

the human-readable-name for the filter, or None to remove any existing name.

pub fn to_gvariant(&self) -> Option<Variant>[src]

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

Feature: v3_22

Returns

a new, floating, glib::Variant

Trait Implementations

impl Clone for FileFilter

impl Debug for FileFilter

impl Default for FileFilter[src]

impl Display for FileFilter[src]

impl Eq for FileFilter

impl Hash for FileFilter

impl IsA<Buildable> for FileFilter

impl Ord for FileFilter

impl<T: ObjectType> PartialEq<T> for FileFilter

impl<T: ObjectType> PartialOrd<T> for FileFilter

impl StaticType for FileFilter

Auto Trait Implementations

impl RefUnwindSafe for FileFilter

impl !Send for FileFilter

impl !Sync for FileFilter

impl Unpin for FileFilter

impl UnwindSafe for FileFilter

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<Super, Sub> CanDowncast<Sub> for Super where
    Sub: IsA<Super>,
    Super: IsA<Super>, 

impl<T> Cast for T where
    T: ObjectType, 

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ObjectExt for T where
    T: ObjectType, 

impl<'a, T> ToGlibContainerFromSlice<'a, *const GList> for T where
    T: GlibPtrDefault + ToGlibPtr<'a, <T as GlibPtrDefault>::GlibType>, 

type Storage = (Option<List>, Vec<Stash<'a, <T as GlibPtrDefault>::GlibType, T>>)

impl<'a, T> ToGlibContainerFromSlice<'a, *const GPtrArray> for T where
    T: GlibPtrDefault + ToGlibPtr<'a, <T as GlibPtrDefault>::GlibType>, 

type Storage = (Option<PtrArray>, Vec<Stash<'a, <T as GlibPtrDefault>::GlibType, T>>)

impl<'a, T> ToGlibContainerFromSlice<'a, *mut GArray> for T where
    T: GlibPtrDefault + ToGlibPtr<'a, <T as GlibPtrDefault>::GlibType>, 

type Storage = (Option<Array>, Vec<Stash<'a, <T as GlibPtrDefault>::GlibType, T>>)

impl<'a, T> ToGlibContainerFromSlice<'a, *mut GList> for T where
    T: GlibPtrDefault + ToGlibPtr<'a, <T as GlibPtrDefault>::GlibType>, 

type Storage = (Option<List>, Vec<Stash<'a, <T as GlibPtrDefault>::GlibType, T>>)

impl<'a, T> ToGlibContainerFromSlice<'a, *mut GPtrArray> for T where
    T: GlibPtrDefault + ToGlibPtr<'a, <T as GlibPtrDefault>::GlibType>, 

type Storage = (Option<PtrArray>, Vec<Stash<'a, <T as GlibPtrDefault>::GlibType, T>>)

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToSendValue for T where
    T: ToValue + SetValue + Send + ?Sized

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T> ToValue for T where
    T: SetValue + ?Sized

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.