mirror of https://github.com/GNOME/gimp.git
libgimpcolor/gimprgb-parse.c added new function gimp_rgb_list_names() that
2004-07-26 Sven Neumann <sven@gimp.org> * libgimpcolor/gimprgb-parse.c * libgimpcolor/gimprgb.h: added new function gimp_rgb_list_names() that gives access to the list of SVG color keywords. * libgimpwidgets/Makefile.am * libgimpwidgets/gimpwidgets.h * libgimpwidgets/gimpwidgetstypes.h * libgimpwidgets/gimpcolorhexentry.[ch]: added new widget that allows to enter colors in hex notation or by using color names. * libgimpwidgets/gimpcolorscales.c: use a GimpColorHexEntry.
This commit is contained in:
parent
7e4db68e80
commit
e0b4899157
14
ChangeLog
14
ChangeLog
|
@ -1,3 +1,17 @@
|
|||
2004-07-26 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* libgimpcolor/gimprgb-parse.c
|
||||
* libgimpcolor/gimprgb.h: added new function gimp_rgb_list_names()
|
||||
that gives access to the list of SVG color keywords.
|
||||
|
||||
* libgimpwidgets/Makefile.am
|
||||
* libgimpwidgets/gimpwidgets.h
|
||||
* libgimpwidgets/gimpwidgetstypes.h
|
||||
* libgimpwidgets/gimpcolorhexentry.[ch]: added new widget that
|
||||
allows to enter colors in hex notation or by using color names.
|
||||
|
||||
* libgimpwidgets/gimpcolorscales.c: use a GimpColorHexEntry.
|
||||
|
||||
2004-07-25 Shlomi Fish <shlomif@iglu.org.il>
|
||||
|
||||
* plug-ins/gimpressionist/: placed all the orientation map-related
|
||||
|
|
|
@ -1,3 +1,12 @@
|
|||
2004-07-26 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* libgimpcolor/libgimpcolor-sections.txt
|
||||
* libgimpcolor/tmpl/gimprgb.sgml
|
||||
* libgimpwidgets/libgimpwidgets.types
|
||||
* libgimpwidgets/libgimpwidgets-docs.sgml
|
||||
* libgimpwidgets/libgimpwidgets-sections.txt
|
||||
* libgimpwidgets/tmpl/gimpcolorhexentry.sgml: updated for new API.
|
||||
|
||||
2004-07-22 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* libgimpcolor/Makefile.am
|
||||
|
|
|
@ -54,6 +54,7 @@ gimp_rgb_get_uchar
|
|||
gimp_rgb_parse_name
|
||||
gimp_rgb_parse_hex
|
||||
gimp_rgb_parse_css
|
||||
gimp_rgb_list_names
|
||||
gimp_rgb_add
|
||||
gimp_rgb_subtract
|
||||
gimp_rgb_multiply
|
||||
|
|
|
@ -108,6 +108,16 @@ GimpRGB
|
|||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gimp_rgb_list_names ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@names:
|
||||
@colors:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gimp_rgb_add ##### -->
|
||||
<para>
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
<xi:include href="xml/gimpchainbutton.xml" />
|
||||
<xi:include href="xml/gimpcolorarea.xml" />
|
||||
<xi:include href="xml/gimpcolorbutton.xml" />
|
||||
<xi:include href="xml/gimpcolorhexentry.xml" />
|
||||
<xi:include href="xml/gimpcolorscale.xml" />
|
||||
<xi:include href="xml/gimpcolorselection.xml" />
|
||||
<xi:include href="xml/gimpdialog.xml" />
|
||||
|
|
|
@ -61,6 +61,24 @@ GIMP_IS_COLOR_BUTTON_CLASS
|
|||
GIMP_COLOR_BUTTON_GET_CLASS
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>gimpcolorhexentry</FILE>
|
||||
<TITLE>GimpColorHexEntry</TITLE>
|
||||
GimpColorHexEntry
|
||||
gimp_color_hex_entry_new
|
||||
gimp_color_hex_entry_set_color
|
||||
gimp_color_hex_entry_get_color
|
||||
<SUBSECTION Standard>
|
||||
GimpColorHexEntryClass
|
||||
GIMP_COLOR_HEX_ENTRY
|
||||
GIMP_IS_COLOR_HEX_ENTRY
|
||||
GIMP_TYPE_COLOR_HEX_ENTRY
|
||||
gimp_color_hex_entry_get_type
|
||||
GIMP_COLOR_HEX_ENTRY_CLASS
|
||||
GIMP_IS_COLOR_HEX_ENTRY_CLASS
|
||||
GIMP_COLOR_HEX_ENTRY_GET_CLASS
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>gimpcolorscale</FILE>
|
||||
<TITLE>GimpColorScale</TITLE>
|
||||
|
|
|
@ -10,6 +10,7 @@ gimp_color_area_get_type
|
|||
gimp_color_button_get_type
|
||||
gimp_color_display_get_type
|
||||
gimp_color_display_stack_get_type
|
||||
gimp_color_hex_entry_get_type
|
||||
gimp_color_notebook_get_type
|
||||
gimp_color_scale_get_type
|
||||
gimp_color_scales_get_type
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
<!-- ##### SECTION Title ##### -->
|
||||
GimpColorHexEntry
|
||||
|
||||
<!-- ##### SECTION Short_Description ##### -->
|
||||
|
||||
|
||||
<!-- ##### SECTION Long_Description ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
<!-- ##### SECTION See_Also ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
<!-- ##### STRUCT GimpColorHexEntry ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
|
||||
<!-- ##### SIGNAL GimpColorHexEntry::color-changed ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@gimpcolorhexentry: the object which received the signal.
|
||||
|
||||
<!-- ##### FUNCTION gimp_color_hex_entry_new ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gimp_color_hex_entry_set_color ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@entry:
|
||||
@color:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gimp_color_hex_entry_get_color ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@entry:
|
||||
@color:
|
||||
|
||||
|
|
@ -50,6 +50,166 @@ static gboolean gimp_rgba_parse_css_internal (GimpRGB *rgb,
|
|||
const gchar *css);
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const gchar *name;
|
||||
const guchar red;
|
||||
const guchar green;
|
||||
const guchar blue;
|
||||
} ColorEntry;
|
||||
|
||||
static const ColorEntry named_colors[] =
|
||||
{
|
||||
{ "aliceblue", 240, 248, 255 },
|
||||
{ "antiquewhite", 250, 235, 215 },
|
||||
{ "aqua", 0, 255, 255 },
|
||||
{ "aquamarine", 127, 255, 212 },
|
||||
{ "azure", 240, 255, 255 },
|
||||
{ "beige", 245, 245, 220 },
|
||||
{ "bisque", 255, 228, 196 },
|
||||
{ "black", 0, 0, 0 },
|
||||
{ "blanchedalmond", 255, 235, 205 },
|
||||
{ "blue", 0, 0, 255 },
|
||||
{ "blueviolet", 138, 43, 226 },
|
||||
{ "brown", 165, 42, 42 },
|
||||
{ "burlywood", 222, 184, 135 },
|
||||
{ "cadetblue", 95, 158, 160 },
|
||||
{ "chartreuse", 127, 255, 0 },
|
||||
{ "chocolate", 210, 105, 30 },
|
||||
{ "coral", 255, 127, 80 },
|
||||
{ "cornflowerblue", 100, 149, 237 },
|
||||
{ "cornsilk", 255, 248, 220 },
|
||||
{ "crimson", 220, 20, 60 },
|
||||
{ "cyan", 0, 255, 255 },
|
||||
{ "darkblue", 0, 0, 139 },
|
||||
{ "darkcyan", 0, 139, 139 },
|
||||
{ "darkgoldenrod", 184, 132, 11 },
|
||||
{ "darkgray", 169, 169, 169 },
|
||||
{ "darkgreen", 0, 100, 0 },
|
||||
{ "darkgrey", 169, 169, 169 },
|
||||
{ "darkkhaki", 189, 183, 107 },
|
||||
{ "darkmagenta", 139, 0, 139 },
|
||||
{ "darkolivegreen", 85, 107, 47 },
|
||||
{ "darkorange", 255, 140, 0 },
|
||||
{ "darkorchid", 153, 50, 204 },
|
||||
{ "darkred", 139, 0, 0 },
|
||||
{ "darksalmon", 233, 150, 122 },
|
||||
{ "darkseagreen", 143, 188, 143 },
|
||||
{ "darkslateblue", 72, 61, 139 },
|
||||
{ "darkslategray", 47, 79, 79 },
|
||||
{ "darkslategrey", 47, 79, 79 },
|
||||
{ "darkturquoise", 0, 206, 209 },
|
||||
{ "darkviolet", 148, 0, 211 },
|
||||
{ "deeppink", 255, 20, 147 },
|
||||
{ "deepskyblue", 0, 191, 255 },
|
||||
{ "dimgray", 105, 105, 105 },
|
||||
{ "dimgrey", 105, 105, 105 },
|
||||
{ "dodgerblue", 30, 144, 255 },
|
||||
{ "firebrick", 178, 34, 34 },
|
||||
{ "floralwhite" , 255, 255, 240 },
|
||||
{ "forestgreen", 34, 139, 34 },
|
||||
{ "fuchsia", 255, 0, 255 },
|
||||
{ "gainsboro", 220, 220, 220 },
|
||||
{ "ghostwhite", 248, 248, 255 },
|
||||
{ "gold", 255, 215, 0 },
|
||||
{ "goldenrod", 218, 165, 32 },
|
||||
{ "gray", 128, 128, 128 },
|
||||
{ "green", 0, 128, 0 },
|
||||
{ "greenyellow", 173, 255, 47 },
|
||||
{ "grey", 128, 128, 128 },
|
||||
{ "honeydew", 240, 255, 240 },
|
||||
{ "hotpink", 255, 105, 180 },
|
||||
{ "indianred", 205, 92, 92 },
|
||||
{ "indigo", 75, 0, 130 },
|
||||
{ "ivory", 255, 255, 240 },
|
||||
{ "khaki", 240, 230, 140 },
|
||||
{ "lavender", 230, 230, 250 },
|
||||
{ "lavenderblush", 255, 240, 245 },
|
||||
{ "lawngreen", 124, 252, 0 },
|
||||
{ "lemonchiffon", 255, 250, 205 },
|
||||
{ "lightblue", 173, 216, 230 },
|
||||
{ "lightcoral", 240, 128, 128 },
|
||||
{ "lightcyan", 224, 255, 255 },
|
||||
{ "lightgoldenrodyellow", 250, 250, 210 },
|
||||
{ "lightgray", 211, 211, 211 },
|
||||
{ "lightgreen", 144, 238, 144 },
|
||||
{ "lightgrey", 211, 211, 211 },
|
||||
{ "lightpink", 255, 182, 193 },
|
||||
{ "lightsalmon", 255, 160, 122 },
|
||||
{ "lightseagreen", 32, 178, 170 },
|
||||
{ "lightskyblue", 135, 206, 250 },
|
||||
{ "lightslategray", 119, 136, 153 },
|
||||
{ "lightslategrey", 119, 136, 153 },
|
||||
{ "lightsteelblue", 176, 196, 222 },
|
||||
{ "lightyellow", 255, 255, 224 },
|
||||
{ "lime", 0, 255, 0 },
|
||||
{ "limegreen", 50, 205, 50 },
|
||||
{ "linen", 250, 240, 230 },
|
||||
{ "magenta", 255, 0, 255 },
|
||||
{ "maroon", 128, 0, 0 },
|
||||
{ "mediumaquamarine", 102, 205, 170 },
|
||||
{ "mediumblue", 0, 0, 205 },
|
||||
{ "mediumorchid", 186, 85, 211 },
|
||||
{ "mediumpurple", 147, 112, 219 },
|
||||
{ "mediumseagreen", 60, 179, 113 },
|
||||
{ "mediumslateblue", 123, 104, 238 },
|
||||
{ "mediumspringgreen", 0, 250, 154 },
|
||||
{ "mediumturquoise", 72, 209, 204 },
|
||||
{ "mediumvioletred", 199, 21, 133 },
|
||||
{ "midnightblue", 25, 25, 112 },
|
||||
{ "mintcream", 245, 255, 250 },
|
||||
{ "mistyrose", 255, 228, 225 },
|
||||
{ "moccasin", 255, 228, 181 },
|
||||
{ "navajowhite", 255, 222, 173 },
|
||||
{ "navy", 0, 0, 128 },
|
||||
{ "oldlace", 253, 245, 230 },
|
||||
{ "olive", 128, 128, 0 },
|
||||
{ "olivedrab", 107, 142, 35 },
|
||||
{ "orange", 255, 165, 0 },
|
||||
{ "orangered", 255, 69, 0 },
|
||||
{ "orchid", 218, 112, 214 },
|
||||
{ "palegoldenrod", 238, 232, 170 },
|
||||
{ "palegreen", 152, 251, 152 },
|
||||
{ "paleturquoise", 175, 238, 238 },
|
||||
{ "palevioletred", 219, 112, 147 },
|
||||
{ "papayawhip", 255, 239, 213 },
|
||||
{ "peachpuff", 255, 218, 185 },
|
||||
{ "peru", 205, 133, 63 },
|
||||
{ "pink", 255, 192, 203 },
|
||||
{ "plum", 221, 160, 203 },
|
||||
{ "powderblue", 176, 224, 230 },
|
||||
{ "purple", 128, 0, 128 },
|
||||
{ "red", 255, 0, 0 },
|
||||
{ "rosybrown", 188, 143, 143 },
|
||||
{ "royalblue", 65, 105, 225 },
|
||||
{ "saddlebrown", 139, 69, 19 },
|
||||
{ "salmon", 250, 128, 114 },
|
||||
{ "sandybrown", 244, 164, 96 },
|
||||
{ "seagreen", 46, 139, 87 },
|
||||
{ "seashell", 255, 245, 238 },
|
||||
{ "sienna", 160, 82, 45 },
|
||||
{ "silver", 192, 192, 192 },
|
||||
{ "skyblue", 135, 206, 235 },
|
||||
{ "slateblue", 106, 90, 205 },
|
||||
{ "slategray", 119, 128, 144 },
|
||||
{ "slategrey", 119, 128, 144 },
|
||||
{ "snow", 255, 255, 250 },
|
||||
{ "springgreen", 0, 255, 127 },
|
||||
{ "steelblue", 70, 130, 180 },
|
||||
{ "tan", 210, 180, 140 },
|
||||
{ "teal", 0, 128, 128 },
|
||||
{ "thistle", 216, 191, 216 },
|
||||
{ "tomato", 255, 99, 71 },
|
||||
{ "turquoise", 64, 224, 208 },
|
||||
{ "violet", 238, 130, 238 },
|
||||
{ "wheat", 245, 222, 179 },
|
||||
{ "white", 255, 255, 255 },
|
||||
{ "whitesmoke", 245, 245, 245 },
|
||||
{ "yellow", 255, 255, 0 },
|
||||
{ "yellowgreen", 154, 205, 50 }
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* gimp_rgb_parse_name:
|
||||
* @rgb: a #GimpRGB struct used to return the parsed color
|
||||
|
@ -214,6 +374,52 @@ gimp_rgba_parse_css (GimpRGB *rgba,
|
|||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* gimp_rgb_list_names:
|
||||
* @names: return location for an array of color names
|
||||
* @colors: return location for an array of GimpRGB structs
|
||||
*
|
||||
* Allows to retrieve the list of <ulink
|
||||
* url="http://www.w3.org/TR/SVG/types.html">SVG 1.0 color
|
||||
* keywords</ulink> that is used by gimp_rgb_parse_name().
|
||||
*
|
||||
* The returned strings are const and must not be freed. Only the two
|
||||
* arrays are allocated dynamically. You must call g_free() on the
|
||||
* @names and @colors arrays when they are not any longer needed.
|
||||
*
|
||||
* Return value: the number of named colors
|
||||
* (i.e. the length of the returned arrays)
|
||||
*
|
||||
* Since: GIMP 2.2
|
||||
**/
|
||||
gint
|
||||
gimp_rgb_list_names (const gchar ***names,
|
||||
GimpRGB **colors)
|
||||
{
|
||||
gint i;
|
||||
|
||||
g_return_val_if_fail (names != NULL, 0);
|
||||
g_return_val_if_fail (colors != NULL, 0);
|
||||
|
||||
*names = g_new (const gchar *, G_N_ELEMENTS (named_colors));
|
||||
*colors = g_new (GimpRGB, G_N_ELEMENTS (named_colors));
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (named_colors); i++)
|
||||
{
|
||||
(*names)[i] = named_colors[i].name;
|
||||
|
||||
gimp_rgba_set_uchar ((*colors) + i,
|
||||
named_colors[i].red,
|
||||
named_colors[i].green,
|
||||
named_colors[i].blue,
|
||||
0xFF);
|
||||
}
|
||||
|
||||
return G_N_ELEMENTS (named_colors);
|
||||
}
|
||||
|
||||
|
||||
static gchar *
|
||||
gimp_rgb_parse_strip (const gchar *str,
|
||||
gint len)
|
||||
|
@ -245,15 +451,6 @@ gimp_rgb_parse_strip (const gchar *str,
|
|||
return result;
|
||||
}
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const gchar *name;
|
||||
const guchar r;
|
||||
const guchar g;
|
||||
const guchar b;
|
||||
} ColorEntry;
|
||||
|
||||
static gint
|
||||
gimp_rgb_color_entry_compare (gconstpointer a,
|
||||
gconstpointer b)
|
||||
|
@ -268,164 +465,13 @@ static gboolean
|
|||
gimp_rgb_parse_name_internal (GimpRGB *rgb,
|
||||
const gchar *name)
|
||||
{
|
||||
static const ColorEntry colors[] =
|
||||
{
|
||||
{ "aliceblue", 240, 248, 255 },
|
||||
{ "antiquewhite", 250, 235, 215 },
|
||||
{ "aqua", 0, 255, 255 },
|
||||
{ "aquamarine", 127, 255, 212 },
|
||||
{ "azure", 240, 255, 255 },
|
||||
{ "beige", 245, 245, 220 },
|
||||
{ "bisque", 255, 228, 196 },
|
||||
{ "black", 0, 0, 0 },
|
||||
{ "blanchedalmond", 255, 235, 205 },
|
||||
{ "blue", 0, 0, 255 },
|
||||
{ "blueviolet", 138, 43, 226 },
|
||||
{ "brown", 165, 42, 42 },
|
||||
{ "burlywood", 222, 184, 135 },
|
||||
{ "cadetblue", 95, 158, 160 },
|
||||
{ "chartreuse", 127, 255, 0 },
|
||||
{ "chocolate", 210, 105, 30 },
|
||||
{ "coral", 255, 127, 80 },
|
||||
{ "cornflowerblue", 100, 149, 237 },
|
||||
{ "cornsilk", 255, 248, 220 },
|
||||
{ "crimson", 220, 20, 60 },
|
||||
{ "cyan", 0, 255, 255 },
|
||||
{ "darkblue", 0, 0, 139 },
|
||||
{ "darkcyan", 0, 139, 139 },
|
||||
{ "darkgoldenrod", 184, 132, 11 },
|
||||
{ "darkgray", 169, 169, 169 },
|
||||
{ "darkgreen", 0, 100, 0 },
|
||||
{ "darkgrey", 169, 169, 169 },
|
||||
{ "darkkhaki", 189, 183, 107 },
|
||||
{ "darkmagenta", 139, 0, 139 },
|
||||
{ "darkolivegreen", 85, 107, 47 },
|
||||
{ "darkorange", 255, 140, 0 },
|
||||
{ "darkorchid", 153, 50, 204 },
|
||||
{ "darkred", 139, 0, 0 },
|
||||
{ "darksalmon", 233, 150, 122 },
|
||||
{ "darkseagreen", 143, 188, 143 },
|
||||
{ "darkslateblue", 72, 61, 139 },
|
||||
{ "darkslategray", 47, 79, 79 },
|
||||
{ "darkslategrey", 47, 79, 79 },
|
||||
{ "darkturquoise", 0, 206, 209 },
|
||||
{ "darkviolet", 148, 0, 211 },
|
||||
{ "deeppink", 255, 20, 147 },
|
||||
{ "deepskyblue", 0, 191, 255 },
|
||||
{ "dimgray", 105, 105, 105 },
|
||||
{ "dimgrey", 105, 105, 105 },
|
||||
{ "dodgerblue", 30, 144, 255 },
|
||||
{ "firebrick", 178, 34, 34 },
|
||||
{ "floralwhite" , 255, 255, 240 },
|
||||
{ "forestgreen", 34, 139, 34 },
|
||||
{ "fuchsia", 255, 0, 255 },
|
||||
{ "gainsboro", 220, 220, 220 },
|
||||
{ "ghostwhite", 248, 248, 255 },
|
||||
{ "gold", 255, 215, 0 },
|
||||
{ "goldenrod", 218, 165, 32 },
|
||||
{ "gray", 128, 128, 128 },
|
||||
{ "green", 0, 128, 0 },
|
||||
{ "greenyellow", 173, 255, 47 },
|
||||
{ "grey", 128, 128, 128 },
|
||||
{ "honeydew", 240, 255, 240 },
|
||||
{ "hotpink", 255, 105, 180 },
|
||||
{ "indianred", 205, 92, 92 },
|
||||
{ "indigo", 75, 0, 130 },
|
||||
{ "ivory", 255, 255, 240 },
|
||||
{ "khaki", 240, 230, 140 },
|
||||
{ "lavender", 230, 230, 250 },
|
||||
{ "lavenderblush", 255, 240, 245 },
|
||||
{ "lawngreen", 124, 252, 0 },
|
||||
{ "lemonchiffon", 255, 250, 205 },
|
||||
{ "lightblue", 173, 216, 230 },
|
||||
{ "lightcoral", 240, 128, 128 },
|
||||
{ "lightcyan", 224, 255, 255 },
|
||||
{ "lightgoldenrodyellow", 250, 250, 210 },
|
||||
{ "lightgray", 211, 211, 211 },
|
||||
{ "lightgreen", 144, 238, 144 },
|
||||
{ "lightgrey", 211, 211, 211 },
|
||||
{ "lightpink", 255, 182, 193 },
|
||||
{ "lightsalmon", 255, 160, 122 },
|
||||
{ "lightseagreen", 32, 178, 170 },
|
||||
{ "lightskyblue", 135, 206, 250 },
|
||||
{ "lightslategray", 119, 136, 153 },
|
||||
{ "lightslategrey", 119, 136, 153 },
|
||||
{ "lightsteelblue", 176, 196, 222 },
|
||||
{ "lightyellow", 255, 255, 224 },
|
||||
{ "lime", 0, 255, 0 },
|
||||
{ "limegreen", 50, 205, 50 },
|
||||
{ "linen", 250, 240, 230 },
|
||||
{ "magenta", 255, 0, 255 },
|
||||
{ "maroon", 128, 0, 0 },
|
||||
{ "mediumaquamarine", 102, 205, 170 },
|
||||
{ "mediumblue", 0, 0, 205 },
|
||||
{ "mediumorchid", 186, 85, 211 },
|
||||
{ "mediumpurple", 147, 112, 219 },
|
||||
{ "mediumseagreen", 60, 179, 113 },
|
||||
{ "mediumslateblue", 123, 104, 238 },
|
||||
{ "mediumspringgreen", 0, 250, 154 },
|
||||
{ "mediumturquoise", 72, 209, 204 },
|
||||
{ "mediumvioletred", 199, 21, 133 },
|
||||
{ "midnightblue", 25, 25, 112 },
|
||||
{ "mintcream", 245, 255, 250 },
|
||||
{ "mistyrose", 255, 228, 225 },
|
||||
{ "moccasin", 255, 228, 181 },
|
||||
{ "navajowhite", 255, 222, 173 },
|
||||
{ "navy", 0, 0, 128 },
|
||||
{ "oldlace", 253, 245, 230 },
|
||||
{ "olive", 128, 128, 0 },
|
||||
{ "olivedrab", 107, 142, 35 },
|
||||
{ "orange", 255, 165, 0 },
|
||||
{ "orangered", 255, 69, 0 },
|
||||
{ "orchid", 218, 112, 214 },
|
||||
{ "palegoldenrod", 238, 232, 170 },
|
||||
{ "palegreen", 152, 251, 152 },
|
||||
{ "paleturquoise", 175, 238, 238 },
|
||||
{ "palevioletred", 219, 112, 147 },
|
||||
{ "papayawhip", 255, 239, 213 },
|
||||
{ "peachpuff", 255, 218, 185 },
|
||||
{ "peru", 205, 133, 63 },
|
||||
{ "pink", 255, 192, 203 },
|
||||
{ "plum", 221, 160, 203 },
|
||||
{ "powderblue", 176, 224, 230 },
|
||||
{ "purple", 128, 0, 128 },
|
||||
{ "red", 255, 0, 0 },
|
||||
{ "rosybrown", 188, 143, 143 },
|
||||
{ "royalblue", 65, 105, 225 },
|
||||
{ "saddlebrown", 139, 69, 19 },
|
||||
{ "salmon", 250, 128, 114 },
|
||||
{ "sandybrown", 244, 164, 96 },
|
||||
{ "seagreen", 46, 139, 87 },
|
||||
{ "seashell", 255, 245, 238 },
|
||||
{ "sienna", 160, 82, 45 },
|
||||
{ "silver", 192, 192, 192 },
|
||||
{ "skyblue", 135, 206, 235 },
|
||||
{ "slateblue", 106, 90, 205 },
|
||||
{ "slategray", 119, 128, 144 },
|
||||
{ "slategrey", 119, 128, 144 },
|
||||
{ "snow", 255, 255, 250 },
|
||||
{ "springgreen", 0, 255, 127 },
|
||||
{ "steelblue", 70, 130, 180 },
|
||||
{ "tan", 210, 180, 140 },
|
||||
{ "teal", 0, 128, 128 },
|
||||
{ "thistle", 216, 191, 216 },
|
||||
{ "tomato", 255, 99, 71 },
|
||||
{ "turquoise", 64, 224, 208 },
|
||||
{ "violet", 238, 130, 238 },
|
||||
{ "wheat", 245, 222, 179 },
|
||||
{ "white", 255, 255, 255 },
|
||||
{ "whitesmoke", 245, 245, 245 },
|
||||
{ "yellow", 255, 255, 0 },
|
||||
{ "yellowgreen", 154, 205, 50 }
|
||||
};
|
||||
|
||||
ColorEntry *entry = bsearch (name, colors,
|
||||
G_N_ELEMENTS (colors), sizeof (ColorEntry),
|
||||
ColorEntry *entry = bsearch (name, named_colors,
|
||||
G_N_ELEMENTS (named_colors), sizeof (ColorEntry),
|
||||
gimp_rgb_color_entry_compare);
|
||||
|
||||
if (entry)
|
||||
{
|
||||
gimp_rgb_set_uchar (rgb, entry->r, entry->g, entry->b);
|
||||
gimp_rgb_set_uchar (rgb, entry->red, entry->green, entry->blue);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -84,6 +84,10 @@ void gimp_rgb_composite (GimpRGB *color1,
|
|||
const GimpRGB *color2,
|
||||
GimpRGBCompositeMode mode);
|
||||
|
||||
/* access to the list of color names */
|
||||
gint gimp_rgb_list_names (const gchar ***names,
|
||||
GimpRGB **colors);
|
||||
|
||||
|
||||
void gimp_rgba_set (GimpRGB *rgba,
|
||||
gdouble red,
|
||||
|
@ -117,6 +121,7 @@ gdouble gimp_rgba_distance (const GimpRGB *rgba1,
|
|||
const GimpRGB *rgba2);
|
||||
|
||||
|
||||
|
||||
/* Map RGB to intensity */
|
||||
|
||||
#define GIMP_RGB_INTENSITY_RED 0.30
|
||||
|
|
|
@ -74,6 +74,8 @@ libgimpwidgets_2_0_la_sources = \
|
|||
gimpcolordisplay.h \
|
||||
gimpcolordisplaystack.c \
|
||||
gimpcolordisplaystack.h \
|
||||
gimpcolorhexentry.c \
|
||||
gimpcolorhexentry.h \
|
||||
gimpcolornotebook.c \
|
||||
gimpcolornotebook.h \
|
||||
gimpcolorscale.c \
|
||||
|
|
|
@ -0,0 +1,293 @@
|
|||
/* LIBGIMP - The GIMP Library
|
||||
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
||||
*
|
||||
* gimpcolorhexentry.c
|
||||
* Copyright (C) 2004 Sven Neumann <sven@gimp.org>
|
||||
*
|
||||
* 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 2 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, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include <gdk/gdkkeysyms.h>
|
||||
|
||||
#include "libgimpcolor/gimpcolor.h"
|
||||
|
||||
#include "gimpwidgetstypes.h"
|
||||
|
||||
#include "gimpcolorhexentry.h"
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
COLOR_CHANGED,
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
COLUMN_NAME,
|
||||
NUM_COLUMNS
|
||||
};
|
||||
|
||||
|
||||
static void gimp_color_hex_entry_class_init (GimpColorHexEntryClass *klass);
|
||||
static void gimp_color_hex_entry_init (GimpColorHexEntry *entry);
|
||||
static gboolean gimp_color_hex_entry_events (GtkWidget *widget,
|
||||
GdkEvent *event);
|
||||
|
||||
static gboolean gimp_color_hex_entry_matched (GtkEntryCompletion *completion,
|
||||
GtkTreeModel *model,
|
||||
GtkTreeIter *iter,
|
||||
GimpColorHexEntry *entry);
|
||||
|
||||
|
||||
static guint entry_signals[LAST_SIGNAL] = { 0 };
|
||||
|
||||
|
||||
GType
|
||||
gimp_color_hex_entry_get_type (void)
|
||||
{
|
||||
static GType entry_type = 0;
|
||||
|
||||
if (! entry_type)
|
||||
{
|
||||
static const GTypeInfo entry_info =
|
||||
{
|
||||
sizeof (GimpColorHexEntryClass),
|
||||
(GBaseInitFunc) NULL,
|
||||
(GBaseFinalizeFunc) NULL,
|
||||
(GClassInitFunc) gimp_color_hex_entry_class_init,
|
||||
NULL, /* class_finalize */
|
||||
NULL, /* class_data */
|
||||
sizeof (GimpColorHexEntry),
|
||||
0, /* n_preallocs */
|
||||
(GInstanceInitFunc) gimp_color_hex_entry_init,
|
||||
};
|
||||
|
||||
entry_type = g_type_register_static (GTK_TYPE_ENTRY,
|
||||
"GimpColorHexEntry",
|
||||
&entry_info, 0);
|
||||
}
|
||||
|
||||
return entry_type;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_color_hex_entry_class_init (GimpColorHexEntryClass *klass)
|
||||
{
|
||||
entry_signals[COLOR_CHANGED] =
|
||||
g_signal_new ("color_changed",
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
G_STRUCT_OFFSET (GimpColorHexEntryClass, color_changed),
|
||||
NULL, NULL,
|
||||
g_cclosure_marshal_VOID__VOID,
|
||||
G_TYPE_NONE, 0);
|
||||
|
||||
klass->color_changed = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_color_hex_entry_init (GimpColorHexEntry *entry)
|
||||
{
|
||||
GtkEntryCompletion *completion;
|
||||
GtkListStore *store;
|
||||
GimpRGB *colors;
|
||||
const gchar **names;
|
||||
gint num_colors;
|
||||
gint i;
|
||||
|
||||
gimp_rgba_set (&entry->color, 0.0, 0.0, 0.0, 1.0);
|
||||
|
||||
store = gtk_list_store_new (NUM_COLUMNS, G_TYPE_STRING, G_TYPE_STRING);
|
||||
|
||||
num_colors = gimp_rgb_list_names (&names, &colors);
|
||||
|
||||
for (i = 0; i < num_colors; i++)
|
||||
{
|
||||
GtkTreeIter iter;
|
||||
|
||||
gtk_list_store_append (store, &iter);
|
||||
gtk_list_store_set (store, &iter,
|
||||
COLUMN_NAME, names[i],
|
||||
-1);
|
||||
}
|
||||
|
||||
g_free (colors);
|
||||
g_free (names);
|
||||
|
||||
completion = g_object_new (GTK_TYPE_ENTRY_COMPLETION,
|
||||
"model", store,
|
||||
NULL);
|
||||
g_object_unref (store);
|
||||
|
||||
gtk_entry_completion_set_text_column (completion, COLUMN_NAME);
|
||||
|
||||
gtk_entry_set_completion (GTK_ENTRY (entry), completion);
|
||||
g_object_unref (completion);
|
||||
|
||||
gtk_entry_set_text (GTK_ENTRY (entry), "000000");
|
||||
|
||||
g_signal_connect (entry, "focus_out_event",
|
||||
G_CALLBACK (gimp_color_hex_entry_events),
|
||||
NULL);
|
||||
g_signal_connect (entry, "key_press_event",
|
||||
G_CALLBACK (gimp_color_hex_entry_events),
|
||||
NULL);
|
||||
|
||||
g_signal_connect (completion, "match_selected",
|
||||
G_CALLBACK (gimp_color_hex_entry_matched),
|
||||
entry);
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_color_hex_entry_new:
|
||||
*
|
||||
* Return value: a new #GimpColorHexEntry widget
|
||||
*
|
||||
* Since: GIMP 2.2
|
||||
**/
|
||||
GtkWidget *
|
||||
gimp_color_hex_entry_new (void)
|
||||
{
|
||||
return g_object_new (GIMP_TYPE_COLOR_HEX_ENTRY, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_color_hex_entry_set_color:
|
||||
* @entry: a #GimpColorHexEntry widget
|
||||
* @color: pointer to a #GimpRGB
|
||||
*
|
||||
* Sets the color displayed by a #GimpColorHexEntry. If the new color
|
||||
* is different to the previously set color, the "color_changed"
|
||||
* signal is emitted.
|
||||
*
|
||||
* Since: GIMP 2.2
|
||||
**/
|
||||
void
|
||||
gimp_color_hex_entry_set_color (GimpColorHexEntry *entry,
|
||||
const GimpRGB *color)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_COLOR_HEX_ENTRY (entry));
|
||||
g_return_if_fail (color != NULL);
|
||||
|
||||
if (gimp_rgb_distance (&entry->color, color) > 0.0)
|
||||
{
|
||||
gchar buffer[8];
|
||||
guchar r, g, b;
|
||||
|
||||
gimp_rgb_set (&entry->color, color->r, color->g, color->b);
|
||||
gimp_rgb_clamp (&entry->color);
|
||||
|
||||
gimp_rgb_get_uchar (&entry->color, &r, &g, &b);
|
||||
g_snprintf (buffer, sizeof (buffer), "%.2x%.2x%.2x", r, g, b);
|
||||
|
||||
gtk_entry_set_text (GTK_ENTRY (entry), buffer);
|
||||
|
||||
/* move cursor to the end */
|
||||
gtk_editable_set_position (GTK_EDITABLE (entry), -1);
|
||||
|
||||
g_signal_emit (entry, entry_signals[COLOR_CHANGED], 0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_color_hex_entry_get_color:
|
||||
* @entry: a #GimpColorHexEntry widget
|
||||
* @color: pointer to a #GimpRGB
|
||||
*
|
||||
* Retrieves the color value displayed by a #GimpColorHexEntry.
|
||||
*
|
||||
* Since: GIMP 2.2
|
||||
**/
|
||||
void
|
||||
gimp_color_hex_entry_get_color (GimpColorHexEntry *entry,
|
||||
GimpRGB *color)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_COLOR_HEX_ENTRY (entry));
|
||||
g_return_if_fail (color != NULL);
|
||||
|
||||
*color = entry->color;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_color_hex_entry_events (GtkWidget *widget,
|
||||
GdkEvent *event)
|
||||
{
|
||||
GimpColorHexEntry *entry = GIMP_COLOR_HEX_ENTRY (widget);
|
||||
const gchar *text;
|
||||
gchar buffer[8];
|
||||
guchar r, g, b;
|
||||
|
||||
switch (event->type)
|
||||
{
|
||||
case GDK_KEY_PRESS:
|
||||
if (((GdkEventKey *) event)->keyval != GDK_Return)
|
||||
break;
|
||||
/* else fall through */
|
||||
|
||||
case GDK_FOCUS_CHANGE:
|
||||
text = gtk_entry_get_text (GTK_ENTRY (widget));
|
||||
|
||||
gimp_rgb_get_uchar (&entry->color, &r, &g, &b);
|
||||
g_snprintf (buffer, sizeof (buffer), "%.2x%.2x%.2x", r, g, b);
|
||||
|
||||
if (g_ascii_strcasecmp (buffer, text) != 0)
|
||||
{
|
||||
GimpRGB color;
|
||||
|
||||
if ((strlen (text) == 6 && gimp_rgb_parse_hex (&color, text, 6)) ||
|
||||
(gimp_rgb_parse_name (&color, text, -1)))
|
||||
{
|
||||
gimp_color_hex_entry_set_color (entry, &color);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
/* do nothing */
|
||||
break;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_color_hex_entry_matched (GtkEntryCompletion *completion,
|
||||
GtkTreeModel *model,
|
||||
GtkTreeIter *iter,
|
||||
GimpColorHexEntry *entry)
|
||||
{
|
||||
gchar *name;
|
||||
GimpRGB color;
|
||||
|
||||
gtk_tree_model_get (model, iter,
|
||||
COLUMN_NAME, &name,
|
||||
-1);
|
||||
|
||||
if (gimp_rgb_parse_name (&color, name, -1))
|
||||
gimp_color_hex_entry_set_color (entry, &color);
|
||||
|
||||
g_free (name);
|
||||
|
||||
return TRUE;
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
/* LIBGIMP - The GIMP Library
|
||||
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
||||
*
|
||||
* gimpcolorhexentry.h
|
||||
* Copyright (C) 2004 Sven Neumann <sven@gimp.org>
|
||||
*
|
||||
* 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 2 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, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GIMP_COLOR_HEX_ENTRY_H__
|
||||
#define __GIMP_COLOR_HEX_ENTRY_H__
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
||||
#define GIMP_TYPE_COLOR_HEX_ENTRY (gimp_color_hex_entry_get_type ())
|
||||
#define GIMP_COLOR_HEX_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_COLOR_HEX_ENTRY, GimpColorHexEntry))
|
||||
#define GIMP_COLOR_HEX_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_COLOR_HEX_ENTRY, GimpColorHexEntryClass))
|
||||
#define GIMP_IS_COLOR_HEX_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_COLOR_HEX_ENTRY))
|
||||
#define GIMP_IS_COLOR_HEX_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_COLOR_HEX_ENTRY))
|
||||
#define GIMP_COLOR_HEX_ENTRY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_COLOR_HEX_AREA, GimpColorHexEntryClass))
|
||||
|
||||
|
||||
typedef struct _GimpColorHexEntryClass GimpColorHexEntryClass;
|
||||
|
||||
struct _GimpColorHexEntry
|
||||
{
|
||||
GtkEntry parent_instance;
|
||||
|
||||
GimpRGB color;
|
||||
};
|
||||
|
||||
struct _GimpColorHexEntryClass
|
||||
{
|
||||
GtkEntryClass parent_class;
|
||||
|
||||
void (* color_changed) (GimpColorHexEntry *entry);
|
||||
|
||||
/* Padding for future expansion */
|
||||
void (* _gimp_reserved1) (void);
|
||||
void (* _gimp_reserved2) (void);
|
||||
void (* _gimp_reserved3) (void);
|
||||
void (* _gimp_reserved4) (void);
|
||||
};
|
||||
|
||||
|
||||
GType gimp_color_hex_entry_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GtkWidget * gimp_color_hex_entry_new (void);
|
||||
|
||||
void gimp_color_hex_entry_set_color (GimpColorHexEntry *entry,
|
||||
const GimpRGB *color);
|
||||
void gimp_color_hex_entry_get_color (GimpColorHexEntry *entry,
|
||||
GimpRGB *color);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GIMP_COLOR_HEX_ENTRY_H__ */
|
|
@ -28,7 +28,6 @@
|
|||
#include <string.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include <gdk/gdkkeysyms.h>
|
||||
|
||||
#include "libgimpcolor/gimpcolor.h"
|
||||
#include "libgimpmath/gimpmath.h"
|
||||
|
@ -37,6 +36,7 @@
|
|||
|
||||
#include "gimpcolorscale.h"
|
||||
#include "gimpcolorscales.h"
|
||||
#include "gimpcolorhexentry.h"
|
||||
#include "gimpwidgets.h"
|
||||
|
||||
#include "libgimp/libgimp-intl.h"
|
||||
|
@ -87,8 +87,8 @@ static void gimp_color_scales_toggle_update (GtkWidget *widget,
|
|||
GimpColorScales *scales);
|
||||
static void gimp_color_scales_scale_update (GtkAdjustment *adjustment,
|
||||
GimpColorScales *scales);
|
||||
static gboolean gimp_color_scales_hex_events (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
|
||||
static void gimp_color_scales_entry_changed (GimpColorHexEntry *entry,
|
||||
GimpColorScales *scales);
|
||||
|
||||
|
||||
|
@ -234,30 +234,25 @@ gimp_color_scales_init (GimpColorScales *scales)
|
|||
}
|
||||
|
||||
/* The hex triplet entry */
|
||||
hbox = gtk_hbox_new (FALSE, 4);
|
||||
hbox = gtk_hbox_new (FALSE, 6);
|
||||
gtk_box_pack_end (GTK_BOX (scales), hbox, FALSE, FALSE, 0);
|
||||
gtk_widget_show (hbox);
|
||||
|
||||
scales->hex_entry = gtk_entry_new ();
|
||||
scales->hex_entry = gimp_color_hex_entry_new ();
|
||||
gimp_help_set_help_data (scales->hex_entry,
|
||||
_("Hexadecimal color notation as used in HTML"),
|
||||
NULL);
|
||||
gtk_entry_set_width_chars (GTK_ENTRY (scales->hex_entry), 8);
|
||||
gtk_entry_set_max_length (GTK_ENTRY (scales->hex_entry), 6);
|
||||
gtk_box_pack_end (GTK_BOX (hbox), scales->hex_entry, FALSE, FALSE, 0);
|
||||
_("Hexadecimal color notation "
|
||||
"as used in HTML and CSS"), NULL);
|
||||
gtk_box_pack_end (GTK_BOX (hbox), scales->hex_entry, TRUE, TRUE, 0);
|
||||
gtk_widget_show (scales->hex_entry);
|
||||
|
||||
g_signal_connect (scales->hex_entry, "focus_out_event",
|
||||
G_CALLBACK (gimp_color_scales_hex_events),
|
||||
scales);
|
||||
g_signal_connect (scales->hex_entry, "key_press_event",
|
||||
G_CALLBACK (gimp_color_scales_hex_events),
|
||||
scales);
|
||||
|
||||
label = gtk_label_new_with_mnemonic (_("He_x Triplet:"));
|
||||
label = gtk_label_new_with_mnemonic (_("HTML _Notation:"));
|
||||
gtk_label_set_mnemonic_widget (GTK_LABEL (label), scales->hex_entry);
|
||||
gtk_box_pack_end (GTK_BOX (hbox), label, FALSE, FALSE, 0);
|
||||
gtk_widget_show (label);
|
||||
|
||||
g_signal_connect (scales->hex_entry, "color_changed",
|
||||
G_CALLBACK (gimp_color_scales_entry_changed),
|
||||
scales);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -351,7 +346,6 @@ gimp_color_scales_update_scales (GimpColorScales *scales,
|
|||
{
|
||||
GimpColorSelector *selector = GIMP_COLOR_SELECTOR (scales);
|
||||
gint values[7];
|
||||
gchar buffer[8];
|
||||
gint i;
|
||||
|
||||
values[GIMP_COLOR_SELECTOR_HUE] = ROUND (selector->hsv.h * 360.0);
|
||||
|
@ -382,12 +376,8 @@ gimp_color_scales_update_scales (GimpColorScales *scales,
|
|||
&selector->rgb, &selector->hsv);
|
||||
}
|
||||
|
||||
g_snprintf (buffer, sizeof (buffer), "%.2x%.2x%.2x",
|
||||
values[GIMP_COLOR_SELECTOR_RED],
|
||||
values[GIMP_COLOR_SELECTOR_GREEN],
|
||||
values[GIMP_COLOR_SELECTOR_BLUE]);
|
||||
|
||||
gtk_entry_set_text (GTK_ENTRY (scales->hex_entry), buffer);
|
||||
gimp_color_hex_entry_set_color (GIMP_COLOR_HEX_ENTRY (scales->hex_entry),
|
||||
&selector->rgb);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -468,52 +458,14 @@ gimp_color_scales_scale_update (GtkAdjustment *adjustment,
|
|||
gimp_color_selector_color_changed (selector);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_color_scales_hex_events (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
static void
|
||||
gimp_color_scales_entry_changed (GimpColorHexEntry *entry,
|
||||
GimpColorScales *scales)
|
||||
{
|
||||
GimpColorSelector *selector = GIMP_COLOR_SELECTOR (scales);
|
||||
const gchar *hex_color;
|
||||
gchar buffer[8];
|
||||
guchar r, g, b;
|
||||
|
||||
switch (event->type)
|
||||
{
|
||||
case GDK_KEY_PRESS:
|
||||
if (((GdkEventKey *) event)->keyval != GDK_Return)
|
||||
break;
|
||||
/* else fall through */
|
||||
gimp_color_hex_entry_get_color (entry, &selector->rgb);
|
||||
|
||||
case GDK_FOCUS_CHANGE:
|
||||
hex_color = gtk_entry_get_text (GTK_ENTRY (scales->hex_entry));
|
||||
|
||||
gimp_rgb_get_uchar (&selector->rgb, &r, &g, &b);
|
||||
g_snprintf (buffer, sizeof (buffer), "%.2x%.2x%.2x", r, g, b);
|
||||
|
||||
if (g_ascii_strcasecmp (buffer, hex_color) != 0)
|
||||
{
|
||||
if ((strlen (hex_color) == 6 &&
|
||||
gimp_rgb_parse_hex (&selector->rgb, hex_color, 6)) ||
|
||||
(gimp_rgb_parse_name (&selector->rgb, hex_color, -1)))
|
||||
{
|
||||
gimp_rgb_to_hsv (&selector->rgb, &selector->hsv);
|
||||
|
||||
gimp_color_scales_update_scales (scales, -1);
|
||||
|
||||
gimp_color_selector_color_changed (selector);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gtk_entry_set_text (GTK_ENTRY (widget), buffer);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
/* do nothing */
|
||||
break;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include <libgimpwidgets/gimpcolorbutton.h>
|
||||
#include <libgimpwidgets/gimpcolordisplay.h>
|
||||
#include <libgimpwidgets/gimpcolordisplaystack.h>
|
||||
#include <libgimpwidgets/gimpcolorhexentry.h>
|
||||
#include <libgimpwidgets/gimpcolornotebook.h>
|
||||
#include <libgimpwidgets/gimpcolorscale.h>
|
||||
#include <libgimpwidgets/gimpcolorscales.h>
|
||||
|
|
|
@ -61,6 +61,7 @@ typedef struct _GimpColorArea GimpColorArea;
|
|||
typedef struct _GimpColorButton GimpColorButton;
|
||||
typedef struct _GimpColorDisplay GimpColorDisplay;
|
||||
typedef struct _GimpColorDisplayStack GimpColorDisplayStack;
|
||||
typedef struct _GimpColorHexEntry GimpColorHexEntry;
|
||||
typedef struct _GimpColorNotebook GimpColorNotebook;
|
||||
typedef struct _GimpColorScale GimpColorScale;
|
||||
typedef struct _GimpColorScales GimpColorScales;
|
||||
|
|
Loading…
Reference in New Issue