1 /* vim: set sts=2 sw=2 et: */
3 * Copyright (C) 2006 Josep Torra <j.torra@telefonica.net>
4 * 2008-2009 Jari Tenhunen <jari.tenhunen@iki.fi>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
27 #define TUNER_VERSION "0.4"
30 #include <hildon/hildon-defines.h>
31 #include <hildon/hildon-program.h>
32 #include <hildon/hildon-number-editor.h>
36 #define OSSO_PACKAGE "tuner-tool"
37 #define OSSO_VERSION TUNER_VERSION
39 #endif /* ifdef HILDON */
42 # define DEFAULT_AUDIOSRC "pulsesrc"
43 # define DEFAULT_AUDIOSINK "pulsesink"
45 # define DEFAULT_AUDIOSRC "alsasrc"
46 # define DEFAULT_AUDIOSINK "alsasink"
54 #include <gconf/gconf-client.h>
59 #define between(x,a,b) (((x)>=(a)) && ((x)<=(b)))
61 #define MAGIC (1.059463094359f) /* 2^(1/2) */
63 extern gboolean plugin_pitch_init (GstPlugin * plugin);
64 extern gboolean plugin_tonesrc_init (GstPlugin * plugin);
74 GtkWidget *targetFrequency;
75 GtkWidget *currentFrequency;
76 GtkWidget *drawingarea1;
77 GtkWidget *drawingarea2;
87 gboolean display_keepalive;
89 osso_context_t *osso_context;
91 guint display_timer_id;
95 typedef struct app_data AppData;
104 #define NUM_LEDS (66)
105 #define NUM_WKEYS (15) /* # of white keys in the piano keyboard */
106 #define WKEY_WIDTH (45)
108 static Note equal_tempered_scale[] = {
182 {"C#6/Db6", 1108.73},
184 {"D#6/Eb6", 1244.51},
187 {"F#6/Gb6", 1479.98},
189 {"G#6/Ab6", 1661.22},
191 {"A#6/Bb6", 1864.66},
194 {"C#7/Db7", 2217.46},
196 {"D#7/Eb7", 2489.02},
199 {"F#7/Gb7", 2959.96},
201 {"G#7/Ab7", 3322.44},
203 {"A#7/Bb7", 3729.31},
207 static GdkColor ledOnColor = { 0, 0 * 255, 180 * 255, 95 * 255 };
208 static GdkColor ledOnColor2 = { 0, 180 * 255, 180 * 255, 0 * 255 };
209 static GdkColor ledOffColor = { 0, 80 * 255, 80 * 255, 80 * 255 };
210 static GdkColor whiteColor = { 0, 65535, 65535, 65535 };
211 static GdkColor blackColor = { 0, 0, 0, 0 };
214 recalculate_scale (double a4)
218 for (i = 0; i < NUM_NOTES; i++) {
219 equal_tempered_scale[i].frequency = a4 * pow (MAGIC, i - 57);
220 /* fprintf(stdout, "%s: %.2f\n", equal_tempered_scale[i].name, equal_tempered_scale[i].frequency); */
225 calibration_changed (GObject * object, GParamSpec * pspec, gpointer user_data)
230 value = hildon_number_editor_get_value (HILDON_NUMBER_EDITOR (object));
232 value = gtk_spin_button_get_value (GTK_SPIN_BUTTON (object));
235 if (value >= CALIB_MIN && value <= CALIB_MAX) {
236 recalculate_scale (value);
237 settings_set_calibration (value);
242 on_window_destroy (GtkObject * object, gpointer user_data)
248 toggle_fullscreen (GtkWindow * window)
250 static gboolean fullscreen = FALSE;
252 fullscreen = !fullscreen;
254 gtk_window_fullscreen (GTK_WINDOW (window));
256 gtk_window_unfullscreen (GTK_WINDOW (window));
260 key_press_event (GtkWidget * widget, GdkEventKey * event, GtkWindow * window)
262 switch (event->keyval) {
264 case HILDON_HARDKEY_FULLSCREEN:
265 toggle_fullscreen (window);
276 draw_leds (AppData * appdata, gint n)
279 static GdkGC *gc = NULL;
280 gint width = appdata->drawingarea1->allocation.width;
281 gint led_width = ((gfloat) width / (gfloat) (NUM_LEDS)) * 0.8;
282 gint led_space = ((gfloat) width / (gfloat) (NUM_LEDS)) * 0.2;
283 gint led_total = led_width + led_space;
284 gint padding = (width - NUM_LEDS * led_total) / 2;
287 gc = gdk_gc_new (appdata->drawingarea1->window);
289 gdk_gc_set_rgb_fg_color (gc, &appdata->drawingarea1->style->fg[0]);
291 gdk_draw_rectangle (appdata->drawingarea1->window, gc, TRUE, 0, 0,
292 appdata->drawingarea1->allocation.width, appdata->drawingarea1->allocation.height);
294 if (abs (n) > (NUM_LEDS / 2))
295 n = n / n * (NUM_LEDS / 2);
298 j = NUM_LEDS / 2 + 1;
299 k = NUM_LEDS / 2 + n;
301 j = NUM_LEDS / 2 + n;
302 k = NUM_LEDS / 2 - 1;
306 for (i = 0; i < NUM_LEDS; i++) {
307 if (i == NUM_LEDS / 2) {
309 gdk_gc_set_rgb_fg_color (gc, &ledOnColor2);
311 gdk_gc_set_rgb_fg_color (gc, &ledOffColor);
313 gdk_draw_rectangle (appdata->drawingarea1->window, gc, TRUE, padding + (i * led_total) + ((led_total - 4) / 2), 2, 4,
316 if ((i >= j) && (i <= k))
317 gdk_gc_set_rgb_fg_color (gc, &ledOnColor);
319 gdk_gc_set_rgb_fg_color (gc, &ledOffColor);
321 gdk_draw_rectangle (appdata->drawingarea1->window, gc, TRUE, padding + (i * led_total), 10, led_width,
327 /* update frequency info */
329 update_frequency (AppData * appdata, gfloat frequency)
333 gfloat diff, min_diff;
335 min_diff = frequency - (equal_tempered_scale[0].frequency - 10);
336 for (i = j = 0; i < NUM_NOTES; i++) {
337 diff = frequency - equal_tempered_scale[i].frequency;
338 if (fabs (diff) <= fabs (min_diff)) {
347 g_strdup_printf ("Nearest note is %s with %.2f Hz frequency",
348 equal_tempered_scale[j].name, equal_tempered_scale[j].frequency);
349 gtk_label_set_text (GTK_LABEL (appdata->targetFrequency), buffer);
352 buffer = g_strdup_printf ("Played frequency is %.2f Hz", frequency);
353 gtk_label_set_text (GTK_LABEL (appdata->currentFrequency), buffer);
356 draw_leds (appdata, (gint) roundf (min_diff));
359 /* receive spectral data from element message */
361 message_handler (GstBus * bus, GstMessage * message, gpointer data)
363 if (message->type == GST_MESSAGE_ELEMENT) {
364 const GstStructure *s = gst_message_get_structure (message);
365 const gchar *name = gst_structure_get_name (s);
367 if (strcmp (name, "pitch") == 0) {
370 frequency = g_value_get_float (gst_structure_get_value (s, "frequency"));
372 update_frequency (data, frequency);
375 /* we handled the message we want, and ignored the ones we didn't want.
376 * so the core can unref the message for us */
381 keynote2freq (AppData * appdata, gint x, gint y)
383 gint i, j, height, found;
384 gfloat frequency = 0;
386 height = appdata->drawingarea2->allocation.height;
390 for (i = 0; i < NUM_WKEYS; i++) {
391 // Test for a white key
393 if (between (x, i * WKEY_WIDTH, i * WKEY_WIDTH + (WKEY_WIDTH - 1)) && between (y, 0, height))
395 // Test for a black key
396 if (((i % 7) != 2) && ((i % 7) != 6) && (i != 14)) {
398 if (between (x, 24 + i * 45, 24 + i * 45 + 42)
399 && between (y, 0, height / 2))
403 frequency = equal_tempered_scale[48 + found - 1].frequency;
411 expose_event (GtkWidget * widget, GdkEventExpose * event, gpointer user_data)
413 AppData * appdata = (AppData *) user_data;
415 static GdkGC *gc = NULL;
418 gc = gdk_gc_new (appdata->drawingarea2->window);
420 gdk_gc_set_rgb_fg_color (gc, &whiteColor);
421 gdk_draw_rectangle (appdata->drawingarea2->window, gc, TRUE, 0, 0,
422 NUM_WKEYS * WKEY_WIDTH, appdata->drawingarea2->allocation.height - 1);
424 gdk_gc_set_rgb_fg_color (gc, &blackColor);
425 gdk_draw_rectangle (appdata->drawingarea2->window, gc, FALSE, 0, 0,
426 NUM_WKEYS * WKEY_WIDTH, appdata->drawingarea2->allocation.height - 1);
428 for (i = 0; i < NUM_WKEYS - 1; i++)
429 gdk_draw_rectangle (appdata->drawingarea2->window, gc, FALSE, i * WKEY_WIDTH, 0,
430 WKEY_WIDTH, appdata->drawingarea2->allocation.height - 1);
432 for (i = 0; i < NUM_WKEYS - 1; i++) {
433 if (((i % 7) != 2) && ((i % 7) != 6))
434 gdk_draw_rectangle (appdata->drawingarea2->window, gc, TRUE, 24 + i * WKEY_WIDTH, 0,
435 42, appdata->drawingarea2->allocation.height / 2);
441 button_press_event (GtkWidget * widget, GdkEventButton * event, gpointer user_data)
443 AppData * appdata = (AppData *) user_data;
445 if (event->button == 1) {
446 g_object_set (appdata->tonesrc, "freq", (gdouble) keynote2freq (appdata, event->x, event->y),
447 "volume", 0.8, NULL);
454 button_release_event (GtkWidget * widget, GdkEventButton * event,
457 AppData * appdata = (AppData *) user_data;
459 if (event->button == 1) {
460 g_object_set (appdata->tonesrc, "volume", 0.0, NULL);
467 set_pipeline_states (AppData * appdata, GstState state)
470 gst_element_set_state (appdata->bin1, state);
473 gst_element_set_state (appdata->bin2, state);
477 stop_pipelines (gpointer user_data)
479 AppData * appdata = (AppData *) user_data;
481 /* dsppcmsrc needs to go to READY or NULL state to make
482 * the DSP sleep and OMAP reach retention mode */
483 set_pipeline_states (appdata, GST_STATE_READY);
484 appdata->stop_timer_id = 0;
489 #ifdef FAKE_FREQUENCY
491 fake_frequency (gpointer user_data)
493 AppData * appdata = (AppData *) user_data;
495 update_frequency (appdata, 440.0);
503 osso_hw_state_cb (osso_hw_state_t *state, gpointer user_data)
505 AppData * appdata = (AppData *) user_data;
507 if (state->shutdown_ind) {
512 if (state->system_inactivity_ind) {
513 /* do not stop pipelines if the app is on foreground
514 * and display is kept on */
515 if (appdata->display_timer_id == 0) {
516 if (appdata->stop_timer_id != 0)
517 g_source_remove (appdata->stop_timer_id);
519 appdata->stop_timer_id = g_timeout_add (5000, (GSourceFunc) stop_pipelines, user_data);
524 if (hildon_program_get_is_topmost (HILDON_PROGRAM (appdata->app))) {
525 if (appdata->stop_timer_id != 0) {
526 g_source_remove (appdata->stop_timer_id);
527 appdata->stop_timer_id = 0;
530 set_pipeline_states (appdata, GST_STATE_PLAYING);
532 /* not topmost => topmost_notify will set pipelines to PLAYING
533 * when the application is on the foreground again */
535 if (appdata->stop_timer_id != 0) {
536 g_source_remove (appdata->stop_timer_id);
537 appdata->stop_timer_id = 0;
540 set_pipeline_states (appdata, GST_STATE_PLAYING);
549 display_keepalive (gpointer user_data)
551 AppData * appdata = (AppData *) user_data;
553 /* first (direct) call: call blanking_pause and set up timer */
554 if (appdata->display_timer_id == 0) {
555 osso_display_blanking_pause (appdata->osso_context);
556 appdata->display_timer_id = g_timeout_add (55000, (GSourceFunc) display_keepalive, user_data);
557 return TRUE; /* does not really matter */
560 /* callback from main loop */
561 if (hildon_program_get_is_topmost (HILDON_PROGRAM (appdata->app))) {
562 osso_display_blanking_pause (appdata->osso_context);
566 appdata->display_timer_id = 0;
571 display_keepalive_stop (AppData * appdata)
573 if (appdata->display_timer_id) {
574 g_source_remove (appdata->display_timer_id);
575 appdata->display_timer_id = 0;
580 topmost_notify (GObject * object, GParamSpec * pspec, gpointer user_data)
582 AppData * appdata = (AppData *) user_data;
584 if (hildon_program_get_is_topmost (HILDON_PROGRAM (object))) {
585 /* cancel pipeline stop timer if it is ticking */
586 if (appdata->stop_timer_id != 0) {
587 g_source_remove (appdata->stop_timer_id);
588 appdata->stop_timer_id = 0;
591 set_pipeline_states (appdata, GST_STATE_PLAYING);
593 /* keep display on */
594 if (appdata->display_keepalive && appdata->display_timer_id == 0)
595 display_keepalive (user_data);
598 /* pause pipelines so that we don't update the UI needlessly */
599 set_pipeline_states (appdata, GST_STATE_PAUSED);
600 /* stop pipelines fully if the app stays in the background for 30 seconds */
601 appdata->stop_timer_id = g_timeout_add (30000, (GSourceFunc) stop_pipelines, user_data);
602 /* let display dim and switch off */
603 display_keepalive_stop (appdata);
611 settings_notify (GConfClient * client, guint cnxn_id, GConfEntry * entry, gpointer user_data)
613 AppData * appdata = (AppData *) user_data;
615 g_debug ("%s changed", gconf_entry_get_key (entry));
617 if (strcmp (gconf_entry_get_key (entry), GCONF_KEY_ALGORITHM) == 0) {
618 if (gconf_entry_get_value (entry) != NULL && gconf_entry_get_value (entry)->type == GCONF_VALUE_INT) {
619 g_object_set (G_OBJECT (appdata->pitch),
620 "algorithm", gconf_value_get_int (gconf_entry_get_value (entry)),
624 else if (strcmp (gconf_entry_get_key (entry), GCONF_KEY_CALIBRATION) == 0) {
627 else if (strcmp (gconf_entry_get_key (entry), GCONF_KEY_DISPLAY_KEEPALIVE) == 0) {
628 if (gconf_entry_get_value (entry) != NULL && gconf_entry_get_value (entry)->type == GCONF_VALUE_BOOL) {
629 appdata->display_keepalive = gconf_value_get_bool (gconf_entry_get_value (entry));
631 if (appdata->display_keepalive && appdata->display_timer_id == 0)
632 display_keepalive (user_data);
634 display_keepalive_stop (appdata);
638 g_warning ("unknown GConf key `%s'", gconf_entry_get_key (entry));
643 settings_activate (GtkWidget * widget, GtkWidget * main_win)
645 settings_dialog_show (GTK_WINDOW (main_win));
649 about_activate (GtkWidget * widget, GtkWindow * main_win)
655 dialog = gtk_dialog_new_with_buttons("About tuner", main_win,
657 GTK_DIALOG_DESTROY_WITH_PARENT |
658 GTK_DIALOG_NO_SEPARATOR,
661 g_signal_connect (G_OBJECT (dialog), "delete_event", G_CALLBACK (gtk_widget_destroy), NULL);
663 vbox = gtk_vbox_new (FALSE, HILDON_MARGIN_DEFAULT);
664 gtk_container_set_border_width (GTK_CONTAINER (vbox), HILDON_MARGIN_DEFAULT);
665 gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), vbox);
666 label = gtk_label_new ("Tuner Tool is developed by Josep Torra and Jari Tenhunen.\n"
667 "http://n770galaxy.blogspot.com/\n");
668 gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 5);
670 gtk_widget_show_all (dialog);
671 gtk_dialog_run (GTK_DIALOG (dialog));
673 gtk_widget_destroy (dialog);
676 static HildonAppMenu *
677 create_menu (GtkWidget *parent)
679 HildonSizeType button_size = HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH;
680 HildonAppMenu *menu = HILDON_APP_MENU (hildon_app_menu_new ());
683 button = GTK_BUTTON (hildon_gtk_button_new (button_size));
684 gtk_button_set_label (button, "Settings");
685 g_signal_connect_after (G_OBJECT (button), "clicked",
686 G_CALLBACK (settings_activate), parent);
687 hildon_app_menu_append (menu, button);
689 button = GTK_BUTTON (hildon_gtk_button_new (button_size));
690 gtk_button_set_label (button, "About");
691 g_signal_connect_after (G_OBJECT (button), "clicked",
692 G_CALLBACK (about_activate), parent);
693 hildon_app_menu_append (menu, button);
695 gtk_widget_show_all (GTK_WIDGET (menu));
701 main (int argc, char *argv[])
703 AppData * appdata = NULL;
705 HildonProgram *app = NULL;
706 osso_hw_state_t hw_state_mask = { TRUE, FALSE, FALSE, TRUE, 0 };
710 GstElement *src1, *src2, *sink1;
718 GtkWidget *alignment;
719 GtkWidget *calibrate;
724 GdkPixbuf *icon = NULL;
725 GError *error = NULL;
727 gboolean piano_enabled = TRUE;
729 appdata = g_new0(AppData, 1);
732 gst_init (&argc, &argv);
733 /* Register the GStreamer plugins */
734 plugin_pitch_init (NULL);
735 plugin_tonesrc_init (NULL);
738 /* Init the gtk - must be called before any hildon stuff */
739 gtk_init (&argc, &argv);
741 app = HILDON_PROGRAM (hildon_program_get_instance ());
742 g_set_application_name ("Tuner");
746 /* Initialize maemo application */
747 appdata->osso_context = osso_initialize (OSSO_PACKAGE, OSSO_VERSION, TRUE, NULL);
749 /* Check that initialization was ok */
750 if (appdata->osso_context == NULL) {
751 g_print ("Bummer, osso failed\n");
753 g_assert (appdata->osso_context);
755 /* could use also display_event_cb but it is available only from chinook onwards */
756 if (osso_hw_set_event_cb (appdata->osso_context, &hw_state_mask, osso_hw_state_cb, appdata) != OSSO_OK)
757 g_warning ("setting osso_hw_state_cb failed!");
759 settings_init (&settings_notify, appdata);
761 calib = settings_get_calibration (CALIB_DEFAULT);
762 recalculate_scale (calib);
764 mainBox = gtk_vbox_new (FALSE, 0);
765 gtk_container_set_border_width (GTK_CONTAINER (mainBox), 0);
766 mainWin = hildon_stackable_window_new ();
767 g_signal_connect (G_OBJECT (app), "notify::is-topmost", G_CALLBACK (topmost_notify), appdata);
769 menu = create_menu (mainWin);
770 hildon_program_set_common_app_menu (app, menu);
772 /* Bin for tuner functionality */
773 appdata->bin1 = gst_pipeline_new ("bin1");
775 src1 = gst_element_factory_make (DEFAULT_AUDIOSRC, "src1");
776 g_object_set (G_OBJECT (src1), "device", "source.voice.raw", NULL);
778 appdata->pitch = gst_element_factory_make ("pitch", "pitch");
780 g_object_set (G_OBJECT (appdata->pitch), "message", TRUE, "minfreq", 10,
782 "algorithm", settings_get_algorithm (DEFAULT_ALGORITHM),
785 sink1 = gst_element_factory_make ("fakesink", "sink1");
786 g_object_set (G_OBJECT (sink1), "silent", 1, NULL);
788 gst_bin_add_many (GST_BIN (appdata->bin1), src1, appdata->pitch, sink1, NULL);
789 if (!gst_element_link_many (src1, appdata->pitch, sink1, NULL)) {
790 fprintf (stderr, "cant link elements\n");
794 bus = gst_element_get_bus (appdata->bin1);
795 gst_bus_add_watch (bus, message_handler, appdata);
796 gst_object_unref (bus);
798 /* Bin for piano functionality */
799 appdata->bin2 = gst_pipeline_new ("bin2");
801 //src2 = gst_element_factory_make ("audiotestsrc", "src2");
802 //g_object_set (G_OBJECT (src2), "volume", 0.0, "wave", 7, NULL);
803 src2 = gst_element_factory_make ("tonesrc", "src2");
804 g_object_set (G_OBJECT (src2), "volume", 0.0, NULL);
805 sink2 = gst_element_factory_make (DEFAULT_AUDIOSINK, "sink2");
807 gst_bin_add_many (GST_BIN (appdata->bin2), src2, sink2, NULL);
808 if (!gst_element_link_many (src2, sink2, NULL)) {
809 piano_enabled = FALSE;
812 appdata->tonesrc = src2;
815 g_signal_connect (G_OBJECT (mainWin), "destroy",
816 G_CALLBACK (on_window_destroy), NULL);
817 g_signal_connect (G_OBJECT(mainWin), "key_press_event",
818 G_CALLBACK (key_press_event), mainWin);
821 appdata->targetFrequency = gtk_label_new ("");
822 gtk_box_pack_start (GTK_BOX (mainBox), appdata->targetFrequency, FALSE, FALSE, 5);
825 appdata->drawingarea1 = gtk_drawing_area_new ();
826 gtk_widget_set_size_request (appdata->drawingarea1, 636, 40);
827 gtk_box_pack_start (GTK_BOX (mainBox), appdata->drawingarea1, FALSE, FALSE, 5);
829 /* Current frequency lable */
830 appdata->currentFrequency = gtk_label_new ("");
831 gtk_box_pack_start (GTK_BOX (mainBox), appdata->currentFrequency, FALSE, FALSE, 5);
833 /* Calibration spinner */
834 box = gtk_hbox_new (FALSE, 0);
835 alignment = gtk_alignment_new (0.5, 0.5, 0, 0);
836 label = gtk_label_new ("Calibration");
837 gtk_box_pack_start (GTK_BOX (box), label, FALSE, FALSE, 5);
840 calibrate = calibration_editor_new (CALIB_MIN, CALIB_MAX);
841 hildon_number_editor_set_value (HILDON_NUMBER_EDITOR (calibrate),
843 g_signal_connect (G_OBJECT (calibrate), "notify::value",
844 G_CALLBACK (calibration_changed), NULL);
846 calibrate = gtk_spin_button_new_with_range (CALIB_MIN, CALIB_MAX, 1);
847 gtk_spin_button_set_value (GTK_SPIN_BUTTON (calibrate), calib);
848 g_signal_connect (G_OBJECT (calibrate), "value_changed",
849 G_CALLBACK (calibration_changed), NULL);
851 gtk_box_pack_start (GTK_BOX (box), calibrate, FALSE, FALSE, 5);
852 gtk_container_add (GTK_CONTAINER (alignment), box);
853 gtk_box_pack_start (GTK_BOX (mainBox), alignment, FALSE, FALSE, 5);
856 sep = gtk_hseparator_new ();
857 gtk_box_pack_start (GTK_BOX (mainBox), sep, FALSE, FALSE, 5);
860 alignment = gtk_alignment_new (0.5, 0.5, 0, 0);
861 appdata->drawingarea2 = gtk_drawing_area_new ();
862 gtk_widget_set_size_request (appdata->drawingarea2, NUM_WKEYS * WKEY_WIDTH + 1, 130);
863 gtk_container_add (GTK_CONTAINER (alignment), appdata->drawingarea2);
864 gtk_box_pack_start (GTK_BOX (mainBox), alignment, FALSE, FALSE, 5);
866 g_signal_connect (G_OBJECT (appdata->drawingarea2), "expose_event",
867 G_CALLBACK (expose_event), appdata);
869 g_signal_connect (G_OBJECT (appdata->drawingarea2), "button_press_event",
870 G_CALLBACK (button_press_event), (gpointer) appdata);
872 g_signal_connect (G_OBJECT (appdata->drawingarea2), "button_release_event",
873 G_CALLBACK (button_release_event), (gpointer) appdata);
875 gtk_widget_set_events (appdata->drawingarea2, GDK_EXPOSURE_MASK
876 | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK);
878 gtk_widget_set_events (appdata->drawingarea2, GDK_EXPOSURE_MASK);
881 gtk_container_add (GTK_CONTAINER (mainWin), mainBox);
882 hildon_program_add_window (app, HILDON_WINDOW (mainWin));
883 gtk_widget_show_all (GTK_WIDGET (mainWin));
885 appdata->display_keepalive = settings_get_display_keepalive (DEFAULT_DISPLAY_KEEPALIVE);
887 if (appdata->display_keepalive)
888 display_keepalive (appdata);
890 draw_leds (appdata, 0);
892 set_pipeline_states (appdata, GST_STATE_PLAYING);
894 #ifdef FAKE_FREQUENCY
895 g_timeout_add (2000, (GSourceFunc) fake_frequency, appdata);
900 set_pipeline_states (appdata, GST_STATE_NULL);
902 gst_object_unref (appdata->bin1);
903 gst_object_unref (appdata->bin2);