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.

It should be 800x600 24bit greyscale.

The code I have written is attached with Makefile.

When I select the plugin in GIMP I get these errors:

Calling error for procedure 'gimp-drawable-width': Procedure
'gimp-drawable-width' has been called with an invalid ID for argument
'drawable'. Most likely a plug-in is trying to work on a layer that
doesn't exist any longer.

Calling error for procedure 'gimp-drawable-height': Procedure
'gimp-drawable-height' has been called with an invalid ID for argument
'drawable'. Most likely a plug-in is trying to work on a layer that
doesn't exist any longer.

Calling error for procedure 'gimp-drawable-bpp': Procedure
'gimp-drawable-bpp' has been called with an invalid ID for argument
'drawable'. Most likely a plug-in is trying to work on a layer that
doesn't exist any longer.

Can someone see what's wrong?

Lots of love,
Louise
#include <libgimp/gimp.h>

typedef struct {
  gint32    drawable_id;   /* drawable ID */
  guint     width;         /* width of drawble */
  guint     height;        /* height of drawble */
  guint     bpp;           /* bytes per pixel of drawable */
  guint     ntile_rows;    /* # of tile rows */
  guint     ntile_cols;    /* # of tile columns */
  GimpTile *tiles;         /* the normal tiles */
  GimpTile *shadow_tiles;  /* the shadow tiles */
} MyDrawable;

static void
query (void)
{
  static GimpParamDef args[] =
  {
    {
      GIMP_PDB_INT32,
      "run-mode",
      "Run mode"
    },
    {
      GIMP_PDB_IMAGE,
      "image",
      "Input image"
    },
    {
      GIMP_PDB_DRAWABLE,
      "drawable",
      "Input drawable"
    }
  };

  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;
  /* ??? */
  GimpDrawable     *drawable;


  /* 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;

  /* Do I open a new drawable on the screen like this? */
  MyDrawable d;

  d.drawable_id = 0;
  d.width = 800;
  d.height = 600;
  d.bpp = 24;
  d.ntile_rows = 1;
  d.ntile_cols = 1;
  d.tiles = NULL;
  d.shadow_tiles = NULL;

  /* ??? */
  /*  Get the specified drawable  */
  drawable = gimp_drawable_get (param[2].data.d_drawable);

  if (run_mode != GIMP_RUN_NONINTERACTIVE)
    g_message("Hello, world!\n");
}

GimpPlugInInfo PLUG_IN_INFO =
{
  NULL,
  NULL,
  query,
  run
};

MAIN()


Attachment: Makefile
Description: Binary data

_______________________________________________
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer

Reply via email to