1999-05-04 03:22:58 +08:00
/* The GIMP -- an image manipulation program
2003-07-03 08:47:26 +08:00
* Copyright ( C ) 1995 - 2003 Spencer Kimball and Peter Mattis
1999-05-04 03:22:58 +08:00
*
* 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 .
*/
/* NOTE: This file is autogenerated by pdbgen.pl. */
2000-12-29 23:22:01 +08:00
# include "config.h"
1999-05-04 03:22:58 +08:00
# include <stdlib.h>
# include <string.h>
2001-08-17 22:27:31 +08:00
# include <glib-object.h>
2000-12-29 23:22:01 +08:00
2004-05-07 07:26:45 +08:00
# include "libgimpbase/gimpbase.h"
2004-05-07 08:30:24 +08:00
# include "libgimpbase/gimpprotocol.h"
2004-05-07 07:26:45 +08:00
2001-08-17 22:27:31 +08:00
# include "pdb-types.h"
2000-12-29 23:22:01 +08:00
# include "procedural_db.h"
2001-10-29 19:47:11 +08:00
# include "core/gimp.h"
2002-03-21 01:46:13 +08:00
# include "plug-in/plug-in-def.h"
2004-05-07 08:30:24 +08:00
# include "plug-in/plug-in-params.h"
2002-03-21 01:46:13 +08:00
# include "plug-in/plug-in-proc.h"
# include "plug-in/plug-in-progress.h"
2001-12-01 08:14:14 +08:00
# include "plug-in/plug-in.h"
2002-03-21 01:46:13 +08:00
# include "plug-in/plug-ins.h"
2001-01-03 08:42:57 +08:00
# ifdef HAVE_GLIBC_REGEX
# include <regex.h>
# else
2001-07-12 08:58:39 +08:00
# include "regexrepl/regex.h"
2001-01-03 08:42:57 +08:00
# endif
1999-05-04 03:22:58 +08:00
static ProcRecord progress_init_proc ;
static ProcRecord progress_update_proc ;
static ProcRecord plugins_query_proc ;
2000-05-31 21:24:14 +08:00
static ProcRecord plugin_domain_register_proc ;
static ProcRecord plugin_help_register_proc ;
2004-05-06 22:23:21 +08:00
static ProcRecord plugin_menu_register_proc ;
2004-05-19 05:19:43 +08:00
static ProcRecord plugin_icon_register_proc ;
1999-05-04 03:22:58 +08:00
void
2001-07-05 03:31:35 +08:00
register_plug_in_procs ( Gimp * gimp )
1999-05-04 03:22:58 +08:00
{
2001-07-05 03:31:35 +08:00
procedural_db_register ( gimp , & progress_init_proc ) ;
procedural_db_register ( gimp , & progress_update_proc ) ;
procedural_db_register ( gimp , & plugins_query_proc ) ;
procedural_db_register ( gimp , & plugin_domain_register_proc ) ;
procedural_db_register ( gimp , & plugin_help_register_proc ) ;
2004-05-06 22:23:21 +08:00
procedural_db_register ( gimp , & plugin_menu_register_proc ) ;
2004-05-19 05:19:43 +08:00
procedural_db_register ( gimp , & plugin_icon_register_proc ) ;
1999-05-04 03:22:58 +08:00
}
static int
match_strings ( regex_t * preg ,
gchar * a )
{
return regexec ( preg , a , 0 , NULL , 0 ) ;
}
static Argument *
2004-04-15 07:37:34 +08:00
progress_init_invoker ( Gimp * gimp ,
GimpContext * context ,
Argument * args )
1999-05-04 03:22:58 +08:00
{
2003-08-20 03:08:11 +08:00
gboolean success = TRUE ;
1999-05-04 03:22:58 +08:00
gchar * message ;
gint32 gdisplay ;
message = ( gchar * ) args [ 0 ] . value . pdb_pointer ;
2003-08-20 03:08:11 +08:00
if ( message & & ! g_utf8_validate ( message , - 1 , NULL ) )
success = FALSE ;
1999-05-04 03:22:58 +08:00
gdisplay = args [ 1 ] . value . pdb_int ;
2003-08-20 03:08:11 +08:00
if ( success )
1999-05-04 06:36:26 +08:00
{
2003-08-20 03:08:11 +08:00
if ( gimp - > current_plug_in & & gimp - > current_plug_in - > open )
2004-03-27 00:49:18 +08:00
{
if ( ! gimp - > no_interface )
plug_in_progress_start ( gimp - > current_plug_in , message , gdisplay ) ;
}
2003-08-20 03:08:11 +08:00
else
2004-03-27 00:49:18 +08:00
success = FALSE ;
1999-05-04 06:36:26 +08:00
}
1999-05-04 03:22:58 +08:00
1999-05-04 06:36:26 +08:00
return procedural_db_return_args ( & progress_init_proc , success ) ;
1999-05-04 03:22:58 +08:00
}
static ProcArg progress_init_inargs [ ] =
{
{
2001-05-21 21:58:46 +08:00
GIMP_PDB_STRING ,
1999-05-04 03:22:58 +08:00
" message " ,
" Message to use in the progress dialog "
} ,
{
2001-05-21 21:58:46 +08:00
GIMP_PDB_INT32 ,
1999-05-04 03:22:58 +08:00
" gdisplay " ,
2001-10-29 19:47:11 +08:00
" GimpDisplay to update progressbar in, or -1 for a seperate window "
1999-05-04 03:22:58 +08:00
}
} ;
static ProcRecord progress_init_proc =
{
" gimp_progress_init " ,
" Initializes the progress bar for the current plug-in. " ,
" Initializes the progress bar for the current plug-in. It is only valid to call this procedure from a plug-in. " ,
" Spencer Kimball & Peter Mattis " ,
" Spencer Kimball & Peter Mattis " ,
" 1995-1996 " ,
2001-05-21 21:58:46 +08:00
GIMP_INTERNAL ,
1999-05-04 03:22:58 +08:00
2 ,
progress_init_inargs ,
0 ,
NULL ,
{ { progress_init_invoker } }
} ;
static Argument *
2004-04-15 07:37:34 +08:00
progress_update_invoker ( Gimp * gimp ,
GimpContext * context ,
Argument * args )
1999-05-04 03:22:58 +08:00
{
2004-07-16 22:43:56 +08:00
gboolean success = TRUE ;
1999-05-04 03:22:58 +08:00
gdouble percentage ;
percentage = args [ 0 ] . value . pdb_float ;
2003-02-11 20:07:31 +08:00
if ( gimp - > current_plug_in & & gimp - > current_plug_in - > open )
1999-05-04 06:36:26 +08:00
{
2001-10-29 19:47:11 +08:00
if ( ! gimp - > no_interface )
2004-03-27 00:49:18 +08:00
plug_in_progress_update ( gimp - > current_plug_in , percentage ) ;
1999-05-04 06:36:26 +08:00
}
2004-07-16 22:43:56 +08:00
else
success = FALSE ;
1999-05-04 03:22:58 +08:00
1999-05-04 06:36:26 +08:00
return procedural_db_return_args ( & progress_update_proc , success ) ;
1999-05-04 03:22:58 +08:00
}
static ProcArg progress_update_inargs [ ] =
{
{
2001-05-21 21:58:46 +08:00
GIMP_PDB_FLOAT ,
1999-05-04 03:22:58 +08:00
" percentage " ,
2003-08-29 04:23:09 +08:00
" Percentage of progress completed which must be between 0.0 and 1.0 "
1999-05-04 03:22:58 +08:00
}
} ;
static ProcRecord progress_update_proc =
{
" gimp_progress_update " ,
" Updates the progress bar for the current plug-in. " ,
" Updates the progress bar for the current plug-in. It is only valid to call this procedure from a plug-in. " ,
" Spencer Kimball & Peter Mattis " ,
" Spencer Kimball & Peter Mattis " ,
" 1995-1996 " ,
2001-05-21 21:58:46 +08:00
GIMP_INTERNAL ,
1999-05-04 03:22:58 +08:00
1 ,
progress_update_inargs ,
0 ,
NULL ,
{ { progress_update_invoker } }
} ;
static Argument *
2004-04-15 07:37:34 +08:00
plugins_query_invoker ( Gimp * gimp ,
GimpContext * context ,
Argument * args )
1999-05-04 03:22:58 +08:00
{
Argument * return_args ;
gchar * search_str ;
gint32 num_plugins = 0 ;
gchar * * menu_strs ;
gchar * * accel_strs ;
gchar * * prog_strs ;
gchar * * types_strs ;
gint32 * time_ints ;
gchar * * realname_strs ;
2004-05-07 19:25:45 +08:00
GSList * list ;
1999-05-04 03:22:58 +08:00
gint i = 0 ;
regex_t sregex ;
search_str = ( gchar * ) args [ 0 ] . value . pdb_pointer ;
if ( search_str & & strlen ( search_str ) )
regcomp ( & sregex , search_str , REG_ICASE ) ;
else
search_str = NULL ;
2004-05-07 19:25:45 +08:00
/* count number of plugin entries, then allocate arrays of correct size
1999-05-04 03:22:58 +08:00
* where we can store the strings .
*/
2003-02-13 19:32:49 +08:00
for ( list = gimp - > plug_in_proc_defs ; list ; list = g_slist_next ( list ) )
1999-05-04 03:22:58 +08:00
{
2004-05-07 19:25:45 +08:00
PlugInProcDef * proc_def = list - > data ;
1999-05-04 03:22:58 +08:00
2004-05-06 21:51:56 +08:00
if ( proc_def - > prog & & proc_def - > menu_paths )
2004-03-27 00:49:18 +08:00
{
2004-05-07 19:25:45 +08:00
gchar * name ;
1999-05-04 03:22:58 +08:00
2004-05-07 19:25:45 +08:00
if ( proc_def - > menu_label )
{
name = proc_def - > menu_label ;
}
2004-03-27 00:49:18 +08:00
else
2004-05-07 19:25:45 +08:00
{
name = strrchr ( proc_def - > menu_paths - > data , ' / ' ) ;
if ( name )
name = name + 1 ;
else
name = proc_def - > menu_paths - > data ;
}
1999-05-04 03:22:58 +08:00
2004-03-27 00:49:18 +08:00
if ( search_str & & match_strings ( & sregex , name ) )
continue ;
1999-05-04 03:22:58 +08:00
2004-03-27 00:49:18 +08:00
num_plugins + + ;
}
1999-05-04 03:22:58 +08:00
}
menu_strs = g_new ( gchar * , num_plugins ) ;
accel_strs = g_new ( gchar * , num_plugins ) ;
prog_strs = g_new ( gchar * , num_plugins ) ;
types_strs = g_new ( gchar * , num_plugins ) ;
realname_strs = g_new ( gchar * , num_plugins ) ;
time_ints = g_new ( gint , num_plugins ) ;
2003-02-13 19:32:49 +08:00
for ( list = gimp - > plug_in_proc_defs ; list ; list = g_slist_next ( list ) )
1999-05-04 03:22:58 +08:00
{
2004-05-07 19:25:45 +08:00
PlugInProcDef * proc_def = list - > data ;
1999-05-04 03:22:58 +08:00
if ( i > num_plugins )
2004-03-27 00:49:18 +08:00
g_error ( " Internal error counting plugins " ) ;
1999-05-04 03:22:58 +08:00
2004-05-06 21:51:56 +08:00
if ( proc_def - > prog & & proc_def - > menu_paths )
2004-03-27 00:49:18 +08:00
{
ProcRecord * pr = & proc_def - > db_info ;
2004-05-07 19:25:45 +08:00
gchar * name ;
1999-05-04 03:22:58 +08:00
2004-05-07 19:25:45 +08:00
if ( proc_def - > menu_label )
{
name = proc_def - > menu_label ;
}
2004-03-27 00:49:18 +08:00
else
2004-05-07 19:25:45 +08:00
{
name = strrchr ( proc_def - > menu_paths - > data , ' / ' ) ;
if ( name )
name = name + 1 ;
else
name = proc_def - > menu_paths - > data ;
}
1999-05-04 03:22:58 +08:00
2004-05-07 19:25:45 +08:00
if ( search_str & & match_strings ( & sregex , name ) )
2004-03-27 00:49:18 +08:00
continue ;
1999-05-04 03:22:58 +08:00
2004-05-06 21:51:56 +08:00
menu_strs [ i ] = gimp_strip_uline ( proc_def - > menu_paths - > data ) ;
2004-05-07 19:25:45 +08:00
accel_strs [ i ] = NULL ;
2004-03-27 00:49:18 +08:00
prog_strs [ i ] = g_strdup ( proc_def - > prog ) ;
types_strs [ i ] = g_strdup ( proc_def - > image_types ) ;
realname_strs [ i ] = g_strdup ( pr - > name ) ;
time_ints [ i ] = proc_def - > mtime ;
1999-05-04 03:22:58 +08:00
2004-03-27 00:49:18 +08:00
i + + ;
}
1999-05-04 03:22:58 +08:00
}
if ( search_str )
2003-09-05 01:10:30 +08:00
regfree ( & sregex ) ;
1999-05-04 03:22:58 +08:00
return_args = procedural_db_return_args ( & plugins_query_proc , TRUE ) ;
return_args [ 1 ] . value . pdb_int = num_plugins ;
return_args [ 2 ] . value . pdb_pointer = menu_strs ;
return_args [ 3 ] . value . pdb_int = num_plugins ;
return_args [ 4 ] . value . pdb_pointer = accel_strs ;
return_args [ 5 ] . value . pdb_int = num_plugins ;
return_args [ 6 ] . value . pdb_pointer = prog_strs ;
return_args [ 7 ] . value . pdb_int = num_plugins ;
return_args [ 8 ] . value . pdb_pointer = types_strs ;
return_args [ 9 ] . value . pdb_int = num_plugins ;
return_args [ 10 ] . value . pdb_pointer = time_ints ;
return_args [ 11 ] . value . pdb_int = num_plugins ;
return_args [ 12 ] . value . pdb_pointer = realname_strs ;
return return_args ;
}
static ProcArg plugins_query_inargs [ ] =
{
{
2001-05-21 21:58:46 +08:00
GIMP_PDB_STRING ,
1999-05-04 03:22:58 +08:00
" search_string " ,
" If not an empty string then use this as a search pattern "
}
} ;
static ProcArg plugins_query_outargs [ ] =
{
{
2001-05-21 21:58:46 +08:00
GIMP_PDB_INT32 ,
1999-05-04 03:22:58 +08:00
" num_plugins " ,
" The number of plugins "
} ,
{
2001-05-21 21:58:46 +08:00
GIMP_PDB_STRINGARRAY ,
1999-05-04 03:22:58 +08:00
" menu_path " ,
" The menu path of the plugin "
} ,
{
2001-05-21 21:58:46 +08:00
GIMP_PDB_INT32 ,
1999-05-04 03:22:58 +08:00
" num_plugins " ,
" The number of plugins "
} ,
{
2001-05-21 21:58:46 +08:00
GIMP_PDB_STRINGARRAY ,
1999-05-04 03:22:58 +08:00
" plugin_accelerator " ,
" String representing keyboard accelerator (could be empty string) "
} ,
{
2001-05-21 21:58:46 +08:00
GIMP_PDB_INT32 ,
1999-05-04 03:22:58 +08:00
" num_plugins " ,
" The number of plugins "
} ,
{
2001-05-21 21:58:46 +08:00
GIMP_PDB_STRINGARRAY ,
1999-05-04 03:22:58 +08:00
" plugin_location " ,
" Location of the plugin program "
} ,
{
2001-05-21 21:58:46 +08:00
GIMP_PDB_INT32 ,
1999-05-04 03:22:58 +08:00
" num_plugins " ,
" The number of plugins "
} ,
{
2001-05-21 21:58:46 +08:00
GIMP_PDB_STRINGARRAY ,
1999-05-04 03:22:58 +08:00
" plugin_image_type " ,
" Type of image that this plugin will work on "
} ,
{
2001-05-21 21:58:46 +08:00
GIMP_PDB_INT32 ,
1999-05-04 03:22:58 +08:00
" num_plugins " ,
" The number of plugins "
} ,
{
2001-05-21 21:58:46 +08:00
GIMP_PDB_INT32ARRAY ,
1999-05-04 03:22:58 +08:00
" plugin_install_time " ,
" Time that the plugin was installed "
} ,
{
2001-05-21 21:58:46 +08:00
GIMP_PDB_INT32 ,
1999-05-04 03:22:58 +08:00
" num_plugins " ,
" The number of plugins "
} ,
{
2001-05-21 21:58:46 +08:00
GIMP_PDB_STRINGARRAY ,
1999-05-04 03:22:58 +08:00
" plugin_real_name " ,
" The internal name of the plugin "
}
} ;
static ProcRecord plugins_query_proc =
{
" gimp_plugins_query " ,
" Queries the plugin database for its contents. " ,
" This procedure queries the contents of the plugin database. " ,
" Andy Thomas " ,
" Andy Thomas " ,
" 1998 " ,
2001-05-21 21:58:46 +08:00
GIMP_INTERNAL ,
1999-05-04 03:22:58 +08:00
1 ,
plugins_query_inargs ,
12 ,
plugins_query_outargs ,
{ { plugins_query_invoker } }
} ;
2000-02-24 02:07:53 +08:00
static Argument *
2004-04-15 07:37:34 +08:00
plugin_domain_register_invoker ( Gimp * gimp ,
GimpContext * context ,
Argument * args )
2000-02-24 02:07:53 +08:00
{
gboolean success = TRUE ;
gchar * domain_name ;
gchar * domain_path ;
domain_name = ( gchar * ) args [ 0 ] . value . pdb_pointer ;
2003-08-19 02:09:26 +08:00
if ( domain_name = = NULL | | ! g_utf8_validate ( domain_name , - 1 , NULL ) )
2000-02-24 02:07:53 +08:00
success = FALSE ;
domain_path = ( gchar * ) args [ 1 ] . value . pdb_pointer ;
if ( success )
{
2003-02-11 20:07:31 +08:00
if ( gimp - > current_plug_in & & gimp - > current_plug_in - > query )
2004-03-27 00:49:18 +08:00
{
plug_in_def_set_locale_domain_name ( gimp - > current_plug_in - > plug_in_def ,
domain_name ) ;
plug_in_def_set_locale_domain_path ( gimp - > current_plug_in - > plug_in_def ,
domain_path ) ;
}
2004-07-16 22:43:56 +08:00
else
success = FALSE ;
2000-02-24 02:07:53 +08:00
}
2000-05-31 21:24:14 +08:00
return procedural_db_return_args ( & plugin_domain_register_proc , success ) ;
2000-02-24 02:07:53 +08:00
}
2000-05-31 21:24:14 +08:00
static ProcArg plugin_domain_register_inargs [ ] =
2000-02-24 02:07:53 +08:00
{
{
2001-05-21 21:58:46 +08:00
GIMP_PDB_STRING ,
2000-02-24 02:07:53 +08:00
" domain_name " ,
2003-08-20 03:08:11 +08:00
" The name of the textdomain (must be unique) "
2000-02-24 02:07:53 +08:00
} ,
{
2001-05-21 21:58:46 +08:00
GIMP_PDB_STRING ,
2000-02-24 02:07:53 +08:00
" domain_path " ,
2003-08-20 03:08:11 +08:00
" The absolute path to the compiled message catalog (may be NULL) "
2000-02-24 02:07:53 +08:00
}
} ;
2000-05-31 21:24:14 +08:00
static ProcRecord plugin_domain_register_proc =
2000-02-24 02:07:53 +08:00
{
2000-05-31 21:24:14 +08:00
" gimp_plugin_domain_register " ,
" Registers a textdomain for localisation. " ,
2000-05-31 14:15:06 +08:00
" This procedure adds a textdomain to the list of domains Gimp searches for strings when translating its menu entries. There is no need to call this function for plug-ins that have their strings included in the gimp-std-plugins domain as that is used by default. If the compiled message catalog is not in the standard location, you may specify an absolute path to another location. This procedure can only be called in the query function of a plug-in and it has to be called before any procedure is installed. " ,
2000-02-24 02:07:53 +08:00
" Sven Neumann " ,
" Sven Neumann " ,
" 2000 " ,
2001-05-21 21:58:46 +08:00
GIMP_INTERNAL ,
2000-02-24 02:07:53 +08:00
2 ,
2000-05-31 21:24:14 +08:00
plugin_domain_register_inargs ,
2000-02-24 02:07:53 +08:00
0 ,
NULL ,
2000-05-31 21:24:14 +08:00
{ { plugin_domain_register_invoker } }
} ;
static Argument *
2004-04-15 07:37:34 +08:00
plugin_help_register_invoker ( Gimp * gimp ,
GimpContext * context ,
Argument * args )
2000-05-31 21:24:14 +08:00
{
gboolean success = TRUE ;
2003-08-29 02:49:11 +08:00
gchar * domain_name ;
gchar * domain_uri ;
domain_name = ( gchar * ) args [ 0 ] . value . pdb_pointer ;
if ( domain_name = = NULL | | ! g_utf8_validate ( domain_name , - 1 , NULL ) )
success = FALSE ;
2000-05-31 21:24:14 +08:00
2003-08-29 02:49:11 +08:00
domain_uri = ( gchar * ) args [ 1 ] . value . pdb_pointer ;
if ( domain_uri = = NULL | | ! g_utf8_validate ( domain_uri , - 1 , NULL ) )
2000-05-31 21:24:14 +08:00
success = FALSE ;
if ( success )
{
2003-02-11 20:07:31 +08:00
if ( gimp - > current_plug_in & & gimp - > current_plug_in - > query )
2004-03-27 00:49:18 +08:00
{
plug_in_def_set_help_domain_name ( gimp - > current_plug_in - > plug_in_def ,
domain_name ) ;
plug_in_def_set_help_domain_uri ( gimp - > current_plug_in - > plug_in_def ,
domain_uri ) ;
}
2004-07-16 22:43:56 +08:00
else
success = FALSE ;
2000-05-31 21:24:14 +08:00
}
return procedural_db_return_args ( & plugin_help_register_proc , success ) ;
}
static ProcArg plugin_help_register_inargs [ ] =
{
{
2001-05-21 21:58:46 +08:00
GIMP_PDB_STRING ,
2003-08-29 02:49:11 +08:00
" domain_name " ,
" The XML namespace of the plug-in's help pages "
} ,
{
GIMP_PDB_STRING ,
" domain_uri " ,
" The root URI of the plug-in's help pages "
2000-05-31 21:24:14 +08:00
}
} ;
static ProcRecord plugin_help_register_proc =
{
" gimp_plugin_help_register " ,
" Register a help path for a plug-in. " ,
2003-08-29 02:49:11 +08:00
" This procedure changes the help rootdir for the plug-in which calls it. All subsequent calls of gimp_help from this plug-in will be interpreted relative to this rootdir. " ,
2000-05-31 21:24:14 +08:00
" Michael Natterer <mitch@gimp.org> " ,
" Michael Natterer <mitch@gimp.org> " ,
" 2000 " ,
2001-05-21 21:58:46 +08:00
GIMP_INTERNAL ,
2003-08-29 02:49:11 +08:00
2 ,
2000-05-31 21:24:14 +08:00
plugin_help_register_inargs ,
0 ,
NULL ,
{ { plugin_help_register_invoker } }
2000-02-24 02:07:53 +08:00
} ;
2004-05-06 21:51:56 +08:00
static Argument *
2004-05-06 22:23:21 +08:00
plugin_menu_register_invoker ( Gimp * gimp ,
GimpContext * context ,
Argument * args )
2004-05-06 21:51:56 +08:00
{
gboolean success = TRUE ;
gchar * procedure_name ;
gchar * menu_path ;
procedure_name = ( gchar * ) args [ 0 ] . value . pdb_pointer ;
if ( procedure_name = = NULL | | ! g_utf8_validate ( procedure_name , - 1 , NULL ) )
success = FALSE ;
menu_path = ( gchar * ) args [ 1 ] . value . pdb_pointer ;
if ( menu_path = = NULL | | ! g_utf8_validate ( menu_path , - 1 , NULL ) )
success = FALSE ;
if ( success )
{
if ( gimp - > current_plug_in & & gimp - > current_plug_in - > query )
{
GSList * list ;
for ( list = gimp - > current_plug_in - > plug_in_def - > proc_defs ;
list ;
list = g_slist_next ( list ) )
{
PlugInProcDef * proc_def = list - > data ;
if ( ! strcmp ( procedure_name , proc_def - > db_info . name ) )
{
2004-05-07 08:30:24 +08:00
if ( proc_def - > menu_label )
{
GError * error = NULL ;
if ( ! plug_in_proc_args_check ( gimp - > current_plug_in - > name ,
gimp - > current_plug_in - > prog ,
procedure_name ,
menu_path ,
proc_def - > db_info . args ,
proc_def - > db_info . num_args ,
proc_def - > db_info . values ,
proc_def - > db_info . num_values ,
& error ) )
{
g_message ( error - > message ) ;
g_clear_error ( & error ) ;
success = FALSE ;
}
else
{
proc_def - > menu_paths = g_list_append ( proc_def - > menu_paths ,
g_strdup ( menu_path ) ) ;
}
}
else
{
g_message ( " Plug-In \" %s \" \n (%s) \n \n "
" attempted to install additional menu_path \" %s \" \n "
" for procedure \" %s \" . \n "
" However the menu_path given in "
" gimp_install_procedure() already contained "
" a path. To make this work, pass just the menu's "
" label to gimp_install_procedure(). " ,
gimp_filename_to_utf8 ( gimp - > current_plug_in - > name ) ,
gimp_filename_to_utf8 ( gimp - > current_plug_in - > prog ) ,
menu_path , procedure_name ) ;
success = FALSE ;
}
2004-05-06 21:51:56 +08:00
break ;
}
}
if ( ! list )
success = FALSE ;
}
2004-07-16 22:43:56 +08:00
else
success = FALSE ;
2004-05-06 21:51:56 +08:00
}
2004-05-06 22:23:21 +08:00
return procedural_db_return_args ( & plugin_menu_register_proc , success ) ;
2004-05-06 21:51:56 +08:00
}
2004-05-06 22:23:21 +08:00
static ProcArg plugin_menu_register_inargs [ ] =
2004-05-06 21:51:56 +08:00
{
{
GIMP_PDB_STRING ,
" procedure_name " ,
" The procedure for which to install the menu path "
} ,
{
GIMP_PDB_STRING ,
" menu_path " ,
" The procedure's additional menu path "
}
} ;
2004-05-06 22:23:21 +08:00
static ProcRecord plugin_menu_register_proc =
2004-05-06 21:51:56 +08:00
{
2004-05-06 22:23:21 +08:00
" gimp_plugin_menu_register " ,
2004-05-06 21:51:56 +08:00
" Register an additional menu path for a plug-in procedure. " ,
" This procedure installs an additional menu entry for the given procedure. " ,
" Michael Natterer <mitch@gimp.org> " ,
" Michael Natterer <mitch@gimp.org> " ,
" 2004 " ,
GIMP_INTERNAL ,
2 ,
2004-05-06 22:23:21 +08:00
plugin_menu_register_inargs ,
2004-05-06 21:51:56 +08:00
0 ,
NULL ,
2004-05-06 22:23:21 +08:00
{ { plugin_menu_register_invoker } }
2004-05-06 21:51:56 +08:00
} ;
2004-05-19 05:19:43 +08:00
static Argument *
plugin_icon_register_invoker ( Gimp * gimp ,
GimpContext * context ,
Argument * args )
{
gboolean success = TRUE ;
gchar * procedure_name ;
gint32 icon_type ;
gint32 icon_data_length ;
guint8 * icon_data ;
procedure_name = ( gchar * ) args [ 0 ] . value . pdb_pointer ;
if ( procedure_name = = NULL | | ! g_utf8_validate ( procedure_name , - 1 , NULL ) )
success = FALSE ;
icon_type = args [ 1 ] . value . pdb_int ;
if ( icon_type < GIMP_ICON_TYPE_STOCK_ID | | icon_type > GIMP_ICON_TYPE_IMAGE_FILE )
success = FALSE ;
icon_data_length = args [ 2 ] . value . pdb_int ;
2004-05-20 09:13:14 +08:00
if ( icon_data_length < = 0 )
success = FALSE ;
2004-05-19 05:19:43 +08:00
icon_data = ( guint8 * ) args [ 3 ] . value . pdb_pointer ;
if ( success )
{
if ( gimp - > current_plug_in & & gimp - > current_plug_in - > query )
{
GSList * list ;
for ( list = gimp - > current_plug_in - > plug_in_def - > proc_defs ;
list ;
list = g_slist_next ( list ) )
{
PlugInProcDef * proc_def = list - > data ;
if ( ! strcmp ( procedure_name , proc_def - > db_info . name ) )
{
if ( proc_def - > icon_data )
{
g_free ( proc_def - > icon_data ) ;
proc_def - > icon_data_length = - 1 ;
proc_def - > icon_data = NULL ;
}
proc_def - > icon_type = icon_type ;
switch ( proc_def - > icon_type )
{
case GIMP_ICON_TYPE_STOCK_ID :
case GIMP_ICON_TYPE_IMAGE_FILE :
proc_def - > icon_data_length = - 1 ;
proc_def - > icon_data = g_strdup ( icon_data ) ;
break ;
case GIMP_ICON_TYPE_INLINE_PIXBUF :
proc_def - > icon_data_length = icon_data_length ;
proc_def - > icon_data = g_memdup ( icon_data ,
icon_data_length ) ;
break ;
}
break ;
}
}
if ( ! list )
success = FALSE ;
}
2004-07-16 22:43:56 +08:00
else
success = FALSE ;
2004-05-19 05:19:43 +08:00
}
return procedural_db_return_args ( & plugin_icon_register_proc , success ) ;
}
static ProcArg plugin_icon_register_inargs [ ] =
{
{
GIMP_PDB_STRING ,
" procedure_name " ,
" The procedure for which to install the icon "
} ,
{
GIMP_PDB_INT32 ,
" icon_type " ,
" The type of the icon "
} ,
{
GIMP_PDB_INT32 ,
" icon_data_length " ,
2004-05-20 09:13:14 +08:00
" The length of 'icon_data': 0 < icon_data_length "
2004-05-19 05:19:43 +08:00
} ,
{
GIMP_PDB_INT8ARRAY ,
" icon_data " ,
" The procedure's icon. The format depends on the 'icon_type' parameter "
}
} ;
static ProcRecord plugin_icon_register_proc =
{
" gimp_plugin_icon_register " ,
" Register an icon for a plug-in procedure. " ,
" This procedure installs an icon for the given procedure. " ,
" Michael Natterer <mitch@gimp.org> " ,
" Michael Natterer <mitch@gimp.org> " ,
" 2004 " ,
GIMP_INTERNAL ,
4 ,
plugin_icon_register_inargs ,
0 ,
NULL ,
{ { plugin_icon_register_invoker } }
} ;