summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2017-08-29 14:26:34 -0400
committerLuke Shumaker <lukeshu@lukeshu.com>2017-08-29 14:26:34 -0400
commit4b367fc447f68e597bb2d7eb6a1bab210b3f8844 (patch)
tree4097e0abc0b5cdebfd6c0c216a6f95dc7fa45c0e
parent06f6f74dc69d461d7bc6e7bf9d03bc40d5e0c2c5 (diff)
pull setting the curve in to its own function
-rw-r--r--ggamma.c15
1 files 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);