Commit 0e678c4c authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann
Browse files

handle a NULL palette with GIMP_CUSTOM_PALETTE type, use the builtin mono

2005-04-13  Sven Neumann  <sven@gimp.org>

	* app/core/gimpimage-convert.c (gimp_image_convert): handle a NULL
	palette with GIMP_CUSTOM_PALETTE type, use the builtin mono
	palette as fallback.

	* app/dialogs/convert-dialog.c: handle empty palette container.

	* app/gui/gui-vtable.c (gui_pdb_dialog_new): removed unused code.

	* tools/pdbgen/pdb/convert.pdb: don't load the palettes implicitely.

	* app/pdb/convert_cmds.c: regenerated.
parent bf1b9651
2005-04-13 Sven Neumann <sven@gimp.org>
* app/core/gimpimage-convert.c (gimp_image_convert): handle a NULL
palette with GIMP_CUSTOM_PALETTE type, use the builtin mono
palette as fallback.
* app/dialogs/convert-dialog.c: handle empty palette container.
* app/gui/gui-vtable.c (gui_pdb_dialog_new): removed unused code.
* tools/pdbgen/pdb/convert.pdb: don't load the palettes implicitely.
* app/pdb/convert_cmds.c: regenerated.
2005-04-13 Michael Natterer <mitch@gimp.org>
* app/widgets/gimpimagedock.c (gimp_image_dock_image_changed):
......
......@@ -774,8 +774,7 @@ color_quicksort (const void *c1,
void
gimp_image_convert (GimpImage *gimage,
GimpImageBaseType new_type,
/* The following three params used only for
* new_type == GIMP_INDEXED
/* The following are only used for new_type == GIMP_INDEXED
*/
gint num_cols,
GimpConvertDitherType dither,
......@@ -798,10 +797,19 @@ gimp_image_convert (GimpImage *gimage,
g_return_if_fail (new_type != gimp_image_base_type (gimage));
g_return_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress));
if (palette_type == GIMP_CUSTOM_PALETTE && custom_palette->n_colors < 1)
if (palette_type == GIMP_CUSTOM_PALETTE)
{
g_message (_("Cannot convert image, palette is empty."));
return;
g_return_if_fail (custom_palette == NULL ||
GIMP_IS_PALETTE (custom_palette));
if (! custom_palette)
palette_type = GIMP_MONO_PALETTE;
if (custom_palette->n_colors < 1)
{
g_message (_("Cannot convert image, palette is empty."));
return;
}
}
theCustomPalette = custom_palette;
......
......@@ -145,16 +145,6 @@ convert_dialog_new (GimpImage *gimage,
palette_box = convert_dialog_palette_box (dialog);
if (dialog->context)
g_object_weak_ref (G_OBJECT (dialog->dialog),
(GWeakNotify) g_object_unref,
dialog->context);
if (dialog->container)
g_object_weak_ref (G_OBJECT (dialog->dialog),
(GWeakNotify) g_object_unref,
dialog->container);
main_vbox = gtk_vbox_new (FALSE, 12);
gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 12);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog->dialog)->vbox),
......@@ -164,11 +154,15 @@ convert_dialog_new (GimpImage *gimage,
/* palette */
frame = gimp_enum_radio_frame_new (GIMP_TYPE_CONVERT_PALETTE_TYPE,
gtk_label_new (_("Colormap")),
G_CALLBACK (gimp_radio_button_update),
&dialog->palette_type,
&toggle);
frame = gimp_enum_radio_frame_new_with_range (GIMP_TYPE_CONVERT_PALETTE_TYPE,
GIMP_MAKE_PALETTE,
palette_box ?
GIMP_CUSTOM_PALETTE : GIMP_MONO_PALETTE,
gtk_label_new (_("Colormap")),
G_CALLBACK (gimp_radio_button_update),
&dialog->palette_type,
&toggle);
gimp_int_radio_group_set_active (GTK_RADIO_BUTTON (toggle),
dialog->palette_type);
gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0);
......@@ -307,32 +301,37 @@ convert_dialog_response (GtkWidget *widget,
static GtkWidget *
convert_dialog_palette_box (IndexedDialog *dialog)
{
Gimp *gimp;
Gimp *gimp = dialog->gimage->gimp;
GList *list;
GimpPalette *palette;
GimpPalette *web_palette = NULL;
gboolean default_found = FALSE;
gimp = dialog->gimage->gimp;
/* We can't dither to > 256 colors */
dialog->container = gimp_container_filter (gimp->palette_factory->container,
convert_dialog_palette_filter,
NULL);
if (! gimp_container_num_children (dialog->container))
if (gimp_container_is_empty (dialog->container))
{
g_object_unref (dialog->container);
dialog->container = NULL;
return NULL;
}
dialog->context = gimp_context_new (gimp, "convert-dialog", NULL);
g_object_weak_ref (G_OBJECT (dialog->dialog),
(GWeakNotify) g_object_unref, dialog->context);
g_object_weak_ref (G_OBJECT (dialog->dialog),
(GWeakNotify) g_object_unref, dialog->container);
for (list = GIMP_LIST (dialog->container)->list;
list;
list = g_list_next (list))
{
palette = (GimpPalette *) list->data;
palette = list->data;
/* Preferentially, the initial default is 'Web' if available */
if (web_palette == NULL &&
......
......@@ -577,21 +577,6 @@ gui_pdb_dialog_new (Gimp *gimp,
{
GimpObject *object = NULL;
#ifdef __GNUC__
#warning FIXME: re-enable gimp->no_data case
#endif
#if 0
if (gimp->no_data)
{
static gboolean first_call = TRUE;
if (first_call)
gimp_data_factory_data_init (gimp->pattern_factory, FALSE);
first_call = FALSE;
}
#endif
if (object_name && strlen (object_name))
object = gimp_container_get_child_by_name (container, object_name);
......
......@@ -196,16 +196,11 @@ image_convert_indexed_invoker (Gimp *gimp,
break;
case GIMP_CUSTOM_PALETTE:
if (gimp_container_is_empty (gimp->palette_factory->container))
gimp_data_factory_data_init (gimp->palette_factory, FALSE);
palette = (GimpPalette *)
gimp_container_get_child_by_name (gimp->palette_factory->container,
palette_name);
if (palette == NULL)
success = FALSE;
break;
default:
......
......@@ -121,16 +121,11 @@ HELP
break;
case GIMP_CUSTOM_PALETTE:
if (gimp_container_is_empty (gimp->palette_factory->container))
gimp_data_factory_data_init (gimp->palette_factory, FALSE);
palette = (GimpPalette *)
gimp_container_get_child_by_name (gimp->palette_factory->container,
palette_name);
if (palette == NULL)
success = FALSE;
break;
default:
......@@ -151,9 +146,9 @@ CODE
);
}
@headers = qw("core/gimp.h" "core/gimpcontainer.h" "core/gimpimage.h"
"core/gimpimage-convert.h" "core/gimpdatafactory.h"
"core/gimppalette.h");
@headers = qw("core/gimp.h" "core/gimpcontainer.h" "core/gimpdatafactory.h"
"core/gimpimage.h" "core/gimpimage-convert.h"
"core/gimppalette.h");
@procs = qw(image_convert_rgb image_convert_grayscale image_convert_indexed);
%exports = (app => [@procs], lib => [@procs]);
......
Supports Markdown
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