View Single Post
Old 12-28-2020, 03:16 PM   #213
capink
Wizard
capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.
 
Posts: 1,203
Karma: 1995558
Join Date: Aug 2015
Device: Kindle
Event Manager

The new event manager gives the user the ability to make chains run automatically in response to events. Events can be either builtin or user-defined. See example below for how to write custom events.

The plugin currently ships with these builtin events:
  • Library Changed
  • Location Selected
  • Device Connected
  • Device Disconnected
  • Book List Double Clicked
  • Book List Enter Pressed
  • Calibre Initialized
  • Timer
  • Shutting Down
  • VL Tab Changed


    Quote:
    N.B This timer is activated every 5 minutes (can be configured by: Preferences > Plugins > Action Chains > Customize Plugin) for chains that should do automatic tasks at regular intervals.

This new event manager was made possible by the introduction of the conditions dialog, because running chains in response to events without reining them with conditions would have been impractical. See this post for more on how to set conditions for chains.

Events can pass arguments that are stored in a chain variable called _event_args. Currently only these Events pass arguments:
  • Book List Double Clicked: book_id, column_name
  • Book List Enter Pressed: book_id, column_name
  • VL Tab Changed: current_vl, previous_vl


Here is an example of how to add extra events using the plugin's module editor, you do it by returning the signal associated with the event.

Code:
from calibre_plugins.action_chains.events import ChainEvent

class SearchChanged(ChainEvent):

    # replace with the name of your event
    name = 'Search Changed'

    def get_event_signal(self):
        return self.gui.search.changed
Note1: Be careful with what events you are adding, events that repeat so often (e.g selections changes) are not good candidate for linking to action chains.

Note2: The event manager does not respond to any events that happen when chains or other events are running.

Last edited by capink; 02-26-2025 at 04:37 PM.
capink is offline   Reply With Quote