diff options
Diffstat (limited to 'src/statistics/gtk_statistics.c')
-rw-r--r-- | src/statistics/gtk_statistics.c | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/src/statistics/gtk_statistics.c b/src/statistics/gtk_statistics.c index c483794d..ab64ca56 100644 --- a/src/statistics/gtk_statistics.c +++ b/src/statistics/gtk_statistics.c | |||
@@ -124,6 +124,21 @@ static void gtk_statistics_finalize (GObject *object); | |||
124 | G_DEFINE_TYPE (GtkStatistics, gtk_statistics, GTK_TYPE_WIDGET) | 124 | G_DEFINE_TYPE (GtkStatistics, gtk_statistics, GTK_TYPE_WIDGET) |
125 | 125 | ||
126 | 126 | ||
127 | #if GTK_MAJOR_VERSION < 3 | ||
128 | static gboolean | ||
129 | statistics_expose (GtkWidget *statistics, | ||
130 | GdkEventExpose *event) | ||
131 | { | ||
132 | cairo_t *cr; | ||
133 | |||
134 | cr = gdk_cairo_create (statistics->window); | ||
135 | gtk_statistics_draw (statistics, cr); | ||
136 | cairo_destroy (cr); | ||
137 | return FALSE; | ||
138 | } | ||
139 | #endif | ||
140 | |||
141 | |||
127 | static void | 142 | static void |
128 | gtk_statistics_class_init (GtkStatisticsClass *class) | 143 | gtk_statistics_class_init (GtkStatisticsClass *class) |
129 | { | 144 | { |
@@ -134,7 +149,9 @@ gtk_statistics_class_init (GtkStatisticsClass *class) | |||
134 | widget_class = (GtkWidgetClass*) class; | 149 | widget_class = (GtkWidgetClass*) class; |
135 | 150 | ||
136 | gobject_class->finalize = gtk_statistics_finalize; | 151 | gobject_class->finalize = gtk_statistics_finalize; |
152 | #if GTK_MAJOR_VERSION >= 3 | ||
137 | widget_class->draw = gtk_statistics_draw; | 153 | widget_class->draw = gtk_statistics_draw; |
154 | #endif | ||
138 | 155 | ||
139 | g_type_class_add_private (class, sizeof (GtkStatisticsPrivate)); | 156 | g_type_class_add_private (class, sizeof (GtkStatisticsPrivate)); |
140 | } | 157 | } |
@@ -149,7 +166,9 @@ gtk_statistics_init (GtkStatistics *statistics) | |||
149 | GTK_TYPE_STATISTICS, | 166 | GTK_TYPE_STATISTICS, |
150 | GtkStatisticsPrivate); | 167 | GtkStatisticsPrivate); |
151 | priv = statistics->priv; | 168 | priv = statistics->priv; |
152 | 169 | #if GTK_MAJOR_VERSION < 3 | |
170 | g_signal_connect (statistics, "expose-event", G_CALLBACK (statistics_expose), statistics); | ||
171 | #endif | ||
153 | gtk_widget_set_has_window (GTK_WIDGET (statistics), FALSE); | 172 | gtk_widget_set_has_window (GTK_WIDGET (statistics), FALSE); |
154 | priv->values = NULL; | 173 | priv->values = NULL; |
155 | priv->num_values = 0; | 174 | priv->num_values = 0; |
@@ -302,6 +321,7 @@ gtk_statistics_draw (GtkWidget *widget, | |||
302 | double rx; | 321 | double rx; |
303 | double ry; | 322 | double ry; |
304 | unsigned int h; | 323 | unsigned int h; |
324 | GtkAllocation alloc; | ||
305 | 325 | ||
306 | /* collect basic data */ | 326 | /* collect basic data */ |
307 | xmin = UINT64_MAX; | 327 | xmin = UINT64_MAX; |
@@ -323,8 +343,9 @@ gtk_statistics_draw (GtkWidget *widget, | |||
323 | while (0 != (xmax % 10)) xmax++; | 343 | while (0 != (xmax % 10)) xmax++; |
324 | while (0 != (xmin % 10)) xmin--; | 344 | while (0 != (xmin % 10)) xmin--; |
325 | 345 | ||
326 | width = gtk_widget_get_allocated_width (widget); | 346 | gtk_widget_get_allocation (widget, &alloc); |
327 | height = gtk_widget_get_allocated_height (widget); | 347 | width = alloc.width; |
348 | height = alloc.height; | ||
328 | 349 | ||
329 | /* fill with black background */ | 350 | /* fill with black background */ |
330 | cairo_set_source_rgb(cr, 0.0, 0.0, 0.0); | 351 | cairo_set_source_rgb(cr, 0.0, 0.0, 0.0); |