GNOME Bugzilla – Bug 356032
add support for white-on-black dropshadow to gtk_label
Last modified: 2011-06-01 03:59:46 UTC
wanted: an easy way to have a gtklabel display in 'dropshadow' mode (ie: white text with a black dropshadow behind it). this is done by using the gdkpango 'embossed' attribute with emboss-color set to "black". the dropshadow attribute can stack with underlines from mnemonics or with markup but cannot stack with a user-supplied attribute list (since the way gtklabel currently works, no copy of made of the list and if we modified it, the user would see our modifications too). here's some code from a first pass at implementing it. i've tested a few cases and they seem to work. the ultimate goal is to be able to use this code inside of gnome applets which display onto a transparent panel. libgnome-applet currently contains code to find all the labels in the heirarchy and call set_use_dropshadow on the panel background type changing. there is a problem, though: new labels added to the applet aren't automatically set to have a dropshadow (unless the user changes the background type after the label is added). this is all sort of very hacky. i'm interested in hearing alternate ideas for implementing this -- including some help from the theme engine (which, could for example, look at some property of the toplevel widget when it goes to render the text and decide to render with a dropshadow). i'm attaching this gtklabel code only as a point at which to start discussion.
Created attachment 72826 [details] [review] .
any word on this? seems silly to have merged the gdk part of this patch if gtk isn't going to use it....
Created attachment 83017 [details] [review] same thing, but using gtk widget style after talking to matthias on irc we decided that the dropshadow is really more of a theme style thing than something that should be directly exposed to an application via an API like in my first patch. this patch does exactly that -- it adds a "draw-dropshadow" style property. a bit of shuffling with respect to stacking order has occured here: in the old code, if there was a drop shadow user pango attrs would be ignored in the new code, if there are user pango attrs then the drop shadow is ignored random: if i write "GtkLabel::draw-dropshadow = TRUE" in my gtkrc it doesn't work. i have to write "= 1". i don't know why. please help?
TRUE/FALSE are not supported as boolean indicator in RC files, you have to use 1/0. I couldn't find this anywhere in the docs though, so it might be a good idea to add it. That, or write a patch to support it...
I have played a bit with this. I don't really like how it hardwires white-on-black regardless of the state. There are no really good solutions at this time, though. Using fg-on-black would be a little better, I think. If somebody turns on dropshadows in a style, he can pick a light color for fg, too. Eventually, we could add a style property to set the color of the shadow; but that won't really solve the state problem. Really, all style properties that select drawing colors need to be array-valued and allow to override colors per-state. Another thing I don't like is that you override the embossing for insensitive labels. I think you should use gtk_paint_layout for insensitive labels, too.
*** This bug has been marked as a duplicate of bug 649314 ***