mirror of
https://gitlab.gnome.org/GNOME/gimp.git
synced 2025-07-04 17:59:37 +00:00
plug-ins: Fix incomplete port of file-openraster.
This fixes #5838 which was caused by an incomplete port of this plug-in to the new introspection API. For now we do keep the n_drawables parameter of save_ora until issue #5312 is fixed. Not doing this would cause saving to fail.
This commit is contained in:
parent
6830cbe92f
commit
dbc198001e
1 changed files with 15 additions and 15 deletions
|
@ -96,7 +96,6 @@ def thumbnail_ora(procedure, file, thumb_size, args, data):
|
||||||
GObject.Value(GObject.TYPE_STRING, tmp),
|
GObject.Value(GObject.TYPE_STRING, tmp),
|
||||||
])
|
])
|
||||||
img = img.index(1)
|
img = img.index(1)
|
||||||
img = Gimp.Image.get_by_id(img)
|
|
||||||
# TODO: scaling
|
# TODO: scaling
|
||||||
os.remove(tmp)
|
os.remove(tmp)
|
||||||
os.rmdir(tempdir)
|
os.rmdir(tempdir)
|
||||||
|
@ -110,7 +109,10 @@ def thumbnail_ora(procedure, file, thumb_size, args, data):
|
||||||
GObject.Value(GObject.TYPE_INT, 1)
|
GObject.Value(GObject.TYPE_INT, 1)
|
||||||
])
|
])
|
||||||
|
|
||||||
def save_ora(procedure, run_mode, image, drawable, file, args, data):
|
# We would expect the n_drawables parameter to not be there with introspection but
|
||||||
|
# currently that isn't working, see issue #5312. Until that is resolved we keep
|
||||||
|
# this parameter here or else saving would fail.
|
||||||
|
def save_ora(procedure, run_mode, image, n_drawables, drawables, file, args, data):
|
||||||
def write_file_str(zfile, fname, data):
|
def write_file_str(zfile, fname, data):
|
||||||
# work around a permission bug in the zipfile library:
|
# work around a permission bug in the zipfile library:
|
||||||
# http://bugs.python.org/issue3394
|
# http://bugs.python.org/issue3394
|
||||||
|
@ -140,9 +142,9 @@ def save_ora(procedure, run_mode, image, drawable, file, args, data):
|
||||||
Gimp.get_pdb().run_procedure('file-png-save', [
|
Gimp.get_pdb().run_procedure('file-png-save', [
|
||||||
GObject.Value(Gimp.RunMode, Gimp.RunMode.NONINTERACTIVE),
|
GObject.Value(Gimp.RunMode, Gimp.RunMode.NONINTERACTIVE),
|
||||||
GObject.Value(Gimp.Image, image),
|
GObject.Value(Gimp.Image, image),
|
||||||
GObject.Value(Gimp.Drawable, drawable),
|
GObject.Value(GObject.TYPE_INT, 1),
|
||||||
GObject.Value(GObject.TYPE_STRING, tmp),
|
GObject.Value(Gimp.ObjectArray, Gimp.ObjectArray.new(Gimp.Drawable, [drawable], 1)),
|
||||||
GObject.Value(GObject.TYPE_STRING, 'tmp.png'),
|
GObject.Value(Gio.File, Gio.File.new_for_path(tmp)),
|
||||||
GObject.Value(GObject.TYPE_BOOLEAN, interlace),
|
GObject.Value(GObject.TYPE_BOOLEAN, interlace),
|
||||||
GObject.Value(GObject.TYPE_INT, compression),
|
GObject.Value(GObject.TYPE_INT, compression),
|
||||||
# write all PNG chunks except oFFs(ets)
|
# write all PNG chunks except oFFs(ets)
|
||||||
|
@ -151,8 +153,11 @@ def save_ora(procedure, run_mode, image, drawable, file, args, data):
|
||||||
GObject.Value(GObject.TYPE_BOOLEAN, False),
|
GObject.Value(GObject.TYPE_BOOLEAN, False),
|
||||||
GObject.Value(GObject.TYPE_BOOLEAN, True),
|
GObject.Value(GObject.TYPE_BOOLEAN, True),
|
||||||
])
|
])
|
||||||
orafile.write(tmp, path)
|
if (os.path.exists(tmp)):
|
||||||
os.remove(tmp)
|
orafile.write(tmp, path)
|
||||||
|
os.remove(tmp)
|
||||||
|
else:
|
||||||
|
print("Error removing ", tmp)
|
||||||
|
|
||||||
def add_layer(parent, x, y, opac, gimp_layer, path, visible=True):
|
def add_layer(parent, x, y, opac, gimp_layer, path, visible=True):
|
||||||
store_layer(image, gimp_layer, path)
|
store_layer(image, gimp_layer, path)
|
||||||
|
@ -220,11 +225,7 @@ def save_ora(procedure, run_mode, image, drawable, file, args, data):
|
||||||
add_layer(parent, x, y, opac, lay, path_name, lay.get_visible())
|
add_layer(parent, x, y, opac, lay, path_name, lay.get_visible())
|
||||||
|
|
||||||
# save mergedimage
|
# save mergedimage
|
||||||
thumb = Gimp.get_pdb().run_procedure('gimp-image-duplicate', [
|
thumb = image.duplicate()
|
||||||
GObject.Value(Gimp.Image, image),
|
|
||||||
])
|
|
||||||
thumb = thumb.index(1)
|
|
||||||
thumb = Gimp.Image.get_by_id(thumb)
|
|
||||||
thumb_layer = thumb.merge_visible_layers (Gimp.MergeType.CLIP_TO_IMAGE)
|
thumb_layer = thumb.merge_visible_layers (Gimp.MergeType.CLIP_TO_IMAGE)
|
||||||
store_layer (thumb, thumb_layer, 'mergedimage.png')
|
store_layer (thumb, thumb_layer, 'mergedimage.png')
|
||||||
|
|
||||||
|
@ -263,7 +264,7 @@ def load_ora(procedure, run_mode, file, args, data):
|
||||||
stack, w, h = get_image_attributes(orafile)
|
stack, w, h = get_image_attributes(orafile)
|
||||||
|
|
||||||
img = Gimp.Image.new(w, h, Gimp.ImageBaseType.RGB)
|
img = Gimp.Image.new(w, h, Gimp.ImageBaseType.RGB)
|
||||||
img.set_filename (file.peek_path())
|
img.set_file (file)
|
||||||
|
|
||||||
def get_layers(root):
|
def get_layers(root):
|
||||||
"""iterates over layers and nested stacks"""
|
"""iterates over layers and nested stacks"""
|
||||||
|
@ -314,10 +315,9 @@ def load_ora(procedure, run_mode, file, args, data):
|
||||||
gimp_layer = Gimp.get_pdb().run_procedure('gimp-file-load-layer', [
|
gimp_layer = Gimp.get_pdb().run_procedure('gimp-file-load-layer', [
|
||||||
GObject.Value(Gimp.RunMode, Gimp.RunMode.NONINTERACTIVE),
|
GObject.Value(Gimp.RunMode, Gimp.RunMode.NONINTERACTIVE),
|
||||||
GObject.Value(Gimp.Image, img),
|
GObject.Value(Gimp.Image, img),
|
||||||
GObject.Value(GObject.TYPE_STRING, tmp),
|
GObject.Value(Gio.File, Gio.File.new_for_path(tmp)),
|
||||||
])
|
])
|
||||||
gimp_layer = gimp_layer.index(1)
|
gimp_layer = gimp_layer.index(1)
|
||||||
gimp_layer = Gimp.Item.get_by_id(gimp_layer)
|
|
||||||
os.remove(tmp)
|
os.remove(tmp)
|
||||||
gimp_layer.set_name(name)
|
gimp_layer.set_name(name)
|
||||||
gimp_layer.set_mode(layer_mode)
|
gimp_layer.set_mode(layer_mode)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue