Re: rewrite question:how to attach a pixmap to aGtkWindowas the background




"Donna S. Martin" <donna@omartin.com> writes:

> > Sorry I couldn't be of more help. Maybe someone else has seen this
> > flicker effect before.
> >
> > -Matt
> 
> My guess is the widgets are setting the background attribute
> as well.  When realized, they invoke gtk_style_set_background which in
> turn invokes gdk_window_set_background and
> gdk_window_set_back_pixmap.  But it's only a guess...
> 
> Is there a reason it can't be done with styles, rather than
> going to the GDK level?
>   How about
> 
>  GtkStyle *new_style;
> 
> new_style = gtk_style_copy( gtk_widget_get_style(window1) );
> new_style->bg_pixmap[GTK_STATE_NORMAL] =
>                      gdk_pixmap_create_from_xpm(window1->window,&mask,
>                       &new_style->bg[GTK_STATE_NORMAL],"./BACKGROUND.XPM");
> gtk_set_style( window1, new_style );
> 
> Or have I misunderstood? (Always possible!)

This is another valid approach. However, since a particular
theme engine might not respect the background pixmap, instead
of copying the widget's current style, I would create a
new style from scratch:

  new_style = gtk_style_new ();

  new_style->bg_pixmap[GTK_STATE_NORMAL] =
                       gdk_pixmap_create_from_xpm(window1->window,&mask,
                       &new_style->bg[GTK_STATE_NORMAL],"./BACKGROUND.XPM");
  gtk_set_style( window1, new_style );

  gtk_style_unef (new_style);

Don't forget to unref the new style, or it will leak.

Regards,
                                        Owen
 



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