[149] in The GTK GIMP ToolKit mailing list archive

home help back first fref pref prev next nref lref last post

[gtk-list] Convenience function create_pixmap_from_file()

daemon@ATHENA.MIT.EDU (Michael K. Johnson)
Wed May 14 18:29:24 1997

To: gtk-list@redhat.com
From: "Michael K. Johnson" <johnsonm@redhat.com>
Date: Wed, 14 May 1997 18:28:43 -0400
Resent-From: gtk-list@redhat.com
Reply-To: gtk-list@redhat.com


I'm writing code that is going to make use of some convenience functions.
I'll post some of them here.  I'm avoiding using the gtk_ prefix so that
I can tell my functions apart easily; if any of them look good for gtk,
feel free to change any naming, indentation, or whatever seems good.  Also
tell me if I do anything foolish in them...  :-)

michaelkjohnson

"Ever wonder why the SAME PEOPLE make up ALL the conspiracy theories?"


/* create_pixmap_from_file takes a "parent" widget (to get a
 * style from, no reason for it to be the real parent other than
 * that) and a pixmap filename, and returns a gtk pixmap widget
 */
GtkWidget *
create_pixmap_from_file(GtkWidget *parent, gchar *filename)
{
  GdkPixmap *pixmap_normal,
            *pixmap_active,
            *pixmap_prelight,
            *pixmap_selected,
            *pixmap_insensitive;
  GtkStyle *style;

  style = gtk_widget_get_style(parent);

  pixmap_normal = gdk_pixmap_create_from_xpm(parent->window,
                        &style->bg[GTK_STATE_NORMAL],
                        filename);
  pixmap_active = gdk_pixmap_create_from_xpm(parent->window,
                        &style->bg[GTK_STATE_ACTIVE],
                        filename);
  pixmap_prelight = gdk_pixmap_create_from_xpm(parent->window,
                        &style->bg[GTK_STATE_PRELIGHT],
                        filename);
  pixmap_selected = gdk_pixmap_create_from_xpm(parent->window,
                        &style->bg[GTK_STATE_SELECTED],
                        filename);
  pixmap_insensitive = gdk_pixmap_create_from_xpm(parent->window,
                        &style->bg[GTK_STATE_INSENSITIVE],
                        filename);
  return gtk_pixmap_new(pixmap_normal, pixmap_active, pixmap_prelight,
                        pixmap_selected, pixmap_insensitive);
}


--
To unsubscribe: mail -s unsubscribe gtk-list-request@redhat.com < /dev/null


home help back first fref pref prev next nref lref last post