marking a document/image as dirty/changed in a plugin
I'm writing a plugin that adds some metadata to an image (gimp document).
The metadata is added as a "parasite".
I can see in the api, libgimp/gimpimage_pdb.h, how you can test if an image
is dirty, via gimp_image_is_dirty(image_id). I can also see how you can
mark an image as clean (gimp_image_clean_all(image_id). But i don't see
how you can mark an image as dirty. I would like to do this so that if you
attempt to close an image without saving, gimp will ask you to save your
I'm adding the metadata using gimp_image_attach_parasite( image_id,
I'm using the c interface, although i imagine any language will face
> On Fri, 2019-11-08 at 18:40 -0800, Dan Hitt via gimp-developer-list
> > But i don't
> > see
> > how you can mark an image as dirty.
> Write some data to the image?
> E.g. read a pixel and write it back again?
> > I'm using gimp 2.10.8 on debian 10.
> You might want to update to 2.10.14. the current version.
> slave ankh
> Liam Quin - web slave for https://www.fromoldbooks.org/ > with fabulous vintage art and fascinating texts to read.
Thanks for your mail.
Your method sounds like it should work, and i absolutely have to be able to
read and write pixels in order for my plugin to do what i want.
Now, for the limited purpose of just having the image show up as dirty when
metadata is written as a parasite, i eventually discovered that it suffices
to pass in the flag GIMP_PARASITE_UNDOABLE in when the parasite is created
by gimp_parasite_new(....). And the comments in the internals
(gimpimage.c) advise you to never call (in all caps) gimp_image_dirty()
directly, and that instead, push an undo operation on the stack. It makes
sense i guess, and certainly explains why there seems to be no external
interface to directly set the image dirty.
So that leaves me with two holes. One is that although i've declared my
parasite to be undoable, i haven't provided any means to actually undo it.
So that's kind of bad, although the parasite info is not the main event
that i hope to do in my plugin.
The other hole is that i find that so far i cannot read and write a pixel.
The obvious looking calls, for example, as used in the basic tutorial
https://developer.gimp.org/writing-a-plug-in/2/index.html, are now marked
deprecated. So to properly do this simple operation of reading and writing
a pixel, one should go through the gegl interface. That i have not done,
but obviously i need to.
Anyhow, thanks again for your help, and if you or anybody knows of some
easy tutorials on using the gegl apparatus, please let me know and tia.
(And glad you get to mess around with scanning and enjoying old books ---
the mustiness may not be so great, but it sounds like a great way to be in
touch with your roots!)
> On 11/10/19 5:23 AM, Dan Hitt via gimp-developer-list wrote:
> > The other hole is that i find that so far i cannot read and write a
> > pixel.
> From my experiments:
> - start an "undo group": this marks the image "dirty"
> - attach an "undoable" parasite
> - end the undo group and exit
> At that point if you list the parasites you find the one that was added
> If you then Ctrl-Z and list the parasites the added parasite is gone.
> <<< clipped >>>
Awesome, thank you so much Ofnuts!
It works in c as well, exactly as you describe, solving both the problem of
getting the document marked dirty, as well as providing a means for undoing
it. This it fills in that first hole that i had.