From 4b367fc447f68e597bb2d7eb6a1bab210b3f8844 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Tue, 29 Aug 2017 14:26:34 -0400 Subject: pull setting the curve in to its own function --- ggamma.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/ggamma.c b/ggamma.c index 79c3f02..a30c9b7 100644 --- a/ggamma.c +++ b/ggamma.c @@ -33,6 +33,14 @@ void curve_edited(GtkWidget *raw_curve, UNUSED GdkEvent *event, struct gamma_cha gamma->flush(); } +void curve_set(GtkGammaCurve *curve, struct gamma_channel *gamma) { + gfloat vec[gamma->size]; + for (int i = 0; i < gamma->size; i++) + vec[i] = gamma->data[i] * gamma->size / 65535.0; + gtk_curve_set_vector(GTK_CURVE(curve->curve), + gamma->size, vec); +} + GtkWidget *curve_new(struct gamma_channel *gamma) { GtkWidget *curve = gtk_gamma_curve_new(); GtkWidget *raw_curve = GTK_GAMMA_CURVE(curve)->curve; @@ -42,16 +50,11 @@ GtkWidget *curve_new(struct gamma_channel *gamma) { * So there's no point in making it awkwardly tall to get the * extra precision; just make it a square, we're not really * loosing anything. */ - gtk_curve_set_range(GTK_CURVE(raw_curve), /* x */0, gamma->size-1, /* y */0, gamma->size-1); - gfloat vec[gamma->size]; - for (int i = 0; i < gamma->size; i++) - vec[i] = gamma->data[i] * gamma->size / 65535.0; - gtk_curve_set_vector(GTK_CURVE(raw_curve), - gamma->size, vec); + curve_set(GTK_GAMMA_CURVE(curve), gamma); // TODO: find a better signal g_signal_connect(raw_curve, "event-after", G_CALLBACK(curve_edited), gamma); -- cgit v1.2.3-2-g168b