|
#include <gtk/gtk.h>
int main( int argc, char *argv[] )
{
GtkWidget *window;
GtkWidget *button;
GdkColor color;
GtkRcStyle *rc_style;
gtk_init (&argc, &argv);
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(GTK_WINDOW(window), "test");
gtk_window_set_policy(GTK_WINDOW(window), FALSE, FALSE, FALSE);
button = gtk_button_new_with_label(" ");
gtk_container_add(GTK_CONTAINER(window), button);
gdk_color_parse("red", &color);
rc_style = gtk_rc_style_new();
rc_style->fg[GTK_STATE_NORMAL] = color;
rc_style->color_flags[GTK_STATE_NORMAL] |= GTK_RC_FG;
gtk_widget_modify_style(GTK_WIDGET(button), rc_style);
gtk_rc_style_unref(rc_style);
gtk_widget_show(button);
gtk_widget_show(window);
gtk_main ();
return 0;
}
简单写了点儿测试代码,1.2里是可以这样设置按钮的颜色的,但是2里不起作用,网上搜了一下,发现都是这么说的,可是我这里就是没效果,不知道为啥,有人知道吗? |
|