Re: Warning when making toolbars



Raymond Wan <rwan cs mu oz au> writes: 
> 	Your solution worked!  [As did Jeff's which made the window
> realized!].
> 
> 	However, as I played around with it more, I realized that the
> first argument to gdk_pixmap_colormap_create_from_xpm_d() and
> gdk_pixmap_create_from_xpm_d () could have been one of many variables as
> long as it was ___ -> window .
> 
> 	Well, to be precise, I use my toolbar-creating function
> in more than one window of my program.  Each window has its own toolbar.
> I've noticed that as long as I add the icon to the correct toolbar using
> gtk_toolbar_append_item (), I can put any of the following as the first
> argument to gdk_pixmap_create_from_xpm_d ():
> 
> 	main_window -> window
> 	main_window -> left_vbox -> window

Right. So the deal is, GTK needs a colormap to create the pixmap. The
reason it needs a colormap is twofold:
 1) because the colormap implies a visual, and you need to know 
    the visual (bit depth, pixel format, etc.) to create a pixmap
 2) because it needs to know which pixels correspond to which 
    RGB colors, so it can fill in the proper pixels

So gdk_pixmap_colormap_create_from_xpm_d() actually allows you to pass
NULL for the window argument, because the relevant issue is just the
colormap.

However, in general in a GTK app, all widgets and all windows have the
same colormap. That's why you can pass in any old window there.

The only widgets that normally have a different colormap are
GtkPreview and GnomePixmap, when used on SGI machines. So if you mess
this up, you will rarely get errors.

In GTK 2, we sort of made this all go away. While widgets can still
have different colormaps in theory, we made the only two in-practice
cases (GtkPreview, GnomePixmap) go away by using the GdkRGB
visual/cmap for the entire toolkit. Then, we added the GdkPixbuf
library; you would now create a pixbuf instead of a pixmap with
gdk_pixbuf_create_from_xpm_data(). Because GdkPixbuf is a client-side
image buffer in a canonical RGB format, it has no visual/colormap
concerns. 

Basically a GdkPixmap is a server-side image data buffer, and isn't
all that appropriate as a place to store image data loaded from disk,
among other reasons because it makes you think about the visual/cmap
of the workstation's video hardware.

Anyhow, in GTK 2 the GdkPixmap code still works but you no longer need
to use it in newly-written application code.

Havoc




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