Commit 2c74680e authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

code review / cleanup.

2004-09-28  Michael Natterer  <mitch@gimp.org>

	* app/core/gimppalette.c: code review / cleanup.

	(gimp_palette_delete_entry): don't add "Black" when the last color
	gets removed, a palette can easily live with zero colors.

	* app/widgets/gimppaletteeditor.c
	(palette_editor_invalidate_preview): also update the entry which
	shows the palette_entry's name.
parent 5ad16c6f
2004-09-28 Michael Natterer <mitch@gimp.org>
* app/core/gimppalette.c: code review / cleanup.
(gimp_palette_delete_entry): don't add "Black" when the last color
gets removed, a palette can easily live with zero colors.
* app/widgets/gimppaletteeditor.c
(palette_editor_invalidate_preview): also update the entry which
shows the palette_entry's name.
2004-09-28 Sven Neumann <sven@gimp.org>
* app/file/gimprecentlist.c (gimp_recent_list_write_raw): handle
......
......@@ -229,22 +229,18 @@ gimp_palette_get_new_preview (GimpViewable *viewable,
gint width,
gint height)
{
GimpPalette *palette = GIMP_PALETTE (viewable);
GimpPaletteEntry *entry;
TempBuf *temp_buf;
guchar *buf;
guchar *b;
GList *list;
guchar white[3] = { 255, 255, 255 };
gint columns;
gint rows;
gint cell_size;
gint x, y, i;
temp_buf = temp_buf_new (width, height,
3,
0, 0,
white);
GimpPalette *palette = GIMP_PALETTE (viewable);
TempBuf *temp_buf;
guchar *buf;
guchar *b;
GList *list;
guchar white[3] = { 255, 255, 255 };
gint columns;
gint rows;
gint cell_size;
gint x, y;
temp_buf = temp_buf_new (width, height, 3, 0, 0, white);
if (palette->n_columns > 1)
cell_size = MAX (4, width / palette->n_columns);
......@@ -261,11 +257,13 @@ gimp_palette_get_new_preview (GimpViewable *viewable,
for (y = 0; y < rows && list; y++)
{
gint i;
memset (b, 255, width * 3);
for (x = 0; x < columns && list; x++)
{
entry = (GimpPaletteEntry *) list->data;
GimpPaletteEntry *entry = list->data;
list = g_list_next (list);
......@@ -283,9 +281,7 @@ gimp_palette_get_new_preview (GimpViewable *viewable,
}
for (i = 0; i < cell_size; i++)
{
memcpy (buf + ((y * cell_size + i) * width) * 3, b, width * 3);
}
memcpy (buf + ((y * cell_size + i) * width) * 3, b, width * 3);
}
g_free (b);
......@@ -675,17 +671,6 @@ gimp_palette_delete_entry (GimpPalette *palette,
entry->position = pos++;
}
if (palette->n_colors == 0)
{
GimpRGB color;
gimp_rgba_set (&color, 0.0, 0.0, 0.0, GIMP_OPACITY_OPAQUE);
gimp_palette_add_entry (palette,
_("Black"),
&color);
}
/* will make the palette dirty too */
gimp_object_name_changed (GIMP_OBJECT (palette));
}
......
......@@ -229,22 +229,18 @@ gimp_palette_get_new_preview (GimpViewable *viewable,
gint width,
gint height)
{
GimpPalette *palette = GIMP_PALETTE (viewable);
GimpPaletteEntry *entry;
TempBuf *temp_buf;
guchar *buf;
guchar *b;
GList *list;
guchar white[3] = { 255, 255, 255 };
gint columns;
gint rows;
gint cell_size;
gint x, y, i;
temp_buf = temp_buf_new (width, height,
3,
0, 0,
white);
GimpPalette *palette = GIMP_PALETTE (viewable);
TempBuf *temp_buf;
guchar *buf;
guchar *b;
GList *list;
guchar white[3] = { 255, 255, 255 };
gint columns;
gint rows;
gint cell_size;
gint x, y;
temp_buf = temp_buf_new (width, height, 3, 0, 0, white);
if (palette->n_columns > 1)
cell_size = MAX (4, width / palette->n_columns);
......@@ -261,11 +257,13 @@ gimp_palette_get_new_preview (GimpViewable *viewable,
for (y = 0; y < rows && list; y++)
{
gint i;
memset (b, 255, width * 3);
for (x = 0; x < columns && list; x++)
{
entry = (GimpPaletteEntry *) list->data;
GimpPaletteEntry *entry = list->data;
list = g_list_next (list);
......@@ -283,9 +281,7 @@ gimp_palette_get_new_preview (GimpViewable *viewable,
}
for (i = 0; i < cell_size; i++)
{
memcpy (buf + ((y * cell_size + i) * width) * 3, b, width * 3);
}
memcpy (buf + ((y * cell_size + i) * width) * 3, b, width * 3);
}
g_free (b);
......@@ -675,17 +671,6 @@ gimp_palette_delete_entry (GimpPalette *palette,
entry->position = pos++;
}
if (palette->n_colors == 0)
{
GimpRGB color;
gimp_rgba_set (&color, 0.0, 0.0, 0.0, GIMP_OPACITY_OPAQUE);
gimp_palette_add_entry (palette,
_("Black"),
&color);
}
/* will make the palette dirty too */
gimp_object_name_changed (GIMP_OBJECT (palette));
}
......
......@@ -229,22 +229,18 @@ gimp_palette_get_new_preview (GimpViewable *viewable,
gint width,
gint height)
{
GimpPalette *palette = GIMP_PALETTE (viewable);
GimpPaletteEntry *entry;
TempBuf *temp_buf;
guchar *buf;
guchar *b;
GList *list;
guchar white[3] = { 255, 255, 255 };
gint columns;
gint rows;
gint cell_size;
gint x, y, i;
temp_buf = temp_buf_new (width, height,
3,
0, 0,
white);
GimpPalette *palette = GIMP_PALETTE (viewable);
TempBuf *temp_buf;
guchar *buf;
guchar *b;
GList *list;
guchar white[3] = { 255, 255, 255 };
gint columns;
gint rows;
gint cell_size;
gint x, y;
temp_buf = temp_buf_new (width, height, 3, 0, 0, white);
if (palette->n_columns > 1)
cell_size = MAX (4, width / palette->n_columns);
......@@ -261,11 +257,13 @@ gimp_palette_get_new_preview (GimpViewable *viewable,
for (y = 0; y < rows && list; y++)
{
gint i;
memset (b, 255, width * 3);
for (x = 0; x < columns && list; x++)
{
entry = (GimpPaletteEntry *) list->data;
GimpPaletteEntry *entry = list->data;
list = g_list_next (list);
......@@ -283,9 +281,7 @@ gimp_palette_get_new_preview (GimpViewable *viewable,
}
for (i = 0; i < cell_size; i++)
{
memcpy (buf + ((y * cell_size + i) * width) * 3, b, width * 3);
}
memcpy (buf + ((y * cell_size + i) * width) * 3, b, width * 3);
}
g_free (b);
......@@ -675,17 +671,6 @@ gimp_palette_delete_entry (GimpPalette *palette,
entry->position = pos++;
}
if (palette->n_colors == 0)
{
GimpRGB color;
gimp_rgba_set (&color, 0.0, 0.0, 0.0, GIMP_OPACITY_OPAQUE);
gimp_palette_add_entry (palette,
_("Black"),
&color);
}
/* will make the palette dirty too */
gimp_object_name_changed (GIMP_OBJECT (palette));
}
......
......@@ -536,10 +536,9 @@ gimp_palette_editor_pick_color (GimpPaletteEditor *editor,
case GIMP_COLOR_PICK_STATE_UPDATE:
editor->color->color = *color;
gimp_data_dirty (data);
break;
}
gimp_data_dirty (data);
}
}
......@@ -948,7 +947,6 @@ palette_editor_redraw (GimpPaletteEditor *editor,
editor->color->position % editor->columns);
}
static void
palette_editor_select_entry (GimpPaletteEditor *editor,
GimpPaletteEntry *entry)
......@@ -1232,8 +1230,20 @@ static void
palette_editor_invalidate_preview (GimpPalette *palette,
GimpPaletteEditor *editor)
{
if (editor->color && ! g_list_find (palette->colors, editor->color))
palette_editor_select_entry (editor, NULL);
if (editor->color)
{
GimpPaletteEntry *entry = editor->color;
if (g_list_find (palette->colors, entry))
{
editor->color = NULL;
palette_editor_select_entry (editor, entry);
}
else
{
palette_editor_select_entry (editor, NULL);
}
}
if (editor->dnd_color && ! g_list_find (palette->colors, editor->dnd_color))
editor->dnd_color = NULL;
......@@ -1291,5 +1301,6 @@ palette_editor_color_dialog_update (GimpColorDialog *dialog,
case GIMP_COLOR_DIALOG_CANCEL:
gtk_widget_hide (editor->color_dialog);
break;
}
}
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