1
-----------------------------------------------------------------------
2
-- GtkAda - Ada95 binding for Gtk+/Gnome --
4
-- Copyright (C) 2006, AdaCore --
6
-- This library is free software; you can redistribute it and/or --
7
-- modify it under the terms of the GNU General Public --
8
-- License as published by the Free Software Foundation; either --
9
-- version 2 of the License, or (at your option) any later version. --
11
-- This library is distributed in the hope that it will be useful, --
12
-- but WITHOUT ANY WARRANTY; without even the implied warranty of --
13
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU --
14
-- General Public License for more details. --
16
-- You should have received a copy of the GNU General Public --
17
-- License along with this library; if not, write to the --
18
-- Free Software Foundation, Inc., 59 Temple Place - Suite 330, --
19
-- Boston, MA 02111-1307, USA. --
21
-----------------------------------------------------------------------
24
-- A Gtk_File_Filter can be used to restrict the files being shown in a
25
-- Gtk_File_Chooser. Files can be filtered based on their name (with
26
-- Add_Pattern), on their mime type (with Add_Mime_Type), or by a custom
27
-- filter function (with Add_Custom).
29
-- Filtering by mime types handles aliasing and subclassing of mime types;
30
-- e.g. a filter for text/plain also matches a file with mime type
31
-- application/rtf, since application/rtf is a subclass of text/plain. Note
32
-- that Gtk_File_Filter allows wildcards for the subtype of a mime type, so
33
-- you can e.g. filter for image/*.
35
-- Normally, filters are used by adding them to a Gtk_File_Chooser, see
36
-- Add_Filter, but it is also possible to manually use a filter on a file with
39
-- <c_version>2.8.17</c_version>
40
-- <group>Selectors</group>
46
package Gtk.File_Filter is
48
type Gtk_File_Filter_Record is
49
new Gtk.Object.Gtk_Object_Record with private;
50
type Gtk_File_Filter is access all Gtk_File_Filter_Record'Class;
52
type File_Filter_Info is new Glib.C_Proxy;
53
-- An opaque structure that contains information about a file
55
function Get_Filename (Info : File_Filter_Info) return String;
56
function Get_Uri (Info : File_Filter_Info) return String;
57
function Get_Display_Name (Info : File_Filter_Info) return String;
58
function Get_Mime_Type (Info : File_Filter_Info) return String;
59
-- Return the various information known about the file. The empty string is
60
-- returned when the associated information is unknown. Display_Name is the
61
-- string used to display the file in a file_chooser.
63
type File_Filter_Flags is mod 2 ** 8;
64
Filter_Filename : constant File_Filter_Flags := 2 ** 0;
65
Filter_Uri : constant File_Filter_Flags := 2 ** 1;
66
Filter_Display_Name : constant File_Filter_Flags := 2 ** 2;
67
Filter_Mime_Type : constant File_Filter_Flags := 2 ** 3;
68
-- These flags indicate what parts of a Gtk_File_Filter_Info struct are
69
-- filled or need to be filled.
71
type File_Filter_Func is access function
72
(Info : File_Filter_Info) return Gboolean;
73
pragma Convention (C, File_Filter_Func);
74
-- Function used by custom filters
76
function Get_Type return GType;
77
-- Return the internal value associated with a Gtk_File_Filter
79
procedure Gtk_New (Filter : out Gtk_File_Filter);
80
procedure Initialize (Filter : access Gtk_File_Filter_Record'Class);
81
-- Creates a new Gtk_File_Filter with no rules added to it. Such a filter
82
-- doesn't accept any files, so is not particularly useful until you add
83
-- rules with Add_Mime_Type, Add_Pattern, or Add_Custom. To create a filter
84
-- that accepts any file, use:
86
-- Add_Pattern (Filter, "*");
89
(Filter : access Gtk_File_Filter_Record; Name : String);
90
function Get_Name (Filter : access Gtk_File_Filter_Record) return String;
91
-- Sets the human-readable name of the filter; this is the string
92
-- that will be displayed in the file selector user interface if
93
-- there is a selectable list of filters.
95
procedure Add_Mime_Type
96
(Filter : access Gtk_File_Filter_Record;
98
-- Adds a rule allowing a given mime type to Filter.
100
procedure Add_Pattern
101
(Filter : access Gtk_File_Filter_Record;
103
-- Adds a rule allowing a shell style glob to a filter.
105
procedure Add_Pixbuf_Formats
106
(Filter : access Gtk_File_Filter_Record);
107
-- Adds a rule allowing image files in the formats supported
111
(Filter : access Gtk_File_Filter_Record;
112
Needed : File_Filter_Flags;
113
Func : File_Filter_Func;
114
Data : System.Address := System.Null_Address;
115
Notify : G_Destroy_Notify_Address := null);
116
-- Adds rule to a filter that allows files based on a custom callback
117
-- function. The bitfield Needed which is passed in provides information
118
-- about what sorts of information that the filter function needs;
119
-- this allows GTK+ to avoid retrieving expensive information when
120
-- it isn't needed by the filter.
121
-- Notify is called when Data is no longer needed and should be freed.
124
type Gtk_File_Filter_Record is
125
new Gtk.Object.Gtk_Object_Record with null record;
127
pragma Import (C, Get_Type, "gtk_file_filter_get_type");
130
-- No binding: gtk_file_filter_filter
131
-- No binding: gtk_file_filter_get_needed