+/* scherzo - Music notation training
+ *
+ * Copyright © 2010 Carl Worth
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see http://www.gnu.org/licenses/ .
+ */
+
+#include <gtk/gtk.h>
+
+#define unused(foo) foo __attribute__((unused))
+
+static int
+on_delete_event_quit (unused (GtkWidget *widget),
+ unused (GdkEvent *event),
+ unused (gpointer user_data))
+{
+ gtk_main_quit ();
+
+ /* Returning FALSE allows the default handler for delete-event
+ * to proceed to cleanup the widget. */
+ return FALSE;
+}
+
+static int
+on_expose_event_draw (GtkWidget *widget,
+ unused (GdkEventExpose *event),
+ unused (gpointer user_data))
+{
+ cairo_t *cr;
+ GtkAllocation allocation;
+
+ gtk_widget_get_allocation (widget, &allocation);
+
+ cr = gdk_cairo_create (widget->window);
+
+ /* Paint in medium sea green */
+ cairo_set_source_rgb (cr, 60/255.0, 179/255.0, 113/255.0);
+
+ cairo_paint (cr);
+
+ return TRUE;
+}
+
+int
+main (int argc, char *argv[])
+{
+ GtkWidget *window;
+ GtkWidget *drawing_area;
+
+ gtk_init (&argc, &argv);
+
+ window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+
+ gtk_window_set_default_size (GTK_WINDOW (window), 600, 400);
+
+ g_signal_connect (window, "delete-event",
+ G_CALLBACK (on_delete_event_quit), NULL);
+
+ drawing_area = gtk_drawing_area_new ();
+
+ gtk_container_add (GTK_CONTAINER (window), drawing_area);
+
+ g_signal_connect (drawing_area, "expose-event",
+ G_CALLBACK (on_expose_event_draw), NULL);
+
+
+ gtk_widget_show_all (window);
+
+ gtk_main ();
+
+ return 0;
+}