GNOME Bugzilla – Bug 675579
Gdk Color override should support red/green/blue_float properties
Last modified: 2012-06-05 08:39:46 UTC
PyGtk/Gdk used to have properties for accessing RGB values on Color objects as individual floats. When working with colors in the gnome stack things can get tricky due to libs having different implementations of a color object (Gtk/Gdk, Clutter, Cairo, Cogl). With Gtk it can be particularly odd to have client code which hard codes things like "color.red / 65535.0" in order to use it with another gnome library. While I understand these libs have potentially different requirements or even need to maintain independence from glib, converting to/from the different libs and color objects should be easier. The float accessors definitely helped this as it allowed client code to be written without having to know implementation detail. Furthermore, it would be nice if there were methods on the color classes which allowed for direct conversion to one another.
Created attachment 213935 [details] [review] Gdk Color override should support red/green/blue_float properties Added red_float, green_float, and blue_float properties to Color. Also added Color.from_floats, RGBA.to_color, and RGBA.from_color.
Created attachment 213936 [details] [review] Proper version with __iter__
Thanks! Applied with a few whitespace fixes.
Forgot to close the bug back then.