TL;DR: How to open an Image in Gimp with Python like you do with (File->Open) in order to get the Overwrite file.png
option and avoid the Save the changes to image 'sample.png' before closing?
Dialog.
I wrote a Python script for Gimp which does a few modifications on a selected area, and then saves it as a PNG. After that I want to open the file so the user can check, whether everything is correct or change something. Since the users of the plugin dont necessarily know how to use Gimp, so the "Save the changes to image 'sample.png' before closing?"
Dialog might be confusing.
The method I currently use is
pdb.file_png_save(image, drw, new_file, new_file,0,9,0,0,0,0,0)
gimp.Display(pdb.gimp_file_load(new_file, new_file))
Have a look at gimp_image_clean_all. This resets the image's dirty flag and allows it to be closed.
Note that you can't prevent it from being set again if the users change something in the image.