Index

Package: File_Filter

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

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

Ancestors:

Primitive operations:

Add_Mime_Type
Add_Pixbuf_Formats
Glib.Object.Deallocate (Inherited)
Glib.Object.Get_Type (Inherited)
Glib.Object.Notify (Inherited)
Glib.Object.Ref (Inherited)
Glib.Object.Ref_Sink (Inherited)
Glib.Object.Unref (Inherited)

Types

Gtk_File_Filter

type Gtk_File_Filter is access all Gtk_File_Filter_Record'Class;

File_Filter_Info

type File_Filter_Info is new Glib.C_Proxy;
An opaque structure that contains information about a file

File_Filter_Flags

type File_Filter_Flags is mod 2 ** 8;

File_Filter_Func

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

Constants & Global variables

Filter_Filename (File_Filter_Flags)

Filter_Filename     : constant File_Filter_Flags := 2 ** 0;

Filter_Uri (File_Filter_Flags)

Filter_Uri          : constant File_Filter_Flags := 2 ** 1;

Filter_Display_Name (File_Filter_Flags)

Filter_Display_Name : constant File_Filter_Flags := 2 ** 2;

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

function Get_Filename     
(Info: File_Filter_Info) return String;

Get_Uri

function Get_Uri          
(Info: File_Filter_Info) return String;

Get_Display_Name

function Get_Display_Name 
(Info: File_Filter_Info) return String;

Get_Mime_Type

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

function Get_Type return GType;
Return the internal value associated with a Gtk_File_Filter

Gtk_New

procedure Gtk_New    
(Filter: out Gtk_File_Filter);

Initialize

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

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

Get_Name

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

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

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

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

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.