From 4fc25bc641a5360245de29aac56e9450415f38e4 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Fri, 16 Sep 2011 20:08:49 -0700 Subject: [PATCH] Initial commit of scherzo. Nothing more than a simple GTK+ window so far. --- Makefile | 6 ++++ scherzo.c | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 89 insertions(+) create mode 100644 Makefile create mode 100644 scherzo.c diff --git a/Makefile b/Makefile new file mode 100644 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 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 + +#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; +} -- 2.43.0