Re: [gtk-list] Re: Dynamic Style/Color change - I don't find the solution...
- From: Georg Greve <greve fusebox hanse de>
- Cc: timj gtk org
- Subject: Re: [gtk-list] Re: Dynamic Style/Color change - I don't find the solution...
- Date: Tue, 7 Jul 1998 11:24:50 GMT
-----BEGIN PGP SIGNED MESSAGE-----
Hi Tim !
Tim Janik <timj@gtk.org> writes:
> On Mon, 6 Jul 1998, Georg Greve wrote:
> could you provide a small example snippet?
> your approach seems to be correct, and you should really not get a segfault
> with this.
Sure. What I do during initialization is:
GdkColormap* cmap = gdk_colormap_get_system();
and (in a loop for each object I want to be changeable later):
myobject->style = gtk_style_copy(gtk_rc_get_style(window));
gtk_widget_set_style(myobject->widget, myobject->style);
(myobject is a class with objects GtkWidget* widget and GtkStyle* style)
window is the main window widget and this part works just fine so far
(the style settings for the main window are being used for the
objects).
During the change-phase I do:
GdkColor normal = {0,color triplet};
GdkColor plight = {0,color triplet};
gdk_color_alloc (cmap, &normal);
gdk_color_alloc (cmap, &plight);
/*
I tried gtk_style_detach and so on here
*/
myobject->style->bg[GTK_STATE_NORMAL].red = normal.red;
myobject->style->bg[GTK_STATE_NORMAL].green = normal.green;
myobject->style->bg[GTK_STATE_NORMAL].blue = normal.blue;
myobject->style->bg[GTK_STATE_PRELIGHT].red = plight.red;
myobject->style->bg[GTK_STATE_PRELIGHT].green = plight.green;
myobject->style->bg[GTK_STATE_PRELIGHT].blue = plight.blue;
/*
I tried widget_realize and everything else here
*/
if ( myobject->pixels[0] != 0 && myobject->pixels[1] != 0 )
gdk_colors_free(cmap, myobject->pixels, 2, 0);
myobject->pixels[0] = normal.pixel;
myobject->pixels[1] = plight.pixel;
This should (in my eyes) allocate the new colors and free the ones
that it had been changed to on the last run...
So what is missing there ??? I am really clueless by now (which
doesn't mean I'll stop trying... :-) ).
Later,
Georg
- --
Georg C. F. Greve <greve@fusebox.hanse.de>
http://porter.desy.de/~greve/ - ICQ#10016966
"People who fight may lose. People who do not
fight have already lost." -- Bertolt Brecht
-----BEGIN PGP SIGNATURE-----
Version: 2.6.3i
Charset: noconv
Comment: Processed
iQCVAwUBNaIFgVZXgZXDxqJtAQFb3gP9ETIfBh31brIVfybgasirdFtZoDBzFX0I
vGDRmdHIXCqAt38zKbvdq9FW61ms2JOQC2q2RH6tFJM7iiiavjngjLwDMOwoOXNa
RqdF/6QbLrAWgRO3rn1Mqr486HCZaUnUKiza3K1Vmaa9mGlzJJAFVyheurtmhLmq
UI3o0KXechM=
=dlhj
-----END PGP SIGNATURE-----
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]