app, libgimp*, plug-ins: GimpColorButton now space-invaded.

The invasion extended to some core widgets too, in particular GimpColorPanel (a
subclass of GimpColorButton). There was quite a lot of code depending on these
widgets.
This commit is contained in:
Jehan 2023-11-24 15:35:50 +01:00
parent 8eb56586aa
commit 916d032f67
37 changed files with 626 additions and 535 deletions

View File

@ -125,8 +125,6 @@ colormap_actions_update (GimpActionGroup *group,
gboolean indexed = FALSE;
gboolean drawable_indexed = FALSE;
gint num_colors = 0;
GimpRGB fg;
GimpRGB bg;
if (image)
{
@ -145,16 +143,6 @@ colormap_actions_update (GimpActionGroup *group,
}
}
if (context)
{
GeglColor *color;
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) \
gimp_action_group_set_action_sensitive (group, action, (condition) != 0, NULL)
#define SET_COLOR(action,color) \
@ -171,8 +159,8 @@ colormap_actions_update (GimpActionGroup *group,
SET_SENSITIVE ("colormap-add-color-from-bg",
indexed && num_colors < 256);
SET_COLOR ("colormap-add-color-from-fg", context ? &fg : NULL);
SET_COLOR ("colormap-add-color-from-bg", context ? &bg : NULL);
SET_COLOR ("colormap-add-color-from-fg", context ? gimp_context_get_foreground (context) : NULL);
SET_COLOR ("colormap-add-color-from-bg", context ? gimp_context_get_background (context) : NULL);
SET_SENSITIVE ("colormap-selection-replace",
drawable_indexed && num_colors > 0);

View File

@ -383,10 +383,7 @@ edit_actions_foreground_changed (GimpContext *context,
GeglColor *color,
GimpActionGroup *group)
{
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);
gimp_action_group_set_action_color (group, "edit-fill-fg", color, FALSE);
}
static void
@ -394,10 +391,7 @@ edit_actions_background_changed (GimpContext *context,
GeglColor *color,
GimpActionGroup *group)
{
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);
gimp_action_group_set_action_color (group, "edit-fill-bg", color, FALSE);
}
static void

View File

@ -465,12 +465,11 @@ gradient_editor_actions_update (GimpActionGroup *group,
GimpDataEditor *data_editor = GIMP_DATA_EDITOR (data);
GimpGradient *gradient;
gboolean editable = FALSE;
GeglColor *color;
GimpRGB left_color;
GimpRGB right_color;
GimpRGB left_seg_color;
GimpRGB right_seg_color;
GimpRGB fg;
GimpRGB bg;
gboolean blending_equal = TRUE;
gboolean coloring_equal = TRUE;
gboolean left_editable = TRUE;
@ -546,16 +545,6 @@ gradient_editor_actions_update (GimpActionGroup *group,
delete = (editor->control_sel_l->prev || editor->control_sel_r->next);
}
if (data_editor->context)
{
GeglColor *color;
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
* insensitive. prevents the gradient from being modified while a
* dialog is running. bug #161411 --mitch
@ -617,23 +606,25 @@ gradient_editor_actions_update (GimpActionGroup *group,
SET_SENSITIVE ("gradient-editor-load-left-left-neighbor", editable);
SET_SENSITIVE ("gradient-editor-load-left-right-endpoint", editable);
color = gegl_color_new (NULL);
if (gradient)
{
SET_COLOR ("gradient-editor-left-color",
&left_color, FALSE);
SET_COLOR ("gradient-editor-load-left-left-neighbor",
&left_seg_color, FALSE);
SET_COLOR ("gradient-editor-load-left-right-endpoint",
&right_color, FALSE);
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), &left_color);
SET_COLOR ("gradient-editor-left-color", color, FALSE);
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), &left_seg_color);
SET_COLOR ("gradient-editor-load-left-left-neighbor", color, FALSE);
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), &right_color);
SET_COLOR ("gradient-editor-load-left-right-endpoint", color, FALSE);
}
SET_SENSITIVE ("gradient-editor-load-left-fg", left_editable);
SET_SENSITIVE ("gradient-editor-load-left-bg", left_editable);
SET_COLOR ("gradient-editor-load-left-fg",
data_editor->context ? &fg : NULL, FALSE);
data_editor->context ? gimp_context_get_foreground (data_editor->context) : NULL, FALSE);
SET_COLOR ("gradient-editor-load-left-bg",
data_editor->context ? &bg : NULL, FALSE);
data_editor->context ? gimp_context_get_background (data_editor->context) : NULL, FALSE);
SET_SENSITIVE ("gradient-editor-load-left-01", left_editable);
SET_SENSITIVE ("gradient-editor-load-left-02", left_editable);
@ -646,16 +637,26 @@ gradient_editor_actions_update (GimpActionGroup *group,
SET_SENSITIVE ("gradient-editor-load-left-09", left_editable);
SET_SENSITIVE ("gradient-editor-load-left-10", left_editable);
SET_COLOR ("gradient-editor-load-left-01", &editor->saved_colors[0], TRUE);
SET_COLOR ("gradient-editor-load-left-02", &editor->saved_colors[1], TRUE);
SET_COLOR ("gradient-editor-load-left-03", &editor->saved_colors[2], TRUE);
SET_COLOR ("gradient-editor-load-left-04", &editor->saved_colors[3], TRUE);
SET_COLOR ("gradient-editor-load-left-05", &editor->saved_colors[4], TRUE);
SET_COLOR ("gradient-editor-load-left-06", &editor->saved_colors[5], TRUE);
SET_COLOR ("gradient-editor-load-left-07", &editor->saved_colors[6], TRUE);
SET_COLOR ("gradient-editor-load-left-08", &editor->saved_colors[7], TRUE);
SET_COLOR ("gradient-editor-load-left-09", &editor->saved_colors[8], TRUE);
SET_COLOR ("gradient-editor-load-left-10", &editor->saved_colors[9], TRUE);
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), &editor->saved_colors[0]);
SET_COLOR ("gradient-editor-load-left-01", color, TRUE);
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), &editor->saved_colors[1]);
SET_COLOR ("gradient-editor-load-left-02", color, TRUE);
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), &editor->saved_colors[2]);
SET_COLOR ("gradient-editor-load-left-03", color, TRUE);
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), &editor->saved_colors[3]);
SET_COLOR ("gradient-editor-load-left-04", color, TRUE);
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), &editor->saved_colors[4]);
SET_COLOR ("gradient-editor-load-left-05", color, TRUE);
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), &editor->saved_colors[5]);
SET_COLOR ("gradient-editor-load-left-06", color, TRUE);
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), &editor->saved_colors[6]);
SET_COLOR ("gradient-editor-load-left-07", color, TRUE);
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), &editor->saved_colors[7]);
SET_COLOR ("gradient-editor-load-left-08", color, TRUE);
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), &editor->saved_colors[8]);
SET_COLOR ("gradient-editor-load-left-09", color, TRUE);
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), &editor->saved_colors[9]);
SET_COLOR ("gradient-editor-load-left-10", color, TRUE);
SET_SENSITIVE ("gradient-editor-save-left-01", gradient);
SET_SENSITIVE ("gradient-editor-save-left-02", gradient);
@ -668,16 +669,26 @@ gradient_editor_actions_update (GimpActionGroup *group,
SET_SENSITIVE ("gradient-editor-save-left-09", gradient);
SET_SENSITIVE ("gradient-editor-save-left-10", gradient);
SET_COLOR ("gradient-editor-save-left-01", &editor->saved_colors[0], TRUE);
SET_COLOR ("gradient-editor-save-left-02", &editor->saved_colors[1], TRUE);
SET_COLOR ("gradient-editor-save-left-03", &editor->saved_colors[2], TRUE);
SET_COLOR ("gradient-editor-save-left-04", &editor->saved_colors[3], TRUE);
SET_COLOR ("gradient-editor-save-left-05", &editor->saved_colors[4], TRUE);
SET_COLOR ("gradient-editor-save-left-06", &editor->saved_colors[5], TRUE);
SET_COLOR ("gradient-editor-save-left-07", &editor->saved_colors[6], TRUE);
SET_COLOR ("gradient-editor-save-left-08", &editor->saved_colors[7], TRUE);
SET_COLOR ("gradient-editor-save-left-09", &editor->saved_colors[8], TRUE);
SET_COLOR ("gradient-editor-save-left-10", &editor->saved_colors[9], TRUE);
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), &editor->saved_colors[0]);
SET_COLOR ("gradient-editor-save-left-01", color, TRUE);
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), &editor->saved_colors[1]);
SET_COLOR ("gradient-editor-save-left-02", color, TRUE);
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), &editor->saved_colors[2]);
SET_COLOR ("gradient-editor-save-left-03", color, TRUE);
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), &editor->saved_colors[3]);
SET_COLOR ("gradient-editor-save-left-04", color, TRUE);
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), &editor->saved_colors[4]);
SET_COLOR ("gradient-editor-save-left-05", color, TRUE);
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), &editor->saved_colors[5]);
SET_COLOR ("gradient-editor-save-left-06", color, TRUE);
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), &editor->saved_colors[6]);
SET_COLOR ("gradient-editor-save-left-07", color, TRUE);
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), &editor->saved_colors[7]);
SET_COLOR ("gradient-editor-save-left-08", color, TRUE);
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), &editor->saved_colors[8]);
SET_COLOR ("gradient-editor-save-left-09", color, TRUE);
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), &editor->saved_colors[9]);
SET_COLOR ("gradient-editor-save-left-10", color, TRUE);
SET_SENSITIVE ("gradient-editor-right-color-fixed", editable);
SET_SENSITIVE ("gradient-editor-right-color-foreground", editable);
@ -713,21 +724,21 @@ gradient_editor_actions_update (GimpActionGroup *group,
if (gradient)
{
SET_COLOR ("gradient-editor-right-color",
&right_color, FALSE);
SET_COLOR ("gradient-editor-load-right-right-neighbor",
&right_seg_color, FALSE);
SET_COLOR ("gradient-editor-load-right-left-endpoint",
&left_color, FALSE);
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), &right_color);
SET_COLOR ("gradient-editor-right-color", color, FALSE);
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), &right_seg_color);
SET_COLOR ("gradient-editor-load-right-right-neighbor", color, FALSE);
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), &left_color);
SET_COLOR ("gradient-editor-load-right-left-endpoint", color, FALSE);
}
SET_SENSITIVE ("gradient-editor-load-right-fg", right_editable);
SET_SENSITIVE ("gradient-editor-load-right-bg", right_editable);
SET_COLOR ("gradient-editor-load-right-fg",
data_editor->context ? &fg : NULL, FALSE);
data_editor->context ? gimp_context_get_foreground (data_editor->context) : NULL, FALSE);
SET_COLOR ("gradient-editor-load-right-bg",
data_editor->context ? &bg : NULL, FALSE);
data_editor->context ? gimp_context_get_background (data_editor->context) : NULL, FALSE);
SET_SENSITIVE ("gradient-editor-load-right-01", right_editable);
SET_SENSITIVE ("gradient-editor-load-right-02", right_editable);
@ -740,16 +751,26 @@ gradient_editor_actions_update (GimpActionGroup *group,
SET_SENSITIVE ("gradient-editor-load-right-09", right_editable);
SET_SENSITIVE ("gradient-editor-load-right-10", right_editable);
SET_COLOR ("gradient-editor-load-right-01", &editor->saved_colors[0], TRUE);
SET_COLOR ("gradient-editor-load-right-02", &editor->saved_colors[1], TRUE);
SET_COLOR ("gradient-editor-load-right-03", &editor->saved_colors[2], TRUE);
SET_COLOR ("gradient-editor-load-right-04", &editor->saved_colors[3], TRUE);
SET_COLOR ("gradient-editor-load-right-05", &editor->saved_colors[4], TRUE);
SET_COLOR ("gradient-editor-load-right-06", &editor->saved_colors[5], TRUE);
SET_COLOR ("gradient-editor-load-right-07", &editor->saved_colors[6], TRUE);
SET_COLOR ("gradient-editor-load-right-08", &editor->saved_colors[7], TRUE);
SET_COLOR ("gradient-editor-load-right-09", &editor->saved_colors[8], TRUE);
SET_COLOR ("gradient-editor-load-right-10", &editor->saved_colors[9], TRUE);
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), &editor->saved_colors[0]);
SET_COLOR ("gradient-editor-load-right-01", color, TRUE);
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), &editor->saved_colors[1]);
SET_COLOR ("gradient-editor-load-right-02", color, TRUE);
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), &editor->saved_colors[2]);
SET_COLOR ("gradient-editor-load-right-03", color, TRUE);
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), &editor->saved_colors[3]);
SET_COLOR ("gradient-editor-load-right-04", color, TRUE);
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), &editor->saved_colors[4]);
SET_COLOR ("gradient-editor-load-right-05", color, TRUE);
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), &editor->saved_colors[5]);
SET_COLOR ("gradient-editor-load-right-06", color, TRUE);
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), &editor->saved_colors[6]);
SET_COLOR ("gradient-editor-load-right-07", color, TRUE);
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), &editor->saved_colors[7]);
SET_COLOR ("gradient-editor-load-right-08", color, TRUE);
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), &editor->saved_colors[8]);
SET_COLOR ("gradient-editor-load-right-09", color, TRUE);
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), &editor->saved_colors[9]);
SET_COLOR ("gradient-editor-load-right-10", color, TRUE);
SET_SENSITIVE ("gradient-editor-save-right-01", gradient);
SET_SENSITIVE ("gradient-editor-save-right-02", gradient);
@ -762,16 +783,26 @@ gradient_editor_actions_update (GimpActionGroup *group,
SET_SENSITIVE ("gradient-editor-save-right-09", gradient);
SET_SENSITIVE ("gradient-editor-save-right-10", gradient);
SET_COLOR ("gradient-editor-save-right-01", &editor->saved_colors[0], TRUE);
SET_COLOR ("gradient-editor-save-right-02", &editor->saved_colors[1], TRUE);
SET_COLOR ("gradient-editor-save-right-03", &editor->saved_colors[2], TRUE);
SET_COLOR ("gradient-editor-save-right-04", &editor->saved_colors[3], TRUE);
SET_COLOR ("gradient-editor-save-right-05", &editor->saved_colors[4], TRUE);
SET_COLOR ("gradient-editor-save-right-06", &editor->saved_colors[5], TRUE);
SET_COLOR ("gradient-editor-save-right-07", &editor->saved_colors[6], TRUE);
SET_COLOR ("gradient-editor-save-right-08", &editor->saved_colors[7], TRUE);
SET_COLOR ("gradient-editor-save-right-09", &editor->saved_colors[8], TRUE);
SET_COLOR ("gradient-editor-save-right-10", &editor->saved_colors[9], TRUE);
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), &editor->saved_colors[0]);
SET_COLOR ("gradient-editor-save-right-01", color, TRUE);
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), &editor->saved_colors[1]);
SET_COLOR ("gradient-editor-save-right-02", color, TRUE);
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), &editor->saved_colors[2]);
SET_COLOR ("gradient-editor-save-right-03", color, TRUE);
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), &editor->saved_colors[3]);
SET_COLOR ("gradient-editor-save-right-04", color, TRUE);
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), &editor->saved_colors[4]);
SET_COLOR ("gradient-editor-save-right-05", color, TRUE);
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), &editor->saved_colors[5]);
SET_COLOR ("gradient-editor-save-right-06", color, TRUE);
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), &editor->saved_colors[6]);
SET_COLOR ("gradient-editor-save-right-07", color, TRUE);
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), &editor->saved_colors[7]);
SET_COLOR ("gradient-editor-save-right-08", color, TRUE);
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), &editor->saved_colors[8]);
SET_COLOR ("gradient-editor-save-right-09", color, TRUE);
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), &editor->saved_colors[9]);
SET_COLOR ("gradient-editor-save-right-10", color, TRUE);
SET_SENSITIVE ("gradient-editor-flip", editable);
SET_SENSITIVE ("gradient-editor-replicate", editable);
@ -906,4 +937,6 @@ gradient_editor_actions_update (GimpActionGroup *group,
#undef SET_LABEL
#undef SET_SENSITIVE
#undef SET_VISIBLE
g_object_unref (color);
}

View File

@ -55,10 +55,14 @@ items_actions_setup (GimpActionGroup *group,
}
else
{
GimpRGB color;
GeglColor *color;
GimpRGB rgb;
gimp_get_color_tag_color (value->value, &color, FALSE);
gimp_action_group_set_action_color (group, action, &color, FALSE);
gimp_get_color_tag_color (value->value, &rgb, FALSE);
color = gegl_color_new (NULL);
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), &rgb);
gimp_action_group_set_action_color (group, action, color, FALSE);
g_object_unref (color);
}
}

View File

@ -131,8 +131,6 @@ palette_editor_actions_update (GimpActionGroup *group,
GimpDataEditor *data_editor = GIMP_DATA_EDITOR (user_data);
GimpData *data;
gboolean editable = FALSE;
GimpRGB fg;
GimpRGB bg;
gboolean edit_active = FALSE;
data = data_editor->data;
@ -143,16 +141,6 @@ palette_editor_actions_update (GimpActionGroup *group,
editable = TRUE;
}
if (data_editor->context)
{
GeglColor *color;
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);
#define SET_SENSITIVE(action,condition) \
@ -168,8 +156,8 @@ palette_editor_actions_update (GimpActionGroup *group,
SET_SENSITIVE ("palette-editor-new-color-fg", editable);
SET_SENSITIVE ("palette-editor-new-color-bg", editable);
SET_COLOR ("palette-editor-new-color-fg", data_editor->context ? &fg : NULL);
SET_COLOR ("palette-editor-new-color-bg", data_editor->context ? &bg : NULL);
SET_COLOR ("palette-editor-new-color-fg", data_editor->context ? gimp_context_get_foreground (data_editor->context) : NULL);
SET_COLOR ("palette-editor-new-color-bg", data_editor->context ? gimp_context_get_background (data_editor->context) : NULL);
SET_SENSITIVE ("palette-editor-zoom-out", data);
SET_SENSITIVE ("palette-editor-zoom-in", data);

View File

@ -125,13 +125,8 @@ quick_mask_actions_update (GimpActionGroup *group,
SET_SENSITIVE ("quick-mask-configure", image);
if (image)
{
GimpRGB rgb;
gegl_color_get_pixel (quick_mask_color, babl_format ("R'G'B'A double"), &rgb);
SET_COLOR ("quick-mask-configure", &rgb);
}
if (quick_mask_color)
SET_COLOR ("quick-mask-configure", quick_mask_color);
#undef SET_SENSITIVE
#undef SET_ACTIVE

View File

@ -1053,10 +1053,8 @@ view_actions_check_type_notify (GimpDisplayConfig *config,
GParamSpec *pspec,
GimpActionGroup *group)
{
GimpRGB rgb;
gegl_color_get_pixel ((GeglColor *) gimp_render_check_color1 (), babl_format ("R'G'B'A double"), &rgb);
gimp_action_group_set_action_color (group, "view-padding-color-light-check", &rgb, FALSE);
gegl_color_get_pixel ((GeglColor *) gimp_render_check_color2 (), babl_format ("R'G'B'A double"), &rgb);
gimp_action_group_set_action_color (group, "view-padding-color-dark-check", &rgb, FALSE);
gimp_action_group_set_action_color (group, "view-padding-color-light-check",
(GeglColor *) gimp_render_check_color1 (), FALSE);
gimp_action_group_set_action_color (group, "view-padding-color-dark-check",
(GeglColor *) gimp_render_check_color2 (), FALSE);
}

View File

@ -148,8 +148,7 @@ channel_options_dialog_new (GimpImage *image,
item_options_dialog_add_widget (dialog,
opacity_label, scale);
private->color_panel = gimp_color_panel_new (color_label,
&rgb,
private->color_panel = gimp_color_panel_new (color_label, channel_color,
GIMP_COLOR_AREA_LARGE_CHECKS,
24, 24);
gimp_color_panel_set_context (GIMP_COLOR_PANEL (private->color_panel),
@ -201,12 +200,10 @@ channel_options_dialog_callback (GtkWidget *dialog,
gpointer user_data)
{
ChannelOptionsDialog *private = user_data;
GeglColor *color = gegl_color_new (NULL);
GimpRGB rgb;
GeglColor *color;
gboolean save_selection = FALSE;
gimp_color_button_get_color (GIMP_COLOR_BUTTON (private->color_panel), &rgb);
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), &rgb);
color = gimp_color_button_get_color (GIMP_COLOR_BUTTON (private->color_panel));
if (private->save_sel_toggle)
save_selection =
@ -225,25 +222,31 @@ channel_options_dialog_callback (GtkWidget *dialog,
item_lock_position,
item_lock_visibility,
private->user_data);
g_object_unref (color);
}
static void
channel_options_opacity_changed (GtkAdjustment *adjustment,
GimpColorButton *color_button)
{
GimpRGB color;
GeglColor *color;
gimp_color_button_get_color (color_button, &color);
gimp_rgb_set_alpha (&color, gtk_adjustment_get_value (adjustment) / 100.0);
gimp_color_button_set_color (color_button, &color);
color = gimp_color_button_get_color (color_button);
gimp_color_set_alpha (color, gtk_adjustment_get_value (adjustment) / 100.0);
gimp_color_button_set_color (color_button, color);
g_object_unref (color);
}
static void
channel_options_color_changed (GimpColorButton *button,
GtkAdjustment *adjustment)
{
GimpRGB color;
GeglColor *color;
gdouble rgba[4];
gimp_color_button_get_color (button, &color);
gtk_adjustment_set_value (adjustment, color.a * 100.0);
color = gimp_color_button_get_color (button);
gegl_color_get_pixel (color, babl_format ("R'G'B'A double"), rgba);
gtk_adjustment_set_value (adjustment, rgba[3] * 100.0);
g_object_unref (color);
}

View File

@ -115,7 +115,7 @@ gimp_display_shell_set_action_active (GimpDisplayShell *shell,
void
gimp_display_shell_set_action_color (GimpDisplayShell *shell,
const gchar *action,
const GimpRGB *color)
GeglColor *color)
{
GimpImageWindow *window;
GimpContext *context;

View File

@ -27,7 +27,7 @@ void gimp_display_shell_set_action_active (GimpDisplayShell *shell,
gboolean active);
void gimp_display_shell_set_action_color (GimpDisplayShell *shell,
const gchar *action,
const GimpRGB *color);
GeglColor *color);
#endif /* __GIMP_DISPLAY_SHELL_ACTIONS_H__ */

View File

@ -400,7 +400,8 @@ gimp_gradient_tool_editor_color_entry_color_changed (GimpColorButton *button,
GimpGradientOptions *options = GIMP_GRADIENT_TOOL_GET_OPTIONS (gradient_tool);
GimpPaintOptions *paint_options = GIMP_PAINT_OPTIONS (options);
gint selection;
GimpRGB color;
GeglColor *color;
GimpRGB rgb;
Direction direction;
GtkWidget *chain_button;
GimpGradientSegment *seg;
@ -411,7 +412,9 @@ gimp_gradient_tool_editor_color_entry_color_changed (GimpColorButton *button,
selection =
gimp_tool_line_get_selection (GIMP_TOOL_LINE (gradient_tool->widget));
gimp_color_button_get_color (button, &color);
color = gimp_color_button_get_color (button);
gegl_color_get_pixel (color, babl_format ("R'G'B'A double"), &rgb);
g_object_unref (color);
direction =
GPOINTER_TO_INT (g_object_get_data (G_OBJECT (button),
@ -442,12 +445,12 @@ gimp_gradient_tool_editor_color_entry_color_changed (GimpColorButton *button,
switch (selection)
{
case GIMP_TOOL_LINE_HANDLE_START:
seg->left_color = color;
seg->left_color = rgb;
seg->left_color_type = GIMP_GRADIENT_COLOR_FIXED;
break;
case GIMP_TOOL_LINE_HANDLE_END:
seg->right_color = color;
seg->right_color = rgb;
seg->right_color_type = GIMP_GRADIENT_COLOR_FIXED;
break;
@ -456,7 +459,7 @@ gimp_gradient_tool_editor_color_entry_color_changed (GimpColorButton *button,
(chain_button &&
gimp_chain_button_get_active (GIMP_CHAIN_BUTTON (chain_button))))
{
seg->right_color = color;
seg->right_color = rgb;
seg->right_color_type = GIMP_GRADIENT_COLOR_FIXED;
}
@ -464,7 +467,7 @@ gimp_gradient_tool_editor_color_entry_color_changed (GimpColorButton *button,
(chain_button &&
gimp_chain_button_get_active (GIMP_CHAIN_BUTTON (chain_button))))
{
seg->next->left_color = color;
seg->next->left_color = rgb;
seg->next->left_color_type = GIMP_GRADIENT_COLOR_FIXED;
}
}
@ -1202,14 +1205,15 @@ gimp_gradient_tool_editor_color_entry_new (GimpGradientTool *gradient_tool,
GtkWidget *hbox;
GtkWidget *button;
GtkWidget *combo;
GimpRGB color = {};
GeglColor *color = gegl_color_new ("transparent");
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2);
/* the color panel */
*color_panel = button = gimp_color_panel_new (title, &color,
*color_panel = button = gimp_color_panel_new (title, color,
GIMP_COLOR_AREA_SMALL_CHECKS,
24, 24);
g_object_unref (color);
gimp_color_button_set_update (GIMP_COLOR_BUTTON (button), TRUE);
gimp_color_panel_set_context (GIMP_COLOR_PANEL (button), context);
gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
@ -1570,7 +1574,8 @@ gimp_gradient_tool_editor_update_endpoint_gui (GimpGradientTool *gradient_tool,
const gchar *title;
gdouble x;
gdouble y;
GimpRGB color;
GeglColor *color;
GimpRGB rgb;
GimpGradientColor color_type;
editable = gimp_gradient_tool_editor_is_gradient_editable (gradient_tool);
@ -1618,7 +1623,7 @@ gimp_gradient_tool_editor_update_endpoint_gui (GimpGradientTool *gradient_tool,
title = _("Start Endpoint");
gimp_gradient_segment_get_left_flat_color (gradient_tool->gradient, context,
seg, &color);
seg, &rgb);
color_type = seg->left_color_type;
break;
@ -1626,7 +1631,7 @@ gimp_gradient_tool_editor_update_endpoint_gui (GimpGradientTool *gradient_tool,
title = _("End Endpoint");
gimp_gradient_segment_get_right_flat_color (gradient_tool->gradient, context,
seg, &color);
seg, &rgb);
color_type = seg->right_color_type;
break;
@ -1639,8 +1644,11 @@ gimp_gradient_tool_editor_update_endpoint_gui (GimpGradientTool *gradient_tool,
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (gradient_tool->endpoint_se), 0, x);
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (gradient_tool->endpoint_se), 1, y);
color = gegl_color_new (NULL);
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), &rgb);
gimp_color_button_set_color (
GIMP_COLOR_BUTTON (gradient_tool->endpoint_color_panel), &color);
GIMP_COLOR_BUTTON (gradient_tool->endpoint_color_panel), color);
g_object_unref (color);
gimp_int_combo_box_set_active (
GIMP_INT_COMBO_BOX (gradient_tool->endpoint_type_combo), color_type);
@ -1663,6 +1671,7 @@ gimp_gradient_tool_editor_update_stop_gui (GimpGradientTool *gradient_tool,
gdouble min;
gdouble max;
gdouble value;
GeglColor *color;
GimpRGB left_color;
GimpGradientColor left_color_type;
GimpRGB right_color;
@ -1697,13 +1706,17 @@ gimp_gradient_tool_editor_update_stop_gui (GimpGradientTool *gradient_tool,
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (gradient_tool->stop_se),
0, 100.0 * value);
color = gegl_color_new (NULL);
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), &left_color);
gimp_color_button_set_color (
GIMP_COLOR_BUTTON (gradient_tool->stop_left_color_panel), &left_color);
GIMP_COLOR_BUTTON (gradient_tool->stop_left_color_panel), color);
gimp_int_combo_box_set_active (
GIMP_INT_COMBO_BOX (gradient_tool->stop_left_type_combo), left_color_type);
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), &right_color);
gimp_color_button_set_color (
GIMP_COLOR_BUTTON (gradient_tool->stop_right_color_panel), &right_color);
GIMP_COLOR_BUTTON (gradient_tool->stop_right_color_panel), color);
gimp_int_combo_box_set_active (
GIMP_INT_COMBO_BOX (gradient_tool->stop_right_type_combo), right_color_type);
@ -1718,6 +1731,7 @@ gimp_gradient_tool_editor_update_stop_gui (GimpGradientTool *gradient_tool,
editable);
g_free (title);
g_object_unref (color);
gtk_widget_show (gradient_tool->stop_editor);
}

View File

@ -76,7 +76,7 @@ struct _GimpActionPrivate
gchar *menu_path;
GimpRGB *color;
GeglColor *color;
GimpViewable *viewable;
PangoEllipsizeMode ellipsize;
gint max_width_chars;
@ -114,8 +114,6 @@ static guint action_signals[LAST_SIGNAL];
static void
gimp_action_default_init (GimpActionInterface *iface)
{
GimpRGB black;
action_signals[ACTIVATE] =
g_signal_new ("activate",
G_TYPE_FROM_INTERFACE (iface),
@ -182,12 +180,11 @@ gimp_action_default_init (GimpActionInterface *iface)
GIMP_PARAM_READWRITE |
G_PARAM_EXPLICIT_NOTIFY));
gimp_rgba_set (&black, 0.0, 0.0, 0.0, GIMP_OPACITY_OPAQUE);
g_object_interface_install_property (iface,
gimp_param_spec_rgb ("color",
NULL, NULL,
TRUE, &black,
GIMP_PARAM_READWRITE));
gegl_param_spec_color_from_string ("color",
NULL, NULL,
"black",
GIMP_PARAM_READWRITE));
g_object_interface_install_property (iface,
g_param_spec_object ("viewable",
NULL, NULL,
@ -899,7 +896,7 @@ gimp_action_get_property (GObject *object,
break;
case GIMP_ACTION_PROP_COLOR:
g_value_set_boxed (value, priv->color);
g_value_set_object (value, priv->color);
break;
case GIMP_ACTION_PROP_VIEWABLE:
g_value_set_object (value, priv->viewable);
@ -959,8 +956,10 @@ gimp_action_set_property (GObject *object,
break;
case GIMP_ACTION_PROP_COLOR:
g_clear_pointer (&priv->color, g_free);
priv->color = g_value_dup_boxed (value);
g_clear_object (&priv->color);
if (g_value_get_object (value))
priv->color = gegl_color_duplicate (g_value_get_object (value));
set_proxy = TRUE;
break;
case GIMP_ACTION_PROP_VIEWABLE:
@ -1009,26 +1008,21 @@ gimp_action_set_proxy (GimpAction *action,
{
if (priv->color)
{
GeglColor *color;
if (GTK_IS_MENU_ITEM (proxy))
proxy_image = gimp_menu_item_get_image (GTK_MENU_ITEM (proxy));
else
proxy_image = gtk_tool_button_get_label_widget (GTK_TOOL_BUTTON (proxy));
color = gegl_color_new (NULL);
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), priv->color);
if (GIMP_IS_COLOR_AREA (proxy_image))
{
gimp_color_area_set_color (GIMP_COLOR_AREA (proxy_image), color);
gimp_color_area_set_color (GIMP_COLOR_AREA (proxy_image), priv->color);
proxy_image = NULL;
}
else
{
gint width, height;
proxy_image = gimp_color_area_new (color, GIMP_COLOR_AREA_SMALL_CHECKS, 0);
proxy_image = gimp_color_area_new (priv->color, GIMP_COLOR_AREA_SMALL_CHECKS, 0);
gimp_color_area_set_draw_border (GIMP_COLOR_AREA (proxy_image), TRUE);
if (priv->context)
@ -1039,8 +1033,6 @@ gimp_action_set_proxy (GimpAction *action,
gtk_widget_set_size_request (proxy_image, width, height);
gtk_widget_show (proxy_image);
}
g_object_unref (color);
}
else if (priv->viewable)
{
@ -1296,7 +1288,7 @@ gimp_action_private_finalize (GimpActionPrivate *priv)
{
g_clear_pointer (&priv->disable_reason, g_free);
g_clear_object (&priv->context);
g_clear_pointer (&priv->color, g_free);
g_clear_object (&priv->color);
g_clear_object (&priv->viewable);
g_free (priv->label);

View File

@ -1161,7 +1161,7 @@ gimp_action_group_get_action_tooltip (GimpActionGroup *group,
void
gimp_action_group_set_action_color (GimpActionGroup *group,
const gchar *action_name,
const GimpRGB *color,
GeglColor *color,
gboolean set_label)
{
GimpAction *action;
@ -1192,10 +1192,18 @@ gimp_action_group_set_action_color (GimpActionGroup *group,
gchar *label;
if (color)
label = g_strdup_printf (_("RGBA (%0.3f, %0.3f, %0.3f, %0.3f)"),
color->r, color->g, color->b, color->a);
{
gfloat rgba[4];
gegl_color_get_pixel (color, babl_format ("R'G'B'A float"), rgba);
label = g_strdup_printf (_("sRGB+A (%0.3f, %0.3f, %0.3f, %0.3f)"),
rgba[0], rgba[1], rgba[2], rgba[3]);
}
else
label = g_strdup (_("(none)"));
{
label = g_strdup (_("(none)"));
}
g_object_set (action,
"color", color,

View File

@ -242,7 +242,7 @@ const gchar * gimp_action_group_get_action_tooltip (GimpActionGroup *group,
const gchar *action_name);
void gimp_action_group_set_action_color (GimpActionGroup *group,
const gchar *action_name,
const GimpRGB *color,
GeglColor *color,
gboolean set_label);
void gimp_action_group_set_action_viewable (GimpActionGroup *group,
const gchar *action_name,

View File

@ -176,9 +176,11 @@ static void
gimp_color_panel_clicked (GtkButton *button)
{
GimpColorPanel *panel = GIMP_COLOR_PANEL (button);
GimpRGB color;
GeglColor *color;
GimpRGB rgb;
gimp_color_button_get_color (GIMP_COLOR_BUTTON (button), &color);
color = gimp_color_button_get_color (GIMP_COLOR_BUTTON (button));
gegl_color_get_pixel (color, babl_format ("R'G'B'A double"), &rgb);
if (! panel->color_dialog)
{
@ -190,7 +192,7 @@ gimp_color_panel_clicked (GtkButton *button)
NULL, NULL,
GTK_WIDGET (button),
NULL, NULL,
&color,
&rgb,
gimp_color_button_get_update (color_button),
gimp_color_button_has_alpha (color_button));
@ -205,10 +207,12 @@ gimp_color_panel_clicked (GtkButton *button)
else
{
gimp_color_dialog_set_color (GIMP_COLOR_DIALOG (panel->color_dialog),
&color);
&rgb);
}
gtk_window_present (GTK_WINDOW (panel->color_dialog));
g_object_unref (color);
}
static GType
@ -222,7 +226,7 @@ gimp_color_panel_get_action_type (GimpColorButton *button)
GtkWidget *
gimp_color_panel_new (const gchar *title,
const GimpRGB *color,
GeglColor *color,
GimpColorAreaType type,
gint width,
gint height)
@ -245,22 +249,27 @@ static void
gimp_color_panel_color_changed (GimpColorButton *button)
{
GimpColorPanel *panel = GIMP_COLOR_PANEL (button);
GimpRGB color;
if (panel->color_dialog)
{
GimpRGB dialog_color;
GeglColor *color;
GimpRGB dialog_color;
GimpRGB rgb;
color = gimp_color_button_get_color (GIMP_COLOR_BUTTON (button));
gegl_color_get_pixel (color, babl_format ("R'G'B'A double"), &rgb);
gimp_color_button_get_color (GIMP_COLOR_BUTTON (button), &color);
gimp_color_dialog_get_color (GIMP_COLOR_DIALOG (panel->color_dialog),
&dialog_color);
if (gimp_rgba_distance (&color, &dialog_color) > RGBA_EPSILON ||
color.a != dialog_color.a)
if (gimp_rgba_distance (&rgb, &dialog_color) > RGBA_EPSILON ||
rgb.a != dialog_color.a)
{
gimp_color_dialog_set_color (GIMP_COLOR_DIALOG (panel->color_dialog),
&color);
&rgb);
}
g_object_unref (color);
}
}
@ -295,10 +304,14 @@ gimp_color_panel_dialog_response (GimpColorPanel *panel,
static void
gimp_color_panel_dialog_update (GimpColorDialog *dialog,
const GimpRGB *color,
const GimpRGB *rgb,
GimpColorDialogState state,
GimpColorPanel *panel)
{
GeglColor *color = gegl_color_new (NULL);
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), rgb);
switch (state)
{
case GIMP_COLOR_DIALOG_UPDATE:
@ -318,4 +331,6 @@ gimp_color_panel_dialog_update (GimpColorDialog *dialog,
state);
break;
}
g_object_unref (color);
}

View File

@ -50,7 +50,7 @@ struct _GimpColorPanelClass
GType gimp_color_panel_get_type (void) G_GNUC_CONST;
GtkWidget * gimp_color_panel_new (const gchar *title,
const GimpRGB *color,
GeglColor *color,
GimpColorAreaType type,
gint width,
gint height);

View File

@ -376,6 +376,7 @@ gimp_prop_color_button_new (GObject *config,
{
GParamSpec *param_spec;
GtkWidget *button;
GeglColor *color;
GimpRGB *value;
param_spec = check_param_spec_w (config, property_name,
@ -390,8 +391,11 @@ gimp_prop_color_button_new (GObject *config,
property_name, &value,
NULL);
button = gimp_color_panel_new (title, value, type, width, height);
color = gegl_color_new (NULL);
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), value);
button = gimp_color_panel_new (title, color, type, width, height);
g_free (value);
g_object_unref (color);
set_param_spec (G_OBJECT (button), button, param_spec);
@ -440,7 +444,6 @@ gimp_prop_gegl_color_button_new (GObject *config,
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);
@ -454,10 +457,7 @@ gimp_prop_gegl_color_button_new (GObject *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);
button = gimp_color_panel_new (title, color, type, width, height);
g_clear_object (&color);
set_param_spec (G_OBJECT (button), button, param_spec);
@ -481,25 +481,29 @@ gimp_prop_color_button_callback (GtkWidget *button,
GObject *config)
{
GParamSpec *param_spec;
GimpRGB value;
GeglColor *color;
GimpRGB rgb;
param_spec = get_param_spec (G_OBJECT (button));
if (! param_spec)
return;
gimp_color_button_get_color (GIMP_COLOR_BUTTON (button), &value);
color = gimp_color_button_get_color (GIMP_COLOR_BUTTON (button));
gegl_color_get_pixel (color, babl_format ("R'G'B'A double"), &rgb);
g_signal_handlers_block_by_func (config,
gimp_prop_color_button_notify,
button);
g_object_set (config,
param_spec->name, &value,
param_spec->name, &rgb,
NULL);
g_signal_handlers_unblock_by_func (config,
gimp_prop_color_button_notify,
button);
g_object_unref (color);
}
static void
@ -507,19 +511,23 @@ gimp_prop_color_button_notify (GObject *config,
GParamSpec *param_spec,
GtkWidget *button)
{
GimpRGB *value;
GeglColor *color;
GimpRGB *rgb;
g_object_get (config,
param_spec->name, &value,
param_spec->name, &rgb,
NULL);
g_signal_handlers_block_by_func (button,
gimp_prop_color_button_callback,
config);
gimp_color_button_set_color (GIMP_COLOR_BUTTON (button), value);
color = gegl_color_new (NULL);
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), rgb);
gimp_color_button_set_color (GIMP_COLOR_BUTTON (button), color);
g_free (value);
g_object_unref (color);
g_free (rgb);
g_signal_handlers_unblock_by_func (button,
gimp_prop_color_button_callback,
@ -532,29 +540,24 @@ gimp_prop_gegl_color_button_callback (GtkWidget *button,
{
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,
gimp_prop_gegl_color_button_notify,
button);
color = gimp_color_button_get_color (GIMP_COLOR_BUTTON (button));
g_object_set (config,
param_spec->name, color,
NULL);
g_object_unref (color);
g_signal_handlers_unblock_by_func (config,
gimp_prop_color_button_notify,
gimp_prop_gegl_color_button_notify,
button);
g_object_unref (color);
}
static void
@ -563,7 +566,6 @@ gimp_prop_gegl_color_button_notify (GObject *config,
GtkWidget *button)
{
GeglColor *color;
GimpRGB value;
g_object_get (config,
param_spec->name, &color,
@ -573,9 +575,7 @@ gimp_prop_gegl_color_button_notify (GObject *config,
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);
gimp_color_button_set_color (GIMP_COLOR_BUTTON (button), color);
g_clear_object (&color);
g_signal_handlers_unblock_by_func (button,

View File

@ -189,7 +189,7 @@ static void
gimp_text_style_editor_init (GimpTextStyleEditor *editor)
{
GtkWidget *image;
GimpRGB color;
GeglColor *color;
gtk_orientable_set_orientation (GTK_ORIENTABLE (editor),
GTK_ORIENTATION_VERTICAL);
@ -247,11 +247,12 @@ gimp_text_style_editor_init (GimpTextStyleEditor *editor)
gtk_container_add (GTK_CONTAINER (editor->clear_button), image);
gtk_widget_show (image);
gimp_rgba_set (&color, 0.0, 0.0, 0.0, 1.0);
color = gegl_color_new ("black");
editor->color_button = gimp_color_panel_new (_("Change color of selected text"),
&color,
color,
GIMP_COLOR_AREA_FLAT, 20, 20);
gimp_widget_set_fully_opaque (editor->color_button, TRUE);
g_object_unref (color);
gtk_box_pack_end (GTK_BOX (editor->lower_hbox), editor->color_button,
FALSE, FALSE, 0);
@ -595,22 +596,25 @@ gimp_text_style_editor_list_tags (GimpTextStyleEditor *editor,
}
{
GList *list;
GimpRGB color;
GList *list;
GeglColor *color;
for (list = editor->buffer->color_tags; list; list = g_list_next (list))
*remove_tags = g_list_prepend (*remove_tags, list->data);
gimp_color_button_get_color (GIMP_COLOR_BUTTON (editor->color_button),
&color);
color = gimp_color_button_get_color (GIMP_COLOR_BUTTON (editor->color_button));
if (TRUE) /* FIXME should have "inconsistent" state as for font and size */
{
GtkTextTag *tag;
GimpRGB rgb;
tag = gimp_text_buffer_get_color_tag (editor->buffer, &color);
gegl_color_get_pixel (color, babl_format ("R'G'B'A double"), &rgb);
tag = gimp_text_buffer_get_color_tag (editor->buffer, &rgb);
tags = g_list_prepend (tags, tag);
}
g_object_unref (color);
}
*remove_tags = g_list_reverse (*remove_tags);
@ -740,13 +744,18 @@ gimp_text_style_editor_color_changed (GimpColorButton *button,
if (gtk_text_buffer_get_has_selection (buffer))
{
GtkTextIter start, end;
GimpRGB color;
GeglColor *color;
GimpRGB rgb;
GtkTextIter start, end;
gtk_text_buffer_get_selection_bounds (buffer, &start, &end);
gimp_color_button_get_color (button, &color);
gimp_text_buffer_set_color (editor->buffer, &start, &end, &color);
color = gimp_color_button_get_color (button);
gegl_color_get_pixel (color, babl_format ("R'G'B'A double"), &rgb);
gimp_text_buffer_set_color (editor->buffer, &start, &end, &rgb);
g_object_unref (color);
}
insert_tags = gimp_text_style_editor_list_tags (editor, &remove_tags);
@ -757,19 +766,22 @@ static void
gimp_text_style_editor_set_color (GimpTextStyleEditor *editor,
GtkTextTag *color_tag)
{
GimpRGB color;
GeglColor *color;
GimpRGB rgb;
gimp_rgba_set (&color, 0.0, 0.0, 0.0, 1.0);
gimp_rgba_set (&rgb, 0.0, 0.0, 0.0, 1.0);
if (color_tag)
gimp_text_tag_get_fg_color (color_tag, &color);
gimp_text_tag_get_fg_color (color_tag, &rgb);
g_signal_handlers_block_by_func (editor->color_button,
gimp_text_style_editor_color_changed,
editor);
gimp_color_button_set_color (GIMP_COLOR_BUTTON (editor->color_button),
&color);
color = gegl_color_new (NULL);
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), &rgb);
gimp_color_button_set_color (GIMP_COLOR_BUTTON (editor->color_button), color);
g_object_unref (color);
/* FIXME should have "inconsistent" state as for font and size */
@ -781,14 +793,11 @@ gimp_text_style_editor_set_color (GimpTextStyleEditor *editor,
static void
gimp_text_style_editor_set_default_color (GimpTextStyleEditor *editor)
{
GimpRGB rgb;
g_signal_handlers_block_by_func (editor->color_button,
gimp_text_style_editor_color_changed,
editor);
gegl_color_get_pixel (editor->text->color, babl_format ("R'G'B'A double"), &rgb);
gimp_color_button_set_color (GIMP_COLOR_BUTTON (editor->color_button), &rgb);
gimp_color_button_set_color (GIMP_COLOR_BUTTON (editor->color_button), editor->text->color);
g_signal_handlers_unblock_by_func (editor->color_button,
gimp_text_style_editor_color_changed,

View File

@ -601,12 +601,11 @@ gimp_procedure_dialog_set_ok_label (GimpProcedureDialog *dialog,
* * %GIMP_TYPE_LABEL_ENTRY (default): an entry with a label.
* * %GTK_TYPE_ENTRY: an entry with no label.
* * %GTK_TYPE_TEXT_VIEW: a text view with no label.
* - %GIMP_TYPE_PARAM_RGB:
* - %GEGL_TYPE_COLOR:
* * %GIMP_TYPE_LABEL_COLOR (default): a color button with a label.
* Please use gimp_procedure_dialog_get_color_widget() for a
* non-editable color area with a label.
* * %GIMP_TYPE_COLOR_BUTTON: a color button with no label.
* - %GEGL_TYPE_COLOR:
* * %GIMP_TYPE_COLOR_AREA: a color area with no label.
* - %G_TYPE_PARAM_FILE:
* * %GTK_FILE_CHOOSER_BUTTON (default): generic file chooser button
@ -741,17 +740,6 @@ gimp_procedure_dialog_get_widget (GimpProcedureDialog *dialog,
property, -1);
}
}
else if (G_PARAM_SPEC_TYPE (pspec) == GIMP_TYPE_PARAM_RGB)
{
if (widget_type == G_TYPE_NONE || widget_type == GIMP_TYPE_COLOR_BUTTON)
{
widget = gimp_prop_color_select_new (G_OBJECT (dialog->priv->config),
property, 20, 20,
GIMP_COLOR_AREA_SMALL_CHECKS);
gtk_widget_set_vexpand (widget, FALSE);
gtk_widget_set_hexpand (widget, FALSE);
}
}
else if (G_PARAM_SPEC_TYPE (pspec) == GEGL_TYPE_PARAM_COLOR)
{
if (widget_type == G_TYPE_NONE || widget_type == GIMP_TYPE_LABEL_COLOR)
@ -767,6 +755,14 @@ gimp_procedure_dialog_get_widget (GimpProcedureDialog *dialog,
gtk_widget_set_vexpand (widget, FALSE);
gtk_widget_set_hexpand (widget, FALSE);
}
else if (widget_type == GIMP_TYPE_COLOR_BUTTON)
{
widget = gimp_prop_color_select_new (G_OBJECT (dialog->priv->config),
property, 20, 20,
GIMP_COLOR_AREA_SMALL_CHECKS);
gtk_widget_set_vexpand (widget, FALSE);
gtk_widget_set_hexpand (widget, FALSE);
}
}
else if (G_IS_PARAM_SPEC_OBJECT (pspec) && pspec->value_type == G_TYPE_FILE)
{

View File

@ -190,7 +190,6 @@ gimp_color_button_class_init (GimpColorButtonClass *klass)
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
GtkButtonClass *button_class = GTK_BUTTON_CLASS (klass);
GimpRGB color;
parent_class = g_type_class_peek_parent (klass);
@ -216,8 +215,6 @@ gimp_color_button_class_init (GimpColorButtonClass *klass)
klass->color_changed = NULL;
klass->get_action_type = gimp_color_button_get_action_type;
gimp_rgba_set (&color, 0.0, 0.0, 0.0, 1.0);
/**
* GimpColorButton:title:
*
@ -240,12 +237,12 @@ gimp_color_button_class_init (GimpColorButtonClass *klass)
* Since: 2.4
*/
g_object_class_install_property (object_class, PROP_COLOR,
gimp_param_spec_rgb ("color",
"Color",
"The color displayed in the button's color area",
TRUE, &color,
GIMP_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
gegl_param_spec_color_from_string ("color",
"Color",
"The color displayed in the button's color area",
"black",
GIMP_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
/**
* GimpColorButton:type:
*
@ -542,7 +539,8 @@ gimp_color_button_clicked (GtkButton *button)
{
GimpColorButton *color_button = GIMP_COLOR_BUTTON (button);
GimpColorButtonPrivate *priv = GET_PRIVATE (button);
GimpRGB color;
GeglColor *color;
GimpRGB rgb;
if (! priv->dialog)
{
@ -589,21 +587,24 @@ gimp_color_button_clicked (GtkButton *button)
button);
}
gimp_color_button_get_color (color_button, &color);
color = gimp_color_button_get_color (color_button);
g_signal_handlers_block_by_func (priv->selection,
gimp_color_button_selection_changed,
button);
gimp_color_selection_set_color (GIMP_COLOR_SELECTION (priv->selection), &color);
gegl_color_get_pixel (color, babl_format ("R'G'B'A double"), &rgb);
gimp_color_selection_set_color (GIMP_COLOR_SELECTION (priv->selection), &rgb);
gimp_color_selection_set_old_color (GIMP_COLOR_SELECTION (priv->selection),
&color);
&rgb);
g_signal_handlers_unblock_by_func (priv->selection,
gimp_color_button_selection_changed,
button);
gtk_window_present (GTK_WINDOW (priv->dialog));
g_object_unref (color);
}
static GType
@ -620,7 +621,7 @@ gimp_color_button_get_action_type (GimpColorButton *button)
* @title: String that will be used as title for the color_selector.
* @width: Width of the colorpreview in pixels.
* @height: Height of the colorpreview in pixels.
* @color: A pointer to a #GimpRGB color.
* @color: A [class@Gegl.Color].
* @type: The type of transparency to be displayed.
*
* Creates a new #GimpColorButton widget.
@ -637,10 +638,10 @@ GtkWidget *
gimp_color_button_new (const gchar *title,
gint width,
gint height,
const GimpRGB *color,
GeglColor *color,
GimpColorAreaType type)
{
g_return_val_if_fail (color != NULL, NULL);
g_return_val_if_fail (GEGL_IS_COLOR (color), NULL);
g_return_val_if_fail (width > 0, NULL);
g_return_val_if_fail (height > 0, NULL);
@ -705,26 +706,22 @@ gimp_color_button_get_title (GimpColorButton *button)
/**
* gimp_color_button_set_color:
* @button: Pointer to a #GimpColorButton.
* @color: Pointer to the new #GimpRGB color.
* @color: A new [class@Gegl.Color].
*
* Sets the @button to the given @color.
**/
void
gimp_color_button_set_color (GimpColorButton *button,
const GimpRGB *rgb)
GeglColor *color)
{
GimpColorButtonPrivate *priv;
GeglColor *color;
g_return_if_fail (GIMP_IS_COLOR_BUTTON (button));
g_return_if_fail (rgb != NULL);
g_return_if_fail (GEGL_IS_COLOR (color));
priv = GET_PRIVATE (button);
color = gegl_color_new (NULL);
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), rgb);
gimp_color_area_set_color (GIMP_COLOR_AREA (priv->color_area), color);
g_object_unref (color);
g_object_notify (G_OBJECT (button), "color");
}
@ -732,26 +729,21 @@ gimp_color_button_set_color (GimpColorButton *button,
/**
* gimp_color_button_get_color:
* @button: Pointer to a #GimpColorButton.
* @color: (out caller-allocates): Pointer to a #GimpRGB struct
* used to return the color.
*
* Retrieves the currently set color from the @button.
*
* Returns: (transfer full): a copy of @button's [class@Gegl.Color].
**/
void
gimp_color_button_get_color (GimpColorButton *button,
GimpRGB *rgb)
GeglColor *
gimp_color_button_get_color (GimpColorButton *button)
{
GimpColorButtonPrivate *priv;
GeglColor *color;
g_return_if_fail (GIMP_IS_COLOR_BUTTON (button));
g_return_if_fail (rgb != NULL);
g_return_val_if_fail (GIMP_IS_COLOR_BUTTON (button), NULL);
priv = GET_PRIVATE (button);
color = gimp_color_area_get_color (GIMP_COLOR_AREA (priv->color_area));
gegl_color_get_pixel (color, babl_format ("R'G'B'A double"), rgb);
g_object_unref (color);
return gimp_color_area_get_color (GIMP_COLOR_AREA (priv->color_area));
}
/**
@ -842,20 +834,19 @@ gimp_color_button_set_update (GimpColorButton *button,
if (priv->selection)
{
GimpRGB color;
GeglColor *color;
GimpRGB rgb;
color = gegl_color_new (NULL);
if (priv->continuous_update)
{
gimp_color_selection_get_color (GIMP_COLOR_SELECTION (priv->selection),
&color);
gimp_color_button_set_color (button, &color);
}
gimp_color_selection_get_color (GIMP_COLOR_SELECTION (priv->selection), &rgb);
else
{
gimp_color_selection_get_old_color (GIMP_COLOR_SELECTION (priv->selection),
&color);
gimp_color_button_set_color (button, &color);
}
gimp_color_selection_get_old_color (GIMP_COLOR_SELECTION (priv->selection), &rgb);
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), &rgb);
gimp_color_button_set_color (button, color);
g_object_unref (color);
}
g_object_notify (G_OBJECT (button), "continuous-update");
@ -924,7 +915,10 @@ gimp_color_button_dialog_response (GtkWidget *dialog,
GimpColorButton *button)
{
GimpColorButtonPrivate *priv = GET_PRIVATE (button);
GimpRGB color;
GeglColor *color;
GimpRGB rgb;
color = gegl_color_new (NULL);
switch (response_id)
{
@ -936,8 +930,9 @@ gimp_color_button_dialog_response (GtkWidget *dialog,
if (! priv->continuous_update)
{
gimp_color_selection_get_color (GIMP_COLOR_SELECTION (priv->selection),
&color);
gimp_color_button_set_color (button, &color);
&rgb);
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), &rgb);
gimp_color_button_set_color (button, color);
}
gtk_widget_hide (dialog);
@ -947,13 +942,16 @@ gimp_color_button_dialog_response (GtkWidget *dialog,
if (priv->continuous_update)
{
gimp_color_selection_get_old_color (GIMP_COLOR_SELECTION (priv->selection),
&color);
gimp_color_button_set_color (button, &color);
&rgb);
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), &rgb);
gimp_color_button_set_color (button, color);
}
gtk_widget_hide (dialog);
break;
}
g_object_unref (color);
}
static void
@ -962,46 +960,38 @@ gimp_color_button_use_color (GAction *action,
GimpColorButton *button)
{
const gchar *name;
GeglColor *color = NULL;
GimpRGB rgb;
GeglColor *color;
name = g_action_get_name (action);
gimp_color_button_get_color (button, &rgb);
if (! strcmp (name, GIMP_COLOR_BUTTON_COLOR_FG))
{
if (_gimp_get_foreground_func)
{
color = _gimp_get_foreground_func ();
gegl_color_get_pixel (color, babl_format_with_space ("R'G'B'A double", NULL), &rgb);
}
color = _gimp_get_foreground_func ();
else
{
gimp_rgba_set (&rgb, 0.0, 0.0, 0.0, 1.0);
}
color = gegl_color_new ("black");
}
else if (! strcmp (name, GIMP_COLOR_BUTTON_COLOR_BG))
{
if (_gimp_get_background_func)
{
color = _gimp_get_background_func ();
gegl_color_get_pixel (color, babl_format_with_space ("R'G'B'A double", NULL), &rgb);
}
color = _gimp_get_background_func ();
else
{
gimp_rgba_set (&rgb, 1.0, 1.0, 1.0, 1.0);
}
color = gegl_color_new ("white");
}
else if (! strcmp (name, GIMP_COLOR_BUTTON_COLOR_BLACK))
{
gimp_rgba_set (&rgb, 0.0, 0.0, 0.0, 1.0);
color = gegl_color_new ("black");
}
else if (! strcmp (name, GIMP_COLOR_BUTTON_COLOR_WHITE))
{
gimp_rgba_set (&rgb, 1.0, 1.0, 1.0, 1.0);
color = gegl_color_new ("white");
}
else
{
color = gimp_color_button_get_color (button);
}
gimp_color_button_set_color (button, &rgb);
gimp_color_button_set_color (button, color);
g_clear_object (&color);
}
@ -1014,20 +1004,24 @@ gimp_color_button_area_changed (GtkWidget *color_area,
if (priv->selection)
{
GimpRGB color;
GeglColor *color;
GimpRGB rgb;
gimp_color_button_get_color (button, &color);
color = gimp_color_button_get_color (button);
g_signal_handlers_block_by_func (priv->selection,
gimp_color_button_selection_changed,
button);
gegl_color_get_pixel (color, babl_format ("R'G'B'A double"), &rgb);
gimp_color_selection_set_color (GIMP_COLOR_SELECTION (priv->selection),
&color);
&rgb);
g_signal_handlers_unblock_by_func (priv->selection,
gimp_color_button_selection_changed,
button);
g_object_unref (color);
}
g_signal_emit (button, gimp_color_button_signals[COLOR_CHANGED], 0);

View File

@ -82,7 +82,7 @@ GType gimp_color_button_get_type (void) G_GNUC_CONST;
GtkWidget * gimp_color_button_new (const gchar *title,
gint width,
gint height,
const GimpRGB *color,
GeglColor *color,
GimpColorAreaType type);
void gimp_color_button_set_title (GimpColorButton *button,
@ -90,9 +90,8 @@ void gimp_color_button_set_title (GimpColorButton *button,
const gchar * gimp_color_button_get_title (GimpColorButton *button);
void gimp_color_button_set_color (GimpColorButton *button,
const GimpRGB *color);
void gimp_color_button_get_color (GimpColorButton *button,
GimpRGB *color);
GeglColor *color);
GeglColor * gimp_color_button_get_color (GimpColorButton *button);
gboolean gimp_color_button_has_alpha (GimpColorButton *button);
void gimp_color_button_set_type (GimpColorButton *button,

View File

@ -4177,12 +4177,12 @@ gimp_prop_color_area_notify (GObject *config,
/**
* gimp_prop_color_select_new:
* @config: Object to which property is attached.
* @property_name: Name of RGB property.
* @property_name: Name of [class@Gegl.Color] property.
* @width: Width of the colorpreview in pixels.
* @height: Height of the colorpreview in pixels.
* @type: How transparency is represented.
*
* Creates a #GimpColorButton to set and display the value of an RGB
* Creates a #GimpColorButton to set and display the value of a color
* property.
*
* Returns: (transfer full): A new #GimpColorButton widget.
@ -4198,10 +4198,10 @@ gimp_prop_color_select_new (GObject *config,
{
GParamSpec *param_spec;
GtkWidget *button;
GimpRGB *value;
GeglColor *value = NULL;
param_spec = check_param_spec_w (config, property_name,
GIMP_TYPE_PARAM_RGB, G_STRFUNC);
GEGL_TYPE_PARAM_COLOR, G_STRFUNC);
if (! param_spec)
return NULL;
@ -4212,7 +4212,7 @@ gimp_prop_color_select_new (GObject *config,
button = gimp_color_button_new (g_param_spec_get_nick (param_spec),
width, height, value, type);
g_free (value);
g_clear_object (&value);
g_object_bind_property (config, property_name,
button, "color",

View File

@ -1087,7 +1087,13 @@ gimp_widget_get_render_space (GtkWidget *widget,
g_return_val_if_fail (widget == NULL || GTK_IS_WIDGET (widget), NULL);
_gimp_widget_get_profiles (widget, config, NULL, &dest_profile);
if (config)
_gimp_widget_get_profiles (widget, config, NULL, &dest_profile);
else
/* When no GimpColorConfig is given, we just return the monitor's color
* profile, disregarding any user preferences.
*/
dest_profile = gimp_widget_get_color_profile (gtk_widget_get_toplevel (widget));
if (dest_profile)
space = gimp_color_profile_get_space (dest_profile,

View File

@ -616,7 +616,8 @@ static void
update_values (Grid *grid)
{
GtkWidget *entry;
GimpRGB color;
GeglColor *color;
GimpRGB rgb;
entry = g_object_get_data (G_OBJECT (main_dialog), "width");
g_object_set (grid->config,
@ -648,12 +649,20 @@ update_values (Grid *grid)
(gint) RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (entry), 2)),
NULL);
gimp_color_button_get_color (GIMP_COLOR_BUTTON (grid->hcolor_button), &color);
g_object_set (grid->config, "hcolor", &color, NULL);
gimp_color_button_get_color (GIMP_COLOR_BUTTON (grid->vcolor_button), &color);
g_object_set (grid->config, "vcolor", &color, NULL);
gimp_color_button_get_color (GIMP_COLOR_BUTTON (grid->icolor_button), &color);
g_object_set (grid->config, "icolor", &color, NULL);
color = gimp_color_button_get_color (GIMP_COLOR_BUTTON (grid->hcolor_button));
gegl_color_get_pixel (color, babl_format ("R'G'B'A double"), &rgb);
g_object_set (grid->config, "hcolor", &rgb, NULL);
g_object_unref (color);
color = gimp_color_button_get_color (GIMP_COLOR_BUTTON (grid->vcolor_button));
gegl_color_get_pixel (color, babl_format ("R'G'B'A double"), &rgb);
g_object_set (grid->config, "vcolor", &rgb, NULL);
g_object_unref (color);
color = gimp_color_button_get_color (GIMP_COLOR_BUTTON (grid->icolor_button));
gegl_color_get_pixel (color, babl_format ("R'G'B'A double"), &rgb);
g_object_set (grid->config, "icolor", &rgb, NULL);
g_object_unref (color);
}
static void
@ -704,18 +713,29 @@ color_callback (GtkWidget *widget,
{
Grid *grid = GRID (data);
GtkWidget *chain_button = grid->color_chain;
GeglColor *color;
GimpRGB rgb;
color = gimp_color_button_get_color (GIMP_COLOR_BUTTON (widget));
if (gimp_chain_button_get_active (GIMP_CHAIN_BUTTON (chain_button)))
{
GimpRGB color;
gimp_color_button_get_color (GIMP_COLOR_BUTTON (widget), &color);
if (widget == grid->vcolor_button)
gimp_color_button_set_color (GIMP_COLOR_BUTTON (grid->hcolor_button), &color);
gimp_color_button_set_color (GIMP_COLOR_BUTTON (grid->hcolor_button), color);
else if (widget == grid->hcolor_button)
gimp_color_button_set_color (GIMP_COLOR_BUTTON (grid->vcolor_button), &color);
gimp_color_button_set_color (GIMP_COLOR_BUTTON (grid->vcolor_button), color);
}
gegl_color_get_pixel (color, babl_format ("R'G'B'A double"), &rgb);
if (widget == grid->hcolor_button)
g_object_set (grid->config, "hcolor", &rgb, NULL);
else if (widget == grid->vcolor_button)
g_object_set (grid->config, "vcolor", &rgb, NULL);
else if (widget == grid->icolor_button)
g_object_set (grid->config, "icolor", &rgb, NULL);
g_object_unref (color);
}
@ -756,6 +776,7 @@ dialog (GimpImage *image,
gint ispace;
gint ioffset;
GimpRGB *icolor;
GeglColor *color;
g_return_val_if_fail (main_dialog == NULL, FALSE);
@ -1030,9 +1051,11 @@ dialog (GimpImage *image,
gtk_widget_show (grid->color_chain);
/* attach color selectors */
color = gegl_color_new (NULL);
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), hcolor);
grid->hcolor_button = gimp_color_button_new (_("Horizontal Color"),
COLOR_BUTTON_WIDTH, 16,
hcolor,
color,
GIMP_COLOR_AREA_SMALL_CHECKS);
gimp_color_button_set_update (GIMP_COLOR_BUTTON (grid->hcolor_button), TRUE);
gtk_grid_attach (GTK_GRID (offset), grid->hcolor_button, 1, 3, 1, 1);
@ -1042,9 +1065,6 @@ dialog (GimpImage *image,
gimp_color_button_set_color_config (GIMP_COLOR_BUTTON (grid->hcolor_button),
color_config);
g_signal_connect (grid->hcolor_button, "color-changed",
G_CALLBACK (gimp_color_button_get_color),
hcolor);
g_signal_connect (grid->hcolor_button, "color-changed",
G_CALLBACK (color_callback),
grid);
@ -1052,9 +1072,10 @@ dialog (GimpImage *image,
G_CALLBACK (gimp_preview_invalidate),
preview);
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), vcolor);
grid->vcolor_button = gimp_color_button_new (_("Vertical Color"),
COLOR_BUTTON_WIDTH, 16,
vcolor,
color,
GIMP_COLOR_AREA_SMALL_CHECKS);
gimp_color_button_set_update (GIMP_COLOR_BUTTON (grid->vcolor_button), TRUE);
gtk_grid_attach (GTK_GRID (offset), grid->vcolor_button, 2, 3, 1, 1);
@ -1063,9 +1084,6 @@ dialog (GimpImage *image,
gimp_color_button_set_color_config (GIMP_COLOR_BUTTON (grid->vcolor_button),
color_config);
g_signal_connect (grid->vcolor_button, "color-changed",
G_CALLBACK (gimp_color_button_get_color),
vcolor);
g_signal_connect (grid->vcolor_button, "color-changed",
G_CALLBACK (color_callback),
grid);
@ -1073,9 +1091,10 @@ dialog (GimpImage *image,
G_CALLBACK (gimp_preview_invalidate),
preview);
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), icolor);
grid->icolor_button = gimp_color_button_new (_("Intersection Color"),
COLOR_BUTTON_WIDTH, 16,
icolor,
color,
GIMP_COLOR_AREA_SMALL_CHECKS);
gimp_color_button_set_update (GIMP_COLOR_BUTTON (grid->icolor_button), TRUE);
gtk_grid_attach (GTK_GRID (offset), grid->icolor_button, 3, 3, 1, 1);
@ -1084,10 +1103,11 @@ dialog (GimpImage *image,
gimp_color_button_set_color_config (GIMP_COLOR_BUTTON (grid->icolor_button),
color_config);
g_object_unref (color_config);
g_object_unref (color);
g_signal_connect (grid->icolor_button, "color-changed",
G_CALLBACK (gimp_color_button_get_color),
icolor);
G_CALLBACK (color_callback),
grid);
g_signal_connect_swapped (grid->icolor_button, "color-changed",
G_CALLBACK (gimp_preview_invalidate),
preview);

View File

@ -2485,16 +2485,20 @@ color1_changed (GimpColorButton *button)
if (t)
{
GimpRGB color;
GeglColor *color;
GimpRGB rgb;
gimp_color_button_get_color (button, &color);
color = gimp_color_button_get_color (button);
gegl_color_get_pixel (color, babl_format ("R'G'B'A double"), &rgb);
t->color1.x = color.r;
t->color1.y = color.g;
t->color1.z = color.b;
t->color1.w = color.a;
t->color1.x = rgb.r;
t->color1.y = rgb.g;
t->color1.z = rgb.b;
t->color1.w = rgb.a;
restartrender ();
g_object_unref (color);
}
}
@ -2505,16 +2509,20 @@ color2_changed (GimpColorButton *button)
if (t)
{
GimpRGB color;
GeglColor *color;
GimpRGB rgb;
gimp_color_button_get_color (button, &color);
color = gimp_color_button_get_color (button);
gegl_color_get_pixel (color, babl_format ("R'G'B'A double"), &rgb);
t->color2.x = color.r;
t->color2.y = color.g;
t->color2.z = color.b;
t->color2.w = color.a;
t->color2.x = rgb.r;
t->color2.y = rgb.g;
t->color2.z = rgb.b;
t->color2.w = rgb.a;
restartrender ();
g_object_unref (color);
}
}
@ -2522,9 +2530,9 @@ static void
drawcolor1 (GtkWidget *w)
{
static GtkWidget *lastw = NULL;
GimpRGB color;
texture *t = currenttexture ();
GeglColor *color;
GimpRGB rgb;
texture *t = currenttexture ();
if (w)
lastw = w;
@ -2536,19 +2544,22 @@ drawcolor1 (GtkWidget *w)
if (!t)
return;
gimp_rgba_set (&color,
color = gegl_color_new (NULL);
gimp_rgba_set (&rgb,
t->color1.x, t->color1.y, t->color1.z, t->color1.w);
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), &rgb);
gimp_color_button_set_color (GIMP_COLOR_BUTTON (w), &color);
gimp_color_button_set_color (GIMP_COLOR_BUTTON (w), color);
g_object_unref (color);
}
static void
drawcolor2 (GtkWidget *w)
{
static GtkWidget *lastw = NULL;
GimpRGB color;
texture *t = currenttexture ();
GeglColor *color;
GimpRGB rgb;
texture *t = currenttexture ();
if (w)
lastw = w;
@ -2560,10 +2571,13 @@ drawcolor2 (GtkWidget *w)
if (!t)
return;
gimp_rgba_set (&color,
color = gegl_color_new (NULL);
gimp_rgba_set (&rgb,
t->color2.x, t->color2.y, t->color2.z, t->color2.w);
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), &rgb);
gimp_color_button_set_color (GIMP_COLOR_BUTTON (w), &color);
gimp_color_button_set_color (GIMP_COLOR_BUTTON (w), color);
g_object_unref (color);
}
static gboolean do_run = FALSE;
@ -2627,7 +2641,7 @@ makewindow (void)
GtkWidget *vbox;
GtkWidget *button;
GtkWidget *list;
GimpRGB rgb = { 0, 0, 0, 0 };
GeglColor *color = gegl_color_new ("transparent");
window = gimp_dialog_new (_("Sphere Designer"), PLUG_IN_ROLE,
NULL, 0,
@ -2814,8 +2828,8 @@ makewindow (void)
hbox, 2);
button = gimp_color_button_new (_("Color Selection Dialog"),
COLORBUTTONWIDTH, COLORBUTTONHEIGHT, &rgb,
GIMP_COLOR_AREA_FLAT);
COLORBUTTONWIDTH, COLORBUTTONHEIGHT,
color, GIMP_COLOR_AREA_FLAT);
gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
gtk_widget_show (button);
drawcolor1 (button);
@ -2825,8 +2839,8 @@ makewindow (void)
NULL);
button = gimp_color_button_new (_("Color Selection Dialog"),
COLORBUTTONWIDTH, COLORBUTTONHEIGHT, &rgb,
GIMP_COLOR_AREA_FLAT);
COLORBUTTONWIDTH, COLORBUTTONHEIGHT,
color, GIMP_COLOR_AREA_FLAT);
gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
gtk_widget_show (button);
drawcolor2 (button);
@ -2956,6 +2970,8 @@ makewindow (void)
gtk_widget_show (window);
g_object_unref (color);
return window;
}

View File

@ -490,17 +490,15 @@ gfig_dialog (GimpGfig *gfig)
vbox);
/* foreground color button in Stroke frame*/
gfig_context->fg_color = g_new0 (GimpRGB, 1);
gfig_context->fg_color = gegl_color_duplicate (gfig_context->default_style.foreground);
gfig_context->fg_color_button = gimp_color_button_new (_("Foreground"),
SEL_BUTTON_WIDTH,
SEL_BUTTON_HEIGHT,
gfig_context->fg_color,
GIMP_COLOR_AREA_SMALL_CHECKS);
SEL_BUTTON_WIDTH,
SEL_BUTTON_HEIGHT,
gfig_context->fg_color,
GIMP_COLOR_AREA_SMALL_CHECKS);
g_signal_connect (gfig_context->fg_color_button, "color-changed",
G_CALLBACK (set_foreground_callback),
gfig_context->fg_color);
gimp_color_button_set_color (GIMP_COLOR_BUTTON (gfig_context->fg_color_button),
&gfig_context->default_style.foreground);
gtk_box_pack_start (GTK_BOX (vbox), gfig_context->fg_color_button,
FALSE, FALSE, 0);
gtk_widget_show (gfig_context->fg_color_button);
@ -557,16 +555,14 @@ gfig_dialog (GimpGfig *gfig)
empty_label, NULL);
/* A page for the fill color button */
gfig_context->bg_color = g_new0 (GimpRGB, 1);
gfig_context->bg_color = gegl_color_duplicate (gfig_context->default_style.background);
gfig_context->bg_color_button = gimp_color_button_new (_("Background"),
SEL_BUTTON_WIDTH, SEL_BUTTON_HEIGHT,
gfig_context->bg_color,
GIMP_COLOR_AREA_SMALL_CHECKS);
SEL_BUTTON_WIDTH, SEL_BUTTON_HEIGHT,
gfig_context->bg_color,
GIMP_COLOR_AREA_SMALL_CHECKS);
g_signal_connect (gfig_context->bg_color_button, "color-changed",
G_CALLBACK (set_background_callback),
gfig_context->bg_color);
gimp_color_button_set_color (GIMP_COLOR_BUTTON (gfig_context->bg_color_button),
&gfig_context->default_style.background);
gtk_widget_show (gfig_context->bg_color_button);
gtk_notebook_append_page (GTK_NOTEBOOK (fill_type_notebook),
gfig_context->bg_color_button, NULL);

View File

@ -56,7 +56,7 @@ static void gfig_read_parameter_double (gchar **text,
static void gfig_read_parameter_gimp_rgb (gchar **text,
gint nitems,
const gchar *name,
GimpRGB *style_entry);
GeglColor **style_entry);
/* From a style string, read a resource name,
* create a resource object, and put it in
@ -168,7 +168,7 @@ static void
gfig_read_parameter_gimp_rgb (gchar **text,
gint nitems,
const gchar *name,
GimpRGB *style_entry)
GeglColor **style_entry)
{
gint n = 0;
gchar *ptr;
@ -180,7 +180,10 @@ gfig_read_parameter_gimp_rgb (gchar **text,
gchar colorstr_b[G_ASCII_DTOSTR_BUF_SIZE];
gchar colorstr_a[G_ASCII_DTOSTR_BUF_SIZE];
style_entry->r = style_entry->g = style_entry->b = style_entry->a = 0.;
if (*style_entry == NULL)
*style_entry = gegl_color_new (NULL);
gegl_color_set_rgba_with_space (*style_entry, 0.0, 0.0, 0.0, 0.0, NULL);
snprintf (fmt_str, sizeof (fmt_str),
"%%%" G_GSIZE_FORMAT "s"
@ -201,10 +204,12 @@ gfig_read_parameter_gimp_rgb (gchar **text,
{
sscanf (ptr, fmt_str,
colorstr_r, colorstr_g, colorstr_b, colorstr_a);
style_entry->r = g_ascii_strtod (colorstr_r, &endptr);
style_entry->g = g_ascii_strtod (colorstr_g, &endptr);
style_entry->b = g_ascii_strtod (colorstr_b, &endptr);
style_entry->a = g_ascii_strtod (colorstr_a, &endptr);
gegl_color_set_rgba_with_space (*style_entry,
g_ascii_strtod (colorstr_r, &endptr),
g_ascii_strtod (colorstr_g, &endptr),
g_ascii_strtod (colorstr_b, &endptr),
g_ascii_strtod (colorstr_a, &endptr),
NULL);
g_free (tmpstr);
return;
}
@ -357,12 +362,13 @@ void
gfig_save_style (Style *style,
GString *string)
{
gchar buffer[G_ASCII_DTOSTR_BUF_SIZE];
gchar buffer_r[G_ASCII_DTOSTR_BUF_SIZE];
gchar buffer_g[G_ASCII_DTOSTR_BUF_SIZE];
gchar buffer_b[G_ASCII_DTOSTR_BUF_SIZE];
gchar buffer_a[G_ASCII_DTOSTR_BUF_SIZE];
gint blen = G_ASCII_DTOSTR_BUF_SIZE;
gchar buffer[G_ASCII_DTOSTR_BUF_SIZE];
gchar buffer_r[G_ASCII_DTOSTR_BUF_SIZE];
gchar buffer_g[G_ASCII_DTOSTR_BUF_SIZE];
gchar buffer_b[G_ASCII_DTOSTR_BUF_SIZE];
gchar buffer_a[G_ASCII_DTOSTR_BUF_SIZE];
gint blen = G_ASCII_DTOSTR_BUF_SIZE;
gdouble rgba[4];
if (gfig_context->debug_styles)
g_printerr ("Saving style %s, brush name '%s'\n", style->name,
@ -386,17 +392,19 @@ gfig_save_style (Style *style,
g_string_append_printf (string, "Gradient: %s\n",
gimp_resource_get_name (GIMP_RESOURCE (style->gradient)));
gegl_color_get_pixel (style->foreground, babl_format ("R'G'B'A double"), rgba);
g_string_append_printf (string, "Foreground: %s %s %s %s\n",
g_ascii_dtostr (buffer_r, blen, style->foreground.r),
g_ascii_dtostr (buffer_g, blen, style->foreground.g),
g_ascii_dtostr (buffer_b, blen, style->foreground.b),
g_ascii_dtostr (buffer_a, blen, style->foreground.a));
g_ascii_dtostr (buffer_r, blen, rgba[0]),
g_ascii_dtostr (buffer_g, blen, rgba[1]),
g_ascii_dtostr (buffer_b, blen, rgba[2]),
g_ascii_dtostr (buffer_a, blen, rgba[3]));
gegl_color_get_pixel (style->background, babl_format ("R'G'B'A double"), rgba);
g_string_append_printf (string, "Background: %s %s %s %s\n",
g_ascii_dtostr (buffer_r, blen, style->background.r),
g_ascii_dtostr (buffer_g, blen, style->background.g),
g_ascii_dtostr (buffer_b, blen, style->background.b),
g_ascii_dtostr (buffer_a, blen, style->background.a));
g_ascii_dtostr (buffer_r, blen, rgba[0]),
g_ascii_dtostr (buffer_g, blen, rgba[1]),
g_ascii_dtostr (buffer_b, blen, rgba[2]),
g_ascii_dtostr (buffer_a, blen, rgba[3]));
g_string_append_printf (string, "</Style>\n");
}
@ -405,12 +413,13 @@ void
gfig_style_save_as_attributes (Style *style,
GString *string)
{
gchar buffer[G_ASCII_DTOSTR_BUF_SIZE];
gchar buffer_r[G_ASCII_DTOSTR_BUF_SIZE];
gchar buffer_g[G_ASCII_DTOSTR_BUF_SIZE];
gchar buffer_b[G_ASCII_DTOSTR_BUF_SIZE];
gchar buffer_a[G_ASCII_DTOSTR_BUF_SIZE];
gint blen = G_ASCII_DTOSTR_BUF_SIZE;
gchar buffer[G_ASCII_DTOSTR_BUF_SIZE];
gchar buffer_r[G_ASCII_DTOSTR_BUF_SIZE];
gchar buffer_g[G_ASCII_DTOSTR_BUF_SIZE];
gchar buffer_b[G_ASCII_DTOSTR_BUF_SIZE];
gchar buffer_a[G_ASCII_DTOSTR_BUF_SIZE];
gint blen = G_ASCII_DTOSTR_BUF_SIZE;
gdouble rgba[4];
if (gfig_context->debug_styles)
g_printerr ("Saving style %s as attributes\n", style->name);
@ -420,17 +429,19 @@ gfig_style_save_as_attributes (Style *style,
gimp_resource_get_name (GIMP_RESOURCE (style->brush)));
/* Why only brush and not pattern and gradient? */
gegl_color_get_pixel (style->foreground, babl_format ("R'G'B'A double"), rgba);
g_string_append_printf (string, "Foreground=\"%s %s %s %s\" ",
g_ascii_dtostr (buffer_r, blen, style->foreground.r),
g_ascii_dtostr (buffer_g, blen, style->foreground.g),
g_ascii_dtostr (buffer_b, blen, style->foreground.b),
g_ascii_dtostr (buffer_a, blen, style->foreground.a));
g_ascii_dtostr (buffer_r, blen, rgba[0]),
g_ascii_dtostr (buffer_g, blen, rgba[1]),
g_ascii_dtostr (buffer_b, blen, rgba[2]),
g_ascii_dtostr (buffer_a, blen, rgba[3]));
gegl_color_get_pixel (style->background, babl_format ("R'G'B'A double"), rgba);
g_string_append_printf (string, "Background=\"%s %s %s %s\" ",
g_ascii_dtostr (buffer_r, blen, style->background.r),
g_ascii_dtostr (buffer_g, blen, style->background.g),
g_ascii_dtostr (buffer_b, blen, style->background.b),
g_ascii_dtostr (buffer_a, blen, style->background.a));
g_ascii_dtostr (buffer_r, blen, rgba[0]),
g_ascii_dtostr (buffer_g, blen, rgba[1]),
g_ascii_dtostr (buffer_b, blen, rgba[2]),
g_ascii_dtostr (buffer_a, blen, rgba[3]));
g_string_append_printf (string, "FillType=%d ", style->fill_type);
@ -438,8 +449,6 @@ gfig_style_save_as_attributes (Style *style,
g_string_append_printf (string, "FillOpacity=%s ",
g_ascii_dtostr (buffer, blen, style->fill_opacity));
}
void
@ -461,18 +470,15 @@ void
set_foreground_callback (GimpColorButton *button,
gpointer data)
{
GimpRGB color2;
Style *current_style;
Style *current_style;
if (gfig_context->debug_styles)
g_printerr ("Setting foreground color from color selector\n");
current_style = gfig_context_get_current_style ();
gimp_color_button_get_color (button, &color2);
gimp_rgba_set (&current_style->foreground,
color2.r, color2.g, color2.b, color2.a);
g_clear_object (&current_style->foreground);
current_style->foreground = gimp_color_button_get_color (button);
gfig_paint_callback ();
}
@ -481,17 +487,15 @@ void
set_background_callback (GimpColorButton *button,
gpointer data)
{
GimpRGB color2;
Style *current_style;
Style *current_style;
if (gfig_context->debug_styles)
g_printerr ("Setting background color from color selector\n");
current_style = gfig_context_get_current_style ();
gimp_color_button_get_color (button, &color2);
gimp_rgba_set (&current_style->background,
color2.r, color2.g, color2.b, color2.a);
g_clear_object (&current_style->background);
current_style->background = gimp_color_button_get_color (button);
gfig_paint_callback ();
}
@ -563,16 +567,6 @@ gfig_gradient_changed_callback (gpointer user_data,
gfig_paint_callback ();
}
void
gfig_rgba_copy (GimpRGB *color1,
GimpRGB *color2)
{
color1->r = color2->r;
color1->g = color2->g;
color1->b = color2->b;
color1->a = color2->a;
}
void
gfig_style_copy (Style *style1,
Style *style0,
@ -586,8 +580,10 @@ gfig_style_copy (Style *style1,
if (gfig_context->debug_styles)
g_printerr ("Copying style %s as style %s\n", style0->name, name);
gfig_rgba_copy (&style1->foreground, &style0->foreground);
gfig_rgba_copy (&style1->background, &style0->background);
g_clear_object (&style1->foreground);
style1->foreground = gegl_color_duplicate (style0->foreground);
g_clear_object (&style1->background);
style1->background = gegl_color_duplicate (style0->background);
if (!style0->brush)
g_message ("Error copying style %s: brush name is NULL.", style0->name);
@ -610,17 +606,11 @@ gfig_style_copy (Style *style1,
void
gfig_style_apply (Style *style)
{
GeglColor *color = gegl_color_new ("black");
if (gfig_context->debug_styles)
g_printerr ("Applying style '%s' -- ", style->name);
gegl_color_set_rgba_with_space (color, style->foreground.r, style->foreground.g, style->foreground.b, style->foreground.a, NULL);
gimp_context_set_foreground (color);
gegl_color_set_rgba_with_space (color, style->background.r, style->background.g, style->background.b, style->background.a, NULL);
gimp_context_set_background (color);
g_object_unref (color);
gimp_context_set_foreground (style->foreground);
gimp_context_set_background (style->background);
if (! gimp_context_set_brush (style->brush))
g_message ("Style apply: Failed to set brush to '%s' in style '%s'",
@ -648,8 +638,7 @@ void
gfig_read_gimp_style (Style *style,
const gchar *name)
{
GeglColor *color;
gint dummy;
gint dummy;
if (!name)
g_message ("Error: name is NULL in gfig_read_gimp_style.");
@ -658,12 +647,11 @@ gfig_read_gimp_style (Style *style,
g_printerr ("Reading Gimp settings as style %s\n", name);
style->name = g_strdup (name);
color = gimp_context_get_foreground ();
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);
g_clear_object (&style->foreground);
style->foreground = gimp_context_get_foreground ();
g_clear_object (&style->background);
style->background = gimp_context_get_background ();
style->brush = gimp_context_get_brush ();
style->gradient = gimp_context_get_gradient ();
@ -699,9 +687,9 @@ gfig_style_set_context_from_style (Style *style)
gfig_context->enable_repaint = FALSE;
gimp_color_button_set_color (GIMP_COLOR_BUTTON (gfig_context->fg_color_button),
&style->foreground);
style->foreground);
gimp_color_button_set_color (GIMP_COLOR_BUTTON (gfig_context->bg_color_button),
&style->background);
style->background);
if (! gimp_context_set_brush (style->brush))
g_message ("Style from context: Failed to set brush");
@ -736,23 +724,25 @@ gfig_style_set_context_from_style (Style *style)
void
gfig_style_set_style_from_context (Style *style)
{
Style *current_style;
GimpRGB color;
gint value;
Style *current_style;
gint value;
style->name = "object";
current_style = gfig_context_get_current_style ();
gimp_color_button_get_color (GIMP_COLOR_BUTTON (gfig_context->fg_color_button),
&color);
g_clear_object (&style->foreground);
style->foreground = gimp_color_button_get_color (GIMP_COLOR_BUTTON (gfig_context->fg_color_button));
if (gfig_context->debug_styles)
g_printerr ("Setting foreground color to %lg %lg %lg\n",
color.r, color.g, color.b);
{
gdouble rgb[3];
gfig_rgba_copy (&style->foreground, &color);
gimp_color_button_get_color (GIMP_COLOR_BUTTON (gfig_context->bg_color_button),
&color);
gfig_rgba_copy (&style->background, &color);
gegl_color_get_pixel (style->foreground, babl_format ("R'G'B' double"), rgb);
g_printerr ("Setting foreground color to %lg %lg %lg\n",
rgb[0], rgb[1], rgb[2]);
}
g_clear_object (&style->background);
style->background = gimp_color_button_get_color (GIMP_COLOR_BUTTON (gfig_context->bg_color_button));
/* FIXME: issues of ownership.
* A resource is a pointer to an object.

View File

@ -46,8 +46,8 @@ struct _Style
gdouble fill_opacity;
PaintType paint_type;
GimpRGB foreground;
GimpRGB background;
GeglColor *foreground;
GeglColor *background;
gboolean reverselines;
gint ref_count;
};
@ -88,9 +88,6 @@ void gfig_gradient_changed_callback (gpointer user_data,
GimpGradient *gradient,
gboolean dialog_closing);
void gfig_rgba_copy (GimpRGB *color1,
GimpRGB *color2);
void gfig_style_copy (Style *style1,
Style *style0,
const gchar *name);

View File

@ -163,8 +163,8 @@ typedef struct
GtkWidget *gradient_select;
GtkWidget *fillstyle_combo;
GtkWidget *paint_type_toggle;
GimpRGB *fg_color;
GimpRGB *bg_color;
GeglColor *fg_color;
GeglColor *bg_color;
gboolean enable_repaint;
gboolean using_new_layer;
} GFigContext;

View File

@ -99,7 +99,7 @@ general_restore (void)
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (general_tileable),
pcvals.general_tileable);
gimp_color_button_set_color (GIMP_COLOR_BUTTON (general_color_button),
&pcvals.color);
pcvals.color);
gimp_label_spin_set_value (GIMP_LABEL_SPIN (dev_thresh_scale),
pcvals.devthresh);
}
@ -112,6 +112,14 @@ select_color (GtkWidget *widget, gpointer data)
TRUE);
}
static void
color_changed (GimpColorButton *button,
gpointer data)
{
g_clear_object (&pcvals.color);
pcvals.color = gimp_color_button_get_color (button);
}
static GtkWidget *
create_general_button (GtkWidget *box,
int idx,
@ -166,15 +174,17 @@ create_generalpage (GtkNotebook *notebook)
_("Solid colored background"),
&radio_group);
pcvals.color = gegl_color_new ("black");
general_color_button = gimp_color_button_new (_("Color"),
COLORBUTTONWIDTH,
COLORBUTTONHEIGHT,
&pcvals.color,
pcvals.color,
GIMP_COLOR_AREA_FLAT);
g_signal_connect (general_color_button, "clicked",
G_CALLBACK (select_color), NULL);
g_signal_connect (general_color_button, "color-changed",
G_CALLBACK (gimp_color_button_get_color),
G_CALLBACK (color_changed),
&pcvals.color);
gtk_box_pack_start (GTK_BOX (box4), general_color_button, FALSE, FALSE, 0);
gtk_widget_show (general_color_button);

View File

@ -70,7 +70,7 @@ typedef struct
int run;
char selected_brush[200];
char selected_paper[200];
GimpRGB color;
GeglColor *color;
int general_paint_edges;
int place_type;
vector_t orient_vectors[MAXORIENTVECT];

View File

@ -47,7 +47,7 @@ static const gimpressionist_vals_t defaultpcvals = {
0,
"defaultbrush.pgm",
"defaultpaper.pgm",
{0,0,0,1.0},
NULL,
1,
0,
{ { 0.5, 0.5, 0.0, 0.0, 1.0, 1.0, 0 } },

View File

@ -429,7 +429,11 @@ set_values (const gchar *key, const gchar *val)
else if (!strcmp (key, "color"))
{
char *c = parse_rgb_string (val);
gimp_rgba_set_uchar (&pcvals.color, c[0], c[1], c[2], 255);
if (pcvals.color == NULL)
pcvals.color = gegl_color_new (NULL);
gegl_color_set_pixel (pcvals.color, babl_format ("R'G'B' u8"), c);
}
else if (!strcmp (key, "numorientvector"))
@ -820,7 +824,7 @@ save_preset (void)
fprintf (f, "selectedbrush=%s\n", pcvals.selected_brush);
fprintf (f, "selectedpaper=%s\n", pcvals.selected_paper);
gimp_rgb_get_uchar (&pcvals.color, &color[0], &color[1], &color[2]);
gegl_color_get_pixel (pcvals.color, babl_format ("R'G'B' u8"), color);
fprintf (f, "color=%02x%02x%02x\n", color[0], color[1], color[2]);
fprintf (f, "placetype=%d\n", pcvals.place_type);

View File

@ -543,8 +543,7 @@ repaint (ppm_t *p, ppm_t *a)
guchar tmpcol[3];
ppm_new (&tmp, p->width, p->height);
gimp_rgb_get_uchar (&runningvals.color,
&tmpcol[0], &tmpcol[1], &tmpcol[2]);
gegl_color_get_pixel (runningvals.color, babl_format ("R'G'B' u8"), tmpcol);
fill (&tmp, tmpcol);
}
else if (runningvals.general_background_type == BG_TYPE_KEEP_ORIGINAL)

View File

@ -96,7 +96,7 @@ typedef struct
typedef struct
{
GimpRGB *color;
GeglColor *color;
GtkWidget *hbox;
GtkWidget *orig_preview;
GtkWidget *button;
@ -2023,7 +2023,8 @@ color_map_create (const gchar *name,
GeglColor *color;
gimp_rgb_set_alpha (data, 1.0);
color_map->color = data;
color_map->color = gegl_color_new (NULL);
gegl_color_set_pixel (color_map->color, babl_format ("R'G'B'A double"), data);
color_map->fixed_point = fixed_point;
color_map->hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2);
@ -2050,16 +2051,12 @@ color_map_create (const gchar *name,
color_map->button = gimp_color_button_new (name,
COLOR_SAMPLE_SIZE,
COLOR_SAMPLE_SIZE,
data,
color_map->color,
GIMP_COLOR_AREA_FLAT);
gtk_box_pack_start (GTK_BOX (color_map->hbox), color_map->button,
FALSE, FALSE, 0);
gtk_widget_show (color_map->button);
g_signal_connect (color_map->button, "color-changed",
G_CALLBACK (gimp_color_button_get_color),
data);
g_signal_connect (color_map->button, "color-changed",
G_CALLBACK (color_map_color_changed_cb),
color_map);
@ -2084,6 +2081,9 @@ color_map_color_changed_cb (GtkWidget *widget,
update_values ();
ifs_compose_preview ();
g_clear_object (&color_map->color);
color_map->color = gimp_color_button_get_color (GIMP_COLOR_BUTTON (widget));
}
static void
@ -2093,14 +2093,7 @@ color_map_update (ColorMap *color_map)
color_map->color);
if (color_map->fixed_point)
{
GeglColor *color;
color = gegl_color_new (NULL);
gegl_color_get_pixel (color, babl_format ("R'G'B'A double"), color_map->color);
gimp_color_area_set_color (GIMP_COLOR_AREA (color_map->orig_preview), color);
g_object_unref (color);
}
gimp_color_area_set_color (GIMP_COLOR_AREA (color_map->orig_preview), color_map->color);
}
static void

View File

@ -313,14 +313,19 @@ preferences_ok_cb (gpointer data)
static void
get_button_color (GtkWidget *button,
GdkRGBA *color)
GdkRGBA *rgba)
{
GimpRGB rgb;
gimp_color_button_get_color (GIMP_COLOR_BUTTON (button), &rgb);
color->red = rgb.r;
color->green = rgb.g;
color->blue = rgb.b;
color->alpha = 1.0;
GeglColor *color;
gdouble rgb[3];
color = gimp_color_button_get_color (GIMP_COLOR_BUTTON (button));
gegl_color_get_pixel (color, babl_format ("R'G'B' double"), rgb);
rgba->red = rgb[0];
rgba->green = rgb[1];
rgba->blue = rgb[2];
rgba->alpha = 1.0;
g_object_unref (color);
}
static void
@ -336,10 +341,13 @@ get_button_colors(PreferencesDialog_t *dialog, ColorSelData_t *colors)
static void
set_button_color (GtkWidget *button,
GdkRGBA *color)
GdkRGBA *rgba)
{
gimp_color_button_set_color (GIMP_COLOR_BUTTON (button),
(GimpRGB *) color);
GeglColor *color = gegl_color_new (NULL);
gegl_color_set_rgba_with_space (color, rgba->red, rgba->green, rgba->blue, rgba->alpha, NULL);
gimp_color_button_set_color (GIMP_COLOR_BUTTON (button), color);
g_object_unref (color);
}
static void
@ -437,13 +445,15 @@ static GtkWidget*
create_color_field (PreferencesDialog_t *data, GtkWidget *grid, gint row,
gint col)
{
GimpRGB color = {0.0, 0.0, 0.0, 1.0};
GtkWidget *area = gimp_color_button_new (_("Select Color"), 16, 8, &color,
GIMP_COLOR_AREA_FLAT);
GeglColor *color = gegl_color_new ("black");
GtkWidget *area = gimp_color_button_new (_("Select Color"), 16, 8, color,
GIMP_COLOR_AREA_FLAT);
gimp_color_button_set_update (GIMP_COLOR_BUTTON (area), TRUE);
gtk_grid_attach (GTK_GRID (grid), area, col, row, 1, 1);
gtk_widget_show (area);
g_object_unref (color);
return area;
}

View File

@ -82,6 +82,8 @@ static void script_fu_file_callback (GtkWidget *widget,
SFFilename *file);
static void script_fu_combo_callback (GtkWidget *widget,
SFOption *option);
static void script_fu_color_button_update (GimpColorButton *button,
GimpRGB *rgb);
static void script_fu_resource_set_handler (gpointer data,
gpointer resource,
@ -321,13 +323,14 @@ script_fu_interface (SFScript *script,
case SF_COLOR:
{
GimpColorConfig *config;
GeglColor *color = gegl_color_new (NULL);
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), &arg->value.sfa_color);
left_align = TRUE;
widget = gimp_color_button_new (_("Script-Fu Color Selection"),
COLOR_SAMPLE_WIDTH,
COLOR_SAMPLE_HEIGHT,
&arg->value.sfa_color,
GIMP_COLOR_AREA_FLAT);
COLOR_SAMPLE_WIDTH, COLOR_SAMPLE_HEIGHT,
color, GIMP_COLOR_AREA_FLAT);
gimp_color_button_set_update (GIMP_COLOR_BUTTON (widget), TRUE);
@ -335,9 +338,10 @@ script_fu_interface (SFScript *script,
gimp_color_button_set_color_config (GIMP_COLOR_BUTTON (widget),
config);
g_object_unref (config);
g_object_unref (color);
g_signal_connect (widget, "color-changed",
G_CALLBACK (gimp_color_button_get_color),
G_CALLBACK (script_fu_color_button_update),
&arg->value.sfa_color);
}
break;
@ -694,6 +698,17 @@ script_fu_combo_callback (GtkWidget *widget,
option->history = gtk_combo_box_get_active (GTK_COMBO_BOX (widget));
}
static void
script_fu_color_button_update (GimpColorButton *button,
GimpRGB *rgb)
{
GeglColor *color = gimp_color_button_get_color (button);
gegl_color_get_pixel (color, babl_format ("R'G'B'A double"), rgb);
g_object_unref (color);
}
/* Handle resource-set signal.
* Store id of newly chosen resource in SF local cache of args,
* at the integer location passed by pointer in "data"
@ -887,8 +902,13 @@ script_fu_reset (SFScript *script)
break;
case SF_COLOR:
gimp_color_button_set_color (GIMP_COLOR_BUTTON (widget),
&value->sfa_color);
{
GeglColor *color = gegl_color_new (NULL);
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), &value->sfa_color);
gimp_color_button_set_color (GIMP_COLOR_BUTTON (widget), color);
g_object_unref (color);
}
break;
case SF_TOGGLE: