From 7e5d6b8c9e50f45b92357643c327a5ae5ad5ef4d Mon Sep 17 00:00:00 2001 From: Jean-Philippe Orsini Date: Wed, 4 Apr 2012 06:43:16 +0000 Subject: [PATCH] fixed wrong background color, get the background color of the window and not the canvas widget. --- NEWS | 2 ++ src/graph.c | 28 ++++++++++++++++++---------- src/graph.h | 5 ++++- src/main.c | 2 +- src/ui_graph.c | 4 +++- 5 files changed, 28 insertions(+), 13 deletions(-) diff --git a/NEWS b/NEWS index 823885d..e9da337 100644 --- a/NEWS +++ b/NEWS @@ -13,6 +13,8 @@ ** changed copyright dates to 2012. ** psensor: fixed systray and application indicator visible at the same time. (Closes LP: #971098) +** psensor: fixed wrong background color, get the background color of + the window and not the canvas widget. * v0.6.2.17 diff --git a/src/graph.c b/src/graph.c index ed3c43a..98b208b 100644 --- a/src/graph.c +++ b/src/graph.c @@ -76,7 +76,8 @@ draw_graph_background(cairo_t *cr, int g_xoff, int g_yoff, int g_width, int g_height, int width, int height, struct config *config, - GtkWidget *widget) + GtkWidget *widget, + GtkWidget *window) { GtkStyleContext *style_ctx; struct color *bgcolor; @@ -84,10 +85,11 @@ draw_graph_background(cairo_t *cr, bgcolor = config->graph_bgcolor; - style_ctx = gtk_widget_get_style_context(widget); + style_ctx = gtk_widget_get_style_context(window); gtk_style_context_get_background_color(style_ctx, GTK_STATE_FLAG_NORMAL, &rgba); + if (config->alpha_channel_enabled) cairo_set_source_rgba(cr, rgba.red, @@ -106,13 +108,13 @@ draw_graph_background(cairo_t *cr, cairo_set_source_rgba(cr, bgcolor->f_red, bgcolor->f_green, - bgcolor->f_blue, config->graph_bg_alpha); + bgcolor->f_blue, + config->graph_bg_alpha); else cairo_set_source_rgb(cr, bgcolor->f_red, - bgcolor->f_green, bgcolor->f_blue); - - + bgcolor->f_green, + bgcolor->f_blue); cairo_rectangle(cr, g_xoff, g_yoff, g_width, g_height); cairo_fill(cr); @@ -213,7 +215,8 @@ static void draw_sensor_curve(struct psensor *s, void graph_update(struct psensor **sensors, GtkWidget *w_graph, - struct config *config) + struct config *config, + GtkWidget *window) { struct color *fgcolor = config->graph_fgcolor; int et, bt, width, height, g_width, g_height; @@ -227,6 +230,8 @@ graph_update(struct psensor **sensors, cairo_text_extents_t te_btime, te_etime, te_max, te_min; struct psensor **sensor_cur; GtkAllocation galloc; + GtkStyleContext *style_ctx; + GdkRGBA rgba; if (!gtk_widget_is_drawable(w_graph)) return ; @@ -279,10 +284,13 @@ graph_update(struct psensor **sensors, draw_graph_background(cr, g_xoff, g_yoff, g_width, g_height, width, height, config, - w_graph); + w_graph, + window); - cairo_set_source_rgb(cr, - fgcolor->f_red, fgcolor->f_green, fgcolor->f_blue); + /** Set the color for text drawing */ + style_ctx = gtk_widget_get_style_context(w_graph); + gtk_style_context_get_color(style_ctx, GTK_STATE_FLAG_NORMAL, &rgba); + cairo_set_source_rgb(cr, rgba.red, rgba.green, rgba.blue); /* draw graph begin time */ cairo_move_to(cr, g_xoff, height - GRAPH_V_PADDING); diff --git a/src/graph.h b/src/graph.h index 897ec7b..3827a35 100644 --- a/src/graph.h +++ b/src/graph.h @@ -24,6 +24,9 @@ #include "psensor.h" #include "cfg.h" -void graph_update(struct psensor **, GtkWidget *, struct config *config); +void graph_update(struct psensor **, + GtkWidget *, + struct config *config, + GtkWidget *window); #endif diff --git a/src/main.c b/src/main.c index f104c6a..dde8e5a 100644 --- a/src/main.c +++ b/src/main.c @@ -215,7 +215,7 @@ gboolean ui_refresh_thread(gpointer data) g_mutex_lock(ui->sensors_mutex); - graph_update(ui->sensors, ui->w_graph, ui->config); + graph_update(ui->sensors, ui->w_graph, ui->config, ui->main_window); ui_sensorlist_update(ui); diff --git a/src/ui_graph.c b/src/ui_graph.c index 47d9fd4..ec8e52c 100644 --- a/src/ui_graph.c +++ b/src/ui_graph.c @@ -124,7 +124,9 @@ on_expose_event(GtkWidget *widget, GdkEventExpose *event, gpointer data) struct ui_psensor *ui_psensor = (struct ui_psensor *)data; graph_update(ui_psensor->sensors, - ui_psensor->w_graph, ui_psensor->config); + ui_psensor->w_graph, + ui_psensor->config, + ui_psensor->main_window); return FALSE; } -- 2.7.4