Convenience function create_pixmap_from_file()




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);
}




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