set window title to "Tuner"
[tunertool] / src / tuner.c
index b7dce3a..5856674 100644 (file)
@@ -1,6 +1,7 @@
 /* vim: set sts=2 sw=2 et: */
 /* Tuner
  * Copyright (C) 2006 Josep Torra <j.torra@telefonica.net>
+ *               2008-2009 Jari Tenhunen <jari.tenhunen@iki.fi>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -325,7 +326,7 @@ draw_leds (AppData * appdata, gint n)
 
 /* update frequency info */
 static void
-update_frequency (AppData * appdata, gint frequency)
+update_frequency (AppData * appdata, gfloat frequency)
 {
   gchar *buffer;
   gint i, j;
@@ -348,7 +349,7 @@ update_frequency (AppData * appdata, gint frequency)
   gtk_label_set_text (GTK_LABEL (appdata->targetFrequency), buffer);
   g_free (buffer);
 
-  buffer = g_strdup_printf ("Played frequency is %d Hz", frequency);
+  buffer = g_strdup_printf ("Played frequency is %.2f Hz", frequency);
   gtk_label_set_text (GTK_LABEL (appdata->currentFrequency), buffer);
   g_free (buffer);
 
@@ -364,9 +365,9 @@ message_handler (GstBus * bus, GstMessage * message, gpointer data)
     const gchar *name = gst_structure_get_name (s);
 
     if (strcmp (name, "pitch") == 0) {
-      gint frequency;
+      gfloat frequency;
 
-      frequency = g_value_get_int (gst_structure_get_value (s, "frequency"));
+      frequency = g_value_get_float (gst_structure_get_value (s, "frequency"));
       if (frequency != 0)
         update_frequency (data, frequency);
     }
@@ -485,15 +486,17 @@ stop_pipelines (gpointer user_data)
   return FALSE;
 }
 
+#ifdef FAKE_FREQUENCY
 static gboolean
 fake_frequency (gpointer user_data)
 {
   AppData * appdata = (AppData *) user_data;
 
-  update_frequency (appdata, 440);
+  update_frequency (appdata, 440.0);
 
   return TRUE;
 }
+#endif
 
 #ifdef MAEMO
 static void
@@ -736,7 +739,7 @@ main (int argc, char *argv[])
   gtk_init (&argc, &argv);
 
   app = HILDON_PROGRAM (hildon_program_get_instance ());
-  g_set_application_name ("Tuner Tool");
+  g_set_application_name ("Tuner");
 
   appdata->app = app;
 
@@ -884,9 +887,13 @@ main (int argc, char *argv[])
   if (appdata->display_keepalive)
     display_keepalive (appdata);
 
+  draw_leds (appdata, 0);
+
   set_pipeline_states (appdata, GST_STATE_PLAYING);
 
-  //g_timeout_add (2000, (GSourceFunc) fake_frequency, appdata);
+#ifdef FAKE_FREQUENCY
+  g_timeout_add (2000, (GSourceFunc) fake_frequency, appdata);
+#endif
 
   gtk_main ();