mirror of https://github.com/GNOME/gimp.git
rephrased the text for the dialog that appears if a new shortcut collides
2004-07-22 Sven Neumann <sven@gimp.org> * app/widgets/gimpactionview.c: rephrased the text for the dialog that appears if a new shortcut collides with an existing one. * libgimpcolor/gimprgb.[ch]: added new function gimp_rgb_parse_name() which accepts RGB colors in hexadezimal notation or as SVG color keywords.
This commit is contained in:
parent
3153eced5d
commit
b50ea15b26
|
@ -1,3 +1,12 @@
|
|||
2004-07-22 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* app/widgets/gimpactionview.c: rephrased the text for the dialog
|
||||
that appears if a new shortcut collides with an existing one.
|
||||
|
||||
* libgimpcolor/gimprgb.[ch]: added new function gimp_rgb_parse_name()
|
||||
which accepts RGB colors in hexadezimal notation or as SVG color
|
||||
keywords.
|
||||
|
||||
2004-07-22 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/display/gimpdisplayshell.c (gimp_display_shell_resume):
|
||||
|
|
|
@ -552,9 +552,9 @@ gimp_action_view_accel_edited (GimpCellRendererAccel *accel,
|
|||
g_strdup_printf ("Shortcut \"%s\" is already taken by "
|
||||
"\"%s\" from the \"%s\" group.\n"
|
||||
"\n"
|
||||
"Click \"Delete Old Shortcut\" to "
|
||||
"assign the shortcut anyway, "
|
||||
"deleting %s's shortcut.",
|
||||
"Choose \"Reassign Shortcut\" to "
|
||||
"reassign the shortcut, thereby removing "
|
||||
"the shortcut from %s.",
|
||||
accel_string,
|
||||
stripped,
|
||||
conflict_group->label,
|
||||
|
@ -573,7 +573,7 @@ gimp_action_view_accel_edited (GimpCellRendererAccel *accel,
|
|||
NULL,
|
||||
GIMP_STOCK_WARNING,
|
||||
message,
|
||||
_("Delete Old Shortcut"),
|
||||
_("_Resassign Shortcut"),
|
||||
GTK_STOCK_CANCEL,
|
||||
G_OBJECT (view), "destroy",
|
||||
gimp_action_view_accel_confirm,
|
||||
|
|
|
@ -19,6 +19,9 @@
|
|||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include "libgimpmath/gimpmath.h"
|
||||
|
@ -28,8 +31,24 @@
|
|||
#include "gimprgb.h"
|
||||
|
||||
|
||||
static gboolean gimp_rgb_parse (GimpRGB *rgb,
|
||||
const gchar *name);
|
||||
|
||||
|
||||
/* RGB functions */
|
||||
|
||||
/**
|
||||
* gimp_rgb_set:
|
||||
* @rgb: a #GimpRGB struct
|
||||
* @r: red
|
||||
* @g: green
|
||||
* @b: blue
|
||||
*
|
||||
* Sets the red, green and blue components of @rgb and leaves the
|
||||
* alpha component unchanged. The color values should be between 0.0
|
||||
* and 1.0 but there is no check to enforce this and the values are
|
||||
* set exactly as they are passed in.
|
||||
**/
|
||||
void
|
||||
gimp_rgb_set (GimpRGB *rgb,
|
||||
gdouble r,
|
||||
|
@ -43,6 +62,13 @@ gimp_rgb_set (GimpRGB *rgb,
|
|||
rgb->b = b;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_rgb_set_alpha:
|
||||
* @rgb: a #GimpRGB struct
|
||||
* @a: alpha
|
||||
*
|
||||
* Sets the alpha component of @rgb and leaves the RGB components unchanged.
|
||||
**/
|
||||
void
|
||||
gimp_rgb_set_alpha (GimpRGB *rgb,
|
||||
gdouble a)
|
||||
|
@ -52,6 +78,16 @@ gimp_rgb_set_alpha (GimpRGB *rgb,
|
|||
rgb->a = a;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_rgb_set_uchar:
|
||||
* @rgb: a #GimpRGB struct
|
||||
* @r: red
|
||||
* @g: green
|
||||
* @b: blue
|
||||
*
|
||||
* Sets the red, green and blue components of @rgb from 8bit values
|
||||
* (0 to 255) and leaves the alpha component unchanged.
|
||||
**/
|
||||
void
|
||||
gimp_rgb_set_uchar (GimpRGB *rgb,
|
||||
guchar r,
|
||||
|
@ -78,6 +114,49 @@ gimp_rgb_get_uchar (const GimpRGB *rgb,
|
|||
if (b) *b = ROUND (CLAMP (rgb->b, 0.0, 1.0) * 255.0);
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_rgb_parse_name:
|
||||
* @rgb: a #GimpRGB struct used to return the parsed color
|
||||
* @name: a color name (in UTF-8 encoding)
|
||||
* @len: the length of @name, in bytes. or -1 if @name is nul-terminated
|
||||
*
|
||||
* Attempts to parse a color name. This function accepts RGB hex
|
||||
* values or <link
|
||||
* linkend="http://www.w3.org/TR/SVG/types.html#ColorKeywords">SVG 1.0
|
||||
* color keywords</link>. The format of an RGB value in hexadecimal
|
||||
* notation is a '#' immediately followed by either three or six
|
||||
* hexadecimal characters.
|
||||
*
|
||||
* This funcion does not touch the alpha component of @rgb.
|
||||
*
|
||||
* Return value: %TRUE if @name was parsed successfully and @rgb has been
|
||||
* set, %FALSE otherwise
|
||||
*
|
||||
* Since: GIMP 2.2
|
||||
**/
|
||||
gboolean
|
||||
gimp_rgb_parse_name (GimpRGB *rgb,
|
||||
const gchar *name,
|
||||
gsize len)
|
||||
{
|
||||
gchar *tmp;
|
||||
gboolean result;
|
||||
|
||||
g_return_val_if_fail (rgb != NULL, FALSE);
|
||||
g_return_val_if_fail (name != NULL, FALSE);
|
||||
|
||||
if (len < 0)
|
||||
len = strlen (name);
|
||||
|
||||
tmp = g_strstrip (g_strndup (name, len));
|
||||
|
||||
result = gimp_rgb_parse (rgb, tmp);
|
||||
|
||||
g_free (tmp);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_rgb_add (GimpRGB *rgb1,
|
||||
const GimpRGB *rgb2)
|
||||
|
@ -241,6 +320,18 @@ gimp_rgb_composite (GimpRGB *color1,
|
|||
|
||||
/* RGBA functions */
|
||||
|
||||
/**
|
||||
* gimp_rgba_set:
|
||||
* @rgba: a #GimpRGB struct
|
||||
* @r: red
|
||||
* @g: green
|
||||
* @b: blue
|
||||
* @a: alpha
|
||||
*
|
||||
* Sets the red, green, blue and alpha components of @rgb. The values
|
||||
* should be between 0.0 and 1.0 but there is no check to enforce this
|
||||
* and the values are set exactly as they are passed in.
|
||||
**/
|
||||
void
|
||||
gimp_rgba_set (GimpRGB *rgba,
|
||||
gdouble r,
|
||||
|
@ -256,6 +347,17 @@ gimp_rgba_set (GimpRGB *rgba,
|
|||
rgba->a = a;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_rgb_set_uchar:
|
||||
* @rgb: a #GimpRGB struct
|
||||
* @r: red
|
||||
* @g: green
|
||||
* @b: blue
|
||||
* @a: alpha
|
||||
*
|
||||
* Sets the red, green, blue and alpha components of @rgb from 8bit
|
||||
* values (0 to 255).
|
||||
**/
|
||||
void
|
||||
gimp_rgba_set_uchar (GimpRGB *rgba,
|
||||
guchar r,
|
||||
|
@ -334,3 +436,251 @@ gimp_rgba_distance (const GimpRGB *rgba1,
|
|||
return (fabs (rgba1->r - rgba2->r) + fabs (rgba1->g - rgba2->g) +
|
||||
fabs (rgba1->b - rgba2->b) + fabs (rgba1->a - rgba2->a));
|
||||
}
|
||||
|
||||
|
||||
/* private functions */
|
||||
|
||||
|
||||
static gboolean
|
||||
gimp_rgb_parse_hex (const gchar *hex,
|
||||
gint len,
|
||||
gdouble *value)
|
||||
{
|
||||
gint i;
|
||||
guint c = 0;
|
||||
|
||||
for (i = 0; i < len; i++, hex++)
|
||||
{
|
||||
if (!*hex || !g_ascii_isxdigit (*hex))
|
||||
return FALSE;
|
||||
|
||||
c = (c << 4) | g_ascii_xdigit_value (*hex);
|
||||
}
|
||||
|
||||
switch (len)
|
||||
{
|
||||
case 1: *value = (gdouble) c / 15.0; break;
|
||||
case 2: *value = (gdouble) c / 255.0; break;
|
||||
case 3: *value = (gdouble) c / 4095.0; break;
|
||||
case 4: *value = (gdouble) c / 65535.0; break;
|
||||
default:
|
||||
g_return_val_if_reached (FALSE);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const gchar *name;
|
||||
guchar r;
|
||||
guchar g;
|
||||
guchar b;
|
||||
} ColorEntry;
|
||||
|
||||
static gint
|
||||
gimp_rgb_color_entry_compare (gconstpointer a,
|
||||
gconstpointer b)
|
||||
{
|
||||
const gchar *name = a;
|
||||
const ColorEntry *entry = b;
|
||||
|
||||
return g_ascii_strcasecmp (name, entry->name);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_rgb_parse (GimpRGB *rgb,
|
||||
const gchar *name)
|
||||
{
|
||||
if (name[0] == '#')
|
||||
{
|
||||
gint i;
|
||||
gsize len;
|
||||
gdouble val[3];
|
||||
|
||||
len = strlen (++name);
|
||||
if (len % 3 || len < 3 || len > 12)
|
||||
return FALSE;
|
||||
|
||||
len /= 3;
|
||||
|
||||
for (i = 0; i < 3; i++, name += len)
|
||||
{
|
||||
if (! gimp_rgb_parse_hex (name, len, val + i))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gimp_rgb_set (rgb, val[0], val[1], val[2]);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
const static 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),
|
||||
gimp_rgb_color_entry_compare);
|
||||
|
||||
if (entry)
|
||||
{
|
||||
gimp_rgb_set_uchar (rgb, entry->r, entry->g, entry->b);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
@ -41,6 +41,7 @@ void gimp_rgb_set (GimpRGB *rgb,
|
|||
gdouble blue);
|
||||
void gimp_rgb_set_alpha (GimpRGB *rgb,
|
||||
gdouble alpha);
|
||||
|
||||
void gimp_rgb_set_uchar (GimpRGB *rgb,
|
||||
guchar red,
|
||||
guchar green,
|
||||
|
@ -50,6 +51,10 @@ void gimp_rgb_get_uchar (const GimpRGB *rgb,
|
|||
guchar *green,
|
||||
guchar *blue);
|
||||
|
||||
gboolean gimp_rgb_parse_name (GimpRGB *rgb,
|
||||
const gchar *name,
|
||||
gsize len);
|
||||
|
||||
void gimp_rgb_add (GimpRGB *rgb1,
|
||||
const GimpRGB *rgb2);
|
||||
void gimp_rgb_subtract (GimpRGB *rgb1,
|
||||
|
@ -58,11 +63,14 @@ void gimp_rgb_multiply (GimpRGB *rgb1,
|
|||
gdouble factor);
|
||||
gdouble gimp_rgb_distance (const GimpRGB *rgb1,
|
||||
const GimpRGB *rgb2);
|
||||
|
||||
gdouble gimp_rgb_max (const GimpRGB *rgb);
|
||||
gdouble gimp_rgb_min (const GimpRGB *rgb);
|
||||
void gimp_rgb_clamp (GimpRGB *rgb);
|
||||
|
||||
void gimp_rgb_gamma (GimpRGB *rgb,
|
||||
gdouble gamma);
|
||||
|
||||
gdouble gimp_rgb_intensity (const GimpRGB *rgb);
|
||||
guchar gimp_rgb_intensity_uchar (const GimpRGB *rgb);
|
||||
|
||||
|
@ -70,11 +78,13 @@ void gimp_rgb_composite (GimpRGB *color1,
|
|||
const GimpRGB *color2,
|
||||
GimpRGBCompositeMode mode);
|
||||
|
||||
|
||||
void gimp_rgba_set (GimpRGB *rgba,
|
||||
gdouble red,
|
||||
gdouble green,
|
||||
gdouble blue,
|
||||
gdouble alpha);
|
||||
|
||||
void gimp_rgba_set_uchar (GimpRGB *rgba,
|
||||
guchar red,
|
||||
guchar green,
|
||||
|
@ -92,6 +102,7 @@ void gimp_rgba_subtract (GimpRGB *rgba1,
|
|||
const GimpRGB *rgba2);
|
||||
void gimp_rgba_multiply (GimpRGB *rgba,
|
||||
gdouble factor);
|
||||
|
||||
gdouble gimp_rgba_distance (const GimpRGB *rgba1,
|
||||
const GimpRGB *rgba2);
|
||||
|
||||
|
|
Loading…
Reference in New Issue