[nautilus] properties-window: don't use expose-event to draw the pie chart
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus] properties-window: don't use expose-event to draw the pie chart
- Date: Mon, 4 Oct 2010 10:09:09 +0000 (UTC)
commit 5ece5d67163e30a91e600d2f2bcf0d657d365dc4
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Mon Oct 4 02:54:26 2010 +0200
properties-window: don't use expose-event to draw the pie chart
Use GtkWidget::draw instead
src/file-manager/fm-properties-window.c | 36 +++++++++++++------------------
1 files changed, 15 insertions(+), 21 deletions(-)
---
diff --git a/src/file-manager/fm-properties-window.c b/src/file-manager/fm-properties-window.c
index e06c098..4c3be0d 100644
--- a/src/file-manager/fm-properties-window.c
+++ b/src/file-manager/fm-properties-window.c
@@ -2571,10 +2571,11 @@ should_show_volume_usage (FMPropertiesWindow *window)
}
static void
-paint_used_legend (GtkWidget *widget, GdkEventExpose *eev, gpointer data)
+paint_used_legend (GtkWidget *widget,
+ cairo_t *cr,
+ gpointer data)
{
FMPropertiesWindow *window;
- cairo_t *cr;
gint width, height;
GtkAllocation allocation;
@@ -2584,9 +2585,7 @@ paint_used_legend (GtkWidget *widget, GdkEventExpose *eev, gpointer data)
height = allocation.height;
window = FM_PROPERTIES_WINDOW (data);
-
- cr = gdk_cairo_create (gtk_widget_get_window (widget));
-
+
cairo_rectangle (cr,
2,
2,
@@ -2598,15 +2597,13 @@ paint_used_legend (GtkWidget *widget, GdkEventExpose *eev, gpointer data)
cairo_set_source_rgb (cr, (double) window->details->used_stroke_color.red / 65535, (double) window->details->used_stroke_color.green / 65535, (double) window->details->used_stroke_color.blue / 65535);
cairo_stroke (cr);
-
- cairo_destroy (cr);
}
static void
-paint_free_legend (GtkWidget *widget, GdkEventExpose *eev, gpointer data)
+paint_free_legend (GtkWidget *widget,
+ cairo_t *cr, gpointer data)
{
FMPropertiesWindow *window;
- cairo_t *cr;
gint width, height;
GtkAllocation allocation;
@@ -2615,7 +2612,6 @@ paint_free_legend (GtkWidget *widget, GdkEventExpose *eev, gpointer data)
width = allocation.width;
height = allocation.height;
- cr = gdk_cairo_create (gtk_widget_get_window (widget));
cairo_rectangle (cr,
2,
@@ -2628,16 +2624,15 @@ paint_free_legend (GtkWidget *widget, GdkEventExpose *eev, gpointer data)
cairo_set_source_rgb (cr, (double) window->details->free_stroke_color.red / 65535, (double) window->details->free_stroke_color.green / 65535, (double) window->details->free_stroke_color.blue / 65535);
cairo_stroke (cr);
-
- cairo_destroy (cr);
}
static void
-paint_pie_chart (GtkWidget *widget, GdkEventExpose *eev, gpointer data)
+paint_pie_chart (GtkWidget *widget,
+ cairo_t *cr,
+ gpointer data)
{
FMPropertiesWindow *window;
- cairo_t *cr;
gint width, height;
double free, used;
double angle1, angle2, split, xc, yc, radius;
@@ -2658,8 +2653,6 @@ paint_pie_chart (GtkWidget *widget, GdkEventExpose *eev, gpointer data)
split = (2 * G_PI - angle1) * .5;
xc = width / 2;
yc = height / 2;
-
- cr = gdk_cairo_create (gtk_widget_get_window (widget));
if (width < height) {
radius = width / 2 - 8;
@@ -2710,8 +2703,6 @@ paint_pie_chart (GtkWidget *widget, GdkEventExpose *eev, gpointer data)
cairo_set_source_rgb (cr, (double) window->details->free_stroke_color.red / 65535, (double) window->details->free_stroke_color.green / 65535, (double) window->details->free_stroke_color.blue / 65535);
cairo_stroke (cr);
}
-
- cairo_destroy (cr);
}
@@ -2994,9 +2985,12 @@ create_pie_widget (FMPropertiesWindow *window)
gtk_table_attach (table, capacity_label , 1, 3, 2, 3, GTK_FILL, 0, 5, 5);
gtk_table_attach (table, fstype_label , 1, 3, 3, 4, GTK_FILL, 0, 5, 5);
- g_signal_connect (G_OBJECT (pie_canvas), "expose-event", G_CALLBACK (paint_pie_chart), window);
- g_signal_connect (G_OBJECT (used_canvas), "expose-event", G_CALLBACK (paint_used_legend), window);
- g_signal_connect (G_OBJECT (free_canvas), "expose-event", G_CALLBACK (paint_free_legend), window);
+ g_signal_connect (pie_canvas, "draw",
+ G_CALLBACK (paint_pie_chart), window);
+ g_signal_connect (used_canvas, "draw",
+ G_CALLBACK (paint_used_legend), window);
+ g_signal_connect (free_canvas, "draw",
+ G_CALLBACK (paint_free_legend), window);
return GTK_WIDGET (table);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]