package Gtk_File_Filter_Flags_Properties is new Generic_Internal_Discrete_Property (Gtk_File_Filter_Flags);
package Implements_Gtk_Buildable is new Glib.Types.Implements (Gtk.Buildable.Gtk_Buildable, Gtk_File_Filter_Record, Gtk_File_Filter);
type Gtk_File_Filter_Record is new GObject_Record with null record;
type Gtk_File_Filter is access all Gtk_File_Filter_Record'Class;
type Gtk_File_Filter_Info is record Contains : Gtk_File_Filter_Flags; Filename : Interfaces.C.Strings.chars_ptr; URI : Interfaces.C.Strings.chars_ptr; Display_Name : Interfaces.C.Strings.chars_ptr; Mime_Type : Interfaces.C.Strings.chars_ptr; end record;
type Gtk_File_Filter_Func is access function (Filter_Info : Gtk_File_Filter_Info) return Boolean;
type Property_Gtk_File_Filter_Flags is new Gtk_File_Filter_Flags_Properties.Property;
File_Filter_Filename : constant Gtk_File_Filter_Flags := 1;
File_Filter_Uri : constant Gtk_File_Filter_Flags := 2;
File_Filter_Display_Name : constant Gtk_File_Filter_Flags := 4;
File_Filter_Mime_Type : constant Gtk_File_Filter_Flags := 8;
function From_Object_Free
( | B | : access Gtk_File_Filter_Info) return Gtk_File_Filter_Info; |
procedure Gtk_New
( | Self | : out Gtk_File_Filter); |
procedure Initialize
( | Self | : not null access Gtk_File_Filter_Record'Class); |
function Gtk_File_Filter_New return Gtk_File_Filter;
function Get_Type return Glib.GType;
procedure Add_Custom
( | Self | : not null access Gtk_File_Filter_Record; |
Needed | : Gtk_File_Filter_Flags; | |
Func | : Gtk_File_Filter_Func; | |
Notify | : Glib.G_Destroy_Notify_Address); |
procedure Add_Mime_Type
( | Self | : not null access Gtk_File_Filter_Record; |
Mime_Type | : UTF8_String); |
procedure Add_Pattern
( | Self | : not null access Gtk_File_Filter_Record; |
Pattern | : UTF8_String); |
procedure Add_Pixbuf_Formats
( | Self | : not null access Gtk_File_Filter_Record); |
function Filter
( | Self | : not null access Gtk_File_Filter_Record; |
Filter_Info | : Gtk_File_Filter_Info) return Boolean; |
function Get_Name
( | Self | : not null access Gtk_File_Filter_Record) return UTF8_String; |
procedure Set_Name
( | Self | : not null access Gtk_File_Filter_Record; |
Name | : UTF8_String := ""); |
function Get_Needed
( | Self | : not null access Gtk_File_Filter_Record) return Gtk_File_Filter_Flags; |
function "+"
( | Widget | : access Gtk_File_Filter_Record'Class) return Gtk.Buildable.Gtk_Buildable renames Implements_Gtk_Buildable.To_Interface; |
function "-"
( | Interf | : Gtk.Buildable.Gtk_Buildable) return Gtk_File_Filter renames Implements_Gtk_Buildable.To_Object; |
A GtkFileFilter can be used to restrict the files being shown in a Gtk.File_Chooser.Gtk_File_Chooser. Files can be filtered based on their name (with Gtk.File_Filter.Add_Pattern), on their mime type (with Gtk.File_Filter.Add_Mime_Type), or by a custom filter function (with Gtk.File_Filter.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.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.Gtk_File_Chooser, see Gtk.File_Chooser.Add_Filter, but it is also possible to manually use a filter on a file with Gtk.File_Filter.Filter. == GtkFileFilter as GtkBuildable == The GtkFileFilter 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> or <pattern> is the same as calling Gtk.Recent_Filter.Add_Mime_Type or Gtk.Recent_Filter.Add_Pattern == A UI definition fragment specifying GtkFileFilter 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>