mirror of https://github.com/GNOME/gimp.git
removed the just added gimp_palette_insert_entry() and added a "gint
2004-12-31 Michael Natterer <mitch@gimp.org> * app/core/gimppalette.[ch]: removed the just added gimp_palette_insert_entry() and added a "gint position" parameter to gimp_palette_add_entry() instead (no need to have two almost identical functions). * app/actions/palette-editor-commands.c * app/core/gimppalette-import.c * app/widgets/gimppaletteeditor.c * tools/pdbgen/pdb/palette.pdb: changed accordingly. * app/pdb/palette_cmds.c: regenerated.
This commit is contained in:
parent
c1ddf3ea45
commit
e5feab6519
14
ChangeLog
14
ChangeLog
|
@ -1,3 +1,17 @@
|
|||
2004-12-31 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/core/gimppalette.[ch]: removed the just added
|
||||
gimp_palette_insert_entry() and added a "gint position" parameter
|
||||
to gimp_palette_add_entry() instead (no need to have two almost
|
||||
identical functions).
|
||||
|
||||
* app/actions/palette-editor-commands.c
|
||||
* app/core/gimppalette-import.c
|
||||
* app/widgets/gimppaletteeditor.c
|
||||
* tools/pdbgen/pdb/palette.pdb: changed accordingly.
|
||||
|
||||
* app/pdb/palette_cmds.c: regenerated.
|
||||
|
||||
2004-12-31 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/widgets/gimpfgbgeditor.[ch]: use the coordinates passed in
|
||||
|
|
|
@ -114,7 +114,7 @@ palette_editor_new_color_cmd_callback (GtkAction *action,
|
|||
else
|
||||
gimp_context_get_foreground (context, &color);
|
||||
|
||||
editor->color = gimp_palette_add_entry (palette, NULL, &color);
|
||||
editor->color = gimp_palette_add_entry (palette, -1, NULL, &color);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ gimp_palette_import_from_gradient (GimpGradient *gradient,
|
|||
for (loop = 0, cur_x = 0; loop < n_colors; loop++, cur_x += dx)
|
||||
{
|
||||
gimp_gradient_get_color_at (gradient, cur_x, reverse, &color);
|
||||
gimp_palette_add_entry (palette, NULL, &color);
|
||||
gimp_palette_add_entry (palette, -1, NULL, &color);
|
||||
}
|
||||
|
||||
return palette;
|
||||
|
@ -226,7 +226,7 @@ gimp_palette_import_create_image_palette (gpointer data,
|
|||
(guchar) color_tab->b + (color_tab->b_adj / color_tab->count),
|
||||
255);
|
||||
|
||||
gimp_palette_add_entry (palette, lab, &color);
|
||||
gimp_palette_add_entry (palette, -1, lab, &color);
|
||||
|
||||
g_free (lab);
|
||||
}
|
||||
|
@ -364,7 +364,7 @@ gimp_palette_import_from_indexed_image (GimpImage *gimage,
|
|||
gimage->cmap[count * 3 + 2],
|
||||
255);
|
||||
|
||||
gimp_palette_add_entry (palette, NULL, &color);
|
||||
gimp_palette_add_entry (palette, -1, NULL, &color);
|
||||
}
|
||||
|
||||
return palette;
|
||||
|
@ -464,7 +464,7 @@ gimp_palette_import_from_file (const gchar *filename,
|
|||
color_bytes[1],
|
||||
color_bytes[2],
|
||||
255);
|
||||
gimp_palette_add_entry (palette, NULL, &color);
|
||||
gimp_palette_add_entry (palette, -1, NULL, &color);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -480,7 +480,7 @@ gimp_palette_import_from_file (const gchar *filename,
|
|||
color_bytes[1],
|
||||
color_bytes[2],
|
||||
255);
|
||||
gimp_palette_add_entry (palette, NULL, &color);
|
||||
gimp_palette_add_entry (palette, -1, NULL, &color);
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
@ -611,16 +611,17 @@ gimp_palette_duplicate (GimpData *data,
|
|||
{
|
||||
GimpPaletteEntry *entry = list->data;
|
||||
|
||||
gimp_palette_add_entry (new, entry->name, &entry->color);
|
||||
gimp_palette_add_entry (new, -1, entry->name, &entry->color);
|
||||
}
|
||||
|
||||
return GIMP_DATA (new);
|
||||
}
|
||||
|
||||
GimpPaletteEntry *
|
||||
gimp_palette_add_entry (GimpPalette *palette,
|
||||
const gchar *name,
|
||||
const GimpRGB *color)
|
||||
gimp_palette_add_entry (GimpPalette *palette,
|
||||
gint position,
|
||||
const gchar *name,
|
||||
const GimpRGB *color)
|
||||
{
|
||||
GimpPaletteEntry *entry;
|
||||
|
||||
|
@ -631,49 +632,30 @@ gimp_palette_add_entry (GimpPalette *palette,
|
|||
|
||||
entry->color = *color;
|
||||
entry->name = g_strdup (name ? name : _("Untitled"));
|
||||
entry->position = palette->n_colors;
|
||||
|
||||
palette->colors = g_list_append (palette->colors, entry);
|
||||
palette->n_colors += 1;
|
||||
|
||||
/* will make the palette dirty too */
|
||||
gimp_object_name_changed (GIMP_OBJECT (palette));
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
GimpPaletteEntry *
|
||||
gimp_palette_insert_entry (GimpPalette *palette,
|
||||
gint position,
|
||||
const gchar *name,
|
||||
const GimpRGB *color)
|
||||
{
|
||||
GimpPaletteEntry *entry;
|
||||
GList *list;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_PALETTE (palette), NULL);
|
||||
g_return_val_if_fail (color != NULL, NULL);
|
||||
|
||||
if (position < 0 || position >= palette->n_colors)
|
||||
return gimp_palette_add_entry (palette, name, color);
|
||||
|
||||
entry = g_new0 (GimpPaletteEntry, 1);
|
||||
|
||||
entry->color = *color;
|
||||
entry->name = g_strdup (name ? name : _("Untitled"));
|
||||
entry->position = position;
|
||||
|
||||
palette->colors = g_list_insert (palette->colors, entry, position);
|
||||
palette->n_colors += 1;
|
||||
|
||||
/* renumber the displaced entries */
|
||||
for (list = g_list_nth (palette->colors, position + 1);
|
||||
list;
|
||||
list = g_list_next (list))
|
||||
{
|
||||
entry = (GimpPaletteEntry *) list->data;
|
||||
entry->position += 1;
|
||||
entry->position = palette->n_colors;
|
||||
palette->colors = g_list_append (palette->colors, entry);
|
||||
}
|
||||
else
|
||||
{
|
||||
GList *list;
|
||||
|
||||
entry->position = position;
|
||||
palette->colors = g_list_insert (palette->colors, entry, position);
|
||||
|
||||
/* renumber the displaced entries */
|
||||
for (list = g_list_nth (palette->colors, position + 1);
|
||||
list;
|
||||
list = g_list_next (list))
|
||||
{
|
||||
entry = (GimpPaletteEntry *) list->data;
|
||||
entry->position += 1;
|
||||
}
|
||||
}
|
||||
|
||||
palette->n_colors += 1;
|
||||
|
||||
/* will make the palette dirty too */
|
||||
gimp_object_name_changed (GIMP_OBJECT (palette));
|
||||
|
|
|
@ -611,16 +611,17 @@ gimp_palette_duplicate (GimpData *data,
|
|||
{
|
||||
GimpPaletteEntry *entry = list->data;
|
||||
|
||||
gimp_palette_add_entry (new, entry->name, &entry->color);
|
||||
gimp_palette_add_entry (new, -1, entry->name, &entry->color);
|
||||
}
|
||||
|
||||
return GIMP_DATA (new);
|
||||
}
|
||||
|
||||
GimpPaletteEntry *
|
||||
gimp_palette_add_entry (GimpPalette *palette,
|
||||
const gchar *name,
|
||||
const GimpRGB *color)
|
||||
gimp_palette_add_entry (GimpPalette *palette,
|
||||
gint position,
|
||||
const gchar *name,
|
||||
const GimpRGB *color)
|
||||
{
|
||||
GimpPaletteEntry *entry;
|
||||
|
||||
|
@ -631,49 +632,30 @@ gimp_palette_add_entry (GimpPalette *palette,
|
|||
|
||||
entry->color = *color;
|
||||
entry->name = g_strdup (name ? name : _("Untitled"));
|
||||
entry->position = palette->n_colors;
|
||||
|
||||
palette->colors = g_list_append (palette->colors, entry);
|
||||
palette->n_colors += 1;
|
||||
|
||||
/* will make the palette dirty too */
|
||||
gimp_object_name_changed (GIMP_OBJECT (palette));
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
GimpPaletteEntry *
|
||||
gimp_palette_insert_entry (GimpPalette *palette,
|
||||
gint position,
|
||||
const gchar *name,
|
||||
const GimpRGB *color)
|
||||
{
|
||||
GimpPaletteEntry *entry;
|
||||
GList *list;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_PALETTE (palette), NULL);
|
||||
g_return_val_if_fail (color != NULL, NULL);
|
||||
|
||||
if (position < 0 || position >= palette->n_colors)
|
||||
return gimp_palette_add_entry (palette, name, color);
|
||||
|
||||
entry = g_new0 (GimpPaletteEntry, 1);
|
||||
|
||||
entry->color = *color;
|
||||
entry->name = g_strdup (name ? name : _("Untitled"));
|
||||
entry->position = position;
|
||||
|
||||
palette->colors = g_list_insert (palette->colors, entry, position);
|
||||
palette->n_colors += 1;
|
||||
|
||||
/* renumber the displaced entries */
|
||||
for (list = g_list_nth (palette->colors, position + 1);
|
||||
list;
|
||||
list = g_list_next (list))
|
||||
{
|
||||
entry = (GimpPaletteEntry *) list->data;
|
||||
entry->position += 1;
|
||||
entry->position = palette->n_colors;
|
||||
palette->colors = g_list_append (palette->colors, entry);
|
||||
}
|
||||
else
|
||||
{
|
||||
GList *list;
|
||||
|
||||
entry->position = position;
|
||||
palette->colors = g_list_insert (palette->colors, entry, position);
|
||||
|
||||
/* renumber the displaced entries */
|
||||
for (list = g_list_nth (palette->colors, position + 1);
|
||||
list;
|
||||
list = g_list_next (list))
|
||||
{
|
||||
entry = (GimpPaletteEntry *) list->data;
|
||||
entry->position += 1;
|
||||
}
|
||||
}
|
||||
|
||||
palette->n_colors += 1;
|
||||
|
||||
/* will make the palette dirty too */
|
||||
gimp_object_name_changed (GIMP_OBJECT (palette));
|
||||
|
|
|
@ -611,16 +611,17 @@ gimp_palette_duplicate (GimpData *data,
|
|||
{
|
||||
GimpPaletteEntry *entry = list->data;
|
||||
|
||||
gimp_palette_add_entry (new, entry->name, &entry->color);
|
||||
gimp_palette_add_entry (new, -1, entry->name, &entry->color);
|
||||
}
|
||||
|
||||
return GIMP_DATA (new);
|
||||
}
|
||||
|
||||
GimpPaletteEntry *
|
||||
gimp_palette_add_entry (GimpPalette *palette,
|
||||
const gchar *name,
|
||||
const GimpRGB *color)
|
||||
gimp_palette_add_entry (GimpPalette *palette,
|
||||
gint position,
|
||||
const gchar *name,
|
||||
const GimpRGB *color)
|
||||
{
|
||||
GimpPaletteEntry *entry;
|
||||
|
||||
|
@ -631,49 +632,30 @@ gimp_palette_add_entry (GimpPalette *palette,
|
|||
|
||||
entry->color = *color;
|
||||
entry->name = g_strdup (name ? name : _("Untitled"));
|
||||
entry->position = palette->n_colors;
|
||||
|
||||
palette->colors = g_list_append (palette->colors, entry);
|
||||
palette->n_colors += 1;
|
||||
|
||||
/* will make the palette dirty too */
|
||||
gimp_object_name_changed (GIMP_OBJECT (palette));
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
GimpPaletteEntry *
|
||||
gimp_palette_insert_entry (GimpPalette *palette,
|
||||
gint position,
|
||||
const gchar *name,
|
||||
const GimpRGB *color)
|
||||
{
|
||||
GimpPaletteEntry *entry;
|
||||
GList *list;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_PALETTE (palette), NULL);
|
||||
g_return_val_if_fail (color != NULL, NULL);
|
||||
|
||||
if (position < 0 || position >= palette->n_colors)
|
||||
return gimp_palette_add_entry (palette, name, color);
|
||||
|
||||
entry = g_new0 (GimpPaletteEntry, 1);
|
||||
|
||||
entry->color = *color;
|
||||
entry->name = g_strdup (name ? name : _("Untitled"));
|
||||
entry->position = position;
|
||||
|
||||
palette->colors = g_list_insert (palette->colors, entry, position);
|
||||
palette->n_colors += 1;
|
||||
|
||||
/* renumber the displaced entries */
|
||||
for (list = g_list_nth (palette->colors, position + 1);
|
||||
list;
|
||||
list = g_list_next (list))
|
||||
{
|
||||
entry = (GimpPaletteEntry *) list->data;
|
||||
entry->position += 1;
|
||||
entry->position = palette->n_colors;
|
||||
palette->colors = g_list_append (palette->colors, entry);
|
||||
}
|
||||
else
|
||||
{
|
||||
GList *list;
|
||||
|
||||
entry->position = position;
|
||||
palette->colors = g_list_insert (palette->colors, entry, position);
|
||||
|
||||
/* renumber the displaced entries */
|
||||
for (list = g_list_nth (palette->colors, position + 1);
|
||||
list;
|
||||
list = g_list_next (list))
|
||||
{
|
||||
entry = (GimpPaletteEntry *) list->data;
|
||||
entry->position += 1;
|
||||
}
|
||||
}
|
||||
|
||||
palette->n_colors += 1;
|
||||
|
||||
/* will make the palette dirty too */
|
||||
gimp_object_name_changed (GIMP_OBJECT (palette));
|
||||
|
|
|
@ -72,9 +72,6 @@ GList * gimp_palette_load (const gchar *filename,
|
|||
GError **error);
|
||||
|
||||
GimpPaletteEntry * gimp_palette_add_entry (GimpPalette *palette,
|
||||
const gchar *name,
|
||||
const GimpRGB *color);
|
||||
GimpPaletteEntry * gimp_palette_insert_entry (GimpPalette *palette,
|
||||
gint position,
|
||||
const gchar *name,
|
||||
const GimpRGB *color);
|
||||
|
|
|
@ -517,7 +517,7 @@ palette_add_entry_invoker (Gimp *gimp,
|
|||
gimp_container_get_child_by_name (gimp->palette_factory->container, name);
|
||||
|
||||
if (palette && GIMP_DATA (palette)->writable)
|
||||
entry = gimp_palette_add_entry (palette, entry_name, &color);
|
||||
entry = gimp_palette_add_entry (palette, -1, entry_name, &color);
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
|
|
|
@ -502,7 +502,7 @@ gimp_palette_editor_pick_color (GimpPaletteEditor *editor,
|
|||
switch (pick_state)
|
||||
{
|
||||
case GIMP_COLOR_PICK_STATE_NEW:
|
||||
editor->color = gimp_palette_add_entry (GIMP_PALETTE (data),
|
||||
editor->color = gimp_palette_add_entry (GIMP_PALETTE (data), -1,
|
||||
NULL, color);
|
||||
break;
|
||||
|
||||
|
@ -1088,10 +1088,9 @@ palette_editor_drop_color (GtkWidget *widget,
|
|||
|
||||
if (GIMP_DATA_EDITOR (editor)->data_editable)
|
||||
{
|
||||
editor->color =
|
||||
gimp_palette_add_entry (GIMP_PALETTE (GIMP_DATA_EDITOR (editor)->data),
|
||||
NULL,
|
||||
(GimpRGB *) color);
|
||||
GimpPalette *palette = GIMP_PALETTE (GIMP_DATA_EDITOR (editor)->data);
|
||||
|
||||
editor->color = gimp_palette_add_entry (palette, -1, NULL, color);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1103,40 +1102,25 @@ palette_editor_color_area_drop_color (GtkWidget *widget,
|
|||
gpointer data)
|
||||
{
|
||||
GimpPaletteEditor *editor = GIMP_PALETTE_EDITOR (data);
|
||||
gint entry_width;
|
||||
gint entry_height;
|
||||
gint row, col;
|
||||
gint pos;
|
||||
|
||||
/* calc drop pos */
|
||||
entry_width = editor->col_width + SPACING;
|
||||
entry_height = (ENTRY_HEIGHT * editor->zoom_factor) + SPACING;
|
||||
col = (x - 1) / entry_width;
|
||||
row = (y - 1) / entry_height;
|
||||
pos = row * editor->columns + col;
|
||||
|
||||
if (GIMP_DATA_EDITOR (editor)->data_editable)
|
||||
{
|
||||
GimpPalette *palette = GIMP_PALETTE (GIMP_DATA_EDITOR (editor)->data);
|
||||
gint entry_width;
|
||||
gint entry_height;
|
||||
gint row, col;
|
||||
gint pos;
|
||||
|
||||
/* on an existing entry? */
|
||||
if (pos >= 0 && pos < palette->n_colors)
|
||||
{
|
||||
/* yep - insert it */
|
||||
editor->color = gimp_palette_insert_entry (palette,
|
||||
pos,
|
||||
NULL,
|
||||
color);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* nope - add it on the end */
|
||||
editor->color = gimp_palette_add_entry (palette,
|
||||
NULL,
|
||||
color);
|
||||
}
|
||||
/* calc drop pos */
|
||||
entry_width = editor->col_width + SPACING;
|
||||
entry_height = (ENTRY_HEIGHT * editor->zoom_factor) + SPACING;
|
||||
col = (x - 1) / entry_width;
|
||||
row = (y - 1) / entry_height;
|
||||
pos = row * editor->columns + col;
|
||||
|
||||
/* adding at a negative or non-existing pos will automatically append */
|
||||
editor->color = gimp_palette_add_entry (palette, pos, NULL, color);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -287,7 +287,7 @@ HELP
|
|||
gimp_container_get_child_by_name (gimp->palette_factory->container, name);
|
||||
|
||||
if (palette && GIMP_DATA (palette)->writable)
|
||||
entry = gimp_palette_add_entry (palette, entry_name, &color);
|
||||
entry = gimp_palette_add_entry (palette, -1, entry_name, &color);
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue