From e27fa0edae8e86d14bc1427f61eb82d0685cec9a Mon Sep 17 00:00:00 2001 From: seebye Date: Fri, 16 Aug 2019 01:47:19 +0200 Subject: [PATCH] add option to disable automatic command transmission --- README.md | 12 +++++++----- ueberzug/lib/v0/__init__.py | 6 ++++-- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index cad364b..6d98c5b 100644 --- a/README.md +++ b/README.md @@ -199,17 +199,19 @@ import ueberzug.lib.v0 as ueberzug Methods: - | Name | Returns | Description | - |------------------|--------------|--------------------------------------| - | create_placement | Placement | prevents the use of the same identifier multiple times,
takes the same arguments as the Placement constructor (excluding canvas parameter) | - | \_\_call\_\_ | Function | Decorator which returns a function which calls the decorated function with the keyword parameter canvas=this_canvas_object.
Of course other arguments are also passed through. | + | Name | Returns | Description | + |----------------------|--------------|--------------------------------------| + | create_placement | Placement | prevents the use of the same identifier multiple times,
takes the same arguments as the Placement constructor (excluding canvas parameter) | + | \_\_call\_\_ | Function | Decorator which returns a function which calls the decorated function with the keyword parameter canvas=this_canvas_object.
Of course other arguments are also passed through. | + | request_transmission | - | Transmits queued commands if automatic\_transmission is enabled or force=True is passed as keyword argument. | - Properties: + Properties / Attributes: | Name | Type | Setter | Description | |---------------|-------------------------|--------|--------------------------------------| | lazy_drawing | context manager factory | No | prevents the transmission of commands till the with-statement was left
`with canvas.lazy_drawing: pass`| | synchronous_lazy_drawing | context manager factory | No | Does the same as lazy_drawing. Additionally forces the redrawing of the windows to happen immediately. | + | automatic\_transmission | bool | Yes | Transmit commands instantly on changing a placement. If it's disabled commands won't be transmitted till a lazy_drawing or synchronous_lazy_drawing with-statement was left or request_transmission(force=True) was called. Default: True | diff --git a/ueberzug/lib/v0/__init__.py b/ueberzug/lib/v0/__init__.py index adb1814..3254294 100644 --- a/ueberzug/lib/v0/__init__.py +++ b/ueberzug/lib/v0/__init__.py @@ -309,6 +309,7 @@ class Canvas: self.__process = None self.__transmitter = None self.__used_identifiers = set() + self.automatic_transmission = True def create_placement(self, identifier, *args, **kwargs): """Creates a placement associated with this canvas. @@ -390,9 +391,10 @@ class Canvas: self.__transmitter.enqueue(command) - def request_transmission(self): + def request_transmission(self, *, force=False): """Requests the transmission of every command in the queue.""" if not self.__process.responsive: self.__process.start() - self.__transmitter.transmit() + if self.automatic_transmission or force: + self.__transmitter.transmit()