added support for extracting colors from the selected pixels only.
2006-05-28 Michael Natterer <mitch@gimp.org> * app/core/gimppalette-import.[ch]: added support for extracting colors from the selected pixels only. * app/dialogs/palette-import-dialog.c: added "Sample merged" and "Selected Pixels only" toggles. Fixes bug #316212. Cleaned up the code quite a bit.
This commit is contained in:

committed by
Michael Natterer

parent
5af5606aac
commit
70adfc5c7e
@ -1,3 +1,12 @@
|
|||||||
|
2006-05-28 Michael Natterer <mitch@gimp.org>
|
||||||
|
|
||||||
|
* app/core/gimppalette-import.[ch]: added support for extracting
|
||||||
|
colors from the selected pixels only.
|
||||||
|
|
||||||
|
* app/dialogs/palette-import-dialog.c: added "Sample merged" and
|
||||||
|
"Selected Pixels only" toggles. Fixes bug #316212. Cleaned up the
|
||||||
|
code quite a bit.
|
||||||
|
|
||||||
2006-05-28 Michael Natterer <mitch@gimp.org>
|
2006-05-28 Michael Natterer <mitch@gimp.org>
|
||||||
|
|
||||||
* app/tools/gimpcolorpickertool.c (gimp_color_picker_tool_picked):
|
* app/tools/gimpcolorpickertool.c (gimp_color_picker_tool_picked):
|
||||||
|
@ -43,8 +43,8 @@
|
|||||||
|
|
||||||
#include "base/pixel-region.h"
|
#include "base/pixel-region.h"
|
||||||
|
|
||||||
|
#include "gimpchannel.h"
|
||||||
#include "gimpcontainer.h"
|
#include "gimpcontainer.h"
|
||||||
#include "gimpdrawable.h"
|
|
||||||
#include "gimpgradient.h"
|
#include "gimpgradient.h"
|
||||||
#include "gimpimage.h"
|
#include "gimpimage.h"
|
||||||
#include "gimppalette.h"
|
#include "gimppalette.h"
|
||||||
@ -266,8 +266,10 @@ gimp_palette_import_make_palette (GHashTable *table,
|
|||||||
|
|
||||||
static GHashTable *
|
static GHashTable *
|
||||||
gimp_palette_import_extract (GimpImage *image,
|
gimp_palette_import_extract (GimpImage *image,
|
||||||
TileManager *tiles,
|
GimpPickable *pickable,
|
||||||
GimpImageType type,
|
gint pickable_off_x,
|
||||||
|
gint pickable_off_y,
|
||||||
|
gboolean selection_only,
|
||||||
gint x,
|
gint x,
|
||||||
gint y,
|
gint y,
|
||||||
gint width,
|
gint width,
|
||||||
@ -275,49 +277,82 @@ gimp_palette_import_extract (GimpImage *image,
|
|||||||
gint n_colors,
|
gint n_colors,
|
||||||
gint threshold)
|
gint threshold)
|
||||||
{
|
{
|
||||||
PixelRegion region;
|
TileManager *tiles;
|
||||||
gpointer pr;
|
GimpImageType type;
|
||||||
GHashTable *colors = NULL;
|
PixelRegion region;
|
||||||
|
PixelRegion mask_region;
|
||||||
|
PixelRegion *maskPR = NULL;
|
||||||
|
gpointer pr;
|
||||||
|
GHashTable *colors = NULL;
|
||||||
|
|
||||||
|
tiles = gimp_pickable_get_tiles (pickable);
|
||||||
|
type = gimp_pickable_get_image_type (pickable);
|
||||||
|
|
||||||
pixel_region_init (®ion, tiles, x, y, width, height, FALSE);
|
pixel_region_init (®ion, tiles, x, y, width, height, FALSE);
|
||||||
|
|
||||||
for (pr = pixel_regions_register (1, ®ion);
|
if (selection_only &&
|
||||||
|
! gimp_channel_is_empty (gimp_image_get_mask (image)))
|
||||||
|
{
|
||||||
|
pixel_region_init (&mask_region,
|
||||||
|
GIMP_DRAWABLE (gimp_image_get_mask (image))->tiles,
|
||||||
|
x + pickable_off_x, y + pickable_off_y,
|
||||||
|
width, height,
|
||||||
|
FALSE);
|
||||||
|
|
||||||
|
maskPR = &mask_region;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (pr = pixel_regions_register (maskPR ? 2 : 1, ®ion, maskPR);
|
||||||
pr != NULL;
|
pr != NULL;
|
||||||
pr = pixel_regions_process (pr))
|
pr = pixel_regions_process (pr))
|
||||||
{
|
{
|
||||||
const guchar *data = region.data;
|
const guchar *data = region.data;
|
||||||
|
const guchar *mask_data = NULL;
|
||||||
gint i, j;
|
gint i, j;
|
||||||
|
|
||||||
|
if (maskPR)
|
||||||
|
mask_data = maskPR->data;
|
||||||
|
|
||||||
for (i = 0; i < region.h; i++)
|
for (i = 0; i < region.h; i++)
|
||||||
{
|
{
|
||||||
const guchar *idata = data;
|
const guchar *idata = data;
|
||||||
|
const guchar *mdata = mask_data;
|
||||||
|
|
||||||
for (j = 0; j < region.w; j++)
|
for (j = 0; j < region.w; j++)
|
||||||
{
|
{
|
||||||
guchar rgba[MAX_CHANNELS];
|
if (! mdata || *mdata)
|
||||||
|
|
||||||
gimp_image_get_color (image, type, idata, rgba);
|
|
||||||
|
|
||||||
/* ignore completely transparent pixels */
|
|
||||||
if (rgba[ALPHA_PIX])
|
|
||||||
{
|
{
|
||||||
guchar rgb_real[MAX_CHANNELS];
|
guchar rgba[MAX_CHANNELS];
|
||||||
|
|
||||||
memcpy (rgb_real, rgba, MAX_CHANNELS);
|
gimp_image_get_color (image, type, idata, rgba);
|
||||||
|
|
||||||
rgba[0] = (rgba[0] / threshold) * threshold;
|
/* ignore completely transparent pixels */
|
||||||
rgba[1] = (rgba[1] / threshold) * threshold;
|
if (rgba[ALPHA_PIX])
|
||||||
rgba[2] = (rgba[2] / threshold) * threshold;
|
{
|
||||||
|
guchar rgb_real[MAX_CHANNELS];
|
||||||
|
|
||||||
colors = gimp_palette_import_store_colors (colors,
|
memcpy (rgb_real, rgba, MAX_CHANNELS);
|
||||||
rgba, rgb_real,
|
|
||||||
n_colors);
|
rgba[0] = (rgba[0] / threshold) * threshold;
|
||||||
|
rgba[1] = (rgba[1] / threshold) * threshold;
|
||||||
|
rgba[2] = (rgba[2] / threshold) * threshold;
|
||||||
|
|
||||||
|
colors = gimp_palette_import_store_colors (colors,
|
||||||
|
rgba, rgb_real,
|
||||||
|
n_colors);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
idata += region.bytes;
|
idata += region.bytes;
|
||||||
|
|
||||||
|
if (mdata)
|
||||||
|
mdata += maskPR->bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
data += region.rowstride;
|
data += region.rowstride;
|
||||||
|
|
||||||
|
if (mask_data)
|
||||||
|
mask_data += maskPR->rowstride;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -328,24 +363,41 @@ GimpPalette *
|
|||||||
gimp_palette_import_from_image (GimpImage *image,
|
gimp_palette_import_from_image (GimpImage *image,
|
||||||
const gchar *palette_name,
|
const gchar *palette_name,
|
||||||
gint n_colors,
|
gint n_colors,
|
||||||
gint threshold)
|
gint threshold,
|
||||||
|
gboolean selection_only)
|
||||||
{
|
{
|
||||||
GimpPickable *pickable;
|
GHashTable *colors;
|
||||||
GHashTable *colors;
|
gint x, y;
|
||||||
|
gint width, height;
|
||||||
|
|
||||||
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
|
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
|
||||||
g_return_val_if_fail (palette_name != NULL, NULL);
|
g_return_val_if_fail (palette_name != NULL, NULL);
|
||||||
g_return_val_if_fail (n_colors > 1, NULL);
|
g_return_val_if_fail (n_colors > 1, NULL);
|
||||||
g_return_val_if_fail (threshold > 0, NULL);
|
g_return_val_if_fail (threshold > 0, NULL);
|
||||||
|
|
||||||
pickable = GIMP_PICKABLE (image->projection);
|
gimp_pickable_flush (GIMP_PICKABLE (image->projection));
|
||||||
|
|
||||||
gimp_pickable_flush (pickable);
|
if (selection_only)
|
||||||
|
{
|
||||||
|
gimp_channel_bounds (gimp_image_get_mask (image),
|
||||||
|
&x, &y, &width, &height);
|
||||||
|
|
||||||
|
width -= x;
|
||||||
|
height -= y;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
x = 0;
|
||||||
|
y = 0;
|
||||||
|
width = image->width;
|
||||||
|
height = image->height;
|
||||||
|
}
|
||||||
|
|
||||||
colors = gimp_palette_import_extract (image,
|
colors = gimp_palette_import_extract (image,
|
||||||
gimp_pickable_get_tiles (pickable),
|
GIMP_PICKABLE (image->projection),
|
||||||
gimp_pickable_get_image_type (pickable),
|
0, 0,
|
||||||
0, 0, image->width, image->height,
|
selection_only,
|
||||||
|
x, y, width, height,
|
||||||
n_colors, threshold);
|
n_colors, threshold);
|
||||||
|
|
||||||
return gimp_palette_import_make_palette (colors, palette_name, n_colors);
|
return gimp_palette_import_make_palette (colors, palette_name, n_colors);
|
||||||
@ -391,11 +443,13 @@ GimpPalette *
|
|||||||
gimp_palette_import_from_drawable (GimpDrawable *drawable,
|
gimp_palette_import_from_drawable (GimpDrawable *drawable,
|
||||||
const gchar *palette_name,
|
const gchar *palette_name,
|
||||||
gint n_colors,
|
gint n_colors,
|
||||||
gint threshold)
|
gint threshold,
|
||||||
|
gboolean selection_only)
|
||||||
{
|
{
|
||||||
GHashTable *colors = NULL;
|
GHashTable *colors = NULL;
|
||||||
gint x, y;
|
gint x, y;
|
||||||
gint width, height;
|
gint width, height;
|
||||||
|
gint off_x, off_y;
|
||||||
|
|
||||||
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
|
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
|
||||||
g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)), NULL);
|
g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)), NULL);
|
||||||
@ -403,15 +457,28 @@ gimp_palette_import_from_drawable (GimpDrawable *drawable,
|
|||||||
g_return_val_if_fail (n_colors > 1, NULL);
|
g_return_val_if_fail (n_colors > 1, NULL);
|
||||||
g_return_val_if_fail (threshold > 0, NULL);
|
g_return_val_if_fail (threshold > 0, NULL);
|
||||||
|
|
||||||
if (gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
|
if (selection_only)
|
||||||
{
|
{
|
||||||
colors =
|
if (! gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
|
||||||
gimp_palette_import_extract (gimp_item_get_image (GIMP_ITEM (drawable)),
|
return NULL;
|
||||||
gimp_drawable_get_tiles (drawable),
|
|
||||||
gimp_drawable_type (drawable),
|
|
||||||
0, 0, width, height,
|
|
||||||
n_colors, threshold);
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
x = 0;
|
||||||
|
y = 0;
|
||||||
|
width = gimp_item_width (GIMP_ITEM (drawable));
|
||||||
|
height = gimp_item_height (GIMP_ITEM (drawable));
|
||||||
|
}
|
||||||
|
|
||||||
|
gimp_item_offsets (GIMP_ITEM (drawable), &off_x, &off_y);
|
||||||
|
|
||||||
|
colors =
|
||||||
|
gimp_palette_import_extract (gimp_item_get_image (GIMP_ITEM (drawable)),
|
||||||
|
GIMP_PICKABLE (drawable),
|
||||||
|
off_x, off_y,
|
||||||
|
selection_only,
|
||||||
|
x, y, width, height,
|
||||||
|
n_colors, threshold);
|
||||||
|
|
||||||
return gimp_palette_import_make_palette (colors, palette_name, n_colors);
|
return gimp_palette_import_make_palette (colors, palette_name, n_colors);
|
||||||
}
|
}
|
||||||
|
@ -27,13 +27,15 @@ GimpPalette * gimp_palette_import_from_gradient (GimpGradient *gradient,
|
|||||||
GimpPalette * gimp_palette_import_from_image (GimpImage *image,
|
GimpPalette * gimp_palette_import_from_image (GimpImage *image,
|
||||||
const gchar *palette_name,
|
const gchar *palette_name,
|
||||||
gint n_colors,
|
gint n_colors,
|
||||||
gint treshold);
|
gint treshold,
|
||||||
|
gboolean selection_only);
|
||||||
GimpPalette * gimp_palette_import_from_indexed_image (GimpImage *image,
|
GimpPalette * gimp_palette_import_from_indexed_image (GimpImage *image,
|
||||||
const gchar *palette_name);
|
const gchar *palette_name);
|
||||||
GimpPalette * gimp_palette_import_from_drawable (GimpDrawable *drawable,
|
GimpPalette * gimp_palette_import_from_drawable (GimpDrawable *drawable,
|
||||||
const gchar *palette_name,
|
const gchar *palette_name,
|
||||||
gint n_colors,
|
gint n_colors,
|
||||||
gint threshold);
|
gint threshold,
|
||||||
|
gboolean selection_only);
|
||||||
GimpPalette * gimp_palette_import_from_file (const gchar *filename,
|
GimpPalette * gimp_palette_import_from_file (const gchar *filename,
|
||||||
const gchar *palette_name,
|
const gchar *palette_name,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
#include "core/gimpcontainer.h"
|
#include "core/gimpcontainer.h"
|
||||||
#include "core/gimpcontext.h"
|
#include "core/gimpcontext.h"
|
||||||
#include "core/gimpdatafactory.h"
|
#include "core/gimpdatafactory.h"
|
||||||
|
#include "core/gimpdrawable.h"
|
||||||
#include "core/gimpgradient.h"
|
#include "core/gimpgradient.h"
|
||||||
#include "core/gimpimage.h"
|
#include "core/gimpimage.h"
|
||||||
#include "core/gimppalette.h"
|
#include "core/gimppalette.h"
|
||||||
@ -62,27 +63,32 @@ typedef struct _ImportDialog ImportDialog;
|
|||||||
|
|
||||||
struct _ImportDialog
|
struct _ImportDialog
|
||||||
{
|
{
|
||||||
GtkWidget *dialog;
|
GtkWidget *dialog;
|
||||||
|
|
||||||
ImportType import_type;
|
ImportType import_type;
|
||||||
GimpContext *context;
|
GimpContext *context;
|
||||||
GimpPalette *palette;
|
GimpImage *image;
|
||||||
|
|
||||||
GtkWidget *gradient_combo;
|
GimpPalette *palette;
|
||||||
GtkWidget *image_combo;
|
|
||||||
GtkWidget *file_chooser;
|
|
||||||
|
|
||||||
GtkWidget *entry;
|
GtkWidget *gradient_radio;
|
||||||
|
GtkWidget *image_radio;
|
||||||
|
GtkWidget *file_radio;
|
||||||
|
|
||||||
GtkWidget *image_radio;
|
GtkWidget *gradient_combo;
|
||||||
GtkWidget *gradient_radio;
|
GtkWidget *image_combo;
|
||||||
GtkWidget *palettefile_radio;
|
GtkWidget *file_chooser;
|
||||||
|
|
||||||
GtkAdjustment *threshold;
|
GtkWidget *sample_merged_toggle;
|
||||||
GtkAdjustment *num_colors;
|
GtkWidget *selection_only_toggle;
|
||||||
GtkAdjustment *columns;
|
|
||||||
|
|
||||||
GtkWidget *preview;
|
GtkWidget *entry;
|
||||||
|
GtkAdjustment *num_colors;
|
||||||
|
GtkAdjustment *columns;
|
||||||
|
GtkAdjustment *threshold;
|
||||||
|
|
||||||
|
GtkWidget *preview;
|
||||||
|
GtkWidget *no_colors_label;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -96,6 +102,10 @@ static void palette_import_gradient_changed (GimpContext *context,
|
|||||||
static void palette_import_image_changed (GimpContext *context,
|
static void palette_import_image_changed (GimpContext *context,
|
||||||
GimpImage *image,
|
GimpImage *image,
|
||||||
ImportDialog *dialog);
|
ImportDialog *dialog);
|
||||||
|
static void palette_import_layer_changed (GimpImage *image,
|
||||||
|
ImportDialog *dialog);
|
||||||
|
static void palette_import_mask_changed (GimpImage *image,
|
||||||
|
ImportDialog *dialog);
|
||||||
static void palette_import_filename_changed (GtkFileChooser *button,
|
static void palette_import_filename_changed (GtkFileChooser *button,
|
||||||
ImportDialog *dialog);
|
ImportDialog *dialog);
|
||||||
static void import_dialog_drop_callback (GtkWidget *widget,
|
static void import_dialog_drop_callback (GtkWidget *widget,
|
||||||
@ -159,7 +169,8 @@ palette_import_dialog_new (Gimp *gimp)
|
|||||||
GtkWidget *vbox;
|
GtkWidget *vbox;
|
||||||
GtkWidget *table;
|
GtkWidget *table;
|
||||||
GtkWidget *abox;
|
GtkWidget *abox;
|
||||||
GSList *group;
|
GtkSizeGroup *size_group;
|
||||||
|
GSList *group = NULL;
|
||||||
|
|
||||||
gradient = gimp_context_get_gradient (gimp_get_user_context (gimp));
|
gradient = gimp_context_get_gradient (gimp_get_user_context (gimp));
|
||||||
|
|
||||||
@ -212,19 +223,22 @@ palette_import_dialog_new (Gimp *gimp)
|
|||||||
gtk_box_pack_start (GTK_BOX (main_hbox), vbox, TRUE, TRUE, 0);
|
gtk_box_pack_start (GTK_BOX (main_hbox), vbox, TRUE, TRUE, 0);
|
||||||
gtk_widget_show (vbox);
|
gtk_widget_show (vbox);
|
||||||
|
|
||||||
|
|
||||||
/* The "Source" frame */
|
/* The "Source" frame */
|
||||||
|
|
||||||
frame = gimp_frame_new (_("Select Source"));
|
frame = gimp_frame_new (_("Select Source"));
|
||||||
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
|
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
|
||||||
gtk_widget_show (frame);
|
gtk_widget_show (frame);
|
||||||
|
|
||||||
table = gtk_table_new (3, 2, FALSE);
|
table = gtk_table_new (5, 2, FALSE);
|
||||||
gtk_table_set_col_spacings (GTK_TABLE (table), 6);
|
gtk_table_set_col_spacings (GTK_TABLE (table), 6);
|
||||||
gtk_table_set_row_spacings (GTK_TABLE (table), 6);
|
gtk_table_set_row_spacings (GTK_TABLE (table), 6);
|
||||||
gtk_container_add (GTK_CONTAINER (frame), table);
|
gtk_container_add (GTK_CONTAINER (frame), table);
|
||||||
gtk_widget_show (table);
|
gtk_widget_show (table);
|
||||||
|
|
||||||
dialog->gradient_radio =
|
dialog->gradient_radio =
|
||||||
gtk_radio_button_new_with_mnemonic (NULL, _("_Gradient"));
|
gtk_radio_button_new_with_mnemonic (group, _("_Gradient"));
|
||||||
|
group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (dialog->gradient_radio));
|
||||||
gtk_table_attach (GTK_TABLE (table), dialog->gradient_radio,
|
gtk_table_attach (GTK_TABLE (table), dialog->gradient_radio,
|
||||||
0, 1, 0, 1, GTK_FILL, GTK_FILL, 0, 0);
|
0, 1, 0, 1, GTK_FILL, GTK_FILL, 0, 0);
|
||||||
gtk_widget_show (dialog->gradient_radio);
|
gtk_widget_show (dialog->gradient_radio);
|
||||||
@ -233,11 +247,9 @@ palette_import_dialog_new (Gimp *gimp)
|
|||||||
G_CALLBACK (palette_import_grad_callback),
|
G_CALLBACK (palette_import_grad_callback),
|
||||||
dialog);
|
dialog);
|
||||||
|
|
||||||
group =
|
|
||||||
gtk_radio_button_get_group (GTK_RADIO_BUTTON (dialog->gradient_radio));
|
|
||||||
|
|
||||||
dialog->image_radio =
|
dialog->image_radio =
|
||||||
gtk_radio_button_new_with_mnemonic (group, _("I_mage"));
|
gtk_radio_button_new_with_mnemonic (group, _("I_mage"));
|
||||||
|
group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (dialog->image_radio));
|
||||||
gtk_table_attach (GTK_TABLE (table), dialog->image_radio,
|
gtk_table_attach (GTK_TABLE (table), dialog->image_radio,
|
||||||
0, 1, 1, 2, GTK_FILL, GTK_FILL, 0, 0);
|
0, 1, 1, 2, GTK_FILL, GTK_FILL, 0, 0);
|
||||||
gtk_widget_show (dialog->image_radio);
|
gtk_widget_show (dialog->image_radio);
|
||||||
@ -249,62 +261,70 @@ palette_import_dialog_new (Gimp *gimp)
|
|||||||
gtk_widget_set_sensitive (dialog->image_radio,
|
gtk_widget_set_sensitive (dialog->image_radio,
|
||||||
! gimp_container_is_empty (gimp->images));
|
! gimp_container_is_empty (gimp->images));
|
||||||
|
|
||||||
group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (dialog->image_radio));
|
dialog->sample_merged_toggle =
|
||||||
|
gtk_check_button_new_with_mnemonic (_("Sample _Merged"));
|
||||||
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->sample_merged_toggle),
|
||||||
|
TRUE);
|
||||||
|
gtk_table_attach (GTK_TABLE (table), dialog->sample_merged_toggle,
|
||||||
|
1, 2, 2, 3, GTK_FILL, GTK_FILL, 0, 0);
|
||||||
|
gtk_widget_show (dialog->sample_merged_toggle);
|
||||||
|
|
||||||
dialog->palettefile_radio =
|
g_signal_connect_swapped (dialog->sample_merged_toggle, "toggled",
|
||||||
|
G_CALLBACK (palette_import_make_palette),
|
||||||
|
dialog);
|
||||||
|
|
||||||
|
dialog->selection_only_toggle =
|
||||||
|
gtk_check_button_new_with_mnemonic (_("_Selected Pixels only"));
|
||||||
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->selection_only_toggle),
|
||||||
|
FALSE);
|
||||||
|
gtk_table_attach (GTK_TABLE (table), dialog->selection_only_toggle,
|
||||||
|
1, 2, 3, 4, GTK_FILL, GTK_FILL, 0, 0);
|
||||||
|
gtk_widget_show (dialog->selection_only_toggle);
|
||||||
|
|
||||||
|
g_signal_connect_swapped (dialog->selection_only_toggle, "toggled",
|
||||||
|
G_CALLBACK (palette_import_make_palette),
|
||||||
|
dialog);
|
||||||
|
|
||||||
|
dialog->file_radio =
|
||||||
gtk_radio_button_new_with_mnemonic (group, _("Palette _file"));
|
gtk_radio_button_new_with_mnemonic (group, _("Palette _file"));
|
||||||
gtk_table_attach (GTK_TABLE (table), dialog->palettefile_radio,
|
group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (dialog->image_radio));
|
||||||
0, 1, 2, 3, GTK_FILL, GTK_FILL, 0, 0);
|
gtk_table_attach (GTK_TABLE (table), dialog->file_radio,
|
||||||
gtk_widget_show (dialog->palettefile_radio);
|
0, 1, 4, 5, GTK_FILL, GTK_FILL, 0, 0);
|
||||||
|
gtk_widget_show (dialog->file_radio);
|
||||||
|
|
||||||
g_signal_connect (dialog->palettefile_radio, "toggled",
|
g_signal_connect (dialog->file_radio, "toggled",
|
||||||
G_CALLBACK (palette_import_file_callback),
|
G_CALLBACK (palette_import_file_callback),
|
||||||
dialog);
|
dialog);
|
||||||
|
|
||||||
|
size_group = gtk_size_group_new (GTK_SIZE_GROUP_VERTICAL);
|
||||||
|
|
||||||
/* The gradient menu */
|
/* The gradient menu */
|
||||||
dialog->gradient_combo =
|
dialog->gradient_combo =
|
||||||
gimp_container_combo_box_new (gimp->gradient_factory->container,
|
gimp_container_combo_box_new (gimp->gradient_factory->container,
|
||||||
dialog->context, 24, 1);
|
dialog->context, 24, 1);
|
||||||
gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
|
gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
|
||||||
NULL, 0.0, 0.5, dialog->gradient_combo, 1, FALSE);
|
NULL, 0.0, 0.5, dialog->gradient_combo, 1, FALSE);
|
||||||
|
gtk_size_group_add_widget (size_group, dialog->gradient_combo);
|
||||||
|
|
||||||
/* The image menu */
|
/* The image menu */
|
||||||
dialog->image_combo =
|
dialog->image_combo =
|
||||||
gimp_container_combo_box_new (gimp->images, dialog->context, 24, 1);
|
gimp_container_combo_box_new (gimp->images, dialog->context, 24, 1);
|
||||||
gimp_table_attach_aligned (GTK_TABLE (table), 0, 1,
|
gimp_table_attach_aligned (GTK_TABLE (table), 0, 1,
|
||||||
NULL, 0.0, 0.5, dialog->image_combo, 1, FALSE);
|
NULL, 0.0, 0.5, dialog->image_combo, 1, FALSE);
|
||||||
|
gtk_size_group_add_widget (size_group, dialog->image_combo);
|
||||||
|
|
||||||
/* Palette file name entry */
|
/* Palette file name entry */
|
||||||
dialog->file_chooser = gtk_file_chooser_button_new (_("Select Palette File"),
|
dialog->file_chooser = gtk_file_chooser_button_new (_("Select Palette File"),
|
||||||
GTK_FILE_CHOOSER_ACTION_OPEN);
|
GTK_FILE_CHOOSER_ACTION_OPEN);
|
||||||
gimp_table_attach_aligned (GTK_TABLE (table), 0, 2,
|
gimp_table_attach_aligned (GTK_TABLE (table), 0, 4,
|
||||||
NULL, 0.0, 0.5, dialog->file_chooser, 1, FALSE);
|
NULL, 0.0, 0.5, dialog->file_chooser, 1, FALSE);
|
||||||
gtk_widget_show (dialog->file_chooser);
|
gtk_size_group_add_widget (size_group, dialog->file_chooser);
|
||||||
|
|
||||||
{
|
g_object_unref (size_group);
|
||||||
gint focus_line_width;
|
|
||||||
gint focus_padding;
|
|
||||||
gint ythickness;
|
|
||||||
gint ysize;
|
|
||||||
|
|
||||||
gtk_widget_style_get (dialog->gradient_combo,
|
|
||||||
"focus-line-width", &focus_line_width,
|
|
||||||
"focus-padding", &focus_padding,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
ythickness = dialog->gradient_combo->style->ythickness;
|
|
||||||
|
|
||||||
ysize = 24 + (2 * (1 /* CHILD_SPACING */ +
|
|
||||||
ythickness +
|
|
||||||
focus_padding +
|
|
||||||
focus_line_width));
|
|
||||||
|
|
||||||
gtk_widget_set_size_request (dialog->gradient_combo, -1, ysize);
|
|
||||||
gtk_widget_set_size_request (dialog->image_combo, -1, ysize);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* The "Import" frame */
|
/* The "Import" frame */
|
||||||
|
|
||||||
frame = gimp_frame_new (_("Import Options"));
|
frame = gimp_frame_new (_("Import Options"));
|
||||||
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
|
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
|
||||||
gtk_widget_show (frame);
|
gtk_widget_show (frame);
|
||||||
@ -356,7 +376,6 @@ palette_import_dialog_new (Gimp *gimp)
|
|||||||
1, 1, 128, 1, 8, 0,
|
1, 1, 128, 1, 8, 0,
|
||||||
TRUE, 0.0, 0.0,
|
TRUE, 0.0, 0.0,
|
||||||
NULL, NULL));
|
NULL, NULL));
|
||||||
gimp_scale_entry_set_sensitive (GTK_OBJECT (dialog->threshold), FALSE);
|
|
||||||
|
|
||||||
g_signal_connect_swapped (dialog->threshold, "value-changed",
|
g_signal_connect_swapped (dialog->threshold, "value-changed",
|
||||||
G_CALLBACK (palette_import_make_palette),
|
G_CALLBACK (palette_import_make_palette),
|
||||||
@ -368,8 +387,12 @@ palette_import_dialog_new (Gimp *gimp)
|
|||||||
gtk_box_pack_start (GTK_BOX (main_hbox), frame, FALSE, FALSE, 0);
|
gtk_box_pack_start (GTK_BOX (main_hbox), frame, FALSE, FALSE, 0);
|
||||||
gtk_widget_show (frame);
|
gtk_widget_show (frame);
|
||||||
|
|
||||||
|
vbox = gtk_vbox_new (FALSE, 6);
|
||||||
|
gtk_container_add (GTK_CONTAINER (frame), vbox);
|
||||||
|
gtk_widget_show (vbox);
|
||||||
|
|
||||||
abox = gtk_alignment_new (0.0, 0.0, 0.0, 0.0);
|
abox = gtk_alignment_new (0.0, 0.0, 0.0, 0.0);
|
||||||
gtk_container_add (GTK_CONTAINER (frame), abox);
|
gtk_box_pack_start (GTK_BOX (vbox), abox, FALSE, FALSE, 0);
|
||||||
gtk_widget_show (abox);
|
gtk_widget_show (abox);
|
||||||
|
|
||||||
dialog->preview = gimp_view_new_full_by_types (GIMP_TYPE_VIEW,
|
dialog->preview = gimp_view_new_full_by_types (GIMP_TYPE_VIEW,
|
||||||
@ -379,6 +402,17 @@ palette_import_dialog_new (Gimp *gimp)
|
|||||||
gtk_container_add (GTK_CONTAINER (abox), dialog->preview);
|
gtk_container_add (GTK_CONTAINER (abox), dialog->preview);
|
||||||
gtk_widget_show (dialog->preview);
|
gtk_widget_show (dialog->preview);
|
||||||
|
|
||||||
|
dialog->no_colors_label =
|
||||||
|
gtk_label_new (_("The selected source contains no colors."));
|
||||||
|
gtk_widget_set_size_request (dialog->no_colors_label, 194, -1);
|
||||||
|
gtk_label_set_line_wrap (GTK_LABEL (dialog->no_colors_label), TRUE);
|
||||||
|
gimp_label_set_attributes (GTK_LABEL (dialog->no_colors_label),
|
||||||
|
PANGO_ATTR_STYLE, PANGO_STYLE_ITALIC,
|
||||||
|
-1);
|
||||||
|
gtk_box_pack_start (GTK_BOX (vbox), dialog->no_colors_label, FALSE, FALSE, 0);
|
||||||
|
gtk_widget_show (dialog->no_colors_label);
|
||||||
|
|
||||||
|
|
||||||
/* keep the dialog up-to-date */
|
/* keep the dialog up-to-date */
|
||||||
|
|
||||||
g_signal_connect (gimp->images, "add",
|
g_signal_connect (gimp->images, "add",
|
||||||
@ -398,8 +432,6 @@ palette_import_dialog_new (Gimp *gimp)
|
|||||||
G_CALLBACK (palette_import_filename_changed),
|
G_CALLBACK (palette_import_filename_changed),
|
||||||
dialog);
|
dialog);
|
||||||
|
|
||||||
palette_import_make_palette (dialog);
|
|
||||||
|
|
||||||
palette_import_grad_callback (dialog->gradient_radio, dialog);
|
palette_import_grad_callback (dialog->gradient_radio, dialog);
|
||||||
|
|
||||||
return dialog;
|
return dialog;
|
||||||
@ -415,6 +447,8 @@ palette_import_response (GtkWidget *widget,
|
|||||||
{
|
{
|
||||||
Gimp *gimp = dialog->context->gimp;
|
Gimp *gimp = dialog->context->gimp;
|
||||||
|
|
||||||
|
palette_import_image_changed (dialog->context, NULL, dialog);
|
||||||
|
|
||||||
g_signal_handlers_disconnect_by_func (gimp->images,
|
g_signal_handlers_disconnect_by_func (gimp->images,
|
||||||
palette_import_image_add,
|
palette_import_image_add,
|
||||||
dialog);
|
dialog);
|
||||||
@ -422,22 +456,23 @@ palette_import_response (GtkWidget *widget,
|
|||||||
palette_import_image_remove,
|
palette_import_image_remove,
|
||||||
dialog);
|
dialog);
|
||||||
|
|
||||||
if (response_id == GTK_RESPONSE_OK && dialog->palette)
|
if (dialog->palette)
|
||||||
{
|
{
|
||||||
const gchar *name = gtk_entry_get_text (GTK_ENTRY (dialog->entry));
|
if (response_id == GTK_RESPONSE_OK)
|
||||||
|
{
|
||||||
|
const gchar *name = gtk_entry_get_text (GTK_ENTRY (dialog->entry));
|
||||||
|
|
||||||
if (name && *name)
|
if (name && *name)
|
||||||
gimp_object_set_name (GIMP_OBJECT (dialog->palette), name);
|
gimp_object_set_name (GIMP_OBJECT (dialog->palette), name);
|
||||||
|
|
||||||
gimp_container_add (gimp->palette_factory->container,
|
gimp_container_add (gimp->palette_factory->container,
|
||||||
GIMP_OBJECT (dialog->palette));
|
GIMP_OBJECT (dialog->palette));
|
||||||
|
}
|
||||||
|
|
||||||
|
g_object_unref (dialog->palette);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_object_unref (dialog->context);
|
g_object_unref (dialog->context);
|
||||||
|
|
||||||
if (dialog->palette)
|
|
||||||
g_object_unref (dialog->palette);
|
|
||||||
|
|
||||||
gtk_widget_destroy (dialog->dialog);
|
gtk_widget_destroy (dialog->dialog);
|
||||||
g_free (dialog);
|
g_free (dialog);
|
||||||
|
|
||||||
@ -466,38 +501,81 @@ palette_import_image_changed (GimpContext *context,
|
|||||||
GimpImage *image,
|
GimpImage *image,
|
||||||
ImportDialog *dialog)
|
ImportDialog *dialog)
|
||||||
{
|
{
|
||||||
|
if (dialog->image)
|
||||||
|
{
|
||||||
|
g_signal_handlers_disconnect_by_func (dialog->image,
|
||||||
|
palette_import_layer_changed,
|
||||||
|
dialog);
|
||||||
|
g_signal_handlers_disconnect_by_func (dialog->image,
|
||||||
|
palette_import_mask_changed,
|
||||||
|
dialog);
|
||||||
|
}
|
||||||
|
|
||||||
|
dialog->image = image;
|
||||||
|
|
||||||
if (dialog->import_type == IMAGE_IMPORT)
|
if (dialog->import_type == IMAGE_IMPORT)
|
||||||
{
|
{
|
||||||
gboolean sensitive;
|
gboolean sensitive = FALSE;
|
||||||
|
|
||||||
if (image)
|
if (image)
|
||||||
{
|
{
|
||||||
gchar *basename;
|
gchar *name;
|
||||||
gchar *label;
|
gchar *label;
|
||||||
|
|
||||||
basename =
|
name = file_utils_uri_display_basename (gimp_image_get_uri (image));
|
||||||
file_utils_uri_display_basename (gimp_image_get_uri (image));
|
label = g_strdup_printf ("%s-%d", name, gimp_image_get_ID (image));
|
||||||
label = g_strdup_printf ("%s-%d", basename, gimp_image_get_ID (image));
|
g_free (name);
|
||||||
g_free (basename);
|
|
||||||
|
|
||||||
gtk_entry_set_text (GTK_ENTRY (dialog->entry), label);
|
gtk_entry_set_text (GTK_ENTRY (dialog->entry), label);
|
||||||
|
|
||||||
g_free (label);
|
g_free (label);
|
||||||
|
|
||||||
palette_import_make_palette (dialog);
|
palette_import_make_palette (dialog);
|
||||||
|
|
||||||
sensitive = (gimp_image_base_type (image) != GIMP_INDEXED);
|
if (gimp_image_base_type (image) != GIMP_INDEXED)
|
||||||
}
|
sensitive = TRUE;
|
||||||
else
|
|
||||||
{
|
|
||||||
sensitive = FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gtk_widget_set_sensitive (dialog->sample_merged_toggle, sensitive);
|
||||||
|
gtk_widget_set_sensitive (dialog->selection_only_toggle, sensitive);
|
||||||
gimp_scale_entry_set_sensitive (GTK_OBJECT (dialog->threshold),
|
gimp_scale_entry_set_sensitive (GTK_OBJECT (dialog->threshold),
|
||||||
sensitive);
|
sensitive);
|
||||||
gimp_scale_entry_set_sensitive (GTK_OBJECT (dialog->num_colors),
|
gimp_scale_entry_set_sensitive (GTK_OBJECT (dialog->num_colors),
|
||||||
sensitive);
|
sensitive);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (dialog->image)
|
||||||
|
{
|
||||||
|
g_signal_connect (dialog->image, "active-layer-changed",
|
||||||
|
G_CALLBACK (palette_import_layer_changed),
|
||||||
|
dialog);
|
||||||
|
g_signal_connect (dialog->image, "mask-changed",
|
||||||
|
G_CALLBACK (palette_import_mask_changed),
|
||||||
|
dialog);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
palette_import_layer_changed (GimpImage *image,
|
||||||
|
ImportDialog *dialog)
|
||||||
|
{
|
||||||
|
if (dialog->import_type == IMAGE_IMPORT &&
|
||||||
|
! gtk_toggle_button_get_active
|
||||||
|
(GTK_TOGGLE_BUTTON (dialog->sample_merged_toggle)))
|
||||||
|
{
|
||||||
|
palette_import_make_palette (dialog);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
palette_import_mask_changed (GimpImage *image,
|
||||||
|
ImportDialog *dialog)
|
||||||
|
{
|
||||||
|
if (dialog->import_type == IMAGE_IMPORT &&
|
||||||
|
gtk_toggle_button_get_active
|
||||||
|
(GTK_TOGGLE_BUTTON (dialog->selection_only_toggle)))
|
||||||
|
{
|
||||||
|
palette_import_make_palette (dialog);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -557,9 +635,26 @@ import_dialog_drop_callback (GtkWidget *widget,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* the import source menu item callbacks ***********************************/
|
/* the import source menu item callbacks ***********************************/
|
||||||
|
|
||||||
|
static void
|
||||||
|
palette_import_set_sensitive (ImportDialog *dialog)
|
||||||
|
{
|
||||||
|
gboolean gradient = (dialog->import_type == GRADIENT_IMPORT);
|
||||||
|
gboolean image = (dialog->import_type == IMAGE_IMPORT);
|
||||||
|
gboolean file = (dialog->import_type == FILE_IMPORT);
|
||||||
|
|
||||||
|
gtk_widget_set_sensitive (dialog->gradient_combo, gradient);
|
||||||
|
gtk_widget_set_sensitive (dialog->image_combo, image);
|
||||||
|
gtk_widget_set_sensitive (dialog->sample_merged_toggle, image);
|
||||||
|
gtk_widget_set_sensitive (dialog->selection_only_toggle, image);
|
||||||
|
gtk_widget_set_sensitive (dialog->file_chooser, file);
|
||||||
|
|
||||||
|
gimp_scale_entry_set_sensitive (GTK_OBJECT (dialog->num_colors), ! file);
|
||||||
|
gimp_scale_entry_set_sensitive (GTK_OBJECT (dialog->columns), ! file);
|
||||||
|
gimp_scale_entry_set_sensitive (GTK_OBJECT (dialog->threshold), image);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
palette_import_grad_callback (GtkWidget *widget,
|
palette_import_grad_callback (GtkWidget *widget,
|
||||||
ImportDialog *dialog)
|
ImportDialog *dialog)
|
||||||
@ -573,16 +668,10 @@ palette_import_grad_callback (GtkWidget *widget,
|
|||||||
|
|
||||||
gradient = gimp_context_get_gradient (dialog->context);
|
gradient = gimp_context_get_gradient (dialog->context);
|
||||||
|
|
||||||
gtk_widget_set_sensitive (dialog->gradient_combo, TRUE);
|
|
||||||
gtk_widget_set_sensitive (dialog->image_combo, FALSE);
|
|
||||||
gtk_widget_set_sensitive (dialog->file_chooser, FALSE);
|
|
||||||
|
|
||||||
gtk_entry_set_text (GTK_ENTRY (dialog->entry),
|
gtk_entry_set_text (GTK_ENTRY (dialog->entry),
|
||||||
GIMP_OBJECT (gradient)->name);
|
GIMP_OBJECT (gradient)->name);
|
||||||
|
|
||||||
gimp_scale_entry_set_sensitive (GTK_OBJECT (dialog->threshold), FALSE);
|
palette_import_set_sensitive (dialog);
|
||||||
gimp_scale_entry_set_sensitive (GTK_OBJECT (dialog->num_colors), TRUE);
|
|
||||||
gimp_scale_entry_set_sensitive (GTK_OBJECT (dialog->columns), TRUE);
|
|
||||||
|
|
||||||
palette_import_make_palette (dialog);
|
palette_import_make_palette (dialog);
|
||||||
}
|
}
|
||||||
@ -604,13 +693,7 @@ palette_import_image_callback (GtkWidget *widget,
|
|||||||
image = (GimpImage *)
|
image = (GimpImage *)
|
||||||
gimp_container_get_child_by_index (dialog->context->gimp->images, 0);
|
gimp_container_get_child_by_index (dialog->context->gimp->images, 0);
|
||||||
|
|
||||||
gtk_widget_set_sensitive (dialog->gradient_combo, FALSE);
|
palette_import_set_sensitive (dialog);
|
||||||
gtk_widget_set_sensitive (dialog->image_combo, TRUE);
|
|
||||||
gtk_widget_set_sensitive (dialog->file_chooser, FALSE);
|
|
||||||
|
|
||||||
gimp_scale_entry_set_sensitive (GTK_OBJECT (dialog->threshold), TRUE);
|
|
||||||
gimp_scale_entry_set_sensitive (GTK_OBJECT (dialog->num_colors), TRUE);
|
|
||||||
gimp_scale_entry_set_sensitive (GTK_OBJECT (dialog->columns), TRUE);
|
|
||||||
|
|
||||||
palette_import_image_changed (dialog->context, image, dialog);
|
palette_import_image_changed (dialog->context, image, dialog);
|
||||||
}
|
}
|
||||||
@ -626,10 +709,6 @@ palette_import_file_callback (GtkWidget *widget,
|
|||||||
|
|
||||||
dialog->import_type = FILE_IMPORT;
|
dialog->import_type = FILE_IMPORT;
|
||||||
|
|
||||||
gtk_widget_set_sensitive (dialog->gradient_combo, FALSE);
|
|
||||||
gtk_widget_set_sensitive (dialog->image_combo, FALSE);
|
|
||||||
gtk_widget_set_sensitive (dialog->file_chooser, TRUE);
|
|
||||||
|
|
||||||
filename =
|
filename =
|
||||||
gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog->file_chooser));
|
gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog->file_chooser));
|
||||||
|
|
||||||
@ -640,17 +719,15 @@ palette_import_file_callback (GtkWidget *widget,
|
|||||||
/* TODO: strip filename extension */
|
/* TODO: strip filename extension */
|
||||||
gtk_entry_set_text (GTK_ENTRY (dialog->entry), basename);
|
gtk_entry_set_text (GTK_ENTRY (dialog->entry), basename);
|
||||||
g_free (basename);
|
g_free (basename);
|
||||||
|
|
||||||
|
g_free (filename);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gtk_entry_set_text (GTK_ENTRY (dialog->entry), "");
|
gtk_entry_set_text (GTK_ENTRY (dialog->entry), "");
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free (filename);
|
palette_import_set_sensitive (dialog);
|
||||||
|
|
||||||
gimp_scale_entry_set_sensitive (GTK_OBJECT (dialog->threshold), FALSE);
|
|
||||||
gimp_scale_entry_set_sensitive (GTK_OBJECT (dialog->num_colors), FALSE);
|
|
||||||
gimp_scale_entry_set_sensitive (GTK_OBJECT (dialog->columns), FALSE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -726,18 +803,41 @@ palette_import_make_palette (ImportDialog *dialog)
|
|||||||
case IMAGE_IMPORT:
|
case IMAGE_IMPORT:
|
||||||
{
|
{
|
||||||
GimpImage *image = gimp_context_get_image (dialog->context);
|
GimpImage *image = gimp_context_get_image (dialog->context);
|
||||||
|
gboolean sample_merged;
|
||||||
|
gboolean selection_only;
|
||||||
|
|
||||||
|
sample_merged =
|
||||||
|
gtk_toggle_button_get_active
|
||||||
|
(GTK_TOGGLE_BUTTON (dialog->sample_merged_toggle));
|
||||||
|
|
||||||
|
selection_only =
|
||||||
|
gtk_toggle_button_get_active
|
||||||
|
(GTK_TOGGLE_BUTTON (dialog->selection_only_toggle));
|
||||||
|
|
||||||
if (gimp_image_base_type (image) == GIMP_INDEXED)
|
if (gimp_image_base_type (image) == GIMP_INDEXED)
|
||||||
{
|
{
|
||||||
palette = gimp_palette_import_from_indexed_image (image,
|
palette = gimp_palette_import_from_indexed_image (image,
|
||||||
palette_name);
|
palette_name);
|
||||||
}
|
}
|
||||||
else
|
else if (sample_merged)
|
||||||
{
|
{
|
||||||
palette = gimp_palette_import_from_image (image,
|
palette = gimp_palette_import_from_image (image,
|
||||||
palette_name,
|
palette_name,
|
||||||
n_colors,
|
n_colors,
|
||||||
threshold);
|
threshold,
|
||||||
|
selection_only);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GimpDrawable *drawable;
|
||||||
|
|
||||||
|
drawable = GIMP_DRAWABLE (gimp_image_get_active_layer (image));
|
||||||
|
|
||||||
|
palette = gimp_palette_import_from_drawable (drawable,
|
||||||
|
palette_name,
|
||||||
|
n_colors,
|
||||||
|
threshold,
|
||||||
|
selection_only);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -775,4 +875,9 @@ palette_import_make_palette (ImportDialog *dialog)
|
|||||||
|
|
||||||
dialog->palette = palette;
|
dialog->palette = palette;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (dialog->palette && dialog->palette->n_colors > 0)
|
||||||
|
gtk_widget_hide (dialog->no_colors_label);
|
||||||
|
else
|
||||||
|
gtk_widget_show (dialog->no_colors_label);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user