Re: [gtk-list] Using the same pixmap in multiple windowsx

On Thu, 6 Aug 1998, Damon Chaplin wrote:

> Here's another problem that's puzzled me for ages:
> If I have a pixmap, can I display it in multiple windows, and how?
> Or do I have to recreate it for each one?
> The problem occurs in Glade due to the pixmaps used to represent
> placeholders (empty places) which are used all over the Glade
> interface. When I first released Glade several people reported
> that it didn't work on multiple-depth displays.
> Currently I do this for every widget that needs the pixmap:
>   placeholder_pixmap
>     = gdk_pixmap_create_from_xpm_d (placeholder->window, NULL,
> 				    &placeholder->style->bg[GTK_STATE_NORMAL],
> 				    placeholder_xpm);
> But that seems rather wasteful.
> If I make sure that every window is created with the same visual
> and colormap, can I use the pixmap everywhere then?
> How do I do this?

i had the same problem with the GLE palette, since i temporarily need
new pixmaps for dragging them (thanx for your pixmaps btw, it's much nicer
to click on those than to select them from a popup).

so in order to get the same visual and colormap for the drag window, i roughly

  gtk_widget_push_colormap (gtk_widget_get_colormap (GTK_WIDGET (wpalette)));
  gtk_widget_push_visual (gtk_widget_get_visual (GTK_WIDGET (wpalette)));
  wpalette->pop_window =
    gtk_widget_new (GTK_TYPE_WINDOW, ...);
  gtk_widget_realize (wpalette->pop_window);
  /* add the containers and then the pixmaps */
  gtk_widget_pop_colormap ();
  gtk_widget_pop_visual ();

the newly added containers and their children will automatically be realized
as well (with the same visual and colormap), because the toplevel is already

you can glance at the exact code portions in the CVS module "gle" in

> Damon


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