File: unit.pdb

package info (click to toggle)
gimp 3.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 222,880 kB
  • sloc: ansic: 870,914; python: 10,965; lisp: 10,857; cpp: 7,355; perl: 4,536; sh: 1,753; xml: 972; yacc: 609; lex: 348; javascript: 150; makefile: 42
file content (186 lines) | stat: -rw-r--r-- 4,915 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
# GIMP - The GNU Image Manipulation Program
# Copyright (C) 1995 Spencer Kimball and Peter Mattis

# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <https://www.gnu.org/licenses/>.

# "Perlized" from C source by Manish Singh <yosh@gimp.org>

sub unit_get_data {
    $blurb = "Returns the various data pertaining to a given unit ID.";

    $help = <<'HELP';
This procedure returns all properties making up an unit.
It is only meant for internal usage to query non built-in units and it
is a programming error to use it directly, in particular for any of the built-in units.
HELP

    &jehan_pdb_misc('2023');

    $lib_private = 1;

    @inargs = (
	{ name => 'unit_id', type => 'int32',
	  desc => "The unit's integer ID" }
    );

    @outargs = (
	{ name => 'name', type => 'string',
	  desc => "The unit's name" },
	{ name => 'factor', type => 'double',
	  desc => "The unit's factor" },
	{ name => 'digits', type => 'int32',
	  desc => "The unit's number of digits" },
	{ name => 'symbol', type => 'string',
	  desc => "The unit's symbol" },
	{ name => 'abbreviation', type => 'string',
	  desc => "The unit's abbreviation" },
    );

    %invoke = (
	code => <<'CODE'
{
  if (unit_id >= 0)
    {
      GimpUnit *unit = gimp_unit_get_by_id (unit_id);

      if (unit != NULL)
        {
          name         = g_strdup (gimp_unit_get_name (unit));
          factor       = gimp_unit_get_factor (unit);
          digits       = gimp_unit_get_digits (unit);
          symbol       = g_strdup (gimp_unit_get_symbol (unit));
          abbreviation = g_strdup (gimp_unit_get_abbreviation (unit));
        }
    }
}
CODE
    );
}

sub unit_new {
    $blurb = "Creates a new unit.";

    $help = <<'HELP';
This procedure creates a new unit and returns it. Note that the new unit
will have it's deletion flag set to TRUE, so you will have to set it
to FALSE with gimp_unit_set_deletion_flag() to make it persistent.
HELP

    &mitch_pdb_misc('1999');

    @inargs = (
	{ name => 'name', type => 'string', non_empty => 1,
	  desc => "The new unit's name" },
	{ name => 'factor', type => 'double',
	  desc => "The new unit's factor" },
	{ name => 'digits', type => 'int32',
	  desc => "The new unit's digits" },
	{ name => 'symbol', type => 'string', non_empty => 1,
	  desc => "The new unit's symbol" },
	{ name => 'abbreviation', type => 'string', non_empty => 1,
	  desc => "The new unit's abbreviation" },
    );

    @outargs = (
	{ name => 'unit', type => 'unit',
	  desc => "The new unit" }
    );

    %invoke = (
	code => <<'CODE'
{
  unit = _gimp_unit_new (gimp, name, factor, digits,
                         symbol, abbreviation);
}
CODE
    );
}

sub unit_get_deletion_flag {
    $blurb = "Returns the deletion flag of the unit.";

    $help = <<'HELP';
This procedure returns the deletion flag of the unit. If this value is TRUE the
unit's definition will not be saved in the user's unitrc file on gimp exit.
HELP

    &mitch_pdb_misc('1999');

    $lib_private = 1;

    @inargs = (
	{ name => 'unit', type => 'unit',
	  desc => "The unit" }
    );

    @outargs = (
	{ name => 'deletion_flag', type => 'boolean',
	  desc => "The unit's deletion flag" }
    );

    %invoke = (
	code => <<'CODE'
{
  deletion_flag = gimp_unit_get_deletion_flag (unit);
}
CODE
    );
}

sub unit_set_deletion_flag {
    $blurb = 'Sets the deletion flag of a unit.';

    $help = <<'HELP';
This procedure sets the unit's deletion flag. If the deletion flag of a unit is
TRUE on gimp exit, this unit's definition will not be saved in the user's
unitrc.
HELP

    &mitch_pdb_misc('1999');

    $lib_private = 1;

    @inargs = (
	{ name => 'unit', type => 'unit',
	  desc => "The unit" },
	{ name => 'deletion_flag', type => 'boolean',
	  desc => 'The new deletion flag of the unit' }
    );

    %invoke = (
	code => <<'CODE'
{
  gimp_unit_set_deletion_flag (unit, deletion_flag);
}
CODE
    );
}

@headers = qw("libgimpbase/gimpbase.h"
              "core/gimp.h"
              "core/gimpunit.h");

@procs = qw(unit_new
            unit_get_data
            unit_get_deletion_flag
            unit_set_deletion_flag);

%exports = (app => [@procs], lib => [@procs]);

$desc = 'Units';
$doc_title = 'gimpunit';
$doc_short_desc = 'Operations on units.';
$doc_long_desc = 'Provides operations on units, a collection of predefined units and functions to create new units.';

1;