I think you need to allocate the return vals (the pointeryou get from the args is to let you tell the caller where the return vals are...like this: static GimpParam values[1]; *nreturn_vals = 0; *return_vals = values; values[0].type = GIMP_PDB_STATUS; values[0].data.d_status = GIMP_PDB_SUCCESS; > > Hi all, > > I'm trying to write a plug-in for the gimp, but I'm having a few > problems. I think at this stage it's pretty bare-bones, pretty much a > hello world plug-in. > > Anyway, my plug-in is detected at start-up by the Gimp, and registers > with the PDB etc - so I suspect that my query function is OK. > > When it's forked again to run, I get in a bit of trouble. On 1.1.28, it > just barf about the internal failure of the plug-in, and how that could > cause transmogrification of good, unsaved data. On 1.1.24, the widget (a > dialog) displays, but it, and the gimp, disappear when I click on it... > I did a stack-trace on teh core, and it looks like I got into an > infinite loop with _dl_runtime_resolve and __restore calling each other > a few hundred times, when gimp_ui_init starts up, until the process ran > out of memory. > > Anyway, I was wondering if someone would have a quick perusal and point > me in the direction of my stupidity. Or point me to a "hello, world!" > gimp plug-in, or point me in the direction of references I might find > useful, other than "Writing a GIMP Plug-in" by Kevin Turner, which is > what I have been working out of so far. > > Just in case the problem is actually in the query function (in > gimp_install_procedure, maybe?) I have included that. In fact, the only > stuff I haven't included are header includes and global vars (of which > there is only one, PLUG_IN_INFO). I realise this is kind of long, > especially for a first post, but I hope you'll give me a bit of > lattitude. > > Thanks a lot, > Dave Neary. > > -- > Dave Neary, > Software engineer, Informix Dublin. > Ireland. > Phone: +353-1-409-1357 > > ****** Code segment starts here *********** > > /* query() function. Sets up type of plug-in in the PDB. > */ > static void query(void) > { > /* We want to define the arguments this will take, > * and what it will return - eventually this will include more > * complicated stuff, for now it accepts the defaults, and returns > * SUCCESS > */ > > static GimpParamDef args[]= > { > { GIMP_PDB_INT32, "run_mode", "Interactive, non-interactive" }, > { GIMP_PDB_IMAGE, "image_id", "(unused)" }, > { GIMP_PDB_DRAWABLE, "drawable_id", "Input drawable" }, > }; > static gint nargs = sizeof (args) / sizeof (args[0]); > > /* We need to register the module - we do this with > * gimp_install_procedure. > */ > > gimp_install_procedure("plug_in_hello", > "Prints a message", > "For no good reason this plug-in only accepts greyscale images", > "David Neary (dneary@xxxxxxxxxxxx)", > "David Neary (dneary@xxxxxxxxxxxx)", > "2000", > "<Image>/Filters/Render/Pattern/Hello", > "GRAY", > GIMP_PLUGIN, > nargs,0, > args,NULL); > > } > > static void run(gchar *name, > gint nparams, > GimpParam *param, > gint *nreturn_vals, > GimpParam **return_vals) > { > > /* We'll add a couple of widgets and show them (a dialog titled > * Hello, world! or something equally original should do) > */ > GtkWidget *dlg; > GtkWidget *frame; > GtkWidget *greeting; > GimpPDBStatusType status = GIMP_PDB_SUCCESS; > > *nreturn_vals=1; > (*return_vals)->type = GIMP_PDB_STATUS; > ((*return_vals)->data).d_status = status; > > gimp_ui_init ("hello", FALSE); > > dlg = gimp_dialog_new ("Hello, world!", "hello", > gimp_standard_help_func, > MY_ARBITRARY_HTML_FILE, > GTK_WIN_POS_MOUSE, > FALSE, TRUE, FALSE, > > "OK", check_ok_callback, > NULL, NULL, NULL, TRUE, FALSE, > "Cancel", gtk_widget_destroy, > NULL, 1, NULL, FALSE, TRUE, > > NULL); > > frame = gtk_frame_new ("Greeting"); > gtk_frame_set_shadow_type (GTK_FRAME (frame), > GTK_SHADOW_ETCHED_IN); > gtk_container_set_border_width (GTK_CONTAINER(frame), 6); > gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dlg)->vbox), frame, TRUE, > TRUE, 0); > gtk_widget_show(frame); > > greeting = gtk_entry_new (); > gtk_entry_set_text( GTK_ENTRY(greeting),"Hello, world!"); > gtk_entry_set_editable( GTK_ENTRY(greeting), FALSE); > gtk_container_add(GTK_CONTAINER(frame), greeting); > gtk_widget_show(greeting); > > gtk_widget_show(dlg); > > gtk_main (); > gdk_flush (); > > return; > } > > /* Callback function for when the OK button is clicked. */ > > void check_ok_callback(GtkWidget *button, GtkWidget *entry) > { > gchar *entry_text; > entry_text = gtk_entry_get_text(GTK_ENTRY(entry)); > printf("Entry contents: %s\n", entry_text); > return; > } >