From f11f8793331cf20bdfa15095bfb50b126d43a2fe Mon Sep 17 00:00:00 2001 From: Kaj-Michael Lang Date: Wed, 19 Dec 2007 13:16:43 +0200 Subject: [PATCH] Add announcements.c for announcement helpers. Start to remove announcements from map.c --- src/Makefile.am | 1 + src/announcements.c | 56 +++++++++++++++++++++++++++++++++++++++++++++ src/announcements.h | 29 +++++++++++++++++++++++ src/map.c | 50 ++++++++++++++++++++++------------------ 4 files changed, 114 insertions(+), 22 deletions(-) create mode 100644 src/announcements.c create mode 100644 src/announcements.h diff --git a/src/Makefile.am b/src/Makefile.am index 0d2d58f..e47140a 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -76,6 +76,7 @@ mapper_SOURCES = utils.c \ ui-common.c \ config-gconf.c \ speak.c \ + announcements.c \ audio-note.c \ help.c \ search.c \ diff --git a/src/announcements.c b/src/announcements.c new file mode 100644 index 0000000..40e7eac --- /dev/null +++ b/src/announcements.c @@ -0,0 +1,56 @@ +/* + * This file is part of mapper + * + * Copyright (C) 2007 Kaj-Michael Lang + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +/* Handle speach and graphical announcements */ + +#include "config.h" + +#define _GNU_SOURCE + +#include +#include +#include + +#include "speak.h" + +static gboolean enable_speach=TRUE; +static gboolean enable_gui=TRUE; + +void +announce_distance_to_destination(gdouble distance, gchar *unit, gdouble climit) +{ +gchar buffer[64]; +if (distance>climit) { + snprintf(buffer, sizeof(buffer), "Distance to destination: %.0f %s", distance, unit); +} else { + snprintf(buffer, sizeof(buffer), "Distance to destination: %.02f %s", distance, unit); +} +if (enable_speach) + speak_text(buffer); +} + +void +announce_destination_reached(void) +{ +if (enable_speach) + speak_text("You have reached your destination."); +} + + diff --git a/src/announcements.h b/src/announcements.h new file mode 100644 index 0000000..58b3251 --- /dev/null +++ b/src/announcements.h @@ -0,0 +1,29 @@ +/* + * This file is part of mapper + * + * Copyright (C) 2007 Kaj-Michael Lang + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include "config.h" + +#define _GNU_SOURCE + +#include + +void announce_distance_to_destination(gdouble distance, gchar *unit, gdouble climit); +void announce_destination_reached(void); + diff --git a/src/map.c b/src/map.c index 381594f..fa1ed9e 100644 --- a/src/map.c +++ b/src/map.c @@ -1,3 +1,28 @@ +/* + * This file is part of mapper + * + * Copyright (C) 2007 Kaj-Michael Lang + * Copyright (C) 2006-2007 John Costigan. + * + * POI and GPS-Info code originally written by Cezary Jackiewicz. + * + * Default map data provided by http://www.openstreetmap.org/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + #include #define _GNU_SOURCE @@ -7,7 +32,6 @@ #include #include #include -#include #include #include #include @@ -37,7 +61,7 @@ #include "speak.h" #include "map-poi.h" #include "map-download.h" - +#include "announcements.h" #include "gtkcompass.h" /** The "base tile" is the upper-left tile in the pixmap. */ @@ -84,6 +108,8 @@ struct _map_tile_rdata { /* Tile max age, 1 week */ #define TILE_MAX_AGE (604800) +#define KM10KNOTS (5.39956803) + void map_render_paths(); void map_force_redraw(); static void map_update_location(gdouble lat, gdouble lon, gboolean force); @@ -1016,26 +1042,6 @@ if (!s && !mp && !sp) { gtk_label_set_label(GTK_LABEL(info_banner.location), buffer); } -#define KM10KNOTS 5.39956803 - -static void -announce_distance_to_destination(gdouble distance, gchar *unit, gdouble climit) -{ -gchar buffer[64]; -if (distance>climit) { - snprintf(buffer, sizeof(buffer), "Distance to destination: %.0f %s", distance, unit); -} else { - snprintf(buffer, sizeof(buffer), "Distance to destination: %.02f %s", distance, unit); -} -speak_text(buffer); -} - -static void -announce_destination_reached() -{ -speak_text("You have reached your destination."); -} - static void map_update_destination(gdouble lat, gdouble lon) { -- 2.39.5