[gimp] plug-ins: add progress updates to openraster load and save.
- From: Jacob Boerema <jboerema src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] plug-ins: add progress updates to openraster load and save.
- Date: Thu, 28 Jan 2021 00:09:24 +0000 (UTC)
commit 9d9f6e6240c4c91fb66290c91ee07c03c6c4ee94
Author: Jacob Boerema <jgboerema gmail com>
Date: Wed Jan 27 18:38:05 2021 -0500
plug-ins: add progress updates to openraster load and save.
Since openraster load and save is not very fast for multi layer
images it seems like a good idea to add progress update
support.
plug-ins/python/file-openraster.py | 25 ++++++++++++++++++++++++-
1 file changed, 24 insertions(+), 1 deletion(-)
---
diff --git a/plug-ins/python/file-openraster.py b/plug-ins/python/file-openraster.py
index d380e149a3..48efc9a2da 100755
--- a/plug-ins/python/file-openraster.py
+++ b/plug-ins/python/file-openraster.py
@@ -193,6 +193,7 @@ def save_ora(procedure, run_mode, image, n_drawables, drawables, file, args, dat
zi.external_attr = int("100644", 8) << 16
zfile.writestr(zi, data)
+ Gimp.progress_init("Exporting openraster image")
tempdir = tempfile.mkdtemp('gimp-plugin-file-openraster')
# use .tmpsave extension, so we don't overwrite a valid file if
@@ -272,7 +273,13 @@ def save_ora(procedure, run_mode, image, n_drawables, drawables, file, args, dat
# save layers
parent_groups = []
i = 0
- for lay in enumerate_layers(image.get_layers()):
+
+ layer_stack = image.get_layers()
+ # Number of top level layers for tracking progress
+ lay_cnt = len(layer_stack)
+
+ for lay in enumerate_layers(layer_stack):
+ prev_lay = i
if lay is NESTED_STACK_END:
parent_groups.pop()
continue
@@ -297,6 +304,9 @@ def save_ora(procedure, run_mode, image, n_drawables, drawables, file, args, dat
else:
add_layer(parent, x, y, opac, lay, path_name, lay.get_visible())
+ if (i > prev_lay):
+ Gimp.progress_update(i/lay_cnt)
+
# save mergedimage
thumb = image.duplicate()
thumb_layer = thumb.merge_visible_layers (Gimp.MergeType.CLIP_TO_IMAGE)
@@ -327,6 +337,8 @@ def save_ora(procedure, run_mode, image, n_drawables, drawables, file, args, dat
os.remove(file.peek_path()) # win32 needs that
os.rename(file.peek_path() + '.tmpsave', file.peek_path())
+ Gimp.progress_end()
+
return Gimp.ValueArray.new_from_values([
GObject.Value(Gimp.PDBStatusType, Gimp.PDBStatusType.SUCCESS)
])
@@ -336,6 +348,8 @@ def load_ora(procedure, run_mode, file, args, data):
orafile = zipfile.ZipFile(file.peek_path())
stack, w, h = get_image_attributes(orafile)
+ Gimp.progress_init("Loading openraster image")
+
img = Gimp.Image.new(w, h, Gimp.ImageBaseType.RGB)
img.set_file (file)
@@ -352,8 +366,12 @@ def load_ora(procedure, run_mode, file, args, data):
parent_groups = []
+ # Number of top level layers for tracking progress
+ lay_cnt = len(stack)
+
layer_no = 0
for item in get_layers(stack):
+ prev_lay = layer_no
if item is NESTED_STACK_END:
parent_groups.pop()
@@ -409,6 +427,11 @@ def load_ora(procedure, run_mode, file, args, data):
if gimp_layer.is_group():
parent_groups.append([gimp_layer, 0])
+ if (layer_no > prev_lay):
+ Gimp.progress_update(layer_no/lay_cnt)
+
+ Gimp.progress_end()
+
os.rmdir(tempdir)
return Gimp.ValueArray.new_from_values([
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]