]> git.cworth.org Git - scherzo/commitdiff
Initial commit of scherzo.
authorCarl Worth <cworth@cworth.org>
Sat, 17 Sep 2011 03:08:49 +0000 (20:08 -0700)
committerCarl Worth <cworth@cworth.org>
Sat, 17 Sep 2011 03:08:49 +0000 (20:08 -0700)
Nothing more than a simple GTK+ window so far.

Makefile [new file with mode: 0644]
scherzo.c [new file with mode: 0644]

diff --git a/Makefile b/Makefile
new file mode 100644 (file)
index 0000000..3bcf15a
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,6 @@
+scherzo: scherzo.c
+       gcc -Wall -Wextra $$(pkg-config --cflags --libs gtk+-2.0) -o scherzo scherzo.c
+
+clean:
+       rm -f scherzo
+
diff --git a/scherzo.c b/scherzo.c
new file mode 100644 (file)
index 0000000..77db9bb
--- /dev/null
+++ b/scherzo.c
@@ -0,0 +1,83 @@
+/* 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;
+}