GNOME Bugzilla – Bug 345828
color palette optimization
Last modified: 2014-03-22 22:24:06 UTC
This is the color palette creation method used in xchat-gnome. I had multiple requests from people wishing to use this method in other things (vte, etc), so it seems like something that could be useful for GTK+.
Created attachment 67950 [details] [review] patch against HEAD My first shot at integrating this into GTK+. I chose to do the API this way because any particular application is probably only interested in a subset of the colors (for example, vte only wants those colors which can be specified using ANSI codes).
minor nitpicking on the code style: if (condition) statement; else statement; are ugly, error-prone and possibly other five or six other things; GLib already has a CLAMP() macro, no need to reinvent the wheel; I'd like a URL in the comment for the transformations, so that they can be checked, especially wrt. the magic numbers; + points[0][0] = color_regions[color][0]; points[0][1] = color_regions[color][2]; points[0][2] = color_regions[color][4]; + points[1][0] = color_regions[color][0]; points[1][1] = color_regions[color][2]; points[1][2] = color_regions[color][5]; ... probably that wants a macro #defined and #undefined in the function body and a wee bit shorter lines (~90/100); +GdkColor gtk_style_render_foreground_color (GtkStyle *style, + GtkStateType state, + GtkPaletteColor color); probably you meant to return GdkColor* - but, in any case, this should probably return a boolean (conversion successful) and have a pointer to the returned GdkColor as an argument, like this: gboolean gtk_style_render_foreground_color (GtkStyle *style, GtkStateType state, GtkPaletteColor palette_color, GdkColor *color);
we have a new colorchooser now, and it has new palettes