Louise Hoffman wrote:
Dear developers,
I am trying to make a GIMP plugin that can open a new drawable on the
screen. Just like when you make one from File->New.
Hi!
You can't show a drawable by itself, it needs to be in an image. Also,
an image can't show itself, you must create a display for that. You are
also using the API in weird ways, for example, objects such as layers
and images are represented by integers in the plug-in context.
You are also saying that the plug-in takes the active image and drawable
as parameter, but since you are creating a new image, you are not
interested in those values (I assume) so there is no point in specifying
these as arguments to the hello-world procedure.
I have attached a rewritten version of main.c (called hello-world.c
since that is a name that doesn't conflict as much) that should do what
you want. You might also want to consider using a scripting language
like Scheme or Python for this.
/ Martin
--
My GIMP Blog:
http://www.chromecode.com/
"Reducing UI clutter, docking bars removed"
#include <libgimp/gimp.h>
static void
query (void)
{
static GimpParamDef args[] =
{
{
GIMP_PDB_INT32,
"run-mode",
"Run mode"
},
};
gimp_install_procedure (
"plug-in-hello",
"Hello, world!",
"Displays \"Hello, world!\" in a dialog",
"David Neary",
"Copyright David Neary",
"2004",
"_Hello world...",
NULL,
GIMP_PLUGIN,
G_N_ELEMENTS (args), 0,
args, NULL);
gimp_plugin_menu_register ("plug-in-hello",
"<Image>/Filters/Misc");
}
static void
run (const gchar *name,
gint nparams,
const GimpParam *param,
gint *nreturn_vals,
GimpParam **return_vals)
{
static GimpParam values[1];
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
GimpRunMode run_mode;
gint32 image;
gint32 layer;
gint32 display;
/* Setting mandatory output values */
*nreturn_vals = 1;
*return_vals = values;
values[0].type = GIMP_PDB_STATUS;
values[0].data.d_status = status;
/* Getting run_mode - we won't display a dialog if
* we are in NONINTERACTIVE mode */
run_mode = param[0].data.d_int32;
image = gimp_image_new (800, 600, GIMP_RGB);
layer = gimp_layer_new (image,
"foo",
800, 600,
GIMP_RGBA_IMAGE,
100.0,
GIMP_NORMAL_MODE);
gimp_image_add_layer (image, layer, 0);
display = gimp_display_new (image);
if (run_mode != GIMP_RUN_NONINTERACTIVE)
g_message("Hello, world!\n");
}
GimpPlugInInfo PLUG_IN_INFO =
{
NULL,
NULL,
query,
run
};
MAIN()
_______________________________________________
Gimp-developer mailing list
Gimp-developer@xxxxxxxxxxxxxxxxxxxxxx
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer