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 <hildon/hildon-banner.h>
+#include <math.h>
+#include <glib.h>
#include "callbacks.h"
#include "appdata.h"
-#include "util.h"
-
-// this is just here for debugging and tracing purposes
-static void print_location(LocationGPSDevice* device) {
- g_print("Latitude: %.2f\n"
- "Longitude: %.2f\n"
- "Altitude: %.2f\n"
- "Speed: %d",
- device->fix->latitude,
- device->fix->longitude,
- device->fix->altitude,
- device->fix->speed);
-}
+#include "ui.h"
void location_changed(LocationGPSDevice* device, gpointer data) {
- print_location(device);
-
- AppData* appdata = (AppData*) data;
-
- if(device->fix && LOCATION_GPS_DEVICE_SPEED_SET) {
- g_print("Speed is %f km/h", device->fix->speed);
- interpret_speed_from_gps(appdata, device->fix->speed);
+ // check for NaN before passing values
+ if(device->fix->fields & LOCATION_GPS_DEVICE_SPEED_SET) {
+ if(!isnan(device->fix->speed)) {
+ interpret_and_set_speed(device->fix->speed);
+ }
}
}
return FALSE;
}
-gboolean top_event_box_button_press(GtkWidget* widget, GdkEventButton* event, gpointer data) {
+gboolean middle_event_box_button_press(GtkWidget* widget, GdkEventButton* event, gpointer data) {
gdouble x = event->x;
- g_print("Top event box pressed at: %f\n", x);
- AppData* appdata = (AppData*) data;
-
- if(x > 750) {
- g_print("Exiting..\n");
- stop_gps(appdata);
+ if (event->type == GDK_2BUTTON_PRESS || event->type == GDK_3BUTTON_PRESS) {
+ g_assert(data);
+ AppData* appdata = (AppData*) data;
g_signal_emit_by_name(appdata->window, "delete_event");
}
- else {
- randomize(appdata);
- }
+
+
+
+ g_print("Middle event box pressed at: %f\n", x);
+ g_print("Changing conversion unit\n");
+ change_unit();
return TRUE;
}
-
gboolean bottom_event_box_button_press(GtkWidget* widget, GdkEventButton* event, gpointer data) {
gdouble x = event->x;
g_print("Bottom event box pressed at: %f\n", x);
- AppData* appdata = (AppData*) data;
-
- randomize(data);
return TRUE;
}