aboutsummaryrefslogtreecommitdiff
path: root/src/mainwindow.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mainwindow.c')
-rw-r--r--src/mainwindow.c42
1 files changed, 11 insertions, 31 deletions
diff --git a/src/mainwindow.c b/src/mainwindow.c
index 8c2b256..93a1fd9 100644
--- a/src/mainwindow.c
+++ b/src/mainwindow.c
@@ -28,41 +28,24 @@
#include <gtk/gtk.h>
#include <stdlib.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <math.h>
#include "types.h"
-#include "accelerometers.h"
#include "audio.h"
-#include "physics.h"
-
-static gboolean mainwindow_timeout(gpointer data) {
-
- MainWindow *mw = data;
-
- accelerometer_update(mw->accel);
-
- physics_update(mw->physics, mw->accel->lval);
- if ( mw->physics->moo ) {
- audio_trigger_moo(mw->audio);
- mw->physics->moo = 0;
- }
-
- return TRUE; /* Call back again */
-
-}
static gint mainwindow_closed(GtkWidget *widget, MainWindow *mw) {
- audio_shutdown(mw->audio);
gtk_exit(0);
return 0;
}
+static gint mainwindow_clicked(GtkWidget *widget, GdkEventButton *event, gpointer data) {
+ audio_trigger_moo();
+ return 0;
+}
+
MainWindow *mainwindow_open(void) {
MainWindow *mw;
- GtkWidget *label;
+ GtkWidget *eb;
mw = malloc(sizeof(*mw));
if ( mw == NULL ) return NULL;
@@ -71,16 +54,13 @@ MainWindow *mainwindow_open(void) {
gtk_window_set_default_size(GTK_WINDOW(mw->window), 240, 320);
gtk_window_set_title(GTK_WINDOW(mw->window), "OpenMooCow");
+ eb = gtk_event_box_new();
mw->cow = gtk_image_new_from_file(PIXMAPDIR"/cow.png");
- gtk_container_add(GTK_CONTAINER(mw->window), mw->cow);
-
- mw->accel = accelerometer_open();
- mw->accel_timeout = g_timeout_add(10, mainwindow_timeout, mw);
- accelerometer_update(mw->accel);
-
- mw->audio = audio_setup();
- mw->physics = physics_setup();
+ gtk_container_add(GTK_CONTAINER(eb), mw->cow);
+ gtk_container_add(GTK_CONTAINER(mw->window), eb);
+ gtk_widget_add_events(GTK_WIDGET(eb), GDK_BUTTON_PRESS_MASK);
+ g_signal_connect(G_OBJECT(eb), "button_press_event", G_CALLBACK(mainwindow_clicked), mw);
g_signal_connect(G_OBJECT(mw->window), "destroy", G_CALLBACK(mainwindow_closed), mw);
gtk_widget_show_all(mw->window);