and now for something from the school of pure evil (setting a background on a GtkTextView)

This is something that comes up from time to time, someone wants to set some attractive background on a GtkTextView. Well, unfortunately for you, the theme engine isn't able to help you here because GtkTextView never calls gtk_paint_box() or friends. Still, today I stared at the code for a bit and came up with a particularly hacky solution: see for yourself. You have to handle everything yourself, resizing (hook into size-allocate), scaling whatever is needed. You could probably cheat though and call something like gtk_paint_box() and then let the theme engine do that bit of the work for you… I've not tried.

Just to prove it works:


This depends on what is basically an implementation detail of the widget, and I make no promises that it will continue working in the future. With that warning in mind, do what you will with the code.

P.S. the background image is a photo of the art in my hotel room. If I was Google, I'd totally sue.

Leave a Reply

Your email address will not be published. Required fields are marked *

Creative Commons Attribution-ShareAlike 2.5 Australia
This work by Danielle Madeley is licensed under a Creative Commons Attribution-ShareAlike 2.5 Australia.