Simplify handling of GG xfer auth queue.
[pidgin-git.git] / pidgin / gtkstyle.c
blob2409c53544d9b3c728b903ac1166df5bfc084425
1 /*
2 * @file gtkstyle.c GTK+ Style utility functions
3 * @ingroup pidgin
4 */
6 /* pidgin
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
27 #include "gtkstyle.h"
29 /* Assume light mode */
30 static gboolean dark_mode_cache = FALSE;
32 gboolean
33 pidgin_style_is_dark(GtkStyle *style) {
34 GdkColor bg;
36 if (!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;
49 void
50 pidgin_style_adjust_contrast(GtkStyle *style, GdkRGBA *rgba) {
51 if (pidgin_style_is_dark(style)) {
52 gdouble h, s, v;
54 gtk_rgb_to_hsv(rgba->red, rgba->green, rgba->blue, &h, &s, &v);
56 v += 0.3;
57 v = v > 1.0 ? 1.0 : v;
58 s = 0.7;
60 gtk_hsv_to_rgb(h, s, v, &rgba->red, &rgba->green, &rgba->blue);