mirror of https://github.com/GNOME/gimp.git
Some PDB cleanup:
2002-09-10 Michael Natterer <mitch@gimp.org> Some PDB cleanup: * tools/pdbgen/pdb/procedural_db.pdb: removed the get_data() and set_data() implementations and the global "data_list" variable. Cleaned up the dump() stuff (pass the FILE pointer around instead of having a global variable for it). Fixed output_string() so it does not crash on NULL strings. * app/core/gimp.[ch]: added gimp->procedural_db_data_list. * app/pdb/procedural_db.[ch]: added procedural_db_[set|get]_data(). Don't leak data identifiers when overwriting an already existing entry. Added g_return_if_fail() stuff to all public functions. * tools/pdbgen/pdb/channel.pdb * tools/pdbgen/pdb/drawable.pdb * tools/pdbgen/pdb/layer.pdb * tools/pdbgen/pdb/parasite.pdb: tweaked some helper functions to take parameters which make them aware of the real type of the objects they handle (e.g. the PDB function gimp_layer_set_name() matches the core function gimp_object_get_name()). * app/pdb/pdb_glue.h: removed ugly CPP-level workarounds for the issue mentioned above. * app/pdb/channel_cmds.c * app/pdb/drawable_cmds.c * app/pdb/layer_cmds.c * app/pdb/parasite_cmds.c * app/pdb/procedural_db_cmds.c: regenerated.
This commit is contained in:
parent
734a786101
commit
451d392aac
33
ChangeLog
33
ChangeLog
|
@ -1,3 +1,36 @@
|
|||
2002-09-10 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
Some PDB cleanup:
|
||||
|
||||
* tools/pdbgen/pdb/procedural_db.pdb: removed the get_data() and
|
||||
set_data() implementations and the global "data_list" variable.
|
||||
Cleaned up the dump() stuff (pass the FILE pointer around instead
|
||||
of having a global variable for it). Fixed output_string() so it
|
||||
does not crash on NULL strings.
|
||||
|
||||
* app/core/gimp.[ch]: added gimp->procedural_db_data_list.
|
||||
|
||||
* app/pdb/procedural_db.[ch]: added procedural_db_[set|get]_data().
|
||||
Don't leak data identifiers when overwriting an already existing
|
||||
entry. Added g_return_if_fail() stuff to all public functions.
|
||||
|
||||
* tools/pdbgen/pdb/channel.pdb
|
||||
* tools/pdbgen/pdb/drawable.pdb
|
||||
* tools/pdbgen/pdb/layer.pdb
|
||||
* tools/pdbgen/pdb/parasite.pdb: tweaked some helper functions to
|
||||
take parameters which make them aware of the real type of the
|
||||
objects they handle (e.g. the PDB function gimp_layer_set_name()
|
||||
matches the core function gimp_object_get_name()).
|
||||
|
||||
* app/pdb/pdb_glue.h: removed ugly CPP-level workarounds for the
|
||||
issue mentioned above.
|
||||
|
||||
* app/pdb/channel_cmds.c
|
||||
* app/pdb/drawable_cmds.c
|
||||
* app/pdb/layer_cmds.c
|
||||
* app/pdb/parasite_cmds.c
|
||||
* app/pdb/procedural_db_cmds.c: regenerated.
|
||||
|
||||
2002-09-10 Dave Neary <bolsh@gimp.org>
|
||||
|
||||
* plug-ins/common/png.c: Handle INDEXA images if the
|
||||
|
|
|
@ -377,6 +377,9 @@ gimp_get_memsize (GimpObject *object)
|
|||
memsize += (g_hash_table_size (gimp->procedural_ht) *
|
||||
3 * sizeof (gpointer)); /* FIXME */
|
||||
|
||||
memsize += (g_list_length (gimp->procedural_db_data_list) *
|
||||
sizeof (GList)); /* FIXME */
|
||||
|
||||
memsize += g_slist_length (gimp->load_procs) * sizeof (GSList); /* FIXME */
|
||||
memsize += g_slist_length (gimp->save_procs) * sizeof (GSList); /* FIXME */
|
||||
|
||||
|
|
|
@ -96,6 +96,7 @@ struct _Gimp
|
|||
GimpDataFactory *palette_factory;
|
||||
|
||||
GHashTable *procedural_ht;
|
||||
GList *procedural_db_data_list;
|
||||
|
||||
GSList *load_procs;
|
||||
GSList *save_procs;
|
||||
|
|
|
@ -31,7 +31,6 @@
|
|||
#include "core/core-enums.h"
|
||||
#include "core/gimpchannel.h"
|
||||
#include "core/gimpimage.h"
|
||||
#include "pdb_glue.h"
|
||||
|
||||
#include "libgimpcolor/gimpcolor.h"
|
||||
|
||||
|
@ -387,7 +386,7 @@ channel_get_name_invoker (Gimp *gimp,
|
|||
return_args = procedural_db_return_args (&channel_get_name_proc, success);
|
||||
|
||||
if (success)
|
||||
return_args[1].value.pdb_pointer = g_strdup (gimp_channel_get_name (channel));
|
||||
return_args[1].value.pdb_pointer = g_strdup (gimp_object_get_name (GIMP_OBJECT (channel)));
|
||||
|
||||
return return_args;
|
||||
}
|
||||
|
@ -443,7 +442,7 @@ channel_set_name_invoker (Gimp *gimp,
|
|||
success = FALSE;
|
||||
|
||||
if (success)
|
||||
gimp_channel_set_name (channel, name);
|
||||
gimp_object_set_name (GIMP_OBJECT (channel), name);
|
||||
|
||||
return procedural_db_return_args (&channel_set_name_proc, success);
|
||||
}
|
||||
|
@ -493,7 +492,7 @@ channel_get_visible_invoker (Gimp *gimp,
|
|||
return_args = procedural_db_return_args (&channel_get_visible_proc, success);
|
||||
|
||||
if (success)
|
||||
return_args[1].value.pdb_int = gimp_channel_get_visible (channel);
|
||||
return_args[1].value.pdb_int = gimp_drawable_get_visible (GIMP_DRAWABLE (channel));
|
||||
|
||||
return return_args;
|
||||
}
|
||||
|
@ -547,7 +546,7 @@ channel_set_visible_invoker (Gimp *gimp,
|
|||
visible = args[1].value.pdb_int ? TRUE : FALSE;
|
||||
|
||||
if (success)
|
||||
gimp_channel_set_visible (channel, visible);
|
||||
gimp_drawable_set_visible (GIMP_DRAWABLE (channel), visible);
|
||||
|
||||
return procedural_db_return_args (&channel_set_visible_proc, success);
|
||||
}
|
||||
|
@ -922,7 +921,7 @@ channel_get_tattoo_invoker (Gimp *gimp,
|
|||
return_args = procedural_db_return_args (&channel_get_tattoo_proc, success);
|
||||
|
||||
if (success)
|
||||
return_args[1].value.pdb_int = gimp_channel_get_tattoo (channel);
|
||||
return_args[1].value.pdb_int = gimp_item_get_tattoo (GIMP_ITEM (channel));
|
||||
|
||||
return return_args;
|
||||
}
|
||||
|
@ -978,7 +977,7 @@ channel_set_tattoo_invoker (Gimp *gimp,
|
|||
success = FALSE;
|
||||
|
||||
if (success)
|
||||
gimp_channel_set_tattoo (channel, tattoo);
|
||||
gimp_item_set_tattoo (GIMP_ITEM (channel), tattoo);
|
||||
|
||||
return procedural_db_return_args (&channel_set_tattoo_proc, success);
|
||||
}
|
||||
|
|
|
@ -40,7 +40,6 @@
|
|||
#include "core/gimpimage.h"
|
||||
#include "core/gimplayer.h"
|
||||
#include "core/gimplayermask.h"
|
||||
#include "pdb_glue.h"
|
||||
|
||||
static ProcRecord drawable_merge_shadow_proc;
|
||||
static ProcRecord drawable_fill_proc;
|
||||
|
@ -984,7 +983,7 @@ drawable_is_layer_invoker (Gimp *gimp,
|
|||
return_args = procedural_db_return_args (&drawable_is_layer_proc, success);
|
||||
|
||||
if (success)
|
||||
return_args[1].value.pdb_int = gimp_drawable_layer (drawable) ? TRUE : FALSE;
|
||||
return_args[1].value.pdb_int = GIMP_IS_LAYER (drawable) ? TRUE : FALSE;
|
||||
|
||||
return return_args;
|
||||
}
|
||||
|
@ -1038,7 +1037,7 @@ drawable_is_layer_mask_invoker (Gimp *gimp,
|
|||
return_args = procedural_db_return_args (&drawable_is_layer_mask_proc, success);
|
||||
|
||||
if (success)
|
||||
return_args[1].value.pdb_int = gimp_drawable_layer_mask (drawable) ? TRUE : FALSE;
|
||||
return_args[1].value.pdb_int = GIMP_IS_LAYER_MASK (drawable) ? TRUE : FALSE;
|
||||
|
||||
return return_args;
|
||||
}
|
||||
|
@ -1092,7 +1091,7 @@ drawable_is_channel_invoker (Gimp *gimp,
|
|||
return_args = procedural_db_return_args (&drawable_is_channel_proc, success);
|
||||
|
||||
if (success)
|
||||
return_args[1].value.pdb_int = gimp_drawable_channel (drawable) ? TRUE : FALSE;
|
||||
return_args[1].value.pdb_int = GIMP_IS_CHANNEL (drawable) ? TRUE : FALSE;
|
||||
|
||||
return return_args;
|
||||
}
|
||||
|
|
|
@ -37,13 +37,23 @@
|
|||
#include "libgimp/gimpintl.h"
|
||||
|
||||
|
||||
typedef struct _PDBData PDBData;
|
||||
|
||||
struct _PDBData
|
||||
{
|
||||
gchar *identifier;
|
||||
gint32 bytes;
|
||||
guint8 *data;
|
||||
};
|
||||
|
||||
|
||||
void
|
||||
procedural_db_init (Gimp *gimp)
|
||||
{
|
||||
g_return_if_fail (gimp != NULL);
|
||||
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
||||
|
||||
gimp->procedural_ht = g_hash_table_new (g_str_hash, g_str_equal);
|
||||
gimp->procedural_ht = g_hash_table_new (g_str_hash, g_str_equal);
|
||||
gimp->procedural_db_data_list = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -58,6 +68,8 @@ procedural_db_free_entry (gpointer key,
|
|||
void
|
||||
procedural_db_free (Gimp *gimp)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
||||
|
||||
if (gimp->procedural_ht)
|
||||
{
|
||||
g_hash_table_foreach (gimp->procedural_ht,
|
||||
|
@ -66,6 +78,24 @@ procedural_db_free (Gimp *gimp)
|
|||
|
||||
gimp->procedural_ht = NULL;
|
||||
}
|
||||
|
||||
if (gimp->procedural_db_data_list)
|
||||
{
|
||||
PDBData *data;
|
||||
GList *list;
|
||||
|
||||
for (list = gimp->procedural_db_data_list; list; list = g_list_next (list))
|
||||
{
|
||||
data = (PDBData *) list->data;
|
||||
|
||||
g_free (data->identifier);
|
||||
g_free (data->data);
|
||||
g_free (data);
|
||||
}
|
||||
|
||||
g_list_free (gimp->procedural_db_data_list);
|
||||
gimp->procedural_db_data_list = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -74,6 +104,9 @@ procedural_db_register (Gimp *gimp,
|
|||
{
|
||||
GList *list;
|
||||
|
||||
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
||||
g_return_if_fail (procedure != NULL);
|
||||
|
||||
list = g_hash_table_lookup (gimp->procedural_ht, (gpointer) procedure->name);
|
||||
list = g_list_prepend (list, (gpointer) procedure);
|
||||
|
||||
|
@ -88,6 +121,9 @@ procedural_db_unregister (Gimp *gimp,
|
|||
{
|
||||
GList *list;
|
||||
|
||||
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
||||
g_return_if_fail (name != NULL);
|
||||
|
||||
list = g_hash_table_lookup (gimp->procedural_ht, (gpointer) name);
|
||||
|
||||
if (list)
|
||||
|
@ -110,6 +146,9 @@ procedural_db_lookup (Gimp *gimp,
|
|||
{
|
||||
GList *list;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
|
||||
g_return_val_if_fail (name != NULL, NULL);
|
||||
|
||||
list = g_hash_table_lookup (gimp->procedural_ht, (gpointer) name);
|
||||
|
||||
if (list)
|
||||
|
@ -128,6 +167,9 @@ procedural_db_execute (Gimp *gimp,
|
|||
GList *list;
|
||||
gint i;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
|
||||
g_return_val_if_fail (name != NULL, NULL);
|
||||
|
||||
return_args = NULL;
|
||||
|
||||
list = g_hash_table_lookup (gimp->procedural_ht, (gpointer) name);
|
||||
|
@ -225,6 +267,9 @@ procedural_db_run_proc (Gimp *gimp,
|
|||
va_list args;
|
||||
gint i;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
|
||||
g_return_val_if_fail (name != NULL, NULL);
|
||||
|
||||
if ((proc = procedural_db_lookup (gimp, name)) == NULL)
|
||||
{
|
||||
return_vals = g_new (Argument, 1);
|
||||
|
@ -323,6 +368,8 @@ procedural_db_return_args (ProcRecord *procedure,
|
|||
Argument *return_args;
|
||||
gint i;
|
||||
|
||||
g_return_val_if_fail (procedure != NULL, NULL);
|
||||
|
||||
return_args = g_new (Argument, procedure->num_values + 1);
|
||||
|
||||
if (success)
|
||||
|
@ -410,3 +457,71 @@ procedural_db_destroy_args (Argument *args,
|
|||
|
||||
g_free (args);
|
||||
}
|
||||
|
||||
void
|
||||
procedural_db_set_data (Gimp *gimp,
|
||||
const gchar *identifier,
|
||||
gint32 bytes,
|
||||
const guint8 *data)
|
||||
{
|
||||
GList *list;
|
||||
PDBData *pdb_data;
|
||||
|
||||
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
||||
g_return_if_fail (identifier != NULL);
|
||||
g_return_if_fail (bytes > 0);
|
||||
g_return_if_fail (data != NULL);
|
||||
|
||||
for (list = gimp->procedural_db_data_list; list; list = g_list_next (list))
|
||||
{
|
||||
pdb_data = (PDBData *) list->data;
|
||||
|
||||
if (! strcmp (pdb_data->identifier, identifier))
|
||||
break;
|
||||
}
|
||||
|
||||
/* If there isn't already data with the specified identifier, create one */
|
||||
if (list == NULL)
|
||||
{
|
||||
pdb_data = g_new0 (PDBData, 1);
|
||||
pdb_data->identifier = g_strdup (identifier);
|
||||
|
||||
gimp->procedural_db_data_list =
|
||||
g_list_prepend (gimp->procedural_db_data_list, pdb_data);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_free (pdb_data->data);
|
||||
}
|
||||
|
||||
pdb_data->bytes = bytes;
|
||||
pdb_data->data = g_memdup (data, bytes);
|
||||
}
|
||||
|
||||
const guint8 *
|
||||
procedural_db_get_data (Gimp *gimp,
|
||||
const gchar *identifier,
|
||||
gint32 *bytes)
|
||||
{
|
||||
GList *list;
|
||||
PDBData *pdb_data;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
|
||||
g_return_val_if_fail (identifier != NULL, NULL);
|
||||
g_return_val_if_fail (bytes != NULL, NULL);
|
||||
|
||||
*bytes = 0;
|
||||
|
||||
for (list = gimp->procedural_db_data_list; list; list = g_list_next (list))
|
||||
{
|
||||
pdb_data = (PDBData *) list->data;
|
||||
|
||||
if (! strcmp (pdb_data->identifier, identifier))
|
||||
{
|
||||
*bytes = pdb_data->bytes;
|
||||
return pdb_data->data;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -119,29 +119,43 @@ struct _ProcRecord
|
|||
|
||||
|
||||
/* Functions */
|
||||
void procedural_db_init (Gimp *gimp);
|
||||
void procedural_db_free (Gimp *gimp);
|
||||
void procedural_db_register (Gimp *gimp,
|
||||
ProcRecord *procedure);
|
||||
void procedural_db_unregister (Gimp *gimp,
|
||||
const gchar *name);
|
||||
ProcRecord * procedural_db_lookup (Gimp *gimp,
|
||||
const gchar *name);
|
||||
Argument * procedural_db_execute (Gimp *gimp,
|
||||
const gchar *name,
|
||||
Argument *args);
|
||||
Argument * procedural_db_run_proc (Gimp *gimp,
|
||||
const gchar *name,
|
||||
gint *nreturn_vals,
|
||||
...);
|
||||
Argument * procedural_db_return_args (ProcRecord *procedure,
|
||||
gboolean success);
|
||||
void procedural_db_destroy_args (Argument *args,
|
||||
gint nargs);
|
||||
|
||||
void procedural_db_init (Gimp *gimp);
|
||||
void procedural_db_free (Gimp *gimp);
|
||||
|
||||
void procedural_db_register (Gimp *gimp,
|
||||
ProcRecord *procedure);
|
||||
void procedural_db_unregister (Gimp *gimp,
|
||||
const gchar *name);
|
||||
ProcRecord * procedural_db_lookup (Gimp *gimp,
|
||||
const gchar *name);
|
||||
|
||||
Argument * procedural_db_execute (Gimp *gimp,
|
||||
const gchar *name,
|
||||
Argument *args);
|
||||
Argument * procedural_db_run_proc (Gimp *gimp,
|
||||
const gchar *name,
|
||||
gint *nreturn_vals,
|
||||
...);
|
||||
|
||||
Argument * procedural_db_return_args (ProcRecord *procedure,
|
||||
gboolean success);
|
||||
void procedural_db_destroy_args (Argument *args,
|
||||
gint nargs);
|
||||
|
||||
void procedural_db_set_data (Gimp *gimp,
|
||||
const gchar *identifier,
|
||||
gint32 bytes,
|
||||
const guint8 *data);
|
||||
const guint8 * procedural_db_get_data (Gimp *gimp,
|
||||
const gchar *identifier,
|
||||
gint32 *bytes);
|
||||
|
||||
|
||||
/* "type" should really be a GimpPDBArgType, but we can cope with
|
||||
* out-of-range values.
|
||||
*/
|
||||
const gchar * pdb_type_name (gint type); /* really exists in _cmds.c file */
|
||||
const gchar * pdb_type_name (gint type); /* really exists in _cmds.c file */
|
||||
|
||||
|
||||
#endif /* __PROCEDURAL_DB_H__ */
|
||||
|
|
|
@ -37,13 +37,23 @@
|
|||
#include "libgimp/gimpintl.h"
|
||||
|
||||
|
||||
typedef struct _PDBData PDBData;
|
||||
|
||||
struct _PDBData
|
||||
{
|
||||
gchar *identifier;
|
||||
gint32 bytes;
|
||||
guint8 *data;
|
||||
};
|
||||
|
||||
|
||||
void
|
||||
procedural_db_init (Gimp *gimp)
|
||||
{
|
||||
g_return_if_fail (gimp != NULL);
|
||||
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
||||
|
||||
gimp->procedural_ht = g_hash_table_new (g_str_hash, g_str_equal);
|
||||
gimp->procedural_ht = g_hash_table_new (g_str_hash, g_str_equal);
|
||||
gimp->procedural_db_data_list = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -58,6 +68,8 @@ procedural_db_free_entry (gpointer key,
|
|||
void
|
||||
procedural_db_free (Gimp *gimp)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
||||
|
||||
if (gimp->procedural_ht)
|
||||
{
|
||||
g_hash_table_foreach (gimp->procedural_ht,
|
||||
|
@ -66,6 +78,24 @@ procedural_db_free (Gimp *gimp)
|
|||
|
||||
gimp->procedural_ht = NULL;
|
||||
}
|
||||
|
||||
if (gimp->procedural_db_data_list)
|
||||
{
|
||||
PDBData *data;
|
||||
GList *list;
|
||||
|
||||
for (list = gimp->procedural_db_data_list; list; list = g_list_next (list))
|
||||
{
|
||||
data = (PDBData *) list->data;
|
||||
|
||||
g_free (data->identifier);
|
||||
g_free (data->data);
|
||||
g_free (data);
|
||||
}
|
||||
|
||||
g_list_free (gimp->procedural_db_data_list);
|
||||
gimp->procedural_db_data_list = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -74,6 +104,9 @@ procedural_db_register (Gimp *gimp,
|
|||
{
|
||||
GList *list;
|
||||
|
||||
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
||||
g_return_if_fail (procedure != NULL);
|
||||
|
||||
list = g_hash_table_lookup (gimp->procedural_ht, (gpointer) procedure->name);
|
||||
list = g_list_prepend (list, (gpointer) procedure);
|
||||
|
||||
|
@ -88,6 +121,9 @@ procedural_db_unregister (Gimp *gimp,
|
|||
{
|
||||
GList *list;
|
||||
|
||||
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
||||
g_return_if_fail (name != NULL);
|
||||
|
||||
list = g_hash_table_lookup (gimp->procedural_ht, (gpointer) name);
|
||||
|
||||
if (list)
|
||||
|
@ -110,6 +146,9 @@ procedural_db_lookup (Gimp *gimp,
|
|||
{
|
||||
GList *list;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
|
||||
g_return_val_if_fail (name != NULL, NULL);
|
||||
|
||||
list = g_hash_table_lookup (gimp->procedural_ht, (gpointer) name);
|
||||
|
||||
if (list)
|
||||
|
@ -128,6 +167,9 @@ procedural_db_execute (Gimp *gimp,
|
|||
GList *list;
|
||||
gint i;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
|
||||
g_return_val_if_fail (name != NULL, NULL);
|
||||
|
||||
return_args = NULL;
|
||||
|
||||
list = g_hash_table_lookup (gimp->procedural_ht, (gpointer) name);
|
||||
|
@ -225,6 +267,9 @@ procedural_db_run_proc (Gimp *gimp,
|
|||
va_list args;
|
||||
gint i;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
|
||||
g_return_val_if_fail (name != NULL, NULL);
|
||||
|
||||
if ((proc = procedural_db_lookup (gimp, name)) == NULL)
|
||||
{
|
||||
return_vals = g_new (Argument, 1);
|
||||
|
@ -323,6 +368,8 @@ procedural_db_return_args (ProcRecord *procedure,
|
|||
Argument *return_args;
|
||||
gint i;
|
||||
|
||||
g_return_val_if_fail (procedure != NULL, NULL);
|
||||
|
||||
return_args = g_new (Argument, procedure->num_values + 1);
|
||||
|
||||
if (success)
|
||||
|
@ -410,3 +457,71 @@ procedural_db_destroy_args (Argument *args,
|
|||
|
||||
g_free (args);
|
||||
}
|
||||
|
||||
void
|
||||
procedural_db_set_data (Gimp *gimp,
|
||||
const gchar *identifier,
|
||||
gint32 bytes,
|
||||
const guint8 *data)
|
||||
{
|
||||
GList *list;
|
||||
PDBData *pdb_data;
|
||||
|
||||
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
||||
g_return_if_fail (identifier != NULL);
|
||||
g_return_if_fail (bytes > 0);
|
||||
g_return_if_fail (data != NULL);
|
||||
|
||||
for (list = gimp->procedural_db_data_list; list; list = g_list_next (list))
|
||||
{
|
||||
pdb_data = (PDBData *) list->data;
|
||||
|
||||
if (! strcmp (pdb_data->identifier, identifier))
|
||||
break;
|
||||
}
|
||||
|
||||
/* If there isn't already data with the specified identifier, create one */
|
||||
if (list == NULL)
|
||||
{
|
||||
pdb_data = g_new0 (PDBData, 1);
|
||||
pdb_data->identifier = g_strdup (identifier);
|
||||
|
||||
gimp->procedural_db_data_list =
|
||||
g_list_prepend (gimp->procedural_db_data_list, pdb_data);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_free (pdb_data->data);
|
||||
}
|
||||
|
||||
pdb_data->bytes = bytes;
|
||||
pdb_data->data = g_memdup (data, bytes);
|
||||
}
|
||||
|
||||
const guint8 *
|
||||
procedural_db_get_data (Gimp *gimp,
|
||||
const gchar *identifier,
|
||||
gint32 *bytes)
|
||||
{
|
||||
GList *list;
|
||||
PDBData *pdb_data;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
|
||||
g_return_val_if_fail (identifier != NULL, NULL);
|
||||
g_return_val_if_fail (bytes != NULL, NULL);
|
||||
|
||||
*bytes = 0;
|
||||
|
||||
for (list = gimp->procedural_db_data_list; list; list = g_list_next (list))
|
||||
{
|
||||
pdb_data = (PDBData *) list->data;
|
||||
|
||||
if (! strcmp (pdb_data->identifier, identifier))
|
||||
{
|
||||
*bytes = pdb_data->bytes;
|
||||
return pdb_data->data;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -119,29 +119,43 @@ struct _ProcRecord
|
|||
|
||||
|
||||
/* Functions */
|
||||
void procedural_db_init (Gimp *gimp);
|
||||
void procedural_db_free (Gimp *gimp);
|
||||
void procedural_db_register (Gimp *gimp,
|
||||
ProcRecord *procedure);
|
||||
void procedural_db_unregister (Gimp *gimp,
|
||||
const gchar *name);
|
||||
ProcRecord * procedural_db_lookup (Gimp *gimp,
|
||||
const gchar *name);
|
||||
Argument * procedural_db_execute (Gimp *gimp,
|
||||
const gchar *name,
|
||||
Argument *args);
|
||||
Argument * procedural_db_run_proc (Gimp *gimp,
|
||||
const gchar *name,
|
||||
gint *nreturn_vals,
|
||||
...);
|
||||
Argument * procedural_db_return_args (ProcRecord *procedure,
|
||||
gboolean success);
|
||||
void procedural_db_destroy_args (Argument *args,
|
||||
gint nargs);
|
||||
|
||||
void procedural_db_init (Gimp *gimp);
|
||||
void procedural_db_free (Gimp *gimp);
|
||||
|
||||
void procedural_db_register (Gimp *gimp,
|
||||
ProcRecord *procedure);
|
||||
void procedural_db_unregister (Gimp *gimp,
|
||||
const gchar *name);
|
||||
ProcRecord * procedural_db_lookup (Gimp *gimp,
|
||||
const gchar *name);
|
||||
|
||||
Argument * procedural_db_execute (Gimp *gimp,
|
||||
const gchar *name,
|
||||
Argument *args);
|
||||
Argument * procedural_db_run_proc (Gimp *gimp,
|
||||
const gchar *name,
|
||||
gint *nreturn_vals,
|
||||
...);
|
||||
|
||||
Argument * procedural_db_return_args (ProcRecord *procedure,
|
||||
gboolean success);
|
||||
void procedural_db_destroy_args (Argument *args,
|
||||
gint nargs);
|
||||
|
||||
void procedural_db_set_data (Gimp *gimp,
|
||||
const gchar *identifier,
|
||||
gint32 bytes,
|
||||
const guint8 *data);
|
||||
const guint8 * procedural_db_get_data (Gimp *gimp,
|
||||
const gchar *identifier,
|
||||
gint32 *bytes);
|
||||
|
||||
|
||||
/* "type" should really be a GimpPDBArgType, but we can cope with
|
||||
* out-of-range values.
|
||||
*/
|
||||
const gchar * pdb_type_name (gint type); /* really exists in _cmds.c file */
|
||||
const gchar * pdb_type_name (gint type); /* really exists in _cmds.c file */
|
||||
|
||||
|
||||
#endif /* __PROCEDURAL_DB_H__ */
|
||||
|
|
|
@ -37,13 +37,23 @@
|
|||
#include "libgimp/gimpintl.h"
|
||||
|
||||
|
||||
typedef struct _PDBData PDBData;
|
||||
|
||||
struct _PDBData
|
||||
{
|
||||
gchar *identifier;
|
||||
gint32 bytes;
|
||||
guint8 *data;
|
||||
};
|
||||
|
||||
|
||||
void
|
||||
procedural_db_init (Gimp *gimp)
|
||||
{
|
||||
g_return_if_fail (gimp != NULL);
|
||||
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
||||
|
||||
gimp->procedural_ht = g_hash_table_new (g_str_hash, g_str_equal);
|
||||
gimp->procedural_ht = g_hash_table_new (g_str_hash, g_str_equal);
|
||||
gimp->procedural_db_data_list = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -58,6 +68,8 @@ procedural_db_free_entry (gpointer key,
|
|||
void
|
||||
procedural_db_free (Gimp *gimp)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
||||
|
||||
if (gimp->procedural_ht)
|
||||
{
|
||||
g_hash_table_foreach (gimp->procedural_ht,
|
||||
|
@ -66,6 +78,24 @@ procedural_db_free (Gimp *gimp)
|
|||
|
||||
gimp->procedural_ht = NULL;
|
||||
}
|
||||
|
||||
if (gimp->procedural_db_data_list)
|
||||
{
|
||||
PDBData *data;
|
||||
GList *list;
|
||||
|
||||
for (list = gimp->procedural_db_data_list; list; list = g_list_next (list))
|
||||
{
|
||||
data = (PDBData *) list->data;
|
||||
|
||||
g_free (data->identifier);
|
||||
g_free (data->data);
|
||||
g_free (data);
|
||||
}
|
||||
|
||||
g_list_free (gimp->procedural_db_data_list);
|
||||
gimp->procedural_db_data_list = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -74,6 +104,9 @@ procedural_db_register (Gimp *gimp,
|
|||
{
|
||||
GList *list;
|
||||
|
||||
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
||||
g_return_if_fail (procedure != NULL);
|
||||
|
||||
list = g_hash_table_lookup (gimp->procedural_ht, (gpointer) procedure->name);
|
||||
list = g_list_prepend (list, (gpointer) procedure);
|
||||
|
||||
|
@ -88,6 +121,9 @@ procedural_db_unregister (Gimp *gimp,
|
|||
{
|
||||
GList *list;
|
||||
|
||||
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
||||
g_return_if_fail (name != NULL);
|
||||
|
||||
list = g_hash_table_lookup (gimp->procedural_ht, (gpointer) name);
|
||||
|
||||
if (list)
|
||||
|
@ -110,6 +146,9 @@ procedural_db_lookup (Gimp *gimp,
|
|||
{
|
||||
GList *list;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
|
||||
g_return_val_if_fail (name != NULL, NULL);
|
||||
|
||||
list = g_hash_table_lookup (gimp->procedural_ht, (gpointer) name);
|
||||
|
||||
if (list)
|
||||
|
@ -128,6 +167,9 @@ procedural_db_execute (Gimp *gimp,
|
|||
GList *list;
|
||||
gint i;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
|
||||
g_return_val_if_fail (name != NULL, NULL);
|
||||
|
||||
return_args = NULL;
|
||||
|
||||
list = g_hash_table_lookup (gimp->procedural_ht, (gpointer) name);
|
||||
|
@ -225,6 +267,9 @@ procedural_db_run_proc (Gimp *gimp,
|
|||
va_list args;
|
||||
gint i;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
|
||||
g_return_val_if_fail (name != NULL, NULL);
|
||||
|
||||
if ((proc = procedural_db_lookup (gimp, name)) == NULL)
|
||||
{
|
||||
return_vals = g_new (Argument, 1);
|
||||
|
@ -323,6 +368,8 @@ procedural_db_return_args (ProcRecord *procedure,
|
|||
Argument *return_args;
|
||||
gint i;
|
||||
|
||||
g_return_val_if_fail (procedure != NULL, NULL);
|
||||
|
||||
return_args = g_new (Argument, procedure->num_values + 1);
|
||||
|
||||
if (success)
|
||||
|
@ -410,3 +457,71 @@ procedural_db_destroy_args (Argument *args,
|
|||
|
||||
g_free (args);
|
||||
}
|
||||
|
||||
void
|
||||
procedural_db_set_data (Gimp *gimp,
|
||||
const gchar *identifier,
|
||||
gint32 bytes,
|
||||
const guint8 *data)
|
||||
{
|
||||
GList *list;
|
||||
PDBData *pdb_data;
|
||||
|
||||
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
||||
g_return_if_fail (identifier != NULL);
|
||||
g_return_if_fail (bytes > 0);
|
||||
g_return_if_fail (data != NULL);
|
||||
|
||||
for (list = gimp->procedural_db_data_list; list; list = g_list_next (list))
|
||||
{
|
||||
pdb_data = (PDBData *) list->data;
|
||||
|
||||
if (! strcmp (pdb_data->identifier, identifier))
|
||||
break;
|
||||
}
|
||||
|
||||
/* If there isn't already data with the specified identifier, create one */
|
||||
if (list == NULL)
|
||||
{
|
||||
pdb_data = g_new0 (PDBData, 1);
|
||||
pdb_data->identifier = g_strdup (identifier);
|
||||
|
||||
gimp->procedural_db_data_list =
|
||||
g_list_prepend (gimp->procedural_db_data_list, pdb_data);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_free (pdb_data->data);
|
||||
}
|
||||
|
||||
pdb_data->bytes = bytes;
|
||||
pdb_data->data = g_memdup (data, bytes);
|
||||
}
|
||||
|
||||
const guint8 *
|
||||
procedural_db_get_data (Gimp *gimp,
|
||||
const gchar *identifier,
|
||||
gint32 *bytes)
|
||||
{
|
||||
GList *list;
|
||||
PDBData *pdb_data;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
|
||||
g_return_val_if_fail (identifier != NULL, NULL);
|
||||
g_return_val_if_fail (bytes != NULL, NULL);
|
||||
|
||||
*bytes = 0;
|
||||
|
||||
for (list = gimp->procedural_db_data_list; list; list = g_list_next (list))
|
||||
{
|
||||
pdb_data = (PDBData *) list->data;
|
||||
|
||||
if (! strcmp (pdb_data->identifier, identifier))
|
||||
{
|
||||
*bytes = pdb_data->bytes;
|
||||
return pdb_data->data;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -119,29 +119,43 @@ struct _ProcRecord
|
|||
|
||||
|
||||
/* Functions */
|
||||
void procedural_db_init (Gimp *gimp);
|
||||
void procedural_db_free (Gimp *gimp);
|
||||
void procedural_db_register (Gimp *gimp,
|
||||
ProcRecord *procedure);
|
||||
void procedural_db_unregister (Gimp *gimp,
|
||||
const gchar *name);
|
||||
ProcRecord * procedural_db_lookup (Gimp *gimp,
|
||||
const gchar *name);
|
||||
Argument * procedural_db_execute (Gimp *gimp,
|
||||
const gchar *name,
|
||||
Argument *args);
|
||||
Argument * procedural_db_run_proc (Gimp *gimp,
|
||||
const gchar *name,
|
||||
gint *nreturn_vals,
|
||||
...);
|
||||
Argument * procedural_db_return_args (ProcRecord *procedure,
|
||||
gboolean success);
|
||||
void procedural_db_destroy_args (Argument *args,
|
||||
gint nargs);
|
||||
|
||||
void procedural_db_init (Gimp *gimp);
|
||||
void procedural_db_free (Gimp *gimp);
|
||||
|
||||
void procedural_db_register (Gimp *gimp,
|
||||
ProcRecord *procedure);
|
||||
void procedural_db_unregister (Gimp *gimp,
|
||||
const gchar *name);
|
||||
ProcRecord * procedural_db_lookup (Gimp *gimp,
|
||||
const gchar *name);
|
||||
|
||||
Argument * procedural_db_execute (Gimp *gimp,
|
||||
const gchar *name,
|
||||
Argument *args);
|
||||
Argument * procedural_db_run_proc (Gimp *gimp,
|
||||
const gchar *name,
|
||||
gint *nreturn_vals,
|
||||
...);
|
||||
|
||||
Argument * procedural_db_return_args (ProcRecord *procedure,
|
||||
gboolean success);
|
||||
void procedural_db_destroy_args (Argument *args,
|
||||
gint nargs);
|
||||
|
||||
void procedural_db_set_data (Gimp *gimp,
|
||||
const gchar *identifier,
|
||||
gint32 bytes,
|
||||
const guint8 *data);
|
||||
const guint8 * procedural_db_get_data (Gimp *gimp,
|
||||
const gchar *identifier,
|
||||
gint32 *bytes);
|
||||
|
||||
|
||||
/* "type" should really be a GimpPDBArgType, but we can cope with
|
||||
* out-of-range values.
|
||||
*/
|
||||
const gchar * pdb_type_name (gint type); /* really exists in _cmds.c file */
|
||||
const gchar * pdb_type_name (gint type); /* really exists in _cmds.c file */
|
||||
|
||||
|
||||
#endif /* __PROCEDURAL_DB_H__ */
|
||||
|
|
|
@ -948,7 +948,7 @@ layer_get_name_invoker (Gimp *gimp,
|
|||
return_args = procedural_db_return_args (&layer_get_name_proc, success);
|
||||
|
||||
if (success)
|
||||
return_args[1].value.pdb_pointer = g_strdup (gimp_layer_get_name (layer));
|
||||
return_args[1].value.pdb_pointer = g_strdup (gimp_object_get_name (GIMP_OBJECT (layer)));
|
||||
|
||||
return return_args;
|
||||
}
|
||||
|
@ -1004,7 +1004,7 @@ layer_set_name_invoker (Gimp *gimp,
|
|||
success = FALSE;
|
||||
|
||||
if (success)
|
||||
gimp_layer_set_name (layer, name);
|
||||
gimp_object_set_name (GIMP_OBJECT (layer), name);
|
||||
|
||||
return procedural_db_return_args (&layer_set_name_proc, success);
|
||||
}
|
||||
|
@ -1054,7 +1054,7 @@ layer_get_visible_invoker (Gimp *gimp,
|
|||
return_args = procedural_db_return_args (&layer_get_visible_proc, success);
|
||||
|
||||
if (success)
|
||||
return_args[1].value.pdb_int = gimp_layer_get_visible (layer);
|
||||
return_args[1].value.pdb_int = gimp_drawable_get_visible (GIMP_DRAWABLE (layer));
|
||||
|
||||
return return_args;
|
||||
}
|
||||
|
@ -1108,7 +1108,7 @@ layer_set_visible_invoker (Gimp *gimp,
|
|||
visible = args[1].value.pdb_int ? TRUE : FALSE;
|
||||
|
||||
if (success)
|
||||
gimp_layer_set_visible (layer, visible);
|
||||
gimp_drawable_set_visible (GIMP_DRAWABLE (layer), visible);
|
||||
|
||||
return procedural_db_return_args (&layer_set_visible_proc, success);
|
||||
}
|
||||
|
@ -1890,7 +1890,7 @@ layer_get_tattoo_invoker (Gimp *gimp,
|
|||
return_args = procedural_db_return_args (&layer_get_tattoo_proc, success);
|
||||
|
||||
if (success)
|
||||
return_args[1].value.pdb_int = gimp_layer_get_tattoo (layer);
|
||||
return_args[1].value.pdb_int = gimp_item_get_tattoo (GIMP_ITEM (layer));
|
||||
|
||||
return return_args;
|
||||
}
|
||||
|
@ -1946,7 +1946,7 @@ layer_set_tattoo_invoker (Gimp *gimp,
|
|||
success = FALSE;
|
||||
|
||||
if (success)
|
||||
gimp_layer_set_tattoo (layer, tattoo);
|
||||
gimp_item_set_tattoo (GIMP_ITEM (layer), tattoo);
|
||||
|
||||
return procedural_db_return_args (&layer_set_tattoo_proc, success);
|
||||
}
|
||||
|
|
|
@ -31,7 +31,6 @@
|
|||
#include "core/gimp-parasites.h"
|
||||
#include "core/gimpdrawable.h"
|
||||
#include "core/gimpimage.h"
|
||||
#include "pdb_glue.h"
|
||||
|
||||
#include "libgimpbase/gimpparasite.h"
|
||||
|
||||
|
@ -278,7 +277,7 @@ drawable_parasite_find_invoker (Gimp *gimp,
|
|||
|
||||
if (success)
|
||||
{
|
||||
parasite = gimp_parasite_copy (gimp_drawable_parasite_find (drawable, name));
|
||||
parasite = gimp_parasite_copy (gimp_item_parasite_find (GIMP_ITEM (drawable), name));
|
||||
success = parasite != NULL;
|
||||
}
|
||||
|
||||
|
@ -346,7 +345,7 @@ drawable_parasite_attach_invoker (Gimp *gimp,
|
|||
success = FALSE;
|
||||
|
||||
if (success)
|
||||
gimp_drawable_parasite_attach (drawable, parasite);
|
||||
gimp_item_parasite_attach (GIMP_ITEM (drawable), parasite);
|
||||
|
||||
return procedural_db_return_args (&drawable_parasite_attach_proc, success);
|
||||
}
|
||||
|
@ -398,7 +397,7 @@ drawable_parasite_detach_invoker (Gimp *gimp,
|
|||
success = FALSE;
|
||||
|
||||
if (success)
|
||||
gimp_drawable_parasite_detach (drawable, name);
|
||||
gimp_item_parasite_detach (GIMP_ITEM (drawable), name);
|
||||
|
||||
return procedural_db_return_args (&drawable_parasite_detach_proc, success);
|
||||
}
|
||||
|
@ -448,7 +447,7 @@ drawable_parasite_list_invoker (Gimp *gimp,
|
|||
success = FALSE;
|
||||
|
||||
if (success)
|
||||
parasites = gimp_drawable_parasite_list (drawable, &num_parasites);
|
||||
parasites = gimp_item_parasite_list (GIMP_ITEM (drawable), &num_parasites);
|
||||
|
||||
return_args = procedural_db_return_args (&drawable_parasite_list_proc, success);
|
||||
|
||||
|
|
|
@ -20,24 +20,6 @@
|
|||
#define __PDB_GLUE_H__
|
||||
|
||||
|
||||
#define gimp_drawable_layer GIMP_IS_LAYER
|
||||
#define gimp_drawable_layer_mask GIMP_IS_LAYER_MASK
|
||||
#define gimp_drawable_channel GIMP_IS_CHANNEL
|
||||
|
||||
#define gimp_layer_set_name(l,n) gimp_object_set_name(GIMP_OBJECT(l),(n))
|
||||
#define gimp_layer_get_name(l) gimp_object_get_name(GIMP_OBJECT(l))
|
||||
#define gimp_layer_get_visible(l) gimp_drawable_get_visible(GIMP_DRAWABLE(l))
|
||||
#define gimp_layer_set_visible(l,v) gimp_drawable_set_visible(GIMP_DRAWABLE(l),(v))
|
||||
#define gimp_layer_set_tattoo(l,t) gimp_item_set_tattoo(GIMP_ITEM(l),(t))
|
||||
#define gimp_layer_get_tattoo(l) gimp_item_get_tattoo(GIMP_ITEM(l))
|
||||
|
||||
#define gimp_channel_set_name(c,n) gimp_object_set_name(GIMP_OBJECT(c),(n))
|
||||
#define gimp_channel_get_name(c) gimp_object_get_name(GIMP_OBJECT(c))
|
||||
#define gimp_channel_get_visible(c) gimp_drawable_get_visible(GIMP_DRAWABLE(c))
|
||||
#define gimp_channel_set_visible(c,v) gimp_drawable_set_visible(GIMP_DRAWABLE(c),(v))
|
||||
#define gimp_channel_set_tattoo(c,t) gimp_item_set_tattoo(GIMP_ITEM(c),(t))
|
||||
#define gimp_channel_get_tattoo(c) gimp_item_get_tattoo(GIMP_ITEM(c))
|
||||
|
||||
#define gimp_layer_get_apply_mask(l) (l)->mask ? gimp_layer_mask_get_apply((l)->mask) : FALSE;
|
||||
#define gimp_layer_get_show_mask(l) (l)->mask ? gimp_layer_mask_get_show((l)->mask) : FALSE;
|
||||
#define gimp_layer_get_edit_mask(l) (l)->mask ? gimp_layer_mask_get_edit((l)->mask) : FALSE;
|
||||
|
@ -46,10 +28,5 @@
|
|||
#define gimp_layer_set_show_mask(l,s) { if((l)->mask) gimp_layer_mask_set_show((l)->mask,(s)); else success = FALSE; }
|
||||
#define gimp_layer_set_edit_mask(l,e) { if((l)->mask) gimp_layer_mask_set_edit((l)->mask,(e)); else success = FALSE; }
|
||||
|
||||
#define gimp_drawable_parasite_attach(d,p) gimp_item_parasite_attach(GIMP_ITEM(d),p)
|
||||
#define gimp_drawable_parasite_detach(d,p) gimp_item_parasite_detach(GIMP_ITEM(d),p)
|
||||
#define gimp_drawable_parasite_list(d,c) gimp_item_parasite_list(GIMP_ITEM(d),c)
|
||||
#define gimp_drawable_parasite_find(d,p) gimp_item_parasite_find(GIMP_ITEM(d),p)
|
||||
|
||||
|
||||
#endif /* __PDB_GLUE_H__ */
|
||||
|
|
|
@ -37,13 +37,23 @@
|
|||
#include "libgimp/gimpintl.h"
|
||||
|
||||
|
||||
typedef struct _PDBData PDBData;
|
||||
|
||||
struct _PDBData
|
||||
{
|
||||
gchar *identifier;
|
||||
gint32 bytes;
|
||||
guint8 *data;
|
||||
};
|
||||
|
||||
|
||||
void
|
||||
procedural_db_init (Gimp *gimp)
|
||||
{
|
||||
g_return_if_fail (gimp != NULL);
|
||||
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
||||
|
||||
gimp->procedural_ht = g_hash_table_new (g_str_hash, g_str_equal);
|
||||
gimp->procedural_ht = g_hash_table_new (g_str_hash, g_str_equal);
|
||||
gimp->procedural_db_data_list = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -58,6 +68,8 @@ procedural_db_free_entry (gpointer key,
|
|||
void
|
||||
procedural_db_free (Gimp *gimp)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
||||
|
||||
if (gimp->procedural_ht)
|
||||
{
|
||||
g_hash_table_foreach (gimp->procedural_ht,
|
||||
|
@ -66,6 +78,24 @@ procedural_db_free (Gimp *gimp)
|
|||
|
||||
gimp->procedural_ht = NULL;
|
||||
}
|
||||
|
||||
if (gimp->procedural_db_data_list)
|
||||
{
|
||||
PDBData *data;
|
||||
GList *list;
|
||||
|
||||
for (list = gimp->procedural_db_data_list; list; list = g_list_next (list))
|
||||
{
|
||||
data = (PDBData *) list->data;
|
||||
|
||||
g_free (data->identifier);
|
||||
g_free (data->data);
|
||||
g_free (data);
|
||||
}
|
||||
|
||||
g_list_free (gimp->procedural_db_data_list);
|
||||
gimp->procedural_db_data_list = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -74,6 +104,9 @@ procedural_db_register (Gimp *gimp,
|
|||
{
|
||||
GList *list;
|
||||
|
||||
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
||||
g_return_if_fail (procedure != NULL);
|
||||
|
||||
list = g_hash_table_lookup (gimp->procedural_ht, (gpointer) procedure->name);
|
||||
list = g_list_prepend (list, (gpointer) procedure);
|
||||
|
||||
|
@ -88,6 +121,9 @@ procedural_db_unregister (Gimp *gimp,
|
|||
{
|
||||
GList *list;
|
||||
|
||||
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
||||
g_return_if_fail (name != NULL);
|
||||
|
||||
list = g_hash_table_lookup (gimp->procedural_ht, (gpointer) name);
|
||||
|
||||
if (list)
|
||||
|
@ -110,6 +146,9 @@ procedural_db_lookup (Gimp *gimp,
|
|||
{
|
||||
GList *list;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
|
||||
g_return_val_if_fail (name != NULL, NULL);
|
||||
|
||||
list = g_hash_table_lookup (gimp->procedural_ht, (gpointer) name);
|
||||
|
||||
if (list)
|
||||
|
@ -128,6 +167,9 @@ procedural_db_execute (Gimp *gimp,
|
|||
GList *list;
|
||||
gint i;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
|
||||
g_return_val_if_fail (name != NULL, NULL);
|
||||
|
||||
return_args = NULL;
|
||||
|
||||
list = g_hash_table_lookup (gimp->procedural_ht, (gpointer) name);
|
||||
|
@ -225,6 +267,9 @@ procedural_db_run_proc (Gimp *gimp,
|
|||
va_list args;
|
||||
gint i;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
|
||||
g_return_val_if_fail (name != NULL, NULL);
|
||||
|
||||
if ((proc = procedural_db_lookup (gimp, name)) == NULL)
|
||||
{
|
||||
return_vals = g_new (Argument, 1);
|
||||
|
@ -323,6 +368,8 @@ procedural_db_return_args (ProcRecord *procedure,
|
|||
Argument *return_args;
|
||||
gint i;
|
||||
|
||||
g_return_val_if_fail (procedure != NULL, NULL);
|
||||
|
||||
return_args = g_new (Argument, procedure->num_values + 1);
|
||||
|
||||
if (success)
|
||||
|
@ -410,3 +457,71 @@ procedural_db_destroy_args (Argument *args,
|
|||
|
||||
g_free (args);
|
||||
}
|
||||
|
||||
void
|
||||
procedural_db_set_data (Gimp *gimp,
|
||||
const gchar *identifier,
|
||||
gint32 bytes,
|
||||
const guint8 *data)
|
||||
{
|
||||
GList *list;
|
||||
PDBData *pdb_data;
|
||||
|
||||
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
||||
g_return_if_fail (identifier != NULL);
|
||||
g_return_if_fail (bytes > 0);
|
||||
g_return_if_fail (data != NULL);
|
||||
|
||||
for (list = gimp->procedural_db_data_list; list; list = g_list_next (list))
|
||||
{
|
||||
pdb_data = (PDBData *) list->data;
|
||||
|
||||
if (! strcmp (pdb_data->identifier, identifier))
|
||||
break;
|
||||
}
|
||||
|
||||
/* If there isn't already data with the specified identifier, create one */
|
||||
if (list == NULL)
|
||||
{
|
||||
pdb_data = g_new0 (PDBData, 1);
|
||||
pdb_data->identifier = g_strdup (identifier);
|
||||
|
||||
gimp->procedural_db_data_list =
|
||||
g_list_prepend (gimp->procedural_db_data_list, pdb_data);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_free (pdb_data->data);
|
||||
}
|
||||
|
||||
pdb_data->bytes = bytes;
|
||||
pdb_data->data = g_memdup (data, bytes);
|
||||
}
|
||||
|
||||
const guint8 *
|
||||
procedural_db_get_data (Gimp *gimp,
|
||||
const gchar *identifier,
|
||||
gint32 *bytes)
|
||||
{
|
||||
GList *list;
|
||||
PDBData *pdb_data;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
|
||||
g_return_val_if_fail (identifier != NULL, NULL);
|
||||
g_return_val_if_fail (bytes != NULL, NULL);
|
||||
|
||||
*bytes = 0;
|
||||
|
||||
for (list = gimp->procedural_db_data_list; list; list = g_list_next (list))
|
||||
{
|
||||
pdb_data = (PDBData *) list->data;
|
||||
|
||||
if (! strcmp (pdb_data->identifier, identifier))
|
||||
{
|
||||
*bytes = pdb_data->bytes;
|
||||
return pdb_data->data;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -119,29 +119,43 @@ struct _ProcRecord
|
|||
|
||||
|
||||
/* Functions */
|
||||
void procedural_db_init (Gimp *gimp);
|
||||
void procedural_db_free (Gimp *gimp);
|
||||
void procedural_db_register (Gimp *gimp,
|
||||
ProcRecord *procedure);
|
||||
void procedural_db_unregister (Gimp *gimp,
|
||||
const gchar *name);
|
||||
ProcRecord * procedural_db_lookup (Gimp *gimp,
|
||||
const gchar *name);
|
||||
Argument * procedural_db_execute (Gimp *gimp,
|
||||
const gchar *name,
|
||||
Argument *args);
|
||||
Argument * procedural_db_run_proc (Gimp *gimp,
|
||||
const gchar *name,
|
||||
gint *nreturn_vals,
|
||||
...);
|
||||
Argument * procedural_db_return_args (ProcRecord *procedure,
|
||||
gboolean success);
|
||||
void procedural_db_destroy_args (Argument *args,
|
||||
gint nargs);
|
||||
|
||||
void procedural_db_init (Gimp *gimp);
|
||||
void procedural_db_free (Gimp *gimp);
|
||||
|
||||
void procedural_db_register (Gimp *gimp,
|
||||
ProcRecord *procedure);
|
||||
void procedural_db_unregister (Gimp *gimp,
|
||||
const gchar *name);
|
||||
ProcRecord * procedural_db_lookup (Gimp *gimp,
|
||||
const gchar *name);
|
||||
|
||||
Argument * procedural_db_execute (Gimp *gimp,
|
||||
const gchar *name,
|
||||
Argument *args);
|
||||
Argument * procedural_db_run_proc (Gimp *gimp,
|
||||
const gchar *name,
|
||||
gint *nreturn_vals,
|
||||
...);
|
||||
|
||||
Argument * procedural_db_return_args (ProcRecord *procedure,
|
||||
gboolean success);
|
||||
void procedural_db_destroy_args (Argument *args,
|
||||
gint nargs);
|
||||
|
||||
void procedural_db_set_data (Gimp *gimp,
|
||||
const gchar *identifier,
|
||||
gint32 bytes,
|
||||
const guint8 *data);
|
||||
const guint8 * procedural_db_get_data (Gimp *gimp,
|
||||
const gchar *identifier,
|
||||
gint32 *bytes);
|
||||
|
||||
|
||||
/* "type" should really be a GimpPDBArgType, but we can cope with
|
||||
* out-of-range values.
|
||||
*/
|
||||
const gchar * pdb_type_name (gint type); /* really exists in _cmds.c file */
|
||||
const gchar * pdb_type_name (gint type); /* really exists in _cmds.c file */
|
||||
|
||||
|
||||
#endif /* __PROCEDURAL_DB_H__ */
|
||||
|
|
|
@ -60,18 +60,6 @@ struct _PDBQuery
|
|||
int num_procs;
|
||||
};
|
||||
|
||||
typedef struct _PDBData PDBData;
|
||||
|
||||
struct _PDBData
|
||||
{
|
||||
gchar *identifier;
|
||||
gint bytes;
|
||||
gchar *data;
|
||||
};
|
||||
|
||||
static FILE *procedural_db_out = NULL;
|
||||
static GList *data_list = NULL;
|
||||
|
||||
static gchar *proc_type_str[] =
|
||||
{
|
||||
N_("Internal GIMP procedure"),
|
||||
|
@ -144,10 +132,10 @@ procedural_db_query_entry (gpointer key,
|
|||
gpointer value,
|
||||
gpointer user_data)
|
||||
{
|
||||
GList *list;
|
||||
GList *list;
|
||||
ProcRecord *proc;
|
||||
PDBQuery *pdb_query;
|
||||
int new_length;
|
||||
PDBQuery *pdb_query;
|
||||
gint new_length;
|
||||
|
||||
list = (GList *) value;
|
||||
proc = (ProcRecord *) list->data;
|
||||
|
@ -175,24 +163,28 @@ procedural_db_query_entry (gpointer key,
|
|||
}
|
||||
|
||||
static void
|
||||
output_string (const char *string)
|
||||
output_string (FILE *file,
|
||||
const char *string)
|
||||
{
|
||||
fprintf (procedural_db_out, "\"");
|
||||
while (*string)
|
||||
{
|
||||
switch (*string)
|
||||
{
|
||||
case '\\' : fprintf (procedural_db_out, "\\\\"); break;
|
||||
case '\"' : fprintf (procedural_db_out, "\\\""); break;
|
||||
case '{' : fprintf (procedural_db_out, "@{"); break;
|
||||
case '@' : fprintf (procedural_db_out, "@@"); break;
|
||||
case '}' : fprintf (procedural_db_out, "@}"); break;
|
||||
default:
|
||||
fprintf (procedural_db_out, "%c", *string);
|
||||
}
|
||||
string++;
|
||||
}
|
||||
fprintf (procedural_db_out, "\"\n");
|
||||
fprintf (file, "\"");
|
||||
|
||||
if (string)
|
||||
while (*string)
|
||||
{
|
||||
switch (*string)
|
||||
{
|
||||
case '\\' : fprintf (file, "\\\\"); break;
|
||||
case '\"' : fprintf (file, "\\\""); break;
|
||||
case '{' : fprintf (file, "@{"); break;
|
||||
case '@' : fprintf (file, "@@"); break;
|
||||
case '}' : fprintf (file, "@}"); break;
|
||||
default:
|
||||
fprintf (file, "%c", *string);
|
||||
}
|
||||
string++;
|
||||
}
|
||||
|
||||
fprintf (file, "\"\n");
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -200,11 +192,17 @@ procedural_db_print_entry (gpointer key,
|
|||
gpointer value,
|
||||
gpointer user_data)
|
||||
{
|
||||
int i;
|
||||
ProcRecord *procedure;
|
||||
GList *list = (GList *) value;
|
||||
int num = 0;
|
||||
GString *buf = g_string_new ("");
|
||||
GString *buf;
|
||||
GList *list;
|
||||
FILE *file;
|
||||
gint i;
|
||||
gint num = 0;
|
||||
|
||||
list = (GList *) value;
|
||||
file = (FILE *) user_data;
|
||||
|
||||
buf = g_string_new ("");
|
||||
|
||||
while (list)
|
||||
{
|
||||
|
@ -212,48 +210,48 @@ procedural_db_print_entry (gpointer key,
|
|||
procedure = (ProcRecord*) list->data;
|
||||
list = list->next;
|
||||
|
||||
fprintf (procedural_db_out, "\n(register-procedure ");
|
||||
fprintf (file, "\n(register-procedure ");
|
||||
|
||||
if (list || num != 1)
|
||||
{
|
||||
g_string_printf (buf, "%s <%d>", procedure->name, num);
|
||||
output_string (buf->str);
|
||||
output_string (file, buf->str);
|
||||
}
|
||||
else
|
||||
output_string (procedure->name);
|
||||
output_string (file, procedure->name);
|
||||
|
||||
output_string (procedure->blurb);
|
||||
output_string (procedure->help);
|
||||
output_string (procedure->author);
|
||||
output_string (procedure->copyright);
|
||||
output_string (procedure->date);
|
||||
output_string (proc_type_str[(int) procedure->proc_type]);
|
||||
output_string (file, procedure->blurb);
|
||||
output_string (file, procedure->help);
|
||||
output_string (file, procedure->author);
|
||||
output_string (file, procedure->copyright);
|
||||
output_string (file, procedure->date);
|
||||
output_string (file, proc_type_str[(int) procedure->proc_type]);
|
||||
|
||||
fprintf (procedural_db_out, "( ");
|
||||
fprintf (file, "( ");
|
||||
for (i = 0; i < procedure->num_args; i++)
|
||||
{
|
||||
fprintf (procedural_db_out, "( ");
|
||||
fprintf (file, "( ");
|
||||
|
||||
output_string (procedure->args[i].name );
|
||||
output_string (type_str[procedure->args[i].arg_type]);
|
||||
output_string (procedure->args[i].description);
|
||||
output_string (file, procedure->args[i].name );
|
||||
output_string (file, type_str[procedure->args[i].arg_type]);
|
||||
output_string (file, procedure->args[i].description);
|
||||
|
||||
fprintf (procedural_db_out, " ) ");
|
||||
fprintf (file, " ) ");
|
||||
}
|
||||
fprintf (procedural_db_out, " ) ");
|
||||
fprintf (file, " ) ");
|
||||
|
||||
fprintf (procedural_db_out, "( ");
|
||||
fprintf (file, "( ");
|
||||
for (i = 0; i < procedure->num_values; i++)
|
||||
{
|
||||
fprintf (procedural_db_out, "( ");
|
||||
output_string (procedure->values[i].name );
|
||||
output_string (type_str[procedure->values[i].arg_type]);
|
||||
output_string (procedure->values[i].description);
|
||||
fprintf (file, "( ");
|
||||
output_string (file, procedure->values[i].name );
|
||||
output_string (file, type_str[procedure->values[i].arg_type]);
|
||||
output_string (file, procedure->values[i].description);
|
||||
|
||||
fprintf (procedural_db_out, " ) ");
|
||||
fprintf (file, " ) ");
|
||||
}
|
||||
fprintf (procedural_db_out, " ) ");
|
||||
fprintf (procedural_db_out, " ) ");
|
||||
fprintf (file, " ) ");
|
||||
fprintf (file, " ) ");
|
||||
}
|
||||
|
||||
g_string_free (buf, TRUE);
|
||||
|
@ -280,6 +278,7 @@ procedural_db_dump_invoker (Gimp *gimp,
|
|||
{
|
||||
gboolean success = TRUE;
|
||||
gchar *filename;
|
||||
FILE *file;
|
||||
|
||||
filename = (gchar *) args[0].value.pdb_pointer;
|
||||
if (filename == NULL)
|
||||
|
@ -287,11 +286,11 @@ procedural_db_dump_invoker (Gimp *gimp,
|
|||
|
||||
if (success)
|
||||
{
|
||||
if ((procedural_db_out = fopen (filename, "w")))
|
||||
if ((file = fopen (filename, "w")))
|
||||
{
|
||||
g_hash_table_foreach (gimp->procedural_ht,
|
||||
procedural_db_print_entry, NULL);
|
||||
fclose (procedural_db_out);
|
||||
procedural_db_print_entry, file);
|
||||
fclose (file);
|
||||
}
|
||||
else
|
||||
success = FALSE;
|
||||
|
@ -756,9 +755,9 @@ procedural_db_get_data_invoker (Gimp *gimp,
|
|||
gboolean success = TRUE;
|
||||
Argument *return_args;
|
||||
gchar *identifier;
|
||||
gint32 bytes;
|
||||
guint8 *data_copy = NULL;
|
||||
PDBData *data = NULL;
|
||||
GList *list;
|
||||
const guint8 *data;
|
||||
|
||||
identifier = (gchar *) args[0].value.pdb_pointer;
|
||||
if (identifier == NULL)
|
||||
|
@ -766,30 +765,18 @@ procedural_db_get_data_invoker (Gimp *gimp,
|
|||
|
||||
if (success)
|
||||
{
|
||||
success = FALSE;
|
||||
data = procedural_db_get_data (gimp, identifier, &bytes);
|
||||
success = (data != NULL);
|
||||
|
||||
list = data_list;
|
||||
while (list)
|
||||
{
|
||||
data = (PDBData *) list->data;
|
||||
list = list->next;
|
||||
|
||||
if (!strcmp (data->identifier, identifier))
|
||||
{
|
||||
data_copy = g_new (guint8, data->bytes);
|
||||
memcpy (data_copy, data->data, data->bytes);
|
||||
|
||||
success = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (success)
|
||||
data_copy = g_memdup (data, bytes);
|
||||
}
|
||||
|
||||
return_args = procedural_db_return_args (&procedural_db_get_data_proc, success);
|
||||
|
||||
if (success)
|
||||
{
|
||||
return_args[1].value.pdb_int = data->bytes;
|
||||
return_args[1].value.pdb_int = bytes;
|
||||
return_args[2].value.pdb_pointer = data_copy;
|
||||
}
|
||||
|
||||
|
@ -842,8 +829,8 @@ procedural_db_get_data_size_invoker (Gimp *gimp,
|
|||
gboolean success = TRUE;
|
||||
Argument *return_args;
|
||||
gchar *identifier;
|
||||
PDBData *data = NULL;
|
||||
GList *list;
|
||||
gint32 bytes;
|
||||
const guint8 *data;
|
||||
|
||||
identifier = (gchar *) args[0].value.pdb_pointer;
|
||||
if (identifier == NULL)
|
||||
|
@ -851,26 +838,14 @@ procedural_db_get_data_size_invoker (Gimp *gimp,
|
|||
|
||||
if (success)
|
||||
{
|
||||
success = FALSE;
|
||||
|
||||
list = data_list;
|
||||
while (list)
|
||||
{
|
||||
data = (PDBData *) list->data;
|
||||
list = list->next;
|
||||
|
||||
if (!strcmp (data->identifier, identifier))
|
||||
{
|
||||
success = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
data = procedural_db_get_data (gimp, identifier, &bytes);
|
||||
success = (data != NULL);
|
||||
}
|
||||
|
||||
return_args = procedural_db_return_args (&procedural_db_get_data_size_proc, success);
|
||||
|
||||
if (success)
|
||||
return_args[1].value.pdb_int = data->bytes;
|
||||
return_args[1].value.pdb_int = bytes;
|
||||
|
||||
return return_args;
|
||||
}
|
||||
|
@ -916,9 +891,7 @@ procedural_db_set_data_invoker (Gimp *gimp,
|
|||
gboolean success = TRUE;
|
||||
gchar *identifier;
|
||||
gint32 bytes;
|
||||
guint8 *data_src;
|
||||
PDBData *data = NULL;
|
||||
GList *list;
|
||||
guint8 *data;
|
||||
|
||||
identifier = (gchar *) args[0].value.pdb_pointer;
|
||||
if (identifier == NULL)
|
||||
|
@ -928,33 +901,10 @@ procedural_db_set_data_invoker (Gimp *gimp,
|
|||
if (bytes <= 0)
|
||||
success = FALSE;
|
||||
|
||||
data_src = (guint8 *) args[2].value.pdb_pointer;
|
||||
data = (guint8 *) args[2].value.pdb_pointer;
|
||||
|
||||
if (success)
|
||||
{
|
||||
list = data_list;
|
||||
while (list)
|
||||
{
|
||||
if (!strcmp (((PDBData *) list->data)->identifier, identifier))
|
||||
data = (PDBData *) list->data;
|
||||
|
||||
list = list->next;
|
||||
}
|
||||
|
||||
/* If there isn't already data with the specified identifier, create one */
|
||||
if (data == NULL)
|
||||
{
|
||||
data = (PDBData *) g_new (PDBData, 1);
|
||||
data_list = g_list_append (data_list, data);
|
||||
}
|
||||
else
|
||||
g_free (data->data);
|
||||
|
||||
data->identifier = g_strdup (identifier);
|
||||
data->bytes = bytes;
|
||||
data->data = g_new (char, data->bytes);
|
||||
memcpy (data->data, (char *) data_src, data->bytes);
|
||||
}
|
||||
procedural_db_set_data (gimp, identifier, bytes, data);
|
||||
|
||||
return procedural_db_return_args (&procedural_db_set_data_proc, success);
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ sub operation_arg () {{
|
|||
}}
|
||||
|
||||
sub channel_get_prop_proc {
|
||||
my ($prop, $type, $desc, $func) = @_;
|
||||
my ($prop, $type, $desc, $func, $core_type, $core_var) = @_;
|
||||
|
||||
$blurb = "Get the $desc of the specified channel.";
|
||||
|
||||
|
@ -45,7 +45,7 @@ sub channel_get_prop_proc {
|
|||
desc => "The channel $desc", no_declare => 1 }
|
||||
);
|
||||
|
||||
my $alias = $func ? "gimp_channel_get_$prop (channel)" : "channel->$prop";
|
||||
my $alias = $func ? "gimp_${core_type}_get_$prop ($core_var)" : "$core_var->$prop";
|
||||
$alias = "g_strdup ($alias)" if $type eq 'string';
|
||||
$outargs[0]->{alias} .= "$alias";
|
||||
|
||||
|
@ -64,7 +64,7 @@ CODE
|
|||
}
|
||||
|
||||
sub channel_set_prop_proc {
|
||||
my ($prop, $type, $desc, $func) = @_;
|
||||
my ($prop, $type, $desc, $func, $core_type, $core_var) = @_;
|
||||
|
||||
$blurb = "Set the $desc of the specified channel.";
|
||||
|
||||
|
@ -82,8 +82,8 @@ sub channel_set_prop_proc {
|
|||
$inargs[1]->{desc} .= ' (%%desc%%)';
|
||||
}
|
||||
|
||||
$invoke{code} = $func ? "gimp_channel_set_$prop (channel, $prop);"
|
||||
: "channel->$prop = $prop;";
|
||||
$invoke{code} = $func ? "gimp_${core_type}_set_$prop ($core_var, $prop);"
|
||||
: "$core_var->$prop = $prop;";
|
||||
|
||||
if ($type eq 'color') {
|
||||
%invoke = (
|
||||
|
@ -106,7 +106,7 @@ CODE
|
|||
}
|
||||
|
||||
sub channel_accessors {
|
||||
my ($prop, $type, $desc, $func, $extra) = @_;
|
||||
my ($prop, $type, $desc, $func, $core_type, $core_var, $extra) = @_;
|
||||
my (@extra, %extra); my $once = 0;
|
||||
|
||||
ref($extra) ? (@extra = @$extra) : (@extra = ($extra, $extra));
|
||||
|
@ -119,7 +119,8 @@ sub channel_accessors {
|
|||
|
||||
eval <<SUB;
|
||||
sub @{[ scalar caller ]}::$proc {
|
||||
\&channel_${_}_prop_proc('$prop', '$type', '$desc', $func);
|
||||
\&channel_${_}_prop_proc('$prop', '$type', '$desc', $func,
|
||||
'$core_type', '$core_var');
|
||||
$extra{$_}
|
||||
}
|
||||
SUB
|
||||
|
@ -253,11 +254,14 @@ HELP
|
|||
CODE
|
||||
}
|
||||
|
||||
&channel_accessors('name', 'string', 'name', 1);
|
||||
&channel_accessors('name', 'string', 'name', 1,
|
||||
'object', 'GIMP_OBJECT (channel)');
|
||||
|
||||
&channel_accessors('visible', 'boolean', 'visibility', 1);
|
||||
&channel_accessors('visible', 'boolean', 'visibility', 1,
|
||||
'drawable', 'GIMP_DRAWABLE (channel)');
|
||||
|
||||
&channel_accessors('show_masked', 'boolean', 'composite method', 1,
|
||||
'channel', 'channel',
|
||||
<<'CODE');
|
||||
$help .= <<'HELP'
|
||||
If it is non-zero, then the channel is composited with the image so that masked
|
||||
|
@ -266,15 +270,18 @@ HELP
|
|||
CODE
|
||||
|
||||
&channel_accessors('opacity', '0 <= float <= 100', 'opacity', 0,
|
||||
'channel', 'channel',
|
||||
[ '$outargs[0]->{alias} =
|
||||
"channel->color.a * 100.0"',
|
||||
'$invoke{code} =~
|
||||
s%(color.a);$%(($1 / 100.0);%' ]);
|
||||
|
||||
&channel_accessors('color', 'color', 'compositing color', 0,
|
||||
&channel_accessors('color', 'color', 'compositing color', 0,
|
||||
'channel', 'channel',
|
||||
[ '$outargs[0]->{void_ret} = 1', '' ]);
|
||||
|
||||
&channel_accessors('tattoo', 'tattoo', 'tattoo', 1,
|
||||
'item', 'GIMP_ITEM (channel)',
|
||||
<<'CODE');
|
||||
$help .= <<'HELP';
|
||||
A tattoo is a unique and permanent identifier attached to a channel that can be
|
||||
|
@ -285,8 +292,6 @@ HELP
|
|||
$date = '1998';
|
||||
CODE
|
||||
|
||||
@headers = qw("pdb_glue.h");
|
||||
|
||||
unshift @procs, qw(channel_new channel_copy channel_delete
|
||||
channel_combine_masks);
|
||||
%exports = (app => [@procs], lib => [@procs]);
|
||||
|
|
|
@ -69,7 +69,7 @@ HELP
|
|||
}
|
||||
|
||||
sub drawable_is_proc {
|
||||
my $desc = shift;
|
||||
my ($desc, $check) = @_;
|
||||
|
||||
my $type = $desc;
|
||||
$type =~ s/ /_/g;
|
||||
|
@ -82,7 +82,7 @@ HELP
|
|||
$type, 'boolean', $type,
|
||||
"Non-zero if the drawable is a $desc");
|
||||
|
||||
$outargs[0]->{alias} .= ' ? TRUE : FALSE';
|
||||
$outargs[0]->{alias} = $check . ' (drawable) ? TRUE : FALSE';
|
||||
}
|
||||
|
||||
sub drawable_merge_shadow {
|
||||
|
@ -306,15 +306,15 @@ HELP
|
|||
}
|
||||
|
||||
sub drawable_is_layer {
|
||||
&drawable_is_proc('layer');
|
||||
&drawable_is_proc('layer', 'GIMP_IS_LAYER');
|
||||
}
|
||||
|
||||
sub drawable_is_layer_mask {
|
||||
&drawable_is_proc('layer mask');
|
||||
&drawable_is_proc('layer mask', 'GIMP_IS_LAYER_MASK');
|
||||
}
|
||||
|
||||
sub drawable_is_channel {
|
||||
&drawable_is_proc('channel');
|
||||
&drawable_is_proc('channel', 'GIMP_IS_CHANNEL');
|
||||
}
|
||||
|
||||
sub drawable_get_pixel {
|
||||
|
@ -538,8 +538,7 @@ CODE
|
|||
|
||||
@headers = qw("core/gimp.h" "core/gimplayermask.h" "core/gimpchannel.h"
|
||||
"core/gimpdrawable.h" "core/gimpdrawable-offset.h"
|
||||
"pdb_glue.h" "base/tile.h" "base/tile-manager.h"
|
||||
"base/temp-buf.h");
|
||||
"base/tile.h" "base/tile-manager.h" "base/temp-buf.h");
|
||||
|
||||
@procs = qw(drawable_merge_shadow drawable_fill drawable_update
|
||||
drawable_mask_bounds drawable_image drawable_type
|
||||
|
|
|
@ -107,7 +107,7 @@ HELP
|
|||
}
|
||||
|
||||
sub layer_get_prop_proc {
|
||||
my ($prop, $type, $desc, $func) = @_;
|
||||
my ($prop, $type, $desc, $func, $core_type, $core_var) = @_;
|
||||
|
||||
$blurb = "Get the $desc of the specified layer.";
|
||||
|
||||
|
@ -122,7 +122,7 @@ sub layer_get_prop_proc {
|
|||
desc => "The layer $desc", no_declare => 1 }
|
||||
);
|
||||
|
||||
my $alias = $func ? "gimp_layer_get_$prop (layer)" : "layer->$prop";
|
||||
my $alias = $func ? "gimp_${core_type}_get_$prop ($core_var)" : "$core_var->$prop";
|
||||
$alias = "g_strdup ($alias)" if $type eq 'string';
|
||||
$outargs[0]->{alias} .= "$alias";
|
||||
|
||||
|
@ -141,7 +141,7 @@ sub layer_get_prop_proc {
|
|||
}
|
||||
|
||||
sub layer_set_prop_proc {
|
||||
my ($prop, $type, $desc, $func) = @_;
|
||||
my ($prop, $type, $desc, $func, $core_type, $core_var) = @_;
|
||||
|
||||
$blurb = "Set the $desc of the specified layer.";
|
||||
|
||||
|
@ -159,8 +159,8 @@ sub layer_set_prop_proc {
|
|||
$inargs[1]->{desc} .= ' (%%desc%%)';
|
||||
}
|
||||
|
||||
$invoke{code} = $func ? "gimp_layer_set_$prop (layer, $prop);"
|
||||
: "layer->$prop = $prop;";
|
||||
$invoke{code} = $func ? "gimp_${core_type}_set_$prop ($core_var, $prop);"
|
||||
: "$core_var->$prop = $prop;";
|
||||
|
||||
if ($type eq 'color') {
|
||||
%invoke = (
|
||||
|
@ -174,7 +174,7 @@ CODE
|
|||
}
|
||||
|
||||
sub layer_accessors {
|
||||
my ($prop, $type, $desc, $func, $setting, $extra) = @_;
|
||||
my ($prop, $type, $desc, $func, $setting, $core_type, $core_var, $extra) = @_;
|
||||
my (@extra, %extra); my $once = 0;
|
||||
|
||||
my $change = "s/ ($desc)/'s \$1 setting/";
|
||||
|
@ -195,7 +195,8 @@ sub layer_accessors {
|
|||
|
||||
eval <<SUB;
|
||||
sub @{[ scalar caller ]}::$proc {
|
||||
\&layer_${_}_prop_proc('$prop', '$type', '$desc', $func);
|
||||
\&layer_${_}_prop_proc('$prop', '$type', '$desc', $func,
|
||||
'$core_type', '$core_var');
|
||||
$extra{$_}
|
||||
@{[ $setting ? $modify{$_} : "" ]}
|
||||
}
|
||||
|
@ -479,13 +480,17 @@ HELP
|
|||
);
|
||||
}
|
||||
|
||||
&layer_accessors('name', 'string', 'name', 1, 0);
|
||||
&layer_accessors('name', 'string', 'name', 1, 0,
|
||||
'object', 'GIMP_OBJECT (layer)');
|
||||
|
||||
&layer_accessors('visible', 'boolean', 'visibility', 1, 0);
|
||||
&layer_accessors('visible', 'boolean', 'visibility', 1, 0,
|
||||
'drawable', 'GIMP_DRAWABLE (layer)');
|
||||
|
||||
&layer_accessors('preserve_trans', 'boolean', 'preserve transperancy', 1, 1);
|
||||
&layer_accessors('preserve_trans', 'boolean', 'preserve transperancy', 1, 1,
|
||||
'layer', 'layer');
|
||||
|
||||
&layer_accessors('apply_mask', 'boolean', 'apply mask', 1, 0,
|
||||
'layer', 'layer',
|
||||
[ <<'CODE1', <<'CODE2' ]);
|
||||
$help .= <<'HELP';
|
||||
If the value is non-zero, then the layer mask for this layer is currently being
|
||||
|
@ -499,6 +504,7 @@ HELP
|
|||
CODE2
|
||||
|
||||
&layer_accessors('show_mask', 'boolean', 'show mask', 1, 0,
|
||||
'layer', 'layer',
|
||||
[ <<'CODE1', <<'CODE2' ]);
|
||||
$help .= <<'HELP';
|
||||
If the value is non-zero, then the layer mask for this layer is currently being
|
||||
|
@ -513,6 +519,7 @@ HELP
|
|||
CODE2
|
||||
|
||||
&layer_accessors('edit_mask', 'boolean', 'show mask', 1, 0,
|
||||
'layer', 'layer',
|
||||
[ <<'CODE1', <<'CODE2' ]);
|
||||
$help .= <<'HELP';
|
||||
If the value is non-zero, then the layer mask for this layer is currently
|
||||
|
@ -527,14 +534,17 @@ HELP
|
|||
CODE2
|
||||
|
||||
&layer_accessors('opacity', '0 <= float <= 100', 'opacity', 1, 0,
|
||||
'layer', 'layer',
|
||||
[ '$outargs[0]->{alias} =
|
||||
"gimp_layer_get_opacity (layer) * 100.0"',
|
||||
'$invoke{code} =~
|
||||
s%opacity\);%opacity / 100.0\);%' ]);
|
||||
|
||||
&layer_accessors('mode', 'enum GimpLayerModeEffects', 'combination mode', 1, 0);
|
||||
&layer_accessors('mode', 'enum GimpLayerModeEffects', 'combination mode', 1, 0,
|
||||
'layer', 'layer');
|
||||
|
||||
&layer_accessors('linked', 'boolean', 'linked state', 1, 0,
|
||||
'layer', 'layer',
|
||||
<<'CODE');
|
||||
$author = $copyright = 'Wolfgang Hofer';
|
||||
$date = '1998';
|
||||
|
@ -545,6 +555,7 @@ CODE2
|
|||
CODE
|
||||
|
||||
&layer_accessors('tattoo', 'tattoo', 'tattoo', 1, 0,
|
||||
'item', 'GIMP_ITEM (layer)',
|
||||
<<'CODE');
|
||||
$help .= <<'HELP';
|
||||
A tattoo is a unique and permanent identifier attached to a
|
||||
|
|
|
@ -42,8 +42,8 @@ sub drawable_arg () {{
|
|||
}}
|
||||
|
||||
sub convert_proc {
|
||||
my ($type, $arg, $var) = @_;
|
||||
my $desc = ($type =~ /^[aeiou]/ ? 'an ' : 'a ') . $type;
|
||||
my ($pdb_type, $arg, $var, $core_type) = @_;
|
||||
my $desc = ($pdb_type =~ /^[aeiou]/ ? 'an ' : 'a ') . $pdb_type;
|
||||
|
||||
foreach ($blurb, $help, $inargs[0]->{desc}) { s/the gimp/$desc/e }
|
||||
|
||||
|
@ -55,7 +55,7 @@ sub convert_proc {
|
|||
|
||||
$invoke{code} =~ s/gimp_parasite_copy/GIMP_parasite_copy/;
|
||||
|
||||
$invoke{code} =~ s/gimp_/"gimp_$type\_"/e;
|
||||
$invoke{code} =~ s/gimp_/"gimp_$core_type\_"/e;
|
||||
$invoke{code} =~ s/gimp, /"$var, "/e;
|
||||
|
||||
$invoke{code} =~ s/GIMP_parasite_copy/gimp_parasite_copy/;
|
||||
|
@ -137,13 +137,13 @@ sub parasite_list {
|
|||
%invoke = ( code => 'parasites = gimp_parasite_list (gimp, &num_parasites);' );
|
||||
}
|
||||
|
||||
@headers = qw("core/gimp-parasites.h" "core/gimpdrawable.h" "pdb_glue.h");
|
||||
@headers = qw("core/gimp-parasites.h");
|
||||
|
||||
@procs = qw(parasite_find parasite_attach parasite_detach parasite_list);
|
||||
|
||||
@types = (
|
||||
['drawable', '&drawable_arg' , 'drawable'],
|
||||
['image' , '&std_image_arg', 'gimage' ]
|
||||
['drawable', '&drawable_arg' , 'GIMP_ITEM (drawable)', 'item' ],
|
||||
['image' , '&std_image_arg', 'gimage', 'image' ]
|
||||
);
|
||||
|
||||
foreach $type (@types) {
|
||||
|
|
|
@ -34,8 +34,6 @@ sub data_bytes_arg () {{
|
|||
name => 'bytes',
|
||||
type => '0 < int32',
|
||||
desc => 'The number of bytes in the data',
|
||||
alias => 'data->bytes',
|
||||
no_declare => 1
|
||||
}}
|
||||
|
||||
sub data_arg () {{
|
||||
|
@ -116,13 +114,14 @@ HELP
|
|||
|
||||
%invoke = (
|
||||
headers => [ qw(<stdio.h> "core/gimp.h") ],
|
||||
vars => [ "FILE *file" ],
|
||||
code => <<'CODE'
|
||||
{
|
||||
if ((procedural_db_out = fopen (filename, "w")))
|
||||
if ((file = fopen (filename, "w")))
|
||||
{
|
||||
g_hash_table_foreach (gimp->procedural_ht,
|
||||
procedural_db_print_entry, NULL);
|
||||
fclose (procedural_db_out);
|
||||
procedural_db_print_entry, file);
|
||||
fclose (file);
|
||||
}
|
||||
else
|
||||
success = FALSE;
|
||||
|
@ -281,26 +280,14 @@ HELP
|
|||
$outargs[0]->{void_ret} = 1;
|
||||
|
||||
%invoke = (
|
||||
vars => [ 'PDBData *data = NULL', 'GList *list' ],
|
||||
vars => [ 'const guint8 *data' ],
|
||||
code => <<'CODE'
|
||||
{
|
||||
success = FALSE;
|
||||
data = procedural_db_get_data (gimp, identifier, &bytes);
|
||||
success = (data != NULL);
|
||||
|
||||
list = data_list;
|
||||
while (list)
|
||||
{
|
||||
data = (PDBData *) list->data;
|
||||
list = list->next;
|
||||
|
||||
if (!strcmp (data->identifier, identifier))
|
||||
{
|
||||
data_copy = g_new (guint8, data->bytes);
|
||||
memcpy (data_copy, data->data, data->bytes);
|
||||
|
||||
success = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (success)
|
||||
data_copy = g_memdup (data, bytes);
|
||||
}
|
||||
CODE
|
||||
);
|
||||
|
@ -323,23 +310,11 @@ HELP
|
|||
@outargs = ( &data_bytes_arg );
|
||||
|
||||
%invoke = (
|
||||
vars => [ 'PDBData *data = NULL', 'GList *list' ],
|
||||
vars => [ 'const guint8 *data' ],
|
||||
code => <<'CODE'
|
||||
{
|
||||
success = FALSE;
|
||||
|
||||
list = data_list;
|
||||
while (list)
|
||||
{
|
||||
data = (PDBData *) list->data;
|
||||
list = list->next;
|
||||
|
||||
if (!strcmp (data->identifier, identifier))
|
||||
{
|
||||
success = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
data = procedural_db_get_data (gimp, identifier, &bytes);
|
||||
success = (data != NULL);
|
||||
}
|
||||
CODE
|
||||
);
|
||||
|
@ -359,38 +334,11 @@ HELP
|
|||
$date = '1997';
|
||||
|
||||
@inargs = ( &data_ident_arg, &data_arg );
|
||||
$inargs[1]->{alias} = 'data_src';
|
||||
$inargs[1]->{wrap} = 1;
|
||||
delete @{$inargs[1]->{array}}{qw(alias no_declare)};
|
||||
|
||||
%invoke = (
|
||||
vars => [ 'PDBData *data = NULL', 'GList *list' ],
|
||||
code => <<'CODE'
|
||||
{
|
||||
list = data_list;
|
||||
while (list)
|
||||
{
|
||||
if (!strcmp (((PDBData *) list->data)->identifier, identifier))
|
||||
data = (PDBData *) list->data;
|
||||
|
||||
list = list->next;
|
||||
}
|
||||
|
||||
/* If there isn't already data with the specified identifier, create one */
|
||||
if (data == NULL)
|
||||
{
|
||||
data = (PDBData *) g_new (PDBData, 1);
|
||||
data_list = g_list_append (data_list, data);
|
||||
}
|
||||
else
|
||||
g_free (data->data);
|
||||
|
||||
data->identifier = g_strdup (identifier);
|
||||
data->bytes = bytes;
|
||||
data->data = g_new (char, data->bytes);
|
||||
memcpy (data->data, (char *) data_src, data->bytes);
|
||||
}
|
||||
CODE
|
||||
code => 'procedural_db_set_data (gimp, identifier, bytes, data);'
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -414,18 +362,6 @@ struct _PDBQuery
|
|||
int num_procs;
|
||||
};
|
||||
|
||||
typedef struct _PDBData PDBData;
|
||||
|
||||
struct _PDBData
|
||||
{
|
||||
gchar *identifier;
|
||||
gint bytes;
|
||||
gchar *data;
|
||||
};
|
||||
|
||||
static FILE *procedural_db_out = NULL;
|
||||
static GList *data_list = NULL;
|
||||
|
||||
static gchar *proc_type_str[] =
|
||||
{
|
||||
N_("Internal GIMP procedure"),
|
||||
|
@ -460,10 +396,10 @@ procedural_db_query_entry (gpointer key,
|
|||
gpointer value,
|
||||
gpointer user_data)
|
||||
{
|
||||
GList *list;
|
||||
GList *list;
|
||||
ProcRecord *proc;
|
||||
PDBQuery *pdb_query;
|
||||
int new_length;
|
||||
PDBQuery *pdb_query;
|
||||
gint new_length;
|
||||
|
||||
list = (GList *) value;
|
||||
proc = (ProcRecord *) list->data;
|
||||
|
@ -491,24 +427,28 @@ procedural_db_query_entry (gpointer key,
|
|||
}
|
||||
|
||||
static void
|
||||
output_string (const char *string)
|
||||
output_string (FILE *file,
|
||||
const char *string)
|
||||
{
|
||||
fprintf (procedural_db_out, "\"");
|
||||
while (*string)
|
||||
{
|
||||
switch (*string)
|
||||
{
|
||||
case '\\' : fprintf (procedural_db_out, "\\\\"); break;
|
||||
case '\"' : fprintf (procedural_db_out, "\\\""); break;
|
||||
case '{' : fprintf (procedural_db_out, "@{"); break;
|
||||
case '@' : fprintf (procedural_db_out, "@@"); break;
|
||||
case '}' : fprintf (procedural_db_out, "@}"); break;
|
||||
default:
|
||||
fprintf (procedural_db_out, "%c", *string);
|
||||
}
|
||||
string++;
|
||||
}
|
||||
fprintf (procedural_db_out, "\"\n");
|
||||
fprintf (file, "\"");
|
||||
|
||||
if (string)
|
||||
while (*string)
|
||||
{
|
||||
switch (*string)
|
||||
{
|
||||
case '\\' : fprintf (file, "\\\\"); break;
|
||||
case '\"' : fprintf (file, "\\\""); break;
|
||||
case '{' : fprintf (file, "@{"); break;
|
||||
case '@' : fprintf (file, "@@"); break;
|
||||
case '}' : fprintf (file, "@}"); break;
|
||||
default:
|
||||
fprintf (file, "%c", *string);
|
||||
}
|
||||
string++;
|
||||
}
|
||||
|
||||
fprintf (file, "\"\n");
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -516,11 +456,17 @@ procedural_db_print_entry (gpointer key,
|
|||
gpointer value,
|
||||
gpointer user_data)
|
||||
{
|
||||
int i;
|
||||
ProcRecord *procedure;
|
||||
GList *list = (GList *) value;
|
||||
int num = 0;
|
||||
GString *buf = g_string_new ("");
|
||||
GString *buf;
|
||||
GList *list;
|
||||
FILE *file;
|
||||
gint i;
|
||||
gint num = 0;
|
||||
|
||||
list = (GList *) value;
|
||||
file = (FILE *) user_data;
|
||||
|
||||
buf = g_string_new ("");
|
||||
|
||||
while (list)
|
||||
{
|
||||
|
@ -528,48 +474,48 @@ procedural_db_print_entry (gpointer key,
|
|||
procedure = (ProcRecord*) list->data;
|
||||
list = list->next;
|
||||
|
||||
fprintf (procedural_db_out, "\n(register-procedure ");
|
||||
fprintf (file, "\n(register-procedure ");
|
||||
|
||||
if (list || num != 1)
|
||||
{
|
||||
g_string_printf (buf, "%s <%d>", procedure->name, num);
|
||||
output_string (buf->str);
|
||||
output_string (file, buf->str);
|
||||
}
|
||||
else
|
||||
output_string (procedure->name);
|
||||
output_string (file, procedure->name);
|
||||
|
||||
output_string (procedure->blurb);
|
||||
output_string (procedure->help);
|
||||
output_string (procedure->author);
|
||||
output_string (procedure->copyright);
|
||||
output_string (procedure->date);
|
||||
output_string (proc_type_str[(int) procedure->proc_type]);
|
||||
output_string (file, procedure->blurb);
|
||||
output_string (file, procedure->help);
|
||||
output_string (file, procedure->author);
|
||||
output_string (file, procedure->copyright);
|
||||
output_string (file, procedure->date);
|
||||
output_string (file, proc_type_str[(int) procedure->proc_type]);
|
||||
|
||||
fprintf (procedural_db_out, "( ");
|
||||
fprintf (file, "( ");
|
||||
for (i = 0; i < procedure->num_args; i++)
|
||||
{
|
||||
fprintf (procedural_db_out, "( ");
|
||||
fprintf (file, "( ");
|
||||
|
||||
output_string (procedure->args[i].name );
|
||||
output_string (type_str[procedure->args[i].arg_type]);
|
||||
output_string (procedure->args[i].description);
|
||||
output_string (file, procedure->args[i].name );
|
||||
output_string (file, type_str[procedure->args[i].arg_type]);
|
||||
output_string (file, procedure->args[i].description);
|
||||
|
||||
fprintf (procedural_db_out, " ) ");
|
||||
fprintf (file, " ) ");
|
||||
}
|
||||
fprintf (procedural_db_out, " ) ");
|
||||
fprintf (file, " ) ");
|
||||
|
||||
fprintf (procedural_db_out, "( ");
|
||||
fprintf (file, "( ");
|
||||
for (i = 0; i < procedure->num_values; i++)
|
||||
{
|
||||
fprintf (procedural_db_out, "( ");
|
||||
output_string (procedure->values[i].name );
|
||||
output_string (type_str[procedure->values[i].arg_type]);
|
||||
output_string (procedure->values[i].description);
|
||||
fprintf (file, "( ");
|
||||
output_string (file, procedure->values[i].name );
|
||||
output_string (file, type_str[procedure->values[i].arg_type]);
|
||||
output_string (file, procedure->values[i].description);
|
||||
|
||||
fprintf (procedural_db_out, " ) ");
|
||||
fprintf (file, " ) ");
|
||||
}
|
||||
fprintf (procedural_db_out, " ) ");
|
||||
fprintf (procedural_db_out, " ) ");
|
||||
fprintf (file, " ) ");
|
||||
fprintf (file, " ) ");
|
||||
}
|
||||
|
||||
g_string_free (buf, TRUE);
|
||||
|
|
Loading…
Reference in New Issue