Re: [gtk-list] Creating a pixmap before showing a window



Arthur Jerijian wrote:
> 
> Hi all,
> 
> I'm still continuing to progress on getting a pixmap to show inside a window
> and updating the pixmap without headaches. There are still some major problems,
> but I'd like to look at them one at a time since these really ought to be
> no-brainers but are giving me a headache. :*(
> 
> Now for the first one:
> 
> 1. I create a window by doing this:
> 
>     capture_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
> 
> where capture_window is the window in question. But I DON'T SHOW IT YET because
> the capture hasn't been taken yet at this point.
> 
> 2. I create a pixmap by doing this:
> 
>     style = gtk_widget_get_style (capture_window);
>     default_pixmap = gdk_pixmap_create_from_xpm_d
>     (
>         capture_window -> window,
>         &default_mask,
>         &style -> bg [GTK_STATE_NORMAL],
>         (gchar **) default_xpm
>     );
>     capture_pixmap = gtk_pixmap_new (default_pixmap, default_mask);
> 
> Now, at this point, all is fine and dandy if the window is shown. But it's
> not...and I get this assertion upon runtime:
> 
> Gdk-WARNING **: Creating pixmap from xpm with NULL window and colormap
> 
> It looks like the window element of capture_window is set to NULL. Is there a
> way to properly render a default pixmap without showing the window first, or is
> this just a strange fantasy of mine? :*)

capture_window -> window won't be created until capture_window is realized.
That is why you get the warning above.

You can call gtk_widget_realize () to realize the window, but the better solution
is to use gdk_pixmap_colormap_create_from_xpm_d () to create the pixmap. e.g.

  GdkColormap *colormap;
  GdkPixmap *gdkpixmap;
  GdkBitmap *mask;

  colormap = gtk_widget_get_colormap (widget);
  gdkpixmap = gdk_pixmap_colormap_create_from_xpm_d (NULL, colormap, &mask,
                                                     NULL, selector_xpm);


Note that if you are going to use the mask together with the pixmap, then you
don't need to worry about passing in the color to use for transparent areas,
since it will be masked out anyway.

Damon




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