+
+Glib::RefPtr<Gdk::Pixbuf>
+MotionFeedback::render_pixbuf (int size)
+{
+ Glib::RefPtr<Gdk::Pixbuf> pixbuf;
+ char path[32];
+ int fd;
+
+ snprintf (path, sizeof (path), "/tmp/mfimg%dXXXXXX", size);
+
+ if ((fd = mkstemp (path)) < 0) {
+ return pixbuf;
+ }
+
+ GdkColor col2 = {0,0,0,0};
+ GdkColor col3 = {0,0,0,0};
+ Gdk::Color base ("#b9feff");
+ GdkColor dark;
+ GdkColor bright;
+ ProlooksHSV* hsv;
+
+ hsv = prolooks_hsv_new_for_gdk_color (base.gobj());
+ bright = (prolooks_hsv_to_gdk_color (hsv, &col2), col2);
+ prolooks_hsv_set_saturation (hsv, 0.66);
+ prolooks_hsv_set_value (hsv, 0.67);
+ dark = (prolooks_hsv_to_gdk_color (hsv, &col3), col3);
+
+ cairo_surface_t *surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, size * 64, size);
+ cairo_t* cr = cairo_create (surface);
+
+ for (int i = 0; i < 64; ++i) {
+ cairo_save (cr);
+ core_draw (cr, i, size, 20, size*i, 0, &bright, &dark);
+ cairo_restore (cr);
+ }
+
+ if (cairo_surface_write_to_png (surface, path) != CAIRO_STATUS_SUCCESS) {
+ std::cerr << "could not save image set to " << path << std::endl;
+ return pixbuf;
+ }
+
+ close (fd);
+
+ cairo_destroy (cr);
+ cairo_surface_destroy (surface);
+
+ try {
+ pixbuf = Gdk::Pixbuf::create_from_file (path);
+ } catch (const Gdk::PixbufError &e) {
+ std::cerr << "Caught PixbufError: " << e.what() << std::endl;
+ unlink (path);
+ throw;
+ } catch (...) {
+ unlink (path);
+ g_message("Caught ... ");
+ throw;
+ }
+
+ unlink (path);
+
+ return pixbuf;
+}