~ubuntu-branches/ubuntu/maverick/gimp/maverick-updates

« back to all changes in this revision

Viewing changes to tools/pdbgen/pdb/unit.pdb

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Holbach
  • Date: 2005-12-09 19:44:52 UTC
  • Revision ID: james.westby@ubuntu.com-20051209194452-yggpemjlofpjqyf4
Tags: upstream-2.2.9
ImportĀ upstreamĀ versionĀ 2.2.9

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# The GIMP -- an image manipulation program
 
2
# Copyright (C) 1995 Spencer Kimball and Peter Mattis
 
3
 
 
4
# This program is free software; you can redistribute it and/or modify
 
5
# it under the terms of the GNU General Public License as published by
 
6
# the Free Software Foundation; either version 2 of the License, or
 
7
# (at your option) any later version.
 
8
 
 
9
# This program is distributed in the hope that it will be useful,
 
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
# GNU General Public License for more details.
 
13
 
 
14
# You should have received a copy of the GNU General Public License
 
15
# along with this program; if not, write to the Free Software
 
16
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
17
 
 
18
# "Perlized" from C source by Manish Singh <yosh@gimp.org>
 
19
 
 
20
sub pdb_misc {
 
21
    $author = $copyright = 'Michael Natterer';
 
22
    $date = '1999';
 
23
}
 
24
 
 
25
sub unit_arg () {{
 
26
    name => 'unit_id',
 
27
    type => 'unit',
 
28
    desc => "The unit's integer ID",
 
29
    alias => 'unit',
 
30
    wrap => 1
 
31
}}
 
32
 
 
33
sub unit_prop_proc {
 
34
    my ($prop, $type, $desc) = @_;
 
35
    $desc = $prop unless $desc;
 
36
 
 
37
    $blurb = "Returns the $desc of the unit.";
 
38
 
 
39
    &pdb_misc;
 
40
 
 
41
    @inargs = ( &unit_arg );
 
42
 
 
43
    @outargs = (
 
44
        { name => $prop, type => $type,
 
45
          desc => "The unit's $desc",
 
46
          alias => "_gimp_unit_get_$prop (gimp, unit)",
 
47
          no_declare => 1 }
 
48
    );
 
49
 
 
50
    if ($type eq 'string') {
 
51
        $outargs[0]->{alias} = "g_strdup ($outargs[0]->{alias})";
 
52
    }
 
53
}
 
54
 
 
55
sub unit_get_number_of_units {
 
56
    $blurb = 'Returns the number of units.';
 
57
 
 
58
    $help = 'This procedure returns the number of defined units.';
 
59
 
 
60
    &pdb_misc;
 
61
 
 
62
    @outargs = (
 
63
        { name => 'num_units', type => 'int32', libdef => 'GIMP_UNIT_END',
 
64
          desc => 'The number of units', wrap => 1,
 
65
          alias => '_gimp_unit_get_number_of_units (gimp)', no_declare => 1 }
 
66
    );
 
67
}
 
68
 
 
69
sub unit_get_number_of_built_in_units {
 
70
    $blurb = 'Returns the number of built-in units.';
 
71
 
 
72
    $help = <<'HELP';
 
73
This procedure returns the number of defined units built-in to the GIMP.
 
74
HELP
 
75
 
 
76
    &pdb_misc;
 
77
 
 
78
    @outargs = (
 
79
        { name => 'num_units', type => 'int32', libdef => 'GIMP_UNIT_END',
 
80
          desc => 'The number of built-in units', wrap => 1,
 
81
          alias => '_gimp_unit_get_number_of_units (gimp)', no_declare => 1 }
 
82
    );
 
83
}
 
84
 
 
85
 
 
86
sub unit_new {
 
87
    $blurb = "Creates a new unit and returns it's integer ID.";
 
88
 
 
89
    $help = <<'HELP';
 
90
This procedure creates a new unit and returns it's integer ID. Note that the
 
91
new unit will have it's deletion flag set to TRUE, so you will have to set it
 
92
to FALSE with gimp_unit_set_deletion_flag to make it persistent.
 
93
HELP
 
94
 
 
95
    &pdb_misc;
 
96
 
 
97
    @inargs = (
 
98
        { name => 'identifier', type => 'string', wrap => 1,
 
99
          desc => "The new unit's identifier" },
 
100
        { name => 'factor', type => 'float',
 
101
          desc => "The new unit's factor" },
 
102
        { name => 'digits', type => 'int32',
 
103
          desc => "The new unit's digits" },
 
104
        { name => 'symbol', type => 'string',
 
105
          desc => "The new unit's symbol" },
 
106
        { name => 'abbreviation', type => 'string',
 
107
          desc => "The new unit's abbreviation" },
 
108
        { name => 'singular', type => 'string',
 
109
          desc => "The new unit's singular form" },
 
110
        { name => 'plural', type => 'string',
 
111
          desc => "The new unit's plural form" }
 
112
    );
 
113
 
 
114
    @outargs = ( &unit_arg );
 
115
    $outargs[0]->{desc} = "The new unit's ID";
 
116
    $outargs[0]->{init} = 1;
 
117
    $outargs[0]->{libdef} = 'GIMP_UNIT_INCH';
 
118
 
 
119
    %invoke = (
 
120
        code => <<'CODE'
 
121
unit = _gimp_unit_new (gimp, identifier, factor, digits, symbol, abbreviation,
 
122
                       singular, plural);
 
123
CODE
 
124
    );
 
125
}
 
126
 
 
127
sub unit_get_deletion_flag {
 
128
    $help = <<'HELP';
 
129
This procedure returns the deletion flag of the unit. If this value is TRUE the
 
130
unit's definition will not be saved in the user's unitrc file on gimp exit.
 
131
HELP
 
132
 
 
133
    &unit_prop_proc('deletion_flag', 'boolean', 'deletion flag');
 
134
}
 
135
 
 
136
sub unit_set_deletion_flag {
 
137
    $blurb = 'Sets the deletion flag of a unit.';
 
138
 
 
139
    $help = <<'HELP';
 
140
This procedure sets the unit's deletion flag. If the deletion flag of a unit is
 
141
TRUE on gimp exit, this unit's definition will not be saved in the user's
 
142
unitrc.
 
143
HELP
 
144
 
 
145
    &pdb_misc;
 
146
 
 
147
    @inargs = (
 
148
        &unit_arg,
 
149
        { name => 'deletion_flag', type => 'boolean',
 
150
          desc => 'The new deletion flag of the unit' }
 
151
    );
 
152
 
 
153
    %invoke = ( code => '_gimp_unit_set_deletion_flag (gimp, unit, deletion_flag);' );
 
154
}
 
155
 
 
156
sub unit_get_identifier {
 
157
    $help = <<'HELP';
 
158
This procedure returns the textual identifier of the unit. For built-in units
 
159
it will be the english singular form of the unit's name. For user-defined units
 
160
this should equal to the singular form.
 
161
HELP
 
162
 
 
163
    &unit_prop_proc('identifier', 'string', 'textual identifier');
 
164
}
 
165
 
 
166
sub unit_get_factor {
 
167
    $help = <<'HELP';
 
168
This procedure returns the unit's factor which indicates how many units make up
 
169
an inch. Note that asking for the factor of "pixels" will produce an error.
 
170
HELP
 
171
 
 
172
    &unit_prop_proc('factor', 'float');
 
173
}
 
174
 
 
175
sub unit_get_digits {
 
176
    $help = <<'HELP';
 
177
This procedure returns the number of digits you should provide in input or
 
178
output functions to get approximately the same accuracy as with two digits and
 
179
inches. Note that asking for the digits of "pixels" will produce an error.
 
180
HELP
 
181
 
 
182
    &unit_prop_proc('digits', 'int32', 'number of digits');
 
183
}
 
184
 
 
185
sub unit_get_symbol {
 
186
    $help = <<'HELP';
 
187
This procedure returns the symbol of the unit ("''" for inches).
 
188
HELP
 
189
 
 
190
    &unit_prop_proc('symbol', 'string');
 
191
}
 
192
 
 
193
sub unit_get_abbreviation {
 
194
    $help = <<'HELP';
 
195
This procedure returns the abbreviation of the unit ("in" for inches).
 
196
HELP
 
197
 
 
198
    &unit_prop_proc('abbreviation', 'string');
 
199
}
 
200
 
 
201
sub unit_get_singular {
 
202
    $help  = <<'HELP';
 
203
This procedure returns the singular form of the unit.
 
204
HELP
 
205
 
 
206
    &unit_prop_proc('singular', 'string', 'singular form');
 
207
}
 
208
 
 
209
sub unit_get_plural {
 
210
    $help = <<'HELP';
 
211
This procedure returns the plural form of the unit.
 
212
HELP
 
213
 
 
214
    &unit_prop_proc('plural', 'string', 'plural form');
 
215
}
 
216
 
 
217
@headers = qw("libgimpbase/gimpbase.h" "core/gimpunit.h");
 
218
 
 
219
@procs = qw(unit_get_number_of_units unit_get_number_of_built_in_units
 
220
            unit_new unit_get_deletion_flag unit_set_deletion_flag
 
221
            unit_get_identifier unit_get_factor unit_get_digits
 
222
            unit_get_symbol unit_get_abbreviation unit_get_singular
 
223
            unit_get_plural);
 
224
%exports = (app => [@procs], lib => [@procs]);
 
225
 
 
226
$desc = 'Units';
 
227
 
 
228
1;