Re: [gtk-list] Need Help on Button widget



IKSAL Sebastien wrote:
> 
> Hello,
> 
> I work with gtk+-1.0.6, and I want to have up and down arrows as
> buttons, but when I compile
>  this lines :
> 
> >   CategBoxUp = gtk_button_new();
> >   glade_pixmapup = gdk_pixmap_create_from_xpm ((MainWidgets[0])->window, &glade_maskup,
> >                                              &(MainWidgets[0])->style->bg[GTK_STATE_NORMAL],
> >                                              "./icons/up.xpm");
> >   PixmapUp = gtk_pixmap_new (glade_pixmapup, glade_maskup);
> >   gdk_pixmap_unref (glade_pixmapup);
> >   gdk_bitmap_unref (glade_maskup);
> >   gtk_widget_set_usize (CategBoxUp, 30, 30);
> >   gtk_fixed_put (GTK_FIXED (CategBoxFixed3), CategBoxUp, 465, 200);
> >   gtk_container_add (GTK_CONTAINER (CategBoxUp), PixmapUp);
> >   gtk_widget_show (CategBoxUp);
> 
> I have the button in my window, but no pixmap on it.
> Have you got an idea??
> Perhaps it's not the good way to make it??

You didn't show the GtkPixmap:
     gtk_widget_show (PixmapUp);

I've recently changed the Glade output for creating pixmaps. I realized you
don't need to
pass a background colour if you are going to use transparent pixels to create
a mask.
I also now use the colormap to create the pixmap instead of an X window, so
you don't need
to realize the widgets first, e.g.

  GdkColormap *colormap;

  colormap = gtk_widget_get_colormap (widget);
  glade_pixmapup = gdk_pixmap_colormap_create_from_xpm (NULL, colormap,
&glade_maskup,
							NULL, "./icons/up.xpm");
  PixmapUp = gtk_pixmap_new (glade_pixmapup, glade_maskup);
  gdk_pixmap_unref (glade_pixmapup);
  gdk_bitmap_unref (glade_maskup);


I think this is the correct way to do it. But I'm not 100% sure.

Damon



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