Re: [gtk-list] Re: Creating pixmaps from xpm data



* Havoc Pennington (hp@redhat.com) [990815 01:31]:
> 
> Hi,
> 
> FAQ guys: you should put this in there. :-)
> 
> The best solution, suggested by Owen in an old mail, is to use
> gdk_pixmap_colormap_create_from_xpm_d() which allows its window argument
> to be NULL if you pass a colormap. Call gtk_widget_get_colormap() to get
> the colormap to use.
> 
> You can also gtk_widget_realize() the widget (if and only if it's already
> somewhere inside a toplevel window) but this is somewhat hacky.
> 
> Havoc

This worked a treat, thanks! 

Maybe if this technique was used in the pixmap example app, instead of the
"show the window first technique", this would help folks like me? When the
time came to use a pixmap in my app, I nicked some code from this example,
and thats how I ended up using the wrong tool for the job.

Anyway, it now looks like this:

[...]
GdkColormap *mycolormap;
style = gtk_widget_get_style (window);
mycolormap = gtk_widget_get_colormap (GTK_WIDGET (window));
mypixmap =
    gdk_pixmap_colormap_create_from_xpm_d (NULL, mycolormap, &mask_1,
                                           &style->bg[GTK_STATE_NORMAL],
                                           (gchar **) xpm_data);

And works!

Tom.
-- 
            .-------------------------------------------------------.
    .^.     | Tom Gilbert, England | tom@tomgilbert.freeserve.co.uk |
    /V\     |----------------------| www.tomgilbert.freeserve.co.uk |
   // \\    | Sites I recommend:   `--------------------------------|
  /(   )\   | www.freshmeat.net www.enlightenment.org www.gnome.org |
   ^^-^^    `-------------------------------------------------------'



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