Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Development

Notices

Reply
 
Thread Tools Search this Thread
Old 08-14-2013, 11:20 AM   #1
AlPe
Digital Amanuensis
AlPe ought to be getting tired of karma fortunes by now.AlPe ought to be getting tired of karma fortunes by now.AlPe ought to be getting tired of karma fortunes by now.AlPe ought to be getting tired of karma fortunes by now.AlPe ought to be getting tired of karma fortunes by now.AlPe ought to be getting tired of karma fortunes by now.AlPe ought to be getting tired of karma fortunes by now.AlPe ought to be getting tired of karma fortunes by now.AlPe ought to be getting tired of karma fortunes by now.AlPe ought to be getting tired of karma fortunes by now.AlPe ought to be getting tired of karma fortunes by now.
 
AlPe's Avatar
 
Posts: 727
Karma: 1446357
Join Date: Dec 2011
Location: Turin, Italy
Device: Several eReaders and tablets
Capturing a GUI event

Hi,

is there a way of capturing a GUI event (like "the user clicked on button X" or "the user sent book to device") to trigger the execution of some code (after the "default" action has been completed)?
AlPe is offline   Reply With Quote
Old 08-14-2013, 11:35 AM   #2
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,896
Karma: 22666668
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
You can do pretty much anything you want in a plugin. plugin code executes in the same context as normal calibre code, so anything normal code can do, you can do.

If you have some specific event you want to track, ask about it.
kovidgoyal is offline   Reply With Quote
Advert
Old 08-15-2013, 11:56 AM   #3
AlPe
Digital Amanuensis
AlPe ought to be getting tired of karma fortunes by now.AlPe ought to be getting tired of karma fortunes by now.AlPe ought to be getting tired of karma fortunes by now.AlPe ought to be getting tired of karma fortunes by now.AlPe ought to be getting tired of karma fortunes by now.AlPe ought to be getting tired of karma fortunes by now.AlPe ought to be getting tired of karma fortunes by now.AlPe ought to be getting tired of karma fortunes by now.AlPe ought to be getting tired of karma fortunes by now.AlPe ought to be getting tired of karma fortunes by now.AlPe ought to be getting tired of karma fortunes by now.
 
AlPe's Avatar
 
Posts: 727
Karma: 1446357
Join Date: Dec 2011
Location: Turin, Italy
Device: Several eReaders and tablets
Thanks for the quick reply.

I would like to modify a custom metadatum field for a library entry whenever I "send to device" it. So far, I understand that I can achieve that by writing a device plugin, but I have multiple eReaders and I do not want to write a plugin for each of them. Hence, my original request.

I am still confused on how can I capture the "send to device" event, in order to trigger the execution of my own code. I looked at the plugins in the official index, but I was not able to identify one which might do something similar to what I need. Would you mind suggesting one, please?
AlPe is offline   Reply With Quote
Old 08-15-2013, 12:29 PM   #4
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,896
Karma: 22666668
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
I doubt there's any existing plugin that does that. You will basically need to hook into the books_uploaded function defined in gui2/device.py

The easiest way is to simply replace that function with your own, something like

self.original_books_uploaded = self.gui.books_uploaded
self.gui.books_upload = self.my_books_uploaded

def my_books_uploaded(self, job):
self.original_books_uploaded(job)
# do whatever you want to do

There maybe some function binding issues you will have to deal with, basically ensure that self is the right object in every context. A bit of googling about python monkey patching should tell you how.
kovidgoyal is offline   Reply With Quote
Old 08-15-2013, 12:37 PM   #5
AlPe
Digital Amanuensis
AlPe ought to be getting tired of karma fortunes by now.AlPe ought to be getting tired of karma fortunes by now.AlPe ought to be getting tired of karma fortunes by now.AlPe ought to be getting tired of karma fortunes by now.AlPe ought to be getting tired of karma fortunes by now.AlPe ought to be getting tired of karma fortunes by now.AlPe ought to be getting tired of karma fortunes by now.AlPe ought to be getting tired of karma fortunes by now.AlPe ought to be getting tired of karma fortunes by now.AlPe ought to be getting tired of karma fortunes by now.AlPe ought to be getting tired of karma fortunes by now.
 
AlPe's Avatar
 
Posts: 727
Karma: 1446357
Join Date: Dec 2011
Location: Turin, Italy
Device: Several eReaders and tablets
Got it, thanks.
AlPe is offline   Reply With Quote
Advert
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Capturing screen shot from NC Rebo Nook Color & Nook Tablet 3 11-26-2010 03:06 PM
capturing text overlaid/within non-rectangular images CharlesinCharge ePub 2 10-27-2010 04:53 AM
Regex capturing variables Lonas Sigil 9 08-14-2010 03:05 PM
700 or K2 for highlighting, capturing & take notes + whole family Douglasco Which one should I buy? 7 02-25-2009 08:46 AM
Entertaining, capturing and inspiring soul teaser irapas1 Reading Recommendations 0 10-25-2003 07:15 AM


All times are GMT -4. The time now is 07:56 AM.


MobileRead.com is a privately owned, operated and funded community.