Gimptalk - Premier Gimp Community: Getting a callback when an image is saved... - Gimptalk - Premier Gimp Community

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Getting a callback when an image is saved...

#1 User is offline   ragtag 

  • Member
  • PipPip
  • Group: Members
  • Posts: 74
  • Joined: 28-December 08

Posted 20 December 2011 - 02:51 AM

I'm working on an plug-in for managing comic book pages in GIMP, and have one thing I just can't figure out from the GIMP docs.

The plug-in is a PyGTK window that loads thumbnails of all the pages of a comic book and lets you manage them. You can double click on any of the thumbnails, and the page loads up in the GIMP (the pages are just .xcf files). This all works fine, but when the user Saves the image a new thumbnail is generated, but my plug-in doesn't know about this. Is there some kind of call back or message I can get from GIMP when a file is saved. All I really need is the name of the file, and that it has been saved, so I can have my plug-in reload the thumbnail.

I know I could do this in a hacky way, by having my plug-in spy on the modification dates of the thumbnails and images/pages at regular intervals, but I figure there must be a better way. :)
Posted Image
Depending on where you work, site may be not safe for work. :)
0

#2 User is offline   ofnuts 

  • Moderator GT
  • Group: Moderators
  • Posts: 1,237
  • Joined: 17-October 10
  • LocationLooking over your shoulder :)

Posted 20 December 2011 - 09:49 AM

View Postragtag, on 20 December 2011 - 02:51 AM, said:

I'm working on an plug-in for managing comic book pages in GIMP, and have one thing I just can't figure out from the GIMP docs.

The plug-in is a PyGTK window that loads thumbnails of all the pages of a comic book and lets you manage them. You can double click on any of the thumbnails, and the page loads up in the GIMP (the pages are just .xcf files). This all works fine, but when the user Saves the image a new thumbnail is generated, but my plug-in doesn't know about this. Is there some kind of call back or message I can get from GIMP when a file is saved. All I really need is the name of the file, and that it has been saved, so I can have my plug-in reload the thumbnail.

I know I could do this in a hacky way, by having my plug-in spy on the modification dates of the thumbnails and images/pages at regular intervals, but I figure there must be a better way. :)
I doubt there is such a plugin. The best you can do is define you own save action that saves the file at sends a notification (you can attach this action to Ctrl-S...). On Linux you may be able to receive standard file systems notifications (this would also let you detect files copied/moved outside of Gimp)(I assume there is a Python lib for this somewhere).
010011110110011001101110011101010111010001110011
0

#3 User is offline   ragtag 

  • Member
  • PipPip
  • Group: Members
  • Posts: 74
  • Joined: 28-December 08

Posted 21 December 2011 - 02:06 AM

Thanks. That's what I thought. Though I found a way to do it that is not too bad. I run:

# self here is the gtk.Window I'm using.
self.connect('notify::is-active', self.update_thumbs)


This way, I only update the thumbs when the window receives focus (you Alt-Tab to it or similar). This means the thumbs won't update if you have a big screen, and can fit it beside the rest of GIMP while you're working....but I don't see that as a big problem. :)
Posted Image
Depending on where you work, site may be not safe for work. :)
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic