Re: Background color problem
- From: Vlad Volodin <vest 84 gmail com>
- To: Chuck Crisler <charles crisler comcast net>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: Background color problem
- Date: Tue, 17 Mar 2009 00:44:55 +0300
No guys, that doesn't help.
Well my code is the next one:
static GObject* quod_board_widget_constructor(GType type, guint
n_construct_properties, GObjectConstructParam *construct_properties)
{
GObject *obj;
QuodBoardWidgetClass *klass;
GObjectClass *parent_class;
QuodBoardWidget *self;
g_debug("quod_board_widget_constructor");
self = QUOD_BOARD_WIDGET(obj);
{
GError* err = NULL;
gtk_widget_realize(GTK_WIDGET(self));
GtkStyle* default_style = gtk_widget_get_style (GTK_WIDGET(self));
GdkColor* bg = &default_style->bg[GTK_STATE_NORMAL];
ClutterColor stage_color = { bg->red / 0xFF, bg->green /
0xFF, bg->blue / 0xFF, 0xF0 };
ClutterActor *stage = gtk_clutter_embed_get_stage
(GTK_CLUTTER_EMBED (self));
g_debug("quod_board_widget_constructor: %x %x %x %x", bg->red,
bg->green, bg->blue, bg->pixel);
clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color);
}
return obj;
}
static GObject* quod_main_window_constructor(GType type, guint
n_construct_properties, GObjectConstructParam *construct_properties)
{
GObject *obj;
QuodMainWindowClass *klass;
GObjectClass *parent_class;
QuodMainWindow *self;
g_debug("quod_main_window_constructor");
klass = QUOD_MAIN_WINDOW_CLASS(g_type_class_peek(QUOD_TYPE_MAIN_WINDOW));
parent_class = G_OBJECT_CLASS(g_type_class_peek_parent(klass));
obj = parent_class->constructor(type, n_construct_properties,
construct_properties);
self = QUOD_MAIN_WINDOW(obj);
{
GError* err = NULL;
gtk_window_set_title((GtkWindow*) self, "Gnome Quod");
gtk_window_set_default_size((GtkWindow*) self,
MAIN_WINDOW_DEFAULT_WIDTH, MAIN_WINDOW_DEFAULT_HEIGHT);
g_signal_connect((GtkObject*) self, "destroy", (GCallback)
_gtk_main_quit_gtk_object_destroy, NULL);
gtk_window_set_icon_from_file((GtkWindow*) self, GNOME_ICONDIR
"/quod.png", &err);
// Create all used widgets and attach possible signals
quod_main_window_create_widgets(self);
GtkStyle* default_style = gtk_widget_get_style (GTK_WIDGET(self));
GdkColor* bg = &default_style->bg[GTK_STATE_NORMAL];
g_debug("quod_main_window_constructor (before show):%x %x %x
%x", bg->red, bg->green, bg->blue, bg->pixel);
gtk_widget_show_all((GtkWidget*) self);
default_style = gtk_widget_get_style (GTK_WIDGET(self));
bg = &default_style->bg[GTK_STATE_NORMAL];
g_debug("quod_main_window_constructor (after show):%x %x %x
%x", bg->red, bg->green, bg->blue, bg->pixel);
}
return obj;
}
** (./gnome-quod:16210): DEBUG: quod_main_window_construct
** (./gnome-quod:16210): DEBUG: quod_main_window_class_init
** (./gnome-quod:16210): DEBUG: quod_main_window_constructor
** (./gnome-quod:16210): DEBUG: quod_main_window_init
** (./gnome-quod:16210): DEBUG: quod_main_window_construct
** (./gnome-quod:16210): DEBUG: quod_main_window_construct
** (./gnome-quod:16210): DEBUG: quod_board_widget_new
** (./gnome-quod:16210): DEBUG: quod_main_window_construct
** (./gnome-quod:16210): DEBUG: quod_board_widget_class_init
** (./gnome-quod:16210): DEBUG: quod_board_widget_constructor
** (./gnome-quod:16210): DEBUG: quod_board_widget_init
(./gnome-quod:16210): Gtk-CRITICAL **: gtk_widget_realize: assertion
`GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(without realize, this error doesn't occur)
** (./gnome-quod:16210): DEBUG: quod_board_widget_constructor: dcdc dada d5d5 0
** (./gnome-quod:16210): DEBUG: quod_main_window_constructor (before
show):dcdc dada d5d5 0
** (./gnome-quod:16210): DEBUG: quod_main_window_constructor (after
show):b0b0 b8b8 f1f1 b0b8f1
** (./gnome-quod:16210): DEBUG: quod_main_window_finalize (and other
destructions, when I press the close button)
http://img10.imageshack.us/img10/5275/72303372.png
here you can see the gray box, it is colored from ClutterColor stage_color.
I wish, you can help me with the next question: When is GtkStyle
(compare before show and after show) applied to my windows/ widgets
etc. I can't get correct (blue, as in screen) colors, instead of them
I got gray: #dcdad5. I don't have such colors in my themas. Are they
default. (they are equal to gtk_wiget_get_default_style)
Thank you all again :)
2009/3/17 Chuck Crisler <charles crisler comcast net>:
Rather than showing the window, call realize(). That does everything
that show() does EXCEPT make the window visible. Then you should be able
to get the background color. X doesn't send the communication to the
server until there is idle time OR you force it (by calling realize()).
On Tue, 2009-03-17 at 00:11 +0300, Vlad Volodin wrote:
Sorry, Brian,
but as I said before, I also can't get the correct GtkWindow
background color before it is shown. why?
(thank you for your reply)
2009/3/16 Brian J. Tarricone <bjt23 cornell edu>:
Vlad Volodin wrote:
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:
You really just can't use this method at all. ÂSome widgets won't have a
color as a background; they'll have a pixmap. ÂYou won't be able to paint it
using this method.
   Â-brian
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]