~ubuntu-branches/ubuntu/intrepid/libgtkada2/intrepid

« back to all changes in this revision

Viewing changes to src/gtk-file_filter.ads

  • Committer: Bazaar Package Importer
  • Author(s): Luca Falavigna
  • Date: 2008-08-11 09:46:51 UTC
  • mfrom: (6.1.1 squeeze)
  • Revision ID: james.westby@ubuntu.com-20080811094651-9mjd6acwa98ffw5c
Tags: 2.12.0-2ubuntu1
Add lpia to supported architectures.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
-----------------------------------------------------------------------
 
2
--              GtkAda - Ada95 binding for Gtk+/Gnome                --
 
3
--                                                                   --
 
4
--                Copyright (C) 2006, AdaCore                        --
 
5
--                                                                   --
 
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.  --
 
10
--                                                                   --
 
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.                          --
 
15
--                                                                   --
 
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.                                       --
 
20
--                                                                   --
 
21
-----------------------------------------------------------------------
 
22
 
 
23
--  <description>
 
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).
 
28
--
 
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/*.
 
34
--
 
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
 
37
--  Filter.
 
38
--  </description>
 
39
--  <c_version>2.8.17</c_version>
 
40
--  <group>Selectors</group>
 
41
 
 
42
with Glib;
 
43
with Gtk.Object;
 
44
with System;
 
45
 
 
46
package Gtk.File_Filter is
 
47
 
 
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;
 
51
 
 
52
   type File_Filter_Info is new Glib.C_Proxy;
 
53
   --  An opaque structure that contains information about a file
 
54
 
 
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.
 
62
 
 
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.
 
70
 
 
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
 
75
 
 
76
   function Get_Type return GType;
 
77
   --  Return the internal value associated with a Gtk_File_Filter
 
78
 
 
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:
 
85
   --      Gtk_New (Filter);
 
86
   --      Add_Pattern (Filter, "*");
 
87
 
 
88
   procedure Set_Name
 
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.
 
94
 
 
95
   procedure Add_Mime_Type
 
96
     (Filter    : access Gtk_File_Filter_Record;
 
97
      Mime_Type : String);
 
98
   --  Adds a rule allowing a given mime type to Filter.
 
99
 
 
100
   procedure Add_Pattern
 
101
     (Filter  : access Gtk_File_Filter_Record;
 
102
      Pattern : String);
 
103
   --  Adds a rule allowing a shell style glob to a filter.
 
104
 
 
105
   procedure Add_Pixbuf_Formats
 
106
     (Filter : access Gtk_File_Filter_Record);
 
107
   --  Adds a rule allowing image files in the formats supported
 
108
   --  by Gdk_Pixbuf.
 
109
 
 
110
   procedure Add_Custom
 
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.
 
122
 
 
123
private
 
124
   type Gtk_File_Filter_Record is
 
125
     new Gtk.Object.Gtk_Object_Record with null record;
 
126
 
 
127
   pragma Import (C, Get_Type, "gtk_file_filter_get_type");
 
128
end Gtk.File_Filter;
 
129
 
 
130
--  No binding: gtk_file_filter_filter
 
131
--  No binding: gtk_file_filter_get_needed