I'm trying to create some GIMP plug-in and here I have gtk FileDialog:
chooser = gtk.FileChooserDialog(title="Save as...",
action=gtk.FILE_CHOOSER_ACTION_SAVE,
buttons=(gtk.STOCK_SAVE,
gtk.RESPONSE_OK,
gtk.STOCK_CANCEL,
gtk.RESPONSE_CANCEL))
chooser.set_do_overwrite_confirmation(True)
I want to set current folder of the FileChoserDialog to the last used directory, like that
chooser.set_current_folder(">>>>>HERE I NEED THE DIRECTORY OF THE LAST SAVED IMAGE<<<<<<<<")
How could I do that?
The only thing I came up with is to save filenames to image.filename and then purge it.
chooser.set_current_folder(choose_set_dir())
response = chooser.run()
filename = chooser.get_filename()
chooser.destroy()
if response == gtk.RESPONSE_OK
<...>
pdb.file_jpeg_save(image, drawable, filename, filename, 0.9, 0, 0, 0, "", 2, 1, 0, 0)
clear_filenames()
image.filename = filename
image.clean_all()
def choose_set_dir():
for img in gimp.image_list():
if img.filename:
return path.dirname(img.filename)
return path.expanduser("~/Desktop")
def clear_filenames():
for img in gimp.image_list():
if img.filename:
img.filename = ""
But it's some sort of hack, and I'd like to get things right way.