1 /* vim: set sts=2 sw=2 et: */
3 * Copyright (C) 2006 Josep Torra <j.torra@telefonica.net>
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
26 #define TUNER_VERSION "0.4"
29 #include <hildon/hildon-defines.h>
30 #include <hildon/hildon-program.h>
31 #include <hildon/hildon-number-editor.h>
35 #define OSSO_PACKAGE "tuner-tool"
36 #define OSSO_VERSION TUNER_VERSION
38 #endif /* ifdef HILDON */
41 # define DEFAULT_AUDIOSRC "pulsesrc"
42 # define DEFAULT_AUDIOSINK "pulsesink"
44 # define DEFAULT_AUDIOSRC "alsasrc"
45 # define DEFAULT_AUDIOSINK "alsasink"
53 #include <gconf/gconf-client.h>
58 #define between(x,a,b) (((x)>=(a)) && ((x)<=(b)))
60 #define MAGIC (1.059463094359f) /* 2^(1/2) */
62 extern gboolean plugin_pitch_init (GstPlugin * plugin);
63 extern gboolean plugin_tonesrc_init (GstPlugin * plugin);
73 GtkWidget *targetFrequency;
74 GtkWidget *currentFrequency;
75 GtkWidget *drawingarea1;
76 GtkWidget *drawingarea2;
86 gboolean display_keepalive;
88 osso_context_t *osso_context;
90 guint display_timer_id;
94 typedef struct app_data AppData;
103 #define NUM_LEDS (66)
104 #define NUM_WKEYS (15) /* # of white keys in the piano keyboard */
105 #define WKEY_WIDTH (45)
107 static Note equal_tempered_scale[] = {
181 {"C#6/Db6", 1108.73},
183 {"D#6/Eb6", 1244.51},
186 {"F#6/Gb6", 1479.98},
188 {"G#6/Ab6", 1661.22},
190 {"A#6/Bb6", 1864.66},
193 {"C#7/Db7", 2217.46},
195 {"D#7/Eb7", 2489.02},
198 {"F#7/Gb7", 2959.96},
200 {"G#7/Ab7", 3322.44},
202 {"A#7/Bb7", 3729.31},
206 static GdkColor ledOnColor = { 0, 0 * 255, 180 * 255, 95 * 255 };
207 static GdkColor ledOnColor2 = { 0, 180 * 255, 180 * 255, 0 * 255 };
208 static GdkColor ledOffColor = { 0, 80 * 255, 80 * 255, 80 * 255 };
209 static GdkColor whiteColor = { 0, 65535, 65535, 65535 };
210 static GdkColor blackColor = { 0, 0, 0, 0 };
213 recalculate_scale (double a4)
217 for (i = 0; i < NUM_NOTES; i++) {
218 equal_tempered_scale[i].frequency = a4 * pow (MAGIC, i - 57);
219 /* fprintf(stdout, "%s: %.2f\n", equal_tempered_scale[i].name, equal_tempered_scale[i].frequency); */
224 calibration_changed (GObject * object, GParamSpec * pspec, gpointer user_data)
229 value = hildon_number_editor_get_value (HILDON_NUMBER_EDITOR (object));
231 value = gtk_spin_button_get_value (GTK_SPIN_BUTTON (object));
234 if (value >= CALIB_MIN && value <= CALIB_MAX) {
235 recalculate_scale (value);
236 settings_set_calibration (value);
241 on_window_destroy (GtkObject * object, gpointer user_data)
247 toggle_fullscreen (GtkWindow * window)
249 static gboolean fullscreen = FALSE;
251 fullscreen = !fullscreen;
253 gtk_window_fullscreen (GTK_WINDOW (window));
255 gtk_window_unfullscreen (GTK_WINDOW (window));
259 key_press_event (GtkWidget * widget, GdkEventKey * event, GtkWindow * window)
261 switch (event->keyval) {
263 case HILDON_HARDKEY_FULLSCREEN:
264 toggle_fullscreen (window);
275 draw_leds (AppData * appdata, gint n)
278 static GdkGC *gc = NULL;
279 gint width = appdata->drawingarea1->allocation.width;
280 gint led_width = ((gfloat) width / (gfloat) (NUM_LEDS)) * 0.8;
281 gint led_space = ((gfloat) width / (gfloat) (NUM_LEDS)) * 0.2;
282 gint led_total = led_width + led_space;
283 gint padding = (width - NUM_LEDS * led_total) / 2;
286 gc = gdk_gc_new (appdata->drawingarea1->window);
288 gdk_gc_set_rgb_fg_color (gc, &appdata->drawingarea1->style->fg[0]);
290 gdk_draw_rectangle (appdata->drawingarea1->window, gc, TRUE, 0, 0,
291 appdata->drawingarea1->allocation.width, appdata->drawingarea1->allocation.height);
293 if (abs (n) > (NUM_LEDS / 2))
294 n = n / n * (NUM_LEDS / 2);
297 j = NUM_LEDS / 2 + 1;
298 k = NUM_LEDS / 2 + n;
300 j = NUM_LEDS / 2 + n;
301 k = NUM_LEDS / 2 - 1;
305 for (i = 0; i < NUM_LEDS; i++) {
306 if (i == NUM_LEDS / 2) {
308 gdk_gc_set_rgb_fg_color (gc, &ledOnColor2);
310 gdk_gc_set_rgb_fg_color (gc, &ledOffColor);
312 gdk_draw_rectangle (appdata->drawingarea1->window, gc, TRUE, padding + (i * led_total) + ((led_total - 4) / 2), 2, 4,
315 if ((i >= j) && (i <= k))
316 gdk_gc_set_rgb_fg_color (gc, &ledOnColor);
318 gdk_gc_set_rgb_fg_color (gc, &ledOffColor);
320 gdk_draw_rectangle (appdata->drawingarea1->window, gc, TRUE, padding + (i * led_total), 10, led_width,
326 /* update frequency info */
328 update_frequency (AppData * appdata, gfloat frequency)
332 gfloat diff, min_diff;
334 min_diff = frequency - (equal_tempered_scale[0].frequency - 10);
335 for (i = j = 0; i < NUM_NOTES; i++) {
336 diff = frequency - equal_tempered_scale[i].frequency;
337 if (fabs (diff) <= fabs (min_diff)) {
346 g_strdup_printf ("Nearest note is %s with %.2f Hz frequency",
347 equal_tempered_scale[j].name, equal_tempered_scale[j].frequency);
348 gtk_label_set_text (GTK_LABEL (appdata->targetFrequency), buffer);
351 buffer = g_strdup_printf ("Played frequency is %.2f Hz", frequency);
352 gtk_label_set_text (GTK_LABEL (appdata->currentFrequency), buffer);
355 draw_leds (appdata, (gint) roundf (min_diff));
358 /* receive spectral data from element message */
360 message_handler (GstBus * bus, GstMessage * message, gpointer data)
362 if (message->type == GST_MESSAGE_ELEMENT) {
363 const GstStructure *s = gst_message_get_structure (message);
364 const gchar *name = gst_structure_get_name (s);
366 if (strcmp (name, "pitch") == 0) {
369 frequency = g_value_get_float (gst_structure_get_value (s, "frequency"));
371 update_frequency (data, frequency);
374 /* we handled the message we want, and ignored the ones we didn't want.
375 * so the core can unref the message for us */
380 keynote2freq (AppData * appdata, gint x, gint y)
382 gint i, j, height, found;
383 gfloat frequency = 0;
385 height = appdata->drawingarea2->allocation.height;
389 for (i = 0; i < NUM_WKEYS; i++) {
390 // Test for a white key
392 if (between (x, i * WKEY_WIDTH, i * WKEY_WIDTH + (WKEY_WIDTH - 1)) && between (y, 0, height))
394 // Test for a black key
395 if (((i % 7) != 2) && ((i % 7) != 6) && (i != 14)) {
397 if (between (x, 24 + i * 45, 24 + i * 45 + 42)
398 && between (y, 0, height / 2))
402 frequency = equal_tempered_scale[48 + found - 1].frequency;
410 expose_event (GtkWidget * widget, GdkEventExpose * event, gpointer user_data)
412 AppData * appdata = (AppData *) user_data;
414 static GdkGC *gc = NULL;
417 gc = gdk_gc_new (appdata->drawingarea2->window);
419 gdk_gc_set_rgb_fg_color (gc, &whiteColor);
420 gdk_draw_rectangle (appdata->drawingarea2->window, gc, TRUE, 0, 0,
421 NUM_WKEYS * WKEY_WIDTH, appdata->drawingarea2->allocation.height - 1);
423 gdk_gc_set_rgb_fg_color (gc, &blackColor);
424 gdk_draw_rectangle (appdata->drawingarea2->window, gc, FALSE, 0, 0,
425 NUM_WKEYS * WKEY_WIDTH, appdata->drawingarea2->allocation.height - 1);
427 for (i = 0; i < NUM_WKEYS - 1; i++)
428 gdk_draw_rectangle (appdata->drawingarea2->window, gc, FALSE, i * WKEY_WIDTH, 0,
429 WKEY_WIDTH, appdata->drawingarea2->allocation.height - 1);
431 for (i = 0; i < NUM_WKEYS - 1; i++) {
432 if (((i % 7) != 2) && ((i % 7) != 6))
433 gdk_draw_rectangle (appdata->drawingarea2->window, gc, TRUE, 24 + i * WKEY_WIDTH, 0,
434 42, appdata->drawingarea2->allocation.height / 2);
440 button_press_event (GtkWidget * widget, GdkEventButton * event, gpointer user_data)
442 AppData * appdata = (AppData *) user_data;
444 if (event->button == 1) {
445 g_object_set (appdata->tonesrc, "freq", (gdouble) keynote2freq (appdata, event->x, event->y),
446 "volume", 0.8, NULL);
453 button_release_event (GtkWidget * widget, GdkEventButton * event,
456 AppData * appdata = (AppData *) user_data;
458 if (event->button == 1) {
459 g_object_set (appdata->tonesrc, "volume", 0.0, NULL);
466 set_pipeline_states (AppData * appdata, GstState state)
469 gst_element_set_state (appdata->bin1, state);
472 gst_element_set_state (appdata->bin2, state);
476 stop_pipelines (gpointer user_data)
478 AppData * appdata = (AppData *) user_data;
480 /* dsppcmsrc needs to go to READY or NULL state to make
481 * the DSP sleep and OMAP reach retention mode */
482 set_pipeline_states (appdata, GST_STATE_READY);
483 appdata->stop_timer_id = 0;
489 fake_frequency (gpointer user_data)
491 AppData * appdata = (AppData *) user_data;
493 update_frequency (appdata, 440.0);
500 osso_hw_state_cb (osso_hw_state_t *state, gpointer user_data)
502 AppData * appdata = (AppData *) user_data;
504 if (state->shutdown_ind) {
509 if (state->system_inactivity_ind) {
510 /* do not stop pipelines if the app is on foreground
511 * and display is kept on */
512 if (appdata->display_timer_id == 0) {
513 if (appdata->stop_timer_id != 0)
514 g_source_remove (appdata->stop_timer_id);
516 appdata->stop_timer_id = g_timeout_add (5000, (GSourceFunc) stop_pipelines, user_data);
521 if (hildon_program_get_is_topmost (HILDON_PROGRAM (appdata->app))) {
522 if (appdata->stop_timer_id != 0) {
523 g_source_remove (appdata->stop_timer_id);
524 appdata->stop_timer_id = 0;
527 set_pipeline_states (appdata, GST_STATE_PLAYING);
529 /* not topmost => topmost_notify will set pipelines to PLAYING
530 * when the application is on the foreground again */
532 if (appdata->stop_timer_id != 0) {
533 g_source_remove (appdata->stop_timer_id);
534 appdata->stop_timer_id = 0;
537 set_pipeline_states (appdata, GST_STATE_PLAYING);
546 display_keepalive (gpointer user_data)
548 AppData * appdata = (AppData *) user_data;
550 /* first (direct) call: call blanking_pause and set up timer */
551 if (appdata->display_timer_id == 0) {
552 osso_display_blanking_pause (appdata->osso_context);
553 appdata->display_timer_id = g_timeout_add (55000, (GSourceFunc) display_keepalive, user_data);
554 return TRUE; /* does not really matter */
557 /* callback from main loop */
558 if (hildon_program_get_is_topmost (HILDON_PROGRAM (appdata->app))) {
559 osso_display_blanking_pause (appdata->osso_context);
563 appdata->display_timer_id = 0;
568 display_keepalive_stop (AppData * appdata)
570 if (appdata->display_timer_id) {
571 g_source_remove (appdata->display_timer_id);
572 appdata->display_timer_id = 0;
577 topmost_notify (GObject * object, GParamSpec * pspec, gpointer user_data)
579 AppData * appdata = (AppData *) user_data;
581 if (hildon_program_get_is_topmost (HILDON_PROGRAM (object))) {
582 /* cancel pipeline stop timer if it is ticking */
583 if (appdata->stop_timer_id != 0) {
584 g_source_remove (appdata->stop_timer_id);
585 appdata->stop_timer_id = 0;
588 set_pipeline_states (appdata, GST_STATE_PLAYING);
590 /* keep display on */
591 if (appdata->display_keepalive && appdata->display_timer_id == 0)
592 display_keepalive (user_data);
595 /* pause pipelines so that we don't update the UI needlessly */
596 set_pipeline_states (appdata, GST_STATE_PAUSED);
597 /* stop pipelines fully if the app stays in the background for 30 seconds */
598 appdata->stop_timer_id = g_timeout_add (30000, (GSourceFunc) stop_pipelines, user_data);
599 /* let display dim and switch off */
600 display_keepalive_stop (appdata);
608 settings_notify (GConfClient * client, guint cnxn_id, GConfEntry * entry, gpointer user_data)
610 AppData * appdata = (AppData *) user_data;
612 g_debug ("%s changed", gconf_entry_get_key (entry));
614 if (strcmp (gconf_entry_get_key (entry), GCONF_KEY_ALGORITHM) == 0) {
615 if (gconf_entry_get_value (entry) != NULL && gconf_entry_get_value (entry)->type == GCONF_VALUE_INT) {
616 g_object_set (G_OBJECT (appdata->pitch),
617 "algorithm", gconf_value_get_int (gconf_entry_get_value (entry)),
621 else if (strcmp (gconf_entry_get_key (entry), GCONF_KEY_CALIBRATION) == 0) {
624 else if (strcmp (gconf_entry_get_key (entry), GCONF_KEY_DISPLAY_KEEPALIVE) == 0) {
625 if (gconf_entry_get_value (entry) != NULL && gconf_entry_get_value (entry)->type == GCONF_VALUE_BOOL) {
626 appdata->display_keepalive = gconf_value_get_bool (gconf_entry_get_value (entry));
628 if (appdata->display_keepalive && appdata->display_timer_id == 0)
629 display_keepalive (user_data);
631 display_keepalive_stop (appdata);
635 g_warning ("unknown GConf key `%s'", gconf_entry_get_key (entry));
640 settings_activate (GtkWidget * widget, GtkWidget * main_win)
642 settings_dialog_show (GTK_WINDOW (main_win));
646 about_activate (GtkWidget * widget, GtkWindow * main_win)
652 dialog = gtk_dialog_new_with_buttons("About tuner", main_win,
654 GTK_DIALOG_DESTROY_WITH_PARENT |
655 GTK_DIALOG_NO_SEPARATOR,
658 g_signal_connect (G_OBJECT (dialog), "delete_event", G_CALLBACK (gtk_widget_destroy), NULL);
660 vbox = gtk_vbox_new (FALSE, HILDON_MARGIN_DEFAULT);
661 gtk_container_set_border_width (GTK_CONTAINER (vbox), HILDON_MARGIN_DEFAULT);
662 gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), vbox);
663 label = gtk_label_new ("Tuner Tool is developed by Josep Torra and Jari Tenhunen.\n"
664 "http://n770galaxy.blogspot.com/\n");
665 gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 5);
667 gtk_widget_show_all (dialog);
668 gtk_dialog_run (GTK_DIALOG (dialog));
670 gtk_widget_destroy (dialog);
673 static HildonAppMenu *
674 create_menu (GtkWidget *parent)
676 HildonSizeType button_size = HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH;
677 HildonAppMenu *menu = HILDON_APP_MENU (hildon_app_menu_new ());
680 button = GTK_BUTTON (hildon_gtk_button_new (button_size));
681 gtk_button_set_label (button, "Settings");
682 g_signal_connect_after (G_OBJECT (button), "clicked",
683 G_CALLBACK (settings_activate), parent);
684 hildon_app_menu_append (menu, button);
686 button = GTK_BUTTON (hildon_gtk_button_new (button_size));
687 gtk_button_set_label (button, "About");
688 g_signal_connect_after (G_OBJECT (button), "clicked",
689 G_CALLBACK (about_activate), parent);
690 hildon_app_menu_append (menu, button);
692 gtk_widget_show_all (GTK_WIDGET (menu));
698 main (int argc, char *argv[])
700 AppData * appdata = NULL;
702 HildonProgram *app = NULL;
703 osso_hw_state_t hw_state_mask = { TRUE, FALSE, FALSE, TRUE, 0 };
707 GstElement *src1, *src2, *sink1;
715 GtkWidget *alignment;
716 GtkWidget *calibrate;
721 GdkPixbuf *icon = NULL;
722 GError *error = NULL;
724 gboolean piano_enabled = TRUE;
726 appdata = g_new0(AppData, 1);
729 gst_init (&argc, &argv);
730 /* Register the GStreamer plugins */
731 plugin_pitch_init (NULL);
732 plugin_tonesrc_init (NULL);
735 /* Init the gtk - must be called before any hildon stuff */
736 gtk_init (&argc, &argv);
738 app = HILDON_PROGRAM (hildon_program_get_instance ());
739 g_set_application_name ("Tuner Tool");
743 /* Initialize maemo application */
744 appdata->osso_context = osso_initialize (OSSO_PACKAGE, OSSO_VERSION, TRUE, NULL);
746 /* Check that initialization was ok */
747 if (appdata->osso_context == NULL) {
748 g_print ("Bummer, osso failed\n");
750 g_assert (appdata->osso_context);
752 /* could use also display_event_cb but it is available only from chinook onwards */
753 if (osso_hw_set_event_cb (appdata->osso_context, &hw_state_mask, osso_hw_state_cb, appdata) != OSSO_OK)
754 g_warning ("setting osso_hw_state_cb failed!");
756 settings_init (&settings_notify, appdata);
758 calib = settings_get_calibration (CALIB_DEFAULT);
759 recalculate_scale (calib);
761 mainBox = gtk_vbox_new (FALSE, 0);
762 gtk_container_set_border_width (GTK_CONTAINER (mainBox), 0);
763 mainWin = hildon_stackable_window_new ();
764 g_signal_connect (G_OBJECT (app), "notify::is-topmost", G_CALLBACK (topmost_notify), appdata);
766 menu = create_menu (mainWin);
767 hildon_program_set_common_app_menu (app, menu);
769 /* Bin for tuner functionality */
770 appdata->bin1 = gst_pipeline_new ("bin1");
772 src1 = gst_element_factory_make (DEFAULT_AUDIOSRC, "src1");
773 g_object_set (G_OBJECT (src1), "device", "source.voice.raw", NULL);
775 appdata->pitch = gst_element_factory_make ("pitch", "pitch");
777 g_object_set (G_OBJECT (appdata->pitch), "message", TRUE, "minfreq", 10,
779 "algorithm", settings_get_algorithm (DEFAULT_ALGORITHM),
782 sink1 = gst_element_factory_make ("fakesink", "sink1");
783 g_object_set (G_OBJECT (sink1), "silent", 1, NULL);
785 gst_bin_add_many (GST_BIN (appdata->bin1), src1, appdata->pitch, sink1, NULL);
786 if (!gst_element_link_many (src1, appdata->pitch, sink1, NULL)) {
787 fprintf (stderr, "cant link elements\n");
791 bus = gst_element_get_bus (appdata->bin1);
792 gst_bus_add_watch (bus, message_handler, appdata);
793 gst_object_unref (bus);
795 /* Bin for piano functionality */
796 appdata->bin2 = gst_pipeline_new ("bin2");
798 //src2 = gst_element_factory_make ("audiotestsrc", "src2");
799 //g_object_set (G_OBJECT (src2), "volume", 0.0, "wave", 7, NULL);
800 src2 = gst_element_factory_make ("tonesrc", "src2");
801 g_object_set (G_OBJECT (src2), "volume", 0.0, NULL);
802 sink2 = gst_element_factory_make (DEFAULT_AUDIOSINK, "sink2");
804 gst_bin_add_many (GST_BIN (appdata->bin2), src2, sink2, NULL);
805 if (!gst_element_link_many (src2, sink2, NULL)) {
806 piano_enabled = FALSE;
809 appdata->tonesrc = src2;
812 g_signal_connect (G_OBJECT (mainWin), "destroy",
813 G_CALLBACK (on_window_destroy), NULL);
814 g_signal_connect (G_OBJECT(mainWin), "key_press_event",
815 G_CALLBACK (key_press_event), mainWin);
818 appdata->targetFrequency = gtk_label_new ("");
819 gtk_box_pack_start (GTK_BOX (mainBox), appdata->targetFrequency, FALSE, FALSE, 5);
822 appdata->drawingarea1 = gtk_drawing_area_new ();
823 gtk_widget_set_size_request (appdata->drawingarea1, 636, 40);
824 gtk_box_pack_start (GTK_BOX (mainBox), appdata->drawingarea1, FALSE, FALSE, 5);
826 /* Current frequency lable */
827 appdata->currentFrequency = gtk_label_new ("");
828 gtk_box_pack_start (GTK_BOX (mainBox), appdata->currentFrequency, FALSE, FALSE, 5);
830 /* Calibration spinner */
831 box = gtk_hbox_new (FALSE, 0);
832 alignment = gtk_alignment_new (0.5, 0.5, 0, 0);
833 label = gtk_label_new ("Calibration");
834 gtk_box_pack_start (GTK_BOX (box), label, FALSE, FALSE, 5);
837 calibrate = calibration_editor_new (CALIB_MIN, CALIB_MAX);
838 hildon_number_editor_set_value (HILDON_NUMBER_EDITOR (calibrate),
840 g_signal_connect (G_OBJECT (calibrate), "notify::value",
841 G_CALLBACK (calibration_changed), NULL);
843 calibrate = gtk_spin_button_new_with_range (CALIB_MIN, CALIB_MAX, 1);
844 gtk_spin_button_set_value (GTK_SPIN_BUTTON (calibrate), calib);
845 g_signal_connect (G_OBJECT (calibrate), "value_changed",
846 G_CALLBACK (calibration_changed), NULL);
848 gtk_box_pack_start (GTK_BOX (box), calibrate, FALSE, FALSE, 5);
849 gtk_container_add (GTK_CONTAINER (alignment), box);
850 gtk_box_pack_start (GTK_BOX (mainBox), alignment, FALSE, FALSE, 5);
853 sep = gtk_hseparator_new ();
854 gtk_box_pack_start (GTK_BOX (mainBox), sep, FALSE, FALSE, 5);
857 alignment = gtk_alignment_new (0.5, 0.5, 0, 0);
858 appdata->drawingarea2 = gtk_drawing_area_new ();
859 gtk_widget_set_size_request (appdata->drawingarea2, NUM_WKEYS * WKEY_WIDTH + 1, 130);
860 gtk_container_add (GTK_CONTAINER (alignment), appdata->drawingarea2);
861 gtk_box_pack_start (GTK_BOX (mainBox), alignment, FALSE, FALSE, 5);
863 g_signal_connect (G_OBJECT (appdata->drawingarea2), "expose_event",
864 G_CALLBACK (expose_event), appdata);
866 g_signal_connect (G_OBJECT (appdata->drawingarea2), "button_press_event",
867 G_CALLBACK (button_press_event), (gpointer) appdata);
869 g_signal_connect (G_OBJECT (appdata->drawingarea2), "button_release_event",
870 G_CALLBACK (button_release_event), (gpointer) appdata);
872 gtk_widget_set_events (appdata->drawingarea2, GDK_EXPOSURE_MASK
873 | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK);
875 gtk_widget_set_events (appdata->drawingarea2, GDK_EXPOSURE_MASK);
878 gtk_container_add (GTK_CONTAINER (mainWin), mainBox);
879 hildon_program_add_window (app, HILDON_WINDOW (mainWin));
880 gtk_widget_show_all (GTK_WIDGET (mainWin));
882 appdata->display_keepalive = settings_get_display_keepalive (DEFAULT_DISPLAY_KEEPALIVE);
884 if (appdata->display_keepalive)
885 display_keepalive (appdata);
887 draw_leds (appdata, 0);
889 set_pipeline_states (appdata, GST_STATE_PLAYING);
891 //g_timeout_add (2000, (GSourceFunc) fake_frequency, appdata);
895 set_pipeline_states (appdata, GST_STATE_NULL);
897 gst_object_unref (appdata->bin1);
898 gst_object_unref (appdata->bin2);