app, libgimp*, pdb, plug-ins: GimpContext is now using only GeglColor.

- app: gimp_context_get_(foreground|background)() are now returning a GeglColor.
- libgimp: PDB functions named similarly in libgimp are returning a newly
  allocated GeglColor too.
- A few other PDB functions (the ones using these functions) were updated and
  their signature changed to use GeglColor too, when relevant. Plug-ins which
  use any of the changed libgimp functions were fixed.
- GimpContext: signals "(foreground|background)-changed" are now passing a
  GeglColor.
- libgimpconfig: new macro GIMP_CONFIG_PROP_COLOR using gegl_param_spec_color().
- GimpContext: properties "foreground" and "background" are now GeglParamColor
  properties.
- app: All code interacting with GimpContext objects were updated to receive a
  GeglColor (that they may still convert, or no, to GimpRGB for now).
- app: gimp_prop_gegl_color_button_new() was added as an alternative to
  gimp_prop_color_button_new() when the property is a GeglParamColor. Eventually
  the former should replace completely the latter.
- libgimpwidgets: gimp_prop_color_area_new() now works on GeglParamColor
  properties only.
- libgimp: gimp_procedure_dialog_get_widget() will generate a GimpColorArea for
  GeglTypeParamColor arguments.
This commit is contained in:
Jehan 2023-11-14 20:04:14 +01:00
parent 229994957c
commit dbbcfb16d5
68 changed files with 1107 additions and 836 deletions

View File

@ -147,8 +147,12 @@ colormap_actions_update (GimpActionGroup *group,
if (context) if (context)
{ {
gimp_context_get_foreground (context, &fg); GeglColor *color;
gimp_context_get_background (context, &bg);
color = gimp_context_get_foreground (context);
gegl_color_get_rgba_with_space (color, &fg.r, &fg.g, &fg.b, &fg.a, NULL);
color = gimp_context_get_background (context);
gegl_color_get_rgba_with_space (color, &bg.r, &bg.g, &bg.b, &bg.a, NULL);
} }
#define SET_SENSITIVE(action,condition) \ #define SET_SENSITIVE(action,condition) \

View File

@ -71,14 +71,17 @@ colormap_add_color_cmd_callback (GimpAction *action,
if (gimp_image_get_colormap_size (image) < 256) if (gimp_image_get_colormap_size (image) < 256)
{ {
GimpRGB color; GimpRGB rgb;
GeglColor *color;
if (background) if (background)
gimp_context_get_background (context, &color); color = gimp_context_get_background (context);
else else
gimp_context_get_foreground (context, &color); color = gimp_context_get_foreground (context);
gimp_image_add_colormap_entry (image, &color); gegl_color_get_rgba_with_space (color, &rgb.r, &rgb.g, &rgb.b, &rgb.a, NULL);
gimp_image_add_colormap_entry (image, &rgb);
gimp_image_flush (image); gimp_image_flush (image);
} }
} }

View File

@ -61,7 +61,7 @@ static gint context_paint_mode_index (GimpLayerMode paint_mode,
gint n_modes); gint n_modes);
static void context_select_color (GimpActionSelectType select_type, static void context_select_color (GimpActionSelectType select_type,
GimpRGB *color, GeglColor *color,
gboolean use_colormap, gboolean use_colormap,
gboolean use_palette); gboolean use_palette);
@ -73,7 +73,7 @@ static gint context_max_color_index (gboolean use_colormap,
static gboolean context_set_color_index (gint index, static gboolean context_set_color_index (gint index,
gboolean use_colormap, gboolean use_colormap,
gboolean use_palette, gboolean use_palette,
GimpRGB *color); GeglColor *color);
static GimpPaletteEditor * context_get_palette_editor (void); static GimpPaletteEditor * context_get_palette_editor (void);
static GimpColormapEditor * context_get_colormap_editor (void); static GimpColormapEditor * context_get_colormap_editor (void);
@ -110,17 +110,15 @@ context_##name##_##fgbg##ground_cmd_callback (GimpAction *action, \
gpointer data) \ gpointer data) \
{ \ { \
GimpContext *context; \ GimpContext *context; \
GimpRGB rgb; \ GeglColor *color; \
GeglColor *color = gegl_color_new ("black"); \
GimpActionSelectType select_type; \ GimpActionSelectType select_type; \
return_if_no_context (context, data); \ return_if_no_context (context, data); \
\ \
select_type = (GimpActionSelectType) g_variant_get_int32 (value); \ select_type = (GimpActionSelectType) g_variant_get_int32 (value); \
\ \
gimp_context_get_##fgbg##ground (context, &rgb); \ color = gegl_color_duplicate (gimp_context_get_##fgbg##ground (context)); \
context_select_color (select_type, &rgb, \ context_select_color (select_type, color, \
use_colormap, use_palette); \ use_colormap, use_palette); \
gegl_color_set_rgba_with_space (color, rgb.r, rgb.g, rgb.b, rgb.a, NULL); \
gimp_context_set_##fgbg##ground (context, color); \ gimp_context_set_##fgbg##ground (context, color); \
g_object_unref (color); \ g_object_unref (color); \
} }
@ -138,19 +136,23 @@ context_foreground_red_cmd_callback (GimpAction *action,
gpointer data) gpointer data)
{ {
GimpContext *context; GimpContext *context;
GeglColor *color = gegl_color_new ("black"); GeglColor *color;
GimpRGB rgb; gdouble red;
gdouble green;
gdouble blue;
gdouble alpha;
GimpActionSelectType select_type; GimpActionSelectType select_type;
return_if_no_context (context, data); return_if_no_context (context, data);
select_type = (GimpActionSelectType) g_variant_get_int32 (value); select_type = (GimpActionSelectType) g_variant_get_int32 (value);
gimp_context_get_foreground (context, &rgb); color = gegl_color_duplicate (gimp_context_get_foreground (context));
rgb.r = action_select_value (select_type, gegl_color_get_rgba_with_space (color, &red, &green, &blue, &alpha, NULL);
rgb.r, red = action_select_value (select_type,
0.0, 1.0, 1.0, red,
1.0 / 255.0, 0.01, 0.1, 0.0, FALSE); 0.0, 1.0, 1.0,
gegl_color_set_rgba_with_space (color, rgb.r, rgb.g, rgb.b, rgb.a, NULL); 1.0 / 255.0, 0.01, 0.1, 0.0, FALSE);
gegl_color_set_rgba_with_space (color, red, green, blue, alpha, NULL);
gimp_context_set_foreground (context, color); gimp_context_set_foreground (context, color);
g_object_unref (color); g_object_unref (color);
} }
@ -161,19 +163,23 @@ context_foreground_green_cmd_callback (GimpAction *action,
gpointer data) gpointer data)
{ {
GimpContext *context; GimpContext *context;
GeglColor *color = gegl_color_new ("black"); GeglColor *color;
GimpRGB rgb; gdouble red;
gdouble green;
gdouble blue;
gdouble alpha;
GimpActionSelectType select_type; GimpActionSelectType select_type;
return_if_no_context (context, data); return_if_no_context (context, data);
select_type = (GimpActionSelectType) g_variant_get_int32 (value); select_type = (GimpActionSelectType) g_variant_get_int32 (value);
gimp_context_get_foreground (context, &rgb); color = gegl_color_duplicate (gimp_context_get_foreground (context));
rgb.g = action_select_value (select_type, gegl_color_get_rgba_with_space (color, &red, &green, &blue, &alpha, NULL);
rgb.g, green = action_select_value (select_type,
green,
0.0, 1.0, 1.0, 0.0, 1.0, 1.0,
1.0 / 255.0, 0.01, 0.1, 0.0, FALSE); 1.0 / 255.0, 0.01, 0.1, 0.0, FALSE);
gegl_color_set_rgba_with_space (color, rgb.r, rgb.g, rgb.b, rgb.a, NULL); gegl_color_set_rgba_with_space (color, red, green, blue, alpha, NULL);
gimp_context_set_foreground (context, color); gimp_context_set_foreground (context, color);
g_object_unref (color); g_object_unref (color);
} }
@ -184,19 +190,23 @@ context_foreground_blue_cmd_callback (GimpAction *action,
gpointer data) gpointer data)
{ {
GimpContext *context; GimpContext *context;
GeglColor *color = gegl_color_new ("black"); GeglColor *color;
GimpRGB rgb; gdouble red;
gdouble green;
gdouble blue;
gdouble alpha;
GimpActionSelectType select_type; GimpActionSelectType select_type;
return_if_no_context (context, data); return_if_no_context (context, data);
select_type = (GimpActionSelectType) g_variant_get_int32 (value); select_type = (GimpActionSelectType) g_variant_get_int32 (value);
gimp_context_get_foreground (context, &rgb); color = gegl_color_duplicate (gimp_context_get_foreground (context));
rgb.b = action_select_value (select_type, gegl_color_get_rgba_with_space (color, &red, &green, &blue, &alpha, NULL);
rgb.b, blue = action_select_value (select_type,
0.0, 1.0, 1.0, blue,
1.0 / 255.0, 0.01, 0.1, 0.0, FALSE); 0.0, 1.0, 1.0,
gegl_color_set_rgba_with_space (color, rgb.r, rgb.g, rgb.b, rgb.a, NULL); 1.0 / 255.0, 0.01, 0.1, 0.0, FALSE);
gegl_color_set_rgba_with_space (color, red, green, blue, alpha, NULL);
gimp_context_set_foreground (context, color); gimp_context_set_foreground (context, color);
g_object_unref (color); g_object_unref (color);
} }
@ -207,19 +217,24 @@ context_background_red_cmd_callback (GimpAction *action,
gpointer data) gpointer data)
{ {
GimpContext *context; GimpContext *context;
GeglColor *color = gegl_color_new ("black"); GeglColor *color;
GimpRGB rgb; gdouble red;
gdouble green;
gdouble blue;
gdouble alpha;
GimpActionSelectType select_type; GimpActionSelectType select_type;
return_if_no_context (context, data); return_if_no_context (context, data);
select_type = (GimpActionSelectType) g_variant_get_int32 (value); select_type = (GimpActionSelectType) g_variant_get_int32 (value);
gimp_context_get_background (context, &rgb); color = gegl_color_duplicate (gimp_context_get_background (context));
rgb.r = action_select_value (select_type, /* TODO: what space to use for this action to work as expected? */
rgb.r, gegl_color_get_rgba_with_space (color, &red, &green, &blue, &alpha, NULL);
0.0, 1.0, 1.0, red = action_select_value (select_type,
1.0 / 255.0, 0.01, 0.1, 0.0, FALSE); red,
gegl_color_set_rgba_with_space (color, rgb.r, rgb.g, rgb.b, rgb.a, NULL); 0.0, 1.0, 1.0,
1.0 / 255.0, 0.01, 0.1, 0.0, FALSE);
gegl_color_set_rgba_with_space (color, red, green, blue, alpha, NULL);
gimp_context_set_background (context, color); gimp_context_set_background (context, color);
g_object_unref (color); g_object_unref (color);
} }
@ -230,19 +245,23 @@ context_background_green_cmd_callback (GimpAction *action,
gpointer data) gpointer data)
{ {
GimpContext *context; GimpContext *context;
GeglColor *color = gegl_color_new ("black"); GeglColor *color;
GimpRGB rgb; gdouble red;
gdouble green;
gdouble blue;
gdouble alpha;
GimpActionSelectType select_type; GimpActionSelectType select_type;
return_if_no_context (context, data); return_if_no_context (context, data);
select_type = (GimpActionSelectType) g_variant_get_int32 (value); select_type = (GimpActionSelectType) g_variant_get_int32 (value);
gimp_context_get_background (context, &rgb); color = gegl_color_duplicate (gimp_context_get_background (context));
rgb.g = action_select_value (select_type, gegl_color_get_rgba_with_space (color, &red, &green, &blue, &alpha, NULL);
rgb.g, green = action_select_value (select_type,
green,
0.0, 1.0, 1.0, 0.0, 1.0, 1.0,
1.0 / 255.0, 0.01, 0.1, 0.0, FALSE); 1.0 / 255.0, 0.01, 0.1, 0.0, FALSE);
gegl_color_set_rgba_with_space (color, rgb.r, rgb.g, rgb.b, rgb.a, NULL); gegl_color_set_rgba_with_space (color, red, green, blue, alpha, NULL);
gimp_context_set_background (context, color); gimp_context_set_background (context, color);
g_object_unref (color); g_object_unref (color);
} }
@ -253,19 +272,23 @@ context_background_blue_cmd_callback (GimpAction *action,
gpointer data) gpointer data)
{ {
GimpContext *context; GimpContext *context;
GeglColor *color = gegl_color_new ("black"); GeglColor *color;
GimpRGB rgb; gdouble red;
gdouble green;
gdouble blue;
gdouble alpha;
GimpActionSelectType select_type; GimpActionSelectType select_type;
return_if_no_context (context, data); return_if_no_context (context, data);
select_type = (GimpActionSelectType) g_variant_get_int32 (value); select_type = (GimpActionSelectType) g_variant_get_int32 (value);
gimp_context_get_background (context, &rgb); color = gegl_color_duplicate (gimp_context_get_background (context));
rgb.b = action_select_value (select_type, gegl_color_get_rgba_with_space (color, &red, &green, &blue, &alpha, NULL);
rgb.b, blue = action_select_value (select_type,
0.0, 1.0, 1.0, blue,
1.0 / 255.0, 0.01, 0.1, 0.0, FALSE); 0.0, 1.0, 1.0,
gegl_color_set_rgba_with_space (color, rgb.r, rgb.g, rgb.b, rgb.a, NULL); 1.0 / 255.0, 0.01, 0.1, 0.0, FALSE);
gegl_color_set_rgba_with_space (color, red, green, blue, alpha, NULL);
gimp_context_set_background (context, color); gimp_context_set_background (context, color);
g_object_unref (color); g_object_unref (color);
} }
@ -276,7 +299,7 @@ context_foreground_hue_cmd_callback (GimpAction *action,
gpointer data) gpointer data)
{ {
GimpContext *context; GimpContext *context;
GeglColor *color = gegl_color_new ("black"); GeglColor *color;
GimpRGB rgb; GimpRGB rgb;
GimpHSV hsv; GimpHSV hsv;
GimpActionSelectType select_type; GimpActionSelectType select_type;
@ -284,7 +307,8 @@ context_foreground_hue_cmd_callback (GimpAction *action,
select_type = (GimpActionSelectType) g_variant_get_int32 (value); select_type = (GimpActionSelectType) g_variant_get_int32 (value);
gimp_context_get_foreground (context, &rgb); color = gegl_color_duplicate (gimp_context_get_foreground (context));
gegl_color_get_pixel (color, babl_format_with_space ("R'G'B'A double", NULL), &rgb);
gimp_rgb_to_hsv (&rgb, &hsv); gimp_rgb_to_hsv (&rgb, &hsv);
hsv.h = action_select_value (select_type, hsv.h = action_select_value (select_type,
hsv.h, hsv.h,
@ -302,7 +326,7 @@ context_foreground_saturation_cmd_callback (GimpAction *action,
gpointer data) gpointer data)
{ {
GimpContext *context; GimpContext *context;
GeglColor *color = gegl_color_new ("black"); GeglColor *color;
GimpRGB rgb; GimpRGB rgb;
GimpHSV hsv; GimpHSV hsv;
GimpActionSelectType select_type; GimpActionSelectType select_type;
@ -310,7 +334,8 @@ context_foreground_saturation_cmd_callback (GimpAction *action,
select_type = (GimpActionSelectType) g_variant_get_int32 (value); select_type = (GimpActionSelectType) g_variant_get_int32 (value);
gimp_context_get_foreground (context, &rgb); color = gegl_color_duplicate (gimp_context_get_foreground (context));
gegl_color_get_pixel (color, babl_format_with_space ("R'G'B'A double", NULL), &rgb);
gimp_rgb_to_hsv (&rgb, &hsv); gimp_rgb_to_hsv (&rgb, &hsv);
hsv.s = action_select_value (select_type, hsv.s = action_select_value (select_type,
hsv.s, hsv.s,
@ -328,7 +353,7 @@ context_foreground_value_cmd_callback (GimpAction *action,
gpointer data) gpointer data)
{ {
GimpContext *context; GimpContext *context;
GeglColor *color = gegl_color_new ("black"); GeglColor *color;
GimpRGB rgb; GimpRGB rgb;
GimpHSV hsv; GimpHSV hsv;
GimpActionSelectType select_type; GimpActionSelectType select_type;
@ -336,7 +361,8 @@ context_foreground_value_cmd_callback (GimpAction *action,
select_type = (GimpActionSelectType) g_variant_get_int32 (value); select_type = (GimpActionSelectType) g_variant_get_int32 (value);
gimp_context_get_foreground (context, &rgb); color = gegl_color_duplicate (gimp_context_get_foreground (context));
gegl_color_get_pixel (color, babl_format_with_space ("R'G'B'A double", NULL), &rgb);
gimp_rgb_to_hsv (&rgb, &hsv); gimp_rgb_to_hsv (&rgb, &hsv);
hsv.v = action_select_value (select_type, hsv.v = action_select_value (select_type,
hsv.v, hsv.v,
@ -354,7 +380,7 @@ context_background_hue_cmd_callback (GimpAction *action,
gpointer data) gpointer data)
{ {
GimpContext *context; GimpContext *context;
GeglColor *color = gegl_color_new ("black"); GeglColor *color;
GimpRGB rgb; GimpRGB rgb;
GimpHSV hsv; GimpHSV hsv;
GimpActionSelectType select_type; GimpActionSelectType select_type;
@ -362,7 +388,8 @@ context_background_hue_cmd_callback (GimpAction *action,
select_type = (GimpActionSelectType) g_variant_get_int32 (value); select_type = (GimpActionSelectType) g_variant_get_int32 (value);
gimp_context_get_background (context, &rgb); color = gegl_color_duplicate (gimp_context_get_background (context));
gegl_color_get_pixel (color, babl_format_with_space ("R'G'B'A double", NULL), &rgb);
gimp_rgb_to_hsv (&rgb, &hsv); gimp_rgb_to_hsv (&rgb, &hsv);
hsv.h = action_select_value (select_type, hsv.h = action_select_value (select_type,
hsv.h, hsv.h,
@ -380,7 +407,7 @@ context_background_saturation_cmd_callback (GimpAction *action,
gpointer data) gpointer data)
{ {
GimpContext *context; GimpContext *context;
GeglColor *color = gegl_color_new ("black"); GeglColor *color;
GimpRGB rgb; GimpRGB rgb;
GimpHSV hsv; GimpHSV hsv;
GimpActionSelectType select_type; GimpActionSelectType select_type;
@ -388,7 +415,8 @@ context_background_saturation_cmd_callback (GimpAction *action,
select_type = (GimpActionSelectType) g_variant_get_int32 (value); select_type = (GimpActionSelectType) g_variant_get_int32 (value);
gimp_context_get_background (context, &rgb); color = gegl_color_duplicate (gimp_context_get_background (context));
gegl_color_get_pixel (color, babl_format_with_space ("R'G'B'A double", NULL), &rgb);
gimp_rgb_to_hsv (&rgb, &hsv); gimp_rgb_to_hsv (&rgb, &hsv);
hsv.s = action_select_value (select_type, hsv.s = action_select_value (select_type,
hsv.s, hsv.s,
@ -406,7 +434,7 @@ context_background_value_cmd_callback (GimpAction *action,
gpointer data) gpointer data)
{ {
GimpContext *context; GimpContext *context;
GeglColor *color = gegl_color_new ("black"); GeglColor *color;
GimpRGB rgb; GimpRGB rgb;
GimpHSV hsv; GimpHSV hsv;
GimpActionSelectType select_type; GimpActionSelectType select_type;
@ -414,7 +442,8 @@ context_background_value_cmd_callback (GimpAction *action,
select_type = (GimpActionSelectType) g_variant_get_int32 (value); select_type = (GimpActionSelectType) g_variant_get_int32 (value);
gimp_context_get_background (context, &rgb); color = gegl_color_duplicate (gimp_context_get_background (context));
gegl_color_get_pixel (color, babl_format_with_space ("R'G'B'A double", NULL), &rgb);
gimp_rgb_to_hsv (&rgb, &hsv); gimp_rgb_to_hsv (&rgb, &hsv);
hsv.v = action_select_value (select_type, hsv.v = action_select_value (select_type,
hsv.v, hsv.v,
@ -907,16 +936,13 @@ context_paint_mode_index (GimpLayerMode paint_mode,
static void static void
context_select_color (GimpActionSelectType select_type, context_select_color (GimpActionSelectType select_type,
GimpRGB *rgb, GeglColor *color,
gboolean use_colormap, gboolean use_colormap,
gboolean use_palette) gboolean use_palette)
{ {
GeglColor *color; gint index;
gint index; gint max;
gint max;
color = gegl_color_new ("black");
gegl_color_set_rgba_with_space (color, rgb->r, rgb->g, rgb->b, rgb->a, NULL);
index = context_get_color_index (use_colormap, use_palette, color); index = context_get_color_index (use_colormap, use_palette, color);
max = context_max_color_index (use_colormap, use_palette); max = context_max_color_index (use_colormap, use_palette);
@ -925,7 +951,7 @@ context_select_color (GimpActionSelectType select_type,
0, max, 0, 0, max, 0,
0, 1, 4, 0, FALSE); 0, 1, 4, 0, FALSE);
context_set_color_index (index, use_colormap, use_palette, rgb); context_set_color_index (index, use_colormap, use_palette, color);
g_object_unref (color); g_object_unref (color);
} }
@ -998,25 +1024,34 @@ context_max_color_index (gboolean use_colormap,
} }
static gboolean static gboolean
context_set_color_index (gint index, context_set_color_index (gint index,
gboolean use_colormap, gboolean use_colormap,
gboolean use_palette, gboolean use_palette,
GimpRGB *color) GeglColor *color)
{ {
GimpRGB rgb;
gegl_color_get_rgba_with_space (color, &rgb.r, &rgb.g, &rgb.b, &rgb.a, NULL);
if (use_colormap) if (use_colormap)
{ {
GimpColormapEditor *editor = context_get_colormap_editor (); GimpColormapEditor *editor = context_get_colormap_editor ();
if (editor && gimp_colormap_editor_set_index (editor, index, color)) if (editor && gimp_colormap_editor_set_index (editor, index, &rgb))
return TRUE; {
gegl_color_set_rgba_with_space (color, rgb.r, rgb.g, rgb.b, rgb.a, NULL);
return TRUE;
}
} }
if (use_palette) if (use_palette)
{ {
GimpPaletteEditor *editor = context_get_palette_editor (); GimpPaletteEditor *editor = context_get_palette_editor ();
if (editor && gimp_palette_editor_set_index (editor, index, color)) if (editor && gimp_palette_editor_set_index (editor, index, &rgb))
return TRUE; {
gegl_color_set_rgba_with_space (color, rgb.r, rgb.g, rgb.b, rgb.a, NULL);
return TRUE;
}
} }
return FALSE; return FALSE;

View File

@ -50,10 +50,10 @@
/* local function prototypes */ /* local function prototypes */
static void edit_actions_foreground_changed (GimpContext *context, static void edit_actions_foreground_changed (GimpContext *context,
const GimpRGB *color, GeglColor *color,
GimpActionGroup *group); GimpActionGroup *group);
static void edit_actions_background_changed (GimpContext *context, static void edit_actions_background_changed (GimpContext *context,
const GimpRGB *color, GeglColor *color,
GimpActionGroup *group); GimpActionGroup *group);
static void edit_actions_pattern_changed (GimpContext *context, static void edit_actions_pattern_changed (GimpContext *context,
GimpPattern *pattern, GimpPattern *pattern,
@ -233,7 +233,7 @@ void
edit_actions_setup (GimpActionGroup *group) edit_actions_setup (GimpActionGroup *group)
{ {
GimpContext *context = gimp_get_user_context (group->gimp); GimpContext *context = gimp_get_user_context (group->gimp);
GimpRGB color; GeglColor *color;
GimpPattern *pattern; GimpPattern *pattern;
gimp_action_group_add_actions (group, "edit-action", gimp_action_group_add_actions (group, "edit-action",
@ -260,11 +260,11 @@ edit_actions_setup (GimpActionGroup *group)
G_CALLBACK (edit_actions_pattern_changed), G_CALLBACK (edit_actions_pattern_changed),
group, 0); group, 0);
gimp_context_get_foreground (context, &color); color = gimp_context_get_foreground (context);
edit_actions_foreground_changed (context, &color, group); edit_actions_foreground_changed (context, color, group);
gimp_context_get_background (context, &color); color = gimp_context_get_background (context);
edit_actions_background_changed (context, &color, group); edit_actions_background_changed (context, color, group);
pattern = gimp_context_get_pattern (context); pattern = gimp_context_get_pattern (context);
edit_actions_pattern_changed (context, pattern, group); edit_actions_pattern_changed (context, pattern, group);
@ -380,18 +380,24 @@ edit_actions_update (GimpActionGroup *group,
static void static void
edit_actions_foreground_changed (GimpContext *context, edit_actions_foreground_changed (GimpContext *context,
const GimpRGB *color, GeglColor *color,
GimpActionGroup *group) GimpActionGroup *group)
{ {
gimp_action_group_set_action_color (group, "edit-fill-fg", color, FALSE); GimpRGB rgb;
gegl_color_get_pixel (color, babl_format ("R'G'B'A double"), &rgb);
gimp_action_group_set_action_color (group, "edit-fill-fg", &rgb, FALSE);
} }
static void static void
edit_actions_background_changed (GimpContext *context, edit_actions_background_changed (GimpContext *context,
const GimpRGB *color, GeglColor *color,
GimpActionGroup *group) GimpActionGroup *group)
{ {
gimp_action_group_set_action_color (group, "edit-fill-bg", color, FALSE); GimpRGB rgb;
gegl_color_get_pixel (color, babl_format ("R'G'B'A double"), &rgb);
gimp_action_group_set_action_color (group, "edit-fill-bg", &rgb, FALSE);
} }
static void static void

View File

@ -548,8 +548,12 @@ gradient_editor_actions_update (GimpActionGroup *group,
if (data_editor->context) if (data_editor->context)
{ {
gimp_context_get_foreground (data_editor->context, &fg); GeglColor *color;
gimp_context_get_background (data_editor->context, &bg);
color = gimp_context_get_foreground (data_editor->context);
gegl_color_get_rgba_with_space (color, &fg.r, &fg.g, &fg.b, &fg.a, NULL);
color = gimp_context_get_background (data_editor->context);
gegl_color_get_rgba_with_space (color, &bg.r, &bg.g, &bg.b, &bg.a, NULL);
} }
/* pretend the gradient not being editable while the dialog is /* pretend the gradient not being editable while the dialog is

View File

@ -108,7 +108,8 @@ gradient_editor_load_left_cmd_callback (GimpAction *action,
GimpGradientSegment *left; GimpGradientSegment *left;
GimpGradientSegment *right; GimpGradientSegment *right;
GimpGradientSegment *seg; GimpGradientSegment *seg;
GimpRGB color; GeglColor *color = NULL;
GimpRGB rgb;
GimpGradientColor color_type = GIMP_GRADIENT_COLOR_FIXED; GimpGradientColor color_type = GIMP_GRADIENT_COLOR_FIXED;
gint index = g_variant_get_int32 (value); gint index = g_variant_get_int32 (value);
@ -122,32 +123,35 @@ gradient_editor_load_left_cmd_callback (GimpAction *action,
else else
seg = gimp_gradient_segment_get_last (left); seg = gimp_gradient_segment_get_last (left);
color = seg->right_color; rgb = seg->right_color;
color_type = seg->right_color_type; color_type = seg->right_color_type;
break; break;
case GRADIENT_EDITOR_COLOR_OTHER_ENDPOINT: case GRADIENT_EDITOR_COLOR_OTHER_ENDPOINT:
color = right->right_color; rgb = right->right_color;
color_type = right->right_color_type; color_type = right->right_color_type;
break; break;
case GRADIENT_EDITOR_COLOR_FOREGROUND: case GRADIENT_EDITOR_COLOR_FOREGROUND:
gimp_context_get_foreground (data_editor->context, &color); color = gimp_context_get_foreground (data_editor->context);
break; break;
case GRADIENT_EDITOR_COLOR_BACKGROUND: case GRADIENT_EDITOR_COLOR_BACKGROUND:
gimp_context_get_background (data_editor->context, &color); color = gimp_context_get_background (data_editor->context);
break; break;
default: /* Load a color */ default: /* Load a color */
color = editor->saved_colors[index - GRADIENT_EDITOR_COLOR_FIRST_CUSTOM]; rgb = editor->saved_colors[index - GRADIENT_EDITOR_COLOR_FIRST_CUSTOM];
break; break;
} }
if (color != NULL)
gegl_color_get_rgba_with_space (color, &rgb.r, &rgb.g, &rgb.b, &rgb.a, NULL);
gimp_data_freeze (GIMP_DATA (gradient)); gimp_data_freeze (GIMP_DATA (gradient));
gimp_gradient_segment_range_blend (gradient, left, right, gimp_gradient_segment_range_blend (gradient, left, right,
&color, &rgb,
&right->right_color, &right->right_color,
TRUE, TRUE); TRUE, TRUE);
gimp_gradient_segment_set_left_color_type (gradient, left, color_type); gimp_gradient_segment_set_left_color_type (gradient, left, color_type);
@ -228,7 +232,8 @@ gradient_editor_load_right_cmd_callback (GimpAction *action,
GimpGradientSegment *left; GimpGradientSegment *left;
GimpGradientSegment *right; GimpGradientSegment *right;
GimpGradientSegment *seg; GimpGradientSegment *seg;
GimpRGB color; GeglColor *color = NULL;
GimpRGB rgb;
GimpGradientColor color_type = GIMP_GRADIENT_COLOR_FIXED; GimpGradientColor color_type = GIMP_GRADIENT_COLOR_FIXED;
gint index = g_variant_get_int32 (value); gint index = g_variant_get_int32 (value);
@ -242,33 +247,36 @@ gradient_editor_load_right_cmd_callback (GimpAction *action,
else else
seg = gimp_gradient_segment_get_first (right); seg = gimp_gradient_segment_get_first (right);
color = seg->left_color; rgb = seg->left_color;
color_type = seg->left_color_type; color_type = seg->left_color_type;
break; break;
case GRADIENT_EDITOR_COLOR_OTHER_ENDPOINT: case GRADIENT_EDITOR_COLOR_OTHER_ENDPOINT:
color = left->left_color; rgb = left->left_color;
color_type = left->left_color_type; color_type = left->left_color_type;
break; break;
case GRADIENT_EDITOR_COLOR_FOREGROUND: case GRADIENT_EDITOR_COLOR_FOREGROUND:
gimp_context_get_foreground (data_editor->context, &color); color = gimp_context_get_foreground (data_editor->context);
break; break;
case GRADIENT_EDITOR_COLOR_BACKGROUND: case GRADIENT_EDITOR_COLOR_BACKGROUND:
gimp_context_get_background (data_editor->context, &color); color = gimp_context_get_background (data_editor->context);
break; break;
default: /* Load a color */ default: /* Load a color */
color = editor->saved_colors[index - GRADIENT_EDITOR_COLOR_FIRST_CUSTOM]; rgb = editor->saved_colors[index - GRADIENT_EDITOR_COLOR_FIRST_CUSTOM];
break; break;
} }
if (color != NULL)
gegl_color_get_rgba_with_space (color, &rgb.r, &rgb.g, &rgb.b, &rgb.a, NULL);
gimp_data_freeze (GIMP_DATA (gradient)); gimp_data_freeze (GIMP_DATA (gradient));
gimp_gradient_segment_range_blend (gradient, left, right, gimp_gradient_segment_range_blend (gradient, left, right,
&left->left_color, &left->left_color,
&color, &rgb,
TRUE, TRUE); TRUE, TRUE);
gimp_gradient_segment_set_right_color_type (gradient, left, color_type); gimp_gradient_segment_set_right_color_type (gradient, left, color_type);

View File

@ -145,8 +145,12 @@ palette_editor_actions_update (GimpActionGroup *group,
if (data_editor->context) if (data_editor->context)
{ {
gimp_context_get_foreground (data_editor->context, &fg); GeglColor *color;
gimp_context_get_background (data_editor->context, &bg);
color = gimp_context_get_foreground (data_editor->context);
gegl_color_get_rgba_with_space (color, &fg.r, &fg.g, &fg.b, &fg.a, NULL);
color = gimp_context_get_background (data_editor->context);
gegl_color_get_rgba_with_space (color, &bg.r, &bg.g, &bg.b, &bg.a, NULL);
} }
edit_active = gimp_data_editor_get_edit_active (data_editor); edit_active = gimp_data_editor_get_edit_active (data_editor);

View File

@ -56,14 +56,16 @@ palette_editor_new_color_cmd_callback (GimpAction *action,
{ {
GimpPalette *palette = GIMP_PALETTE (data_editor->data); GimpPalette *palette = GIMP_PALETTE (data_editor->data);
GimpPaletteEntry *entry; GimpPaletteEntry *entry;
GimpRGB color; GimpRGB rgb;
GeglColor *color;
if (background) if (background)
gimp_context_get_background (data_editor->context, &color); color = gimp_context_get_background (data_editor->context);
else else
gimp_context_get_foreground (data_editor->context, &color); color = gimp_context_get_foreground (data_editor->context);
entry = gimp_palette_add_entry (palette, -1, NULL, &color); gegl_color_get_rgba_with_space (color, &rgb.r, &rgb.g, &rgb.b, &rgb.a, NULL);
entry = gimp_palette_add_entry (palette, -1, NULL, &rgb);
gimp_palette_view_select_entry (GIMP_PALETTE_VIEW (editor->view), entry); gimp_palette_view_select_entry (GIMP_PALETTE_VIEW (editor->view), entry);
} }
} }

View File

@ -527,13 +527,15 @@ gimp_enum_get_value_name (GType enum_type,
gboolean gboolean
gimp_get_fill_params (GimpContext *context, gimp_get_fill_params (GimpContext *context,
GimpFillType fill_type, GimpFillType fill_type,
GimpRGB *color, GimpRGB *rgb,
GimpPattern **pattern, GimpPattern **pattern,
GError **error) GError **error)
{ {
GeglColor *color;
g_return_val_if_fail (GIMP_IS_CONTEXT (context), FALSE); g_return_val_if_fail (GIMP_IS_CONTEXT (context), FALSE);
g_return_val_if_fail (color != NULL, FALSE); g_return_val_if_fail (rgb != NULL, FALSE);
g_return_val_if_fail (pattern != NULL, FALSE); g_return_val_if_fail (pattern != NULL, FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE); g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
@ -542,11 +544,13 @@ gimp_get_fill_params (GimpContext *context,
switch (fill_type) switch (fill_type)
{ {
case GIMP_FILL_FOREGROUND: case GIMP_FILL_FOREGROUND:
gimp_context_get_foreground (context, color); color = gimp_context_get_foreground (context);
gegl_color_get_rgba_with_space (color, &rgb->r, &rgb->g, &rgb->b, &rgb->a, NULL);
break; break;
case GIMP_FILL_BACKGROUND: case GIMP_FILL_BACKGROUND:
gimp_context_get_background (context, color); color = gimp_context_get_background (context);
gegl_color_get_rgba_with_space (color, &rgb->r, &rgb->g, &rgb->b, &rgb->a, NULL);
break; break;
case GIMP_FILL_CIELAB_MIDDLE_GRAY: case GIMP_FILL_CIELAB_MIDDLE_GRAY:
@ -568,16 +572,16 @@ gimp_get_fill_params (GimpContext *context,
babl_process (babl_fish (babl_format ("CIE Lab float"), format), babl_process (babl_fish (babl_format ("CIE Lab float"), format),
cielab_pixel, pixel, 1); cielab_pixel, pixel, 1);
gimp_rgba_set (color, pixel[0], pixel[1], pixel[2], GIMP_OPACITY_OPAQUE); gimp_rgba_set (rgb, pixel[0], pixel[1], pixel[2], GIMP_OPACITY_OPAQUE);
} }
break; break;
case GIMP_FILL_WHITE: case GIMP_FILL_WHITE:
gimp_rgba_set (color, 1.0, 1.0, 1.0, GIMP_OPACITY_OPAQUE); gimp_rgba_set (rgb, 1.0, 1.0, 1.0, GIMP_OPACITY_OPAQUE);
break; break;
case GIMP_FILL_TRANSPARENT: case GIMP_FILL_TRANSPARENT:
gimp_rgba_set (color, 0.0, 0.0, 0.0, GIMP_OPACITY_TRANSPARENT); gimp_rgba_set (rgb, 0.0, 0.0, 0.0, GIMP_OPACITY_TRANSPARENT);
break; break;
case GIMP_FILL_PATTERN: case GIMP_FILL_PATTERN:
@ -589,7 +593,8 @@ gimp_get_fill_params (GimpContext *context,
_("No patterns available for this operation.")); _("No patterns available for this operation."));
/* fall back to BG fill */ /* fall back to BG fill */
gimp_context_get_background (context, color); color = gimp_context_get_background (context);
gegl_color_get_rgba_with_space (color, &rgb->r, &rgb->g, &rgb->b, &rgb->a, NULL);
return FALSE; return FALSE;
} }

View File

@ -58,8 +58,6 @@
#include "gimp-intl.h" #include "gimp-intl.h"
#define RGBA_EPSILON 1e-10
typedef void (* GimpContextCopyPropFunc) (GimpContext *src, typedef void (* GimpContextCopyPropFunc) (GimpContext *src,
GimpContext *dest); GimpContext *dest);
@ -405,11 +403,8 @@ gimp_context_class_init (GimpContextClass *klass)
{ {
GObjectClass *object_class = G_OBJECT_CLASS (klass); GObjectClass *object_class = G_OBJECT_CLASS (klass);
GimpObjectClass *gimp_object_class = GIMP_OBJECT_CLASS (klass); GimpObjectClass *gimp_object_class = GIMP_OBJECT_CLASS (klass);
GimpRGB black; GeglColor *black = gegl_color_new ("black");
GimpRGB white; GeglColor *white = gegl_color_new ("white");
gimp_rgba_set (&black, 0.0, 0.0, 0.0, GIMP_OPACITY_OPAQUE);
gimp_rgba_set (&white, 1.0, 1.0, 1.0, GIMP_OPACITY_OPAQUE);
gimp_context_signals[IMAGE_CHANGED] = gimp_context_signals[IMAGE_CHANGED] =
g_signal_new ("image-changed", g_signal_new ("image-changed",
@ -454,7 +449,7 @@ gimp_context_class_init (GimpContextClass *klass)
G_STRUCT_OFFSET (GimpContextClass, foreground_changed), G_STRUCT_OFFSET (GimpContextClass, foreground_changed),
NULL, NULL, NULL, NULL, NULL, NULL,
G_TYPE_NONE, 1, G_TYPE_NONE, 1,
GIMP_TYPE_RGB | G_SIGNAL_TYPE_STATIC_SCOPE); GEGL_TYPE_COLOR);
gimp_context_signals[BACKGROUND_CHANGED] = gimp_context_signals[BACKGROUND_CHANGED] =
g_signal_new ("background-changed", g_signal_new ("background-changed",
@ -463,7 +458,7 @@ gimp_context_class_init (GimpContextClass *klass)
G_STRUCT_OFFSET (GimpContextClass, background_changed), G_STRUCT_OFFSET (GimpContextClass, background_changed),
NULL, NULL, NULL, NULL, NULL, NULL,
G_TYPE_NONE, 1, G_TYPE_NONE, 1,
GIMP_TYPE_RGB | G_SIGNAL_TYPE_STATIC_SCOPE); GEGL_TYPE_COLOR);
gimp_context_signals[OPACITY_CHANGED] = gimp_context_signals[OPACITY_CHANGED] =
g_signal_new ("opacity-changed", g_signal_new ("opacity-changed",
@ -666,19 +661,19 @@ gimp_context_class_init (GimpContextClass *klass)
GIMP_TYPE_PAINT_INFO, GIMP_TYPE_PAINT_INFO,
GIMP_PARAM_STATIC_STRINGS); GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_PROP_RGB (object_class, GIMP_CONTEXT_PROP_FOREGROUND, GIMP_CONFIG_PROP_COLOR (object_class, GIMP_CONTEXT_PROP_FOREGROUND,
gimp_context_prop_names[GIMP_CONTEXT_PROP_FOREGROUND], gimp_context_prop_names[GIMP_CONTEXT_PROP_FOREGROUND],
_("Foreground"), _("Foreground"),
_("Foreground color"), _("Foreground color"),
FALSE, &black, black,
GIMP_PARAM_STATIC_STRINGS); GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_PROP_RGB (object_class, GIMP_CONTEXT_PROP_BACKGROUND, GIMP_CONFIG_PROP_COLOR (object_class, GIMP_CONTEXT_PROP_BACKGROUND,
gimp_context_prop_names[GIMP_CONTEXT_PROP_BACKGROUND], gimp_context_prop_names[GIMP_CONTEXT_PROP_BACKGROUND],
_("Background"), _("Background"),
_("Background color"), _("Background color"),
FALSE, &white, white,
GIMP_PARAM_STATIC_STRINGS); GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_PROP_DOUBLE (object_class, GIMP_CONTEXT_PROP_OPACITY, GIMP_CONFIG_PROP_DOUBLE (object_class, GIMP_CONTEXT_PROP_OPACITY,
gimp_context_prop_names[GIMP_CONTEXT_PROP_OPACITY], gimp_context_prop_names[GIMP_CONTEXT_PROP_OPACITY],
@ -770,6 +765,9 @@ gimp_context_class_init (GimpContextClass *klass)
NULL, NULL, NULL, NULL,
GIMP_TYPE_TEMPLATE, GIMP_TYPE_TEMPLATE,
GIMP_PARAM_READWRITE)); GIMP_PARAM_READWRITE));
g_object_unref (black);
g_object_unref (white);
} }
static void static void
@ -827,8 +825,8 @@ gimp_context_init (GimpContext *context)
context->line_art = NULL; context->line_art = NULL;
context->line_art_timeout_id = 0; context->line_art_timeout_id = 0;
context->foreground = NULL; context->foreground = gegl_color_new ("black");
context->background = NULL; context->background = gegl_color_new ("white");
} }
static void static void
@ -1058,24 +1056,10 @@ gimp_context_set_property (GObject *object,
gimp_context_set_paint_info (context, g_value_get_object (value)); gimp_context_set_paint_info (context, g_value_get_object (value));
break; break;
case GIMP_CONTEXT_PROP_FOREGROUND: case GIMP_CONTEXT_PROP_FOREGROUND:
{ gimp_context_set_foreground (context, g_value_get_object (value));
GeglColor *color = gegl_color_new ("black");
GimpRGB *rgb = g_value_get_boxed (value);
gegl_color_set_rgba_with_space (color, rgb->r, rgb->g, rgb->b, rgb->a, NULL);
gimp_context_set_foreground (context, color);
g_object_unref (color);
}
break; break;
case GIMP_CONTEXT_PROP_BACKGROUND: case GIMP_CONTEXT_PROP_BACKGROUND:
{ gimp_context_set_background (context, g_value_get_object (value));
GeglColor *color = gegl_color_new ("black");
GimpRGB *rgb = g_value_get_boxed (value);
gegl_color_set_rgba_with_space (color, rgb->r, rgb->g, rgb->b, rgb->a, NULL);
gimp_context_set_background (context, color);
g_object_unref (color);
}
break; break;
case GIMP_CONTEXT_PROP_OPACITY: case GIMP_CONTEXT_PROP_OPACITY:
gimp_context_set_opacity (context, g_value_get_double (value)); gimp_context_set_opacity (context, g_value_get_double (value));
@ -1148,20 +1132,10 @@ gimp_context_get_property (GObject *object,
g_value_set_object (value, gimp_context_get_paint_info (context)); g_value_set_object (value, gimp_context_get_paint_info (context));
break; break;
case GIMP_CONTEXT_PROP_FOREGROUND: case GIMP_CONTEXT_PROP_FOREGROUND:
{ g_value_take_object (value, gegl_color_duplicate (gimp_context_get_foreground (context)));
GimpRGB color;
gimp_context_get_foreground (context, &color);
g_value_set_boxed (value, &color);
}
break; break;
case GIMP_CONTEXT_PROP_BACKGROUND: case GIMP_CONTEXT_PROP_BACKGROUND:
{ g_value_take_object (value, gegl_color_duplicate (gimp_context_get_background (context)));
GimpRGB color;
gimp_context_get_background (context, &color);
g_value_set_boxed (value, &color);
}
break; break;
case GIMP_CONTEXT_PROP_OPACITY: case GIMP_CONTEXT_PROP_OPACITY:
g_value_set_double (value, gimp_context_get_opacity (context)); g_value_set_double (value, gimp_context_get_opacity (context));
@ -2307,14 +2281,12 @@ gimp_context_real_set_paint_info (GimpContext *context,
/*****************************************************************************/ /*****************************************************************************/
/* foreground color ********************************************************/ /* foreground color ********************************************************/
void GeglColor *
gimp_context_get_foreground (GimpContext *context, gimp_context_get_foreground (GimpContext *context)
GimpRGB *rgb)
{ {
g_return_if_fail (GIMP_IS_CONTEXT (context)); g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
g_return_if_fail (rgb != NULL);
gegl_color_get_rgba_with_space (context->foreground, &rgb->r, &rgb->g, &rgb->b, &rgb->a, NULL); return context->foreground;
} }
void void
@ -2322,7 +2294,7 @@ gimp_context_set_foreground (GimpContext *context,
GeglColor *color) GeglColor *color)
{ {
g_return_if_fail (GIMP_IS_CONTEXT (context)); g_return_if_fail (GIMP_IS_CONTEXT (context));
g_return_if_fail (color != NULL); g_return_if_fail (GEGL_IS_COLOR (color));
context_find_defined (context, GIMP_CONTEXT_PROP_FOREGROUND); context_find_defined (context, GIMP_CONTEXT_PROP_FOREGROUND);
@ -2336,7 +2308,7 @@ gimp_context_foreground_changed (GimpContext *context)
g_signal_emit (context, g_signal_emit (context,
gimp_context_signals[FOREGROUND_CHANGED], 0, gimp_context_signals[FOREGROUND_CHANGED], 0,
&context->foreground); context->foreground);
} }
static void static void
@ -2359,15 +2331,12 @@ gimp_context_real_set_foreground (GimpContext *context,
/*****************************************************************************/ /*****************************************************************************/
/* background color ********************************************************/ /* background color ********************************************************/
void GeglColor *
gimp_context_get_background (GimpContext *context, gimp_context_get_background (GimpContext *context)
GimpRGB *rgb)
{ {
g_return_if_fail (GIMP_IS_CONTEXT (context)); g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
g_return_if_fail (rgb != NULL); return context->background;
gegl_color_get_rgba_with_space (context->background, &rgb->r, &rgb->g, &rgb->b, &rgb->a, NULL);
} }
void void
@ -2375,7 +2344,7 @@ gimp_context_set_background (GimpContext *context,
GeglColor *color) GeglColor *color)
{ {
g_return_if_fail (GIMP_IS_CONTEXT (context)); g_return_if_fail (GIMP_IS_CONTEXT (context));
g_return_if_fail (color != NULL); g_return_if_fail (GEGL_IS_COLOR (color));
context_find_defined (context, GIMP_CONTEXT_PROP_BACKGROUND); context_find_defined (context, GIMP_CONTEXT_PROP_BACKGROUND);
@ -2389,7 +2358,7 @@ gimp_context_background_changed (GimpContext *context)
g_signal_emit (context, g_signal_emit (context,
gimp_context_signals[BACKGROUND_CHANGED], 0, gimp_context_signals[BACKGROUND_CHANGED], 0,
&context->background); context->background);
} }
static void static void

View File

@ -122,9 +122,9 @@ struct _GimpContextClass
GimpPaintInfo *paint_info); GimpPaintInfo *paint_info);
void (* foreground_changed) (GimpContext *context, void (* foreground_changed) (GimpContext *context,
GimpRGB *color); GeglColor *color);
void (* background_changed) (GimpContext *context, void (* background_changed) (GimpContext *context,
GimpRGB *color); GeglColor *color);
void (* opacity_changed) (GimpContext *context, void (* opacity_changed) (GimpContext *context,
gdouble opacity); gdouble opacity);
void (* paint_mode_changed) (GimpContext *context, void (* paint_mode_changed) (GimpContext *context,
@ -246,16 +246,14 @@ void gimp_context_paint_info_changed (GimpContext *context);
/* foreground color */ /* foreground color */
void gimp_context_get_foreground (GimpContext *context, GeglColor * gimp_context_get_foreground (GimpContext *context);
GimpRGB *color);
void gimp_context_set_foreground (GimpContext *context, void gimp_context_set_foreground (GimpContext *context,
GeglColor *color); GeglColor *color);
void gimp_context_foreground_changed (GimpContext *context); void gimp_context_foreground_changed (GimpContext *context);
/* background color */ /* background color */
void gimp_context_get_background (GimpContext *context, GeglColor * gimp_context_get_background (GimpContext *context);
GimpRGB *color);
void gimp_context_set_background (GimpContext *context, void gimp_context_set_background (GimpContext *context,
GeglColor *color); GeglColor *color);
void gimp_context_background_changed (GimpContext *context); void gimp_context_background_changed (GimpContext *context);

View File

@ -410,6 +410,7 @@ gimp_drawable_get_line_art_fill_buffer (GimpDrawable *drawable,
if (fill_color_as_line_art) if (fill_color_as_line_art)
{ {
GimpPickable *pickable = gimp_line_art_get_input (line_art); GimpPickable *pickable = gimp_line_art_get_input (line_art);
GeglColor *color = NULL;
/* This cannot be a pattern fill. */ /* This cannot be a pattern fill. */
g_return_val_if_fail (gimp_fill_options_get_style (options) != GIMP_FILL_STYLE_PATTERN, g_return_val_if_fail (gimp_fill_options_get_style (options) != GIMP_FILL_STYLE_PATTERN,
@ -418,9 +419,12 @@ gimp_drawable_get_line_art_fill_buffer (GimpDrawable *drawable,
g_return_val_if_fail (GIMP_IS_DRAWABLE (pickable), NULL); g_return_val_if_fail (GIMP_IS_DRAWABLE (pickable), NULL);
if (gimp_fill_options_get_style (options) == GIMP_FILL_STYLE_FG_COLOR) if (gimp_fill_options_get_style (options) == GIMP_FILL_STYLE_FG_COLOR)
gimp_context_get_foreground (GIMP_CONTEXT (options), &fill_color); color = gimp_context_get_foreground (GIMP_CONTEXT (options));
else if (gimp_fill_options_get_style (options) == GIMP_FILL_STYLE_BG_COLOR) else if (gimp_fill_options_get_style (options) == GIMP_FILL_STYLE_BG_COLOR)
gimp_context_get_background (GIMP_CONTEXT (options), &fill_color); color = gimp_context_get_background (GIMP_CONTEXT (options));
g_return_val_if_fail (color != NULL, NULL);
gegl_color_get_rgba_with_space (color, &fill_color.r, &fill_color.g, &fill_color.b, &fill_color.a, NULL);
fill_buffer = gimp_drawable_get_buffer (drawable); fill_buffer = gimp_drawable_get_buffer (drawable);
fill_offset_x = gimp_item_get_offset_x (GIMP_ITEM (drawable)) - fill_offset_x = gimp_item_get_offset_x (GIMP_ITEM (drawable)) -

View File

@ -198,7 +198,7 @@ gimp_drawable_transform_buffer_flip (GimpDrawable *drawable,
if (clip_result && (new_x != orig_x || new_y != orig_y)) if (clip_result && (new_x != orig_x || new_y != orig_y))
{ {
GimpRGB bg; GimpRGB bg;
GeglColor *color; GeglColor *color = NULL;
gint clip_x, clip_y; gint clip_x, clip_y;
gint clip_width, clip_height; gint clip_width, clip_height;
@ -209,17 +209,12 @@ gimp_drawable_transform_buffer_flip (GimpDrawable *drawable,
* channels, and drawables with an alpha channel. * channels, and drawables with an alpha channel.
*/ */
if (GIMP_IS_CHANNEL (drawable) || babl_format_has_alpha (format)) if (GIMP_IS_CHANNEL (drawable) || babl_format_has_alpha (format))
{ gimp_rgba_set (&bg, 0.0, 0.0, 0.0, 0.0);
gimp_rgba_set (&bg, 0.0, 0.0, 0.0, 0.0);
}
else else
{ color = gegl_color_duplicate (gimp_context_get_background (context));
gimp_context_get_background (context, &bg);
gimp_pickable_srgb_to_image_color (GIMP_PICKABLE (drawable),
&bg, &bg);
}
color = gimp_gegl_color_new (&bg, gimp_drawable_get_space (drawable)); if (color == NULL)
color = gimp_gegl_color_new (&bg, gimp_drawable_get_space (drawable));
gegl_buffer_set_color (new_buffer, NULL, color); gegl_buffer_set_color (new_buffer, NULL, color);
g_object_unref (color); g_object_unref (color);
@ -459,7 +454,7 @@ gimp_drawable_transform_buffer_rotate (GimpDrawable *drawable,
{ {
GimpRGB bg; GimpRGB bg;
GeglColor *color; GeglColor *color = NULL;
gint clip_x, clip_y; gint clip_x, clip_y;
gint clip_width, clip_height; gint clip_width, clip_height;
@ -474,17 +469,12 @@ gimp_drawable_transform_buffer_rotate (GimpDrawable *drawable,
* channels, and drawables with an alpha channel. * channels, and drawables with an alpha channel.
*/ */
if (GIMP_IS_CHANNEL (drawable) || babl_format_has_alpha (format)) if (GIMP_IS_CHANNEL (drawable) || babl_format_has_alpha (format))
{ gimp_rgba_set (&bg, 0.0, 0.0, 0.0, 0.0);
gimp_rgba_set (&bg, 0.0, 0.0, 0.0, 0.0);
}
else else
{ color = gegl_color_duplicate (gimp_context_get_background (context));
gimp_context_get_background (context, &bg);
gimp_pickable_srgb_to_image_color (GIMP_PICKABLE (drawable),
&bg, &bg);
}
color = gimp_gegl_color_new (&bg, gimp_drawable_get_space (drawable)); if (color == NULL)
color = gimp_gegl_color_new (&bg, gimp_drawable_get_space (drawable));
gegl_buffer_set_color (new_buffer, NULL, color); gegl_buffer_set_color (new_buffer, NULL, color);
g_object_unref (color); g_object_unref (color);

View File

@ -375,8 +375,7 @@ gimp_fill_options_set_by_fill_type (GimpFillOptions *options,
GError **error) GError **error)
{ {
GimpFillOptionsPrivate *private; GimpFillOptionsPrivate *private;
GeglColor *color; GeglColor *color = NULL;
GimpRGB rgb;
const gchar *undo_desc; const gchar *undo_desc;
g_return_val_if_fail (GIMP_IS_FILL_OPTIONS (options), FALSE); g_return_val_if_fail (GIMP_IS_FILL_OPTIONS (options), FALSE);
@ -390,46 +389,33 @@ gimp_fill_options_set_by_fill_type (GimpFillOptions *options,
switch (fill_type) switch (fill_type)
{ {
case GIMP_FILL_FOREGROUND: case GIMP_FILL_FOREGROUND:
gimp_context_get_foreground (context, &rgb); color = gegl_color_duplicate (gimp_context_get_foreground (context));
undo_desc = C_("undo-type", "Fill with Foreground Color"); undo_desc = C_("undo-type", "Fill with Foreground Color");
break; break;
case GIMP_FILL_BACKGROUND: case GIMP_FILL_BACKGROUND:
gimp_context_get_background (context, &rgb); color = gegl_color_duplicate (gimp_context_get_background (context));
undo_desc = C_("undo-type", "Fill with Background Color"); undo_desc = C_("undo-type", "Fill with Background Color");
break; break;
case GIMP_FILL_CIELAB_MIDDLE_GRAY: case GIMP_FILL_CIELAB_MIDDLE_GRAY:
{ {
const float cielab_pixel[3] = {50, 0, 0}; const float cielab_pixel[3] = {50, 0, 0};
float pixel[3] = {0, 0, 0};
GimpImage *image = gimp_context_get_image (context);
GimpImageBaseType base_type;
const Babl *format;
base_type = gimp_image_get_base_type (image); color = gegl_color_new (NULL);
if (base_type == GIMP_INDEXED) gegl_color_set_pixel (color, babl_format ("CIE Lab float"), cielab_pixel);
base_type = GIMP_RGB;
format = gimp_image_get_format (image, base_type,
GIMP_PRECISION_FLOAT_NON_LINEAR, FALSE,
gimp_image_get_layer_space (image));
babl_process (babl_fish (babl_format ("CIE Lab float"), format),
cielab_pixel, pixel, 1);
gimp_rgba_set (&rgb, pixel[0], pixel[1], pixel[2], GIMP_OPACITY_OPAQUE);
undo_desc = C_("undo-type", "Fill with Middle Gray (CIELAB) Color"); undo_desc = C_("undo-type", "Fill with Middle Gray (CIELAB) Color");
} }
break; break;
case GIMP_FILL_WHITE: case GIMP_FILL_WHITE:
gimp_rgba_set (&rgb, 1.0, 1.0, 1.0, GIMP_OPACITY_OPAQUE); color = gegl_color_new ("white");
undo_desc = C_("undo-type", "Fill with White"); undo_desc = C_("undo-type", "Fill with White");
break; break;
case GIMP_FILL_TRANSPARENT: case GIMP_FILL_TRANSPARENT:
gimp_context_get_background (context, &rgb); color = gegl_color_duplicate (gimp_context_get_background (context));
gimp_context_set_paint_mode (GIMP_CONTEXT (options), gimp_context_set_paint_mode (GIMP_CONTEXT (options),
GIMP_LAYER_MODE_ERASE); GIMP_LAYER_MODE_ERASE);
undo_desc = C_("undo-type", "Fill with Transparency"); undo_desc = C_("undo-type", "Fill with Transparency");
@ -459,9 +445,9 @@ gimp_fill_options_set_by_fill_type (GimpFillOptions *options,
return FALSE; return FALSE;
} }
g_return_val_if_fail (color != NULL, FALSE);
gimp_fill_options_set_style (options, GIMP_FILL_STYLE_FG_COLOR); gimp_fill_options_set_style (options, GIMP_FILL_STYLE_FG_COLOR);
color = gegl_color_new ("black");
gegl_color_set_rgba_with_space (color, rgb.r, rgb.g, rgb.b, rgb.a, NULL);
gimp_context_set_foreground (GIMP_CONTEXT (options), color); gimp_context_set_foreground (GIMP_CONTEXT (options), color);
private->undo_desc = undo_desc; private->undo_desc = undo_desc;
@ -592,25 +578,27 @@ gimp_fill_options_fill_buffer (GimpFillOptions *options,
{ {
case GIMP_FILL_STYLE_FG_COLOR: case GIMP_FILL_STYLE_FG_COLOR:
{ {
GimpRGB color; GeglColor *color;
GimpRGB rgb;
gimp_context_get_foreground (GIMP_CONTEXT (options), &color); color = gimp_context_get_foreground (GIMP_CONTEXT (options));
gimp_palettes_add_color_history (GIMP_CONTEXT (options)->gimp, &color); gegl_color_get_rgba_with_space (color, &rgb.r, &rgb.g, &rgb.b, &rgb.a, NULL);
gimp_palettes_add_color_history (GIMP_CONTEXT (options)->gimp, &rgb);
gimp_drawable_fill_buffer (drawable, buffer, gimp_drawable_fill_buffer (drawable, buffer, &rgb, NULL, 0, 0);
&color, NULL, 0, 0);
} }
break; break;
case GIMP_FILL_STYLE_BG_COLOR: case GIMP_FILL_STYLE_BG_COLOR:
{ {
GimpRGB color; GeglColor *color;
GimpRGB rgb;
gimp_context_get_background (GIMP_CONTEXT (options), &color); color = gimp_context_get_background (GIMP_CONTEXT (options));
gimp_palettes_add_color_history (GIMP_CONTEXT (options)->gimp, &color); gegl_color_get_rgba_with_space (color, &rgb.r, &rgb.g, &rgb.b, &rgb.a, NULL);
gimp_palettes_add_color_history (GIMP_CONTEXT (options)->gimp, &rgb);
gimp_drawable_fill_buffer (drawable, buffer, gimp_drawable_fill_buffer (drawable, buffer, &rgb, NULL, 0, 0);
&color, NULL, 0, 0);
} }
break; break;

View File

@ -2195,32 +2195,39 @@ gimp_gradient_get_segment_at_internal (GimpGradient *gradient,
static void static void
gimp_gradient_get_flat_color (GimpContext *context, gimp_gradient_get_flat_color (GimpContext *context,
const GimpRGB *color, const GimpRGB *rgb,
GimpGradientColor color_type, GimpGradientColor color_type,
GimpRGB *flat_color) GimpRGB *flat_color)
{ {
GeglColor *color = NULL;
switch (color_type) switch (color_type)
{ {
case GIMP_GRADIENT_COLOR_FIXED: case GIMP_GRADIENT_COLOR_FIXED:
*flat_color = *color; *flat_color = *rgb;
break; break;
case GIMP_GRADIENT_COLOR_FOREGROUND: case GIMP_GRADIENT_COLOR_FOREGROUND:
case GIMP_GRADIENT_COLOR_FOREGROUND_TRANSPARENT: case GIMP_GRADIENT_COLOR_FOREGROUND_TRANSPARENT:
gimp_context_get_foreground (context, flat_color); color = gegl_color_duplicate (gimp_context_get_foreground (context));
if (color_type == GIMP_GRADIENT_COLOR_FOREGROUND_TRANSPARENT) if (color_type == GIMP_GRADIENT_COLOR_FOREGROUND_TRANSPARENT)
gimp_rgb_set_alpha (flat_color, 0.0); gimp_color_set_alpha (color, 0.0);
break; break;
case GIMP_GRADIENT_COLOR_BACKGROUND: case GIMP_GRADIENT_COLOR_BACKGROUND:
case GIMP_GRADIENT_COLOR_BACKGROUND_TRANSPARENT: case GIMP_GRADIENT_COLOR_BACKGROUND_TRANSPARENT:
gimp_context_get_background (context, flat_color); color = gegl_color_duplicate (gimp_context_get_background (context));
if (color_type == GIMP_GRADIENT_COLOR_BACKGROUND_TRANSPARENT) if (color_type == GIMP_GRADIENT_COLOR_BACKGROUND_TRANSPARENT)
gimp_rgb_set_alpha (flat_color, 0.0); gimp_color_set_alpha (color, 0.0);
break; break;
} }
if (color != NULL)
gegl_color_get_rgba_with_space (color, &flat_color->r, &flat_color->g, &flat_color->b, &flat_color->a, NULL);
g_clear_object (&color);
} }
static inline gdouble static inline gdouble

View File

@ -673,7 +673,8 @@ gimp_image_merge_layers (GimpImage *image,
(gimp_drawable_is_indexed (GIMP_DRAWABLE (layer)) && (gimp_drawable_is_indexed (GIMP_DRAWABLE (layer)) &&
! gimp_drawable_has_alpha (GIMP_DRAWABLE (layer)))) ! gimp_drawable_has_alpha (GIMP_DRAWABLE (layer))))
{ {
GimpRGB bg; GeglColor *color;
GimpRGB bg;
merge_layer = gimp_layer_new (image, (x2 - x1), (y2 - y1), merge_layer = gimp_layer_new (image, (x2 - x1), (y2 - y1),
gimp_image_get_layer_format (image, FALSE), gimp_image_get_layer_format (image, FALSE),
@ -689,7 +690,8 @@ gimp_image_merge_layers (GimpImage *image,
} }
/* get the background for compositing */ /* get the background for compositing */
gimp_context_get_background (context, &bg); color = gimp_context_get_background (context);
gegl_color_get_rgba_with_space (color, &bg.r, &bg.g, &bg.b, &bg.a, NULL);
gimp_pickable_srgb_to_image_color (GIMP_PICKABLE (layer), gimp_pickable_srgb_to_image_color (GIMP_PICKABLE (layer),
&bg, &bg); &bg, &bg);

View File

@ -2517,6 +2517,7 @@ gimp_layer_remove_alpha (GimpLayer *layer,
GimpContext *context) GimpContext *context)
{ {
GeglBuffer *new_buffer; GeglBuffer *new_buffer;
GeglColor *color;
GimpRGB background; GimpRGB background;
g_return_if_fail (GIMP_IS_LAYER (layer)); g_return_if_fail (GIMP_IS_LAYER (layer));
@ -2531,7 +2532,8 @@ gimp_layer_remove_alpha (GimpLayer *layer,
gimp_item_get_height (GIMP_ITEM (layer))), gimp_item_get_height (GIMP_ITEM (layer))),
gimp_drawable_get_format_without_alpha (GIMP_DRAWABLE (layer))); gimp_drawable_get_format_without_alpha (GIMP_DRAWABLE (layer)));
gimp_context_get_background (context, &background); color = gimp_context_get_background (context);
gegl_color_get_rgba_with_space (color, &background.r, &background.g, &background.b, &background.a, NULL);
gimp_pickable_srgb_to_image_color (GIMP_PICKABLE (layer), gimp_pickable_srgb_to_image_color (GIMP_PICKABLE (layer),
&background, &background); &background, &background);

View File

@ -193,11 +193,12 @@ gimp_canvas_pen_new (GimpDisplayShell *shell,
const GimpVector2 *points, const GimpVector2 *points,
gint n_points, gint n_points,
GimpContext *context, GimpContext *context,
GimpActiveColor color, GimpActiveColor active_color,
gint width) gint width)
{ {
GimpCanvasItem *item; GimpCanvasItem *item;
GimpArray *array; GimpArray *array;
GeglColor *color = NULL;
GimpRGB rgb; GimpRGB rgb;
g_return_val_if_fail (GIMP_IS_DISPLAY_SHELL (shell), NULL); g_return_val_if_fail (GIMP_IS_DISPLAY_SHELL (shell), NULL);
@ -207,17 +208,22 @@ gimp_canvas_pen_new (GimpDisplayShell *shell,
array = gimp_array_new ((const guint8 *) points, array = gimp_array_new ((const guint8 *) points,
n_points * sizeof (GimpVector2), TRUE); n_points * sizeof (GimpVector2), TRUE);
switch (color) switch (active_color)
{ {
case GIMP_ACTIVE_COLOR_FOREGROUND: case GIMP_ACTIVE_COLOR_FOREGROUND:
gimp_context_get_foreground (context, &rgb); color = gimp_context_get_foreground (context);
break; break;
case GIMP_ACTIVE_COLOR_BACKGROUND: case GIMP_ACTIVE_COLOR_BACKGROUND:
gimp_context_get_background (context, &rgb); color = gimp_context_get_background (context);
break; break;
default:
g_return_val_if_reached (NULL);
} }
gegl_color_get_rgba_with_space (color, &rgb.r, &rgb.g, &rgb.b, &rgb.a, NULL);
item = g_object_new (GIMP_TYPE_CANVAS_PEN, item = g_object_new (GIMP_TYPE_CANVAS_PEN,
"shell", shell, "shell", shell,
"points", array, "points", array,

View File

@ -388,15 +388,18 @@ gimp_display_shell_dnd_fill (GimpDisplayShell *shell,
(gimp_fill_options_get_style (options) == GIMP_FILL_STYLE_FG_COLOR || (gimp_fill_options_get_style (options) == GIMP_FILL_STYLE_FG_COLOR ||
gimp_fill_options_get_style (options) == GIMP_FILL_STYLE_BG_COLOR)) gimp_fill_options_get_style (options) == GIMP_FILL_STYLE_BG_COLOR))
{ {
GimpRGB color; GeglColor *color;
GimpRGB rgb;
if (gimp_fill_options_get_style (options) == GIMP_FILL_STYLE_FG_COLOR) if (gimp_fill_options_get_style (options) == GIMP_FILL_STYLE_FG_COLOR)
gimp_context_get_foreground (GIMP_CONTEXT (options), &color); color = gimp_context_get_foreground (GIMP_CONTEXT (options));
else else
gimp_context_get_background (GIMP_CONTEXT (options), &color); color = gimp_context_get_background (GIMP_CONTEXT (options));
gegl_color_get_rgba_with_space (color, &rgb.r, &rgb.g, &rgb.b, &rgb.a, NULL);
gimp_text_layer_set (iter->data, NULL, gimp_text_layer_set (iter->data, NULL,
"color", &color, "color", &rgb,
NULL); NULL);
} }
else else

View File

@ -112,48 +112,48 @@
/* local function prototypes */ /* local function prototypes */
static gchar * gui_sanity_check (void); static gchar * gui_sanity_check (void);
static void gui_help_func (const gchar *help_id, static void gui_help_func (const gchar *help_id,
gpointer help_data); gpointer help_data);
static gboolean gui_get_background_func (GimpRGB *color); static GeglColor * gui_get_background_func (void);
static gboolean gui_get_foreground_func (GimpRGB *color); static GeglColor * gui_get_foreground_func (void);
static void gui_initialize_after_callback (Gimp *gimp, static void gui_initialize_after_callback (Gimp *gimp,
GimpInitStatusFunc callback); GimpInitStatusFunc callback);
static void gui_restore_callback (Gimp *gimp, static void gui_restore_callback (Gimp *gimp,
GimpInitStatusFunc callback); GimpInitStatusFunc callback);
static void gui_restore_after_callback (Gimp *gimp, static void gui_restore_after_callback (Gimp *gimp,
GimpInitStatusFunc callback); GimpInitStatusFunc callback);
static gboolean gui_exit_callback (Gimp *gimp, static gboolean gui_exit_callback (Gimp *gimp,
gboolean force); gboolean force);
static gboolean gui_exit_after_callback (Gimp *gimp, static gboolean gui_exit_after_callback (Gimp *gimp,
gboolean force); gboolean force);
static void gui_show_help_button_notify (GimpGuiConfig *gui_config, static void gui_show_help_button_notify (GimpGuiConfig *gui_config,
GParamSpec *pspec, GParamSpec *pspec,
Gimp *gimp); Gimp *gimp);
static void gui_user_manual_notify (GimpGuiConfig *gui_config, static void gui_user_manual_notify (GimpGuiConfig *gui_config,
GParamSpec *pspec, GParamSpec *pspec,
Gimp *gimp); Gimp *gimp);
static void gui_single_window_mode_notify (GimpGuiConfig *gui_config, static void gui_single_window_mode_notify (GimpGuiConfig *gui_config,
GParamSpec *pspec, GParamSpec *pspec,
GimpUIConfigurer *ui_configurer); GimpUIConfigurer *ui_configurer);
static void gui_clipboard_changed (Gimp *gimp); static void gui_clipboard_changed (Gimp *gimp);
static void gui_menu_show_tooltip (GimpUIManager *manager, static void gui_menu_show_tooltip (GimpUIManager *manager,
const gchar *tooltip, const gchar *tooltip,
Gimp *gimp); Gimp *gimp);
static void gui_menu_hide_tooltip (GimpUIManager *manager, static void gui_menu_hide_tooltip (GimpUIManager *manager,
Gimp *gimp); Gimp *gimp);
static void gui_display_changed (GimpContext *context, static void gui_display_changed (GimpContext *context,
GimpDisplay *display, GimpDisplay *display,
Gimp *gimp); Gimp *gimp);
static void gui_check_unique_accelerators (Gimp *gimp); static void gui_check_unique_accelerators (Gimp *gimp);
/* private variables */ /* private variables */
@ -411,26 +411,28 @@ gui_help_func (const gchar *help_id,
gimp_help (the_gui_gimp, NULL, NULL, help_id); gimp_help (the_gui_gimp, NULL, NULL, help_id);
} }
static gboolean static GeglColor *
gui_get_foreground_func (GimpRGB *color) gui_get_foreground_func (void)
{ {
g_return_val_if_fail (color != NULL, FALSE); GeglColor *color;
g_return_val_if_fail (GIMP_IS_GIMP (the_gui_gimp), FALSE); g_return_val_if_fail (GIMP_IS_GIMP (the_gui_gimp), FALSE);
gimp_context_get_foreground (gimp_get_user_context (the_gui_gimp), color); color = gimp_context_get_foreground (gimp_get_user_context (the_gui_gimp));
return TRUE; return gegl_color_duplicate (color);
} }
static gboolean static GeglColor *
gui_get_background_func (GimpRGB *color) gui_get_background_func (void)
{ {
g_return_val_if_fail (color != NULL, FALSE); GeglColor *color;
g_return_val_if_fail (GIMP_IS_GIMP (the_gui_gimp), FALSE); g_return_val_if_fail (GIMP_IS_GIMP (the_gui_gimp), FALSE);
gimp_context_get_background (gimp_get_user_context (the_gui_gimp), color); color = gimp_context_get_background (gimp_get_user_context (the_gui_gimp));
return TRUE; return gegl_color_duplicate (color);
} }
static void static void

View File

@ -357,13 +357,7 @@ gimp_operation_offset_process (GeglOperation *operation,
gimp_operation_offset_get_offset (offset, FALSE, &x, &y); gimp_operation_offset_get_offset (offset, FALSE, &x, &y);
if (offset->type == GIMP_OFFSET_BACKGROUND && offset->context) if (offset->type == GIMP_OFFSET_BACKGROUND && offset->context)
{ color = gimp_context_get_background (offset->context);
GimpRGB bg;
gimp_context_get_background (offset->context, &bg);
color = gimp_gegl_color_new (&bg, NULL);
}
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
{ {
@ -398,8 +392,6 @@ gimp_operation_offset_process (GeglOperation *operation,
} }
} }
g_clear_object (&color);
return TRUE; return TRUE;
} }

View File

@ -86,7 +86,7 @@ static gboolean
gimp_eraser_get_color_history_color (GimpPaintbrush *paintbrush, gimp_eraser_get_color_history_color (GimpPaintbrush *paintbrush,
GimpDrawable *drawable, GimpDrawable *drawable,
GimpPaintOptions *paint_options, GimpPaintOptions *paint_options,
GimpRGB *color) GimpRGB *rgb)
{ {
/* Erasing on a drawable without alpha is equivalent to /* Erasing on a drawable without alpha is equivalent to
* drawing with background color. So let's save history. * drawing with background color. So let's save history.
@ -94,8 +94,10 @@ gimp_eraser_get_color_history_color (GimpPaintbrush *paintbrush,
if (! gimp_drawable_has_alpha (drawable)) if (! gimp_drawable_has_alpha (drawable))
{ {
GimpContext *context = GIMP_CONTEXT (paint_options); GimpContext *context = GIMP_CONTEXT (paint_options);
GeglColor *color;
gimp_context_get_background (context, color); color = gimp_context_get_background (context);
gegl_color_get_rgba_with_space (color, &rgb->r, &rgb->g, &rgb->b, &rgb->a, NULL);
return TRUE; return TRUE;
} }
@ -116,8 +118,10 @@ gimp_eraser_get_paint_params (GimpPaintbrush *paintbrush,
{ {
GimpEraserOptions *options = GIMP_ERASER_OPTIONS (paint_options); GimpEraserOptions *options = GIMP_ERASER_OPTIONS (paint_options);
GimpContext *context = GIMP_CONTEXT (paint_options); GimpContext *context = GIMP_CONTEXT (paint_options);
GeglColor *color;
gimp_context_get_background (context, paint_color); color = gimp_context_get_background (context);
gegl_color_get_rgba_with_space (color, &paint_color->r, &paint_color->g, &paint_color->b, &paint_color->a, NULL);
gimp_pickable_srgb_to_image_color (GIMP_PICKABLE (drawable), gimp_pickable_srgb_to_image_color (GIMP_PICKABLE (drawable),
paint_color, paint_color); paint_color, paint_color);

View File

@ -169,12 +169,13 @@ gimp_ink_paint (GimpPaintCore *paint_core,
case GIMP_PAINT_STATE_INIT: case GIMP_PAINT_STATE_INIT:
{ {
GimpContext *context = GIMP_CONTEXT (paint_options); GimpContext *context = GIMP_CONTEXT (paint_options);
GimpRGB foreground; GeglColor *foreground;
GimpRGB rgb;
gimp_symmetry_set_stateful (sym, TRUE); gimp_symmetry_set_stateful (sym, TRUE);
gimp_context_get_foreground (context, &foreground); foreground = gimp_context_get_foreground (context);
gimp_palettes_add_color_history (context->gimp, gegl_color_get_pixel (foreground, babl_format_with_space ("R'G'B'A double", NULL), &rgb);
&foreground); gimp_palettes_add_color_history (context->gimp, &rgb);
if (cur_coords->x == last_coords.x && if (cur_coords->x == last_coords.x &&
cur_coords->y == last_coords.y) cur_coords->y == last_coords.y)
@ -352,7 +353,6 @@ gimp_ink_motion (GimpPaintCore *paint_core,
gint paint_buffer_x; gint paint_buffer_x;
gint paint_buffer_y; gint paint_buffer_y;
GimpLayerMode paint_mode; GimpLayerMode paint_mode;
GimpRGB foreground;
GeglColor *color; GeglColor *color;
GimpBlob *last_blob; GimpBlob *last_blob;
GimpCoords coords; GimpCoords coords;
@ -445,11 +445,8 @@ gimp_ink_motion (GimpPaintCore *paint_core,
} }
paint_mode = gimp_context_get_paint_mode (context); paint_mode = gimp_context_get_paint_mode (context);
color = gimp_context_get_foreground (context);
gimp_context_get_foreground (context, &foreground);
gimp_pickable_srgb_to_image_color (GIMP_PICKABLE (drawable),
&foreground, &foreground);
color = gimp_gegl_color_new (&foreground, gimp_drawable_get_space (drawable));
ink->blobs_to_render = blobs_to_render; ink->blobs_to_render = blobs_to_render;
for (i = 0; i < n_strokes; i++) for (i = 0; i < n_strokes; i++)
@ -494,8 +491,6 @@ gimp_ink_motion (GimpPaintCore *paint_core,
} }
g_object_unref (color);
g_list_free_full (blobs_to_render, g_free); g_list_free_full (blobs_to_render, g_free);
} }

View File

@ -204,6 +204,7 @@ gimp_mybrush_core_paint (GimpPaintCore *paint_core,
GimpContext *context = GIMP_CONTEXT (paint_options); GimpContext *context = GIMP_CONTEXT (paint_options);
gint offset_x; gint offset_x;
gint offset_y; gint offset_y;
GeglColor *color;
GimpRGB fg; GimpRGB fg;
g_return_if_fail (g_list_length (drawables) == 1); g_return_if_fail (g_list_length (drawables) == 1);
@ -211,7 +212,8 @@ gimp_mybrush_core_paint (GimpPaintCore *paint_core,
switch (paint_state) switch (paint_state)
{ {
case GIMP_PAINT_STATE_INIT: case GIMP_PAINT_STATE_INIT:
gimp_context_get_foreground (context, &fg); color = gimp_context_get_foreground (context);
gegl_color_get_rgba_with_space (color, &fg.r, &fg.g, &fg.b, &fg.a, NULL);
gimp_palettes_add_color_history (context->gimp, &fg); gimp_palettes_add_color_history (context->gimp, &fg);
gimp_symmetry_set_stateful (sym, TRUE); gimp_symmetry_set_stateful (sym, TRUE);
@ -392,6 +394,7 @@ gimp_mybrush_core_create_brushes (GimpMybrushCore *mybrush,
{ {
GimpMybrushOptions *options = GIMP_MYBRUSH_OPTIONS (paint_options); GimpMybrushOptions *options = GIMP_MYBRUSH_OPTIONS (paint_options);
GimpContext *context = GIMP_CONTEXT (paint_options); GimpContext *context = GIMP_CONTEXT (paint_options);
GeglColor *color;
GimpRGB fg; GimpRGB fg;
GimpHSV hsv; GimpHSV hsv;
gint n_strokes; gint n_strokes;
@ -405,9 +408,11 @@ gimp_mybrush_core_create_brushes (GimpMybrushCore *mybrush,
} }
if (options->eraser) if (options->eraser)
gimp_context_get_background (context, &fg); color = gimp_context_get_background (context);
else else
gimp_context_get_foreground (context, &fg); color = gimp_context_get_foreground (context);
gegl_color_get_rgba_with_space (color, &fg.r, &fg.g, &fg.b, &fg.a, NULL);
gimp_pickable_srgb_to_image_color (GIMP_PICKABLE (drawable), gimp_pickable_srgb_to_image_color (GIMP_PICKABLE (drawable),
&fg, &fg); &fg, &fg);

View File

@ -151,11 +151,12 @@ static gboolean
gimp_paintbrush_real_get_color_history_color (GimpPaintbrush *paintbrush, gimp_paintbrush_real_get_color_history_color (GimpPaintbrush *paintbrush,
GimpDrawable *drawable, GimpDrawable *drawable,
GimpPaintOptions *paint_options, GimpPaintOptions *paint_options,
GimpRGB *color) GimpRGB *rgb)
{ {
GimpContext *context = GIMP_CONTEXT (paint_options); GimpContext *context = GIMP_CONTEXT (paint_options);
GimpBrushCore *brush_core = GIMP_BRUSH_CORE (paintbrush); GimpBrushCore *brush_core = GIMP_BRUSH_CORE (paintbrush);
GimpDynamics *dynamics = gimp_context_get_dynamics (context); GimpDynamics *dynamics = gimp_context_get_dynamics (context);
GeglColor *color;
/* We don't save gradient color history and pixmap brushes /* We don't save gradient color history and pixmap brushes
* have no color to save. * have no color to save.
@ -166,7 +167,8 @@ gimp_paintbrush_real_get_color_history_color (GimpPaintbrush *paintbrush,
return FALSE; return FALSE;
} }
gimp_context_get_foreground (context, color); color = gimp_context_get_foreground (context);
gegl_color_get_rgba_with_space (color, &rgb->r, &rgb->g, &rgb->b, &rgb->a, NULL);
return TRUE; return TRUE;
} }
@ -213,7 +215,10 @@ gimp_paintbrush_real_get_paint_params (GimpPaintbrush *paintbrush,
else else
{ {
/* otherwise fill the area with the foreground color */ /* otherwise fill the area with the foreground color */
gimp_context_get_foreground (context, paint_color); GeglColor *color;
color = gimp_context_get_foreground (context);
gegl_color_get_rgba_with_space (color, &paint_color->r, &paint_color->g, &paint_color->b, &paint_color->a, NULL);
gimp_pickable_srgb_to_image_color (GIMP_PICKABLE (drawable), gimp_pickable_srgb_to_image_color (GIMP_PICKABLE (drawable),
paint_color, paint_color); paint_color, paint_color);

View File

@ -160,10 +160,12 @@ gimp_smudge_paint (GimpPaintCore *paint_core,
! gimp_dynamics_is_output_enabled (dynamics, GIMP_DYNAMICS_OUTPUT_COLOR) && ! gimp_dynamics_is_output_enabled (dynamics, GIMP_DYNAMICS_OUTPUT_COLOR) &&
! (brush_core->brush && gimp_brush_get_pixmap (brush_core->brush))) ! (brush_core->brush && gimp_brush_get_pixmap (brush_core->brush)))
{ {
GimpRGB foreground; GeglColor *foreground;
GimpRGB rgb;
gimp_context_get_foreground (context, &foreground); foreground = gimp_context_get_foreground (context);
gimp_palettes_add_color_history (context->gimp, &foreground); gegl_color_get_rgba_with_space (foreground, &rgb.r, &rgb.g, &rgb.b, &rgb.a, NULL);
gimp_palettes_add_color_history (context->gimp, &rgb);
} }
} }
break; break;
@ -453,7 +455,10 @@ gimp_smudge_motion (GimpPaintCore *paint_core,
} }
else else
{ {
gimp_context_get_foreground (context, &brush_color); GeglColor *color;
color = gimp_context_get_foreground (context);
gegl_color_get_rgba_with_space (color, &brush_color.r, &brush_color.g, &brush_color.b, &brush_color.a, NULL);
} }
/* Convert to linear RGBA */ /* Convert to linear RGBA */

View File

@ -249,13 +249,13 @@ context_get_foreground_invoker (GimpProcedure *procedure,
GError **error) GError **error)
{ {
GimpValueArray *return_vals; GimpValueArray *return_vals;
GimpRGB foreground = { 0.0, 0.0, 0.0, 1.0 }; GeglColor *foreground = NULL;
gimp_context_get_foreground (context, &foreground); foreground = gegl_color_duplicate (gimp_context_get_foreground (context));
gimp_rgb_set_alpha (&foreground, 1.0); gimp_color_set_alpha (foreground, 1.0);
return_vals = gimp_procedure_get_return_values (procedure, TRUE, NULL); return_vals = gimp_procedure_get_return_values (procedure, TRUE, NULL);
gimp_value_set_rgb (gimp_value_array_index (return_vals, 1), &foreground); g_value_take_object (gimp_value_array_index (return_vals, 1), foreground);
return return_vals; return return_vals;
} }
@ -292,13 +292,13 @@ context_get_background_invoker (GimpProcedure *procedure,
GError **error) GError **error)
{ {
GimpValueArray *return_vals; GimpValueArray *return_vals;
GimpRGB background = { 0.0, 0.0, 0.0, 1.0 }; GeglColor *background = NULL;
gimp_context_get_background (context, &background); background = gegl_color_duplicate (gimp_context_get_background (context));
gimp_rgb_set_alpha (&background, 1.0); gimp_color_set_alpha (background, 1.0);
return_vals = gimp_procedure_get_return_values (procedure, TRUE, NULL); return_vals = gimp_procedure_get_return_values (procedure, TRUE, NULL);
gimp_value_set_rgb (gimp_value_array_index (return_vals, 1), &background); g_value_take_object (gimp_value_array_index (return_vals, 1), background);
return return_vals; return return_vals;
} }
@ -3258,12 +3258,11 @@ register_context_procs (GimpPDB *pdb)
"Michael Natterer & Sven Neumann", "Michael Natterer & Sven Neumann",
"2004"); "2004");
gimp_procedure_add_return_value (procedure, gimp_procedure_add_return_value (procedure,
gimp_param_spec_rgb ("foreground", gegl_param_spec_color ("foreground",
"foreground", "foreground",
"The foreground color", "The foreground color",
FALSE, NULL,
NULL, GIMP_PARAM_READWRITE));
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure); gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure); g_object_unref (procedure);
@ -3305,12 +3304,11 @@ register_context_procs (GimpPDB *pdb)
"Michael Natterer & Sven Neumann", "Michael Natterer & Sven Neumann",
"2004"); "2004");
gimp_procedure_add_return_value (procedure, gimp_procedure_add_return_value (procedure,
gimp_param_spec_rgb ("background", gegl_param_spec_color ("background",
"background", "background",
"The background color", "The background color",
FALSE, NULL,
NULL, GIMP_PARAM_READWRITE));
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure); gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure); g_object_unref (procedure);

View File

@ -598,25 +598,27 @@ plug_in_applylens_invoker (GimpProcedure *procedure,
GIMP_PDB_ITEM_CONTENT, error) && GIMP_PDB_ITEM_CONTENT, error) &&
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error)) gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
{ {
GimpRGB color; GeglColor *color;
GeglColor *gegl_color;
GeglNode *node; GeglNode *node;
if (set_background) if (set_background)
gimp_context_get_background (context, &color); {
color = gegl_color_duplicate (gimp_context_get_background (context));
}
else else
gimp_rgba_set (&color, 0.0, 0.0, 0.0, 0.0); {
color = gegl_color_new ("black");
gegl_color = gimp_gegl_color_new (&color, NULL); gegl_color_set_rgba_with_space (color, 0.0, 0.0, 0.0, 0.0, NULL);
}
node = gegl_node_new_child (NULL, node = gegl_node_new_child (NULL,
"operation", "gegl:apply-lens", "operation", "gegl:apply-lens",
"refraction-index", refraction, "refraction-index", refraction,
"keep-surroundings", keep_surroundings, "keep-surroundings", keep_surroundings,
"background-color", gegl_color, "background-color", color,
NULL); NULL);
g_object_unref (gegl_color); g_object_unref (color);
node = wrap_in_selection_bounds (node, drawable); node = wrap_in_selection_bounds (node, drawable);
@ -1265,29 +1267,27 @@ plug_in_cubism_invoker (GimpProcedure *procedure,
GIMP_PDB_ITEM_CONTENT, error) && GIMP_PDB_ITEM_CONTENT, error) &&
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error)) gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
{ {
GimpRGB color; GeglColor *color;
GeglColor *gegl_color;
GeglNode *node; GeglNode *node;
if (bg_color) if (bg_color)
{ {
gimp_context_get_background (context, &color); color = gegl_color_duplicate (gimp_context_get_background (context));
gimp_rgb_set_alpha (&color, 0.0); gimp_color_set_alpha (color, 0.0);
} }
else else
{ {
gimp_rgba_set (&color, 0.0, 0.0, 0.0, 0.0); color = gegl_color_new ("black");
gegl_color_set_rgba_with_space (color, 0.0, 0.0, 0.0, 0.0, NULL);
} }
gegl_color = gimp_gegl_color_new (&color, NULL);
node = gegl_node_new_child (NULL, node = gegl_node_new_child (NULL,
"operation", "gegl:cubism", "operation", "gegl:cubism",
"tile-size", tile_size, "tile-size", tile_size,
"tile-saturation", tile_saturation, "tile-saturation", tile_saturation,
"bg-color", gegl_color, "bg-color", color,
NULL); NULL);
g_object_unref (gegl_color); g_object_unref (color);
gimp_drawable_apply_operation (drawable, progress, gimp_drawable_apply_operation (drawable, progress,
C_("undo-type", "Cubism"), C_("undo-type", "Cubism"),
@ -2294,21 +2294,14 @@ plug_in_lens_distortion_invoker (GimpProcedure *procedure,
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error)) gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
{ {
GeglNode *node = NULL; GeglNode *node = NULL;
GimpRGB color; GeglColor *color;
GeglColor *gegl_color;
gimp_context_get_background (context, &color); color = gegl_color_duplicate (gimp_context_get_background (context));
if (gimp_drawable_has_alpha (drawable)) if (gimp_drawable_has_alpha (drawable))
{ gimp_color_set_alpha (color, 0.0);
gimp_rgb_set_alpha (&color, 0.0);
}
else else
{ gimp_color_set_alpha (color, 1.0);
gimp_rgb_set_alpha (&color, 1.0);
}
gegl_color = gimp_gegl_color_new (&color, NULL);
node = gegl_node_new_child (NULL, node = gegl_node_new_child (NULL,
"operation", "gegl:lens-distortion", "operation", "gegl:lens-distortion",
@ -2318,10 +2311,10 @@ plug_in_lens_distortion_invoker (GimpProcedure *procedure,
"x-shift", (gdouble) offset_x, "x-shift", (gdouble) offset_x,
"y-shift", (gdouble) offset_y, "y-shift", (gdouble) offset_y,
"brighten", (gdouble) brighten, "brighten", (gdouble) brighten,
"background", gegl_color, "background", color,
NULL); NULL);
g_object_unref (gegl_color); g_object_unref (color);
node = wrap_in_selection_bounds (node, drawable); node = wrap_in_selection_bounds (node, drawable);
@ -2410,13 +2403,9 @@ plug_in_maze_invoker (GimpProcedure *procedure,
GeglNode *node; GeglNode *node;
GeglColor *fg_color; GeglColor *fg_color;
GeglColor *bg_color; GeglColor *bg_color;
GimpRGB color;
gimp_context_get_foreground (context, &color); fg_color = gimp_context_get_foreground (context);
fg_color = gimp_gegl_color_new (&color, NULL); bg_color = gimp_context_get_background (context);
gimp_context_get_background (context, &color);
bg_color = gimp_gegl_color_new (&color, NULL);
node = gegl_node_new_child (NULL, node = gegl_node_new_child (NULL,
"operation", "gegl:maze", "operation", "gegl:maze",
@ -2429,9 +2418,6 @@ plug_in_maze_invoker (GimpProcedure *procedure,
"bg-color", bg_color, "bg-color", bg_color,
NULL); NULL);
g_object_unref (fg_color);
g_object_unref (bg_color);
gimp_drawable_apply_operation (drawable, progress, gimp_drawable_apply_operation (drawable, progress,
C_("undo-type", "Maze"), C_("undo-type", "Maze"),
node); node);
@ -2708,13 +2694,8 @@ plug_in_mosaic_invoker (GimpProcedure *procedure,
if (grout_color) if (grout_color)
{ {
GimpRGB fgcolor, bgcolor; bg_color = gegl_color_duplicate (gimp_context_get_background (context));
fg_color = gegl_color_duplicate (gimp_context_get_foreground (context));
gimp_context_get_background (context, &bgcolor);
bg_color = gimp_gegl_color_new (&bgcolor, NULL);
gimp_context_get_foreground (context, &fgcolor);
fg_color = gimp_gegl_color_new (&fgcolor, NULL);
} }
else else
{ {
@ -3118,7 +3099,7 @@ plug_in_papertile_invoker (GimpProcedure *procedure,
gboolean wrap_around; gboolean wrap_around;
gboolean centering; gboolean centering;
gint background_type; gint background_type;
GimpRGB background_color; GeglColor *background_color;
drawable = g_value_get_object (gimp_value_array_index (args, 2)); drawable = g_value_get_object (gimp_value_array_index (args, 2));
tile_size = g_value_get_int (gimp_value_array_index (args, 3)); tile_size = g_value_get_int (gimp_value_array_index (args, 3));
@ -3127,7 +3108,7 @@ plug_in_papertile_invoker (GimpProcedure *procedure,
wrap_around = g_value_get_boolean (gimp_value_array_index (args, 6)); wrap_around = g_value_get_boolean (gimp_value_array_index (args, 6));
centering = g_value_get_boolean (gimp_value_array_index (args, 7)); centering = g_value_get_boolean (gimp_value_array_index (args, 7));
background_type = g_value_get_int (gimp_value_array_index (args, 8)); background_type = g_value_get_int (gimp_value_array_index (args, 8));
gimp_value_get_rgb (gimp_value_array_index (args, 9), &background_color); background_color = g_value_get_object (gimp_value_array_index (args, 9));
if (success) if (success)
{ {
@ -3136,48 +3117,49 @@ plug_in_papertile_invoker (GimpProcedure *procedure,
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error)) gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
{ {
GeglNode *node; GeglNode *node;
GimpRGB color; GeglColor *color;
GeglColor *gegl_color;
gint bg_type; gint bg_type;
switch (background_type) switch (background_type)
{ {
default: default:
bg_type = background_type; bg_type = background_type;
gimp_rgba_set (&color, 0.0, 0.0, 1.0, 1.0); color = gegl_color_new (NULL);
/* XXX: I guess what we want is to set this color (why blue?) in the
* drawable's space, though I haven't looked too much into it.
*/
gegl_color_set_rgba_with_space (color, 0.0, 0.0, 1.0, 1.0, gimp_drawable_get_space (drawable));
break; break;
case 3: case 3:
bg_type = 3; bg_type = 3;
gimp_context_get_foreground (context, &color); color = gegl_color_duplicate (gimp_context_get_foreground (context));
break; break;
case 4: case 4:
bg_type = 3; bg_type = 3;
gimp_context_get_background (context, &color); color = gegl_color_duplicate (gimp_context_get_background (context));
break; break;
case 5: case 5:
bg_type = 3; bg_type = 3;
color = background_color; color = gegl_color_duplicate (background_color);
break; break;
} }
gegl_color = gimp_gegl_color_new (&color, NULL);
node = gegl_node_new_child (NULL, node = gegl_node_new_child (NULL,
"operation", "gegl:tile-paper", "operation", "gegl:tile-paper",
"tile-width", tile_size, "tile-width", tile_size,
"tile-height", tile_size, "tile-height", tile_size,
"move-rate", move_max, "move-rate", move_max,
"bg-color", gegl_color, "bg-color", color,
"centering", centering, "centering", centering,
"wrap-around", wrap_around, "wrap-around", wrap_around,
"background-type", bg_type, "background-type", bg_type,
"fractional-type", fractional_type, "fractional-type", fractional_type,
NULL); NULL);
g_object_unref (gegl_color); g_object_unref (color);
gimp_drawable_apply_operation (drawable, progress, gimp_drawable_apply_operation (drawable, progress,
C_("undo-type", "Paper Tile"), C_("undo-type", "Paper Tile"),
@ -3963,15 +3945,17 @@ plug_in_semiflatten_invoker (GimpProcedure *procedure,
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error) && gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error) &&
gimp_drawable_has_alpha (drawable)) gimp_drawable_has_alpha (drawable))
{ {
GeglNode *node; GeglNode *node;
GimpRGB color; GeglColor *color;
GimpRGB rgb;
gimp_context_get_background (context, &color); color = gimp_context_get_background (context);
gegl_color_get_rgba_with_space (color, &rgb.r, &rgb.g, &rgb.b, &rgb.a, NULL);
node = node =
gegl_node_new_child (NULL, gegl_node_new_child (NULL,
"operation", "gimp:semi-flatten", "operation", "gimp:semi-flatten",
"color", &color, "color", &rgb,
NULL); NULL);
gimp_drawable_apply_operation (drawable, progress, gimp_drawable_apply_operation (drawable, progress,
@ -4047,8 +4031,8 @@ plug_in_sinus_invoker (GimpProcedure *procedure,
gboolean tiling; gboolean tiling;
gboolean perturb; gboolean perturb;
gint colors; gint colors;
GimpRGB col1; GeglColor *col1;
GimpRGB col2; GeglColor *col2;
gdouble alpha1; gdouble alpha1;
gdouble alpha2; gdouble alpha2;
gint blend; gint blend;
@ -4062,8 +4046,8 @@ plug_in_sinus_invoker (GimpProcedure *procedure,
tiling = g_value_get_boolean (gimp_value_array_index (args, 7)); tiling = g_value_get_boolean (gimp_value_array_index (args, 7));
perturb = g_value_get_boolean (gimp_value_array_index (args, 8)); perturb = g_value_get_boolean (gimp_value_array_index (args, 8));
colors = g_value_get_int (gimp_value_array_index (args, 9)); colors = g_value_get_int (gimp_value_array_index (args, 9));
gimp_value_get_rgb (gimp_value_array_index (args, 10), &col1); col1 = g_value_get_object (gimp_value_array_index (args, 10));
gimp_value_get_rgb (gimp_value_array_index (args, 11), &col2); col2 = g_value_get_object (gimp_value_array_index (args, 11));
alpha1 = g_value_get_double (gimp_value_array_index (args, 12)); alpha1 = g_value_get_double (gimp_value_array_index (args, 12));
alpha2 = g_value_get_double (gimp_value_array_index (args, 13)); alpha2 = g_value_get_double (gimp_value_array_index (args, 13));
blend = g_value_get_int (gimp_value_array_index (args, 14)); blend = g_value_get_int (gimp_value_array_index (args, 14));
@ -4076,28 +4060,30 @@ plug_in_sinus_invoker (GimpProcedure *procedure,
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error)) gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
{ {
GeglNode *node; GeglNode *node;
GeglColor *gegl_color1; GeglColor *gegl_color1 = NULL;
GeglColor *gegl_color2; GeglColor *gegl_color2 = NULL;
gint x, y, width, height; gint x, y, width, height;
switch (colors) switch (colors)
{ {
case 0: case 0:
gimp_rgb_set (&col1, 0.0, 0.0, 0.0); gegl_color1 = gegl_color_new ("black");
gimp_rgb_set (&col2, 1.0, 1.0, 1.0); gegl_color2 = gegl_color_new ("white");
break; break;
case 1: case 1:
gimp_context_get_foreground (context, &col1); gegl_color1 = gegl_color_duplicate (gimp_context_get_foreground (context));
gimp_context_get_background (context, &col2); gegl_color2 = gegl_color_duplicate (gimp_context_get_background (context));
break; break;
} }
gimp_rgb_set_alpha (&col1, alpha1); if (gegl_color1 == NULL)
gimp_rgb_set_alpha (&col2, alpha2); {
gegl_color1 = gegl_color_duplicate (col1);
gegl_color1 = gimp_gegl_color_new (&col1, NULL); gegl_color2 = gegl_color_duplicate (col2);
gegl_color2 = gimp_gegl_color_new (&col2, NULL); }
gimp_color_set_alpha (gegl_color1, alpha1);
gimp_color_set_alpha (gegl_color2, alpha2);
gimp_item_mask_intersect (GIMP_ITEM (drawable), &x, &y, &width, &height); gimp_item_mask_intersect (GIMP_ITEM (drawable), &x, &y, &width, &height);
@ -4536,8 +4522,7 @@ plug_in_vpropagate_invoker (GimpProcedure *procedure,
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error)) gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
{ {
GeglNode *node; GeglNode *node;
GimpRGB color; GeglColor *color = NULL;
GeglColor *gegl_color = NULL;
gint gegl_mode = 0; gint gegl_mode = 0;
gboolean to_left = (direction_mask & (0x1 << 0)) != 0; gboolean to_left = (direction_mask & (0x1 << 0)) != 0;
gboolean to_top = (direction_mask & (0x1 << 1)) != 0; gboolean to_top = (direction_mask & (0x1 << 1)) != 0;
@ -4561,16 +4546,14 @@ plug_in_vpropagate_invoker (GimpProcedure *procedure,
{ {
gegl_mode = propagate_mode; gegl_mode = propagate_mode;
gimp_context_get_foreground (context, &color); color = gimp_context_get_foreground (context);
} }
else else
{ {
gegl_mode = 4; gegl_mode = 4;
gimp_context_get_background (context, &color); color = gimp_context_get_background (context);
} }
gegl_color = gimp_gegl_color_new (&color, NULL);
break; break;
case 6: case 6:
@ -4586,7 +4569,7 @@ plug_in_vpropagate_invoker (GimpProcedure *procedure,
"lower-threshold", (gdouble) lower_limit / 255.0, "lower-threshold", (gdouble) lower_limit / 255.0,
"upper-threshold", (gdouble) upper_limit / 255.0, "upper-threshold", (gdouble) upper_limit / 255.0,
"rate", propagating_rate, "rate", propagating_rate,
"color", gegl_color, "color", color,
"top", to_top, "top", to_top,
"left", to_left, "left", to_left,
"right", to_right, "right", to_right,
@ -4595,9 +4578,6 @@ plug_in_vpropagate_invoker (GimpProcedure *procedure,
"alpha", alpha, "alpha", alpha,
NULL); NULL);
if (gegl_color)
g_object_unref (gegl_color);
gimp_drawable_apply_operation (drawable, progress, gimp_drawable_apply_operation (drawable, progress,
C_("undo-type", "Value Propagate"), C_("undo-type", "Value Propagate"),
node); node);
@ -7896,12 +7876,11 @@ register_plug_in_compat_procs (GimpPDB *pdb)
0, 5, 0, 0, 5, 0,
GIMP_PARAM_READWRITE)); GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure, gimp_procedure_add_argument (procedure,
gimp_param_spec_rgb ("background-color", gegl_param_spec_color ("background-color",
"background color", "background color",
"Background color (for background-type == 5)", "Background color (for background-type == 5)",
FALSE, NULL,
NULL, GIMP_PARAM_READWRITE));
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure, gimp_procedure_add_argument (procedure,
g_param_spec_int ("background-alpha", g_param_spec_int ("background-alpha",
"background alpha", "background alpha",
@ -8870,19 +8849,17 @@ register_plug_in_compat_procs (GimpPDB *pdb)
0, 2, 0, 0, 2, 0,
GIMP_PARAM_READWRITE)); GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure, gimp_procedure_add_argument (procedure,
gimp_param_spec_rgb ("col1", gegl_param_spec_color ("col1",
"col1", "col1",
"fist color (sometimes unused)", "fist color (sometimes unused)",
FALSE, NULL,
NULL, GIMP_PARAM_READWRITE));
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure, gimp_procedure_add_argument (procedure,
gimp_param_spec_rgb ("col2", gegl_param_spec_color ("col2",
"col2", "col2",
"second color (sometimes unused)", "second color (sometimes unused)",
FALSE, NULL,
NULL, GIMP_PARAM_READWRITE));
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure, gimp_procedure_add_argument (procedure,
g_param_spec_double ("alpha1", g_param_spec_double ("alpha1",
"alpha1", "alpha1",

View File

@ -76,20 +76,23 @@ text_layer_new_invoker (GimpProcedure *procedure,
if (success) if (success)
{ {
GimpText *gimp_text; GimpText *gimp_text;
GimpRGB color; GeglColor *color;
GimpRGB rgb;
gimp_context_get_foreground (context, &color); color = gimp_context_get_foreground (context);
gegl_color_get_pixel (color, babl_format ("R'G'B'A double"), &rgb);
gimp_text = g_object_new (GIMP_TYPE_TEXT, gimp_text = g_object_new (GIMP_TYPE_TEXT,
"text", text, "text", text,
"font", font, "font", font,
"font-size", size, "font-size", size,
"font-size-unit", unit, "font-size-unit", unit,
"color", &color, "color", &rgb,
NULL); NULL);
layer = GIMP_TEXT_LAYER (gimp_text_layer_new (image, gimp_text)); layer = GIMP_TEXT_LAYER (gimp_text_layer_new (image, gimp_text));
g_object_unref (color);
g_object_unref (gimp_text); g_object_unref (gimp_text);
if (! layer) if (! layer)

View File

@ -60,7 +60,8 @@ text_render (GimpImage *image,
{ {
GimpText *gtext; GimpText *gtext;
GimpLayer *layer; GimpLayer *layer;
GimpRGB color; GeglColor *color;
GimpRGB rgb;
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 (drawable == NULL || GIMP_IS_DRAWABLE (drawable), NULL); g_return_val_if_fail (drawable == NULL || GIMP_IS_DRAWABLE (drawable), NULL);
@ -76,7 +77,8 @@ text_render (GimpImage *image,
if (border < 0) if (border < 0)
border = 0; border = 0;
gimp_context_get_foreground (context, &color); color = gimp_context_get_foreground (context);
gegl_color_get_pixel (color, babl_format ("R'G'B'A double"), &rgb);
gtext = g_object_new (GIMP_TYPE_TEXT, gtext = g_object_new (GIMP_TYPE_TEXT,
"text", text, "text", text,
@ -84,7 +86,7 @@ text_render (GimpImage *image,
"font-size", font_size, "font-size", font_size,
"antialias", antialias, "antialias", antialias,
"border", border, "border", border,
"color", &color, "color", &rgb,
NULL); NULL);
layer = gimp_text_layer_new (image, gtext); layer = gimp_text_layer_new (image, gtext);

View File

@ -494,19 +494,18 @@ gimp_operation_tool_sync_op (GimpOperationTool *op_tool,
} }
else if (sync_colors) else if (sync_colors)
{ {
GeglColor *color = NULL;
GimpRGB rgb;
if (HAS_KEY (pspec, "role", "color-primary")) if (HAS_KEY (pspec, "role", "color-primary"))
{ color = gimp_context_get_foreground (GIMP_CONTEXT (options));
GimpRGB color;
gimp_context_get_foreground (GIMP_CONTEXT (options), &color);
g_object_set (filter_tool->config, pspec->name, &color, NULL);
}
else if (sync_colors && HAS_KEY (pspec, "role", "color-secondary")) else if (sync_colors && HAS_KEY (pspec, "role", "color-secondary"))
{ color = gimp_context_get_background (GIMP_CONTEXT (options));
GimpRGB color;
gimp_context_get_background (GIMP_CONTEXT (options), &color); if (color != NULL)
g_object_set (filter_tool->config, pspec->name, &color, NULL); {
gegl_color_get_rgba_with_space (color, &rgb.r, &rgb.g, &rgb.b, &rgb.a, NULL);
g_object_set (filter_tool->config, pspec->name, &rgb, NULL);
} }
} }
} }

View File

@ -683,15 +683,17 @@ gimp_text_options_notify_color (GimpContext *context,
GParamSpec *pspec, GParamSpec *pspec,
GimpText *text) GimpText *text)
{ {
GimpRGB color; GeglColor *color;
GimpRGB rgb;
gimp_context_get_foreground (context, &color); color = gimp_context_get_foreground (context);
gegl_color_get_pixel (color, babl_format ("R'G'B'A double"), &rgb);
g_signal_handlers_block_by_func (text, g_signal_handlers_block_by_func (text,
gimp_text_options_notify_text_color, gimp_text_options_notify_text_color,
context); context);
g_object_set (text, "color", &color, NULL); g_object_set (text, "color", &rgb, NULL);
g_signal_handlers_unblock_by_func (text, g_signal_handlers_unblock_by_func (text,
gimp_text_options_notify_text_color, gimp_text_options_notify_text_color,
@ -725,19 +727,21 @@ gimp_text_options_connect_text (GimpTextOptions *options,
GimpText *text) GimpText *text)
{ {
GimpContext *context; GimpContext *context;
GimpRGB color; GeglColor *color;
GimpRGB rgb;
g_return_if_fail (GIMP_IS_TEXT_OPTIONS (options)); g_return_if_fail (GIMP_IS_TEXT_OPTIONS (options));
g_return_if_fail (GIMP_IS_TEXT (text)); g_return_if_fail (GIMP_IS_TEXT (text));
context = GIMP_CONTEXT (options); context = GIMP_CONTEXT (options);
gimp_context_get_foreground (context, &color); color = gimp_context_get_foreground (context);
gegl_color_get_pixel (color, babl_format ("R'G'B'A double"), &rgb);
gimp_config_sync (G_OBJECT (options), G_OBJECT (text), 0); gimp_config_sync (G_OBJECT (options), G_OBJECT (text), 0);
g_object_set (text, g_object_set (text,
"color", &color, "color", &rgb,
"font", gimp_context_get_font (context), "font", gimp_context_get_font (context),
NULL); NULL);
@ -851,8 +855,8 @@ gimp_text_options_gui (GimpToolOptions *tool_options)
button, 1); button, 1);
gtk_size_group_add_widget (size_group, button); gtk_size_group_add_widget (size_group, button);
button = gimp_prop_color_button_new (config, "foreground", _("Text Color"), button = gimp_prop_gegl_color_button_new (config, "foreground", _("Text Color"),
40, 24, GIMP_COLOR_AREA_FLAT); 40, 24, GIMP_COLOR_AREA_FLAT);
gimp_color_button_set_update (GIMP_COLOR_BUTTON (button), TRUE); gimp_color_button_set_update (GIMP_COLOR_BUTTON (button), TRUE);
gimp_color_panel_set_context (GIMP_COLOR_PANEL (button), gimp_color_panel_set_context (GIMP_COLOR_PANEL (button),
GIMP_CONTEXT (options)); GIMP_CONTEXT (options));

View File

@ -609,11 +609,13 @@ gimp_color_dialog_colormap_add_activate (GimpColorDialog *dialog)
viewable_dialog->context) viewable_dialog->context)
{ {
GimpContext *user_context = viewable_dialog->context->gimp->user_context; GimpContext *user_context = viewable_dialog->context->gimp->user_context;
GimpRGB color; GeglColor *color;
GimpRGB rgb;
gimp_context_get_foreground (user_context, &color); color = gimp_context_get_foreground (user_context);
gegl_color_get_rgba_with_space (color, &rgb.r, &rgb.g, &rgb.b, &rgb.a, NULL);
gimp_image_add_colormap_entry (dialog->active_image, &color); gimp_image_add_colormap_entry (dialog->active_image, &rgb);
gimp_image_flush (dialog->active_image); gimp_image_flush (dialog->active_image);
} }
} }

View File

@ -78,10 +78,10 @@ static void gimp_color_editor_set_context (GimpDocked *docked,
GimpContext *context); GimpContext *context);
static void gimp_color_editor_fg_changed (GimpContext *context, static void gimp_color_editor_fg_changed (GimpContext *context,
const GimpRGB *rgb, GeglColor *color,
GimpColorEditor *editor); GimpColorEditor *editor);
static void gimp_color_editor_bg_changed (GimpContext *context, static void gimp_color_editor_bg_changed (GimpContext *context,
const GimpRGB *rgb, GeglColor *color,
GimpColorEditor *editor); GimpColorEditor *editor);
static void gimp_color_editor_color_changed (GimpColorSelector *selector, static void gimp_color_editor_color_changed (GimpColorSelector *selector,
const GimpRGB *rgb, const GimpRGB *rgb,
@ -455,7 +455,7 @@ gimp_color_editor_set_context (GimpDocked *docked,
if (editor->context) if (editor->context)
{ {
GimpRGB rgb; GeglColor *color;
g_object_ref (editor->context); g_object_ref (editor->context);
@ -481,13 +481,13 @@ gimp_color_editor_set_context (GimpDocked *docked,
if (editor->edit_bg) if (editor->edit_bg)
{ {
gimp_context_get_background (editor->context, &rgb); color = gimp_context_get_background (editor->context);
gimp_color_editor_bg_changed (editor->context, &rgb, editor); gimp_color_editor_bg_changed (editor->context, color, editor);
} }
else else
{ {
gimp_context_get_foreground (editor->context, &rgb); color = gimp_context_get_foreground (editor->context);
gimp_color_editor_fg_changed (editor->context, &rgb, editor); gimp_color_editor_fg_changed (editor->context, color, editor);
} }
g_object_set_data (G_OBJECT (context->gimp->config->color_management), g_object_set_data (G_OBJECT (context->gimp->config->color_management),
@ -536,18 +536,20 @@ gimp_color_editor_style_updated (GtkWidget *widget)
static void static void
gimp_color_editor_set_color (GimpColorEditor *editor, gimp_color_editor_set_color (GimpColorEditor *editor,
const GimpRGB *rgb) GeglColor *color)
{ {
GimpRGB rgb;
GimpHSV hsv; GimpHSV hsv;
gimp_rgb_to_hsv (rgb, &hsv); gegl_color_get_pixel (color, babl_format ("R'G'B'A double"), &rgb);
gimp_rgb_to_hsv (&rgb, &hsv);
g_signal_handlers_block_by_func (editor->notebook, g_signal_handlers_block_by_func (editor->notebook,
gimp_color_editor_color_changed, gimp_color_editor_color_changed,
editor); editor);
gimp_color_selector_set_color (GIMP_COLOR_SELECTOR (editor->notebook), gimp_color_selector_set_color (GIMP_COLOR_SELECTOR (editor->notebook),
rgb, &hsv); &rgb, &hsv);
g_signal_handlers_unblock_by_func (editor->notebook, g_signal_handlers_unblock_by_func (editor->notebook,
gimp_color_editor_color_changed, gimp_color_editor_color_changed,
@ -558,7 +560,7 @@ gimp_color_editor_set_color (GimpColorEditor *editor,
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),
rgb); &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,
@ -567,20 +569,20 @@ gimp_color_editor_set_color (GimpColorEditor *editor,
static void static void
gimp_color_editor_fg_changed (GimpContext *context, gimp_color_editor_fg_changed (GimpContext *context,
const GimpRGB *rgb, GeglColor *color,
GimpColorEditor *editor) GimpColorEditor *editor)
{ {
if (! editor->edit_bg) if (! editor->edit_bg)
gimp_color_editor_set_color (editor, rgb); gimp_color_editor_set_color (editor, color);
} }
static void static void
gimp_color_editor_bg_changed (GimpContext *context, gimp_color_editor_bg_changed (GimpContext *context,
const GimpRGB *rgb, GeglColor *color,
GimpColorEditor *editor) GimpColorEditor *editor)
{ {
if (editor->edit_bg) if (editor->edit_bg)
gimp_color_editor_set_color (editor, rgb); gimp_color_editor_set_color (editor, color);
} }
static void static void
@ -675,17 +677,17 @@ gimp_color_editor_fg_bg_notify (GtkWidget *widget,
if (editor->context) if (editor->context)
{ {
GimpRGB rgb; GeglColor *color;
if (edit_bg) if (edit_bg)
{ {
gimp_context_get_background (editor->context, &rgb); color = gimp_context_get_background (editor->context);
gimp_color_editor_bg_changed (editor->context, &rgb, editor); gimp_color_editor_bg_changed (editor->context, color, editor);
} }
else else
{ {
gimp_context_get_foreground (editor->context, &rgb); color = gimp_context_get_foreground (editor->context);
gimp_color_editor_fg_changed (editor->context, &rgb, editor); gimp_color_editor_fg_changed (editor->context, color, editor);
} }
} }
} }

View File

@ -129,7 +129,7 @@ gimp_color_panel_button_press (GtkWidget *widget,
GimpColorPanel *color_panel; GimpColorPanel *color_panel;
GSimpleActionGroup *group; GSimpleActionGroup *group;
GimpAction *action; GimpAction *action;
GimpRGB color; GimpRGB rgb;
color_button = GIMP_COLOR_BUTTON (widget); color_button = GIMP_COLOR_BUTTON (widget);
color_panel = GIMP_COLOR_PANEL (widget); color_panel = GIMP_COLOR_PANEL (widget);
@ -144,22 +144,26 @@ gimp_color_panel_button_press (GtkWidget *widget,
if (color_panel->context) if (color_panel->context)
{ {
GeglColor *color;
action = GIMP_ACTION (g_action_map_lookup_action (G_ACTION_MAP (group), "use-foreground")); action = GIMP_ACTION (g_action_map_lookup_action (G_ACTION_MAP (group), "use-foreground"));
gimp_context_get_foreground (color_panel->context, &color); color = gimp_context_get_foreground (color_panel->context);
g_object_set (action, "color", &color, NULL); gegl_color_get_rgba_with_space (color, &rgb.r, &rgb.g, &rgb.b, &rgb.a, NULL);
g_object_set (action, "color", &rgb, NULL);
action = GIMP_ACTION (g_action_map_lookup_action (G_ACTION_MAP (group), "use-background")); action = GIMP_ACTION (g_action_map_lookup_action (G_ACTION_MAP (group), "use-background"));
gimp_context_get_background (color_panel->context, &color); color = gegl_color_duplicate (gimp_context_get_background (color_panel->context));
g_object_set (action, "color", &color, NULL); gegl_color_get_rgba_with_space (color, &rgb.r, &rgb.g, &rgb.b, &rgb.a, NULL);
g_object_set (action, "color", &rgb, NULL);
} }
action = GIMP_ACTION (g_action_map_lookup_action (G_ACTION_MAP (group), "use-black")); action = GIMP_ACTION (g_action_map_lookup_action (G_ACTION_MAP (group), "use-black"));
gimp_rgba_set (&color, 0.0, 0.0, 0.0, GIMP_OPACITY_OPAQUE); gimp_rgba_set (&rgb, 0.0, 0.0, 0.0, GIMP_OPACITY_OPAQUE);
g_object_set (action, "color", &color, NULL); g_object_set (action, "color", &rgb, NULL);
action = GIMP_ACTION (g_action_map_lookup_action (G_ACTION_MAP (group), "use-white")); action = GIMP_ACTION (g_action_map_lookup_action (G_ACTION_MAP (group), "use-white"));
gimp_rgba_set (&color, 1.0, 1.0, 1.0, GIMP_OPACITY_OPAQUE); gimp_rgba_set (&rgb, 1.0, 1.0, 1.0, GIMP_OPACITY_OPAQUE);
g_object_set (action, "color", &color, NULL); g_object_set (action, "color", &rgb, NULL);
} }
if (GTK_WIDGET_CLASS (parent_class)->button_press_event) if (GTK_WIDGET_CLASS (parent_class)->button_press_event)

View File

@ -551,18 +551,19 @@ gimp_device_status_notify_info (GimpDeviceInfo *device_info,
if (! strcmp (pspec->name, "tool-options")) if (! strcmp (pspec->name, "tool-options"))
{ {
GimpRGB color; GeglColor *color;
guchar r, g, b; guchar rgb[3];
gchar buf[64]; gchar buf[64];
gimp_context_get_foreground (entry->context, &color); color = gimp_context_get_foreground (entry->context);
gimp_rgb_get_uchar (&color, &r, &g, &b); /* TODO: which space to use exactly to provide more useful info? */
g_snprintf (buf, sizeof (buf), _("Foreground: %d, %d, %d"), r, g, b); gegl_color_get_pixel (color, babl_format_with_space ("R'G'B' u8", NULL), rgb);
g_snprintf (buf, sizeof (buf), _("Foreground: %d, %d, %d"), rgb[0], rgb[1], rgb[2]);
gimp_help_set_help_data (entry->foreground, buf, NULL); gimp_help_set_help_data (entry->foreground, buf, NULL);
gimp_context_get_background (entry->context, &color); color = gimp_context_get_background (entry->context);
gimp_rgb_get_uchar (&color, &r, &g, &b); gegl_color_get_pixel (color, babl_format_with_space ("R'G'B' u8", NULL), rgb);
g_snprintf (buf, sizeof (buf), _("Background: %d, %d, %d"), r, g, b); g_snprintf (buf, sizeof (buf), _("Background: %d, %d, %d"), rgb[0], rgb[1], rgb[2]);
gimp_help_set_help_data (entry->background, buf, NULL); gimp_help_set_help_data (entry->background, buf, NULL);
} }
} }

View File

@ -347,7 +347,6 @@ gimp_fg_bg_editor_draw (GtkWidget *widget,
gint width, height; gint width, height;
gint default_w, default_h; gint default_w, default_h;
gint swap_w, swap_h; gint swap_w, swap_h;
GimpRGB color;
gtk_style_context_save (style); gtk_style_context_save (style);
@ -435,20 +434,25 @@ gimp_fg_bg_editor_draw (GtkWidget *widget,
if (editor->context) if (editor->context)
{ {
GeglColor *color;
GimpRGB rgb;
/* draw the background frame */ /* draw the background frame */
gimp_context_get_background (editor->context, &color); color = gimp_context_get_background (editor->context);
gegl_color_get_rgba_with_space (color, &rgb.r, &rgb.g, &rgb.b, &rgb.a, NULL);
rect.x = width - rect.width - border.right; rect.x = width - rect.width - border.right;
rect.y = height - rect.height - border.bottom; rect.y = height - rect.height - border.bottom;
gimp_fg_bg_editor_draw_color_frame (editor, cr, &color, gimp_fg_bg_editor_draw_color_frame (editor, cr, &rgb,
rect.x, rect.y, rect.x, rect.y,
rect.width, rect.height, rect.width, rect.height,
-1, -1); -1, -1);
/* draw the foreground frame */ /* draw the foreground frame */
gimp_context_get_foreground (editor->context, &color); color = gimp_context_get_foreground (editor->context);
gegl_color_get_rgba_with_space (color, &rgb.r, &rgb.g, &rgb.b, &rgb.a, NULL);
rect.x = border.left; rect.x = border.left;
rect.y = border.top; rect.y = border.top;
gimp_fg_bg_editor_draw_color_frame (editor, cr, &color, gimp_fg_bg_editor_draw_color_frame (editor, cr, &rgb,
rect.x, rect.y, rect.x, rect.y,
rect.width, rect.height, rect.width, rect.height,
+1, +1); +1, +1);
@ -742,24 +746,28 @@ gimp_fg_bg_editor_set_active (GimpFgBgEditor *editor,
static void static void
gimp_fg_bg_editor_drag_color (GtkWidget *widget, gimp_fg_bg_editor_drag_color (GtkWidget *widget,
GimpRGB *color, GimpRGB *rgb,
gpointer data) gpointer data)
{ {
GimpFgBgEditor *editor = GIMP_FG_BG_EDITOR (widget); GimpFgBgEditor *editor = GIMP_FG_BG_EDITOR (widget);
GeglColor *color = NULL;
if (editor->context) if (editor->context)
{ {
switch (editor->active_color) switch (editor->active_color)
{ {
case GIMP_ACTIVE_COLOR_FOREGROUND: case GIMP_ACTIVE_COLOR_FOREGROUND:
gimp_context_get_foreground (editor->context, color); color = gimp_context_get_foreground (editor->context);
break; break;
case GIMP_ACTIVE_COLOR_BACKGROUND: case GIMP_ACTIVE_COLOR_BACKGROUND:
gimp_context_get_background (editor->context, color); color = gimp_context_get_background (editor->context);
break; break;
} }
} }
if (color != NULL)
gegl_color_get_rgba_with_space (color, &rgb->r, &rgb->g, &rgb->b, &rgb->a, NULL);
} }
static void static void

View File

@ -161,7 +161,8 @@ gimp_fg_bg_view_draw (GtkWidget *widget,
GtkBorder border; GtkBorder border;
GtkBorder padding; GtkBorder padding;
GdkRectangle rect; GdkRectangle rect;
GimpRGB color; GeglColor *color;
GimpRGB rgb;
gtk_widget_get_allocation (widget, &allocation); gtk_widget_get_allocation (widget, &allocation);
@ -190,17 +191,18 @@ gimp_fg_bg_view_draw (GtkWidget *widget,
if (view->context) if (view->context)
{ {
gimp_context_get_background (view->context, &color); color = gimp_context_get_background (view->context);
gegl_color_get_rgba_with_space (color, &rgb.r, &rgb.g, &rgb.b, &rgb.a, NULL);
if (view->transform) if (view->transform)
gimp_color_transform_process_pixels (view->transform, gimp_color_transform_process_pixels (view->transform,
babl_format ("R'G'B'A double"), babl_format ("R'G'B'A double"),
&color, &rgb,
babl_format ("R'G'B'A double"), babl_format ("R'G'B'A double"),
&color, &rgb,
1); 1);
gimp_cairo_set_source_rgb (cr, &color); gimp_cairo_set_source_rgb (cr, &rgb);
cairo_rectangle (cr, rect.x, rect.y, rect.width, rect.height); cairo_rectangle (cr, rect.x, rect.y, rect.width, rect.height);
cairo_fill (cr); cairo_fill (cr);
@ -217,17 +219,18 @@ gimp_fg_bg_view_draw (GtkWidget *widget,
if (view->context) if (view->context)
{ {
gimp_context_get_foreground (view->context, &color); color = gimp_context_get_foreground (view->context);
gegl_color_get_rgba_with_space (color, &rgb.r, &rgb.g, &rgb.b, &rgb.a, NULL);
if (view->transform) if (view->transform)
gimp_color_transform_process_pixels (view->transform, gimp_color_transform_process_pixels (view->transform,
babl_format ("R'G'B'A double"), babl_format ("R'G'B'A double"),
&color, &rgb,
babl_format ("R'G'B'A double"), babl_format ("R'G'B'A double"),
&color, &rgb,
1); 1);
gimp_cairo_set_source_rgb (cr, &color); gimp_cairo_set_source_rgb (cr, &rgb);
cairo_rectangle (cr, rect.x, rect.y, rect.width, rect.height); cairo_rectangle (cr, rect.x, rect.y, rect.width, rect.height);
cairo_fill (cr); cairo_fill (cr);

View File

@ -137,11 +137,11 @@ gimp_fill_editor_constructed (GObject *object)
if (editor->use_custom_style) if (editor->use_custom_style)
{ {
color_button = gimp_prop_color_button_new (G_OBJECT (editor->options), color_button = gimp_prop_gegl_color_button_new (G_OBJECT (editor->options),
"foreground", "foreground",
_("Fill Color"), _("Fill Color"),
1, 24, 1, 24,
GIMP_COLOR_AREA_SMALL_CHECKS); GIMP_COLOR_AREA_SMALL_CHECKS);
gimp_color_panel_set_context (GIMP_COLOR_PANEL (color_button), gimp_color_panel_set_context (GIMP_COLOR_PANEL (color_button),
GIMP_CONTEXT (editor->options)); GIMP_CONTEXT (editor->options));
gimp_enum_radio_box_add (GTK_BOX (box), color_button, gimp_enum_radio_box_add (GTK_BOX (box), color_button,
@ -149,21 +149,21 @@ gimp_fill_editor_constructed (GObject *object)
} }
else else
{ {
color_button = gimp_prop_color_button_new (G_OBJECT (editor->options), color_button = gimp_prop_gegl_color_button_new (G_OBJECT (editor->options),
"foreground", "foreground",
_("Fill Color"), _("Fill Color"),
1, 24, 1, 24,
GIMP_COLOR_AREA_SMALL_CHECKS); GIMP_COLOR_AREA_SMALL_CHECKS);
gimp_color_panel_set_context (GIMP_COLOR_PANEL (color_button), gimp_color_panel_set_context (GIMP_COLOR_PANEL (color_button),
GIMP_CONTEXT (editor->options)); GIMP_CONTEXT (editor->options));
gimp_enum_radio_box_add (GTK_BOX (box), color_button, gimp_enum_radio_box_add (GTK_BOX (box), color_button,
GIMP_FILL_STYLE_FG_COLOR, FALSE); GIMP_FILL_STYLE_FG_COLOR, FALSE);
color_button = gimp_prop_color_button_new (G_OBJECT (editor->options), color_button = gimp_prop_gegl_color_button_new (G_OBJECT (editor->options),
"background", "background",
_("Fill BG Color"), _("Fill BG Color"),
1, 24, 1, 24,
GIMP_COLOR_AREA_SMALL_CHECKS); GIMP_COLOR_AREA_SMALL_CHECKS);
gimp_color_panel_set_context (GIMP_COLOR_PANEL (color_button), gimp_color_panel_set_context (GIMP_COLOR_PANEL (color_button),
GIMP_CONTEXT (editor->options)); GIMP_CONTEXT (editor->options));
gimp_enum_radio_box_add (GTK_BOX (box), color_button, gimp_enum_radio_box_add (GTK_BOX (box), color_button,

View File

@ -337,11 +337,16 @@ gimp_prop_layer_mode_box_new (GObject *config,
/* color button */ /* color button */
/******************/ /******************/
static void gimp_prop_color_button_callback (GtkWidget *widget, static void gimp_prop_color_button_callback (GtkWidget *widget,
GObject *config); GObject *config);
static void gimp_prop_color_button_notify (GObject *config, static void gimp_prop_color_button_notify (GObject *config,
GParamSpec *param_spec, GParamSpec *param_spec,
GtkWidget *button); GtkWidget *button);
static void gimp_prop_gegl_color_button_callback (GtkWidget *widget,
GObject *config);
static void gimp_prop_gegl_color_button_notify (GObject *config,
GParamSpec *param_spec,
GtkWidget *button);
/** /**
* gimp_prop_color_button_new: * gimp_prop_color_button_new:
@ -404,6 +409,73 @@ gimp_prop_color_button_new (GObject *config,
return button; return button;
} }
/**
* gimp_prop_gegl_color_button_new:
* @config: #GimpConfig object to which property is attached.
* @property_name: Name of #GeglColor property.
* @title: Title of the #GimpColorPanel that is to be created
* @width: Width of color button.
* @height: Height of color button.
* @type: How transparency is represented.
*
* Creates a #GimpColorPanel to set and display the value of a #GimpRGB
* property. Pressing the button brings up a color selector dialog.
* If @title is %NULL, the @property_name's nick will be used as label
* of the returned widget.
*
* TODO: this is meant to replace completely gimp_prop_color_button_new().
*
* Returns: A new #GimpColorPanel widget.
*
* Since GIMP 2.4
*/
GtkWidget *
gimp_prop_gegl_color_button_new (GObject *config,
const gchar *property_name,
const gchar *title,
gint width,
gint height,
GimpColorAreaType type)
{
GParamSpec *param_spec;
GtkWidget *button;
GeglColor *color = NULL;
GimpRGB value;
param_spec = check_param_spec_w (config, property_name,
GEGL_TYPE_PARAM_COLOR, G_STRFUNC);
if (! param_spec)
return NULL;
if (! title)
title = g_param_spec_get_nick (param_spec);
g_object_get (config,
property_name, &color,
NULL);
if (color != NULL)
gegl_color_get_pixel (color, babl_format ("R'G'B'A double"), &value);
button = gimp_color_panel_new (title, &value, type, width, height);
g_clear_object (&color);
set_param_spec (G_OBJECT (button), button, param_spec);
g_signal_connect (button, "color-changed",
G_CALLBACK (gimp_prop_gegl_color_button_callback),
config);
connect_notify (config, property_name,
G_CALLBACK (gimp_prop_gegl_color_button_notify),
button);
gimp_widget_set_bound_property (button, config, property_name);
gtk_widget_show (button);
return button;
}
static void static void
gimp_prop_color_button_callback (GtkWidget *button, gimp_prop_color_button_callback (GtkWidget *button,
GObject *config) GObject *config)
@ -454,6 +526,63 @@ gimp_prop_color_button_notify (GObject *config,
config); config);
} }
static void
gimp_prop_gegl_color_button_callback (GtkWidget *button,
GObject *config)
{
GParamSpec *param_spec;
GeglColor *color;
GimpRGB value;
param_spec = get_param_spec (G_OBJECT (button));
if (! param_spec)
return;
gimp_color_button_get_color (GIMP_COLOR_BUTTON (button), &value);
color = gegl_color_new (NULL);
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), &value);
g_signal_handlers_block_by_func (config,
gimp_prop_color_button_notify,
button);
g_object_set (config,
param_spec->name, color,
NULL);
g_signal_handlers_unblock_by_func (config,
gimp_prop_color_button_notify,
button);
g_object_unref (color);
}
static void
gimp_prop_gegl_color_button_notify (GObject *config,
GParamSpec *param_spec,
GtkWidget *button)
{
GeglColor *color;
GimpRGB value;
g_object_get (config,
param_spec->name, &color,
NULL);
g_signal_handlers_block_by_func (button,
gimp_prop_color_button_callback,
config);
gegl_color_get_pixel (color, babl_format ("R'G'B'A double"), &value);
gimp_color_button_set_color (GIMP_COLOR_BUTTON (button), &value);
g_clear_object (&color);
g_signal_handlers_unblock_by_func (button,
gimp_prop_color_button_callback,
config);
}
/************/ /************/
/* angles */ /* angles */

View File

@ -54,6 +54,15 @@ GtkWidget * gimp_prop_color_button_new (GObject *config,
gint height, gint height,
GimpColorAreaType type); GimpColorAreaType type);
/* GeglParamColor */
GtkWidget * gimp_prop_gegl_color_button_new (GObject *config,
const gchar *property_name,
const gchar *title,
gint width,
gint height,
GimpColorAreaType type);
/* GParamDouble */ /* GParamDouble */

View File

@ -46,10 +46,10 @@
/* local function prototypes */ /* local function prototypes */
static void color_area_foreground_changed (GimpContext *context, static void color_area_foreground_changed (GimpContext *context,
const GimpRGB *color, GeglColor *color,
GimpColorDialog *dialog); GimpColorDialog *dialog);
static void color_area_background_changed (GimpContext *context, static void color_area_background_changed (GimpContext *context,
const GimpRGB *color, GeglColor *color,
GimpColorDialog *dialog); GimpColorDialog *dialog);
static void color_area_dialog_update (GimpColorDialog *dialog, static void color_area_dialog_update (GimpColorDialog *dialog,
@ -122,18 +122,21 @@ gimp_toolbox_color_area_create (GimpToolbox *toolbox,
static void static void
color_area_foreground_changed (GimpContext *context, color_area_foreground_changed (GimpContext *context,
const GimpRGB *color, GeglColor *color,
GimpColorDialog *dialog) GimpColorDialog *dialog)
{ {
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,
@ -143,18 +146,21 @@ color_area_foreground_changed (GimpContext *context,
static void static void
color_area_background_changed (GimpContext *context, color_area_background_changed (GimpContext *context,
const GimpRGB *color, GeglColor *color,
GimpColorDialog *dialog) GimpColorDialog *dialog)
{ {
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,
@ -227,23 +233,28 @@ color_area_color_clicked (GimpFgBgEditor *editor,
GimpActiveColor active_color, GimpActiveColor active_color,
GimpContext *context) GimpContext *context)
{ {
GimpRGB color; GeglColor *color;
GimpRGB rgb;
const gchar *title; const gchar *title;
if (! color_dialog_active) if (! color_dialog_active)
{ {
gimp_context_get_foreground (context, &revert_fg); color = gimp_context_get_foreground (context);
gimp_context_get_background (context, &revert_bg); gegl_color_get_rgba_with_space (color, &revert_fg.r, &revert_fg.g, &revert_fg.b, &revert_fg.a, NULL);
color = gimp_context_get_background (context);
gegl_color_get_rgba_with_space (color, &revert_bg.r, &revert_bg.g, &revert_bg.b, &revert_bg.a, NULL);
} }
if (active_color == GIMP_ACTIVE_COLOR_FOREGROUND) if (active_color == GIMP_ACTIVE_COLOR_FOREGROUND)
{ {
gimp_context_get_foreground (context, &color); color = gimp_context_get_foreground (context);
gegl_color_get_rgba_with_space (color, &rgb.r, &rgb.g, &rgb.b, &rgb.a, NULL);
title = _("Change Foreground Color"); title = _("Change Foreground Color");
} }
else else
{ {
gimp_context_get_background (context, &color); color = gimp_context_get_background (context);
gegl_color_get_rgba_with_space (color, &rgb.r, &rgb.g, &rgb.b, &rgb.a, NULL);
title = _("Change Background Color"); title = _("Change Background Color");
} }
@ -256,7 +267,7 @@ color_area_color_clicked (GimpFgBgEditor *editor,
GTK_WIDGET (editor), GTK_WIDGET (editor),
gimp_dialog_factory_get_singleton (), gimp_dialog_factory_get_singleton (),
"gimp-toolbox-color-dialog", "gimp-toolbox-color-dialog",
&color, &rgb,
TRUE, FALSE); TRUE, FALSE);
g_signal_connect_object (color_dialog, "update", g_signal_connect_object (color_dialog, "update",
@ -279,7 +290,7 @@ color_area_color_clicked (GimpFgBgEditor *editor,
} }
gtk_window_set_title (GTK_WINDOW (color_dialog), title); gtk_window_set_title (GTK_WINDOW (color_dialog), title);
gimp_color_dialog_set_color (GIMP_COLOR_DIALOG (color_dialog), &color); gimp_color_dialog_set_color (GIMP_COLOR_DIALOG (color_dialog), &rgb);
gtk_window_present (GTK_WINDOW (color_dialog)); gtk_window_present (GTK_WINDOW (color_dialog));
color_dialog_active = TRUE; color_dialog_active = TRUE;

View File

@ -69,7 +69,7 @@ gimp_view_renderer_gradient_init (GimpViewRendererGradient *renderer)
static void static void
gimp_view_renderer_gradient_fg_bg_changed (GimpContext *context, gimp_view_renderer_gradient_fg_bg_changed (GimpContext *context,
const GimpRGB *color, GeglColor *color,
GimpViewRenderer *renderer) GimpViewRenderer *renderer)
{ {
#if 0 #if 0

View File

@ -328,7 +328,6 @@ gimp_context_set_stroke_method (GimpStrokeMethod stroke_method)
/** /**
* gimp_context_get_foreground: * gimp_context_get_foreground:
* @foreground: (out caller-allocates): The foreground color.
* *
* Get the current GIMP foreground color. * Get the current GIMP foreground color.
* *
@ -336,16 +335,16 @@ gimp_context_set_stroke_method (GimpStrokeMethod stroke_method)
* used in a variety of tools such as paint tools, blending, and bucket * used in a variety of tools such as paint tools, blending, and bucket
* fill. * fill.
* *
* Returns: TRUE on success. * Returns: (transfer full): The foreground color.
* *
* Since: 2.2 * Since: 2.2
**/ **/
gboolean GeglColor *
gimp_context_get_foreground (GimpRGB *foreground) gimp_context_get_foreground (void)
{ {
GimpValueArray *args; GimpValueArray *args;
GimpValueArray *return_vals; GimpValueArray *return_vals;
gboolean success = TRUE; GeglColor *foreground = NULL;
args = gimp_value_array_new_from_types (NULL, args = gimp_value_array_new_from_types (NULL,
G_TYPE_NONE); G_TYPE_NONE);
@ -355,14 +354,12 @@ gimp_context_get_foreground (GimpRGB *foreground)
args); args);
gimp_value_array_unref (args); gimp_value_array_unref (args);
success = GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS; if (GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS)
foreground = g_value_dup_object (gimp_value_array_index (return_vals, 1));
if (success)
GIMP_VALUES_GET_RGB (return_vals, 1, &*foreground);
gimp_value_array_unref (return_vals); gimp_value_array_unref (return_vals);
return success; return foreground;
} }
/** /**
@ -404,7 +401,6 @@ gimp_context_set_foreground (GeglColor *foreground)
/** /**
* gimp_context_get_background: * gimp_context_get_background:
* @background: (out caller-allocates): The background color.
* *
* Get the current GIMP background color. * Get the current GIMP background color.
* *
@ -412,16 +408,16 @@ gimp_context_set_foreground (GeglColor *foreground)
* used in a variety of tools such as blending, erasing (with non-alpha * used in a variety of tools such as blending, erasing (with non-alpha
* images), and image filling. * images), and image filling.
* *
* Returns: TRUE on success. * Returns: (transfer full): The background color.
* *
* Since: 2.2 * Since: 2.2
**/ **/
gboolean GeglColor *
gimp_context_get_background (GimpRGB *background) gimp_context_get_background (void)
{ {
GimpValueArray *args; GimpValueArray *args;
GimpValueArray *return_vals; GimpValueArray *return_vals;
gboolean success = TRUE; GeglColor *background = NULL;
args = gimp_value_array_new_from_types (NULL, args = gimp_value_array_new_from_types (NULL,
G_TYPE_NONE); G_TYPE_NONE);
@ -431,14 +427,12 @@ gimp_context_get_background (GimpRGB *background)
args); args);
gimp_value_array_unref (args); gimp_value_array_unref (args);
success = GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS; if (GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS)
background = g_value_dup_object (gimp_value_array_index (return_vals, 1));
if (success)
GIMP_VALUES_GET_RGB (return_vals, 1, &*background);
gimp_value_array_unref (return_vals); gimp_value_array_unref (return_vals);
return success; return background;
} }
/** /**

View File

@ -40,9 +40,9 @@ gchar* gimp_context_get_paint_method (void)
gboolean gimp_context_set_paint_method (const gchar *name); gboolean gimp_context_set_paint_method (const gchar *name);
GimpStrokeMethod gimp_context_get_stroke_method (void); GimpStrokeMethod gimp_context_get_stroke_method (void);
gboolean gimp_context_set_stroke_method (GimpStrokeMethod stroke_method); gboolean gimp_context_set_stroke_method (GimpStrokeMethod stroke_method);
gboolean gimp_context_get_foreground (GimpRGB *foreground); GeglColor* gimp_context_get_foreground (void);
gboolean gimp_context_set_foreground (GeglColor *foreground); gboolean gimp_context_set_foreground (GeglColor *foreground);
gboolean gimp_context_get_background (GimpRGB *background); GeglColor* gimp_context_get_background (void);
gboolean gimp_context_set_background (GeglColor *background); gboolean gimp_context_set_background (GeglColor *background);
gboolean gimp_context_set_default_colors (void); gboolean gimp_context_set_default_colors (void);
gboolean gimp_context_swap_colors (void); gboolean gimp_context_swap_colors (void);

View File

@ -606,6 +606,7 @@ gimp_procedure_dialog_set_ok_label (GimpProcedureDialog *dialog,
* Please use gimp_procedure_dialog_get_color_widget() for a * Please use gimp_procedure_dialog_get_color_widget() for a
* non-editable color area with a label. * non-editable color area with a label.
* * %GIMP_TYPE_COLOR_BUTTON: a color button with no label. * * %GIMP_TYPE_COLOR_BUTTON: a color button with no label.
* - %GEGL_TYPE_COLOR:
* * %GIMP_TYPE_COLOR_AREA: a color area with no label. * * %GIMP_TYPE_COLOR_AREA: a color area with no label.
* - %G_TYPE_PARAM_FILE: * - %G_TYPE_PARAM_FILE:
* * %GTK_FILE_CHOOSER_BUTTON (default): generic file chooser button * * %GTK_FILE_CHOOSER_BUTTON (default): generic file chooser button
@ -755,7 +756,10 @@ gimp_procedure_dialog_get_widget (GimpProcedureDialog *dialog,
gtk_widget_set_vexpand (widget, FALSE); gtk_widget_set_vexpand (widget, FALSE);
gtk_widget_set_hexpand (widget, FALSE); gtk_widget_set_hexpand (widget, FALSE);
} }
else if (widget_type == GIMP_TYPE_COLOR_AREA) }
else if (G_PARAM_SPEC_TYPE (pspec) == GEGL_TYPE_PARAM_COLOR)
{
if (widget_type == G_TYPE_NONE || widget_type == GIMP_TYPE_COLOR_AREA)
{ {
widget = gimp_prop_color_area_new (G_OBJECT (dialog->priv->config), widget = gimp_prop_color_area_new (G_OBJECT (dialog->priv->config),
property, 20, 20, property, 20, 20,

View File

@ -198,6 +198,14 @@ G_BEGIN_DECLS
G_PARAM_READWRITE |\ G_PARAM_READWRITE |\
GIMP_CONFIG_PARAM_SERIALIZE)) GIMP_CONFIG_PARAM_SERIALIZE))
#define GIMP_CONFIG_PROP_COLOR(class, id, name, nick, blurb, default, flags) \
g_object_class_install_property (class, id,\
gegl_param_spec_color (name, nick, blurb,\
default,\
flags |\
G_PARAM_READWRITE |\
GIMP_CONFIG_PARAM_SERIALIZE))
#define GIMP_CONFIG_PROP_BOXED(class, id, name, nick, blurb, boxed_type, flags) \ #define GIMP_CONFIG_PROP_BOXED(class, id, name, nick, blurb, boxed_type, flags) \
g_object_class_install_property (class, id,\ g_object_class_install_property (class, id,\
g_param_spec_boxed (name, nick, blurb,\ g_param_spec_boxed (name, nick, blurb,\

View File

@ -955,35 +955,48 @@ gimp_color_button_use_color (GAction *action,
GimpColorButton *button) GimpColorButton *button)
{ {
const gchar *name; const gchar *name;
GimpRGB color; GeglColor *color = NULL;
GimpRGB rgb;
name = g_action_get_name (action); name = g_action_get_name (action);
gimp_color_button_get_color (button, &color); gimp_color_button_get_color (button, &rgb);
if (! strcmp (name, GIMP_COLOR_BUTTON_COLOR_FG)) if (! strcmp (name, GIMP_COLOR_BUTTON_COLOR_FG))
{ {
if (_gimp_get_foreground_func) if (_gimp_get_foreground_func)
_gimp_get_foreground_func (&color); {
color = _gimp_get_foreground_func ();
gegl_color_get_pixel (color, babl_format_with_space ("R'G'B'A double", NULL), &rgb);
}
else else
gimp_rgba_set (&color, 0.0, 0.0, 0.0, 1.0); {
gimp_rgba_set (&rgb, 0.0, 0.0, 0.0, 1.0);
}
} }
else if (! strcmp (name, GIMP_COLOR_BUTTON_COLOR_BG)) else if (! strcmp (name, GIMP_COLOR_BUTTON_COLOR_BG))
{ {
if (_gimp_get_background_func) if (_gimp_get_background_func)
_gimp_get_background_func (&color); {
color = _gimp_get_background_func ();
gegl_color_get_pixel (color, babl_format_with_space ("R'G'B'A double", NULL), &rgb);
}
else else
gimp_rgba_set (&color, 1.0, 1.0, 1.0, 1.0); {
gimp_rgba_set (&rgb, 1.0, 1.0, 1.0, 1.0);
}
} }
else if (! strcmp (name, GIMP_COLOR_BUTTON_COLOR_BLACK)) else if (! strcmp (name, GIMP_COLOR_BUTTON_COLOR_BLACK))
{ {
gimp_rgba_set (&color, 0.0, 0.0, 0.0, 1.0); gimp_rgba_set (&rgb, 0.0, 0.0, 0.0, 1.0);
} }
else if (! strcmp (name, GIMP_COLOR_BUTTON_COLOR_WHITE)) else if (! strcmp (name, GIMP_COLOR_BUTTON_COLOR_WHITE))
{ {
gimp_rgba_set (&color, 1.0, 1.0, 1.0, 1.0); gimp_rgba_set (&rgb, 1.0, 1.0, 1.0, 1.0);
} }
gimp_color_button_set_color (button, &color); gimp_color_button_set_color (button, &rgb);
g_clear_object (&color);
} }
static void static void

View File

@ -4069,7 +4069,7 @@ static void gimp_prop_color_area_notify (GObject *config,
/** /**
* gimp_prop_color_area_new: * gimp_prop_color_area_new:
* @config: Object to which property is attached. * @config: Object to which property is attached.
* @property_name: Name of RGB property. * @property_name: Name of %GeglColor property.
* @width: Width of color area. * @width: Width of color area.
* @height: Height of color area. * @height: Height of color area.
* @type: How transparency is represented. * @type: How transparency is represented.
@ -4090,10 +4090,11 @@ gimp_prop_color_area_new (GObject *config,
{ {
GParamSpec *param_spec; GParamSpec *param_spec;
GtkWidget *area; GtkWidget *area;
GimpRGB *value; GeglColor *value = NULL;
GimpRGB rgb = { 0 };
param_spec = check_param_spec_w (config, property_name, param_spec = check_param_spec_w (config, property_name,
GIMP_TYPE_PARAM_RGB, G_STRFUNC); GEGL_TYPE_PARAM_COLOR, G_STRFUNC);
if (! param_spec) if (! param_spec)
return NULL; return NULL;
@ -4101,11 +4102,13 @@ gimp_prop_color_area_new (GObject *config,
property_name, &value, property_name, &value,
NULL); NULL);
area = gimp_color_area_new (value, type, if (value != NULL)
gegl_color_get_pixel (value, babl_format ("R'G'B'A double"), &rgb);
area = gimp_color_area_new (&rgb, type,
GDK_BUTTON1_MASK | GDK_BUTTON2_MASK); GDK_BUTTON1_MASK | GDK_BUTTON2_MASK);
gtk_widget_set_size_request (area, width, height); gtk_widget_set_size_request (area, width, height);
g_free (value); g_clear_object (&value);
set_param_spec (G_OBJECT (area), area, param_spec); set_param_spec (G_OBJECT (area), area, param_spec);
@ -4129,25 +4132,29 @@ gimp_prop_color_area_callback (GtkWidget *area,
GObject *config) GObject *config)
{ {
GParamSpec *param_spec; GParamSpec *param_spec;
GeglColor *color;
GimpRGB value; GimpRGB value;
param_spec = get_param_spec (G_OBJECT (area)); param_spec = get_param_spec (G_OBJECT (area));
if (! param_spec) if (! param_spec)
return; return;
color = gegl_color_new (NULL);
gimp_color_area_get_color (GIMP_COLOR_AREA (area), &value); gimp_color_area_get_color (GIMP_COLOR_AREA (area), &value);
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), &value);
g_signal_handlers_block_by_func (config, g_signal_handlers_block_by_func (config,
gimp_prop_color_area_notify, gimp_prop_color_area_notify,
area); area);
g_object_set (config, g_object_set (config,
param_spec->name, &value, param_spec->name, color,
NULL); NULL);
g_signal_handlers_unblock_by_func (config, g_signal_handlers_unblock_by_func (config,
gimp_prop_color_area_notify, gimp_prop_color_area_notify,
area); area);
g_object_unref (color);
} }
static void static void
@ -4155,19 +4162,21 @@ gimp_prop_color_area_notify (GObject *config,
GParamSpec *param_spec, GParamSpec *param_spec,
GtkWidget *area) GtkWidget *area)
{ {
GimpRGB *value; GeglColor *color = NULL;
GimpRGB value;
g_object_get (config, g_object_get (config,
param_spec->name, &value, param_spec->name, &color,
NULL); NULL);
g_signal_handlers_block_by_func (area, g_signal_handlers_block_by_func (area,
gimp_prop_color_area_callback, gimp_prop_color_area_callback,
config); config);
gimp_color_area_set_color (GIMP_COLOR_AREA (area), value); gegl_color_get_pixel (color, babl_format ("R'G'B'A double"), &value);
gimp_color_area_set_color (GIMP_COLOR_AREA (area), &value);
g_free (value); g_clear_object (&color);
g_signal_handlers_unblock_by_func (area, g_signal_handlers_unblock_by_func (area,
gimp_prop_color_area_callback, gimp_prop_color_area_callback,

View File

@ -22,6 +22,7 @@
#include "config.h" #include "config.h"
#include <babl/babl.h> #include <babl/babl.h>
#include <gegl.h>
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include "libgimpbase/gimpbase.h" #include "libgimpbase/gimpbase.h"

View File

@ -26,8 +26,8 @@
#define GIMP_RGBA_EPSILON 1e-6 #define GIMP_RGBA_EPSILON 1e-6
typedef gboolean (* GimpGetColorFunc) (GimpRGB *color); typedef GeglColor * (* GimpGetColorFunc) (void);
typedef void (* GimpEnsureModulesFunc) (void); typedef void (* GimpEnsureModulesFunc) (void);
extern GimpHelpFunc _gimp_standard_help_func; extern GimpHelpFunc _gimp_standard_help_func;

View File

@ -249,15 +249,15 @@ HELP
&pdb_misc; &pdb_misc;
@outargs = ( @outargs = (
{ name => 'foreground', type => 'color', void_ret => 1, { name => 'foreground', type => 'geglcolor',
desc => 'The foreground color' } desc => 'The foreground color' }
); );
%invoke = ( %invoke = (
code => <<'CODE' code => <<'CODE'
{ {
gimp_context_get_foreground (context, &foreground); foreground = gegl_color_duplicate (gimp_context_get_foreground (context));
gimp_rgb_set_alpha (&foreground, 1.0); gimp_color_set_alpha (foreground, 1.0);
} }
CODE CODE
); );
@ -301,15 +301,15 @@ HELP
&pdb_misc; &pdb_misc;
@outargs = ( @outargs = (
{ name => 'background', type => 'color', void_ret => 1, { name => 'background', type => 'geglcolor',
desc => 'The background color' } desc => 'The background color' }
); );
%invoke = ( %invoke = (
code => <<'CODE' code => <<'CODE'
{ {
gimp_context_get_background (context, &background); background = gegl_color_duplicate (gimp_context_get_background (context));
gimp_rgb_set_alpha (&background, 1.0); gimp_color_set_alpha (background, 1.0);
} }
CODE CODE
); );
@ -3409,7 +3409,8 @@ CODE
); );
} }
@headers = qw("core/gimp.h" @headers = qw(<cairo.h>
"core/gimp.h"
"core/gimp-gradients.h" "core/gimp-gradients.h"
"core/gimpcontainer.h" "core/gimpcontainer.h"
"core/gimpdashpattern.h" "core/gimpdashpattern.h"
@ -3419,6 +3420,7 @@ CODE
"core/gimpmybrush.h" "core/gimpmybrush.h"
"core/gimpstrokeoptions.h" "core/gimpstrokeoptions.h"
"paint/gimppaintoptions.h" "paint/gimppaintoptions.h"
"libgimpcolor/gimpcolor.h"
"libgimpconfig/gimpconfig.h" "libgimpconfig/gimpconfig.h"
"plug-in/gimpplugin.h" "plug-in/gimpplugin.h"
"plug-in/gimpplugin-context.h" "plug-in/gimpplugin-context.h"

View File

@ -215,25 +215,27 @@ HELP
GIMP_PDB_ITEM_CONTENT, error) && GIMP_PDB_ITEM_CONTENT, error) &&
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error)) gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
{ {
GimpRGB color; GeglColor *color;
GeglColor *gegl_color;
GeglNode *node; GeglNode *node;
if (set_background) if (set_background)
gimp_context_get_background (context, &color); {
color = gegl_color_duplicate (gimp_context_get_background (context));
}
else else
gimp_rgba_set (&color, 0.0, 0.0, 0.0, 0.0); {
color = gegl_color_new ("black");
gegl_color = gimp_gegl_color_new (&color, NULL); gegl_color_set_rgba_with_space (color, 0.0, 0.0, 0.0, 0.0, NULL);
}
node = gegl_node_new_child (NULL, node = gegl_node_new_child (NULL,
"operation", "gegl:apply-lens", "operation", "gegl:apply-lens",
"refraction-index", refraction, "refraction-index", refraction,
"keep-surroundings", keep_surroundings, "keep-surroundings", keep_surroundings,
"background-color", gegl_color, "background-color", color,
NULL); NULL);
g_object_unref (gegl_color); g_object_unref (color);
node = wrap_in_selection_bounds (node, drawable); node = wrap_in_selection_bounds (node, drawable);
@ -980,29 +982,27 @@ HELP
GIMP_PDB_ITEM_CONTENT, error) && GIMP_PDB_ITEM_CONTENT, error) &&
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error)) gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
{ {
GimpRGB color; GeglColor *color;
GeglColor *gegl_color;
GeglNode *node; GeglNode *node;
if (bg_color) if (bg_color)
{ {
gimp_context_get_background (context, &color); color = gegl_color_duplicate (gimp_context_get_background (context));
gimp_rgb_set_alpha (&color, 0.0); gimp_color_set_alpha (color, 0.0);
} }
else else
{ {
gimp_rgba_set (&color, 0.0, 0.0, 0.0, 0.0); color = gegl_color_new ("black");
gegl_color_set_rgba_with_space (color, 0.0, 0.0, 0.0, 0.0, NULL);
} }
gegl_color = gimp_gegl_color_new (&color, NULL);
node = gegl_node_new_child (NULL, node = gegl_node_new_child (NULL,
"operation", "gegl:cubism", "operation", "gegl:cubism",
"tile-size", tile_size, "tile-size", tile_size,
"tile-saturation", tile_saturation, "tile-saturation", tile_saturation,
"bg-color", gegl_color, "bg-color", color,
NULL); NULL);
g_object_unref (gegl_color); g_object_unref (color);
gimp_drawable_apply_operation (drawable, progress, gimp_drawable_apply_operation (drawable, progress,
C_("undo-type", "Cubism"), C_("undo-type", "Cubism"),
@ -2172,21 +2172,14 @@ HELP
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error)) gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
{ {
GeglNode *node = NULL; GeglNode *node = NULL;
GimpRGB color; GeglColor *color;
GeglColor *gegl_color;
gimp_context_get_background (context, &color); color = gegl_color_duplicate (gimp_context_get_background (context));
if (gimp_drawable_has_alpha (drawable)) if (gimp_drawable_has_alpha (drawable))
{ gimp_color_set_alpha (color, 0.0);
gimp_rgb_set_alpha (&color, 0.0);
}
else else
{ gimp_color_set_alpha (color, 1.0);
gimp_rgb_set_alpha (&color, 1.0);
}
gegl_color = gimp_gegl_color_new (&color, NULL);
node = gegl_node_new_child (NULL, node = gegl_node_new_child (NULL,
"operation", "gegl:lens-distortion", "operation", "gegl:lens-distortion",
@ -2196,10 +2189,10 @@ HELP
"x-shift", (gdouble) offset_x, "x-shift", (gdouble) offset_x,
"y-shift", (gdouble) offset_y, "y-shift", (gdouble) offset_y,
"brighten", (gdouble) brighten, "brighten", (gdouble) brighten,
"background", gegl_color, "background", color,
NULL); NULL);
g_object_unref (gegl_color); g_object_unref (color);
node = wrap_in_selection_bounds (node, drawable); node = wrap_in_selection_bounds (node, drawable);
@ -2305,13 +2298,9 @@ HELP
GeglNode *node; GeglNode *node;
GeglColor *fg_color; GeglColor *fg_color;
GeglColor *bg_color; GeglColor *bg_color;
GimpRGB color;
gimp_context_get_foreground (context, &color); fg_color = gimp_context_get_foreground (context);
fg_color = gimp_gegl_color_new (&color, NULL); bg_color = gimp_context_get_background (context);
gimp_context_get_background (context, &color);
bg_color = gimp_gegl_color_new (&color, NULL);
node = gegl_node_new_child (NULL, node = gegl_node_new_child (NULL,
"operation", "gegl:maze", "operation", "gegl:maze",
@ -2324,9 +2313,6 @@ HELP
"bg-color", bg_color, "bg-color", bg_color,
NULL); NULL);
g_object_unref (fg_color);
g_object_unref (bg_color);
gimp_drawable_apply_operation (drawable, progress, gimp_drawable_apply_operation (drawable, progress,
C_("undo-type", "Maze"), C_("undo-type", "Maze"),
node); node);
@ -2633,13 +2619,8 @@ HELP
if (grout_color) if (grout_color)
{ {
GimpRGB fgcolor, bgcolor; bg_color = gegl_color_duplicate (gimp_context_get_background (context));
fg_color = gegl_color_duplicate (gimp_context_get_foreground (context));
gimp_context_get_background (context, &bgcolor);
bg_color = gimp_gegl_color_new (&bgcolor, NULL);
gimp_context_get_foreground (context, &fgcolor);
fg_color = gimp_gegl_color_new (&fgcolor, NULL);
} }
else else
{ {
@ -3102,7 +3083,7 @@ HELP
desc => 'Centering' }, desc => 'Centering' },
{ name => 'background_type', type => '0 <= int32 <= 5', { name => 'background_type', type => '0 <= int32 <= 5',
desc => 'Background type { TRANSPARENT (0), INVERTED (1), IMAGE (2), FG (3), BG (4), COLOR (5) }' }, desc => 'Background type { TRANSPARENT (0), INVERTED (1), IMAGE (2), FG (3), BG (4), COLOR (5) }' },
{ name => 'background_color', type => 'color', { name => 'background_color', type => 'geglcolor',
desc => 'Background color (for background-type == 5)' }, desc => 'Background color (for background-type == 5)' },
{ name => 'background_alpha', type => 'int32', dead => 1, { name => 'background_alpha', type => 'int32', dead => 1,
desc => 'Background alpha (unused)' } desc => 'Background alpha (unused)' }
@ -3116,48 +3097,49 @@ HELP
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error)) gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
{ {
GeglNode *node; GeglNode *node;
GimpRGB color; GeglColor *color;
GeglColor *gegl_color;
gint bg_type; gint bg_type;
switch (background_type) switch (background_type)
{ {
default: default:
bg_type = background_type; bg_type = background_type;
gimp_rgba_set (&color, 0.0, 0.0, 1.0, 1.0); color = gegl_color_new (NULL);
/* XXX: I guess what we want is to set this color (why blue?) in the
* drawable's space, though I haven't looked too much into it.
*/
gegl_color_set_rgba_with_space (color, 0.0, 0.0, 1.0, 1.0, gimp_drawable_get_space (drawable));
break; break;
case 3: case 3:
bg_type = 3; bg_type = 3;
gimp_context_get_foreground (context, &color); color = gegl_color_duplicate (gimp_context_get_foreground (context));
break; break;
case 4: case 4:
bg_type = 3; bg_type = 3;
gimp_context_get_background (context, &color); color = gegl_color_duplicate (gimp_context_get_background (context));
break; break;
case 5: case 5:
bg_type = 3; bg_type = 3;
color = background_color; color = gegl_color_duplicate (background_color);
break; break;
} }
gegl_color = gimp_gegl_color_new (&color, NULL);
node = gegl_node_new_child (NULL, node = gegl_node_new_child (NULL,
"operation", "gegl:tile-paper", "operation", "gegl:tile-paper",
"tile-width", tile_size, "tile-width", tile_size,
"tile-height", tile_size, "tile-height", tile_size,
"move-rate", move_max, "move-rate", move_max,
"bg-color", gegl_color, "bg-color", color,
"centering", centering, "centering", centering,
"wrap-around", wrap_around, "wrap-around", wrap_around,
"background-type", bg_type, "background-type", bg_type,
"fractional-type", fractional_type, "fractional-type", fractional_type,
NULL); NULL);
g_object_unref (gegl_color); g_object_unref (color);
gimp_drawable_apply_operation (drawable, progress, gimp_drawable_apply_operation (drawable, progress,
C_("undo-type", "Paper Tile"), C_("undo-type", "Paper Tile"),
@ -4074,15 +4056,17 @@ HELP
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error) && gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error) &&
gimp_drawable_has_alpha (drawable)) gimp_drawable_has_alpha (drawable))
{ {
GeglNode *node; GeglNode *node;
GimpRGB color; GeglColor *color;
GimpRGB rgb;
gimp_context_get_background (context, &color); color = gimp_context_get_background (context);
gegl_color_get_rgba_with_space (color, &rgb.r, &rgb.g, &rgb.b, &rgb.a, NULL);
node = node =
gegl_node_new_child (NULL, gegl_node_new_child (NULL,
"operation", "gimp:semi-flatten", "operation", "gimp:semi-flatten",
"color", &color, "color", &rgb,
NULL); NULL);
gimp_drawable_apply_operation (drawable, progress, gimp_drawable_apply_operation (drawable, progress,
@ -4175,9 +4159,9 @@ sub plug_in_sinus {
desc => 'If set, the pattern is a little more distorted...' }, desc => 'If set, the pattern is a little more distorted...' },
{ name => 'colors', type => '0 <= int32 <=2', { name => 'colors', type => '0 <= int32 <=2',
desc => 'where to take the colors (0=B&W, 1=fg/bg, 2=col1/col2)' }, desc => 'where to take the colors (0=B&W, 1=fg/bg, 2=col1/col2)' },
{ name => 'col1', type => 'color', { name => 'col1', type => 'geglcolor',
desc => 'fist color (sometimes unused)' }, desc => 'fist color (sometimes unused)' },
{ name => 'col2', type => 'color', { name => 'col2', type => 'geglcolor',
desc => 'second color (sometimes unused)' }, desc => 'second color (sometimes unused)' },
{ name => 'alpha1', type => '0 <= float <= 1', { name => 'alpha1', type => '0 <= float <= 1',
desc => 'alpha for the first color (used if the drawable has an alpha channel)' }, desc => 'alpha for the first color (used if the drawable has an alpha channel)' },
@ -4197,28 +4181,30 @@ sub plug_in_sinus {
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error)) gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
{ {
GeglNode *node; GeglNode *node;
GeglColor *gegl_color1; GeglColor *gegl_color1 = NULL;
GeglColor *gegl_color2; GeglColor *gegl_color2 = NULL;
gint x, y, width, height; gint x, y, width, height;
switch (colors) switch (colors)
{ {
case 0: case 0:
gimp_rgb_set (&col1, 0.0, 0.0, 0.0); gegl_color1 = gegl_color_new ("black");
gimp_rgb_set (&col2, 1.0, 1.0, 1.0); gegl_color2 = gegl_color_new ("white");
break; break;
case 1: case 1:
gimp_context_get_foreground (context, &col1); gegl_color1 = gegl_color_duplicate (gimp_context_get_foreground (context));
gimp_context_get_background (context, &col2); gegl_color2 = gegl_color_duplicate (gimp_context_get_background (context));
break; break;
} }
gimp_rgb_set_alpha (&col1, alpha1); if (gegl_color1 == NULL)
gimp_rgb_set_alpha (&col2, alpha2); {
gegl_color1 = gegl_color_duplicate (col1);
gegl_color1 = gimp_gegl_color_new (&col1, NULL); gegl_color2 = gegl_color_duplicate (col2);
gegl_color2 = gimp_gegl_color_new (&col2, NULL); }
gimp_color_set_alpha (gegl_color1, alpha1);
gimp_color_set_alpha (gegl_color2, alpha2);
gimp_item_mask_intersect (GIMP_ITEM (drawable), &x, &y, &width, &height); gimp_item_mask_intersect (GIMP_ITEM (drawable), &x, &y, &width, &height);
@ -4736,8 +4722,7 @@ HELP
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error)) gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
{ {
GeglNode *node; GeglNode *node;
GimpRGB color; GeglColor *color = NULL;
GeglColor *gegl_color = NULL;
gint gegl_mode = 0; gint gegl_mode = 0;
gboolean to_left = (direction_mask & (0x1 << 0)) != 0; gboolean to_left = (direction_mask & (0x1 << 0)) != 0;
gboolean to_top = (direction_mask & (0x1 << 1)) != 0; gboolean to_top = (direction_mask & (0x1 << 1)) != 0;
@ -4761,16 +4746,14 @@ HELP
{ {
gegl_mode = propagate_mode; gegl_mode = propagate_mode;
gimp_context_get_foreground (context, &color); color = gimp_context_get_foreground (context);
} }
else else
{ {
gegl_mode = 4; gegl_mode = 4;
gimp_context_get_background (context, &color); color = gimp_context_get_background (context);
} }
gegl_color = gimp_gegl_color_new (&color, NULL);
break; break;
case 6: case 6:
@ -4786,7 +4769,7 @@ HELP
"lower-threshold", (gdouble) lower_limit / 255.0, "lower-threshold", (gdouble) lower_limit / 255.0,
"upper-threshold", (gdouble) upper_limit / 255.0, "upper-threshold", (gdouble) upper_limit / 255.0,
"rate", propagating_rate, "rate", propagating_rate,
"color", gegl_color, "color", color,
"top", to_top, "top", to_top,
"left", to_left, "left", to_left,
"right", to_right, "right", to_right,
@ -4795,9 +4778,6 @@ HELP
"alpha", alpha, "alpha", alpha,
NULL); NULL);
if (gegl_color)
g_object_unref (gegl_color);
gimp_drawable_apply_operation (drawable, progress, gimp_drawable_apply_operation (drawable, progress,
C_("undo-type", "Value Propagate"), C_("undo-type", "Value Propagate"),
node); node);

View File

@ -54,20 +54,23 @@ HELP
%invoke = ( %invoke = (
code => <<'CODE' code => <<'CODE'
{ {
GimpText *gimp_text; GimpText *gimp_text;
GimpRGB color; GeglColor *color;
GimpRGB rgb;
gimp_context_get_foreground (context, &color); color = gimp_context_get_foreground (context);
gegl_color_get_pixel (color, babl_format ("R'G'B'A double"), &rgb);
gimp_text = g_object_new (GIMP_TYPE_TEXT, gimp_text = g_object_new (GIMP_TYPE_TEXT,
"text", text, "text", text,
"font", font, "font", font,
"font-size", size, "font-size", size,
"font-size-unit", unit, "font-size-unit", unit,
"color", &color, "color", &rgb,
NULL); NULL);
layer = GIMP_TEXT_LAYER (gimp_text_layer_new (image, gimp_text)); layer = GIMP_TEXT_LAYER (gimp_text_layer_new (image, gimp_text));
g_object_unref (color);
g_object_unref (gimp_text); g_object_unref (gimp_text);
if (! layer) if (! layer)

View File

@ -452,6 +452,7 @@ dialog_update_preview (GtkWidget *widget,
guchar *buffer; guchar *buffer;
GBytes *cache; GBytes *cache;
const guchar *cache_start; const guchar *cache_start;
GeglColor *color;
GimpRGB background; GimpRGB background;
guchar bg[4]; guchar bg[4];
gint width; gint width;
@ -471,10 +472,13 @@ dialog_update_preview (GtkWidget *widget,
&width, &height, &bpp); &width, &height, &bpp);
p = cache_start = g_bytes_get_data (cache, NULL); p = cache_start = g_bytes_get_data (cache, NULL);
gimp_context_get_background (&background); color = gimp_context_get_background ();
if (bg_trans) if (bg_trans)
gimp_rgb_set_alpha (&background, 0.0); gimp_color_set_alpha (color, 0.0);
gegl_color_get_pixel (color, babl_format_with_space ("R'G'B'A double", NULL), &background);
g_object_unref (color);
if (gimp_drawable_is_gray (drawable)) if (gimp_drawable_is_gray (drawable))
{ {
@ -580,7 +584,7 @@ apply_blinds (GObject *config,
guchar *src_rows, *des_rows; guchar *src_rows, *des_rows;
gint bytes; gint bytes;
gint x, y; gint x, y;
GimpRGB background; GeglColor *background;
guchar bg[4]; guchar bg[4];
gint sel_x1, sel_y1; gint sel_x1, sel_y1;
gint sel_width, sel_height; gint sel_width, sel_height;
@ -592,12 +596,13 @@ apply_blinds (GObject *config,
"orientation", &orientation, "orientation", &orientation,
NULL); NULL);
gimp_context_get_background (&background); background = gimp_context_get_background ();
if (bg_trans) if (bg_trans)
gimp_rgb_set_alpha (&background, 0.0); gimp_color_set_alpha (background, 0.0);
gimp_rgba_get_uchar (&background, bg, bg + 1, bg + 2, bg + 3); gegl_color_get_pixel (background, babl_format_with_space ("R'G'B'A u8", NULL), bg);
g_object_unref (background);
if (! gimp_drawable_mask_intersect (drawable, if (! gimp_drawable_mask_intersect (drawable,
&sel_x1, &sel_y1, &sel_x1, &sel_y1,

View File

@ -257,6 +257,7 @@ do_checkerboard_pattern (GObject *config,
GimpPreview *preview) GimpPreview *preview)
{ {
CheckerboardParam_t param; CheckerboardParam_t param;
GeglColor *color;
GimpRGB fg, bg; GimpRGB fg, bg;
const Babl *format; const Babl *format;
gint bpp; gint bpp;
@ -269,8 +270,12 @@ do_checkerboard_pattern (GObject *config,
"psychobily", &mode, "psychobily", &mode,
NULL); NULL);
gimp_context_get_background (&bg); color = gimp_context_get_background ();
gimp_context_get_foreground (&fg); gegl_color_get_pixel (color, babl_format_with_space ("R'G'B'A double", NULL), &bg);
g_object_unref (color);
color = gimp_context_get_foreground ();
gegl_color_get_pixel (color, babl_format_with_space ("R'G'B'A double", NULL), &fg);
g_object_unref (color);
if (gimp_drawable_is_gray (drawable)) if (gimp_drawable_is_gray (drawable))
{ {

View File

@ -660,7 +660,7 @@ transfer_registration_color (GeglBuffer *src,
GeglBuffer **dst, GeglBuffer **dst,
gint count) gint count)
{ {
GimpRGB color, test; GeglColor *color;
GeglBufferIterator *gi; GeglBufferIterator *gi;
const Babl *src_format; const Babl *src_format;
const Babl *dst_format; const Babl *dst_format;
@ -669,7 +669,7 @@ transfer_registration_color (GeglBuffer *src,
gint i; gint i;
gdouble white; gdouble white;
gimp_context_get_foreground (&color); color = gimp_context_get_foreground ();
white = 1.0; white = 1.0;
src_format = gegl_buffer_get_format (src); src_format = gegl_buffer_get_format (src);
@ -699,11 +699,13 @@ transfer_registration_color (GeglBuffer *src,
for (k = 0; k < gi->length; k++) for (k = 0; k < gi->length; k++)
{ {
gulong pos = k * src_bpp; GeglColor *test;
gulong pos = k * src_bpp;
gimp_rgba_set_pixel (&test, src_format, ((guchar *)src_data) + pos); test = gegl_color_new (NULL);
gegl_color_set_pixel (test, src_format, ((guchar *)src_data) + pos);
if (gimp_rgb_distance (&test, &color) < 1e-6) if (gimp_color_is_perceptually_identical (test, color))
{ {
for (j = 0; j < count; j++) for (j = 0; j < count; j++)
{ {
@ -713,8 +715,12 @@ transfer_registration_color (GeglBuffer *src,
&white, (guchar *)data + (k * dst_bpp), 1); &white, (guchar *)data + (k * dst_bpp), 1);
} }
} }
g_object_unref (test);
} }
} }
g_object_unref (color);
} }
static void static void

View File

@ -785,8 +785,9 @@ save_image (GFile *file,
gint Disposal; gint Disposal;
gchar *layer_name; gchar *layer_name;
GimpRGB background; guchar bgred = 255;
guchar bgred, bggreen, bgblue; guchar bggreen = 255;
guchar bgblue = 255;
guchar bgindex = 0; guchar bgindex = 0;
guint best_error = 0xFFFFFFFF; guint best_error = 0xFFFFFFFF;
@ -882,22 +883,31 @@ save_image (GFile *file,
case GIMP_INDEXEDA_IMAGE: case GIMP_INDEXEDA_IMAGE:
is_gif89 = TRUE; is_gif89 = TRUE;
case GIMP_INDEXED_IMAGE: case GIMP_INDEXED_IMAGE:
cmap = gimp_image_get_colormap (image, NULL, &colors);
gimp_context_get_background (&background);
gimp_rgb_get_uchar (&background, &bgred, &bggreen, &bgblue);
for (i = 0; i < colors; i++)
{ {
Red[i] = *cmap++; GeglColor *background;
Green[i] = *cmap++; guchar bg[3];
Blue[i] = *cmap++;
} cmap = gimp_image_get_colormap (image, NULL, &colors);
for ( ; i < 256; i++)
{ background = gimp_context_get_background ();
Red[i] = bgred; gegl_color_get_pixel (background, babl_format_with_space ("R'G'B' u8", NULL), bg);
Green[i] = bggreen; g_object_unref (background);
Blue[i] = bgblue; bgred = bg[0];
bggreen = bg[1];
bgblue = bg[2];
for (i = 0; i < colors; i++)
{
Red[i] = *cmap++;
Green[i] = *cmap++;
Blue[i] = *cmap++;
}
for ( ; i < 256; i++)
{
Red[i] = bgred;
Green[i] = bggreen;
Blue[i] = bgblue;
}
} }
break; break;
case GIMP_GRAYA_IMAGE: case GIMP_GRAYA_IMAGE:

View File

@ -768,17 +768,18 @@ pdf_save_image (GimpProcedure *procedure,
if (gimp_drawable_has_alpha (GIMP_DRAWABLE (layers[n_layers - 1])) && if (gimp_drawable_has_alpha (GIMP_DRAWABLE (layers[n_layers - 1])) &&
fill_background_color) fill_background_color)
{ {
GimpRGB color; GeglColor *color;
double rgb[3];
cairo_rectangle (cr, 0.0, 0.0, cairo_rectangle (cr, 0.0, 0.0,
gimp_image_get_width (image), gimp_image_get_width (image),
gimp_image_get_height (image)); gimp_image_get_height (image));
gimp_context_get_background (&color); color = gimp_context_get_background ();
cairo_set_source_rgb (cr, gegl_color_get_pixel (color, babl_format_with_space ("R'G'B'A double", NULL), rgb);
color.r, cairo_set_source_rgb (cr, rgb[0], rgb[1], rgb[2]);
color.g,
color.b);
cairo_fill (cr); cairo_fill (cr);
g_object_unref (color);
} }
/* Now, we should loop over the layers of each image */ /* Now, we should loop over the layers of each image */

View File

@ -1743,17 +1743,20 @@ save_image (GFile *file,
if (save_bkgd) if (save_bkgd)
{ {
GimpRGB color; GeglColor *color;
guchar red, green, blue; GimpRGB rgb;
guchar c[3];
gimp_context_get_background (&color); color = gimp_context_get_background ();
gimp_rgb_get_uchar (&color, &red, &green, &blue); gegl_color_get_pixel (color, babl_format_with_space ("R'G'B' u8", NULL), c);
gegl_color_get_pixel (color, babl_format_with_space ("R'G'B'A double", NULL), &rgb);
g_object_unref (color);
background.index = 0; background.index = 0;
background.red = red; background.red = c[0];
background.green = green; background.green = c[1];
background.blue = blue; background.blue = c[2];
background.gray = gimp_rgb_luminance_uchar (&color); background.gray = gimp_rgb_luminance_uchar (&rgb);
png_set_bKGD (pp, info, &background); png_set_bKGD (pp, info, &background);
} }

View File

@ -992,7 +992,7 @@ fspike (GObject *config,
gdouble sfac; gdouble sfac;
gint i; gint i;
gboolean ok; gboolean ok;
GimpRGB gimp_color; GeglColor *gegl_color;
guchar pixel[MAX_CHANNELS]; guchar pixel[MAX_CHANNELS];
guchar chosen_color[MAX_CHANNELS]; guchar chosen_color[MAX_CHANNELS];
guchar color[MAX_CHANNELS]; guchar color[MAX_CHANNELS];
@ -1018,15 +1018,15 @@ fspike (GObject *config,
break; break;
case FOREGROUND: case FOREGROUND:
gimp_context_get_foreground (&gimp_color); gegl_color = gimp_context_get_foreground ();
gimp_rgb_get_uchar (&gimp_color, &chosen_color[0], &chosen_color[1], gegl_color_get_pixel (gegl_color, babl_format_with_space ("R'G'B' u8", NULL), chosen_color);
&chosen_color[2]); g_clear_object (&gegl_color);
break; break;
case BACKGROUND: case BACKGROUND:
gimp_context_get_background (&gimp_color); gegl_color = gimp_context_get_background ();
gimp_rgb_get_uchar (&gimp_color, &chosen_color[0], &chosen_color[1], gegl_color_get_pixel (gegl_color, babl_format_with_space ("R'G'B' u8", NULL), chosen_color);
&chosen_color[2]); g_clear_object (&gegl_color);
break; break;
} }

View File

@ -332,7 +332,7 @@ warp_run (GimpProcedure *procedure,
gpointer run_data) gpointer run_data)
{ {
GimpDrawable *drawable; GimpDrawable *drawable;
GimpRGB color; GeglColor *color;
gegl_init (NULL, NULL); gegl_init (NULL, NULL);
@ -354,11 +354,9 @@ warp_run (GimpProcedure *procedure,
} }
/* get currently selected foreground pixel color */ /* get currently selected foreground pixel color */
gimp_context_get_foreground (&color); color = gimp_context_get_foreground ();
gimp_rgb_get_uchar (&color, gegl_color_get_pixel (color, babl_format ("R'G'B' u8"), color_pixel);
&color_pixel[0], g_object_unref (color);
&color_pixel[1],
&color_pixel[2]);
run_mode = _run_mode; run_mode = _run_mode;

View File

@ -669,14 +669,14 @@ save_image (GFile *file,
gint colors, i; gint colors, i;
guchar *cmap; guchar *cmap;
guchar bg; guchar bg;
guchar red, green, blue; guchar rgb[3];
gint diff, sum, max; gint diff, sum, max;
gint offset_x, offset_y, xc, yc, xx, yy; gint offset_x, offset_y, xc, yc, xx, yy;
guint rows, cols, bytes; guint rows, cols, bytes;
guchar *src_row; guchar *src_row;
guchar *fb, *ofb; guchar *fb, *ofb;
guchar cm[768]; guchar cm[768];
GimpRGB background; GeglColor *background;
s_fli_header fli_header; s_fli_header fli_header;
gint cnt; gint cnt;
gint from_frame; gint from_frame;
@ -721,8 +721,9 @@ save_image (GFile *file,
to_frame = n_frames; to_frame = n_frames;
} }
gimp_context_get_background (&background); background = gimp_context_get_background ();
gimp_rgb_get_uchar (&background, &red, &green, &blue); gegl_color_get_pixel (background, babl_format_with_space ("R'G'B' u8", NULL), rgb);
g_object_unref (background);
switch (gimp_image_get_base_type (image)) switch (gimp_image_get_base_type (image))
{ {
@ -732,7 +733,7 @@ save_image (GFile *file,
{ {
cm[i*3+0] = cm[i*3+1] = cm[i*3+2] = i; cm[i*3+0] = cm[i*3+1] = cm[i*3+2] = i;
} }
bg = GIMP_RGB_LUMINANCE (red, green, blue) + 0.5; bg = GIMP_RGB_LUMINANCE (rgb[0], rgb[1], rgb[2]) + 0.5;
break; break;
case GIMP_INDEXED: case GIMP_INDEXED:
@ -745,11 +746,11 @@ save_image (GFile *file,
cm[i*3+1] = cmap[i*3+1]; cm[i*3+1] = cmap[i*3+1];
cm[i*3+2] = cmap[i*3+2]; cm[i*3+2] = cmap[i*3+2];
diff = red - cm[i*3+0]; diff = rgb[0] - cm[i*3+0];
sum = SQR (diff); sum = SQR (diff);
diff = green - cm[i*3+1]; diff = rgb[1] - cm[i*3+1];
sum += SQR (diff); sum += SQR (diff);
diff = blue - cm[i*3+2]; diff = rgb[1] - cm[i*3+2];
sum += SQR (diff); sum += SQR (diff);
if (sum < max) if (sum < max)

View File

@ -648,7 +648,8 @@ void
gfig_read_gimp_style (Style *style, gfig_read_gimp_style (Style *style,
const gchar *name) const gchar *name)
{ {
gint dummy; GeglColor *color;
gint dummy;
if (!name) if (!name)
g_message ("Error: name is NULL in gfig_read_gimp_style."); g_message ("Error: name is NULL in gfig_read_gimp_style.");
@ -657,8 +658,12 @@ gfig_read_gimp_style (Style *style,
g_printerr ("Reading Gimp settings as style %s\n", name); g_printerr ("Reading Gimp settings as style %s\n", name);
style->name = g_strdup (name); style->name = g_strdup (name);
gimp_context_get_foreground (&style->foreground); color = gimp_context_get_foreground ();
gimp_context_get_background (&style->background); gegl_color_get_pixel (color, babl_format_with_space ("R'G'B'A double", NULL), &style->foreground);
g_object_unref (color);
color = gimp_context_get_background ();
gegl_color_get_pixel (color, babl_format_with_space ("R'G'B'A double", NULL), &style->background);
g_object_unref (color);
style->brush = gimp_context_get_brush (); style->brush = gimp_context_get_brush ();
style->gradient = gimp_context_get_gradient (); style->gradient = gimp_context_get_gradient ();

View File

@ -1317,8 +1317,8 @@ ifs_compose (GimpDrawable *drawable)
guchar *data; guchar *data;
guchar *mask = NULL; guchar *mask = NULL;
guchar *nhits; guchar *nhits;
guchar rc, gc, bc; guchar c[3];
GimpRGB color; GeglColor *color;
if (alpha) if (alpha)
format = babl_format ("R'G'B'A u8"); format = babl_format ("R'G'B'A u8");
@ -1336,8 +1336,9 @@ ifs_compose (GimpDrawable *drawable)
data = g_new (guchar, width * band_height * SQR (ifsvals.subdivide) * 3); data = g_new (guchar, width * band_height * SQR (ifsvals.subdivide) * 3);
nhits = g_new (guchar, width * band_height * SQR (ifsvals.subdivide)); nhits = g_new (guchar, width * band_height * SQR (ifsvals.subdivide));
gimp_context_get_background (&color); color = gimp_context_get_background ();
gimp_rgb_get_uchar (&color, &rc, &gc, &bc); gegl_color_get_pixel (color, babl_format_with_space ("R'G'B' u8", NULL), c);
g_object_unref (color);
for (band_no = 0, band_y = 0; band_no < num_bands; band_no++) for (band_no = 0, band_y = 0; band_no < num_bands; band_no++)
{ {
@ -1429,9 +1430,9 @@ ifs_compose (GimpDrawable *drawable)
} }
else else
{ {
*dest++ = (mtot * rtot + (255 - mtot) * rc) / 255; *dest++ = (mtot * rtot + (255 - mtot) * c[0]) / 255;
*dest++ = (mtot * gtot + (255 - mtot) * gc) / 255; *dest++ = (mtot * gtot + (255 - mtot) * c[1]) / 255;
*dest++ = (mtot * btot + (255 - mtot) * bc) / 255; *dest++ = (mtot * btot + (255 - mtot) * c[2]) / 255;
} }
} }
@ -2324,10 +2325,13 @@ flip_check_button_callback (GtkWidget *widget,
static void static void
ifs_compose_set_defaults (void) ifs_compose_set_defaults (void)
{ {
gint i; GeglColor *color;
GimpRGB color; GimpRGB rgb;
gint i;
gimp_context_get_foreground (&color); color = gimp_context_get_foreground ();
gegl_color_get_pixel (color, babl_format ("R'G'B'A double"), &rgb);
g_object_unref (color);
ifsvals.aspect_ratio = ifsvals.aspect_ratio =
(gdouble)ifsD->drawable_height / ifsD->drawable_width; (gdouble)ifsD->drawable_height / ifsD->drawable_width;
@ -2341,13 +2345,13 @@ ifs_compose_set_defaults (void)
element_selected = g_realloc (element_selected, element_selected = g_realloc (element_selected,
ifsvals.num_elements * sizeof(gboolean)); ifsvals.num_elements * sizeof(gboolean));
elements[0] = aff_element_new (0.3, 0.37 * ifsvals.aspect_ratio, &color, elements[0] = aff_element_new (0.3, 0.37 * ifsvals.aspect_ratio, &rgb,
++count_for_naming); ++count_for_naming);
element_selected[0] = FALSE; element_selected[0] = FALSE;
elements[1] = aff_element_new (0.7, 0.37 * ifsvals.aspect_ratio, &color, elements[1] = aff_element_new (0.7, 0.37 * ifsvals.aspect_ratio, &rgb,
++count_for_naming); ++count_for_naming);
element_selected[1] = FALSE; element_selected[1] = FALSE;
elements[2] = aff_element_new (0.5, 0.7 * ifsvals.aspect_ratio, &color, elements[2] = aff_element_new (0.5, 0.7 * ifsvals.aspect_ratio, &rgb,
++count_for_naming); ++count_for_naming);
element_selected[2] = FALSE; element_selected[2] = FALSE;
@ -2622,19 +2626,22 @@ ifs_compose_new_action (GSimpleAction *action,
GVariant *parameter, GVariant *parameter,
gpointer user_data) gpointer user_data)
{ {
GtkAllocation allocation; GtkAllocation allocation;
GimpRGB color; GeglColor *color;
gint i; GimpRGB rgb;
AffElement *elem; gint i;
AffElement *elem;
gtk_widget_get_allocation (ifsDesign->area, &allocation); gtk_widget_get_allocation (ifsDesign->area, &allocation);
undo_begin (); undo_begin ();
gimp_context_get_foreground (&color); color = gimp_context_get_foreground ();
gegl_color_get_pixel (color, babl_format ("R'G'B'A double"), &rgb);
g_object_unref (color);
elem = aff_element_new (0.5, 0.5 * allocation.height / allocation.width, elem = aff_element_new (0.5, 0.5 * allocation.height / allocation.width,
&color, &rgb,
++count_for_naming); ++count_for_naming);
ifsvals.num_elements++; ifsvals.num_elements++;
@ -2777,25 +2784,26 @@ static void
ifs_compose_preview (void) ifs_compose_preview (void)
{ {
/* Expansion isn't really supported for previews */ /* Expansion isn't really supported for previews */
gint i; gint i;
gint width = ifsD->preview_width; gint width = ifsD->preview_width;
gint height = ifsD->preview_height; gint height = ifsD->preview_height;
guchar rc, gc, bc; guchar *ptr;
guchar *ptr; GeglColor *color;
GimpRGB color; guchar c[3];
if (!ifsD->preview_data) if (!ifsD->preview_data)
ifsD->preview_data = g_new (guchar, 3 * width * height); ifsD->preview_data = g_new (guchar, 3 * width * height);
gimp_context_get_background (&color); color = gimp_context_get_background ();
gimp_rgb_get_uchar (&color, &rc, &gc, &bc); gegl_color_get_pixel (color, babl_format_with_space ("R'G'B' u8", NULL), c);
g_object_unref (color);
ptr = ifsD->preview_data; ptr = ifsD->preview_data;
for (i = 0; i < width * height; i++) for (i = 0; i < width * height; i++)
{ {
*ptr++ = rc; *ptr++ = c[0];
*ptr++ = gc; *ptr++ = c[1];
*ptr++ = bc; *ptr++ = c[2];
} }
if (ifsD->preview_iterations == 0) if (ifsD->preview_iterations == 0)

View File

@ -341,8 +341,13 @@ image_setup (GimpDrawable *drawable,
} }
else else
{ {
gimp_context_get_background (&background); GeglColor *gegl_color;
gimp_rgb_set_alpha (&background, 1.0);
gegl_color = gimp_context_get_background ();
gimp_color_set_alpha (gegl_color, 1.0);
gegl_color_get_rgba_with_space (gegl_color, &background.r, &background.g, &background.b, &background.a, NULL);
g_object_unref (gegl_color);
} }
if (interactive == TRUE) if (interactive == TRUE)

View File

@ -123,8 +123,13 @@ compute_preview (gint x,
} }
else else
{ {
gimp_context_get_background (&background); GeglColor *gegl_color;
gimp_rgb_set_alpha (&background, 1.0);
gegl_color = gimp_context_get_background ();
gimp_color_set_alpha (gegl_color, 1.0);
gegl_color_get_rgba_with_space (gegl_color, &background.r, &background.g, &background.b, &background.a, NULL);
g_object_unref (gegl_color);
} }
gimp_rgba_set (&lightcheck, gimp_rgba_set (&lightcheck,

View File

@ -481,6 +481,7 @@ static void
init_calculation (GimpDrawable *drawable, init_calculation (GimpDrawable *drawable,
GimpProcedureConfig *config) GimpProcedureConfig *config)
{ {
GeglColor *color;
gdouble k; gdouble k;
gdouble alpha, beta; gdouble alpha, beta;
gdouble angle; gdouble angle;
@ -547,8 +548,12 @@ init_calculation (GimpDrawable *drawable,
/* Colors */ /* Colors */
gimp_context_get_foreground (&fg_color); color = gimp_context_get_foreground ();
gimp_context_get_background (&bg_color); gegl_color_get_rgba_with_space (color, &fg_color.r, &fg_color.g, &fg_color.b, &fg_color.a, NULL);
g_object_unref (color);
color = gimp_context_get_background ();
gegl_color_get_rgba_with_space (color, &bg_color.r, &bg_color.g, &bg_color.b, &bg_color.a, NULL);
g_object_unref (color);
} }
static GimpLayer * static GimpLayer *