Re: [gtk-list] GDK, and `gdk_pixmap_create_from_xpm_d': NULL window



Nancy MAZUR wrote:
> 
> Hi,
> 
> I'm quite desperate here, having first tried to live with imlib,
> I now tried another approach to my problem, inspired from Harlow's
> book, chapter about sprites and animation.
> 
> My goal is simple: draw some background image, and on top of it
> another image having some non-zero mask. Well, I can't even test
> my code, because as soon as I run it, the message:
> 
> Gdk-WARNING **: Creating pixmap from xpm with NULL window and colormap
> Segmentation fault
> 
> I assume the source of this problem is my call to:
> GdkPixmap grid  = gdk_pixmap_create_from_xpm_d ( widget->window,
>                         &gridmask, &color, white60 );
> 
> The widget is a drawing area, but why is its window NULL?
> When is a widget's window initialised?
> Or am I completely wrong, does the problem reside somewhere else?

The X windows are only created when the widget is "realized".

 
> I'm really sorry if all this seem so trivial questions, but just
> as GTK is documented well enough, for GDK the only documentation
> is the code, and unfortanetely I don't have all the time in the world. ;-(
> 
> Perhaps someone has got some ideas about how I should handle
> this best? Perhaps it's an overkill to use gtk/gdk? Perhaps
> someone knows about some libraries I'm unaware of and which do
> exactly what I'd like to do?

You should probably use gdk_pixmap_colormap_create_from_xpm_d().
It only relies on a colormap, not a window, and colormaps are
usually set as soon as a widget is created.

e.g.

  GdkColormap *colormap;
  GdkPixmap *pixmap;
  GdkBitmap *mask;

  colormap = gtk_widget_get_colormap (widget);
  pixmap = gdk_pixmap_colormap_create_from_xpm_d (NULL, colormap, &mask,
                                                  NULL, my_pixmap_xpm);

Damon




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