Background color problem



Hello everybody,

I'm using libclutter-gtk (with GtkClutterEmbed widget), where I want
to display some graphics. If somebody doesn't know it, I'll describe
it a bit. It is derived from GtkWidget. Then it uses it's own canvas.
The canvas is white, and it doesn't have some kind of transparency.
So, as I thought, I decided to fill it's background with color, got
from it's GtkStyle. After some experiments I realized, that widgets
(main window, container and GtkClutterEmbed) don't have needed color:

quod_main_window_create_widgets(self); // here I create all widgets

GtkStyle* default_style = gtk_widget_get_style (GTK_WIDGET(self));
GdkColor* bg = &default_style->bg[GTK_STATE_NORMAL];
g_debug("%x %x %x %x", bg->red, bg->green, bg->blue, bg->pixel);

gtk_widget_show_all((GtkWidget*) self);

** (./dist/Debug/GNU-Linux-x86/gnome-quod:2349): DEBUG: dcdc dada d5d5 0

if I change the code in such way:
quod_main_window_create_widgets(self); // here I create all widgets

gtk_widget_show_all((GtkWidget*) self);

GtkStyle* default_style = gtk_widget_get_style (GTK_WIDGET(self));
GdkColor* bg = &default_style->bg[GTK_STATE_NORMAL];
g_debug("%x %x %x %x", bg->red, bg->green, bg->blue, bg->pixel);

** (./dist/Debug/GNU-Linux-x86/gnome-quod:3088): DEBUG: b0b0 b8b8 f1f1 b0b8f1

Can you help me with this?
I don't know how to change the color of my widget, because I've
created as a separate class, derived from GtkClutterEmbed. And when I
use the next construction in
static GObject* quod_board_widget_constructor(GType type, guint
n_construct_properties, GObjectConstructParam *construct_properties)
....
GdkColor* bg = &default_style->bg[GTK_STATE_NORMAL]; // got in the same way
g_debug("%x %x %x %x", bg->red, bg->green, bg->blue, bg->pixel);  //
again: dcdc dada d5d5 0 and not #b0b8f1
...

Now, I'm thinking how can I get the correct (needed) color in my
widget constructor. Or, should I connect the signal "expose-event" to
my widget, where I will recheck widget's color and use it as
background.
What should I use, when I want to redraw my widgets when user
dynamically changes GTK theme?

Thank you in advance,
Vlad Volodin



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