## Documentation

Table of Contents
Class Inheritance Tree
Widget Screenshots
Package groups

## Index

Package: File_Filter

- Goto spec source

# Description

    package Gtk.File_Filter is

A Gtk_File_Filter can be used to restrict the files being shown in a Gtk_File_Chooser. Files can be filtered based on their name (with Add_Pattern), on their mime type (with Add_Mime_Type), or by a custom filter function (with 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 Gtk_File_Filter 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 Gtk_File_Chooser, see Add_Filter, but it is also possible to manually use a filter on a file with Filter.

Binding from C File version 2.8.17

# Classes

### Gtk_File_Filter_Record

- Goto declaration in source
- Goto full declaration in source

    type Gtk_File_Filter_Record is
         new Glib.Object.GObject_Record with private;

#### Ancestors:

Glib.Object.GObject_Record

#### Primitive operations:

Add_Custom

- To API doc
- To spec

Add_Mime_Type

- To API doc
- To spec

Add_Pattern

- To API doc
- To spec

Add_Pixbuf_Formats

- To API doc
- To spec

Get_Name

- To API doc
- To spec

Glib.Object.Deallocate

- To API doc
- To spec

(Inherited)
Glib.Object.Get_Type

- To API doc
- To spec

(Inherited)
Glib.Object.Notify

- To API doc
- To spec

(Inherited)
Glib.Object.Ref

- To API doc
- To spec

(Inherited)
Glib.Object.Ref_Sink

- To API doc
- To spec

(Inherited)
Glib.Object.Unref

- To API doc
- To spec

(Inherited)
Set_Name

- To API doc
- To spec

# Types

### Gtk_File_Filter

- Goto declaration in source

    type Gtk_File_Filter is access all Gtk_File_Filter_Record'Class;

### File_Filter_Info

- Goto declaration in source

    type File_Filter_Info is new Glib.C_Proxy;

An opaque structure that contains information about a file

### File_Filter_Flags

- Goto declaration in source

    type File_Filter_Flags is mod 2 ** 8;

### File_Filter_Func

- Goto declaration in source

    type File_Filter_Func is access function
         (Info : File_Filter_Info) return Gboolean;

# Constants & Global variables

### Filter_Filename

- Goto declaration in source

(File_Filter_Flags)

    Filter_Filename     : constant File_Filter_Flags := 2 ** 0;

### Filter_Uri

- Goto declaration in source

(File_Filter_Flags)

    Filter_Uri          : constant File_Filter_Flags := 2 ** 1;

### Filter_Display_Name

- Goto declaration in source

(File_Filter_Flags)

    Filter_Display_Name : constant File_Filter_Flags := 2 ** 2;

### Filter_Mime_Type

- Goto declaration in source

(File_Filter_Flags)

    Filter_Mime_Type    : constant File_Filter_Flags := 2 ** 3;

These flags indicate what parts of a Gtk_File_Filter_Info struct are filled or need to be filled.

# Subprograms & Entries

### Get_Filename

- Goto spec in source

    function Get_Filename     (Info: File_Filter_Info) return String;

### Get_Uri

- Goto spec in source

    function Get_Uri          (Info: File_Filter_Info) return String;

### Get_Display_Name

- Goto spec in source

    function Get_Display_Name (Info: File_Filter_Info) return String;

### Get_Mime_Type

- Goto spec in source

    function Get_Mime_Type    (Info: File_Filter_Info) return String;

Return the various information known about the file. The empty string is returned when the associated information is unknown. Display_Name is the string used to display the file in a file_chooser.

### Get_Type

- Goto spec in source
- Goto body in source

    function Get_Type return GType;

Return the internal value associated with a Gtk_File_Filter

### Gtk_New

- Goto spec in source

    procedure Gtk_New    (Filter: out Gtk_File_Filter);

### Initialize

- Goto spec in source

    procedure Initialize (Filter: access Gtk_File_Filter_Record'Class);

Creates a new Gtk_File_Filter with no rules added to it. Such a filter doesn't accept any files, so is not particularly useful until you add rules with Add_Mime_Type, Add_Pattern, or Add_Custom. To create a filter that accepts any file, use: Gtk_New (Filter); Add_Pattern (Filter, "*");

### Set_Name

- Goto spec in source

    procedure Set_Name (Filter: access Gtk_File_Filter_Record;Name: String);

### Get_Name

- Goto spec in source

    function Get_Name (Filter: access Gtk_File_Filter_Record) return String;

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.

### Add_Mime_Type

- Goto spec in source

    procedure Add_Mime_Type (Filter: access Gtk_File_Filter_Record;Mime_Type: String);

Adds a rule allowing a given mime type to Filter. In particular, if you want to show directories only and not files, you could use "x-directory/normal" as the Mime type

### Add_Pattern

- Goto spec in source

    procedure Add_Pattern (Filter: access Gtk_File_Filter_Record;Pattern: String);

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

### Add_Pixbuf_Formats

- Goto spec in source

    procedure Add_Pixbuf_Formats (Filter: access Gtk_File_Filter_Record);

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

### Add_Custom

- Goto spec in source

    procedure Add_Custom (Filter: access Gtk_File_Filter_Record;Needed: File_Filter_Flags;Func: File_Filter_Func;Data: System.Address := System.Null_Address;Notify: G_Destroy_Notify_Address := null);

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. Notify is called when Data is no longer needed and should be freed.