GNOME Bugzilla – Bug 110605
Gtk::Widget::modify_fg/bg can't take a 0
Last modified: 2004-12-22 21:47:04 UTC
According to the GTK+ (and the gtkmm) documentation, one should pass a 0 to modify_fg/bg for the Gdk::Color parameter to undo the effects of previous calls to the methods. However, the Gdk::Color parameter is wrapped as a reference, not a pointer, rendering passing of zero impossible. I guess there is some common pattern in gtkmm for solving this problem.
Well spotted. We would usually wrap this as hand-coded unset_fg() and unset_bg() methods. A patch against gtkmm 2.4 would be very helpful. In the meantime, you can use the GTK+ C function as a workaround.
I've got one cooked now. I just need to add documentation. Can I grab the current documentation for modify_fg in Doxygen format from somewhere? I need to modify it to strip out the "or [pass] 0 to undo the effect of previous calls to modify_fg()" and mention unset instead. Also, I've added unset_* methods for fg, bg, text, base and font, but not for modify_bg_pixmap since I'm a little unsure of where that method comes from. It is hand coded, not wrapped, and I can't find anything like it in GTK+. Any ideas? > In the meantime, you can use the GTK+ C function as a workaround. I'm glad C++ is so compatible with C. Stroustrup knew what he was doing.
> Can I grab the current documentation for modify_fg in Doxygen format. Yes, using similar doxygen comments would be fine. > Also, I've added unset_* methods for fg, bg, text, base and font OK, as long as you are sure they can take 0 too. > but not for modify_bg_pixmap since I'm a little unsure of where that method comes from. Google gave me this: http://mail.gnome.org/archives/cvs-commits-list/2002- December/msg04868.html But it doesn't really mean much to me. Putting that in a doxygen comment would be nice.
Attaching a patch that adds the unset_blabla methods and changes the documentation for modify_blabla to mention this (and updates the ChangeLog). I haven't touched modify_bg_pixmap since I still don't quite understand how it is supposed to work (after having grep-researched it for a while; GtkStyle is still black magic as far as I am concerned). Perhaps we could persuade Daniel to look at it?
Created attachment 15752 [details] [review] Patch that adds unset_* and custom documentation to modify_*
That looks great. Please apply to gtkmm 2.4. Please do add a "//TODO: Document this" comment next to modify_bg_pixmap().
OK, done.
Thanks again, Ole.