Commit 8938834a authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

actually return the added entry, and not always the palette's last entry

2005-07-13  Michael Natterer  <mitch@gimp.org>

	* app/core/gimppalette.c (gimp_palette_add_entry): actually return
	the added entry, and not always the palette's last entry (argh!).

	* app/widgets/gimppaletteeditor.c: make sure the cursor is always
	on the newly added color. Really fixes #15060 this time.
parent fbd53c51
2005-07-13 Michael Natterer <mitch@gimp.org>
* app/core/gimppalette.c (gimp_palette_add_entry): actually return
the added entry, and not always the palette's last entry (argh!).
* app/widgets/gimppaletteeditor.c: make sure the cursor is always
on the newly added color. Really fixes #15060 this time.
2005-07-13 Sven Neumann <sven@gimp.org>
* app/paint-funcs/paint-funcs.[ch]: added smooth_region(), a
......
......@@ -611,10 +611,10 @@ gimp_palette_duplicate (GimpData *data)
}
GimpPaletteEntry *
gimp_palette_add_entry (GimpPalette *palette,
gint position,
const gchar *name,
const GimpRGB *color)
gimp_palette_add_entry (GimpPalette *palette,
gint position,
const gchar *name,
const GimpRGB *color)
{
GimpPaletteEntry *entry;
......@@ -623,8 +623,8 @@ gimp_palette_add_entry (GimpPalette *palette,
entry = g_new0 (GimpPaletteEntry, 1);
entry->color = *color;
entry->name = g_strdup (name ? name : _("Untitled"));
entry->color = *color;
entry->name = g_strdup (name ? name : _("Untitled"));
if (position < 0 || position >= palette->n_colors)
{
......@@ -643,8 +643,9 @@ gimp_palette_add_entry (GimpPalette *palette,
list;
list = g_list_next (list))
{
entry = (GimpPaletteEntry *) list->data;
entry->position += 1;
GimpPaletteEntry *entry2 = list->data;
entry2->position += 1;
}
}
......
......@@ -611,10 +611,10 @@ gimp_palette_duplicate (GimpData *data)
}
GimpPaletteEntry *
gimp_palette_add_entry (GimpPalette *palette,
gint position,
const gchar *name,
const GimpRGB *color)
gimp_palette_add_entry (GimpPalette *palette,
gint position,
const gchar *name,
const GimpRGB *color)
{
GimpPaletteEntry *entry;
......@@ -623,8 +623,8 @@ gimp_palette_add_entry (GimpPalette *palette,
entry = g_new0 (GimpPaletteEntry, 1);
entry->color = *color;
entry->name = g_strdup (name ? name : _("Untitled"));
entry->color = *color;
entry->name = g_strdup (name ? name : _("Untitled"));
if (position < 0 || position >= palette->n_colors)
{
......@@ -643,8 +643,9 @@ gimp_palette_add_entry (GimpPalette *palette,
list;
list = g_list_next (list))
{
entry = (GimpPaletteEntry *) list->data;
entry->position += 1;
GimpPaletteEntry *entry2 = list->data;
entry2->position += 1;
}
}
......
......@@ -611,10 +611,10 @@ gimp_palette_duplicate (GimpData *data)
}
GimpPaletteEntry *
gimp_palette_add_entry (GimpPalette *palette,
gint position,
const gchar *name,
const GimpRGB *color)
gimp_palette_add_entry (GimpPalette *palette,
gint position,
const gchar *name,
const GimpRGB *color)
{
GimpPaletteEntry *entry;
......@@ -623,8 +623,8 @@ gimp_palette_add_entry (GimpPalette *palette,
entry = g_new0 (GimpPaletteEntry, 1);
entry->color = *color;
entry->name = g_strdup (name ? name : _("Untitled"));
entry->color = *color;
entry->name = g_strdup (name ? name : _("Untitled"));
if (position < 0 || position >= palette->n_colors)
{
......@@ -643,8 +643,9 @@ gimp_palette_add_entry (GimpPalette *palette,
list;
list = g_list_next (list))
{
entry = (GimpPaletteEntry *) list->data;
entry->position += 1;
GimpPaletteEntry *entry2 = list->data;
entry2->position += 1;
}
}
......
......@@ -493,8 +493,11 @@ gimp_palette_editor_pick_color (GimpPaletteEditor *editor,
if (GIMP_DATA_EDITOR (editor)->data_editable)
{
GimpData *data = gimp_data_editor_get_data (GIMP_DATA_EDITOR (editor));
gint index = -1;
GimpPaletteEntry *entry;
GimpData *data;
gint index = -1;
data = gimp_data_editor_get_data (GIMP_DATA_EDITOR (editor));
switch (pick_state)
{
......@@ -502,8 +505,12 @@ gimp_palette_editor_pick_color (GimpPaletteEditor *editor,
if (editor->color)
index = editor->color->position + 1;
editor->color = gimp_palette_add_entry (GIMP_PALETTE (data), index,
NULL, color);
entry = gimp_palette_add_entry (GIMP_PALETTE (data), index,
NULL, color);
palette_editor_select_entry (editor, entry);
palette_editor_draw_entries (editor,
entry->position / editor->columns,
entry->position % editor->columns);
break;
case GIMP_COLOR_PICK_STATE_UPDATE:
......@@ -1088,9 +1095,14 @@ palette_editor_drop_color (GtkWidget *widget,
if (GIMP_DATA_EDITOR (editor)->data_editable)
{
GimpPalette *palette = GIMP_PALETTE (GIMP_DATA_EDITOR (editor)->data);
editor->color = gimp_palette_add_entry (palette, -1, NULL, color);
GimpPalette *palette = GIMP_PALETTE (GIMP_DATA_EDITOR (editor)->data);
GimpPaletteEntry *entry;
entry = gimp_palette_add_entry (palette, -1, NULL, color);
palette_editor_select_entry (editor, entry);
palette_editor_draw_entries (editor,
entry->position / editor->columns,
entry->position % editor->columns);
}
}
......@@ -1105,11 +1117,12 @@ palette_editor_color_area_drop_color (GtkWidget *widget,
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;
GimpPalette *palette = GIMP_PALETTE (GIMP_DATA_EDITOR (editor)->data);
GimpPaletteEntry *entry;
gint entry_width;
gint entry_height;
gint row, col;
gint pos;
/* calc drop pos */
entry_width = editor->col_width + SPACING;
......@@ -1119,7 +1132,11 @@ palette_editor_color_area_drop_color (GtkWidget *widget,
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);
entry = gimp_palette_add_entry (palette, pos, NULL, color);
palette_editor_select_entry (editor, entry);
palette_editor_draw_entries (editor,
entry->position / editor->columns,
entry->position % editor->columns);
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment