mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-02-04 06:02:24 +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:
parent
5de838a979
commit
620622b3e5
@ -3362,15 +3362,33 @@ int do_cmdline(int argc, char **argv, int do_everything, int *allow_launch,
|
|||||||
} else if (!strcmp(p, "-fg") || !strcmp(p, "-bg") ||
|
} else if (!strcmp(p, "-fg") || !strcmp(p, "-bg") ||
|
||||||
!strcmp(p, "-bfg") || !strcmp(p, "-bbg") ||
|
!strcmp(p, "-bfg") || !strcmp(p, "-bbg") ||
|
||||||
!strcmp(p, "-cfg") || !strcmp(p, "-cbg")) {
|
!strcmp(p, "-cfg") || !strcmp(p, "-cbg")) {
|
||||||
GdkColor col;
|
|
||||||
|
|
||||||
EXPECTS_ARG;
|
EXPECTS_ARG;
|
||||||
SECOND_PASS_ONLY;
|
SECOND_PASS_ONLY;
|
||||||
if (!gdk_color_parse(val, &col)) {
|
|
||||||
|
{
|
||||||
|
#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;
|
err = 1;
|
||||||
fprintf(stderr, "%s: unable to parse colour \"%s\"\n",
|
fprintf(stderr, "%s: unable to parse colour \"%s\"\n",
|
||||||
appname, val);
|
appname, val);
|
||||||
} else {
|
} 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;
|
int index;
|
||||||
index = (!strcmp(p, "-fg") ? 0 :
|
index = (!strcmp(p, "-fg") ? 0 :
|
||||||
!strcmp(p, "-bg") ? 2 :
|
!strcmp(p, "-bg") ? 2 :
|
||||||
@ -3379,9 +3397,11 @@ int do_cmdline(int argc, char **argv, int do_everything, int *allow_launch,
|
|||||||
!strcmp(p, "-cfg") ? 4 :
|
!strcmp(p, "-cfg") ? 4 :
|
||||||
!strcmp(p, "-cbg") ? 5 : -1);
|
!strcmp(p, "-cbg") ? 5 : -1);
|
||||||
assert(index != -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+0, r);
|
||||||
conf_set_int_int(conf, CONF_colours, index*3+2, col.blue/ 256);
|
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")) {
|
} else if (use_pty_argv && !strcmp(p, "-e")) {
|
||||||
|
Loading…
Reference in New Issue
Block a user