2 * @file gtkstyle.c GTK+ Style utility functions
8 * Pidgin is the legal property of its developers, whose names are too numerous
9 * to list here. Please refer to the COPYRIGHT file distributed with this
10 * source distribution.
12 * This program is free software; you can redistribute it and/or modify
13 * under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
29 /* Assume light mode */
30 static gboolean dark_mode_cache
= FALSE
;
33 pidgin_style_is_dark(GtkStyle
*style
) {
37 return dark_mode_cache
;
40 bg
= style
->base
[GTK_STATE_NORMAL
];
42 if (bg
.red
!= 0xFFFF || bg
.green
!= 0xFFFF || bg
.blue
!= 0xFFFF) {
43 dark_mode_cache
= ((int) bg
.red
+ (int) bg
.green
+ (int) bg
.blue
) < (65536 * 3 / 2);
46 return dark_mode_cache
;
50 pidgin_style_adjust_contrast(GtkStyle
*style
, GdkRGBA
*rgba
) {
51 if (pidgin_style_is_dark(style
)) {
54 gtk_rgb_to_hsv(rgba
->red
, rgba
->green
, rgba
->blue
, &h
, &s
, &v
);
57 v
= v
> 1.0 ? 1.0 : v
;
60 gtk_hsv_to_rgb(h
, s
, v
, &rgba
->red
, &rgba
->green
, &rgba
->blue
);