python, libgimp: rename gimp_palette_entry_[gs]et_*()

Followup to 151cb9c40c
to make the palette offset and sort scripts work again.
This commit is contained in:
Anders Jonsson 2025-01-29 21:02:22 +01:00
parent 29c9747222
commit 255e942087
3 changed files with 17 additions and 17 deletions

View file

@ -35,7 +35,7 @@ assert palette_bears.get_columns() == 0
colors = palette_bears.get_colors()
assert len(colors) == 256
# color of first entry is as expected
success, color = palette_bears.entry_get_color(0)
success, color = palette_bears.get_entry_color(0)
assert success
assert color.r == 0.03137254901960784
assert color.g == 0.03137254901960784
@ -105,7 +105,7 @@ assert index == 0
# After adding an entry, color count is incremented
assert palette_new.get_color_count() == 1
# The color of the new entry equals what we passed
success, color = palette_new.entry_get_color(0)
success, color = palette_new.get_entry_color(0)
assert success == True
assert foreground_color.r == color.r
@ -118,7 +118,7 @@ assert palette_new.get_color_count() == 2
# An added entry for which the provided name was empty string is empty string
# TODO C code seems to suggest that it should be named "Untitled"
success, name = palette_new.entry_get_name(1)
success, name = palette_new.get_entry_name(1)
assert success
assert name == ""
@ -129,7 +129,7 @@ assert palette_new.delete_entry(1) == True
# Delete entry decrements the color count
assert palette_new.get_color_count() == 1
# A deleted entry no longer is gettable
success, name = palette_new.entry_get_name(1)
success, name = palette_new.get_entry_name(1)
assert not success
assert name == None

View file

@ -110,16 +110,16 @@ class PaletteOffset (Gimp.PlugIn):
num_colors = palette.get_color_count()
tmp_entry_array = []
for i in range (num_colors):
tmp_entry_array.append ((palette.entry_get_name(i)[1],
palette.entry_get_color(i)))
tmp_entry_array.append ((palette.get_entry_name(i)[1],
palette.get_entry_color(i)))
for i in range (num_colors):
target_index = i + amount
if target_index >= num_colors:
target_index -= num_colors
elif target_index < 0:
target_index += num_colors
palette.entry_set_name(target_index, tmp_entry_array[i][0])
palette.entry_set_color(target_index, tmp_entry_array[i][1])
palette.set_entry_name(target_index, tmp_entry_array[i][0])
palette.set_entry_color(target_index, tmp_entry_array[i][1])
retval = procedure.new_return_values(Gimp.PDBStatusType.SUCCESS, GLib.Error())
value = GObject.Value(Gimp.Palette, palette)

View file

@ -202,7 +202,7 @@ def palette_sort(palette, selection, slice_expr, channel1, ascending1,
if selection == "auto-slice":
def find_index(color, startindex=0):
for i in range(startindex, num_colors):
c = palette.entry_get_color(i)
c = palette.get_entry_color(i)
rgba = c.get_rgba()
if rgba[0] == color[1].r and rgba[1] == color[1].g and rgba[2] == color[1].b:
@ -250,8 +250,8 @@ def palette_sort(palette, selection, slice_expr, channel1, ascending1,
def get_colors(start, end):
result = []
for i in range(start, end):
entry = (palette.entry_get_name(i)[1],
palette.entry_get_color(i))
entry = (palette.get_entry_name(i)[1],
palette.get_entry_color(i))
index1 = channels_getter_1(entry[1], i)
index2 = channels_getter_2(entry[1], i)
index = ((index1 - (index1 % grain1)) * (1 if ascending1 else -1),
@ -265,8 +265,8 @@ def palette_sort(palette, selection, slice_expr, channel1, ascending1,
entry_list = get_colors(0, num_colors)
entry_list.sort(key=lambda v: v[0])
for i in range(num_colors):
palette.entry_set_name(i, entry_list[i][1][0])
palette.entry_set_color(i, entry_list[i][1][1])
palette.set_entry_name(i, entry_list[i][1][0])
palette.set_entry_color(i, entry_list[i][1][1])
elif selection == "partitioned":
if num_colors < (start + length * nrows) - 1:
@ -277,11 +277,11 @@ def palette_sort(palette, selection, slice_expr, channel1, ascending1,
for row in range(nrows):
partition_spans = [1]
rowstart = start + (row * length)
old_color = palette.entry_get_color(rowstart)
old_color = palette.get_entry_color(rowstart)
old_partition = pchannels_getter(old_color, rowstart)
old_partition = old_partition - (old_partition % pgrain)
for i in range(rowstart + 1, rowstart + length):
this_color = palette.entry_get_color(i)
this_color = palette.get_entry_color(i)
this_partition = pchannels_getter(this_color, i)
this_partition = this_partition - (this_partition % pgrain)
if this_partition == old_partition:
@ -308,8 +308,8 @@ def palette_sort(palette, selection, slice_expr, channel1, ascending1,
sublist = get_colors(row_start, row_start + stride)
sublist.sort(key=lambda v: v[0])
for i, entry in zip(range(row_start, row_start + stride), sublist):
palette.entry_set_name(i, entry[1][0])
palette.entry_set_color(i, entry[1][1])
palette.set_entry_name(i, entry[1][0])
palette.set_entry_color(i, entry[1][1])
return palette