2006-04-29 Michael Natterer <mitch@gimp.org> * app/plug-in/Makefile.am * app/plug-in/plug-in-types.h * app/plug-in/gimppluginmanager.[ch]: new object which keeps all plug-in related stuff that was kept in the Gimp instance. Has "menu-branch-added" and "last-plug-in-changed" signals. * app/plug-in/plug-ins.[ch]: removed, all its functions are in GimpPlugInManager now. * app/core/gimpmarshal.list: new marshaller for the new object. * app/core/gimp.[ch]: removed all plug-in related stuff and keep a GimpPlugInManager around. * app/plug-in/plug-in-data.[ch] * app/plug-in/plug-in-file.[ch] * app/plug-in/plug-in-help-domain.[ch] * app/plug-in/plug-in-locale-domain.[ch] * app/plug-in/plug-in-menu-branch.[ch] * app/plug-in/plug-ins-query.[ch]: removed... * app/plug-in/gimppluginmanager-data.[ch] * app/plug-in/gimppluginmanager-file.[ch] * app/plug-in/gimppluginmanager-help-domain.[ch] * app/plug-in/gimppluginmanager-locale-domain.[ch] * app/plug-in/gimppluginmanager-menu-branch.[ch] * app/plug-in/gimppluginmanager-query.[ch]: ...and added as methods of GimpPlugInManager. * app/plug-in/plug-in-debug.[ch] * app/plug-in/plug-in-shm.[ch]: removed... * app/plug-in/gimpplugindebug.[ch] * app/plug-in/gimppluginshm.[ch]: ...and added as properly namespeced structs with constructors and destructors. * app/core/Makefile.am * app/core/gimpenvirontable.[ch] * app/core/gimpinterpreterdb.[ch]: removed... * app/plug-in/gimpenvirontable.[ch] * app/plug-in/gimpinterpreterdb.[ch]: ...and added here unchanged. * app/core/gimp-gui.[ch] * app/gui/gui-vtable.c: remove gimp_menus_create_branch() and all related stuff. * app/actions/plug-in-actions.[ch]: connect to the plug-in-manager's "menu-path-added" signal and create menu branch actions accordingly. * app/plug-in/plug-in-context.c * app/plug-in/plug-in-message.c * app/plug-in/plug-in-progress.c * app/plug-in/plug-in-run.[ch] * app/plug-in/plug-in.[ch] * app/app_procs.c * app/actions/file-commands.c * app/actions/plug-in-commands.c * app/core/gimpimage.c * app/dialogs/file-open-location-dialog.c * app/dialogs/file-save-dialog.c * app/file/file-open.c * app/gui/gui.c * app/menus/plug-in-menus.c * app/pdb/gimppluginprocedure.c * app/pdb/gimptemporaryprocedure.c * app/widgets/gimpdnd-xds.c * app/widgets/gimpfiledialog.c * app/widgets/gimpfileprocview.c * app/widgets/gimphelp.c * app/widgets/gimpthumbbox.c * app/xcf/xcf.c * tools/pdbgen/pdb/context.pdb * tools/pdbgen/pdb/drawable.pdb * tools/pdbgen/pdb/fileops.pdb * tools/pdbgen/pdb/help.pdb * tools/pdbgen/pdb/message.pdb * tools/pdbgen/pdb/plug_in.pdb * tools/pdbgen/pdb/procedural_db.pdb * tools/pdbgen/pdb/progress.pdb * tools/pdbgen/pdb/undo.pdb: follow above refactoring. * app/pdb/context_cmds.c * app/pdb/drawable_cmds.c * app/pdb/fileops_cmds.c * app/pdb/help_cmds.c * app/pdb/message_cmds.c * app/pdb/plug_in_cmds.c * app/pdb/procedural_db_cmds.c * app/pdb/progress_cmds.c * app/pdb/undo_cmds.c: regenerated.
530 lines
15 KiB
Text
530 lines
15 KiB
Text
# The GIMP -- an image manipulation program
|
|
# Copyright (C) 1995, 1996, 1997 Spencer Kimball and Peter Mattis
|
|
# Copyright (C) 1997 Josh MacDonald
|
|
|
|
# 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 2 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, write to the Free Software
|
|
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
# "Perlized" from C source by Manish Singh <yosh@gimp.org>
|
|
|
|
sub file_load {
|
|
$blurb = 'Loads an image file by invoking the right load handler.';
|
|
|
|
$help = <<'HELP';
|
|
This procedure invokes the correct file load handler using magic if possible,
|
|
and falling back on the file's extension and/or prefix if not. The name of
|
|
the file to load is typically a full pathname, and the name entered is what
|
|
the user actually typed before prepending a directory path. The reason for
|
|
this is that if the user types http://www.xcf/~gimp/ he wants to fetch a URL,
|
|
and the full pathname will not look like a URL."
|
|
HELP
|
|
|
|
&josh_pdb_misc('1997');
|
|
|
|
@inargs = (
|
|
{ name => 'run_mode',
|
|
type => 'enum GimpRunMode (no GIMP_RUN_WITH_LAST_VALS)',
|
|
desc => 'The run mode: %%desc%%' },
|
|
{ name => 'filename', type => 'string', no_validate => 1,
|
|
desc => 'The name of the file to load' },
|
|
{ name => 'raw_filename', type => 'string', no_validate => 1,
|
|
desc => 'The name as entered by the user' }
|
|
);
|
|
|
|
@outargs = (
|
|
{ name => 'image', type => 'image',
|
|
desc => 'The output image' }
|
|
);
|
|
|
|
%invoke = (
|
|
no_marshalling => 1,
|
|
code => <<'CODE'
|
|
{
|
|
GValueArray *new_args;
|
|
GValueArray *return_vals;
|
|
GimpPlugInProcedure *file_proc;
|
|
GimpProcedure *proc;
|
|
gchar *uri;
|
|
gint i;
|
|
|
|
uri = file_utils_filename_to_uri (gimp->plug_in_manager->load_procs,
|
|
g_value_get_string (&args->values[1]),
|
|
NULL);
|
|
|
|
if (! uri)
|
|
return gimp_procedure_get_return_values (procedure, FALSE);
|
|
|
|
file_proc = file_utils_find_proc (gimp->plug_in_manager->load_procs, uri);
|
|
|
|
g_free (uri);
|
|
|
|
if (! file_proc)
|
|
return gimp_procedure_get_return_values (procedure, FALSE);
|
|
|
|
proc = GIMP_PROCEDURE (file_proc);
|
|
|
|
new_args = gimp_procedure_get_arguments (proc);
|
|
|
|
for (i = 0; i < 3; i++)
|
|
g_value_transform (&args->values[i], &new_args->values[i]);
|
|
|
|
for (i = 3; i < proc->num_args; i++)
|
|
if (G_IS_PARAM_SPEC_STRING (proc->args[i]))
|
|
g_value_set_static_string (&new_args->values[i], "");
|
|
|
|
return_vals = gimp_pdb_execute_procedure_by_name_args (gimp->pdb,
|
|
context, progress,
|
|
GIMP_OBJECT (proc)->name,
|
|
new_args);
|
|
|
|
g_value_array_free (new_args);
|
|
|
|
return return_vals;
|
|
}
|
|
CODE
|
|
);
|
|
}
|
|
|
|
sub file_load_layer {
|
|
$blurb = 'Loads an image file as a layer into an already opened image.';
|
|
|
|
$help = <<'HELP';
|
|
This procedure behaves like the file-load procedure but opens the specified
|
|
image as a layer into an already opened image.
|
|
HELP
|
|
|
|
&neo_pdb_misc('2005', '2.4');
|
|
|
|
@inargs = (
|
|
{ name => 'run_mode',
|
|
type => 'enum GimpRunMode (no GIMP_RUN_WITH_LAST_VALS)',
|
|
desc => 'The run mode: %%desc%%' },
|
|
{ name => 'image', type => 'image',
|
|
desc => 'Destination image' },
|
|
{ name => 'filename', type => 'string', no_validate => 1,
|
|
desc => 'The name of the file to load' }
|
|
);
|
|
|
|
@outargs = (
|
|
{ name => 'layer', type => 'layer',
|
|
desc => 'The layer created when loading the image file' }
|
|
);
|
|
|
|
%invoke = (
|
|
headers => [ qw("file/file-open.h") ],
|
|
code => <<'CODE'
|
|
{
|
|
gchar *uri = file_utils_filename_to_uri (gimp->plug_in_manager->load_procs,
|
|
filename, NULL);
|
|
|
|
if (uri)
|
|
{
|
|
GimpPDBStatusType status;
|
|
|
|
layer = file_open_layer (gimp, context, progress,
|
|
image, uri, run_mode, NULL, &status, NULL);
|
|
|
|
if (! layer)
|
|
success = FALSE;
|
|
}
|
|
else
|
|
success = FALSE;
|
|
}
|
|
CODE
|
|
);
|
|
}
|
|
|
|
sub file_save {
|
|
$blurb = 'Saves a file by extension.';
|
|
|
|
$help = <<'HELP';
|
|
This procedure invokes the correct file save handler according to the file's
|
|
extension and/or prefix. The name of the file to save is typically a full
|
|
pathname, and the name entered is what the user actually typed before
|
|
prepending a directory path. The reason for this is that if the user types
|
|
http://www.xcf/~gimp/ she wants to fetch a URL, and the full pathname will not
|
|
look like a URL.
|
|
HELP
|
|
|
|
&josh_pdb_misc('1997');
|
|
|
|
@inargs = (
|
|
{ name => 'run_mode', type => 'enum GimpRunMode',
|
|
desc => 'The run mode: %%desc%%' },
|
|
{ name => 'image', type => 'image',
|
|
desc => 'Input image' },
|
|
{ name => 'drawable', type => 'drawable',
|
|
desc => 'Drawable to save' },
|
|
{ name => 'filename', type => 'string', no_validate => 1,
|
|
desc => 'The name of the file to save the image in' },
|
|
{ name => 'raw_filename', type => 'string', no_validate => 1,
|
|
desc => 'The name as entered by the user' }
|
|
);
|
|
|
|
%invoke = (
|
|
headers => [ qw(<string.h>) ],
|
|
no_marshalling => 1,
|
|
code => <<'CODE'
|
|
{
|
|
GValueArray *new_args;
|
|
GValueArray *return_vals;
|
|
GimpPlugInProcedure *file_proc;
|
|
GimpProcedure *proc;
|
|
gchar *uri;
|
|
gint i;
|
|
|
|
uri = file_utils_filename_to_uri (gimp->plug_in_manager->load_procs,
|
|
g_value_get_string (&args->values[3]),
|
|
NULL);
|
|
|
|
if (! uri)
|
|
return gimp_procedure_get_return_values (procedure, FALSE);
|
|
|
|
file_proc = file_utils_find_proc (gimp->plug_in_manager->save_procs, uri);
|
|
|
|
g_free (uri);
|
|
|
|
if (! file_proc)
|
|
return gimp_procedure_get_return_values (procedure, FALSE);
|
|
|
|
proc = GIMP_PROCEDURE (file_proc);
|
|
|
|
new_args = gimp_procedure_get_arguments (proc);
|
|
|
|
for (i = 0; i < 5; i++)
|
|
g_value_transform (&args->values[i], &new_args->values[i]);
|
|
|
|
for (i = 5; i < proc->num_args; i++)
|
|
if (G_IS_PARAM_SPEC_STRING (proc->args[i]))
|
|
g_value_set_static_string (&new_args->values[i], "");
|
|
|
|
return_vals = gimp_pdb_execute_procedure_by_name_args (gimp->pdb,
|
|
context, progress,
|
|
GIMP_OBJECT (proc)->name,
|
|
new_args);
|
|
|
|
g_value_array_free (new_args);
|
|
|
|
return return_vals;
|
|
}
|
|
CODE
|
|
);
|
|
}
|
|
|
|
sub file_load_thumbnail {
|
|
$blurb = 'Loads the thumbnail for a file.';
|
|
|
|
$help = <<'HELP';
|
|
This procedure tries to load a thumbnail that belongs to the file with
|
|
the given filename. This name is a full pathname. The returned data is
|
|
an array of colordepth 3 (RGB), regardless of the image type. Width and
|
|
height of the thumbnail are also returned. Don't use this function if
|
|
you need a thumbnail of an already opened image, use gimp_image_thumbnail
|
|
instead.
|
|
HELP
|
|
|
|
$author = $copyright = 'Adam D. Moss, Sven Neumann';
|
|
$date = '1999-2003';
|
|
|
|
@inargs = (
|
|
{ name => 'filename', type => 'string', no_validate => 1,
|
|
desc => 'The name of the file that owns the thumbnail to load' }
|
|
);
|
|
|
|
@outargs = (
|
|
{ name => 'width', type => 'int32',
|
|
desc => 'The width of the thumbnail' },
|
|
{ name => 'height', type => 'int32',
|
|
desc => 'The height of the thumbnail' },
|
|
{ name => 'thumb_data', type => 'int8array',
|
|
desc => 'The thumbnail data',
|
|
array => { name => 'thumb_data_count',
|
|
desc => 'The number of bytes in thumbnail data' } }
|
|
);
|
|
|
|
%invoke = (
|
|
code => <<'CODE'
|
|
{
|
|
GdkPixbuf *pixbuf = file_utils_load_thumbnail (filename);
|
|
|
|
if (pixbuf)
|
|
{
|
|
width = gdk_pixbuf_get_width (pixbuf);
|
|
height = gdk_pixbuf_get_height (pixbuf);
|
|
thumb_data_count = 3 * width * height;
|
|
thumb_data = g_memdup (gdk_pixbuf_get_pixels (pixbuf),
|
|
thumb_data_count);
|
|
|
|
g_object_unref (pixbuf);
|
|
}
|
|
else
|
|
success = FALSE;
|
|
}
|
|
CODE
|
|
);
|
|
}
|
|
|
|
sub file_save_thumbnail {
|
|
$blurb = 'Saves a thumbnail for the given image';
|
|
|
|
$help = <<'HELP';
|
|
This procedure saves a thumbnail for the given image according to the
|
|
Free Desktop Thumbnail Managing Standard. The thumbnail is saved so
|
|
that it belongs to the file with the given filename. This means you
|
|
have to save the image under this name first, otherwise this procedure
|
|
will fail. This procedure may become useful if you want to
|
|
explicitely save a thumbnail with a file.
|
|
HELP
|
|
|
|
&josh_pdb_misc('1997');
|
|
|
|
@inargs = (
|
|
{ name => 'image', type => 'image',
|
|
desc => 'The image' },
|
|
{ name => 'filename', type => 'string', no_validate => 1,
|
|
desc => 'The name of the file the thumbnail belongs to' },
|
|
);
|
|
|
|
%invoke = (
|
|
code => <<'CODE'
|
|
{
|
|
success = file_utils_save_thumbnail (image, filename);
|
|
}
|
|
CODE
|
|
);
|
|
}
|
|
|
|
sub temp_name {
|
|
$blurb = 'Generates a unique filename.';
|
|
|
|
$help = <<'HELP';
|
|
Generates a unique filename using the temp path supplied in the user's gimprc.
|
|
HELP
|
|
|
|
&josh_pdb_misc('1997');
|
|
|
|
@inargs = (
|
|
{ name => 'extension', type => 'string', no_validate => 1,
|
|
desc => 'The extension the file will have' }
|
|
);
|
|
|
|
@outargs = (
|
|
{ name => 'name', type => 'string',
|
|
desc => 'The new temp filename' }
|
|
);
|
|
|
|
%invoke = (
|
|
headers => [ qw("core/gimp-utils.h") ],
|
|
code => <<'CODE'
|
|
{
|
|
name = gimp_get_temp_filename (gimp, extension);
|
|
}
|
|
CODE
|
|
);
|
|
}
|
|
|
|
sub register_magic_load_handler {
|
|
$blurb = 'Registers a file load handler procedure.';
|
|
|
|
$help = <<'HELP';
|
|
Registers a procedural database procedure to be called to load files of a
|
|
particular file format using magic file information.
|
|
HELP
|
|
|
|
&std_pdb_misc;
|
|
|
|
@inargs = (
|
|
{ name => 'procedure_name', type => 'string',
|
|
desc => 'The name of the procedure to be used for loading' },
|
|
{ name => 'extensions', type => 'string', no_success => 1,
|
|
desc => 'comma separated list of extensions this handler
|
|
can load (i.e. "jpg,jpeg")' },
|
|
{ name => 'prefixes', type => 'string', no_success => 1,
|
|
desc => 'comma separated list of prefixes this handler
|
|
can load (i.e. "http:,ftp:")' },
|
|
{ name => 'magics', type => 'string', no_success => 1,
|
|
desc => 'comma separated list of magic file information
|
|
this handler can load (i.e. "0,string,GIF")' }
|
|
);
|
|
|
|
%invoke = (
|
|
code => <<'CODE'
|
|
{
|
|
gchar *canonical = gimp_canonicalize_identifier (procedure_name);
|
|
|
|
success = gimp_plug_in_manager_register_load_handler (gimp->plug_in_manager,
|
|
canonical,
|
|
extensions, prefixes, magics);
|
|
|
|
g_free (canonical);
|
|
}
|
|
CODE
|
|
);
|
|
}
|
|
|
|
sub register_load_handler {
|
|
$blurb = 'Registers a file load handler procedure.';
|
|
|
|
$help = <<'HELP';
|
|
Registers a procedural database procedure to be called to load files of a
|
|
particular file format.
|
|
HELP
|
|
|
|
&std_pdb_misc;
|
|
|
|
@inargs = (
|
|
{ name => 'procedure_name', type => 'string',
|
|
desc => 'The name of the procedure to be used for loading' },
|
|
{ name => 'extensions', type => 'string', no_success => 1,
|
|
desc => 'comma separated list of extensions this handler
|
|
can load (i.e. "jpg,jpeg")' },
|
|
{ name => 'prefixes', type => 'string', no_success => 1,
|
|
desc => 'comma separated list of prefixes this handler
|
|
can load (i.e. "http:,ftp:")' }
|
|
);
|
|
|
|
|
|
%invoke = (
|
|
code => <<'CODE'
|
|
{
|
|
gchar *canonical = gimp_canonicalize_identifier (procedure_name);
|
|
|
|
success = gimp_plug_in_manager_register_load_handler (gimp->plug_in_manager,
|
|
canonical,
|
|
extensions, prefixes, NULL);
|
|
|
|
g_free (canonical);
|
|
}
|
|
CODE
|
|
);
|
|
}
|
|
|
|
sub register_save_handler {
|
|
$blurb = 'Registers a file save handler procedure.';
|
|
|
|
$help = <<'HELP';
|
|
Registers a procedural database procedure to be called to save files in a
|
|
particular file format.
|
|
HELP
|
|
|
|
&std_pdb_misc;
|
|
|
|
@inargs = (
|
|
{ name => 'procedure_name', type => 'string',
|
|
desc => 'The name of the procedure to be used for saving' },
|
|
{ name => 'extensions', type => 'string', no_success => 1,
|
|
desc => 'comma separated list of extensions this handler
|
|
can save (i.e. "jpg,jpeg")' },
|
|
{ name => 'prefixes', type => 'string', no_success => 1,
|
|
desc => 'comma separated list of prefixes this handler
|
|
can save (i.e. "http:,ftp:")' }
|
|
);
|
|
|
|
%invoke = (
|
|
code => <<'CODE'
|
|
{
|
|
gchar *canonical = gimp_canonicalize_identifier (procedure_name);
|
|
|
|
success = gimp_plug_in_manager_register_save_handler (gimp->plug_in_manager,
|
|
canonical,
|
|
extensions, prefixes);
|
|
|
|
g_free (canonical);
|
|
}
|
|
CODE
|
|
);
|
|
}
|
|
|
|
sub register_file_handler_mime {
|
|
$blurb = 'Associates a MIME type with a file handler procedure.';
|
|
|
|
$help = <<'HELP';
|
|
Registers a MIME type for a file handler procedure. This allows GIMP
|
|
to determine the MIME type of the file opened or saved using this
|
|
procedure.
|
|
HELP
|
|
|
|
&neo_pdb_misc('2004', '2.2');
|
|
|
|
@inargs = (
|
|
{ name => 'procedure_name', type => 'string',
|
|
desc => "The name of the procedure to associate a MIME type with." },
|
|
{ name => 'mime_type', type => 'string',
|
|
desc => "A single MIME type, like for example \"image/jpeg\"." }
|
|
);
|
|
|
|
%invoke = (
|
|
code => <<'CODE'
|
|
{
|
|
gchar *canonical = gimp_canonicalize_identifier (procedure_name);
|
|
|
|
success = gimp_plug_in_manager_register_mime_type (gimp->plug_in_manager,
|
|
canonical, mime_type);
|
|
|
|
g_free (canonical);
|
|
}
|
|
CODE
|
|
);
|
|
}
|
|
|
|
sub register_thumbnail_loader {
|
|
$blurb = 'Associates a thumbnail loader with a file load procedure.';
|
|
|
|
$help = <<'HELP';
|
|
Some file formats allow for embedded thumbnails, other file formats
|
|
contain a scalable image or provide the image data in different
|
|
resolutions. A file plug-in for such a format may register a special
|
|
procedure that allows GIMP to load a thumbnail preview of the
|
|
image. This procedure is then associated with the standard load
|
|
procedure using this function.
|
|
HELP
|
|
|
|
&neo_pdb_misc('2004', '2.2');
|
|
|
|
@inargs = (
|
|
{ name => 'load_proc', type => 'string',
|
|
desc => "The name of the procedure the thumbnail loader with." },
|
|
{ name => 'thumb_proc', type => 'string',
|
|
desc => "The name of the thumbnail load procedure." }
|
|
);
|
|
%invoke = (
|
|
code => <<'CODE'
|
|
{
|
|
gchar *canonical = gimp_canonicalize_identifier (load_proc);
|
|
|
|
success = gimp_plug_in_manager_register_thumb_loader (gimp->plug_in_manager,
|
|
canonical, thumb_proc);
|
|
|
|
g_free (canonical);
|
|
}
|
|
CODE
|
|
);
|
|
}
|
|
|
|
|
|
@headers = qw("libgimpbase/gimpbase.h" "libgimpconfig/gimpconfig.h"
|
|
"core/gimp.h" "plug-in/gimppluginmanager.h"
|
|
"plug-in/gimppluginmanager-file.h" "file/file-utils.h");
|
|
|
|
@procs = qw(file_load file_load_layer file_save
|
|
file_load_thumbnail file_save_thumbnail
|
|
temp_name register_magic_load_handler register_load_handler
|
|
register_save_handler register_file_handler_mime
|
|
register_thumbnail_loader);
|
|
|
|
%exports = (app => [@procs], lib => [@procs[0..2,5..10]]);
|
|
|
|
$desc = 'File Operations';
|
|
|
|
1;
|