plug-ins: forgotten Python plug-ins had to be ported to new Gimp.Procedure.new().

There was also one case of port to updated GimpResource API to get the name of a
palette.
This commit is contained in:
Jehan
2023-06-16 23:36:11 +02:00
parent 2b38a2df86
commit 3806b46fc5
5 changed files with 37 additions and 80 deletions

View File

@ -108,30 +108,20 @@ class PaletteOffset (Gimp.PlugIn):
return procedure
def run(self, procedure, args, data):
palette = None
amount = 1
def run(self, procedure, config, data):
runmode = config.get_property("run-mode")
palette = config.get_property("palette")
amount = config.get_property("amount")
# Get the parameters
if args.length() < 1:
error = 'No parameters given'
return procedure.new_return_values(Gimp.PDBStatusType.CALLING_ERROR,
GLib.Error(error))
runmode = args.index(0)
if args.length() > 1:
palette = args.index(1)
if palette is None:
palette = Gimp.context_get_palette()
config.set_property("palette", palette)
if not palette.is_valid():
error = f'Invalid palette ID: {palette.get_id()}'
return procedure.new_return_values(Gimp.PDBStatusType.CALLING_ERROR,
GLib.Error(error))
if args.length() > 2:
amount = args.index(2)
if runmode == Gimp.RunMode.INTERACTIVE:
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
@ -140,7 +130,7 @@ class PaletteOffset (Gimp.PlugIn):
use_header_bar = Gtk.Settings.get_default().get_property("gtk-dialogs-use-header")
dialog = GimpUi.Dialog(use_header_bar=use_header_bar,
title=_("Offset Palette..."))
title=_("Offset Palette..."))
dialog.add_button(_("_Cancel"), Gtk.ResponseType.CANCEL)
dialog.add_button(_("_OK"), Gtk.ResponseType.OK)
@ -162,10 +152,10 @@ class PaletteOffset (Gimp.PlugIn):
dialog.show()
if dialog.run() != Gtk.ResponseType.OK:
print ("Canceled")
return procedure.new_return_values(Gimp.PDBStatusType.CANCEL,
GLib.Error("Canceled"))
amount = self.get_property("amount")
config.set_property("amount", amount)
#If palette is read only, work on a copy:
editable = palette.is_editable()