gimprc.pdb 6.14 KB
Newer Older
1
# GIMP - The GNU Image Manipulation Program
Manish Singh's avatar
Manish Singh committed
2 3
# Copyright (C) 1995 Spencer Kimball and Peter Mattis

4
# This program is free software: you can redistribute it and/or modify
Manish Singh's avatar
Manish Singh committed
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; either version 3 of the License, or
Manish Singh's avatar
Manish Singh committed
7 8 9 10 11 12 13 14
# (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
15
# along with this program.  If not, see <https://www.gnu.org/licenses/>.
Manish Singh's avatar
Manish Singh committed
16 17 18 19 20 21 22 23 24 25

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

sub gimprc_query {
    $blurb = <<'BLURB';
Queries the gimprc file parser for information on a specified token.
BLURB

    $help = <<'HELP';
This procedure is used to locate additional information contained in the gimprc
26
file considered extraneous to the operation of GIMP. Plug-ins that need
27
configuration information can expect it will be stored in the user gimprc
Manish Singh's avatar
Manish Singh committed
28 29 30 31
file and can use this procedure to retrieve it. This query procedure will
return the value associated with the specified token. This corresponds _only_
to entries with the format: (<token> <value>). The value must be a string.
Entries not corresponding to this format will cause warnings to be issued on
32
gimprc parsing and will not be queryable.
Manish Singh's avatar
Manish Singh committed
33 34 35 36 37 38 39
HELP

    &std_pdb_misc;
    $date = '1997';

    @inargs = (
	{ name => 'token', type => 'string',
40
	  desc => 'The token to query for' }
Manish Singh's avatar
Manish Singh committed
41 42 43
    );

    @outargs = (
44
	{ name => 'value', type => 'string',
45
	  desc => 'The value associated with the queried token' }
Manish Singh's avatar
Manish Singh committed
46 47 48
    );

    %invoke = (
Manish Singh's avatar
Manish Singh committed
49 50
	code => <<'CODE'
{
51 52 53 54
  if (strlen (token))
    {
      /*  use edit_config because unknown tokens are set there  */
      value = gimp_rc_query (GIMP_RC (gimp->edit_config), token);
55

56 57 58 59 60
      if (! value)
        success = FALSE;
    }
  else
    success = FALSE;
Manish Singh's avatar
Manish Singh committed
61 62
}
CODE
Manish Singh's avatar
Manish Singh committed
63 64 65
    );
}

66 67 68 69 70
sub gimprc_set {
    $blurb = 'Sets a gimprc token to a value and saves it in the gimprc.';

    $help = <<'HELP';
This procedure is used to add or change additional information in the gimprc
71
file that is considered extraneous to the operation of GIMP. Plug-ins that
72
need configuration information can use this function to store it, and
73
gimp_gimprc_query() to retrieve it.  This will accept _only_ string values in
74
UTF-8 encoding.
75 76
HELP

77
    &seth_pdb_misc('1999');
78 79 80
	
    @inargs = (
	{ name => 'token', type => 'string',
81 82
	  desc => 'The token to add or modify' },
	{ name => 'value', type => 'string',
83 84 85 86
	  desc => 'The value to set the token to' }
    );

    %invoke = ( 
87
	code => <<'CODE'
88
{
89 90 91 92 93 94 95
  if (strlen (token))
    {
      /*  use edit_config because that's the one that gets saved  */
      gimp_rc_set_unknown_token (GIMP_RC (gimp->edit_config), token, value);
    }
  else
    success = FALSE;
96 97
}
CODE
98 99 100
    );
}

101 102
sub get_monitor_resolution {
    $blurb = 'Get the monitor resolution as specified in the Preferences.';
103

104 105
    $help = <<'HELP';
Returns the resolution of the monitor in pixels/inch. This value
106 107
is taken from the Preferences (or the windowing system if this is set in
the Preferences) and there's no guarantee for the value to be reasonable.
108 109 110 111 112
HELP

    &std_pdb_misc;

    @outargs = (
113
	{  name => 'xres', type => 'float', void_ret => 1,
114
	   desc => 'X resolution' },
115
	{  name => 'yres', type => 'float',
116
	   desc => 'Y resolution' },	   
117 118 119 120 121
    );

    %invoke = (
	code => <<'CODE'
{
122 123
  xres = GIMP_DISPLAY_CONFIG (gimp->config)->monitor_xres;
  yres = GIMP_DISPLAY_CONFIG (gimp->config)->monitor_yres;
124 125 126 127 128
}
CODE
    );
}

129 130
sub get_default_comment {
    $blurb = 'Get the default image comment as specified in the Preferences.';
131
    $help  = 'Returns a copy of the default image comment.';
132 133 134 135 136

    &std_pdb_misc;

    @outargs = (
	{  name => 'comment', type => 'string',
137
	   desc => 'Default image comment' }
138 139 140
    );

    %invoke = (
141
	headers => [ qw("core/gimptemplate.h") ],
142 143
	code => <<'CODE'
{
144
  comment = g_strdup (gimp_template_get_comment (gimp->config->default_image));
145 146 147 148 149
}
CODE
    );
}

150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172
sub get_default_unit {
    $blurb = 'Get the default unit (taken from the user\'s locale).';
    $help  = 'Returns the default unit\'s integer ID.';

    &std_pdb_misc;
    $since = '2.4';

    @outargs = (
	{  name => 'unit_id', type => 'unit',
	   desc => 'Default unit' }
    );

    %invoke = (
	headers => [ qw("libgimpbase/gimpbase.h"
                        "core/gimp-utils.h") ],
	code => <<'CODE'
{
  unit_id = gimp_get_default_unit ();
}
CODE
    );
}

173 174 175 176
sub get_color_configuration {
    $blurb = 'Get a serialized version of the color management configuration.';
    $help = 'Returns a string that can be deserialized into a GimpColorConfig object representing the current color management configuration.';

177
    &neo_pdb_misc('2005', '2.4');
178 179 180 181 182 183 184 185

    @outargs = (
	{  name => 'config', type => 'string',
	   desc => 'Serialized color management configuration',
	   wrap => 1 }
    );

    %invoke = (
186
	headers => [ qw("libgimpconfig/gimpconfig.h") ],
187 188 189 190 191 192 193 194
	code => <<'CODE'
{
  config = gimp_config_serialize_to_string (GIMP_CONFIG (gimp->config->color_management), NULL);
}
CODE
    );
}

195 196
sub get_module_load_inhibit {
    $blurb = 'Get the list of modules which should not be loaded.';
197
    $help  = 'Returns a copy of the list of modules which should not be loaded.';
198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215

    &std_pdb_misc;

    @outargs = (
	{  name => 'load_inhibit', type => 'string',
	   desc => 'The list of modules' }
    );

    %invoke = (
	headers => [ qw("libgimpmodule/gimpmodule.h") ],
	code => <<'CODE'
{
  load_inhibit = g_strdup (gimp_module_db_get_load_inhibit (gimp->module_db));
}
CODE
    );
}

216

217 218 219
@headers = qw(<string.h>
              "config/gimprc.h"
              "core/gimp.h");
220

221 222
@procs = qw(gimprc_query
            gimprc_set 
223
            get_default_comment
224 225 226
            get_default_unit
            get_monitor_resolution
            get_color_configuration
227
            get_module_load_inhibit);
228

229
%exports = (app => [@procs], lib => [@procs]);
Manish Singh's avatar
Manish Singh committed
230 231

$desc = 'Gimprc procedures';
232 233 234
$doc_title = 'gimpgimprc';
$doc_short_desc = 'Interactions with settings from gimprc.';
$doc_long_desc = 'Interactions with settings from gimprc.';
Manish Singh's avatar
Manish Singh committed
235 236

1;