questions on using icons with GtkButton.

Hi all; couldn't find a tutorial or FAQ on this subject.

I want to put a small bitmap or pixmap into a button instead of a
text label.  Is GnomePixmap the only/best way to do this?

Can GnomePixmap handle a monochrome bitmap?

Next, I want to change the displayed bitmap from time to time.  I haven't
found a clean way to do this.  The best I could come up with was to call
code like this:

    ChangeGlyph(GtkWidget *button, GdkPixmap *new_pixmap, GdkBitmap *new_mask)
	GtkWidget	*button = button holding the glyph
	GnomePixmap	*pixmapWidget ;

	pixmapWidget = GNOME_PIXMAP(gtk_bin_get_child(GTK_BIN(button))) ;
	gdk_pixmap_unref( pixmapWidget->pixmap ) ;
	gdk_bitmap_unref( pixmapWidget->mask ) ;
	pixmapWidget->pixmap = new_pixmap ;
	pixmapWidget->mask = new_mask ;
	gdk_pixmap_ref( pixmapWidget->pixmap ) ;
	gdk_bitmap_ref( pixmapWidget->mask ) ;
	gtk_widget_draw(GTK_WIDGET(pixmapWidget), NULL) ;

This doesn't really look right to me.  In particular, the pixmap widget
hasn't been given the opportunity to recompute its size.  If the new image
is smaller than the previous for instance, it's not centered.  Also, the
previous glyph is not erased.

Any advice here?

	-ed falk

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