Change colour function to is_color_light in gnc-dense-cal

Change colour function to is_color_light and correct syntax and also
change some character strings.
This commit is contained in:
Robert Fewell 2017-08-28 10:21:44 +01:00
parent d3e6a9c53b
commit 659d3b9582

View File

@ -924,17 +924,17 @@ gnc_style_context_get_border_color (GtkStyleContext *context,
} }
static gboolean static gboolean
is_color_dark (GdkRGBA *color) is_color_light (GdkRGBA *color)
{ {
gboolean is_dark = FALSE; gboolean is_light = FALSE;
// Counting the perceptive luminance - human eye favors green color... // Counting the perceptive luminance - human eye favors green color...
double a = (0.299 * color->red + 0.587 * color->green + 0.114 * color->blue); double a = (0.299 * color->red + 0.587 * color->green + 0.114 * color->blue);
if (a > 0.5) if (a > 0.5)
is_dark = TRUE; is_light = TRUE;
return is_dark; return is_light;
} }
static void static void
@ -949,7 +949,7 @@ gnc_dense_cal_draw_to_buffer(GncDenseCal *dcal)
PangoLayout *layout; PangoLayout *layout;
GTimer *timer; GTimer *timer;
cairo_t *cr; cairo_t *cr;
const gchar *primary_color_class, *secondary_color_class, *marker_color_class; gchar *primary_color_class, *secondary_color_class, *marker_color_class;
timer = g_timer_new(); timer = g_timer_new();
g_debug("drawing"); g_debug("drawing");
@ -976,16 +976,16 @@ gnc_dense_cal_draw_to_buffer(GncDenseCal *dcal)
/* get the colors */ /* get the colors */
{ {
GdkRGBA color; GdkRGBA color;
gchar *color_extension = NULL; gchar *class_extension = NULL;
gtk_style_context_get_color (stylectxt, GTK_STATE_FLAG_NORMAL, &color); gtk_style_context_get_color (stylectxt, GTK_STATE_FLAG_NORMAL, &color);
if (is_color_dark (&color)) if (is_color_light (&color))
color_extension = "-dark"; class_extension = "-dark";
primary_color_class = g_strconcat ("primary", color_extension, NULL); primary_color_class = g_strconcat ("primary", class_extension, NULL);
secondary_color_class = g_strconcat ("secondary", color_extension, NULL); secondary_color_class = g_strconcat ("secondary", class_extension, NULL);
marker_color_class = g_strconcat ("markers", color_extension, NULL); marker_color_class = g_strconcat ("markers", class_extension, NULL);
} }
@ -1232,6 +1232,10 @@ gnc_dense_cal_draw_to_buffer(GncDenseCal *dcal)
LOG_AND_RESET(timer, "queue draw"); LOG_AND_RESET(timer, "queue draw");
g_free (primary_color_class);
g_free (secondary_color_class);
g_free (marker_color_class);
g_object_unref(layout); g_object_unref(layout);
cairo_destroy (cr); cairo_destroy (cr);