mirror of https://github.com/GNOME/gimp.git
added new procedure gimp-procedural-db-proc-exists.
2008-04-06 Sven Neumann <sven@gimp.org> * tools/pdbgen/pdb/procedural_db.pdb: added new procedure gimp-procedural-db-proc-exists. * app/pdb/internal-procs.c * app/pdb/procedural-db-cmds.c * libgimp/gimpproceduraldb_pdb.[ch]: regenerated. * libgimp/gimp.def: updated. * plug-ins/print/print.c (page_setup): use the new procedure. svn path=/trunk/; revision=25384
This commit is contained in:
parent
8341dd2fcd
commit
f84b68a4af
13
ChangeLog
13
ChangeLog
|
@ -1,3 +1,16 @@
|
|||
2008-04-06 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* tools/pdbgen/pdb/procedural_db.pdb: added new procedure
|
||||
gimp-procedural-db-proc-exists.
|
||||
|
||||
* app/pdb/internal-procs.c
|
||||
* app/pdb/procedural-db-cmds.c
|
||||
* libgimp/gimpproceduraldb_pdb.[ch]: regenerated.
|
||||
|
||||
* libgimp/gimp.def: updated.
|
||||
|
||||
* plug-ins/print/print.c (page_setup): use the new procedure.
|
||||
|
||||
2008-04-06 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* plug-ins/print/print.c (page_setup): do a query for the
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
#include "internal-procs.h"
|
||||
|
||||
|
||||
/* 583 procedures registered total */
|
||||
/* 584 procedures registered total */
|
||||
|
||||
void
|
||||
internal_procs_init (GimpPDB *pdb)
|
||||
|
|
|
@ -128,6 +128,34 @@ procedural_db_query_invoker (GimpProcedure *procedure,
|
|||
return return_vals;
|
||||
}
|
||||
|
||||
static GValueArray *
|
||||
procedural_db_proc_exists_invoker (GimpProcedure *procedure,
|
||||
Gimp *gimp,
|
||||
GimpContext *context,
|
||||
GimpProgress *progress,
|
||||
const GValueArray *args,
|
||||
GError **error)
|
||||
{
|
||||
gboolean success = TRUE;
|
||||
GValueArray *return_vals;
|
||||
const gchar *procedure_name;
|
||||
gboolean exists = FALSE;
|
||||
|
||||
procedure_name = g_value_get_string (&args->values[0]);
|
||||
|
||||
if (success)
|
||||
{
|
||||
exists = (gimp_pdb_lookup_procedure (gimp->pdb, procedure_name) != NULL);
|
||||
}
|
||||
|
||||
return_vals = gimp_procedure_get_return_values (procedure, success);
|
||||
|
||||
if (success)
|
||||
g_value_set_boolean (&return_vals->values[1], exists);
|
||||
|
||||
return return_vals;
|
||||
}
|
||||
|
||||
static GValueArray *
|
||||
procedural_db_proc_info_invoker (GimpProcedure *procedure,
|
||||
Gimp *gimp,
|
||||
|
@ -549,6 +577,36 @@ register_procedural_db_procs (GimpPDB *pdb)
|
|||
gimp_pdb_register_procedure (pdb, procedure);
|
||||
g_object_unref (procedure);
|
||||
|
||||
/*
|
||||
* gimp-procedural-db-proc-exists
|
||||
*/
|
||||
procedure = gimp_procedure_new (procedural_db_proc_exists_invoker);
|
||||
gimp_object_set_static_name (GIMP_OBJECT (procedure),
|
||||
"gimp-procedural-db-proc-exists");
|
||||
gimp_procedure_set_static_strings (procedure,
|
||||
"gimp-procedural-db-proc-exists",
|
||||
"Checks if the specified procedure exists in the procedural database",
|
||||
"This procedure checks if the specified procedure is registered in the procedural database.",
|
||||
"Sven Neumann <sven@gimp.org>",
|
||||
"Sven Neumann",
|
||||
"2008",
|
||||
NULL);
|
||||
gimp_procedure_add_argument (procedure,
|
||||
gimp_param_spec_string ("procedure-name",
|
||||
"procedure name",
|
||||
"The procedure name",
|
||||
FALSE, FALSE, TRUE,
|
||||
NULL,
|
||||
GIMP_PARAM_READWRITE));
|
||||
gimp_procedure_add_return_value (procedure,
|
||||
g_param_spec_boolean ("exists",
|
||||
"exists",
|
||||
"Whether a procedure of that name is registered",
|
||||
FALSE,
|
||||
GIMP_PARAM_READWRITE));
|
||||
gimp_pdb_register_procedure (pdb, procedure);
|
||||
g_object_unref (procedure);
|
||||
|
||||
/*
|
||||
* gimp-procedural-db-proc-info
|
||||
*/
|
||||
|
|
|
@ -540,6 +540,7 @@ EXPORTS
|
|||
gimp_procedural_db_get_data
|
||||
gimp_procedural_db_get_data_size
|
||||
gimp_procedural_db_proc_arg
|
||||
gimp_procedural_db_proc_exists
|
||||
gimp_procedural_db_proc_info
|
||||
gimp_procedural_db_proc_val
|
||||
gimp_procedural_db_query
|
||||
|
|
|
@ -162,6 +162,39 @@ gimp_procedural_db_query (const gchar *name,
|
|||
return success;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_procedural_db_proc_exists:
|
||||
* @procedure_name: The procedure name.
|
||||
*
|
||||
* Checks if the specified procedure exists in the procedural database
|
||||
*
|
||||
* This procedure checks if the specified procedure is registered in
|
||||
* the procedural database.
|
||||
*
|
||||
* Returns: Whether a procedure of that name is registered.
|
||||
*
|
||||
* Since: GIMP 2.6
|
||||
*/
|
||||
gboolean
|
||||
gimp_procedural_db_proc_exists (const gchar *procedure_name)
|
||||
{
|
||||
GimpParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
gboolean exists = FALSE;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp-procedural-db-proc-exists",
|
||||
&nreturn_vals,
|
||||
GIMP_PDB_STRING, procedure_name,
|
||||
GIMP_PDB_END);
|
||||
|
||||
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
|
||||
exists = return_vals[1].data.d_int32;
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return exists;
|
||||
}
|
||||
|
||||
/**
|
||||
* _gimp_procedural_db_proc_info:
|
||||
* @procedure_name: The procedure name.
|
||||
|
|
|
@ -40,6 +40,7 @@ gboolean gimp_procedural_db_query (const gchar *na
|
|||
const gchar *proc_type,
|
||||
gint *num_matches,
|
||||
gchar ***procedure_names);
|
||||
gboolean gimp_procedural_db_proc_exists (const gchar *procedure_name);
|
||||
G_GNUC_INTERNAL gboolean _gimp_procedural_db_proc_info (const gchar *procedure_name,
|
||||
gchar **blurb,
|
||||
gchar **help,
|
||||
|
|
|
@ -294,8 +294,6 @@ page_setup (gint32 image_ID)
|
|||
{
|
||||
GtkPrintOperation *operation;
|
||||
gchar *name;
|
||||
gchar **matches;
|
||||
gint num_matches;
|
||||
|
||||
gimp_ui_init (PLUG_IN_BINARY, FALSE);
|
||||
|
||||
|
@ -310,19 +308,13 @@ page_setup (gint32 image_ID)
|
|||
/* now notify a running print procedure about this change */
|
||||
name = print_temp_proc_name (image_ID);
|
||||
|
||||
/* FIXME: There should be a better way to query for a procedure.
|
||||
* Also this code has a race condition. The best solution
|
||||
/* FIXME: This code has a race condition. The best solution
|
||||
* would be to catch the error somehow (see bug #344818).
|
||||
*/
|
||||
gimp_procedural_db_query (name,
|
||||
".*", ".*", ".*", ".*", ".*", ".*",
|
||||
&num_matches, &matches);
|
||||
|
||||
if (num_matches)
|
||||
if (gimp_procedural_db_proc_exists (name))
|
||||
{
|
||||
GimpParam *return_vals;
|
||||
gint n_return_vals;
|
||||
gint i;
|
||||
|
||||
return_vals = gimp_run_procedure (name,
|
||||
&n_return_vals,
|
||||
|
@ -330,11 +322,6 @@ page_setup (gint32 image_ID)
|
|||
GIMP_PDB_END);
|
||||
|
||||
gimp_destroy_params (return_vals, n_return_vals);
|
||||
|
||||
for (i = 0; i < num_matches; i++)
|
||||
g_free (matches[i]);
|
||||
|
||||
g_free (matches);
|
||||
}
|
||||
|
||||
g_free (name);
|
||||
|
|
Loading…
Reference in New Issue