2022-02-17 05:20:46 +08:00
|
|
|
/* LIBGIMP - The GIMP Library
|
|
|
|
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
|
|
|
*
|
|
|
|
* gimplabelcolor.c
|
|
|
|
* Copyright (C) 2022 Jehan
|
|
|
|
*
|
|
|
|
* This library is free software: you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 3 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library. If not, see
|
|
|
|
* <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <gegl.h>
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
|
|
#include "libgimpcolor/gimpcolor.h"
|
|
|
|
#include "libgimpmath/gimpmath.h"
|
|
|
|
#include "libgimpbase/gimpbase.h"
|
|
|
|
|
|
|
|
#include "gimpwidgets.h"
|
|
|
|
#include "gimpwidgets-private.h"
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* SECTION: gimplabelcolor
|
|
|
|
* @title: GimpLabelColor
|
2022-02-18 04:29:13 +08:00
|
|
|
* @short_description: Widget containing a color widget and a label.
|
2022-02-17 05:20:46 +08:00
|
|
|
*
|
|
|
|
* This widget is a subclass of #GimpLabeled with a #GtkColor.
|
|
|
|
**/
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
VALUE_CHANGED,
|
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
|
|
|
PROP_VALUE,
|
2022-02-18 04:29:13 +08:00
|
|
|
PROP_EDITABLE,
|
|
|
|
N_PROPS
|
2022-02-17 05:20:46 +08:00
|
|
|
};
|
2022-02-18 04:29:13 +08:00
|
|
|
static GParamSpec *object_props[N_PROPS] = { NULL, };
|
|
|
|
|
2022-02-17 05:20:46 +08:00
|
|
|
|
|
|
|
typedef struct _GimpLabelColorPrivate
|
|
|
|
{
|
|
|
|
GtkWidget *area;
|
2022-02-18 04:29:13 +08:00
|
|
|
gboolean editable;
|
2022-02-17 05:20:46 +08:00
|
|
|
} GimpLabelColorPrivate;
|
|
|
|
|
|
|
|
static void gimp_label_color_constructed (GObject *object);
|
|
|
|
static void gimp_label_color_set_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec);
|
|
|
|
static void gimp_label_color_get_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec);
|
|
|
|
|
|
|
|
static GtkWidget * gimp_label_color_populate (GimpLabeled *color,
|
|
|
|
gint *x,
|
|
|
|
gint *y,
|
|
|
|
gint *width,
|
|
|
|
gint *height);
|
|
|
|
|
2023-11-21 04:38:11 +08:00
|
|
|
static gboolean gimp_label_color_from_color_area (GBinding *binding,
|
|
|
|
const GValue *from_value,
|
|
|
|
GValue* to_value,
|
|
|
|
gpointer user_data);
|
|
|
|
static gboolean gimp_label_color_to_color_area (GBinding *binding,
|
|
|
|
const GValue *from_value,
|
|
|
|
GValue* to_value,
|
|
|
|
gpointer user_data);
|
|
|
|
|
|
|
|
|
2022-02-17 05:20:46 +08:00
|
|
|
G_DEFINE_TYPE_WITH_PRIVATE (GimpLabelColor, gimp_label_color, GIMP_TYPE_LABELED)
|
|
|
|
|
|
|
|
#define parent_class gimp_label_color_parent_class
|
|
|
|
|
|
|
|
static guint gimp_label_color_signals[LAST_SIGNAL] = { 0 };
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_label_color_class_init (GimpLabelColorClass *klass)
|
|
|
|
{
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
GimpLabeledClass *labeled_class = GIMP_LABELED_CLASS (klass);
|
|
|
|
|
|
|
|
gimp_label_color_signals[VALUE_CHANGED] =
|
|
|
|
g_signal_new ("value-changed",
|
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
|
|
|
G_STRUCT_OFFSET (GimpLabelColorClass, value_changed),
|
|
|
|
NULL, NULL, NULL,
|
|
|
|
G_TYPE_NONE, 0);
|
|
|
|
|
|
|
|
object_class->constructed = gimp_label_color_constructed;
|
|
|
|
object_class->set_property = gimp_label_color_set_property;
|
|
|
|
object_class->get_property = gimp_label_color_get_property;
|
|
|
|
|
|
|
|
labeled_class->populate = gimp_label_color_populate;
|
|
|
|
|
2023-11-21 04:38:11 +08:00
|
|
|
babl_init ();
|
2022-02-17 05:20:46 +08:00
|
|
|
/**
|
|
|
|
* GimpLabelColor:value:
|
|
|
|
*
|
|
|
|
* The currently set value.
|
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
2023-11-21 04:38:11 +08:00
|
|
|
object_props[PROP_VALUE] = gegl_param_spec_color_from_string ("value",
|
|
|
|
"Color",
|
|
|
|
"The displayed color",
|
|
|
|
"black",
|
|
|
|
GIMP_PARAM_READWRITE |
|
|
|
|
G_PARAM_CONSTRUCT);
|
2022-02-18 04:29:13 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* GimpLabelColor:editable:
|
|
|
|
*
|
|
|
|
* Whether the color can be edited.
|
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
|
|
|
object_props[PROP_EDITABLE] = g_param_spec_boolean ("editable",
|
|
|
|
"Whether the color can be edited",
|
|
|
|
"Whether the color can be edited",
|
|
|
|
FALSE,
|
|
|
|
GIMP_PARAM_READWRITE);
|
|
|
|
|
|
|
|
g_object_class_install_properties (object_class, N_PROPS, object_props);
|
2022-02-17 05:20:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_label_color_init (GimpLabelColor *color)
|
|
|
|
{
|
|
|
|
GimpLabelColorPrivate *priv = gimp_label_color_get_instance_private (color);
|
|
|
|
GimpRGB black;
|
|
|
|
|
|
|
|
gimp_rgba_set (&black, 0.0, 0.0, 0.0, 1.0);
|
2022-02-18 04:29:13 +08:00
|
|
|
priv->editable = FALSE;
|
2022-02-17 05:20:46 +08:00
|
|
|
priv->area = gimp_color_area_new (&black, GIMP_COLOR_AREA_SMALL_CHECKS,
|
|
|
|
GDK_BUTTON1_MASK | GDK_BUTTON2_MASK);
|
|
|
|
|
|
|
|
/* Typically for a labelled color area, a small square next to your
|
|
|
|
* label is probably what you want to display.
|
|
|
|
*/
|
|
|
|
gtk_widget_set_size_request (priv->area, 20, 20);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_label_color_constructed (GObject *object)
|
|
|
|
{
|
|
|
|
GimpLabelColor *color = GIMP_LABEL_COLOR (object);
|
|
|
|
GimpLabelColorPrivate *priv = gimp_label_color_get_instance_private (color);
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (parent_class)->constructed (object);
|
|
|
|
|
|
|
|
/* This is important to make this object into a property widget. It
|
|
|
|
* will allow config object to bind the "value" property of this
|
|
|
|
* widget, and therefore be updated automatically.
|
|
|
|
*/
|
2023-11-21 04:38:11 +08:00
|
|
|
g_object_bind_property_full (G_OBJECT (priv->area), "color",
|
|
|
|
G_OBJECT (color), "value",
|
|
|
|
G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE,
|
|
|
|
gimp_label_color_from_color_area,
|
|
|
|
gimp_label_color_to_color_area,
|
|
|
|
NULL, NULL);
|
2022-02-17 05:20:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_label_color_set_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GimpLabelColor *lcolor = GIMP_LABEL_COLOR (object);
|
|
|
|
GimpLabelColorPrivate *priv = gimp_label_color_get_instance_private (lcolor);
|
|
|
|
|
|
|
|
switch (property_id)
|
|
|
|
{
|
|
|
|
case PROP_VALUE:
|
|
|
|
{
|
2023-11-21 04:38:11 +08:00
|
|
|
GeglColor *new_color;
|
|
|
|
GeglColor *color;
|
|
|
|
GimpRGB *rgb;
|
2022-02-17 05:20:46 +08:00
|
|
|
|
2023-11-21 04:38:11 +08:00
|
|
|
new_color = g_value_get_object (value);
|
2022-02-17 05:20:46 +08:00
|
|
|
|
2022-02-18 04:29:13 +08:00
|
|
|
g_object_get (priv->area,
|
2023-11-21 04:38:11 +08:00
|
|
|
"color", &rgb,
|
2022-02-18 04:29:13 +08:00
|
|
|
NULL);
|
2022-02-17 05:20:46 +08:00
|
|
|
|
2023-11-21 04:38:11 +08:00
|
|
|
color = gegl_color_new (NULL);
|
|
|
|
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), rgb);
|
2022-02-17 05:20:46 +08:00
|
|
|
/* Avoid looping forever since we have bound this widget's
|
|
|
|
* "value" property with the color button "value" property.
|
|
|
|
*/
|
2023-11-21 04:38:11 +08:00
|
|
|
if (! gimp_color_is_perceptually_identical (color, new_color))
|
2022-02-17 05:20:46 +08:00
|
|
|
{
|
2023-11-21 04:38:11 +08:00
|
|
|
gegl_color_get_pixel (new_color, babl_format ("R'G'B'A double"), rgb);
|
|
|
|
g_object_set (priv->area, "color", rgb, NULL);
|
2022-02-17 05:20:46 +08:00
|
|
|
g_signal_emit (object, gimp_label_color_signals[VALUE_CHANGED], 0);
|
|
|
|
}
|
2023-11-21 04:38:11 +08:00
|
|
|
g_object_unref (color);
|
2022-02-18 04:29:13 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case PROP_EDITABLE:
|
|
|
|
if (priv->editable != g_value_get_boolean (value))
|
|
|
|
{
|
|
|
|
const gchar *dialog_title;
|
|
|
|
GimpLabeled *labeled;
|
2023-11-21 04:38:11 +08:00
|
|
|
GimpRGB *rgb;
|
2022-02-18 04:29:13 +08:00
|
|
|
GimpColorAreaType type;
|
|
|
|
gboolean attached;
|
|
|
|
|
|
|
|
labeled = GIMP_LABELED (lcolor);
|
|
|
|
/* Reuse the label contents (without mnemonics) as dialog
|
|
|
|
* title for the color selection. This is why the "editable"
|
|
|
|
* property must not be a G_PARAM_CONSTRUCT.
|
|
|
|
*/
|
|
|
|
dialog_title = gtk_label_get_text (GTK_LABEL (gimp_labeled_get_label (labeled)));
|
|
|
|
|
|
|
|
attached = (gtk_widget_get_parent (priv->area) != NULL);
|
|
|
|
g_object_get (priv->area,
|
|
|
|
"type", &type,
|
2023-11-21 04:38:11 +08:00
|
|
|
"color", &rgb,
|
2022-02-18 04:29:13 +08:00
|
|
|
NULL);
|
|
|
|
|
|
|
|
gtk_widget_destroy (priv->area);
|
|
|
|
|
|
|
|
priv->editable = g_value_get_boolean (value);
|
|
|
|
if (priv->editable)
|
|
|
|
priv->area = gimp_color_button_new (dialog_title,
|
2023-11-21 04:38:11 +08:00
|
|
|
20, 20, rgb, type);
|
2022-02-18 04:29:13 +08:00
|
|
|
else
|
2023-11-21 04:38:11 +08:00
|
|
|
priv->area = gimp_color_area_new (rgb, type,
|
2022-02-18 04:29:13 +08:00
|
|
|
GDK_BUTTON1_MASK | GDK_BUTTON2_MASK);
|
|
|
|
|
|
|
|
gtk_widget_set_size_request (priv->area, 20, 20);
|
2023-11-21 04:38:11 +08:00
|
|
|
g_object_bind_property_full (G_OBJECT (priv->area), "color",
|
|
|
|
G_OBJECT (lcolor), "value",
|
|
|
|
G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE,
|
|
|
|
gimp_label_color_from_color_area,
|
|
|
|
gimp_label_color_to_color_area,
|
|
|
|
NULL, NULL);
|
2022-02-18 04:29:13 +08:00
|
|
|
|
|
|
|
if (attached)
|
|
|
|
{
|
|
|
|
gtk_grid_attach (GTK_GRID (lcolor), priv->area, 1, 0, 1, 1);
|
|
|
|
gtk_widget_show (priv->area);
|
2022-02-18 06:24:05 +08:00
|
|
|
g_signal_emit_by_name (object, "mnemonic-widget-changed", priv->area);
|
2022-02-18 04:29:13 +08:00
|
|
|
}
|
2022-02-17 05:20:46 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_label_color_get_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GimpLabelColor *color = GIMP_LABEL_COLOR (object);
|
|
|
|
GimpLabelColorPrivate *priv = gimp_label_color_get_instance_private (color);
|
|
|
|
|
|
|
|
switch (property_id)
|
|
|
|
{
|
|
|
|
case PROP_VALUE:
|
2023-11-21 04:38:11 +08:00
|
|
|
{
|
|
|
|
GimpRGB *rgb;
|
|
|
|
GeglColor *color = gegl_color_new (NULL);
|
|
|
|
|
|
|
|
g_object_get (priv->area,
|
|
|
|
"color", &rgb,
|
|
|
|
NULL);
|
|
|
|
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), rgb);
|
|
|
|
g_value_take_object (value, color);
|
|
|
|
}
|
2022-02-17 05:20:46 +08:00
|
|
|
break;
|
2022-02-18 04:29:13 +08:00
|
|
|
case PROP_EDITABLE:
|
|
|
|
g_value_set_boolean (value, priv->editable);
|
|
|
|
break;
|
|
|
|
|
2022-02-17 05:20:46 +08:00
|
|
|
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static GtkWidget *
|
|
|
|
gimp_label_color_populate (GimpLabeled *labeled,
|
|
|
|
gint *x,
|
|
|
|
gint *y,
|
|
|
|
gint *width,
|
|
|
|
gint *height)
|
|
|
|
{
|
|
|
|
GimpLabelColor *color = GIMP_LABEL_COLOR (labeled);
|
|
|
|
GimpLabelColorPrivate *priv = gimp_label_color_get_instance_private (color);
|
|
|
|
|
|
|
|
gtk_grid_attach (GTK_GRID (color), priv->area, 1, 0, 1, 1);
|
|
|
|
/* Make sure the label and color won't be glued next to each other's. */
|
|
|
|
gtk_grid_set_column_spacing (GTK_GRID (color),
|
|
|
|
4 * gtk_widget_get_scale_factor (GTK_WIDGET (color)));
|
|
|
|
gtk_widget_show (priv->area);
|
|
|
|
|
|
|
|
return priv->area;
|
|
|
|
}
|
|
|
|
|
2023-11-21 04:38:11 +08:00
|
|
|
static gboolean
|
|
|
|
gimp_label_color_from_color_area (GBinding *binding,
|
|
|
|
const GValue *from_value,
|
|
|
|
GValue* to_value,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
GimpRGB *rgb = g_value_get_boxed (from_value);
|
|
|
|
GeglColor *color = gegl_color_new (NULL);
|
|
|
|
|
|
|
|
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), rgb);
|
|
|
|
g_value_take_object (to_value, color);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gimp_label_color_to_color_area (GBinding *binding,
|
|
|
|
const GValue *from_value,
|
|
|
|
GValue* to_value,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
GeglColor *color = g_value_get_object (from_value);
|
|
|
|
GimpRGB rgb;
|
|
|
|
|
|
|
|
gegl_color_get_pixel (color, babl_format ("R'G'B'A double"), &rgb);
|
|
|
|
g_value_set_boxed (to_value, &rgb);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2022-02-17 05:20:46 +08:00
|
|
|
|
|
|
|
/* Public Functions */
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gimp_label_color_new:
|
|
|
|
* @label: The text for the #GtkLabel.
|
|
|
|
* @color: The color displayed.
|
|
|
|
*
|
|
|
|
* Creates a #GimpLabelColor which contains a widget and displays a
|
|
|
|
* color area. By default, the color area is of type
|
|
|
|
* %GIMP_COLOR_AREA_SMALL_CHECKS, which means transparency of @color
|
2022-02-18 04:29:13 +08:00
|
|
|
* will be shown.
|
|
|
|
*
|
|
|
|
* Moreover in the non-editable case, the color is draggable to other
|
|
|
|
* widgets accepting color drops with buttons 1 and 2.
|
|
|
|
* In the editable case, the @label is reused as the color chooser's
|
|
|
|
* dialog title.
|
2022-02-17 05:20:46 +08:00
|
|
|
*
|
2023-07-22 03:35:23 +08:00
|
|
|
* If you wish to customize any of these default behaviors, get the
|
2022-02-18 04:29:13 +08:00
|
|
|
* #GimpColorArea or #GimpColorButton with gimp_label_color_get_color_widget().
|
2022-02-17 05:20:46 +08:00
|
|
|
*
|
|
|
|
* Returns: (transfer full): The new #GimpLabelColor widget.
|
|
|
|
**/
|
|
|
|
GtkWidget *
|
2023-11-21 04:38:11 +08:00
|
|
|
gimp_label_color_new (const gchar *label,
|
|
|
|
GeglColor *color,
|
|
|
|
gboolean editable)
|
2022-02-17 05:20:46 +08:00
|
|
|
{
|
|
|
|
GtkWidget *labeled;
|
|
|
|
|
|
|
|
labeled = g_object_new (GIMP_TYPE_LABEL_COLOR,
|
2022-02-18 04:29:13 +08:00
|
|
|
"label", label,
|
|
|
|
"value", color,
|
|
|
|
"editable", editable,
|
2022-02-17 05:20:46 +08:00
|
|
|
NULL);
|
|
|
|
|
|
|
|
return labeled;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gimp_label_color_set_value:
|
|
|
|
* @color: The #GtkLabelColor.
|
|
|
|
* @value: A new value.
|
|
|
|
*
|
|
|
|
* This function sets the value in the #GtkColor inside @color.
|
|
|
|
**/
|
|
|
|
void
|
|
|
|
gimp_label_color_set_value (GimpLabelColor *color,
|
2023-11-21 04:38:11 +08:00
|
|
|
GeglColor *value)
|
2022-02-17 05:20:46 +08:00
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_LABEL_COLOR (color));
|
2023-11-21 04:38:11 +08:00
|
|
|
g_return_if_fail (GEGL_IS_COLOR (value));
|
2022-02-17 05:20:46 +08:00
|
|
|
|
|
|
|
g_object_set (color,
|
|
|
|
"value", value,
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gimp_label_color_get_value:
|
|
|
|
* @color: The #GtkLabelColor.
|
|
|
|
*
|
|
|
|
* This function returns the value shown by @color.
|
2023-11-21 04:38:11 +08:00
|
|
|
*
|
|
|
|
* Returns: (transfer full): a copy of the [class@Gegl.Color] used by the widget.
|
2022-02-17 05:20:46 +08:00
|
|
|
**/
|
2023-11-21 04:38:11 +08:00
|
|
|
GeglColor *
|
|
|
|
gimp_label_color_get_value (GimpLabelColor *color)
|
2022-02-17 05:20:46 +08:00
|
|
|
{
|
2023-11-21 04:38:11 +08:00
|
|
|
GimpLabelColorPrivate *priv = gimp_label_color_get_instance_private (color);
|
|
|
|
GeglColor *value = NULL;
|
|
|
|
GeglColor *retval;
|
2022-02-17 05:20:46 +08:00
|
|
|
|
2023-11-21 04:38:11 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_LABEL_COLOR (color), NULL);
|
2022-02-17 05:20:46 +08:00
|
|
|
|
2022-02-18 04:29:13 +08:00
|
|
|
g_object_get (priv->area,
|
|
|
|
"color", &value,
|
|
|
|
NULL);
|
2023-11-21 04:38:11 +08:00
|
|
|
retval = gegl_color_duplicate (value);
|
|
|
|
g_clear_object (&value);
|
|
|
|
|
|
|
|
return retval;
|
2022-02-18 04:29:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gimp_label_color_set_editable:
|
|
|
|
* @color: The #GtkLabelColor.
|
|
|
|
* @editable: Whether the color should be editable.
|
|
|
|
*
|
|
|
|
* Changes the editability of the color.
|
|
|
|
**/
|
|
|
|
void
|
|
|
|
gimp_label_color_set_editable (GimpLabelColor *color,
|
|
|
|
gboolean editable)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_LABEL_COLOR (color));
|
|
|
|
|
|
|
|
g_object_set (color, "editable", editable, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gimp_label_color_is_editable:
|
|
|
|
* @color: The #GtkLabelColor.
|
|
|
|
*
|
|
|
|
* This function tells whether the color widget allows to edit the
|
|
|
|
* color.
|
|
|
|
* Returns: %TRUE if the color is editable.
|
|
|
|
**/
|
|
|
|
gboolean
|
|
|
|
gimp_label_color_is_editable (GimpLabelColor *color)
|
|
|
|
{
|
|
|
|
GimpLabelColorPrivate *priv = gimp_label_color_get_instance_private (color);
|
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_LABEL_COLOR (color), FALSE);
|
|
|
|
|
|
|
|
priv = gimp_label_color_get_instance_private (color);
|
|
|
|
|
|
|
|
return GIMP_IS_COLOR_SELECT (priv->area);
|
2022-02-17 05:20:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2022-02-18 04:29:13 +08:00
|
|
|
* gimp_label_color_get_color_widget:
|
2022-02-17 05:20:46 +08:00
|
|
|
* @color: The #GimpLabelColor
|
|
|
|
*
|
2022-02-18 04:29:13 +08:00
|
|
|
* This function returns the color widget packed in @color, which can be
|
|
|
|
* either a #GimpColorButton (if the @color is editable) or a
|
|
|
|
* #GimpColorArea otherwise.
|
2022-02-17 05:20:46 +08:00
|
|
|
*
|
2022-02-18 04:29:13 +08:00
|
|
|
* Returns: (transfer none): The color widget packed in @color.
|
2022-02-17 05:20:46 +08:00
|
|
|
**/
|
|
|
|
GtkWidget *
|
2022-02-18 04:29:13 +08:00
|
|
|
gimp_label_color_get_color_widget (GimpLabelColor *color)
|
2022-02-17 05:20:46 +08:00
|
|
|
{
|
|
|
|
GimpLabelColorPrivate *priv = gimp_label_color_get_instance_private (color);
|
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_LABEL_COLOR (color), NULL);
|
|
|
|
|
|
|
|
return priv->area;
|
|
|
|
}
|