Commit 3be9ce0e authored by Owen Taylor's avatar Owen Taylor Committed by Owen Taylor
Browse files

Implement gdk_color_parse() in terms of pango_color_parse().

Sun Nov  4 19:16:23 2001  Owen Taylor  <otaylor@redhat.com>

        * gdk/gdkcolor.c (gdk_color_parse): Implement gdk_color_parse()
        in terms of pango_color_parse().

        * gdk/{linux-fb,win32,x11}/gdkcolor-*.c: Remove port-specific
        gdk_color_parse() implementations.
parent 37c87ccd
Sun Nov 4 19:16:23 2001 Owen Taylor <otaylor@redhat.com>
* gdk/gdkcolor.c (gdk_color_parse): Implement gdk_color_parse()
in terms of pango_color_parse().
* gdk/{linux-fb,win32,x11}/gdkcolor-*.c: Remove port-specific
gdk_color_parse() implementations.
Sun Nov 4 18:39:43 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtksizegroup.c (gtk_size_group_set_mode):
......
Sun Nov 4 19:16:23 2001 Owen Taylor <otaylor@redhat.com>
* gdk/gdkcolor.c (gdk_color_parse): Implement gdk_color_parse()
in terms of pango_color_parse().
* gdk/{linux-fb,win32,x11}/gdkcolor-*.c: Remove port-specific
gdk_color_parse() implementations.
Sun Nov 4 18:39:43 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtksizegroup.c (gtk_size_group_set_mode):
......
Sun Nov 4 19:16:23 2001 Owen Taylor <otaylor@redhat.com>
* gdk/gdkcolor.c (gdk_color_parse): Implement gdk_color_parse()
in terms of pango_color_parse().
* gdk/{linux-fb,win32,x11}/gdkcolor-*.c: Remove port-specific
gdk_color_parse() implementations.
Sun Nov 4 18:39:43 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtksizegroup.c (gtk_size_group_set_mode):
......
Sun Nov 4 19:16:23 2001 Owen Taylor <otaylor@redhat.com>
* gdk/gdkcolor.c (gdk_color_parse): Implement gdk_color_parse()
in terms of pango_color_parse().
* gdk/{linux-fb,win32,x11}/gdkcolor-*.c: Remove port-specific
gdk_color_parse() implementations.
Sun Nov 4 18:39:43 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtksizegroup.c (gtk_size_group_set_mode):
......
Sun Nov 4 19:16:23 2001 Owen Taylor <otaylor@redhat.com>
* gdk/gdkcolor.c (gdk_color_parse): Implement gdk_color_parse()
in terms of pango_color_parse().
* gdk/{linux-fb,win32,x11}/gdkcolor-*.c: Remove port-specific
gdk_color_parse() implementations.
Sun Nov 4 18:39:43 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtksizegroup.c (gtk_size_group_set_mode):
......
Sun Nov 4 19:16:23 2001 Owen Taylor <otaylor@redhat.com>
* gdk/gdkcolor.c (gdk_color_parse): Implement gdk_color_parse()
in terms of pango_color_parse().
* gdk/{linux-fb,win32,x11}/gdkcolor-*.c: Remove port-specific
gdk_color_parse() implementations.
Sun Nov 4 18:39:43 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtksizegroup.c (gtk_size_group_set_mode):
......
Sun Nov 4 19:16:23 2001 Owen Taylor <otaylor@redhat.com>
* gdk/gdkcolor.c (gdk_color_parse): Implement gdk_color_parse()
in terms of pango_color_parse().
* gdk/{linux-fb,win32,x11}/gdkcolor-*.c: Remove port-specific
gdk_color_parse() implementations.
Sun Nov 4 18:39:43 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtksizegroup.c (gtk_size_group_set_mode):
......
......@@ -228,3 +228,21 @@ gdk_color_get_type (void)
(GBoxedFreeFunc)gdk_color_free);
return our_type;
}
gboolean
gdk_color_parse (const gchar *spec,
GdkColor *color)
{
PangoColor pango_color;
if (pango_color_parse (&pango_color, spec))
{
color->red = pango_color.red;
color->green = pango_color.green;
color->blue = pango_color.blue;
return TRUE;
}
else
return FALSE;
}
......@@ -360,94 +360,6 @@ gdk_colormap_change (GdkColormap *colormap,
}
}
gboolean
gdk_color_parse (const gchar *spec,
GdkColor *color)
{
char aline[512];
FILE *fh;
g_return_val_if_fail(spec, FALSE);
g_return_val_if_fail(color, FALSE);
if (spec[0] == '#')
{
if (strlen(spec) == 7)
{
guint num;
sscanf (spec + 1, "%x", &num);
color->red = (num & 0xFF0000) >> 8;
color->green = (num & 0xFF00);
color->blue = (num & 0xFF) << 8;
}
else if (strlen(spec) == 13)
{
char s1[5], s2[5], s3[5];
g_snprintf (s1, sizeof(s1), spec + 1);
g_snprintf (s2, sizeof(s2), spec + 5);
g_snprintf (s3, sizeof(s3), spec + 9);
if (!sscanf(s1, "%hx", &color->red))
g_error ("sscanf failed");
if (!sscanf(s2, "%hx", &color->green))
g_error ("sscanf failed");
if (!sscanf (s3, "%hx", &color->blue))
g_error ("sscanf failed");
}
else
{
g_warning ("Couldn't parse color specifier `%s'", spec);
return FALSE;
}
return TRUE;
}
else
{
fh = fopen ("/usr/lib/X11/rgb.txt", "r");
if (!fh)
return FALSE;
while(fgets (aline, sizeof(aline), fh))
{
int red, green, blue;
char *ctmp;
g_strstrip (aline);
if (!aline[0] || aline[0] == '#' || aline[0] == '!')
continue;
ctmp = strtok (aline, " \t");
if (!ctmp)
continue;
red = atoi (ctmp);
ctmp = strtok (NULL, " \t");
if (!ctmp)
continue;
green = atoi (ctmp);
ctmp = strtok (NULL, " \t");
if (!ctmp)
continue;
blue = atoi (ctmp);
ctmp = strtok (NULL, " \t");
if (!ctmp || strcmp (ctmp, spec))
continue;
color->red = red << 8;
color->green = green << 8;
color->blue = blue << 8;
return TRUE;
}
fclose (fh);
}
return FALSE;
}
void
gdk_colormap_free_colors (GdkColormap *colormap,
GdkColor *colors,
......
......@@ -507,879 +507,6 @@ free_colormap(Colormap colormap)
g_free (colormap);
}
typedef struct {
char *name;
unsigned char red;
unsigned char green;
unsigned char blue;
} XColorEntry;
static XColorEntry xColors[] = {
{ "alice blue", 240, 248, 255 },
{ "AliceBlue", 240, 248, 255 },
{ "antique white", 250, 235, 215 },
{ "AntiqueWhite", 250, 235, 215 },
{ "AntiqueWhite1", 255, 239, 219 },
{ "AntiqueWhite2", 238, 223, 204 },
{ "AntiqueWhite3", 205, 192, 176 },
{ "AntiqueWhite4", 139, 131, 120 },
{ "aquamarine", 127, 255, 212 },
{ "aquamarine1", 127, 255, 212 },
{ "aquamarine2", 118, 238, 198 },
{ "aquamarine3", 102, 205, 170 },
{ "aquamarine4", 69, 139, 116 },
{ "azure", 240, 255, 255 },
{ "azure1", 240, 255, 255 },
{ "azure2", 224, 238, 238 },
{ "azure3", 193, 205, 205 },
{ "azure4", 131, 139, 139 },
{ "beige", 245, 245, 220 },
{ "bisque", 255, 228, 196 },
{ "bisque1", 255, 228, 196 },
{ "bisque2", 238, 213, 183 },
{ "bisque3", 205, 183, 158 },
{ "bisque4", 139, 125, 107 },
{ "black", 0, 0, 0 },
{ "blanched almond", 255, 235, 205 },
{ "BlanchedAlmond", 255, 235, 205 },
{ "blue", 0, 0, 255 },
{ "blue violet", 138, 43, 226 },
{ "blue1", 0, 0, 255 },
{ "blue2", 0, 0, 238 },
{ "blue3", 0, 0, 205 },
{ "blue4", 0, 0, 139 },
{ "BlueViolet", 138, 43, 226 },
{ "brown", 165, 42, 42 },
{ "brown1", 255, 64, 64 },
{ "brown2", 238, 59, 59 },
{ "brown3", 205, 51, 51 },
{ "brown4", 139, 35, 35 },
{ "burlywood", 222, 184, 135 },
{ "burlywood1", 255, 211, 155 },
{ "burlywood2", 238, 197, 145 },
{ "burlywood3", 205, 170, 125 },
{ "burlywood4", 139, 115, 85 },
{ "cadet blue", 95, 158, 160 },
{ "CadetBlue", 95, 158, 160 },
{ "CadetBlue1", 152, 245, 255 },
{ "CadetBlue2", 142, 229, 238 },
{ "CadetBlue3", 122, 197, 205 },
{ "CadetBlue4", 83, 134, 139 },
{ "chartreuse", 127, 255, 0 },
{ "chartreuse1", 127, 255, 0 },
{ "chartreuse2", 118, 238, 0 },
{ "chartreuse3", 102, 205, 0 },
{ "chartreuse4", 69, 139, 0 },
{ "chocolate", 210, 105, 30 },
{ "chocolate1", 255, 127, 36 },
{ "chocolate2", 238, 118, 33 },
{ "chocolate3", 205, 102, 29 },
{ "chocolate4", 139, 69, 19 },
{ "coral", 255, 127, 80 },
{ "coral1", 255, 114, 86 },
{ "coral2", 238, 106, 80 },
{ "coral3", 205, 91, 69 },
{ "coral4", 139, 62, 47 },
{ "cornflower blue", 100, 149, 237 },
{ "CornflowerBlue", 100, 149, 237 },
{ "cornsilk", 255, 248, 220 },
{ "cornsilk1", 255, 248, 220 },
{ "cornsilk2", 238, 232, 205 },
{ "cornsilk3", 205, 200, 177 },
{ "cornsilk4", 139, 136, 120 },
{ "cyan", 0, 255, 255 },
{ "cyan1", 0, 255, 255 },
{ "cyan2", 0, 238, 238 },
{ "cyan3", 0, 205, 205 },
{ "cyan4", 0, 139, 139 },
{ "dark blue", 0, 0, 139 },
{ "dark cyan", 0, 139, 139 },
{ "dark goldenrod", 184, 134, 11 },
{ "dark gray", 169, 169, 169 },
{ "dark green", 0, 100, 0 },
{ "dark grey", 169, 169, 169 },
{ "dark khaki", 189, 183, 107 },
{ "dark magenta", 139, 0, 139 },
{ "dark olive green", 85, 107, 47 },
{ "dark orange", 255, 140, 0 },
{ "dark orchid", 153, 50, 204 },
{ "dark red", 139, 0, 0 },
{ "dark salmon", 233, 150, 122 },
{ "dark sea green", 143, 188, 143 },
{ "dark slate blue", 72, 61, 139 },
{ "dark slate gray", 47, 79, 79 },
{ "dark slate grey", 47, 79, 79 },
{ "dark turquoise", 0, 206, 209 },
{ "dark violet", 148, 0, 211 },
{ "DarkBlue", 0, 0, 139 },
{ "DarkCyan", 0, 139, 139 },
{ "DarkGoldenrod", 184, 134, 11 },
{ "DarkGoldenrod1", 255, 185, 15 },
{ "DarkGoldenrod2", 238, 173, 14 },
{ "DarkGoldenrod3", 205, 149, 12 },
{ "DarkGoldenrod4", 139, 101, 8 },
{ "DarkGray", 169, 169, 169 },
{ "DarkGreen", 0, 100, 0 },
{ "DarkGrey", 169, 169, 169 },
{ "DarkKhaki", 189, 183, 107 },
{ "DarkMagenta", 139, 0, 139 },
{ "DarkOliveGreen", 85, 107, 47 },
{ "DarkOliveGreen1", 202, 255, 112 },
{ "DarkOliveGreen2", 188, 238, 104 },
{ "DarkOliveGreen3", 162, 205, 90 },
{ "DarkOliveGreen4", 110, 139, 61 },
{ "DarkOrange", 255, 140, 0 },
{ "DarkOrange1", 255, 127, 0 },
{ "DarkOrange2", 238, 118, 0 },
{ "DarkOrange3", 205, 102, 0 },
{ "DarkOrange4", 139, 69, 0 },
{ "DarkOrchid", 153, 50, 204 },
{ "DarkOrchid1", 191, 62, 255 },
{ "DarkOrchid2", 178, 58, 238 },
{ "DarkOrchid3", 154, 50, 205 },
{ "DarkOrchid4", 104, 34, 139 },
{ "DarkRed", 139, 0, 0 },
{ "DarkSalmon", 233, 150, 122 },
{ "DarkSeaGreen", 143, 188, 143 },
{ "DarkSeaGreen1", 193, 255, 193 },
{ "DarkSeaGreen2", 180, 238, 180 },
{ "DarkSeaGreen3", 155, 205, 155 },
{ "DarkSeaGreen4", 105, 139, 105 },
{ "DarkSlateBlue", 72, 61, 139 },
{ "DarkSlateGray", 47, 79, 79 },
{ "DarkSlateGray1", 151, 255, 255 },
{ "DarkSlateGray2", 141, 238, 238 },
{ "DarkSlateGray3", 121, 205, 205 },
{ "DarkSlateGray4", 82, 139, 139 },
{ "DarkSlateGrey", 47, 79, 79 },
{ "DarkTurquoise", 0, 206, 209 },
{ "DarkViolet", 148, 0, 211 },
{ "deep pink", 255, 20, 147 },
{ "deep sky blue", 0, 191, 255 },
{ "DeepPink", 255, 20, 147 },
{ "DeepPink1", 255, 20, 147 },
{ "DeepPink2", 238, 18, 137 },
{ "DeepPink3", 205, 16, 118 },
{ "DeepPink4", 139, 10, 80 },
{ "DeepSkyBlue", 0, 191, 255 },
{ "DeepSkyBlue1", 0, 191, 255 },
{ "DeepSkyBlue2", 0, 178, 238 },
{ "DeepSkyBlue3", 0, 154, 205 },
{ "DeepSkyBlue4", 0, 104, 139 },
{ "dim gray", 105, 105, 105 },
{ "dim grey", 105, 105, 105 },
{ "DimGray", 105, 105, 105 },
{ "DimGrey", 105, 105, 105 },
{ "dodger blue", 30, 144, 255 },
{ "DodgerBlue", 30, 144, 255 },
{ "DodgerBlue1", 30, 144, 255 },
{ "DodgerBlue2", 28, 134, 238 },
{ "DodgerBlue3", 24, 116, 205 },
{ "DodgerBlue4", 16, 78, 139 },
{ "firebrick", 178, 34, 34 },
{ "firebrick1", 255, 48, 48 },
{ "firebrick2", 238, 44, 44 },
{ "firebrick3", 205, 38, 38 },
{ "firebrick4", 139, 26, 26 },
{ "floral white", 255, 250, 240 },
{ "FloralWhite", 255, 250, 240 },
{ "forest green", 34, 139, 34 },
{ "ForestGreen", 34, 139, 34 },
{ "gainsboro", 220, 220, 220 },
{ "ghost white", 248, 248, 255 },
{ "GhostWhite", 248, 248, 255 },
{ "gold", 255, 215, 0 },
{ "gold1", 255, 215, 0 },
{ "gold2", 238, 201, 0 },
{ "gold3", 205, 173, 0 },
{ "gold4", 139, 117, 0 },
{ "goldenrod", 218, 165, 32 },
{ "goldenrod1", 255, 193, 37 },
{ "goldenrod2", 238, 180, 34 },
{ "goldenrod3", 205, 155, 29 },
{ "goldenrod4", 139, 105, 20 },
{ "gray", 190, 190, 190 },
{ "gray0", 0, 0, 0 },
{ "gray1", 3, 3, 3 },
{ "gray10", 26, 26, 26 },
{ "gray100", 255, 255, 255 },
{ "gray11", 28, 28, 28 },
{ "gray12", 31, 31, 31 },
{ "gray13", 33, 33, 33 },
{ "gray14", 36, 36, 36 },
{ "gray15", 38, 38, 38 },
{ "gray16", 41, 41, 41 },
{ "gray17", 43, 43, 43 },
{ "gray18", 46, 46, 46 },
{ "gray19", 48, 48, 48 },
{ "gray2", 5, 5, 5 },
{ "gray20", 51, 51, 51 },
{ "gray21", 54, 54, 54 },
{ "gray22", 56, 56, 56 },
{ "gray23", 59, 59, 59 },
{ "gray24", 61, 61, 61 },
{ "gray25", 64, 64, 64 },
{ "gray26", 66, 66, 66 },
{ "gray27", 69, 69, 69 },
{ "gray28", 71, 71, 71 },
{ "gray29", 74, 74, 74 },
{ "gray3", 8, 8, 8 },
{ "gray30", 77, 77, 77 },
{ "gray31", 79, 79, 79 },
{ "gray32", 82, 82, 82 },
{ "gray33", 84, 84, 84 },
{ "gray34", 87, 87, 87 },
{ "gray35", 89, 89, 89 },
{ "gray36", 92, 92, 92 },
{ "gray37", 94, 94, 94 },
{ "gray38", 97, 97, 97 },
{ "gray39", 99, 99, 99 },
{ "gray4", 10, 10, 10 },
{ "gray40", 102, 102, 102 },
{ "gray41", 105, 105, 105 },
{ "gray42", 107, 107, 107 },
{ "gray43", 110, 110, 110 },
{ "gray44", 112, 112, 112 },
{ "gray45", 115, 115, 115 },
{ "gray46", 117, 117, 117 },
{ "gray47", 120, 120, 120 },
{ "gray48", 122, 122, 122 },
{ "gray49", 125, 125, 125 },
{ "gray5", 13, 13, 13 },
{ "gray50", 127, 127, 127 },
{ "gray51", 130, 130, 130 },
{ "gray52", 133, 133, 133 },
{ "gray53", 135, 135, 135 },
{ "gray54", 138, 138, 138 },
{ "gray55", 140, 140, 140 },
{ "gray56", 143, 143, 143 },
{ "gray57", 145, 145, 145 },
{ "gray58", 148, 148, 148 },
{ "gray59", 150, 150, 150 },
{ "gray6", 15, 15, 15 },
{ "gray60", 153, 153, 153 },
{ "gray61", 156, 156, 156 },
{ "gray62", 158, 158, 158 },
{ "gray63", 161, 161, 161 },
{ "gray64", 163, 163, 163 },
{ "gray65", 166, 166, 166 },
{ "gray66", 168, 168, 168 },
{ "gray67", 171, 171, 171 },
{ "gray68", 173, 173, 173 },
{ "gray69", 176, 176, 176 },
{ "gray7", 18, 18, 18 },
{ "gray70", 179, 179, 179 },
{ "gray71", 181, 181, 181 },
{ "gray72", 184, 184, 184 },
{ "gray73", 186, 186, 186 },
{ "gray74", 189, 189, 189 },
{ "gray75", 191, 191, 191 },
{ "gray76", 194, 194, 194 },
{ "gray77", 196, 196, 196 },
{ "gray78", 199, 199, 199 },
{ "gray79", 201, 201, 201 },
{ "gray8", 20, 20, 20 },
{ "gray80", 204, 204, 204 },
{ "gray81", 207, 207, 207 },
{ "gray82", 209, 209, 209 },
{ "gray83", 212, 212, 212 },
{ "gray84", 214, 214, 214 },
{ "gray85", 217, 217, 217 },
{ "gray86", 219, 219, 219 },
{ "gray87", 222, 222, 222 },
{ "gray88", 224, 224, 224 },
{ "gray89", 227, 227, 227 },
{ "gray9", 23, 23, 23 },
{ "gray90", 229, 229, 229 },
{ "gray91", 232, 232, 232 },
{ "gray92", 235, 235, 235 },
{ "gray93", 237, 237, 237 },
{ "gray94", 240, 240, 240 },
{ "gray95", 242, 242, 242 },
{ "gray96", 245, 245, 245 },
{ "gray97", 247, 247, 247 },
{ "gray98", 250, 250, 250 },
{ "gray99", 252, 252, 252 },
{ "green", 0, 255, 0 },
{ "green yellow", 173, 255, 47 },
{ "green1", 0, 255, 0 },
{ "green2", 0, 238, 0 },
{ "green3", 0, 205, 0 },
{ "green4", 0, 139, 0 },
{ "GreenYellow", 173, 255, 47 },
{ "grey", 190, 190, 190 },
{ "grey0", 0, 0, 0 },
{ "grey1", 3, 3, 3 },
{ "grey10", 26, 26, 26 },
{ "grey100", 255, 255, 255 },
{ "grey11", 28, 28, 28 },
{ "grey12", 31, 31, 31 },
{ "grey13", 33, 33, 33 },
{ "grey14", 36, 36, 36 },
{ "grey15", 38, 38, 38 },
{ "grey16", 41, 41, 41 },
{ "grey17", 43, 43, 43 },
{ "grey18", 46, 46, 46 },
{ "grey19", 48, 48, 48 },
{ "grey2", 5, 5, 5 },
{ "grey20", 51, 51, 51 },
{ "grey21", 54, 54, 54 },
{ "grey22", 56, 56, 56 },
{ "grey23", 59, 59, 59 },
{ "grey24", 61, 61, 61 },
{ "grey25", 64, 64, 64 },
{ "grey26", 66, 66, 66 },
{ "grey27", 69, 69, 69 },
{ "grey28", 71, 71, 71 },
{ "grey29", 74, 74, 74 },
{ "grey3", 8, 8, 8 },
{ "grey30", 77, 77, 77 },
{ "grey31", 79, 79, 79 },
{ "grey32", 82, 82, 82 },
{ "grey33", 84, 84, 84 },
{ "grey34", 87, 87, 87 },
{ "grey35", 89, 89, 89 },
{ "grey36", 92, 92, 92 },
{ "grey37", 94, 94, 94 },
{ "grey38", 97, 97, 97 },
{ "grey39", 99, 99, 99 },
{ "grey4", 10, 10, 10 },
{ "grey40", 102, 102, 102 },
{ "grey41", 105, 105, 105 },
{ "grey42", 107, 107, 107 },
{ "grey43", 110, 110, 110 },
{ "grey44", 112, 112, 112 },
{ "grey45", 115, 115, 115 },
{ "grey46", 117, 117, 117 },
{ "grey47", 120, 120, 120 },
{ "grey48", 122, 122, 122 },
{ "grey49", 125, 125, 125 },
{ "grey5", 13, 13, 13 },
{ "grey50", 127, 127, 127 },
{ "grey51", 130, 130, 130 },
{ "grey52", 133, 133, 133 },
{ "grey53", 135, 135, 135 },
{ "grey54", 138, 138, 138 },
{ "grey55", 140, 140, 140 },
{ "grey56", 143, 143, 143 },
{ "grey57", 145, 145, 145 },
{ "grey58", 148, 148, 148 },
{ "grey59", 150, 150, 150 },
{ "grey6", 15, 15, 15 },
{ "grey60", 153, 153, 153 },
{ "grey61", 156, 156, 156 },
{ "grey62", 158, 158, 158 },
{ "grey63", 161, 161, 161 },
{ "grey64", 163, 163, 163 },
{ "grey65", 166, 166, 166 },
{ "grey66", 168, 168, 168 },
{ "grey67", 171, 171, 171 },
{ "grey68", 173, 173, 173 },
{ "grey69", 176, 176, 176 },
{ "grey7", 18, 18, 18 },
{ "grey70", 179, 179, 179 },
{ "grey71", 181, 181, 181 },
{ "grey72", 184, 184, 184 },
{ "grey73", 186, 186, 186 },
{ "grey74", 189, 189, 189 },
{ "grey75", 191, 191, 191 },
{ "grey76", 194, 194, 194 },
{ "grey77", 196, 196, 196 },
{ "grey78", 199, 199, 199 },
{ "grey79", 201, 201, 201 },