combo problem



Hi, I have been trying using the function gtk_widget_set_style( ) to change the base colour on a gtkcombo box but I can't seen to get it to change colour. I have used the same function on a gtkentry box and it worked fine. Here is an example of what I am trying to do:

int main (int argc, char* argv[])
{
	GtkWidget* Main_Window;
	GtkWidget* fixed;
	GtkWidget* entry;
	GtkWidget* combo;
	GtkStyle* gtkstyle_normal_style;
	GtkStyle* gtkstyle_grey_base;

	gtk_set_locale();
	gtk_init(&argc, &argv);

	Main_Window = gtk_window_new(GTK_WINDOW_TOPLEVEL);

	fixed = gtk_fixed_new();
	gtk_widget_show(fixed);
	gtk_container_add(GTK_CONTAINER(Main_Window),fixed);

	entry = gtk_entry_new();
	gtk_fixed_put(GTK_FIXED(fixed),entry,5,5);
	gtk_widget_show(entry);

	combo = gtk_combo_new();
	gtk_widget_show(combo);
	gtk_fixed_put(GTK_FIXED(fixed),combo,5,40);
	gtk_widget_show(combo);

	gtk_widget_show(Main_Window);


	gtkstyle_normal_style = gtk_widget_get_default_style();
	gtkstyle_grey_base = gtk_style_copy(gtkstyle_normal_style);

	//change the base colour in gtkstyle_grey_base to grey
gtkstyle_grey_base->base[GTK_STATE_NORMAL] = gtkstyle_normal_style->bg[GTK_STATE_NORMAL]; gtkstyle_grey_base->base[GTK_STATE_ACTIVE] = gtkstyle_normal_style->bg[GTK_STATE_NORMAL]; gtkstyle_grey_base->base[GTK_STATE_PRELIGHT] = gtkstyle_normal_style->bg[GTK_STATE_NORMAL]; gtkstyle_grey_base->base[GTK_STATE_SELECTED] = gtkstyle_normal_style->bg[GTK_STATE_NORMAL]; gtkstyle_grey_base->base[GTK_STATE_INSENSITIVE] = gtkstyle_normal_style->bg[GTK_STATE_NORMAL];

	//works fine
	gtk_widget_set_style(entry,gtkstyle_grey_base);
	//does not seem to have any effect
	gtk_widget_set_style(combo,gtkstyle_grey_base);

	gtk_signal_connect(GTK_OBJECT(Main_Window),
					   "delete",
					   GTK_SIGNAL_FUNC(eventDelete),
					   NULL);
	gtk_signal_connect(GTK_OBJECT(Main_Window),
					   "destroy",
					   GTK_SIGNAL_FUNC(eventDestroy),
					   NULL);

	gtk_main();

	return(0);
}

Richard.




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