diff options
author | Chris Kühl <[email protected]> | 2011-01-26 11:51:50 +0100 |
---|---|---|
committer | Benjamin Valentin <[email protected]> | 2012-03-17 16:45:43 +0100 |
commit | a43f2684570c10f3c5ee2f32b41065c9d2f2f14e (patch) | |
tree | eaace075dc0d958e29196be892066895662aacb6 | |
parent | d978ff67175c8e0b05b2a6732ec47aff2dbd21b8 (diff) | |
download | mate-system-monitor-a43f2684570c10f3c5ee2f32b41065c9d2f2f14e.tar.bz2 mate-system-monitor-a43f2684570c10f3c5ee2f32b41065c9d2f2f14e.tar.xz |
Replace old GDK drawing API
Patch from Sergey Nizovtsev.
See https://bugzilla.gnome.org/show_bug.cgi?id=627568
-rw-r--r-- | src/load-graph.cpp | 30 | ||||
-rw-r--r-- | src/load-graph.h | 1 |
2 files changed, 10 insertions, 21 deletions
diff --git a/src/load-graph.cpp b/src/load-graph.cpp index 79700d4..3cf8683 100644 --- a/src/load-graph.cpp +++ b/src/load-graph.cpp @@ -87,7 +87,7 @@ void draw_background(LoadGraph *g) { allocation.height, -1); cr = gdk_cairo_create (g->background); - + // set the background colour GtkStyle *style = gtk_widget_get_style (ProcData::get_instance()->notebook); gdk_cairo_set_source_color (cr, &style->bg[GTK_STATE_NORMAL]); @@ -95,13 +95,13 @@ void draw_background(LoadGraph *g) { /* draw frame */ cairo_translate (cr, FRAME_WIDTH, FRAME_WIDTH); - + /* Draw background rectangle */ cairo_set_source_rgb (cr, 1.0, 1.0, 1.0); cairo_rectangle (cr, g->rmargin + g->indent, 0, g->draw_width - g->rmargin - g->indent, g->real_draw_height); cairo_fill(cr); - + cairo_set_line_width (cr, 1.0); cairo_set_dash (cr, dash, 2, 0); cairo_set_font_size (cr, g->fontsize); @@ -191,10 +191,6 @@ load_graph_configure (GtkWidget *widget, g->clear_background(); - if (g->gc == NULL) { - g->gc = gdk_gc_new (GDK_DRAWABLE (gtk_widget_get_window (widget))); - } - load_graph_draw (g); return TRUE; @@ -212,19 +208,14 @@ load_graph_expose (GtkWidget *widget, guint i, j; gdouble sample_width, x_offset; + window = gtk_widget_get_window (g->disp); + gtk_widget_get_allocation (g->disp, &allocation); + if (g->background == NULL) { draw_background(g); + gdk_window_set_back_pixmap (window, g->background, FALSE); } - window = gtk_widget_get_window (g->disp); - gtk_widget_get_allocation (g->disp, &allocation); - gdk_draw_drawable (window, - g->gc, - g->background, - 0, 0, 0, 0, - allocation.width, - allocation.height); - /* Number of pixels wide for one graph point */ sample_width = (float)(g->draw_width - g->rmargin - g->indent) / (float)LoadGraph::NUM_POINTS; /* General offset */ @@ -252,7 +243,7 @@ load_graph_expose (GtkWidget *widget, for (i = 1; i < LoadGraph::NUM_POINTS; ++i) { if (g->data[i][j] == -1.0f) continue; - cairo_curve_to (cr, + cairo_curve_to (cr, x_offset - ((i - 0.5f) * g->graph_delx), (1.0f - g->data[i-1][j]) * g->real_draw_height + 3.5f, x_offset - ((i - 0.5f) * g->graph_delx), @@ -619,7 +610,6 @@ LoadGraph::LoadGraph(guint type) graph_buffer_offset(0), main_widget(NULL), disp(NULL), - gc(NULL), background(NULL), timer_index(0), draw(FALSE), @@ -676,9 +666,9 @@ LoadGraph::LoadGraph(guint type) case LOAD_GRAPH_MEM: g->colors[0] = ProcData::get_instance()->config.mem_color; g->colors[1] = ProcData::get_instance()->config.swap_color; - g->mem_color_picker = gsm_color_button_new (&g->colors[0], + g->mem_color_picker = gsm_color_button_new (&g->colors[0], GSMCP_TYPE_PIE); - g->swap_color_picker = gsm_color_button_new (&g->colors[1], + g->swap_color_picker = gsm_color_button_new (&g->colors[1], GSMCP_TYPE_PIE); break; case LOAD_GRAPH_NET: diff --git a/src/load-graph.h b/src/load-graph.h index 6e7a599..9dd28bb 100644 --- a/src/load-graph.h +++ b/src/load-graph.h @@ -66,7 +66,6 @@ struct LoadGraph { GtkWidget *main_widget; GtkWidget *disp; - GdkGC *gc; GdkDrawable *background; guint timer_index; |