summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Schwarz <michi.schwarz@gmail.com>2018-05-05 14:19:26 +0200
committerMichael Schwarz <michi.schwarz@gmail.com>2018-05-05 14:22:24 +0200
commit69f08a3e741abcd36ef65047677d0e6eb1ce6482 (patch)
treeb0a3631cbb1f8221cbe684286880429c2a36bff6
parent3566dbc9438935d7cc6951a882a9d2ca148fb58d (diff)
downloadpogojig-69f08a3e741abcd36ef65047677d0e6eb1ce6482.tar.gz
pogojig-69f08a3e741abcd36ef65047677d0e6eb1ce6482.tar.bz2
pogojig-69f08a3e741abcd36ef65047677d0e6eb1ce6482.zip
Slight refactoring
-rw-r--r--support/inkscape/inkscape.py24
1 files changed, 13 insertions, 11 deletions
diff --git a/support/inkscape/inkscape.py b/support/inkscape/inkscape.py
index dee1542..3a25a15 100644
--- a/support/inkscape/inkscape.py
+++ b/support/inkscape/inkscape.py
@@ -80,23 +80,25 @@ class InkscapeCommandLine(object):
target_index = self._layers.index(layer)
- if self._current_layer_index < target_index:
- for _ in range(target_index - self._current_layer_index):
- self.apply_to_document(
- 'LayerMoveToNext' if with_selection else 'LayerNext')
- elif self._current_layer_index > target_index:
- for _ in range(self._current_layer_index - target_index):
- self.apply_to_document(
- 'LayerMoveToPrev' if with_selection else 'LayerPrev')
+ if with_selection:
+ next_command = 'LayerMoveToNext'
+ previous_command = 'LayerMoveToPrev'
else:
- return
+ next_command = 'LayerNext'
+ previous_command = 'LayerPrev'
+
+ while self._current_layer_index != target_index:
+ if self._current_layer_index < target_index:
+ self.apply_to_document(next_command)
+ self._current_layer_index += 1
+ else:
+ self.apply_to_document(previous_command)
+ self._current_layer_index -= 1
if with_selection:
# When using LayerMoveToNext and LayerMoveToPrev, inkscape does
# not reliably select the next/previous layer.
self._current_layer_index = None
- else:
- self._current_layer_index = target_index
def duplicate_layer(self, layer):
self.apply_to_layer(layer, 'LayerDuplicate')