mirror of https://github.com/GNOME/gimp.git
app, libgimpcolor: more move to GeglColor.
- New libgimpcolor functions: gimp_color_parse_hex() and gimp_color_parse_name(). - GimpColorHexEntry is now space-invaded. Though recognized color names and hexadecimal syntax are sRGB only (because CSS and SVG specifications explicitly say that this syntax is for sRGB values), it is possible to enter non-sRGB values with gimp_color_hex_entry_set_color(). - GimpColorSelection is now space-invaded.
This commit is contained in:
parent
ee19ad54d6
commit
093d00572a
|
@ -339,6 +339,7 @@ gimp_color_dialog_response (GtkDialog *gtk_dialog,
|
||||||
GimpImage *image = NULL;
|
GimpImage *image = NULL;
|
||||||
GimpColormapSelection *colormap_selection;
|
GimpColormapSelection *colormap_selection;
|
||||||
gint col_index;
|
gint col_index;
|
||||||
|
GeglColor *color = NULL;
|
||||||
GimpRGB rgb;
|
GimpRGB rgb;
|
||||||
|
|
||||||
colormap_selection = GIMP_COLORMAP_SELECTION (dialog->colormap_selection);
|
colormap_selection = GIMP_COLORMAP_SELECTION (dialog->colormap_selection);
|
||||||
|
@ -358,21 +359,18 @@ gimp_color_dialog_response (GtkDialog *gtk_dialog,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GTK_RESPONSE_OK:
|
case GTK_RESPONSE_OK:
|
||||||
gimp_color_selection_get_color (GIMP_COLOR_SELECTION (dialog->selection),
|
color = gimp_color_selection_get_color (GIMP_COLOR_SELECTION (dialog->selection));
|
||||||
&rgb);
|
gegl_color_get_pixel (color, babl_format ("R'G'B'A double"), &rgb);
|
||||||
|
|
||||||
if (dialog->colormap_editing && image)
|
if (dialog->colormap_editing && image)
|
||||||
{
|
{
|
||||||
GeglColor *color = gegl_color_new (NULL);
|
GeglColor *old_color;
|
||||||
GimpRGB old_color;
|
|
||||||
|
|
||||||
dialog->colormap_editing = FALSE;
|
dialog->colormap_editing = FALSE;
|
||||||
|
|
||||||
/* Restore old color for undo */
|
/* Restore old color for undo */
|
||||||
gimp_color_selection_get_old_color (GIMP_COLOR_SELECTION (dialog->selection), &old_color);
|
old_color = gimp_color_selection_get_old_color (GIMP_COLOR_SELECTION (dialog->selection));
|
||||||
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), &old_color);
|
gimp_image_set_colormap_entry (image, col_index, old_color, FALSE);
|
||||||
gimp_image_set_colormap_entry (image, col_index, color, FALSE);
|
|
||||||
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), &rgb);
|
|
||||||
gimp_image_set_colormap_entry (image, col_index, color, TRUE);
|
gimp_image_set_colormap_entry (image, col_index, color, TRUE);
|
||||||
gimp_image_flush (image);
|
gimp_image_flush (image);
|
||||||
|
|
||||||
|
@ -380,40 +378,39 @@ gimp_color_dialog_response (GtkDialog *gtk_dialog,
|
||||||
g_signal_emit (dialog, color_dialog_signals[UPDATE], 0,
|
g_signal_emit (dialog, color_dialog_signals[UPDATE], 0,
|
||||||
&rgb, GIMP_COLOR_DIALOG_UPDATE);
|
&rgb, GIMP_COLOR_DIALOG_UPDATE);
|
||||||
|
|
||||||
g_object_unref (color);
|
g_object_unref (old_color);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
g_signal_emit (dialog, color_dialog_signals[UPDATE], 0,
|
g_signal_emit (dialog, color_dialog_signals[UPDATE], 0,
|
||||||
&rgb, GIMP_COLOR_DIALOG_OK);
|
&rgb, GIMP_COLOR_DIALOG_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_object_unref (color);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
gimp_color_selection_get_old_color (GIMP_COLOR_SELECTION (dialog->selection),
|
color = gimp_color_selection_get_old_color (GIMP_COLOR_SELECTION (dialog->selection));
|
||||||
&rgb);
|
gegl_color_get_pixel (color, babl_format ("R'G'B'A double"), &rgb);
|
||||||
|
|
||||||
if (dialog->colormap_editing && image)
|
if (dialog->colormap_editing && image)
|
||||||
{
|
{
|
||||||
GeglColor *color = gegl_color_new (NULL);
|
|
||||||
|
|
||||||
dialog->colormap_editing = FALSE;
|
dialog->colormap_editing = FALSE;
|
||||||
|
|
||||||
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), &rgb);
|
|
||||||
gimp_image_set_colormap_entry (image, col_index, color, FALSE);
|
gimp_image_set_colormap_entry (image, col_index, color, FALSE);
|
||||||
gimp_projection_flush (gimp_image_get_projection (image));
|
gimp_projection_flush (gimp_image_get_projection (image));
|
||||||
|
|
||||||
gtk_stack_set_visible_child_name (GTK_STACK (dialog->stack), "colormap");
|
gtk_stack_set_visible_child_name (GTK_STACK (dialog->stack), "colormap");
|
||||||
g_signal_emit (dialog, color_dialog_signals[UPDATE], 0,
|
g_signal_emit (dialog, color_dialog_signals[UPDATE], 0,
|
||||||
&rgb, GIMP_COLOR_DIALOG_UPDATE);
|
&rgb, GIMP_COLOR_DIALOG_UPDATE);
|
||||||
|
|
||||||
g_object_unref (color);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
g_signal_emit (dialog, color_dialog_signals[UPDATE], 0,
|
g_signal_emit (dialog, color_dialog_signals[UPDATE], 0,
|
||||||
&rgb, GIMP_COLOR_DIALOG_CANCEL);
|
&rgb, GIMP_COLOR_DIALOG_CANCEL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_object_unref (color);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -431,12 +428,13 @@ gimp_color_dialog_new (GimpViewable *viewable,
|
||||||
GtkWidget *parent,
|
GtkWidget *parent,
|
||||||
GimpDialogFactory *dialog_factory,
|
GimpDialogFactory *dialog_factory,
|
||||||
const gchar *dialog_identifier,
|
const gchar *dialog_identifier,
|
||||||
const GimpRGB *color,
|
const GimpRGB *rgb,
|
||||||
gboolean wants_updates,
|
gboolean wants_updates,
|
||||||
gboolean show_alpha)
|
gboolean show_alpha)
|
||||||
{
|
{
|
||||||
GimpColorDialog *dialog;
|
GimpColorDialog *dialog;
|
||||||
const gchar *role;
|
const gchar *role;
|
||||||
|
GeglColor *color;
|
||||||
gboolean use_header_bar;
|
gboolean use_header_bar;
|
||||||
|
|
||||||
g_return_val_if_fail (viewable == NULL || GIMP_IS_VIEWABLE (viewable), NULL);
|
g_return_val_if_fail (viewable == NULL || GIMP_IS_VIEWABLE (viewable), NULL);
|
||||||
|
@ -446,7 +444,7 @@ gimp_color_dialog_new (GimpViewable *viewable,
|
||||||
GIMP_IS_DIALOG_FACTORY (dialog_factory), NULL);
|
GIMP_IS_DIALOG_FACTORY (dialog_factory), NULL);
|
||||||
g_return_val_if_fail (dialog_factory == NULL || dialog_identifier != NULL,
|
g_return_val_if_fail (dialog_factory == NULL || dialog_identifier != NULL,
|
||||||
NULL);
|
NULL);
|
||||||
g_return_val_if_fail (color != NULL, NULL);
|
g_return_val_if_fail (rgb != NULL, NULL);
|
||||||
|
|
||||||
role = dialog_identifier ? dialog_identifier : "gimp-color-selector";
|
role = dialog_identifier ? dialog_identifier : "gimp-color-selector";
|
||||||
|
|
||||||
|
@ -517,29 +515,37 @@ gimp_color_dialog_new (GimpViewable *viewable,
|
||||||
g_object_set_data (G_OBJECT (context->gimp->config->color_management),
|
g_object_set_data (G_OBJECT (context->gimp->config->color_management),
|
||||||
"gimp-context", NULL);
|
"gimp-context", NULL);
|
||||||
|
|
||||||
|
color = gegl_color_new (NULL);
|
||||||
|
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), rgb);
|
||||||
gimp_color_selection_set_color (GIMP_COLOR_SELECTION (dialog->selection),
|
gimp_color_selection_set_color (GIMP_COLOR_SELECTION (dialog->selection),
|
||||||
color);
|
color);
|
||||||
gimp_color_selection_set_old_color (GIMP_COLOR_SELECTION (dialog->selection),
|
gimp_color_selection_set_old_color (GIMP_COLOR_SELECTION (dialog->selection),
|
||||||
color);
|
color);
|
||||||
|
g_object_unref (color);
|
||||||
|
|
||||||
return GTK_WIDGET (dialog);
|
return GTK_WIDGET (dialog);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gimp_color_dialog_set_color (GimpColorDialog *dialog,
|
gimp_color_dialog_set_color (GimpColorDialog *dialog,
|
||||||
const GimpRGB *color)
|
const GimpRGB *rgb)
|
||||||
{
|
{
|
||||||
|
GeglColor *color;
|
||||||
|
|
||||||
g_return_if_fail (GIMP_IS_COLOR_DIALOG (dialog));
|
g_return_if_fail (GIMP_IS_COLOR_DIALOG (dialog));
|
||||||
g_return_if_fail (color != NULL);
|
g_return_if_fail (rgb != NULL);
|
||||||
|
|
||||||
g_signal_handlers_block_by_func (dialog->selection,
|
g_signal_handlers_block_by_func (dialog->selection,
|
||||||
gimp_color_dialog_color_changed,
|
gimp_color_dialog_color_changed,
|
||||||
dialog);
|
dialog);
|
||||||
|
|
||||||
|
color = gegl_color_new (NULL);
|
||||||
|
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), rgb);
|
||||||
gimp_color_selection_set_color (GIMP_COLOR_SELECTION (dialog->selection),
|
gimp_color_selection_set_color (GIMP_COLOR_SELECTION (dialog->selection),
|
||||||
color);
|
color);
|
||||||
gimp_color_selection_set_old_color (GIMP_COLOR_SELECTION (dialog->selection),
|
gimp_color_selection_set_old_color (GIMP_COLOR_SELECTION (dialog->selection),
|
||||||
color);
|
color);
|
||||||
|
g_object_unref (color);
|
||||||
|
|
||||||
g_signal_handlers_unblock_by_func (dialog->selection,
|
g_signal_handlers_unblock_by_func (dialog->selection,
|
||||||
gimp_color_dialog_color_changed,
|
gimp_color_dialog_color_changed,
|
||||||
|
@ -548,13 +554,16 @@ gimp_color_dialog_set_color (GimpColorDialog *dialog,
|
||||||
|
|
||||||
void
|
void
|
||||||
gimp_color_dialog_get_color (GimpColorDialog *dialog,
|
gimp_color_dialog_get_color (GimpColorDialog *dialog,
|
||||||
GimpRGB *color)
|
GimpRGB *rgb)
|
||||||
{
|
{
|
||||||
g_return_if_fail (GIMP_IS_COLOR_DIALOG (dialog));
|
GeglColor *color;
|
||||||
g_return_if_fail (color != NULL);
|
|
||||||
|
|
||||||
gimp_color_selection_get_color (GIMP_COLOR_SELECTION (dialog->selection),
|
g_return_if_fail (GIMP_IS_COLOR_DIALOG (dialog));
|
||||||
color);
|
g_return_if_fail (rgb != NULL);
|
||||||
|
|
||||||
|
color = gimp_color_selection_get_color (GIMP_COLOR_SELECTION (dialog->selection));
|
||||||
|
gegl_color_get_pixel (color, babl_format ("R'G'B'A double"), rgb);
|
||||||
|
g_object_unref (color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -636,9 +645,9 @@ gimp_color_dialog_color_changed (GimpColorSelection *selection,
|
||||||
GimpColorDialog *dialog)
|
GimpColorDialog *dialog)
|
||||||
{
|
{
|
||||||
GimpViewableDialog *viewable_dialog = GIMP_VIEWABLE_DIALOG (dialog);
|
GimpViewableDialog *viewable_dialog = GIMP_VIEWABLE_DIALOG (dialog);
|
||||||
GimpRGB rgb;
|
GeglColor *color;
|
||||||
|
|
||||||
gimp_color_selection_get_color (selection, &rgb);
|
color = gimp_color_selection_get_color (selection);
|
||||||
|
|
||||||
if (dialog->colormap_editing && viewable_dialog->context)
|
if (dialog->colormap_editing && viewable_dialog->context)
|
||||||
{
|
{
|
||||||
|
@ -649,7 +658,6 @@ gimp_color_dialog_color_changed (GimpColorSelection *selection,
|
||||||
if (image)
|
if (image)
|
||||||
{
|
{
|
||||||
GimpColormapSelection *colormap_selection;
|
GimpColormapSelection *colormap_selection;
|
||||||
GeglColor *color = gegl_color_new (NULL);
|
|
||||||
gboolean push_undo = FALSE;
|
gboolean push_undo = FALSE;
|
||||||
gint col_index;
|
gint col_index;
|
||||||
|
|
||||||
|
@ -657,32 +665,35 @@ gimp_color_dialog_color_changed (GimpColorSelection *selection,
|
||||||
col_index = gimp_colormap_selection_get_index (colormap_selection, NULL);
|
col_index = gimp_colormap_selection_get_index (colormap_selection, NULL);
|
||||||
if (push_undo)
|
if (push_undo)
|
||||||
{
|
{
|
||||||
GimpRGB old_color;
|
GeglColor *old_color;
|
||||||
|
|
||||||
gimp_color_selection_get_old_color (GIMP_COLOR_SELECTION (dialog->selection), &old_color);
|
old_color = gimp_color_selection_get_old_color (GIMP_COLOR_SELECTION (dialog->selection));
|
||||||
|
|
||||||
/* Restore old color for undo */
|
/* Restore old color for undo */
|
||||||
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), &old_color);
|
gimp_image_set_colormap_entry (image, col_index, old_color, FALSE);
|
||||||
gimp_image_set_colormap_entry (image, col_index, color, FALSE);
|
|
||||||
|
g_object_unref (old_color);
|
||||||
}
|
}
|
||||||
|
|
||||||
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), &rgb);
|
|
||||||
gimp_image_set_colormap_entry (image, col_index, color, push_undo);
|
gimp_image_set_colormap_entry (image, col_index, color, push_undo);
|
||||||
|
|
||||||
if (push_undo)
|
if (push_undo)
|
||||||
gimp_image_flush (image);
|
gimp_image_flush (image);
|
||||||
else
|
else
|
||||||
gimp_projection_flush (gimp_image_get_projection (image));
|
gimp_projection_flush (gimp_image_get_projection (image));
|
||||||
|
|
||||||
g_object_unref (color);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dialog->wants_updates)
|
if (dialog->wants_updates)
|
||||||
{
|
{
|
||||||
|
GimpRGB rgb;
|
||||||
|
|
||||||
|
gegl_color_get_pixel (color, babl_format ("R'G'B'A double"), &rgb);
|
||||||
g_signal_emit (dialog, color_dialog_signals[UPDATE], 0,
|
g_signal_emit (dialog, color_dialog_signals[UPDATE], 0,
|
||||||
&rgb, GIMP_COLOR_DIALOG_UPDATE);
|
&rgb, GIMP_COLOR_DIALOG_UPDATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_object_unref (color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -694,14 +705,15 @@ gimp_color_history_add_clicked (GtkWidget *widget,
|
||||||
{
|
{
|
||||||
GimpViewableDialog *viewable_dialog = GIMP_VIEWABLE_DIALOG (dialog);
|
GimpViewableDialog *viewable_dialog = GIMP_VIEWABLE_DIALOG (dialog);
|
||||||
GimpPalette *history;
|
GimpPalette *history;
|
||||||
GimpRGB color;
|
GeglColor *color;
|
||||||
|
GimpRGB rgb;
|
||||||
|
|
||||||
history = gimp_palettes_get_color_history (viewable_dialog->context->gimp);
|
history = gimp_palettes_get_color_history (viewable_dialog->context->gimp);
|
||||||
|
|
||||||
gimp_color_selection_get_color (GIMP_COLOR_SELECTION (dialog->selection),
|
color = gimp_color_selection_get_color (GIMP_COLOR_SELECTION (dialog->selection));
|
||||||
&color);
|
gegl_color_get_pixel (color, babl_format ("R'G'B'A double"), &rgb);
|
||||||
|
|
||||||
gimp_palette_mru_add (GIMP_PALETTE_MRU (history), &color);
|
gimp_palette_mru_add (GIMP_PALETTE_MRU (history), &rgb);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Color history callback */
|
/* Color history callback */
|
||||||
|
@ -711,8 +723,11 @@ gimp_color_dialog_history_selected (GimpColorHistory *history,
|
||||||
const GimpRGB *rgb,
|
const GimpRGB *rgb,
|
||||||
GimpColorDialog *dialog)
|
GimpColorDialog *dialog)
|
||||||
{
|
{
|
||||||
gimp_color_selection_set_color (GIMP_COLOR_SELECTION (dialog->selection),
|
GeglColor *color = gegl_color_new (NULL);
|
||||||
rgb);
|
|
||||||
|
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), rgb);
|
||||||
|
gimp_color_selection_set_color (GIMP_COLOR_SELECTION (dialog->selection), color);
|
||||||
|
g_object_unref (color);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Context-related callbacks */
|
/* Context-related callbacks */
|
||||||
|
|
|
@ -559,8 +559,7 @@ gimp_color_editor_set_color (GimpColorEditor *editor,
|
||||||
gimp_color_editor_entry_changed,
|
gimp_color_editor_entry_changed,
|
||||||
editor);
|
editor);
|
||||||
|
|
||||||
gimp_color_hex_entry_set_color (GIMP_COLOR_HEX_ENTRY (editor->hex_entry),
|
gimp_color_hex_entry_set_color (GIMP_COLOR_HEX_ENTRY (editor->hex_entry), color);
|
||||||
&rgb);
|
|
||||||
|
|
||||||
g_signal_handlers_unblock_by_func (editor->hex_entry,
|
g_signal_handlers_unblock_by_func (editor->hex_entry,
|
||||||
gimp_color_editor_entry_changed,
|
gimp_color_editor_entry_changed,
|
||||||
|
@ -591,11 +590,12 @@ gimp_color_editor_color_changed (GimpColorSelector *selector,
|
||||||
const GimpHSV *hsv,
|
const GimpHSV *hsv,
|
||||||
GimpColorEditor *editor)
|
GimpColorEditor *editor)
|
||||||
{
|
{
|
||||||
|
GeglColor *color = gegl_color_new ("black");
|
||||||
|
|
||||||
|
gegl_color_set_rgba_with_space (color, rgb->r, rgb->g, rgb->b, rgb->a, NULL);
|
||||||
|
|
||||||
if (editor->context)
|
if (editor->context)
|
||||||
{
|
{
|
||||||
GeglColor *color = gegl_color_new ("black");
|
|
||||||
|
|
||||||
gegl_color_set_rgba_with_space (color, rgb->r, rgb->g, rgb->b, rgb->a, NULL);
|
|
||||||
if (editor->edit_bg)
|
if (editor->edit_bg)
|
||||||
{
|
{
|
||||||
g_signal_handlers_block_by_func (editor->context,
|
g_signal_handlers_block_by_func (editor->context,
|
||||||
|
@ -620,20 +620,19 @@ gimp_color_editor_color_changed (GimpColorSelector *selector,
|
||||||
gimp_color_editor_fg_changed,
|
gimp_color_editor_fg_changed,
|
||||||
editor);
|
editor);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_object_unref (color);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
g_signal_handlers_block_by_func (editor->hex_entry,
|
g_signal_handlers_block_by_func (editor->hex_entry,
|
||||||
gimp_color_editor_entry_changed,
|
gimp_color_editor_entry_changed,
|
||||||
editor);
|
editor);
|
||||||
|
|
||||||
gimp_color_hex_entry_set_color (GIMP_COLOR_HEX_ENTRY (editor->hex_entry),
|
gimp_color_hex_entry_set_color (GIMP_COLOR_HEX_ENTRY (editor->hex_entry), color);
|
||||||
rgb);
|
|
||||||
|
|
||||||
g_signal_handlers_unblock_by_func (editor->hex_entry,
|
g_signal_handlers_unblock_by_func (editor->hex_entry,
|
||||||
gimp_color_editor_entry_changed,
|
gimp_color_editor_entry_changed,
|
||||||
editor);
|
editor);
|
||||||
|
|
||||||
|
g_object_unref (color);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -717,11 +716,9 @@ static void
|
||||||
gimp_color_editor_entry_changed (GimpColorHexEntry *entry,
|
gimp_color_editor_entry_changed (GimpColorHexEntry *entry,
|
||||||
GimpColorEditor *editor)
|
GimpColorEditor *editor)
|
||||||
{
|
{
|
||||||
GeglColor *color = gegl_color_new ("black");
|
GeglColor *color;
|
||||||
GimpRGB rgb;
|
|
||||||
|
|
||||||
gimp_color_hex_entry_get_color (entry, &rgb);
|
color = gimp_color_hex_entry_get_color (entry);
|
||||||
gegl_color_set_rgba_with_space (color, rgb.r, rgb.g, rgb.b, rgb.a, NULL);
|
|
||||||
|
|
||||||
if (editor->context)
|
if (editor->context)
|
||||||
{
|
{
|
||||||
|
|
|
@ -399,15 +399,14 @@ gimp_colormap_editor_color_update (GimpColorDialog *dialog,
|
||||||
NULL);
|
NULL);
|
||||||
if (push_undo)
|
if (push_undo)
|
||||||
{
|
{
|
||||||
GimpRGB old_color;
|
GeglColor *old_color;
|
||||||
|
|
||||||
gimp_color_selection_get_old_color (
|
old_color = gimp_color_selection_get_old_color (GIMP_COLOR_SELECTION (dialog->selection));
|
||||||
GIMP_COLOR_SELECTION (dialog->selection), &old_color);
|
|
||||||
|
|
||||||
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), &old_color);
|
|
||||||
/* Restore old color for undo */
|
/* Restore old color for undo */
|
||||||
gimp_image_set_colormap_entry (image, col_index, color, FALSE);
|
gimp_image_set_colormap_entry (image, col_index, old_color, FALSE);
|
||||||
|
|
||||||
|
g_object_unref (old_color);
|
||||||
}
|
}
|
||||||
|
|
||||||
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), rgb);
|
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), rgb);
|
||||||
|
|
|
@ -245,7 +245,7 @@ gimp_colormap_selection_init (GimpColormapSelection *selection)
|
||||||
selection->color_entry = gimp_color_hex_entry_new ();
|
selection->color_entry = gimp_color_hex_entry_new ();
|
||||||
gtk_widget_set_halign (selection->color_entry, GTK_ALIGN_START);
|
gtk_widget_set_halign (selection->color_entry, GTK_ALIGN_START);
|
||||||
gimp_grid_attach_aligned (GTK_GRID (grid), 0, 1,
|
gimp_grid_attach_aligned (GTK_GRID (grid), 0, 1,
|
||||||
_("HTML notation:"), 0.0, 0.5,
|
_("HTML notation (sRGB):"), 0.0, 0.5,
|
||||||
selection->color_entry, 1);
|
selection->color_entry, 1);
|
||||||
|
|
||||||
g_signal_connect (selection->color_entry, "color-changed",
|
g_signal_connect (selection->color_entry, "color-changed",
|
||||||
|
@ -590,15 +590,16 @@ gimp_colormap_selection_update_entries (GimpColormapSelection *selection)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GeglColor *color;
|
GeglColor *color;
|
||||||
guchar rgb[3];
|
guchar rgb[3];
|
||||||
gchar *string;
|
gchar *string;
|
||||||
|
|
||||||
gtk_adjustment_set_value (selection->index_adjustment,
|
gtk_adjustment_set_value (selection->index_adjustment,
|
||||||
selection->col_index);
|
selection->col_index);
|
||||||
color = gimp_image_get_colormap_entry (image, selection->col_index);
|
color = gimp_image_get_colormap_entry (image, selection->col_index);
|
||||||
/* The color entry shows an HTML notation, which we assumes mean
|
/* The color entry shows a CSS/SVG notation, which so far means
|
||||||
* sRGB for most people. But is it really what we want? TODO
|
* sRGB. But is it really what we want? Don't we want to edit
|
||||||
|
* colors in the image's specific RGB color space? TODO
|
||||||
*/
|
*/
|
||||||
gegl_color_get_pixel (color, babl_format ("R'G'B' u8"), rgb);
|
gegl_color_get_pixel (color, babl_format ("R'G'B' u8"), rgb);
|
||||||
|
|
||||||
|
@ -689,14 +690,13 @@ gimp_colormap_hex_entry_changed (GimpColorHexEntry *entry,
|
||||||
|
|
||||||
if (image)
|
if (image)
|
||||||
{
|
{
|
||||||
GeglColor *color = gegl_color_new (NULL);
|
GeglColor *color;
|
||||||
GimpRGB rgb;
|
|
||||||
|
|
||||||
gimp_color_hex_entry_get_color (entry, &rgb);
|
color = gimp_color_hex_entry_get_color (entry);
|
||||||
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), &rgb);
|
|
||||||
|
|
||||||
gimp_image_set_colormap_entry (image, selection->col_index, color, TRUE);
|
gimp_image_set_colormap_entry (image, selection->col_index, color, TRUE);
|
||||||
gimp_image_flush (image);
|
gimp_image_flush (image);
|
||||||
|
g_object_unref (color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -127,16 +127,12 @@ color_area_foreground_changed (GimpContext *context,
|
||||||
{
|
{
|
||||||
if (edit_color == GIMP_ACTIVE_COLOR_FOREGROUND)
|
if (edit_color == GIMP_ACTIVE_COLOR_FOREGROUND)
|
||||||
{
|
{
|
||||||
GimpRGB rgb;
|
|
||||||
|
|
||||||
gegl_color_get_pixel (color, babl_format ("R'G'B'A double"), &rgb);
|
|
||||||
g_signal_handlers_block_by_func (dialog,
|
g_signal_handlers_block_by_func (dialog,
|
||||||
color_area_dialog_update,
|
color_area_dialog_update,
|
||||||
context);
|
context);
|
||||||
|
|
||||||
/* FIXME this should use GimpColorDialog API */
|
/* FIXME this should use GimpColorDialog API */
|
||||||
gimp_color_selection_set_color (GIMP_COLOR_SELECTION (dialog->selection),
|
gimp_color_selection_set_color (GIMP_COLOR_SELECTION (dialog->selection), color);
|
||||||
&rgb);
|
|
||||||
|
|
||||||
g_signal_handlers_unblock_by_func (dialog,
|
g_signal_handlers_unblock_by_func (dialog,
|
||||||
color_area_dialog_update,
|
color_area_dialog_update,
|
||||||
|
@ -151,16 +147,12 @@ color_area_background_changed (GimpContext *context,
|
||||||
{
|
{
|
||||||
if (edit_color == GIMP_ACTIVE_COLOR_BACKGROUND)
|
if (edit_color == GIMP_ACTIVE_COLOR_BACKGROUND)
|
||||||
{
|
{
|
||||||
GimpRGB rgb;
|
|
||||||
|
|
||||||
gegl_color_get_pixel (color, babl_format ("R'G'B'A double"), &rgb);
|
|
||||||
g_signal_handlers_block_by_func (dialog,
|
g_signal_handlers_block_by_func (dialog,
|
||||||
color_area_dialog_update,
|
color_area_dialog_update,
|
||||||
context);
|
context);
|
||||||
|
|
||||||
/* FIXME this should use GimpColorDialog API */
|
/* FIXME this should use GimpColorDialog API */
|
||||||
gimp_color_selection_set_color (GIMP_COLOR_SELECTION (dialog->selection),
|
gimp_color_selection_set_color (GIMP_COLOR_SELECTION (dialog->selection), color);
|
||||||
&rgb);
|
|
||||||
|
|
||||||
g_signal_handlers_unblock_by_func (dialog,
|
g_signal_handlers_unblock_by_func (dialog,
|
||||||
color_area_dialog_update,
|
color_area_dialog_update,
|
||||||
|
|
|
@ -240,6 +240,70 @@ gimp_color_parse_css (const gchar *css,
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gimp_color_parse_hex:
|
||||||
|
* @hex: (array length=len): a string describing a color in hexadecimal notation
|
||||||
|
* @len: the length of @hex, in bytes. or -1 if @hex is nul-terminated
|
||||||
|
*
|
||||||
|
* Attempts to parse a string describing an RGB color in hexadecimal
|
||||||
|
* notation (optionally prefixed with a '#').
|
||||||
|
*
|
||||||
|
* This function does not touch the alpha component of @rgb.
|
||||||
|
*
|
||||||
|
* Returns: (transfer full): a newly allocated color representing @hex.
|
||||||
|
*
|
||||||
|
* Since: 2.2
|
||||||
|
**/
|
||||||
|
GeglColor *
|
||||||
|
gimp_color_parse_hex (const gchar *hex,
|
||||||
|
gint len)
|
||||||
|
{
|
||||||
|
GeglColor *result;
|
||||||
|
gchar *tmp;
|
||||||
|
|
||||||
|
g_return_val_if_fail (hex != NULL, FALSE);
|
||||||
|
|
||||||
|
tmp = gimp_color_parse_strip (hex, len);
|
||||||
|
|
||||||
|
result = gimp_color_parse_hex_internal (tmp);
|
||||||
|
|
||||||
|
g_free (tmp);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gimp_color_parse_name:
|
||||||
|
* @name: (array length=len): a color name (in UTF-8 encoding)
|
||||||
|
* @len: the length of @name, in bytes. or -1 if @name is nul-terminated
|
||||||
|
*
|
||||||
|
* Attempts to parse a color name. This function accepts [SVG 1.1 color
|
||||||
|
* keywords](https://www.w3.org/TR/SVG11/types.html#ColorKeywords).
|
||||||
|
*
|
||||||
|
* Returns: (transfer full): a sRGB color as defined in "4.4. Recognized color
|
||||||
|
* keyword names" list of SVG 1.1 specification, if @name was parsed
|
||||||
|
* successfully, %NULL otherwise
|
||||||
|
*
|
||||||
|
* Since: 2.2
|
||||||
|
**/
|
||||||
|
GeglColor *
|
||||||
|
gimp_color_parse_name (const gchar *name,
|
||||||
|
gint len)
|
||||||
|
{
|
||||||
|
gchar *tmp;
|
||||||
|
GeglColor *result;
|
||||||
|
|
||||||
|
g_return_val_if_fail (name != NULL, FALSE);
|
||||||
|
|
||||||
|
tmp = gimp_color_parse_strip (name, len);
|
||||||
|
|
||||||
|
result = gimp_color_parse_name_internal (tmp);
|
||||||
|
|
||||||
|
g_free (tmp);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Private functions. */
|
/* Private functions. */
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,8 @@ EXPORTS
|
||||||
gimp_color_managed_simulation_intent_changed
|
gimp_color_managed_simulation_intent_changed
|
||||||
gimp_color_managed_simulation_profile_changed
|
gimp_color_managed_simulation_profile_changed
|
||||||
gimp_color_parse_css
|
gimp_color_parse_css
|
||||||
|
gimp_color_parse_hex
|
||||||
|
gimp_color_parse_name
|
||||||
gimp_color_profile_get_copyright
|
gimp_color_profile_get_copyright
|
||||||
gimp_color_profile_get_description
|
gimp_color_profile_get_description
|
||||||
gimp_color_profile_get_format
|
gimp_color_profile_get_format
|
||||||
|
|
|
@ -55,6 +55,10 @@ gboolean gimp_color_is_perceptually_identical (GeglColor *color1,
|
||||||
|
|
||||||
GeglColor * gimp_color_parse_css (const gchar *css,
|
GeglColor * gimp_color_parse_css (const gchar *css,
|
||||||
gint len);
|
gint len);
|
||||||
|
GeglColor * gimp_color_parse_hex (const gchar *hex,
|
||||||
|
gint len);
|
||||||
|
GeglColor * gimp_color_parse_name (const gchar *name,
|
||||||
|
gint len);
|
||||||
|
|
||||||
gboolean gimp_color_is_out_of_self_gamut (GeglColor *color);
|
gboolean gimp_color_is_out_of_self_gamut (GeglColor *color);
|
||||||
gboolean gimp_color_is_out_of_gamut (GeglColor *color,
|
gboolean gimp_color_is_out_of_gamut (GeglColor *color,
|
||||||
|
|
|
@ -540,7 +540,6 @@ gimp_color_button_clicked (GtkButton *button)
|
||||||
GimpColorButton *color_button = GIMP_COLOR_BUTTON (button);
|
GimpColorButton *color_button = GIMP_COLOR_BUTTON (button);
|
||||||
GimpColorButtonPrivate *priv = GET_PRIVATE (button);
|
GimpColorButtonPrivate *priv = GET_PRIVATE (button);
|
||||||
GeglColor *color;
|
GeglColor *color;
|
||||||
GimpRGB rgb;
|
|
||||||
|
|
||||||
if (! priv->dialog)
|
if (! priv->dialog)
|
||||||
{
|
{
|
||||||
|
@ -593,10 +592,8 @@ gimp_color_button_clicked (GtkButton *button)
|
||||||
gimp_color_button_selection_changed,
|
gimp_color_button_selection_changed,
|
||||||
button);
|
button);
|
||||||
|
|
||||||
gegl_color_get_pixel (color, babl_format ("R'G'B'A double"), &rgb);
|
gimp_color_selection_set_color (GIMP_COLOR_SELECTION (priv->selection), color);
|
||||||
gimp_color_selection_set_color (GIMP_COLOR_SELECTION (priv->selection), &rgb);
|
gimp_color_selection_set_old_color (GIMP_COLOR_SELECTION (priv->selection), color);
|
||||||
gimp_color_selection_set_old_color (GIMP_COLOR_SELECTION (priv->selection),
|
|
||||||
&rgb);
|
|
||||||
|
|
||||||
g_signal_handlers_unblock_by_func (priv->selection,
|
g_signal_handlers_unblock_by_func (priv->selection,
|
||||||
gimp_color_button_selection_changed,
|
gimp_color_button_selection_changed,
|
||||||
|
@ -835,16 +832,12 @@ gimp_color_button_set_update (GimpColorButton *button,
|
||||||
if (priv->selection)
|
if (priv->selection)
|
||||||
{
|
{
|
||||||
GeglColor *color;
|
GeglColor *color;
|
||||||
GimpRGB rgb;
|
|
||||||
|
|
||||||
color = gegl_color_new (NULL);
|
|
||||||
|
|
||||||
if (priv->continuous_update)
|
if (priv->continuous_update)
|
||||||
gimp_color_selection_get_color (GIMP_COLOR_SELECTION (priv->selection), &rgb);
|
color = gimp_color_selection_get_color (GIMP_COLOR_SELECTION (priv->selection));
|
||||||
else
|
else
|
||||||
gimp_color_selection_get_old_color (GIMP_COLOR_SELECTION (priv->selection), &rgb);
|
color = gimp_color_selection_get_old_color (GIMP_COLOR_SELECTION (priv->selection));
|
||||||
|
|
||||||
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), &rgb);
|
|
||||||
gimp_color_button_set_color (button, color);
|
gimp_color_button_set_color (button, color);
|
||||||
g_object_unref (color);
|
g_object_unref (color);
|
||||||
}
|
}
|
||||||
|
@ -914,11 +907,8 @@ gimp_color_button_dialog_response (GtkWidget *dialog,
|
||||||
gint response_id,
|
gint response_id,
|
||||||
GimpColorButton *button)
|
GimpColorButton *button)
|
||||||
{
|
{
|
||||||
GimpColorButtonPrivate *priv = GET_PRIVATE (button);
|
GimpColorButtonPrivate *priv = GET_PRIVATE (button);
|
||||||
GeglColor *color;
|
GeglColor *color = NULL;
|
||||||
GimpRGB rgb;
|
|
||||||
|
|
||||||
color = gegl_color_new (NULL);
|
|
||||||
|
|
||||||
switch (response_id)
|
switch (response_id)
|
||||||
{
|
{
|
||||||
|
@ -929,9 +919,7 @@ gimp_color_button_dialog_response (GtkWidget *dialog,
|
||||||
case GTK_RESPONSE_OK:
|
case GTK_RESPONSE_OK:
|
||||||
if (! priv->continuous_update)
|
if (! priv->continuous_update)
|
||||||
{
|
{
|
||||||
gimp_color_selection_get_color (GIMP_COLOR_SELECTION (priv->selection),
|
color = gimp_color_selection_get_color (GIMP_COLOR_SELECTION (priv->selection));
|
||||||
&rgb);
|
|
||||||
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), &rgb);
|
|
||||||
gimp_color_button_set_color (button, color);
|
gimp_color_button_set_color (button, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -941,9 +929,7 @@ gimp_color_button_dialog_response (GtkWidget *dialog,
|
||||||
default:
|
default:
|
||||||
if (priv->continuous_update)
|
if (priv->continuous_update)
|
||||||
{
|
{
|
||||||
gimp_color_selection_get_old_color (GIMP_COLOR_SELECTION (priv->selection),
|
color = gimp_color_selection_get_old_color (GIMP_COLOR_SELECTION (priv->selection)),
|
||||||
&rgb);
|
|
||||||
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), &rgb);
|
|
||||||
gimp_color_button_set_color (button, color);
|
gimp_color_button_set_color (button, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -951,7 +937,7 @@ gimp_color_button_dialog_response (GtkWidget *dialog,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_object_unref (color);
|
g_clear_object (&color);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -1005,7 +991,6 @@ gimp_color_button_area_changed (GtkWidget *color_area,
|
||||||
if (priv->selection)
|
if (priv->selection)
|
||||||
{
|
{
|
||||||
GeglColor *color;
|
GeglColor *color;
|
||||||
GimpRGB rgb;
|
|
||||||
|
|
||||||
color = gimp_color_button_get_color (button);
|
color = gimp_color_button_get_color (button);
|
||||||
|
|
||||||
|
@ -1013,9 +998,7 @@ gimp_color_button_area_changed (GtkWidget *color_area,
|
||||||
gimp_color_button_selection_changed,
|
gimp_color_button_selection_changed,
|
||||||
button);
|
button);
|
||||||
|
|
||||||
gegl_color_get_pixel (color, babl_format ("R'G'B'A double"), &rgb);
|
gimp_color_selection_set_color (GIMP_COLOR_SELECTION (priv->selection), color);
|
||||||
gimp_color_selection_set_color (GIMP_COLOR_SELECTION (priv->selection),
|
|
||||||
&rgb);
|
|
||||||
|
|
||||||
g_signal_handlers_unblock_by_func (priv->selection,
|
g_signal_handlers_unblock_by_func (priv->selection,
|
||||||
gimp_color_button_selection_changed,
|
gimp_color_button_selection_changed,
|
||||||
|
@ -1036,24 +1019,22 @@ gimp_color_button_selection_changed (GtkWidget *selection,
|
||||||
if (priv->continuous_update)
|
if (priv->continuous_update)
|
||||||
{
|
{
|
||||||
GeglColor *color;
|
GeglColor *color;
|
||||||
GimpRGB rgb;
|
|
||||||
|
|
||||||
gimp_color_selection_get_color (GIMP_COLOR_SELECTION (selection), &rgb);
|
color = gimp_color_selection_get_color (GIMP_COLOR_SELECTION (selection));
|
||||||
|
|
||||||
g_signal_handlers_block_by_func (priv->color_area,
|
g_signal_handlers_block_by_func (priv->color_area,
|
||||||
gimp_color_button_area_changed,
|
gimp_color_button_area_changed,
|
||||||
button);
|
button);
|
||||||
|
|
||||||
color = gegl_color_new (NULL);
|
|
||||||
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), &rgb);
|
|
||||||
gimp_color_area_set_color (GIMP_COLOR_AREA (priv->color_area), color);
|
gimp_color_area_set_color (GIMP_COLOR_AREA (priv->color_area), color);
|
||||||
g_object_unref (color);
|
|
||||||
|
|
||||||
g_signal_handlers_unblock_by_func (priv->color_area,
|
g_signal_handlers_unblock_by_func (priv->color_area,
|
||||||
gimp_color_button_area_changed,
|
gimp_color_button_area_changed,
|
||||||
button);
|
button);
|
||||||
|
|
||||||
g_signal_emit (button, gimp_color_button_signals[COLOR_CHANGED], 0);
|
g_signal_emit (button, gimp_color_button_signals[COLOR_CHANGED], 0);
|
||||||
|
|
||||||
|
g_object_unref (color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,8 @@
|
||||||
* @title: GimpColorHexEntry
|
* @title: GimpColorHexEntry
|
||||||
* @short_description: Widget for entering a color's hex triplet.
|
* @short_description: Widget for entering a color's hex triplet.
|
||||||
*
|
*
|
||||||
* Widget for entering a color's hex triplet.
|
* Widget for entering a color's hex triplet. The syntax follows CSS and
|
||||||
|
* SVG specifications, which means that only sRGB colors are supported.
|
||||||
**/
|
**/
|
||||||
|
|
||||||
|
|
||||||
|
@ -63,16 +64,14 @@ enum
|
||||||
|
|
||||||
struct _GimpColorHexEntryPrivate
|
struct _GimpColorHexEntryPrivate
|
||||||
{
|
{
|
||||||
GimpRGB color;
|
GeglColor *color;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define GET_PRIVATE(obj) (((GimpColorHexEntry *) (obj))->priv)
|
#define GET_PRIVATE(obj) (((GimpColorHexEntry *) (obj))->priv)
|
||||||
|
|
||||||
|
|
||||||
static void gimp_color_hex_entry_constructed (GObject *object);
|
static void gimp_color_hex_entry_constructed (GObject *object);
|
||||||
|
static void gimp_color_hex_entry_finalize (GObject *object);
|
||||||
static gboolean gimp_color_hex_entry_events (GtkWidget *widget,
|
|
||||||
GdkEvent *event);
|
|
||||||
|
|
||||||
static gboolean gimp_color_hex_entry_events (GtkWidget *widget,
|
static gboolean gimp_color_hex_entry_events (GtkWidget *widget,
|
||||||
GdkEvent *event);
|
GdkEvent *event);
|
||||||
|
@ -105,6 +104,7 @@ gimp_color_hex_entry_class_init (GimpColorHexEntryClass *klass)
|
||||||
G_TYPE_NONE, 0);
|
G_TYPE_NONE, 0);
|
||||||
|
|
||||||
object_class->constructed = gimp_color_hex_entry_constructed;
|
object_class->constructed = gimp_color_hex_entry_constructed;
|
||||||
|
object_class->finalize = gimp_color_hex_entry_finalize;
|
||||||
|
|
||||||
klass->color_changed = NULL;
|
klass->color_changed = NULL;
|
||||||
}
|
}
|
||||||
|
@ -135,7 +135,7 @@ gimp_color_hex_entry_init (GimpColorHexEntry *entry)
|
||||||
"CSS. This entry also accepts CSS color names."),
|
"CSS. This entry also accepts CSS color names."),
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
gimp_rgba_set (&private->color, 0.0, 0.0, 0.0, 1.0);
|
private->color = gegl_color_new ("black");
|
||||||
|
|
||||||
store = gtk_list_store_new (NUM_COLUMNS, G_TYPE_STRING, GIMP_TYPE_RGB);
|
store = gtk_list_store_new (NUM_COLUMNS, G_TYPE_STRING, GIMP_TYPE_RGB);
|
||||||
|
|
||||||
|
@ -191,6 +191,16 @@ gimp_color_hex_entry_constructed (GObject *object)
|
||||||
gtk_entry_set_text (GTK_ENTRY (object), "000000");
|
gtk_entry_set_text (GTK_ENTRY (object), "000000");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gimp_color_hex_entry_finalize (GObject *object)
|
||||||
|
{
|
||||||
|
GimpColorHexEntryPrivate *private = GET_PRIVATE (object);
|
||||||
|
|
||||||
|
g_object_unref (private->color);
|
||||||
|
|
||||||
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gimp_color_hex_entry_new:
|
* gimp_color_hex_entry_new:
|
||||||
*
|
*
|
||||||
|
@ -217,25 +227,25 @@ gimp_color_hex_entry_new (void)
|
||||||
**/
|
**/
|
||||||
void
|
void
|
||||||
gimp_color_hex_entry_set_color (GimpColorHexEntry *entry,
|
gimp_color_hex_entry_set_color (GimpColorHexEntry *entry,
|
||||||
const GimpRGB *color)
|
GeglColor *color)
|
||||||
{
|
{
|
||||||
GimpColorHexEntryPrivate *private;
|
GimpColorHexEntryPrivate *private;
|
||||||
|
|
||||||
g_return_if_fail (GIMP_IS_COLOR_HEX_ENTRY (entry));
|
g_return_if_fail (GIMP_IS_COLOR_HEX_ENTRY (entry));
|
||||||
g_return_if_fail (color != NULL);
|
g_return_if_fail (GEGL_IS_COLOR (color));
|
||||||
|
|
||||||
private = GET_PRIVATE (entry);
|
private = GET_PRIVATE (entry);
|
||||||
|
|
||||||
if (gimp_rgb_distance (&private->color, color) > 0.0)
|
if (! gimp_color_is_perceptually_identical (private->color, color))
|
||||||
{
|
{
|
||||||
gchar buffer[8];
|
gchar buffer[8];
|
||||||
guchar r, g, b;
|
guchar rgb[3];
|
||||||
|
|
||||||
gimp_rgb_set (&private->color, color->r, color->g, color->b);
|
g_object_unref (private->color);
|
||||||
gimp_rgb_clamp (&private->color);
|
private->color = gegl_color_duplicate (color);
|
||||||
|
|
||||||
gimp_rgb_get_uchar (&private->color, &r, &g, &b);
|
gegl_color_get_pixel (color, babl_format ("R'G'B' u8"), rgb);
|
||||||
g_snprintf (buffer, sizeof (buffer), "%.2x%.2x%.2x", r, g, b);
|
g_snprintf (buffer, sizeof (buffer), "%.2x%.2x%.2x", rgb[0], rgb[1], rgb[2]);
|
||||||
|
|
||||||
gtk_entry_set_text (GTK_ENTRY (entry), buffer);
|
gtk_entry_set_text (GTK_ENTRY (entry), buffer);
|
||||||
|
|
||||||
|
@ -249,24 +259,23 @@ gimp_color_hex_entry_set_color (GimpColorHexEntry *entry,
|
||||||
/**
|
/**
|
||||||
* gimp_color_hex_entry_get_color:
|
* gimp_color_hex_entry_get_color:
|
||||||
* @entry: a #GimpColorHexEntry widget
|
* @entry: a #GimpColorHexEntry widget
|
||||||
* @color: (out caller-allocates): pointer to a #GimpRGB
|
|
||||||
*
|
*
|
||||||
* Retrieves the color value displayed by a #GimpColorHexEntry.
|
* Retrieves the color value displayed by a #GimpColorHexEntry.
|
||||||
*
|
*
|
||||||
|
* Returns: (transfer full): the color stored in @entry.
|
||||||
|
*
|
||||||
* Since: 2.2
|
* Since: 2.2
|
||||||
**/
|
**/
|
||||||
void
|
GeglColor *
|
||||||
gimp_color_hex_entry_get_color (GimpColorHexEntry *entry,
|
gimp_color_hex_entry_get_color (GimpColorHexEntry *entry)
|
||||||
GimpRGB *color)
|
|
||||||
{
|
{
|
||||||
GimpColorHexEntryPrivate *private;
|
GimpColorHexEntryPrivate *private;
|
||||||
|
|
||||||
g_return_if_fail (GIMP_IS_COLOR_HEX_ENTRY (entry));
|
g_return_val_if_fail (GIMP_IS_COLOR_HEX_ENTRY (entry), NULL);
|
||||||
g_return_if_fail (color != NULL);
|
|
||||||
|
|
||||||
private = GET_PRIVATE (entry);
|
private = GET_PRIVATE (entry);
|
||||||
|
|
||||||
*color = private->color;
|
return gegl_color_duplicate (private->color);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
@ -293,23 +302,24 @@ gimp_color_hex_entry_events (GtkWidget *widget,
|
||||||
{
|
{
|
||||||
const gchar *text;
|
const gchar *text;
|
||||||
gchar buffer[8];
|
gchar buffer[8];
|
||||||
guchar r, g, b;
|
guchar rgb[3];
|
||||||
|
|
||||||
text = gtk_entry_get_text (GTK_ENTRY (widget));
|
text = gtk_entry_get_text (GTK_ENTRY (widget));
|
||||||
|
|
||||||
gimp_rgb_get_uchar (&private->color, &r, &g, &b);
|
gegl_color_get_pixel (private->color, babl_format ("R'G'B' u8"), rgb);
|
||||||
g_snprintf (buffer, sizeof (buffer), "%.2x%.2x%.2x", r, g, b);
|
g_snprintf (buffer, sizeof (buffer), "%.2x%.2x%.2x", rgb[0], rgb[1], rgb[2]);
|
||||||
|
|
||||||
if (g_ascii_strcasecmp (buffer, text) != 0)
|
if (g_ascii_strcasecmp (buffer, text) != 0)
|
||||||
{
|
{
|
||||||
GimpRGB color;
|
GeglColor *color = NULL;
|
||||||
gsize len = strlen (text);
|
gsize len = strlen (text);
|
||||||
|
|
||||||
if (len > 0 &&
|
if (len > 0 &&
|
||||||
(gimp_rgb_parse_hex (&color, text, len) ||
|
((color = gimp_color_parse_hex (text, len)) ||
|
||||||
gimp_rgb_parse_name (&color, text, -1)))
|
(color = gimp_color_parse_name (text, -1))))
|
||||||
{
|
{
|
||||||
gimp_color_hex_entry_set_color (entry, &color);
|
gimp_color_hex_entry_set_color (entry, color);
|
||||||
|
g_object_unref (color);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -333,17 +343,18 @@ gimp_color_hex_entry_matched (GtkEntryCompletion *completion,
|
||||||
GtkTreeIter *iter,
|
GtkTreeIter *iter,
|
||||||
GimpColorHexEntry *entry)
|
GimpColorHexEntry *entry)
|
||||||
{
|
{
|
||||||
gchar *name;
|
gchar *name = NULL;
|
||||||
GimpRGB color;
|
GeglColor *color = NULL;
|
||||||
|
|
||||||
gtk_tree_model_get (model, iter,
|
gtk_tree_model_get (model, iter,
|
||||||
COLUMN_NAME, &name,
|
COLUMN_NAME, &name,
|
||||||
-1);
|
-1);
|
||||||
|
|
||||||
if (gimp_rgb_parse_name (&color, name, -1))
|
if ((color = gimp_color_parse_name (name, -1)))
|
||||||
gimp_color_hex_entry_set_color (entry, &color);
|
gimp_color_hex_entry_set_color (entry, color);
|
||||||
|
|
||||||
g_free (name);
|
g_free (name);
|
||||||
|
g_clear_object (&color);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,9 +70,8 @@ GType gimp_color_hex_entry_get_type (void) G_GNUC_CONST;
|
||||||
GtkWidget * gimp_color_hex_entry_new (void);
|
GtkWidget * gimp_color_hex_entry_new (void);
|
||||||
|
|
||||||
void gimp_color_hex_entry_set_color (GimpColorHexEntry *entry,
|
void gimp_color_hex_entry_set_color (GimpColorHexEntry *entry,
|
||||||
const GimpRGB *color);
|
GeglColor *color);
|
||||||
void gimp_color_hex_entry_get_color (GimpColorHexEntry *entry,
|
GeglColor * gimp_color_hex_entry_get_color (GimpColorHexEntry *entry);
|
||||||
GimpRGB *color);
|
|
||||||
|
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
|
@ -84,8 +84,7 @@ struct _GimpColorSelectionPrivate
|
||||||
{
|
{
|
||||||
gboolean show_alpha;
|
gboolean show_alpha;
|
||||||
|
|
||||||
GimpHSV hsv;
|
GeglColor *color;
|
||||||
GimpRGB rgb;
|
|
||||||
GimpColorSelectorChannel channel;
|
GimpColorSelectorChannel channel;
|
||||||
|
|
||||||
GtkWidget *left_vbox;
|
GtkWidget *left_vbox;
|
||||||
|
@ -101,6 +100,7 @@ struct _GimpColorSelectionPrivate
|
||||||
#define GET_PRIVATE(obj) (((GimpColorSelection *) (obj))->priv)
|
#define GET_PRIVATE(obj) (((GimpColorSelection *) (obj))->priv)
|
||||||
|
|
||||||
|
|
||||||
|
static void gimp_color_selection_finalize (GObject *object);
|
||||||
static void gimp_color_selection_set_property (GObject *object,
|
static void gimp_color_selection_set_property (GObject *object,
|
||||||
guint property_id,
|
guint property_id,
|
||||||
const GValue *value,
|
const GValue *value,
|
||||||
|
@ -146,6 +146,7 @@ gimp_color_selection_class_init (GimpColorSelectionClass *klass)
|
||||||
{
|
{
|
||||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||||
|
|
||||||
|
object_class->finalize = gimp_color_selection_finalize;
|
||||||
object_class->set_property = gimp_color_selection_set_property;
|
object_class->set_property = gimp_color_selection_set_property;
|
||||||
|
|
||||||
klass->color_changed = NULL;
|
klass->color_changed = NULL;
|
||||||
|
@ -181,7 +182,8 @@ gimp_color_selection_init (GimpColorSelection *selection)
|
||||||
GtkWidget *button;
|
GtkWidget *button;
|
||||||
GtkSizeGroup *new_group;
|
GtkSizeGroup *new_group;
|
||||||
GtkSizeGroup *old_group;
|
GtkSizeGroup *old_group;
|
||||||
GeglColor *color;
|
GimpRGB rgb;
|
||||||
|
GimpHSV hsv;
|
||||||
|
|
||||||
selection->priv = gimp_color_selection_get_instance_private (selection);
|
selection->priv = gimp_color_selection_get_instance_private (selection);
|
||||||
|
|
||||||
|
@ -192,8 +194,10 @@ gimp_color_selection_init (GimpColorSelection *selection)
|
||||||
gtk_orientable_set_orientation (GTK_ORIENTABLE (selection),
|
gtk_orientable_set_orientation (GTK_ORIENTABLE (selection),
|
||||||
GTK_ORIENTATION_VERTICAL);
|
GTK_ORIENTATION_VERTICAL);
|
||||||
|
|
||||||
gimp_rgba_set (&priv->rgb, 0.0, 0.0, 0.0, 1.0);
|
priv->color = gegl_color_new ("black");
|
||||||
gimp_rgb_to_hsv (&priv->rgb, &priv->hsv);
|
|
||||||
|
gegl_color_get_pixel (priv->color, babl_format ("R'G'B'A double"), &rgb);
|
||||||
|
gegl_color_get_pixel (priv->color, babl_format ("HSVA double"), &hsv);
|
||||||
|
|
||||||
priv->channel = GIMP_COLOR_SELECTOR_RED;
|
priv->channel = GIMP_COLOR_SELECTOR_RED;
|
||||||
|
|
||||||
|
@ -214,9 +218,7 @@ gimp_color_selection_init (GimpColorSelection *selection)
|
||||||
}
|
}
|
||||||
|
|
||||||
priv->notebook = gimp_color_selector_new (GIMP_TYPE_COLOR_NOTEBOOK,
|
priv->notebook = gimp_color_selector_new (GIMP_TYPE_COLOR_NOTEBOOK,
|
||||||
&priv->rgb,
|
&rgb, &hsv, priv->channel);
|
||||||
&priv->hsv,
|
|
||||||
priv->channel);
|
|
||||||
|
|
||||||
if (_gimp_ensure_modules_func)
|
if (_gimp_ensure_modules_func)
|
||||||
g_type_class_unref (g_type_class_peek (GIMP_TYPE_COLOR_SELECT));
|
g_type_class_unref (g_type_class_peek (GIMP_TYPE_COLOR_SELECT));
|
||||||
|
@ -273,9 +275,7 @@ gimp_color_selection_init (GimpColorSelection *selection)
|
||||||
gtk_container_add (GTK_CONTAINER (frame), vbox);
|
gtk_container_add (GTK_CONTAINER (frame), vbox);
|
||||||
gtk_widget_show (vbox);
|
gtk_widget_show (vbox);
|
||||||
|
|
||||||
color = gegl_color_new (NULL);
|
priv->new_color = gimp_color_area_new (priv->color,
|
||||||
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), &priv->rgb);
|
|
||||||
priv->new_color = gimp_color_area_new (color,
|
|
||||||
priv->show_alpha ?
|
priv->show_alpha ?
|
||||||
GIMP_COLOR_AREA_SMALL_CHECKS :
|
GIMP_COLOR_AREA_SMALL_CHECKS :
|
||||||
GIMP_COLOR_AREA_FLAT,
|
GIMP_COLOR_AREA_FLAT,
|
||||||
|
@ -289,7 +289,7 @@ gimp_color_selection_init (GimpColorSelection *selection)
|
||||||
G_CALLBACK (gimp_color_selection_new_color_changed),
|
G_CALLBACK (gimp_color_selection_new_color_changed),
|
||||||
selection);
|
selection);
|
||||||
|
|
||||||
priv->old_color = gimp_color_area_new (color,
|
priv->old_color = gimp_color_area_new (priv->color,
|
||||||
priv->show_alpha ?
|
priv->show_alpha ?
|
||||||
GIMP_COLOR_AREA_SMALL_CHECKS :
|
GIMP_COLOR_AREA_SMALL_CHECKS :
|
||||||
GIMP_COLOR_AREA_FLAT,
|
GIMP_COLOR_AREA_FLAT,
|
||||||
|
@ -307,9 +307,7 @@ gimp_color_selection_init (GimpColorSelection *selection)
|
||||||
gtk_widget_show (priv->right_vbox);
|
gtk_widget_show (priv->right_vbox);
|
||||||
|
|
||||||
priv->scales = gimp_color_selector_new (GIMP_TYPE_COLOR_SCALES,
|
priv->scales = gimp_color_selector_new (GIMP_TYPE_COLOR_SCALES,
|
||||||
&priv->rgb,
|
&rgb, &hsv, priv->channel);
|
||||||
&priv->hsv,
|
|
||||||
priv->channel);
|
|
||||||
gimp_color_selector_set_toggles_visible
|
gimp_color_selector_set_toggles_visible
|
||||||
(GIMP_COLOR_SELECTOR (priv->scales), TRUE);
|
(GIMP_COLOR_SELECTOR (priv->scales), TRUE);
|
||||||
gimp_color_selector_set_show_alpha (GIMP_COLOR_SELECTOR (priv->scales),
|
gimp_color_selector_set_show_alpha (GIMP_COLOR_SELECTOR (priv->scales),
|
||||||
|
@ -353,8 +351,16 @@ gimp_color_selection_init (GimpColorSelection *selection)
|
||||||
g_signal_connect (entry, "color-changed",
|
g_signal_connect (entry, "color-changed",
|
||||||
G_CALLBACK (gimp_color_selection_entry_changed),
|
G_CALLBACK (gimp_color_selection_entry_changed),
|
||||||
selection);
|
selection);
|
||||||
|
}
|
||||||
|
|
||||||
g_object_unref (color);
|
static void
|
||||||
|
gimp_color_selection_finalize (GObject *object)
|
||||||
|
{
|
||||||
|
GimpColorSelectionPrivate *priv = GET_PRIVATE (object);
|
||||||
|
|
||||||
|
g_object_unref (priv->color);
|
||||||
|
|
||||||
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -453,17 +459,17 @@ gimp_color_selection_get_show_alpha (GimpColorSelection *selection)
|
||||||
**/
|
**/
|
||||||
void
|
void
|
||||||
gimp_color_selection_set_color (GimpColorSelection *selection,
|
gimp_color_selection_set_color (GimpColorSelection *selection,
|
||||||
const GimpRGB *color)
|
GeglColor *color)
|
||||||
{
|
{
|
||||||
GimpColorSelectionPrivate *priv;
|
GimpColorSelectionPrivate *priv;
|
||||||
|
|
||||||
g_return_if_fail (GIMP_IS_COLOR_SELECTION (selection));
|
g_return_if_fail (GIMP_IS_COLOR_SELECTION (selection));
|
||||||
g_return_if_fail (color != NULL);
|
g_return_if_fail (GEGL_IS_COLOR (color));
|
||||||
|
|
||||||
priv = GET_PRIVATE (selection);
|
priv = GET_PRIVATE (selection);
|
||||||
|
|
||||||
priv->rgb = *color;
|
g_object_unref (priv->color);
|
||||||
gimp_rgb_to_hsv (&priv->rgb, &priv->hsv);
|
priv->color = gegl_color_duplicate (color);
|
||||||
|
|
||||||
gimp_color_selection_update (selection, UPDATE_ALL);
|
gimp_color_selection_update (selection, UPDATE_ALL);
|
||||||
|
|
||||||
|
@ -473,19 +479,17 @@ gimp_color_selection_set_color (GimpColorSelection *selection,
|
||||||
/**
|
/**
|
||||||
* gimp_color_selection_get_color:
|
* gimp_color_selection_get_color:
|
||||||
* @selection: A #GimpColorSelection widget.
|
* @selection: A #GimpColorSelection widget.
|
||||||
* @color: (out caller-allocates): Return location for the
|
|
||||||
* @selection's current @color.
|
|
||||||
*
|
*
|
||||||
* This function returns the #GimpColorSelection's current color.
|
* This function returns the #GimpColorSelection's current color.
|
||||||
|
*
|
||||||
|
* Returns: (transfer full): the currently selected color.
|
||||||
**/
|
**/
|
||||||
void
|
GeglColor *
|
||||||
gimp_color_selection_get_color (GimpColorSelection *selection,
|
gimp_color_selection_get_color (GimpColorSelection *selection)
|
||||||
GimpRGB *color)
|
|
||||||
{
|
{
|
||||||
g_return_if_fail (GIMP_IS_COLOR_SELECTION (selection));
|
g_return_val_if_fail (GIMP_IS_COLOR_SELECTION (selection), NULL);
|
||||||
g_return_if_fail (color != NULL);
|
|
||||||
|
|
||||||
*color = GET_PRIVATE (selection)->rgb;
|
return gegl_color_duplicate (GET_PRIVATE (selection)->color);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -497,45 +501,34 @@ gimp_color_selection_get_color (GimpColorSelection *selection,
|
||||||
**/
|
**/
|
||||||
void
|
void
|
||||||
gimp_color_selection_set_old_color (GimpColorSelection *selection,
|
gimp_color_selection_set_old_color (GimpColorSelection *selection,
|
||||||
const GimpRGB *rgb)
|
GeglColor *color)
|
||||||
{
|
{
|
||||||
GimpColorSelectionPrivate *priv;
|
GimpColorSelectionPrivate *priv;
|
||||||
GeglColor *color;
|
|
||||||
|
|
||||||
g_return_if_fail (GIMP_IS_COLOR_SELECTION (selection));
|
g_return_if_fail (GIMP_IS_COLOR_SELECTION (selection));
|
||||||
g_return_if_fail (rgb != NULL);
|
g_return_if_fail (GEGL_IS_COLOR (color));
|
||||||
|
|
||||||
priv = GET_PRIVATE (selection);
|
priv = GET_PRIVATE (selection);
|
||||||
|
|
||||||
color = gegl_color_new (NULL);
|
|
||||||
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), rgb);
|
|
||||||
gimp_color_area_set_color (GIMP_COLOR_AREA (priv->old_color), color);
|
gimp_color_area_set_color (GIMP_COLOR_AREA (priv->old_color), color);
|
||||||
g_object_unref (color);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gimp_color_selection_get_old_color:
|
* gimp_color_selection_get_old_color:
|
||||||
* @selection: A #GimpColorSelection widget.
|
* @selection: A #GimpColorSelection widget.
|
||||||
* @color: (out caller-allocates): Return location for the
|
|
||||||
* @selection's old @color.
|
|
||||||
*
|
*
|
||||||
* This function returns the #GimpColorSelection's old color.
|
* Returns: (transfer full): the old color.
|
||||||
**/
|
**/
|
||||||
void
|
GeglColor *
|
||||||
gimp_color_selection_get_old_color (GimpColorSelection *selection,
|
gimp_color_selection_get_old_color (GimpColorSelection *selection)
|
||||||
GimpRGB *rgb)
|
|
||||||
{
|
{
|
||||||
GimpColorSelectionPrivate *priv;
|
GimpColorSelectionPrivate *priv;
|
||||||
GeglColor *color;
|
|
||||||
|
|
||||||
g_return_if_fail (GIMP_IS_COLOR_SELECTION (selection));
|
g_return_val_if_fail (GIMP_IS_COLOR_SELECTION (selection), NULL);
|
||||||
g_return_if_fail (rgb != NULL);
|
|
||||||
|
|
||||||
priv = GET_PRIVATE (selection);
|
priv = GET_PRIVATE (selection);
|
||||||
|
|
||||||
color = gimp_color_area_get_color (GIMP_COLOR_AREA (priv->old_color));
|
return gimp_color_area_get_color (GIMP_COLOR_AREA (priv->old_color));
|
||||||
gegl_color_get_pixel (color, babl_format ("R'G'B'A double"), rgb);
|
|
||||||
g_object_unref (color);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -549,15 +542,13 @@ gimp_color_selection_reset (GimpColorSelection *selection)
|
||||||
{
|
{
|
||||||
GimpColorSelectionPrivate *priv;
|
GimpColorSelectionPrivate *priv;
|
||||||
GeglColor *color;
|
GeglColor *color;
|
||||||
GimpRGB rgb;
|
|
||||||
|
|
||||||
g_return_if_fail (GIMP_IS_COLOR_SELECTION (selection));
|
g_return_if_fail (GIMP_IS_COLOR_SELECTION (selection));
|
||||||
|
|
||||||
priv = GET_PRIVATE (selection);
|
priv = GET_PRIVATE (selection);
|
||||||
|
|
||||||
color = gimp_color_area_get_color (GIMP_COLOR_AREA (priv->old_color));
|
color = gimp_color_area_get_color (GIMP_COLOR_AREA (priv->old_color));
|
||||||
gegl_color_get_pixel (color, babl_format ("R'G'B'A double"), &rgb);
|
gimp_color_selection_set_color (selection, color);
|
||||||
gimp_color_selection_set_color (selection, &rgb);
|
|
||||||
|
|
||||||
g_object_unref (color);
|
g_object_unref (color);
|
||||||
}
|
}
|
||||||
|
@ -696,8 +687,7 @@ gimp_color_selection_notebook_changed (GimpColorSelector *selector,
|
||||||
{
|
{
|
||||||
GimpColorSelectionPrivate *priv = GET_PRIVATE (selection);
|
GimpColorSelectionPrivate *priv = GET_PRIVATE (selection);
|
||||||
|
|
||||||
priv->hsv = *hsv;
|
gegl_color_set_pixel (priv->color, babl_format ("HSVA double"), hsv);
|
||||||
priv->rgb = *rgb;
|
|
||||||
|
|
||||||
gimp_color_selection_update (selection,
|
gimp_color_selection_update (selection,
|
||||||
UPDATE_SCALES | UPDATE_ENTRY | UPDATE_COLOR);
|
UPDATE_SCALES | UPDATE_ENTRY | UPDATE_COLOR);
|
||||||
|
@ -712,8 +702,7 @@ gimp_color_selection_scales_changed (GimpColorSelector *selector,
|
||||||
{
|
{
|
||||||
GimpColorSelectionPrivate *priv = GET_PRIVATE (selection);
|
GimpColorSelectionPrivate *priv = GET_PRIVATE (selection);
|
||||||
|
|
||||||
priv->rgb = *rgb;
|
gegl_color_set_pixel (priv->color, babl_format ("HSVA double"), hsv);
|
||||||
priv->hsv = *hsv;
|
|
||||||
|
|
||||||
gimp_color_selection_update (selection,
|
gimp_color_selection_update (selection,
|
||||||
UPDATE_ENTRY | UPDATE_NOTEBOOK | UPDATE_COLOR);
|
UPDATE_ENTRY | UPDATE_NOTEBOOK | UPDATE_COLOR);
|
||||||
|
@ -725,7 +714,12 @@ gimp_color_selection_color_picked (GtkWidget *widget,
|
||||||
const GimpRGB *rgb,
|
const GimpRGB *rgb,
|
||||||
GimpColorSelection *selection)
|
GimpColorSelection *selection)
|
||||||
{
|
{
|
||||||
gimp_color_selection_set_color (selection, rgb);
|
GeglColor *color = gegl_color_new (NULL);
|
||||||
|
|
||||||
|
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), rgb);
|
||||||
|
gimp_color_selection_set_color (selection, color);
|
||||||
|
|
||||||
|
g_object_unref (color);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -734,9 +728,8 @@ gimp_color_selection_entry_changed (GimpColorHexEntry *entry,
|
||||||
{
|
{
|
||||||
GimpColorSelectionPrivate *priv = GET_PRIVATE (selection);
|
GimpColorSelectionPrivate *priv = GET_PRIVATE (selection);
|
||||||
|
|
||||||
gimp_color_hex_entry_get_color (entry, &priv->rgb);
|
g_object_unref (priv->color);
|
||||||
|
priv->color = gimp_color_hex_entry_get_color (entry);
|
||||||
gimp_rgb_to_hsv (&priv->rgb, &priv->hsv);
|
|
||||||
|
|
||||||
gimp_color_selection_update (selection,
|
gimp_color_selection_update (selection,
|
||||||
UPDATE_NOTEBOOK | UPDATE_SCALES | UPDATE_COLOR);
|
UPDATE_NOTEBOOK | UPDATE_SCALES | UPDATE_COLOR);
|
||||||
|
@ -761,17 +754,13 @@ gimp_color_selection_new_color_changed (GtkWidget *widget,
|
||||||
GimpColorSelection *selection)
|
GimpColorSelection *selection)
|
||||||
{
|
{
|
||||||
GimpColorSelectionPrivate *priv = GET_PRIVATE (selection);
|
GimpColorSelectionPrivate *priv = GET_PRIVATE (selection);
|
||||||
GeglColor *color;
|
|
||||||
|
|
||||||
color = gimp_color_area_get_color (GIMP_COLOR_AREA (widget));
|
g_object_unref (priv->color);
|
||||||
gegl_color_get_pixel (color, babl_format ("R'G'B'A double"), &priv->rgb);
|
priv->color = gimp_color_area_get_color (GIMP_COLOR_AREA (widget));
|
||||||
gegl_color_get_pixel (color, babl_format ("HSVA double"), &priv->hsv);
|
|
||||||
|
|
||||||
gimp_color_selection_update (selection,
|
gimp_color_selection_update (selection,
|
||||||
UPDATE_NOTEBOOK | UPDATE_SCALES | UPDATE_ENTRY);
|
UPDATE_NOTEBOOK | UPDATE_SCALES | UPDATE_ENTRY);
|
||||||
gimp_color_selection_color_changed (selection);
|
gimp_color_selection_color_changed (selection);
|
||||||
|
|
||||||
g_object_unref (color);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -779,6 +768,11 @@ gimp_color_selection_update (GimpColorSelection *selection,
|
||||||
UpdateType update)
|
UpdateType update)
|
||||||
{
|
{
|
||||||
GimpColorSelectionPrivate *priv = GET_PRIVATE (selection);
|
GimpColorSelectionPrivate *priv = GET_PRIVATE (selection);
|
||||||
|
GimpRGB rgb;
|
||||||
|
GimpHSV hsv;
|
||||||
|
|
||||||
|
gegl_color_get_pixel (priv->color, babl_format ("R'G'B'A double"), &rgb);
|
||||||
|
gegl_color_get_pixel (priv->color, babl_format ("HSVA double"), &hsv);
|
||||||
|
|
||||||
if (update & UPDATE_NOTEBOOK)
|
if (update & UPDATE_NOTEBOOK)
|
||||||
{
|
{
|
||||||
|
@ -787,8 +781,7 @@ gimp_color_selection_update (GimpColorSelection *selection,
|
||||||
selection);
|
selection);
|
||||||
|
|
||||||
gimp_color_selector_set_color (GIMP_COLOR_SELECTOR (priv->notebook),
|
gimp_color_selector_set_color (GIMP_COLOR_SELECTOR (priv->notebook),
|
||||||
&priv->rgb,
|
&rgb, &hsv);
|
||||||
&priv->hsv);
|
|
||||||
|
|
||||||
g_signal_handlers_unblock_by_func (priv->notebook,
|
g_signal_handlers_unblock_by_func (priv->notebook,
|
||||||
gimp_color_selection_notebook_changed,
|
gimp_color_selection_notebook_changed,
|
||||||
|
@ -802,8 +795,7 @@ gimp_color_selection_update (GimpColorSelection *selection,
|
||||||
selection);
|
selection);
|
||||||
|
|
||||||
gimp_color_selector_set_color (GIMP_COLOR_SELECTOR (priv->scales),
|
gimp_color_selector_set_color (GIMP_COLOR_SELECTOR (priv->scales),
|
||||||
&priv->rgb,
|
&rgb, &hsv);
|
||||||
&priv->hsv);
|
|
||||||
|
|
||||||
g_signal_handlers_unblock_by_func (priv->scales,
|
g_signal_handlers_unblock_by_func (priv->scales,
|
||||||
gimp_color_selection_scales_changed,
|
gimp_color_selection_scales_changed,
|
||||||
|
@ -820,7 +812,7 @@ gimp_color_selection_update (GimpColorSelection *selection,
|
||||||
gimp_color_selection_entry_changed,
|
gimp_color_selection_entry_changed,
|
||||||
selection);
|
selection);
|
||||||
|
|
||||||
gimp_color_hex_entry_set_color (entry, &priv->rgb);
|
gimp_color_hex_entry_set_color (entry, priv->color);
|
||||||
|
|
||||||
g_signal_handlers_unblock_by_func (entry,
|
g_signal_handlers_unblock_by_func (entry,
|
||||||
gimp_color_selection_entry_changed,
|
gimp_color_selection_entry_changed,
|
||||||
|
@ -829,20 +821,14 @@ gimp_color_selection_update (GimpColorSelection *selection,
|
||||||
|
|
||||||
if (update & UPDATE_COLOR)
|
if (update & UPDATE_COLOR)
|
||||||
{
|
{
|
||||||
GeglColor *color;
|
|
||||||
|
|
||||||
g_signal_handlers_block_by_func (priv->new_color,
|
g_signal_handlers_block_by_func (priv->new_color,
|
||||||
gimp_color_selection_new_color_changed,
|
gimp_color_selection_new_color_changed,
|
||||||
selection);
|
selection);
|
||||||
|
|
||||||
color = gegl_color_new (NULL);
|
gimp_color_area_set_color (GIMP_COLOR_AREA (priv->new_color), priv->color);
|
||||||
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), &priv->rgb);
|
|
||||||
gimp_color_area_set_color (GIMP_COLOR_AREA (priv->new_color), color);
|
|
||||||
|
|
||||||
g_signal_handlers_unblock_by_func (priv->new_color,
|
g_signal_handlers_unblock_by_func (priv->new_color,
|
||||||
gimp_color_selection_new_color_changed,
|
gimp_color_selection_new_color_changed,
|
||||||
selection);
|
selection);
|
||||||
|
|
||||||
g_object_unref (color);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,14 +76,12 @@ void gimp_color_selection_set_show_alpha (GimpColorSelection *selection,
|
||||||
gboolean gimp_color_selection_get_show_alpha (GimpColorSelection *selection);
|
gboolean gimp_color_selection_get_show_alpha (GimpColorSelection *selection);
|
||||||
|
|
||||||
void gimp_color_selection_set_color (GimpColorSelection *selection,
|
void gimp_color_selection_set_color (GimpColorSelection *selection,
|
||||||
const GimpRGB *color);
|
GeglColor *color);
|
||||||
void gimp_color_selection_get_color (GimpColorSelection *selection,
|
GeglColor * gimp_color_selection_get_color (GimpColorSelection *selection);
|
||||||
GimpRGB *color);
|
|
||||||
|
|
||||||
void gimp_color_selection_set_old_color (GimpColorSelection *selection,
|
void gimp_color_selection_set_old_color (GimpColorSelection *selection,
|
||||||
const GimpRGB *color);
|
GeglColor *color);
|
||||||
void gimp_color_selection_get_old_color (GimpColorSelection *selection,
|
GeglColor * gimp_color_selection_get_old_color (GimpColorSelection *selection);
|
||||||
GimpRGB *color);
|
|
||||||
|
|
||||||
void gimp_color_selection_reset (GimpColorSelection *selection);
|
void gimp_color_selection_reset (GimpColorSelection *selection);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue