diff --git a/libgimp/gimp.def b/libgimp/gimp.def index faef83b1aa..f2e98e626f 100644 --- a/libgimp/gimp.def +++ b/libgimp/gimp.def @@ -613,6 +613,7 @@ EXPORTS gimp_patterns_refresh gimp_patterns_set_popup gimp_pdb_dump + gimp_pdb_dump_to_file gimp_pdb_get_data gimp_pdb_get_data_size gimp_pdb_get_type @@ -625,6 +626,7 @@ EXPORTS gimp_pdb_proc_val gimp_pdb_procedure_exists gimp_pdb_query + gimp_pdb_query_procedures gimp_pdb_run_procedure gimp_pdb_run_procedure_array gimp_pdb_run_procedure_valist diff --git a/libgimp/gimplegacy.c b/libgimp/gimplegacy.c index c284a331f9..744339836a 100644 --- a/libgimp/gimplegacy.c +++ b/libgimp/gimplegacy.c @@ -1220,6 +1220,76 @@ gimp_pdb_temp_name (void) 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: * @procedure_name: The procedure name. diff --git a/libgimp/gimplegacy.h b/libgimp/gimplegacy.h index 90c7f2cc3b..3c27fddb67 100644 --- a/libgimp/gimplegacy.h +++ b/libgimp/gimplegacy.h @@ -313,6 +313,16 @@ gboolean gimp_plugin_icon_register (const gchar *procedure_name, */ 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_info (const gchar *procedure_name, gchar **blurb, diff --git a/libgimp/gimppdb.c b/libgimp/gimppdb.c index 301ebbccf6..47347d6c2f 100644 --- a/libgimp/gimppdb.c +++ b/libgimp/gimppdb.c @@ -352,6 +352,100 @@ gimp_pdb_temp_procedure_name (GimpPDB *pdb) 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 _gimp_pdb_error_quark (void) { diff --git a/libgimp/gimppdb.h b/libgimp/gimppdb.h index 1c1159e5a7..4a8271c834 100644 --- a/libgimp/gimppdb.h +++ b/libgimp/gimppdb.h @@ -87,6 +87,19 @@ GimpValueArray * gimp_pdb_run_procedure_array (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 */ diff --git a/libgimp/gimppdb_pdb.c b/libgimp/gimppdb_pdb.c index ea62ff87af..4dc28f618f 100644 --- a/libgimp/gimppdb_pdb.c +++ b/libgimp/gimppdb_pdb.c @@ -63,7 +63,7 @@ _gimp_pdb_temp_name (void) } /** - * gimp_pdb_dump: + * _gimp_pdb_dump: * @filename: The dump filename. * * Dumps the current contents of the procedural database @@ -75,7 +75,7 @@ _gimp_pdb_temp_name (void) * Returns: TRUE on success. **/ gboolean -gimp_pdb_dump (const gchar *filename) +_gimp_pdb_dump (const gchar *filename) { GimpPDB *pdb = gimp_get_pdb (); GimpValueArray *args; @@ -103,7 +103,7 @@ gimp_pdb_dump (const gchar *filename) } /** - * gimp_pdb_query: + * _gimp_pdb_query: * @name: The regex for procedure name. * @blurb: The regex for procedure blurb. * @help: The regex for procedure help. @@ -133,15 +133,15 @@ gimp_pdb_dump (const gchar *filename) * 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) +_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) { GimpPDB *pdb = gimp_get_pdb (); GimpValueArray *args; diff --git a/libgimp/gimppdb_pdb.h b/libgimp/gimppdb_pdb.h index c0f2321145..5767376501 100644 --- a/libgimp/gimppdb_pdb.h +++ b/libgimp/gimppdb_pdb.h @@ -33,8 +33,8 @@ G_BEGIN_DECLS G_GNUC_INTERNAL gchar* _gimp_pdb_temp_name (void); -gboolean gimp_pdb_dump (const gchar *filename); -gboolean gimp_pdb_query (const gchar *name, +G_GNUC_INTERNAL gboolean _gimp_pdb_dump (const gchar *filename); +G_GNUC_INTERNAL gboolean _gimp_pdb_query (const gchar *name, const gchar *blurb, const gchar *help, const gchar *author, diff --git a/pdb/groups/pdb.pdb b/pdb/groups/pdb.pdb index fbfcd9df40..45cb34f370 100644 --- a/pdb/groups/pdb.pdb +++ b/pdb/groups/pdb.pdb @@ -57,6 +57,8 @@ HELP $author = 'Spencer Kimball & Josh MacDonald'; $copyright = $author . ' & Peter Mattis'; + $lib_private = 1; + @inargs = ( { name => 'filename', type => 'string', allow_non_utf8 => 1, non_empty => 1, @@ -97,6 +99,8 @@ HELP &std_pdb_misc; + $lib_private = 1; + @inargs = ( { name => 'name', type => 'string', allow_non_utf8 => 1, desc => 'The regex for procedure name' },