[maemo-developers] Something strange when setting the color of the widget

From: LIU Chun Hung hungsiu at ust.hk
Date: Wed Mar 19 18:17:58 EET 2008
Hi,

I want to create three buttons with different colors. But three buttons
are with the same colors at the final. What's wrong? Anybody help? My
program code is as below:

GtkWidget *bn1, *bn2, *bn3;
GdkColor red_color, green_color, blue_color;
GtkStyle *bn1_style, *bn2_style, *bn3_style;

bn1 = gtk_button_new();
bn2 = gtk_button_new();
bn3 = gtk_button_new();

red_color.red = 65535;
red_color.green = 0;
red_color.blue = 0;
green_color.red = 0;
green_color.green = 65535;
green_color.blue = 0;
blue_color.red = 0;
blue_color.green = 0;
blue_color.blue = 65535;

bn1_style = gtk_widget_get_style(bn1);
bn1_style->bg[GTK_STATE_NORMAL] = red_color;
gtk_widget_set_style(bn1, bn1_style);
bn2_style = gtk_widget_get_style(bn2);
bn2_style->bg[GTK_STATE_NORMAL] = green_color;
gtk_widget_set_style(bn2, bn2_style);
bn3_style = gtk_widget_get_style(bn3);
bn3_style->bg[GTK_STATE_NORMAL] = blue_color;
gtk_widget_set_style(bn3, bn3_style);

Three buttons are in blue at the final.

Regards,
Hung


More information about the maemo-developers mailing list