1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-10 01:48:00 +00:00

Switch to gdk_rgba_parse() for GDK 3.

I'm using a slightly more up-to-date GTK version for testing on MacOS,
and it's marked a few more functions as deprecated, among which is
gdk_color_parse(). So now parsing -fg and -bg options has to be done
by two different calls and an ugly #ifdef, depending on GTK version.
This commit is contained in:
Simon Tatham 2015-08-31 13:37:30 +01:00
parent 5de838a979
commit 620622b3e5

View File

@ -3362,27 +3362,47 @@ int do_cmdline(int argc, char **argv, int do_everything, int *allow_launch,
} else if (!strcmp(p, "-fg") || !strcmp(p, "-bg") ||
!strcmp(p, "-bfg") || !strcmp(p, "-bbg") ||
!strcmp(p, "-cfg") || !strcmp(p, "-cbg")) {
GdkColor col;
EXPECTS_ARG;
SECOND_PASS_ONLY;
if (!gdk_color_parse(val, &col)) {
err = 1;
fprintf(stderr, "%s: unable to parse colour \"%s\"\n",
appname, val);
} else {
int index;
index = (!strcmp(p, "-fg") ? 0 :
!strcmp(p, "-bg") ? 2 :
!strcmp(p, "-bfg") ? 1 :
!strcmp(p, "-bbg") ? 3 :
!strcmp(p, "-cfg") ? 4 :
!strcmp(p, "-cbg") ? 5 : -1);
assert(index != -1);
conf_set_int_int(conf, CONF_colours, index*3+0, col.red / 256);
conf_set_int_int(conf, CONF_colours, index*3+1,col.green/ 256);
conf_set_int_int(conf, CONF_colours, index*3+2, col.blue/ 256);
}
{
#if GTK_CHECK_VERSION(3,0,0)
GdkRGBA rgba;
int success = gdk_rgba_parse(&rgba, val);
#else
GdkColor col;
int success = gdk_color_parse(val, &col);
#endif
if (!success) {
err = 1;
fprintf(stderr, "%s: unable to parse colour \"%s\"\n",
appname, val);
} else {
#if GTK_CHECK_VERSION(3,0,0)
int r = rgba.red * 255;
int g = rgba.green * 255;
int b = rgba.blue * 255;
#else
int r = col.red / 256;
int g = col.green / 256;
int b = col.blue / 256;
#endif
int index;
index = (!strcmp(p, "-fg") ? 0 :
!strcmp(p, "-bg") ? 2 :
!strcmp(p, "-bfg") ? 1 :
!strcmp(p, "-bbg") ? 3 :
!strcmp(p, "-cfg") ? 4 :
!strcmp(p, "-cbg") ? 5 : -1);
assert(index != -1);
conf_set_int_int(conf, CONF_colours, index*3+0, r);
conf_set_int_int(conf, CONF_colours, index*3+1, g);
conf_set_int_int(conf, CONF_colours, index*3+2, b);
}
}
} else if (use_pty_argv && !strcmp(p, "-e")) {
/* This option swallows all further arguments. */