widgets: Port gimp_get_color_tag_color ()...

...to accept GeglColor paramaters instead
of GimpRGB. This function is used to draw
the layer/channel color tags.
Note that a temporary GimpRGB was left
to use with gimp_rgb_composite ().
It will be replaced once that function is
also converted to use GeglColor.
This commit is contained in:
Alx Sa
2024-04-02 04:00:50 +00:00
parent 2f2027b757
commit 10eb615eff
5 changed files with 42 additions and 32 deletions

View File

@ -55,12 +55,9 @@ items_actions_setup (GimpActionGroup *group,
} }
else else
{ {
GeglColor *color; GeglColor *color = gegl_color_new ("none");
GimpRGB rgb;
gimp_get_color_tag_color (value->value, &rgb, FALSE); gimp_get_color_tag_color (value->value, color, 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); gimp_action_group_set_action_color (group, action, color, FALSE);
g_object_unref (color); g_object_unref (color);
} }
@ -77,14 +74,14 @@ items_actions_update (GimpActionGroup *group,
GEnumClass *enum_class; GEnumClass *enum_class;
GEnumValue *value; GEnumValue *value;
gchar action[32]; gchar action[32];
gboolean visible = FALSE; gboolean visible = FALSE;
gboolean has_color_tag = FALSE; gboolean has_color_tag = FALSE;
gboolean lock_content = TRUE; gboolean lock_content = TRUE;
gboolean can_lock_content = FALSE; gboolean can_lock_content = FALSE;
gboolean lock_position = TRUE; gboolean lock_position = TRUE;
gboolean can_lock_position = FALSE; gboolean can_lock_position = FALSE;
GimpRGB tag_color; GeglColor *tag_color = gegl_color_new ("none");
GList *iter; GList *iter;
for (iter = items; iter; iter = iter->next) for (iter = items; iter; iter = iter->next)
{ {
@ -116,8 +113,9 @@ items_actions_update (GimpActionGroup *group,
has_color_tag = (has_color_tag || has_color_tag = (has_color_tag ||
gimp_get_color_tag_color (gimp_item_get_color_tag (item), gimp_get_color_tag_color (gimp_item_get_color_tag (item),
&tag_color, FALSE)); tag_color, FALSE));
} }
g_object_unref (tag_color);
#define SET_SENSITIVE(action,condition) \ #define SET_SENSITIVE(action,condition) \
gimp_action_group_set_action_sensitive (group, action, (condition) != 0, NULL) gimp_action_group_set_action_sensitive (group, action, (condition) != 0, NULL)

View File

@ -216,7 +216,7 @@ item_options_dialog_new (GimpImage *image,
list = g_list_next (list)) list = g_list_next (list))
{ {
GimpColorTag color_tag; GimpColorTag color_tag;
GimpRGB rgb; GeglColor *rgb = gegl_color_new ("none");
GtkWidget *image; GtkWidget *image;
radio = list->data; radio = list->data;
@ -228,25 +228,22 @@ item_options_dialog_new (GimpImage *image,
color_tag = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (radio), color_tag = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (radio),
"gimp-item-data")); "gimp-item-data"));
if (gimp_get_color_tag_color (color_tag, &rgb, FALSE)) if (gimp_get_color_tag_color (color_tag, rgb, FALSE))
{ {
GeglColor *color = gegl_color_new (NULL); gint w, h;
gint w, h;
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), &rgb); image = gimp_color_area_new (rgb, GIMP_COLOR_AREA_FLAT, 0);
image = gimp_color_area_new (color, GIMP_COLOR_AREA_FLAT, 0);
gimp_color_area_set_color_config (GIMP_COLOR_AREA (image), gimp_color_area_set_color_config (GIMP_COLOR_AREA (image),
context->gimp->config->color_management); context->gimp->config->color_management);
gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, &w, &h); gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, &w, &h);
gtk_widget_set_size_request (image, w, h); gtk_widget_set_size_request (image, w, h);
g_object_unref (color);
} }
else else
{ {
image = gtk_image_new_from_icon_name (GIMP_ICON_CLOSE, image = gtk_image_new_from_icon_name (GIMP_ICON_CLOSE,
GTK_ICON_SIZE_MENU); GTK_ICON_SIZE_MENU);
} }
g_object_unref (rgb);
gtk_container_add (GTK_CONTAINER (radio), image); gtk_container_add (GTK_CONTAINER (radio), image);
gtk_widget_show (image); gtk_widget_show (image);

View File

@ -1619,7 +1619,8 @@ gimp_item_tree_view_insert_item (GimpContainerView *view,
GimpItemTreeView *item_view = GIMP_ITEM_TREE_VIEW (view); GimpItemTreeView *item_view = GIMP_ITEM_TREE_VIEW (view);
GimpItem *item = GIMP_ITEM (viewable); GimpItem *item = GIMP_ITEM (viewable);
GtkTreeIter *iter; GtkTreeIter *iter;
GimpRGB color; GeglColor *color = gegl_color_new ("none");
GdkRGBA rgba;
gboolean has_color; gboolean has_color;
const gchar *icon_name; const gchar *icon_name;
gint n_locks; gint n_locks;
@ -1628,9 +1629,11 @@ gimp_item_tree_view_insert_item (GimpContainerView *view,
parent_insert_data, index); parent_insert_data, index);
has_color = gimp_get_color_tag_color (gimp_item_get_merged_color_tag (item), has_color = gimp_get_color_tag_color (gimp_item_get_merged_color_tag (item),
&color, color,
gimp_item_get_color_tag (item) == gimp_item_get_color_tag (item) ==
GIMP_COLOR_TAG_NONE); GIMP_COLOR_TAG_NONE);
gegl_color_get_pixel (color, babl_format ("R'G'B'A double"), &rgba);
g_object_unref (color);
n_locks = gimp_item_tree_view_get_n_locks (item_view, item, &icon_name); n_locks = gimp_item_tree_view_get_n_locks (item_view, item, &icon_name);
@ -1650,7 +1653,7 @@ gimp_item_tree_view_insert_item (GimpContainerView *view,
icon_name, icon_name,
item_view->priv->model_column_color_tag, item_view->priv->model_column_color_tag,
has_color ? (GdkRGBA *) &color : NULL, has_color ? &rgba : NULL,
-1); -1);
if (GIMP_IS_LAYER_TREE_VIEW (item_view)) if (GIMP_IS_LAYER_TREE_VIEW (item_view))
@ -2835,17 +2838,20 @@ gimp_item_tree_view_color_tag_changed (GimpItem *item,
if (iter) if (iter)
{ {
GimpContainer *children; GimpContainer *children;
GimpRGB color; GeglColor *color = gegl_color_new ("none");
GdkRGBA rgba;
gboolean has_color; gboolean has_color;
has_color = gimp_get_color_tag_color (gimp_item_get_merged_color_tag (item), has_color = gimp_get_color_tag_color (gimp_item_get_merged_color_tag (item),
&color, color,
gimp_item_get_color_tag (item) == gimp_item_get_color_tag (item) ==
GIMP_COLOR_TAG_NONE); GIMP_COLOR_TAG_NONE);
gegl_color_get_pixel (color, babl_format ("R'G'B'A double"), &rgba);
g_object_unref (color);
gtk_tree_store_set (GTK_TREE_STORE (tree_view->model), iter, gtk_tree_store_set (GTK_TREE_STORE (tree_view->model), iter,
view->priv->model_column_color_tag, view->priv->model_column_color_tag,
has_color ? (GdkRGBA *) &color : NULL, has_color ? &rgba : NULL,
-1); -1);
children = gimp_viewable_get_children (GIMP_VIEWABLE (item)); children = gimp_viewable_get_children (GIMP_VIEWABLE (item));

View File

@ -1096,7 +1096,7 @@ gimp_get_message_icon_name (GimpMessageSeverity severity)
gboolean gboolean
gimp_get_color_tag_color (GimpColorTag color_tag, gimp_get_color_tag_color (GimpColorTag color_tag,
GimpRGB *color, GeglColor *color,
gboolean inherited) gboolean inherited)
{ {
static const struct static const struct
@ -1123,16 +1123,25 @@ gimp_get_color_tag_color (GimpColorTag color_tag,
if (color_tag > GIMP_COLOR_TAG_NONE) if (color_tag > GIMP_COLOR_TAG_NONE)
{ {
gimp_rgba_set_uchar (color, gegl_color_set_rgba (color,
colors[color_tag].r, colors[color_tag].r / 255.0f,
colors[color_tag].g, colors[color_tag].g / 255.0f,
colors[color_tag].b, colors[color_tag].b / 255.0f,
255); 1.0f);
if (inherited) if (inherited)
{ {
gimp_rgb_composite (color, &(GimpRGB) {1.0, 1.0, 1.0, 0.2}, /* TODO: Replace once gimp_rgb_composite () is replaced with
* GeglColor composite function */
GimpRGB temp_color;
gegl_color_get_pixel (color, babl_format ("R'G'B'A double"),
&temp_color);
gimp_rgb_set_alpha (&temp_color, 1.0f);
gimp_rgb_composite (&temp_color, &(GimpRGB) {1.0, 1.0, 1.0, 0.2},
GIMP_RGB_COMPOSITE_NORMAL); GIMP_RGB_COMPOSITE_NORMAL);
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"),
&temp_color);
} }
return TRUE; return TRUE;

View File

@ -80,7 +80,7 @@ void gimp_widget_set_accel_help (GtkWidget *widget
const gchar * gimp_get_message_icon_name (GimpMessageSeverity severity); const gchar * gimp_get_message_icon_name (GimpMessageSeverity severity);
gboolean gimp_get_color_tag_color (GimpColorTag color_tag, gboolean gimp_get_color_tag_color (GimpColorTag color_tag,
GimpRGB *color, GeglColor *color,
gboolean inherited); gboolean inherited);
void gimp_pango_layout_set_scale (PangoLayout *layout, void gimp_pango_layout_set_scale (PangoLayout *layout,