widget colors/fonts



Hi,

I think we have discussed convenience routines for modifying widget
styles, but never proposed an API. So here is a proposal:

void gtk_widget_set_color (GtkWidget *widget,
                           GtkRcFlags component,
                           GtkStateType state,
                           GdkColor  *color);

void gtk_widget_set_font  (GtkWidget            *widget,
                           PangoFontDescription *desc);

These both modify a GtkRcStyle which is stored on the widget as object
data. If it's the same GtkRcStyle stored by gtk_widget_modify_style()
then the fact that that GtkRcStyle gets modified is slightly
surprising; on the other hand, if it isn't the same GtkRcStyle then
combining the above calls with modify_style could result in surprising
behavior as well. To me it seems cleanest to modify the "gtk-rc-style"
style, or maybe have gtk_widget_modify_style() copy the passed-in
style instead of just ref'ing it.

I am not a huge fan of using GtkRcFlags here, mostly because
GtkRcFlags isn't a good name for the enum in this context.
If I could think of a good name in this context I'd advocate creating
another enum for this purpose.

The color arg is of course an unallocated color.

Sample usage:

 gtk_widget_set_color (label, GTK_RC_FG, GTK_STATE_NORMAL, color);
 gtk_widget_set_font (label, &desc);

So, suggestions on enhancing the API welcome.

Havoc




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