libgimp: replace gimp_pdb_dump() and gimp_pdb_query() by new API

and move them to gimplegacy.[ch].
This commit is contained in:
Michael Natterer 2019-08-08 01:14:35 +02:00
parent 00bf76752c
commit 0aa2dcfadb
8 changed files with 207 additions and 14 deletions

View File

@ -613,6 +613,7 @@ EXPORTS
gimp_patterns_refresh gimp_patterns_refresh
gimp_patterns_set_popup gimp_patterns_set_popup
gimp_pdb_dump gimp_pdb_dump
gimp_pdb_dump_to_file
gimp_pdb_get_data gimp_pdb_get_data
gimp_pdb_get_data_size gimp_pdb_get_data_size
gimp_pdb_get_type gimp_pdb_get_type
@ -625,6 +626,7 @@ EXPORTS
gimp_pdb_proc_val gimp_pdb_proc_val
gimp_pdb_procedure_exists gimp_pdb_procedure_exists
gimp_pdb_query gimp_pdb_query
gimp_pdb_query_procedures
gimp_pdb_run_procedure gimp_pdb_run_procedure
gimp_pdb_run_procedure_array gimp_pdb_run_procedure_array
gimp_pdb_run_procedure_valist gimp_pdb_run_procedure_valist

View File

@ -1220,6 +1220,76 @@ gimp_pdb_temp_name (void)
return _gimp_pdb_temp_name (); return _gimp_pdb_temp_name ();
} }
/**
* gimp_pdb_dump:
* @filename: The dump filename.
*
* Dumps the current contents of the procedural database
*
* This procedure dumps the contents of the procedural database to the
* specified file. The file will contain all of the information
* provided for each registered procedure.
*
* Returns: TRUE on success.
**/
gboolean
gimp_pdb_dump (const gchar *filename)
{
ASSERT_NO_PLUG_IN_EXISTS (G_STRFUNC);
return _gimp_pdb_dump (filename);
}
/**
* gimp_pdb_query:
* @name: The regex for procedure name.
* @blurb: The regex for procedure blurb.
* @help: The regex for procedure help.
* @author: The regex for procedure author.
* @copyright: The regex for procedure copyright.
* @date: The regex for procedure date.
* @proc_type: The regex for procedure type: { 'Internal GIMP procedure', 'GIMP Plug-in', 'GIMP Extension', 'Temporary Procedure' }.
* @num_matches: (out): The number of matching procedures.
* @procedure_names: (out) (array length=num_matches) (element-type gchar*) (transfer full): The list of procedure names.
*
* Queries the procedural database for its contents using regular
* expression matching.
*
* This procedure queries the contents of the procedural database. It
* is supplied with seven arguments matching procedures on { name,
* blurb, help, author, copyright, date, procedure type}. This is
* accomplished using regular expression matching. For instance, to
* find all procedures with \"jpeg\" listed in the blurb, all seven
* arguments can be supplied as \".*\", except for the second, which
* can be supplied as \".*jpeg.*\". There are two return arguments for
* this procedure. The first is the number of procedures matching the
* query. The second is a concatenated list of procedure names
* corresponding to those matching the query. If no matching entries
* are found, then the returned string is NULL and the number of
* entries is 0.
*
* Returns: TRUE on success.
**/
gboolean
gimp_pdb_query (const gchar *name,
const gchar *blurb,
const gchar *help,
const gchar *author,
const gchar *copyright,
const gchar *date,
const gchar *proc_type,
gint *num_matches,
gchar ***procedure_names)
{
ASSERT_NO_PLUG_IN_EXISTS (G_STRFUNC);
return _gimp_pdb_query (name,
blurb, help,
author, copyright, date,
proc_type,
num_matches, procedure_names);
}
/** /**
* gimp_pdb_proc_exists: * gimp_pdb_proc_exists:
* @procedure_name: The procedure name. * @procedure_name: The procedure name.

View File

@ -313,6 +313,16 @@ gboolean gimp_plugin_icon_register (const gchar *procedure_name,
*/ */
gchar * gimp_pdb_temp_name (void); gchar * gimp_pdb_temp_name (void);
gboolean gimp_pdb_dump (const gchar *filename);
gboolean gimp_pdb_query (const gchar *name,
const gchar *blurb,
const gchar *help,
const gchar *author,
const gchar *copyright,
const gchar *date,
const gchar *proc_type,
gint *num_matches,
gchar ***procedure_names);
gboolean gimp_pdb_proc_exists (const gchar *procedure_name); gboolean gimp_pdb_proc_exists (const gchar *procedure_name);
gboolean gimp_pdb_proc_info (const gchar *procedure_name, gboolean gimp_pdb_proc_info (const gchar *procedure_name,
gchar **blurb, gchar **blurb,

View File

@ -352,6 +352,100 @@ gimp_pdb_temp_procedure_name (GimpPDB *pdb)
return _gimp_pdb_temp_name (); return _gimp_pdb_temp_name ();
} }
/**
* gimp_pdb_dump_to_file:
* @pdb: A #GimpPDB.
* @file: The dump filename.
*
* Dumps the current contents of the procedural database
*
* This procedure dumps the contents of the procedural database to the
* specified @file. The file will contain all of the information
* provided for each registered procedure.
*
* Returns: TRUE on success.
*
* Since: 3.0
**/
gboolean
gimp_pdb_dump_to_file (GimpPDB *pdb,
GFile *file)
{
gchar *path;
gboolean success;
g_return_val_if_fail (GIMP_IS_PDB (pdb), FALSE);
g_return_val_if_fail (G_IS_FILE (pdb), FALSE);
path = g_file_get_path (file);
success = _gimp_pdb_dump (path);
g_free (path);
return success;
}
/**
* gimp_pdb_query_procedures:
* @pdb: A #GimpPDB.
* @name: The regex for procedure name.
* @blurb: The regex for procedure blurb.
* @help: The regex for procedure help.
* @help_id: The regex for procedure help-id.
* @authors: The regex for procedure authors.
* @copyright: The regex for procedure copyright.
* @date: The regex for procedure date.
* @proc_type: The regex for procedure type: { 'Internal GIMP procedure', 'GIMP Plug-in', 'GIMP Extension', 'Temporary Procedure' }.
* @num_matches: (out): The number of matching procedures.
*
* Queries the procedural database for its contents using regular
* expression matching.
*
* This function queries the contents of the procedural database. It
* is supplied with eight arguments matching procedures on
*
* { name, blurb, help, help-id, authors, copyright, date, procedure type}.
*
* This is accomplished using regular expression matching. For
* instance, to find all procedures with "jpeg" listed in the blurb,
* all seven arguments can be supplied as ".*", except for the second,
* which can be supplied as ".*jpeg.*". There are two return arguments
* for this procedure. The first is the number of procedures matching
* the query. The second is a concatenated list of procedure names
* corresponding to those matching the query. If no matching entries
* are found, then the returned string is NULL and the number of
* entries is 0.
*
* Returns: (out) (array length=num_matches) (transfer full): The list
* of procedure names. Free with g_strfreev().
*
* Since: 3.0
**/
gchar **
gimp_pdb_query_procedures (GimpPDB *pdb,
const gchar *name,
const gchar *blurb,
const gchar *help,
const gchar *help_id,
const gchar *authors,
const gchar *copyright,
const gchar *date,
const gchar *proc_type,
gint *num_matches)
{
gchar **matches;
g_return_val_if_fail (GIMP_IS_PDB (pdb), NULL);
_gimp_pdb_query (name,
blurb, help, /* FIXME help_id */
authors, copyright, date,
proc_type,
num_matches,
&matches);
return matches;
}
GQuark GQuark
_gimp_pdb_error_quark (void) _gimp_pdb_error_quark (void)
{ {

View File

@ -87,6 +87,19 @@ GimpValueArray * gimp_pdb_run_procedure_array (GimpPDB *pdb,
gchar * gimp_pdb_temp_procedure_name (GimpPDB *pdb); gchar * gimp_pdb_temp_procedure_name (GimpPDB *pdb);
gboolean gimp_pdb_dump_to_file (GimpPDB *pdb,
GFile *file);
gchar ** gimp_pdb_query_procedures (GimpPDB *pdb,
const gchar *name,
const gchar *blurb,
const gchar *help,
const gchar *help_id,
const gchar *authors,
const gchar *copyright,
const gchar *date,
const gchar *proc_type,
gint *num_matches);
/* Cruft API */ /* Cruft API */

View File

@ -63,7 +63,7 @@ _gimp_pdb_temp_name (void)
} }
/** /**
* gimp_pdb_dump: * _gimp_pdb_dump:
* @filename: The dump filename. * @filename: The dump filename.
* *
* Dumps the current contents of the procedural database * Dumps the current contents of the procedural database
@ -75,7 +75,7 @@ _gimp_pdb_temp_name (void)
* Returns: TRUE on success. * Returns: TRUE on success.
**/ **/
gboolean gboolean
gimp_pdb_dump (const gchar *filename) _gimp_pdb_dump (const gchar *filename)
{ {
GimpPDB *pdb = gimp_get_pdb (); GimpPDB *pdb = gimp_get_pdb ();
GimpValueArray *args; GimpValueArray *args;
@ -103,7 +103,7 @@ gimp_pdb_dump (const gchar *filename)
} }
/** /**
* gimp_pdb_query: * _gimp_pdb_query:
* @name: The regex for procedure name. * @name: The regex for procedure name.
* @blurb: The regex for procedure blurb. * @blurb: The regex for procedure blurb.
* @help: The regex for procedure help. * @help: The regex for procedure help.
@ -133,7 +133,7 @@ gimp_pdb_dump (const gchar *filename)
* Returns: TRUE on success. * Returns: TRUE on success.
**/ **/
gboolean gboolean
gimp_pdb_query (const gchar *name, _gimp_pdb_query (const gchar *name,
const gchar *blurb, const gchar *blurb,
const gchar *help, const gchar *help,
const gchar *author, const gchar *author,

View File

@ -33,8 +33,8 @@ G_BEGIN_DECLS
G_GNUC_INTERNAL gchar* _gimp_pdb_temp_name (void); G_GNUC_INTERNAL gchar* _gimp_pdb_temp_name (void);
gboolean gimp_pdb_dump (const gchar *filename); G_GNUC_INTERNAL gboolean _gimp_pdb_dump (const gchar *filename);
gboolean gimp_pdb_query (const gchar *name, G_GNUC_INTERNAL gboolean _gimp_pdb_query (const gchar *name,
const gchar *blurb, const gchar *blurb,
const gchar *help, const gchar *help,
const gchar *author, const gchar *author,

View File

@ -57,6 +57,8 @@ HELP
$author = 'Spencer Kimball & Josh MacDonald'; $author = 'Spencer Kimball & Josh MacDonald';
$copyright = $author . ' & Peter Mattis'; $copyright = $author . ' & Peter Mattis';
$lib_private = 1;
@inargs = ( @inargs = (
{ name => 'filename', type => 'string', allow_non_utf8 => 1, { name => 'filename', type => 'string', allow_non_utf8 => 1,
non_empty => 1, non_empty => 1,
@ -97,6 +99,8 @@ HELP
&std_pdb_misc; &std_pdb_misc;
$lib_private = 1;
@inargs = ( @inargs = (
{ name => 'name', type => 'string', allow_non_utf8 => 1, { name => 'name', type => 'string', allow_non_utf8 => 1,
desc => 'The regex for procedure name' }, desc => 'The regex for procedure name' },