Re: Background image isn't persisting after gtk_container_remove/add
- From: David Nečas (Yeti) <yeti physics muni cz>
- To: gtk-list gnome org
- Subject: Re: Background image isn't persisting after gtk_container_remove/add
- Date: Sat, 7 Apr 2007 17:05:17 +0200
On Fri, Apr 06, 2007 at 03:17:41PM -0700, konton wrote:
> My program sets the background image of widgets from a pixmap with
> style->bg_pixmap[GTK_STATE_NORAL]. The background image shows up
> correctly when I draw the window. However, if I remove any widget
> with a background pixmap style with g_object_ref() followed by
> gtk_container_remove(), and then I re-add the widget to the container,
> the background image does not show up. All I get is a grey background
> on the widget when I re-add it.
>
> I think that gtk_container_remove() is destroying the style I've set
> because it also unrefs my background image pixmap.
Style is associated with a screen. Therefore style is
attached to the widget when it is realized, i.e. when its
screen is known (consequently its visual and colormap are
known, etc.). Conversely, when the widget is removed from
the container, it is unrealized and its style information is
lost.
> Can I stop this behavior? I'd like to be able to remove a widget and
> re-add it without having to mess with the style again. I think I can
> work around this issue by ref'ing the background pixmap before
> removing the widget and then re-applying the style after re-adding the
> widget to the container.
Perform style modifications in "realize". Generally the
pixmap you created for one screen may be unusable when the
widget is realized the next time, though in practice you
probably know this cannot happen and therefore you can
reference and keep the pixmap.
Yeti
--
http://gwyddion.net/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]