mirror of https://github.com/GNOME/gimp.git
pdb: add gimp_pdb_set_proc_image_types()
and all the needed code in libgimp/ and app/ to set a plug-in procedure's image types using the new API. Remove the image types from GPProcInstall.
This commit is contained in:
parent
d75a25c565
commit
2a62287439
|
@ -28,7 +28,7 @@
|
|||
#include "internal-procs.h"
|
||||
|
||||
|
||||
/* 749 procedures registered total */
|
||||
/* 750 procedures registered total */
|
||||
|
||||
void
|
||||
internal_procs_init (GimpPDB *pdb)
|
||||
|
|
|
@ -263,6 +263,39 @@ pdb_get_proc_info_invoker (GimpProcedure *procedure,
|
|||
return return_vals;
|
||||
}
|
||||
|
||||
static GimpValueArray *
|
||||
pdb_set_proc_image_types_invoker (GimpProcedure *procedure,
|
||||
Gimp *gimp,
|
||||
GimpContext *context,
|
||||
GimpProgress *progress,
|
||||
const GimpValueArray *args,
|
||||
GError **error)
|
||||
{
|
||||
gboolean success = TRUE;
|
||||
const gchar *procedure_name;
|
||||
const gchar *image_types;
|
||||
|
||||
procedure_name = g_value_get_string (gimp_value_array_index (args, 0));
|
||||
image_types = g_value_get_string (gimp_value_array_index (args, 1));
|
||||
|
||||
if (success)
|
||||
{
|
||||
GimpPlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
|
||||
|
||||
if (plug_in &&
|
||||
gimp_pdb_is_canonical_procedure (procedure_name, error))
|
||||
{
|
||||
success = gimp_plug_in_set_proc_image_types (plug_in, procedure_name,
|
||||
image_types);
|
||||
}
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
|
||||
return gimp_procedure_get_return_values (procedure, success,
|
||||
error ? *error : NULL);
|
||||
}
|
||||
|
||||
static GimpValueArray *
|
||||
pdb_get_proc_image_types_invoker (GimpProcedure *procedure,
|
||||
Gimp *gimp,
|
||||
|
@ -981,6 +1014,36 @@ register_pdb_procs (GimpPDB *pdb)
|
|||
gimp_pdb_register_procedure (pdb, procedure);
|
||||
g_object_unref (procedure);
|
||||
|
||||
/*
|
||||
* gimp-pdb-set-proc-image-types
|
||||
*/
|
||||
procedure = gimp_procedure_new (pdb_set_proc_image_types_invoker);
|
||||
gimp_object_set_static_name (GIMP_OBJECT (procedure),
|
||||
"gimp-pdb-set-proc-image-types");
|
||||
gimp_procedure_set_static_strings (procedure,
|
||||
"Set the supported image types for a plug-in procedure.",
|
||||
"This procedure sets the supported images types for the given procedure.",
|
||||
"Michael Natterer <mitch@gimp.org>",
|
||||
"Michael Natterer",
|
||||
"2019",
|
||||
NULL);
|
||||
gimp_procedure_add_argument (procedure,
|
||||
gimp_param_spec_string ("procedure-name",
|
||||
"procedure name",
|
||||
"The procedure for which to install the menu path",
|
||||
FALSE, FALSE, TRUE,
|
||||
NULL,
|
||||
GIMP_PARAM_READWRITE));
|
||||
gimp_procedure_add_argument (procedure,
|
||||
gimp_param_spec_string ("image-types",
|
||||
"image types",
|
||||
"The procedure's supported image types",
|
||||
FALSE, TRUE, FALSE,
|
||||
NULL,
|
||||
GIMP_PARAM_READWRITE));
|
||||
gimp_pdb_register_procedure (pdb, procedure);
|
||||
g_object_unref (procedure);
|
||||
|
||||
/*
|
||||
* gimp-pdb-get-proc-image-types
|
||||
*/
|
||||
|
|
|
@ -870,7 +870,6 @@ gimp_plug_in_handle_proc_install (GimpPlugIn *plug_in,
|
|||
if (proc_install->menu_label && strlen (proc_install->menu_label))
|
||||
proc->menu_label = g_strdup (proc_install->menu_label);
|
||||
|
||||
gimp_plug_in_procedure_set_image_types (proc, proc_install->image_types);
|
||||
gimp_plug_in_procedure_set_help_id (proc, proc_install->help_id);
|
||||
|
||||
for (i = 0; i < proc_install->nparams; i++)
|
||||
|
|
|
@ -37,6 +37,58 @@
|
|||
#include "gimp-intl.h"
|
||||
|
||||
|
||||
gboolean
|
||||
gimp_plug_in_set_proc_image_types (GimpPlugIn *plug_in,
|
||||
const gchar *proc_name,
|
||||
const gchar *image_types)
|
||||
{
|
||||
GimpPlugInProcedure *proc = NULL;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_PLUG_IN (plug_in), FALSE);
|
||||
g_return_val_if_fail (proc_name != NULL, FALSE);
|
||||
|
||||
if (plug_in->plug_in_def)
|
||||
proc = gimp_plug_in_procedure_find (plug_in->plug_in_def->procedures,
|
||||
proc_name);
|
||||
|
||||
if (! proc)
|
||||
proc = gimp_plug_in_procedure_find (plug_in->temp_procedures, proc_name);
|
||||
|
||||
if (! proc)
|
||||
{
|
||||
gimp_message (plug_in->manager->gimp, NULL, GIMP_MESSAGE_ERROR,
|
||||
"Plug-in \"%s\"\n(%s)\n"
|
||||
"attempted to register images types "
|
||||
"for the procedure \"%s\".\n"
|
||||
"It has however not installed that procedure. "
|
||||
"This is not allowed.",
|
||||
gimp_object_get_name (plug_in),
|
||||
gimp_file_get_utf8_name (plug_in->file),
|
||||
proc_name);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
switch (GIMP_PROCEDURE (proc)->proc_type)
|
||||
{
|
||||
case GIMP_PDB_PROC_TYPE_INTERNAL:
|
||||
return FALSE;
|
||||
|
||||
case GIMP_PDB_PROC_TYPE_PLUGIN:
|
||||
case GIMP_PDB_PROC_TYPE_EXTENSION:
|
||||
if (plug_in->call_mode != GIMP_PLUG_IN_CALL_QUERY &&
|
||||
plug_in->call_mode != GIMP_PLUG_IN_CALL_INIT)
|
||||
return FALSE;
|
||||
|
||||
case GIMP_PDB_PROC_TYPE_TEMPORARY:
|
||||
break;
|
||||
}
|
||||
|
||||
gimp_plug_in_procedure_set_image_types (proc, image_types);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_plug_in_add_proc_menu_path (GimpPlugIn *plug_in,
|
||||
const gchar *proc_name,
|
||||
|
|
|
@ -21,6 +21,9 @@
|
|||
#define __GIMP_PLUG_IN_PROC_H__
|
||||
|
||||
|
||||
gboolean gimp_plug_in_set_proc_image_types (GimpPlugIn *plug_in,
|
||||
const gchar *proc_name,
|
||||
const gchar *image_types);
|
||||
gboolean gimp_plug_in_add_proc_menu_path (GimpPlugIn *plug_in,
|
||||
const gchar *proc_name,
|
||||
const gchar *menu_path);
|
||||
|
|
|
@ -262,6 +262,45 @@ _gimp_pdb_get_proc_info (const gchar *procedure_name,
|
|||
return success;
|
||||
}
|
||||
|
||||
/**
|
||||
* _gimp_pdb_set_proc_image_types:
|
||||
* @procedure_name: The procedure for which to install the menu path.
|
||||
* @image_types: The procedure's supported image types.
|
||||
*
|
||||
* Set the supported image types for a plug-in procedure.
|
||||
*
|
||||
* This procedure sets the supported images types for the given
|
||||
* procedure.
|
||||
*
|
||||
* Returns: TRUE on success.
|
||||
*
|
||||
* Since: 3.0
|
||||
**/
|
||||
gboolean
|
||||
_gimp_pdb_set_proc_image_types (const gchar *procedure_name,
|
||||
const gchar *image_types)
|
||||
{
|
||||
GimpValueArray *args;
|
||||
GimpValueArray *return_vals;
|
||||
gboolean success = TRUE;
|
||||
|
||||
args = gimp_value_array_new_from_types (NULL,
|
||||
G_TYPE_STRING, procedure_name,
|
||||
G_TYPE_STRING, image_types,
|
||||
G_TYPE_NONE);
|
||||
|
||||
return_vals = gimp_pdb_run_procedure_array (gimp_get_pdb (),
|
||||
"gimp-pdb-set-proc-image-types",
|
||||
args);
|
||||
gimp_value_array_unref (args);
|
||||
|
||||
success = GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS;
|
||||
|
||||
gimp_value_array_unref (return_vals);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
/**
|
||||
* _gimp_pdb_get_proc_image_types:
|
||||
* @procedure_name: The procedure name.
|
||||
|
|
|
@ -48,6 +48,8 @@ G_GNUC_INTERNAL gboolean _gimp_pdb_get_proc_info (const gchar
|
|||
GimpPDBProcType *proc_type,
|
||||
gint *num_args,
|
||||
gint *num_values);
|
||||
G_GNUC_INTERNAL gboolean _gimp_pdb_set_proc_image_types (const gchar *procedure_name,
|
||||
const gchar *image_types);
|
||||
G_GNUC_INTERNAL gchar* _gimp_pdb_get_proc_image_types (const gchar *procedure_name);
|
||||
G_GNUC_INTERNAL gchar* _gimp_pdb_get_proc_menu_label (const gchar *procedure_name);
|
||||
G_GNUC_INTERNAL gboolean _gimp_pdb_add_proc_menu_path (const gchar *procedure_name,
|
||||
|
|
|
@ -372,7 +372,6 @@ gimp_procedure_real_install (GimpProcedure *procedure)
|
|||
proc_install.copyright = (gchar *) gimp_procedure_get_copyright (procedure);
|
||||
proc_install.date = (gchar *) gimp_procedure_get_date (procedure);
|
||||
proc_install.menu_label = (gchar *) gimp_procedure_get_menu_label (procedure);
|
||||
proc_install.image_types = (gchar *) gimp_procedure_get_image_types (procedure);
|
||||
proc_install.type = gimp_procedure_get_proc_type (procedure);
|
||||
proc_install.nparams = n_args;
|
||||
proc_install.nreturn_vals = n_return_vals;
|
||||
|
@ -402,6 +401,9 @@ gimp_procedure_real_install (GimpProcedure *procedure)
|
|||
|
||||
gimp_procedure_install_icon (procedure);
|
||||
|
||||
_gimp_pdb_set_proc_image_types (gimp_procedure_get_name (procedure),
|
||||
procedure->priv->image_types);
|
||||
|
||||
for (list = gimp_procedure_get_menu_paths (procedure);
|
||||
list;
|
||||
list = g_list_next (list))
|
||||
|
@ -590,6 +592,10 @@ gimp_procedure_set_image_types (GimpProcedure *procedure,
|
|||
|
||||
g_free (procedure->priv->image_types);
|
||||
procedure->priv->image_types = g_strdup (image_types);
|
||||
|
||||
if (procedure->priv->installed)
|
||||
_gimp_pdb_set_proc_image_types (gimp_procedure_get_name (procedure),
|
||||
procedure->priv->image_types);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1224,9 +1224,6 @@ _gp_proc_install_read (GIOChannel *channel,
|
|||
if (! _gimp_wire_read_string (channel,
|
||||
&proc_install->menu_label, 1, user_data))
|
||||
goto cleanup;
|
||||
if (! _gimp_wire_read_string (channel,
|
||||
&proc_install->image_types, 1, user_data))
|
||||
goto cleanup;
|
||||
|
||||
if (! _gimp_wire_read_int32 (channel,
|
||||
&proc_install->type, 1, user_data))
|
||||
|
@ -1270,7 +1267,6 @@ _gp_proc_install_read (GIOChannel *channel,
|
|||
g_free (proc_install->copyright);
|
||||
g_free (proc_install->date);
|
||||
g_free (proc_install->menu_label);
|
||||
g_free (proc_install->image_types);
|
||||
|
||||
if (proc_install->params)
|
||||
{
|
||||
|
@ -1472,9 +1468,6 @@ _gp_proc_install_write (GIOChannel *channel,
|
|||
if (! _gimp_wire_write_string (channel,
|
||||
&proc_install->menu_label, 1, user_data))
|
||||
return;
|
||||
if (! _gimp_wire_write_string (channel,
|
||||
&proc_install->image_types, 1, user_data))
|
||||
return;
|
||||
|
||||
if (! _gimp_wire_write_int32 (channel,
|
||||
&proc_install->type, 1, user_data))
|
||||
|
@ -1520,7 +1513,6 @@ _gp_proc_install_destroy (GimpWireMessage *msg)
|
|||
g_free (proc_install->copyright);
|
||||
g_free (proc_install->date);
|
||||
g_free (proc_install->menu_label);
|
||||
g_free (proc_install->image_types);
|
||||
|
||||
for (i = 0; i < proc_install->nparams; i++)
|
||||
{
|
||||
|
|
|
@ -26,7 +26,7 @@ G_BEGIN_DECLS
|
|||
|
||||
/* Increment every time the protocol changes
|
||||
*/
|
||||
#define GIMP_PROTOCOL_VERSION 0x0109
|
||||
#define GIMP_PROTOCOL_VERSION 0x010A
|
||||
|
||||
|
||||
enum
|
||||
|
@ -289,7 +289,6 @@ struct _GPProcInstall
|
|||
gchar *copyright;
|
||||
gchar *date;
|
||||
gchar *menu_label;
|
||||
gchar *image_types;
|
||||
guint32 type;
|
||||
guint32 nparams;
|
||||
guint32 nreturn_vals;
|
||||
|
|
|
@ -246,6 +246,42 @@ CODE
|
|||
);
|
||||
}
|
||||
|
||||
sub pdb_set_proc_image_types {
|
||||
$blurb = "Set the supported image types for a plug-in procedure.";
|
||||
|
||||
$help = <<HELP;
|
||||
This procedure sets the supported images types for the given procedure.
|
||||
HELP
|
||||
|
||||
&mitch_pdb_misc('2019', '3.0');
|
||||
|
||||
$lib_private = 1;
|
||||
|
||||
@inargs = (
|
||||
{ name => 'procedure_name', type => 'string', non_empty => 1,
|
||||
desc => 'The procedure for which to install the menu path' },
|
||||
{ name => 'image_types', type => 'string', null_ok => 1,
|
||||
desc => "The procedure's supported image types" }
|
||||
);
|
||||
|
||||
%invoke = (
|
||||
code => <<'CODE'
|
||||
{
|
||||
GimpPlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
|
||||
|
||||
if (plug_in &&
|
||||
gimp_pdb_is_canonical_procedure (procedure_name, error))
|
||||
{
|
||||
success = gimp_plug_in_set_proc_image_types (plug_in, procedure_name,
|
||||
image_types);
|
||||
}
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
CODE
|
||||
);
|
||||
}
|
||||
|
||||
sub pdb_get_proc_image_types {
|
||||
$blurb = <<'BLURB';
|
||||
Queries the procedural database for the image types supported by the
|
||||
|
@ -851,6 +887,7 @@ CODE
|
|||
pdb_query
|
||||
pdb_proc_exists
|
||||
pdb_get_proc_info
|
||||
pdb_set_proc_image_types
|
||||
pdb_get_proc_image_types
|
||||
pdb_get_proc_menu_label
|
||||
pdb_add_proc_menu_path
|
||||
|
|
Loading…
Reference in New Issue