gimp/app/plug-in/gimppluginmanager-file.c
Michael Natterer 1ed8dd4f53 app/actions/data-commands.c app/actions/documents-commands.c
2006-10-09  Michael Natterer  <mitch@gimp.org>

	* app/actions/data-commands.c
	* app/actions/documents-commands.c
	* app/actions/drawable-commands.c
	* app/actions/gradients-commands.c
	* app/actions/image-commands.c
	* app/actions/layers-commands.c
	* app/actions/palettes-commands.c
	* app/actions/select-commands.c
	* app/actions/vectors-commands.c
	* app/core/gimp-contexts.c
	* app/core/gimp-documents.c
	* app/core/gimp-edit.c
	* app/core/gimp-modules.c
	* app/core/gimp-parasites.c
	* app/core/gimp-templates.c
	* app/core/gimp-units.c
	* app/core/gimpchannel.c
	* app/core/gimpdatafactory.[ch]
	* app/core/gimpdrawable-bucket-fill.c
	* app/core/gimpimage-merge.c
	* app/core/gimpimagefile.c
	* app/core/gimplayer-floating-sel.c
	* app/core/gimppdbprogress.c
	* app/core/gimpselection.c
	* app/dialogs/palette-import-dialog.c
	* app/display/gimpdisplayshell-dnd.c
	* app/gui/session.c
	* app/gui/themes.c
	* app/pdb/gimpprocedure.c
	* app/plug-in/gimpplugin-message.c
	* app/plug-in/gimpplugin.c
	* app/plug-in/gimppluginmanager-file.c
	* app/plug-in/gimppluginmanager.c
	* app/text/gimptextlayer-xcf.c
	* app/text/gimptextlayer.c
	* app/widgets/gimpcontrollers.c
	* app/widgets/gimpdataeditor.c
	* app/widgets/gimpdevices.c
	* app/widgets/gimpdnd-xds.c
	* app/widgets/gimplayertreeview.c
	* app/widgets/gimptoolbox-dnd.c
	* app/widgets/gimptoolbox.c
	* app/widgets/gimpuimanager.c
	* app/widgets/gimpvectorstreeview.c
	* tools/pdbgen/pdb/brush.pdb
	* tools/pdbgen/pdb/gradient.pdb
	* tools/pdbgen/pdb/palette.pdb: convert lots of g_message() to
	gimp_message(). Make sure we never pass unknown strings (like
	error->message) to printf-like functions directly; run them
	thorugh "%s" instead. Don't translate some messages which should
	never happen.

	* app/pdb/brush_cmds.c
	* app/pdb/gradient_cmds.c
	* app/pdb/palette_cmds.c: regenerated.
2006-10-09 18:49:15 +00:00

197 lines
6.4 KiB
C

/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimppluginmanager-file.c
*
* 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.
*/
#include "config.h"
#include <glib-object.h>
#include "plug-in-types.h"
#include "core/gimp.h"
#include "core/gimpparamspecs.h"
#include "gimpplugin.h"
#include "gimppluginmanager.h"
#include "gimppluginmanager-file.h"
#include "gimppluginprocedure.h"
#include "plug-in-def.h"
/* public functions */
gboolean
gimp_plug_in_manager_register_load_handler (GimpPlugInManager *manager,
const gchar *name,
const gchar *extensions,
const gchar *prefixes,
const gchar *magics)
{
GimpPlugInProcedure *file_proc;
GimpProcedure *procedure;
GSList *list;
g_return_val_if_fail (GIMP_IS_PLUG_IN_MANAGER (manager), FALSE);
g_return_val_if_fail (name != NULL, FALSE);
if (manager->current_plug_in && manager->current_plug_in->plug_in_def)
list = manager->current_plug_in->plug_in_def->procedures;
else
list = manager->plug_in_procedures;
file_proc = gimp_plug_in_procedure_find (list, name);
if (! file_proc)
{
gimp_message (manager->gimp, NULL, GIMP_MESSAGE_ERROR,
"attempt to register nonexistent load handler \"%s\"",
name);
return FALSE;
}
procedure = GIMP_PROCEDURE (file_proc);
if ((procedure->num_args < 3) ||
(procedure->num_values < 1) ||
! GIMP_IS_PARAM_SPEC_INT32 (procedure->args[0]) ||
! G_IS_PARAM_SPEC_STRING (procedure->args[1]) ||
! G_IS_PARAM_SPEC_STRING (procedure->args[2]) ||
! GIMP_IS_PARAM_SPEC_IMAGE_ID (procedure->values[0]))
{
gimp_message (manager->gimp, NULL, GIMP_MESSAGE_ERROR,
"load handler \"%s\" does not take the standard "
"load handler args", name);
return FALSE;
}
gimp_plug_in_procedure_set_file_proc (file_proc,
extensions, prefixes, magics);
if (! g_slist_find (manager->load_procs, file_proc))
manager->load_procs = g_slist_prepend (manager->load_procs, file_proc);
return TRUE;
}
gboolean
gimp_plug_in_manager_register_save_handler (GimpPlugInManager *manager,
const gchar *name,
const gchar *extensions,
const gchar *prefixes)
{
GimpPlugInProcedure *file_proc;
GimpProcedure *procedure;
GSList *list;
g_return_val_if_fail (GIMP_IS_PLUG_IN_MANAGER (manager), FALSE);
g_return_val_if_fail (name != NULL, FALSE);
if (manager->current_plug_in && manager->current_plug_in->plug_in_def)
list = manager->current_plug_in->plug_in_def->procedures;
else
list = manager->plug_in_procedures;
file_proc = gimp_plug_in_procedure_find (list, name);
if (! file_proc)
{
gimp_message (manager->gimp, NULL, GIMP_MESSAGE_ERROR,
"attempt to register nonexistent save handler \"%s\"",
name);
return FALSE;
}
procedure = GIMP_PROCEDURE (file_proc);
if ((procedure->num_args < 5) ||
! GIMP_IS_PARAM_SPEC_INT32 (procedure->args[0]) ||
! GIMP_IS_PARAM_SPEC_IMAGE_ID (procedure->args[1]) ||
! GIMP_IS_PARAM_SPEC_DRAWABLE_ID (procedure->args[2]) ||
! G_IS_PARAM_SPEC_STRING (procedure->args[3]) ||
! G_IS_PARAM_SPEC_STRING (procedure->args[4]))
{
gimp_message (manager->gimp, NULL, GIMP_MESSAGE_ERROR,
"save handler \"%s\" does not take the standard "
"save handler args", name);
return FALSE;
}
gimp_plug_in_procedure_set_file_proc (file_proc,
extensions, prefixes, NULL);
if (! g_slist_find (manager->save_procs, file_proc))
manager->save_procs = g_slist_prepend (manager->save_procs, file_proc);
return TRUE;
}
gboolean
gimp_plug_in_manager_register_mime_type (GimpPlugInManager *manager,
const gchar *name,
const gchar *mime_type)
{
GimpPlugInProcedure *file_proc;
GSList *list;
g_return_val_if_fail (GIMP_IS_PLUG_IN_MANAGER (manager), FALSE);
g_return_val_if_fail (name != NULL, FALSE);
g_return_val_if_fail (mime_type != NULL, FALSE);
if (manager->current_plug_in && manager->current_plug_in->plug_in_def)
list = manager->current_plug_in->plug_in_def->procedures;
else
list = manager->plug_in_procedures;
file_proc = gimp_plug_in_procedure_find (list, name);
if (! file_proc)
return FALSE;
gimp_plug_in_procedure_set_mime_type (file_proc, mime_type);
return TRUE;
}
gboolean
gimp_plug_in_manager_register_thumb_loader (GimpPlugInManager *manager,
const gchar *load_proc,
const gchar *thumb_proc)
{
GimpPlugInProcedure *file_proc;
GSList *list;
g_return_val_if_fail (GIMP_IS_PLUG_IN_MANAGER (manager), FALSE);
g_return_val_if_fail (load_proc, FALSE);
g_return_val_if_fail (thumb_proc, FALSE);
if (manager->current_plug_in && manager->current_plug_in->plug_in_def)
list = manager->current_plug_in->plug_in_def->procedures;
else
list = manager->plug_in_procedures;
file_proc = gimp_plug_in_procedure_find (list, load_proc);
if (! file_proc)
return FALSE;
gimp_plug_in_procedure_set_thumb_loader (file_proc, thumb_proc);
return TRUE;
}