Re: [Gimp-developer] marking a document/image as dirty/changed in a plugin

2019-11-11 Thread Dan Hitt via gimp-developer-list
On Mon, Nov 11, 2019 at 1:40 AM Ofnuts  wrote:

> 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.

dan
___
gimp-developer-list mailing list
List address:gimp-developer-list@gnome.org
List membership: https://mail.gnome.org/mailman/listinfo/gimp-developer-list
List archives:   https://mail.gnome.org/archives/gimp-developer-list


Re: [Gimp-developer] marking a document/image as dirty/changed in a plugin

2019-11-11 Thread Ofnuts

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.



Actual Python code used in the Pyhon console:

>>> # Assumes you have only a single image loaded

>>> image=gimp.image_list()[0]

>>> # when you enter the line below, the title bar gets an '*'
indicating a dirty image

>>> image.undo_group_start()

>>> Check dirtiness with API

>>> image.dirty
True
>>> p=gimp.Parasite('foo',PARASITE_UNDOABLE,'bar')
>>> image.parasite_attach(p)
>>> image.undo_group_end()
>>> image.parasite_list()
('gimp-comment', 'jpeg-settings', 'foo')

>>> Now undo with Ctrl-Z in the image window, and retest the parasites:

>>> image.parasite_list()
('gimp-comment', 'jpeg-settings')

___
gimp-developer-list mailing list
List address:gimp-developer-list@gnome.org
List membership: https://mail.gnome.org/mailman/listinfo/gimp-developer-list
List archives:   https://mail.gnome.org/archives/gimp-developer-list


Re: [Gimp-developer] marking a document/image as dirty/changed in a plugin

2019-11-09 Thread Liam R E Quin
On Sat, 2019-11-09 at 20:23 -0800, Dan Hitt wrote:
> .  So to properly do this simple operation of reading and
> writing
> a pixel, one should go through the gegl interface. 

You could look at the source for existing plugins, especially in
2.10.14, for examples.


> (And glad you get to mess around with scanning and enjoying old books

:-) thank you sir. so am i! And i process the scans with GIMP :D


-- 
Liam Quin - web slave for https://www.fromoldbooks.org/
with fabulous vintage art and fascinating texts to read.
Click here to have the slave beaten.

___
gimp-developer-list mailing list
List address:gimp-developer-list@gnome.org
List membership: https://mail.gnome.org/mailman/listinfo/gimp-developer-list
List archives:   https://mail.gnome.org/archives/gimp-developer-list


Re: [Gimp-developer] marking a document/image as dirty/changed in a plugin

2019-11-09 Thread Dan Hitt via gimp-developer-list
On Fri, Nov 8, 2019 at 7:53 PM Liam R E Quin  wrote:

> On Fri, 2019-11-08 at 18:40 -0800, Dan Hitt via gimp-developer-list
> wrote:
> >  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.
>

Hi Liam,

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!)

dan
___
gimp-developer-list mailing list
List address:gimp-developer-list@gnome.org
List membership: https://mail.gnome.org/mailman/listinfo/gimp-developer-list
List archives:   https://mail.gnome.org/archives/gimp-developer-list


Re: [Gimp-developer] marking a document/image as dirty/changed in a plugin

2019-11-08 Thread Liam R E Quin
On Fri, 2019-11-08 at 18:40 -0800, Dan Hitt via gimp-developer-list
wrote:
>  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.

___
gimp-developer-list mailing list
List address:gimp-developer-list@gnome.org
List membership: https://mail.gnome.org/mailman/listinfo/gimp-developer-list
List archives:   https://mail.gnome.org/archives/gimp-developer-list


[Gimp-developer] marking a document/image as dirty/changed in a plugin

2019-11-08 Thread Dan Hitt via gimp-developer-list
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
image first.

I'm adding the metadata using gimp_image_attach_parasite( image_id,
parasite).

I'm using the c interface, although i imagine any language will face
similar issues.

I'm using gimp 2.10.8 on debian 10.

Thanks in advance for any info or advice.

dan
___
gimp-developer-list mailing list
List address:gimp-developer-list@gnome.org
List membership: https://mail.gnome.org/mailman/listinfo/gimp-developer-list
List archives:   https://mail.gnome.org/archives/gimp-developer-list