[gnome-power-manager] Fix compile with expose -> draw change



commit cd9255c8742703b544a297ca76884c14f08d03e3
Author: Richard Hughes <richard hughsie com>
Date:   Mon Oct 4 20:40:06 2010 +0100

    Fix compile with expose -> draw change

 src/gpm-graph-widget.c |   47 +++++++++++------------------------------------
 1 files changed, 11 insertions(+), 36 deletions(-)
---
diff --git a/src/gpm-graph-widget.c b/src/gpm-graph-widget.c
index c81ac2d..499070f 100644
--- a/src/gpm-graph-widget.c
+++ b/src/gpm-graph-widget.c
@@ -67,7 +67,7 @@ struct GpmGraphWidgetPrivate
 	GPtrArray		*plot_list;
 };
 
-static gboolean gpm_graph_widget_expose (GtkWidget *graph, GdkEventExpose *event);
+static gboolean gpm_graph_widget_draw (GtkWidget *widget, cairo_t *cr);
 static void	gpm_graph_widget_finalize (GObject *object);
 
 enum
@@ -231,7 +231,7 @@ gpm_graph_widget_class_init (GpmGraphWidgetClass *class)
 	GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
 	GObjectClass *object_class = G_OBJECT_CLASS (class);
 
-	widget_class->expose_event = gpm_graph_widget_expose;
+	widget_class->draw = gpm_graph_widget_draw;
 	object_class->get_property = up_graph_get_property;
 	object_class->set_property = up_graph_set_property;
 	object_class->finalize = gpm_graph_widget_finalize;
@@ -1062,14 +1062,14 @@ gpm_graph_widget_legend_calculate_size (GpmGraphWidget *graph, cairo_t *cr,
 }
 
 /**
- * gpm_graph_widget_draw_graph:
+ * gpm_graph_widget_draw:
  * @graph: This class instance
- * @cr: Cairo drawing context
+ * @event: The expose event
  *
- * Draw the complete graph, with the box, the grid, the labels and the line.
+ * Just repaint the entire graph widget on expose.
  **/
-static void
-gpm_graph_widget_draw_graph (GtkWidget *graph_widget, cairo_t *cr)
+static gboolean
+gpm_graph_widget_draw (GtkWidget *widget, cairo_t *cr)
 {
 	GtkAllocation allocation;
 	gint legend_x = 0;
@@ -1079,9 +1079,9 @@ gpm_graph_widget_draw_graph (GtkWidget *graph_widget, cairo_t *cr)
 	gfloat data_x;
 	gfloat data_y;
 
-	GpmGraphWidget *graph = (GpmGraphWidget*) graph_widget;
-	g_return_if_fail (graph != NULL);
-	g_return_if_fail (GPM_IS_GRAPH_WIDGET (graph));
+	GpmGraphWidget *graph = (GpmGraphWidget*) widget;
+	g_return_val_if_fail (graph != NULL, FALSE);
+	g_return_val_if_fail (GPM_IS_GRAPH_WIDGET (graph), FALSE);
 
 	gpm_graph_widget_legend_calculate_size (graph, cr, &legend_width, &legend_height);
 	cairo_save (cr);
@@ -1095,7 +1095,7 @@ gpm_graph_widget_draw_graph (GtkWidget *graph_widget, cairo_t *cr)
 	graph->priv->box_x = gpm_graph_widget_get_y_label_max_width (graph, cr) + 10;
 	graph->priv->box_y = 5;
 
-	gtk_widget_get_allocation (graph_widget, &allocation);
+	gtk_widget_get_allocation (widget, &allocation);
 	graph->priv->box_height = allocation.height - (20 + graph->priv->box_y);
 
 	/* make size adjustment for legend */
@@ -1128,31 +1128,6 @@ gpm_graph_widget_draw_graph (GtkWidget *graph_widget, cairo_t *cr)
 		gpm_graph_widget_draw_legend (graph, legend_x, legend_y, legend_width, legend_height);
 
 	cairo_restore (cr);
-}
-
-/**
- * gpm_graph_widget_expose:
- * @graph: This class instance
- * @event: The expose event
- *
- * Just repaint the entire graph widget on expose.
- **/
-static gboolean
-gpm_graph_widget_expose (GtkWidget *graph, GdkEventExpose *event)
-{
-	cairo_t *cr;
-
-	/* get a cairo_t */
-	cr = gdk_cairo_create (gtk_widget_get_window (graph));
-	cairo_rectangle (cr,
-			 event->area.x, event->area.y,
-			 event->area.width, event->area.height);
-	cairo_clip (cr);
-	((GpmGraphWidget *)graph)->priv->cr = cr;
-
-	gpm_graph_widget_draw_graph (graph, cr);
-
-	cairo_destroy (cr);
 	return FALSE;
 }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]