]> err.no Git - mapper/blob - src/announcements.c
Map widget:
[mapper] / src / announcements.c
1 /*
2  * This file is part of mapper
3  *
4  * Copyright (C) 2007 Kaj-Michael Lang
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program 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
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with this program; if not, write to the Free Software Foundation, Inc.,
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19  */
20
21 /* Handle speach and graphical announcements */
22
23 #include "config.h"
24
25 #include <glib/gstdio.h>
26 #include <glib/gi18n.h>
27 #include <libintl.h>
28 #include <locale.h>
29
30 #include "ui-common.h"
31 #include "utils.h"
32 #include "settings.h"
33 #include "announcements.h"
34 #include "speak.h"
35
36 static gboolean enable_speach=TRUE;
37 static gboolean enable_gui=TRUE;
38
39 #define SPEAK(s) { if (enable_speach) speak_text(s); }
40
41 void
42 announce_distance_to_destination(gdouble distance, gchar *unit, gdouble climit)
43 {
44 gchar buffer[64];
45 if (distance>climit) {
46         g_snprintf(buffer, sizeof(buffer), _("Distance to destination: %.01f %s"), distance, unit);
47 } else {
48         g_snprintf(buffer, sizeof(buffer), _("Distance to destination: %.02f %s"), distance, unit);
49 }
50 SPEAK(buffer);
51 MACRO_BANNER_SHOW_INFO(_window, buffer);
52 }
53
54 void
55 announce_destination_reached(void)
56 {
57 gchar *msg=_("You have reached your destination.");
58 SPEAK(msg);
59 MACRO_BANNER_SHOW_INFO(_window, msg);
60 }
61
62 void
63 announce_over_speed_limit(guint limit)
64 {
65 gchar *msg=_("Warning, you are over speed limit!");
66 SPEAK(msg);
67 MACRO_BANNER_SHOW_INFO(_window, msg);
68 }
69
70 void
71 announce_waypoint(gchar *msg)
72 {
73 SPEAK(msg);
74 MACRO_BANNER_SHOW_INFO(_window, msg);
75 }
76
77 #if 0
78
79 void
80 announce_continue(gchar *to_name, gchar *to_ref)
81 {
82 gchar buffer[64];
83
84 }
85
86 void
87 announce_turn(gdouble direction, gchar *to_name, gchar *to_ref, gdouble next_wpt_dist, gchar unit)
88 {
89 gchar buffer[128];
90 gchar *turn, *amount;
91
92 turn=(direction > 0) ? _("left") : _("right");
93 /* amount=(fabs(direction)<25) ? */
94 g_snprintf(buffer, sizeof(buffer), "Turn %s to %s, %s. Continue on %s ", 
95         turn,
96         to_name ? to_name : "",
97         to_ref ? to_ref : "",
98         to_ref ? to_ref : to_name ? );
99 }
100
101 #endif