
#include <stdio.h>
#include <stdlib.h>
#include <gtk/gtk.h>

/* Define the size of our icon (width and height), and the foreground and
 * background colours.
 */
#define	ICON_SIZE	16
#define	F		0xe0,0xe0,0xff		/* Foreground, light blue */
#define	B		0x00,0x00,0xff		/* Background, blue */

static void setWindowIcon(GtkWidget *widget);

int main(int argc, char *argv[])
{
    GtkWidget *window;
    GtkWidget *label;

    /* Initialise GTK */
    gtk_init(&argc, &argv);

    /* Create the window */
    window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_signal_connect(GTK_OBJECT (window), "destroy",
		      GTK_SIGNAL_FUNC(gtk_main_quit),
		      NULL);

    /* Create a label and put it in the window. */
    label = gtk_label_new("This is a label");
    gtk_container_add(GTK_CONTAINER(window), label);

    /* Set the window icon. */
    setWindowIcon(window);

    /* Show everything and run the main loop. */
    gtk_widget_show_all(window);
    gtk_main();
    return(0);
}

static void setWindowIcon(GtkWidget *widget)
{
static char iconData[ICON_SIZE * ICON_SIZE * 3] =
   {
	B, B, B, B, B, B, B, B, B, B, B, B, B, B, B, B,
	B, B, B, B, B, B, B, B, B, B, B, B, B, B, B, B,
	B, B, B, B, B, B, B, B, B, B, B, B, B, B, B, B,
	B, F, F, F, B, F, B, B, B, F, B, F, F, F, B, B,
	B, F, B, F, B, F, B, B, B, F, B, F, B, F, B, B,
	B, F, B, F, B, F, B, B, B, F, B, F, B, F, B, B,
	B, F, B, F, B, F, B, B, B, F, B, F, B, F, B, B,
	B, F, F, F, B, F, B, B, B, F, B, F, F, F, B, B,
	B, F, F, B, B, B, F, B, F, B, B, F, B, B, B, B,
	B, F, B, F, B, B, F, B, F, B, B, F, B, B, B, B,
	B, F, B, F, B, B, F, B, F, B, B, F, B, B, B, B,
	B, F, B, B, F, B, B, F, B, B, B, F, B, B, B, B,
	B, F, B, B, F, B, B, F, B, B, B, F, B, B, B, B,
	B, B, B, B, B, B, B, B, B, B, B, B, B, B, B, B,
	B, B, B, B, B, B, B, B, B, B, B, B, B, B, B, B,
	B, B, B, B, B, B, B, B, B, B, B, B, B, B, B, B,
    };
    GdkPixbuf *pixbuf;

    /* Create a pixbuf from our data. */
    pixbuf = gdk_pixbuf_new_from_data(iconData, GDK_COLORSPACE_RGB,
					FALSE, 8,
					ICON_SIZE, ICON_SIZE,
					ICON_SIZE * 3,
					NULL, NULL);

    /* Set this as the icon for the window. */
    gtk_window_set_icon(GTK_WINDOW(widget), pixbuf);

    /* Return to the caller. */
    return;
} /* setWindowIcon() */

