Re: set custom entry background?



On Mon, 16 Nov 2015, Stefan Salewski wrote:

On Sun, 2015-11-15 at 14:32 -0500, Allin Cottrell wrote:
I'm trying to set a custom background for a GtkEntry

I think you have to use CSS -- unfortunately that is some work and I can
not provide an example yet. See

https://developer.gnome.org/gtk3/stable/GtkWidget.html#gtk-widget-overri
de-background-color

Thanks. I've tried the CSS approach: that is, create a custom GtkCssProvider and feed it a suitable snippet of CSS inline. This works to change the background color OK. But step 2 is to revert the background color to normal once the alert is over, and I couldn't figure that out, because I couldn't find a way of determining what "normal" is.

There's an API "on the books" to get the original background color (which in principle would allow you to save it, and re-apply it later) but it doesn't work in current gtk 3 (now it always just gives you an all-zero GdkRGBA).

I've studied the doc for gtk_widget_override_background_color(), and in the code I posted I was trying to implement the suggestion there to "use Cairo to draw a specific color, regardless of the CSS style," in the hope that this would revert itself automatically the next time a selection had to be drawn. But at this point I don't know if that would work since I can't get the background to change in the first place, using cairo plus gtk_render_background().

--
Allin Cottrell
Department of Economics
Wake Forest University


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]