]> err.no Git - mapper/blob - src/gps-conn.c
Add header and cast properly.
[mapper] / src / gps-conn.c
1 /*
2  * This file is part of mapper
3  *
4  * Copyright (C) 2007 Kaj-Michael Lang
5  * Copyright (C) 2006-2007 John Costigan.
6  *
7  * POI and GPS-Info code originally written by Cezary Jackiewicz.
8  *
9  * Default map data provided by http://www.openstreetmap.org/
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License along
22  * with this program; if not, write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24  */
25
26 #include <config.h>
27 #include <unistd.h>
28 #include <stdlib.h>
29 #include <stddef.h>
30 #include <errno.h>
31 #include <sys/wait.h>
32 #include <glib/gstdio.h>
33 #include <glib/gi18n.h>
34 #include <gtk/gtk.h>
35 #include <fcntl.h>
36 #include <dbus/dbus-glib.h>
37 #include <libintl.h>
38 #include <locale.h>
39
40 #include "hildon-mapper.h"
41
42 static GtkWidget *connect_banner = NULL;
43 static GtkWidget *fix_banner = NULL;
44
45 #include "utils.h"
46 #include "settings.h"
47 #include "gps.h"
48 #include "map.h"
49 #include "ui-common.h"
50 #include "gps-conn.h"
51
52 /**
53  * Set the connection state. This function controls all connection-related banners.
54  */
55 void 
56 gps_conn_set_state(Gps *gps, GpsConnState new_conn_state)
57 {
58 switch (gps->io.conn=new_conn_state) {
59         case RCVR_OFF:
60                 set_action_activate("gps_enabled", FALSE);
61         case RCVR_FIXED:
62                 if (connect_banner) {
63                         gtk_widget_destroy(connect_banner);
64                         connect_banner=NULL;
65                 }
66                 if (fix_banner) {
67                         gtk_widget_destroy(fix_banner);
68                         fix_banner=NULL;
69                 }
70 #ifndef WITH_HILDON
71                 gtk_progress_bar_set_text(_progress_item, "");
72                 gtk_progress_bar_set_fraction(_progress_item, 0.0);
73 #endif
74                 break;
75         case RCVR_DOWN:
76                 if (fix_banner) {
77                         gtk_widget_destroy(fix_banner);
78                         fix_banner=NULL;
79                 }
80                 if (!connect_banner)
81                         connect_banner=hildon_banner_show_animation(_window, NULL, _("Searching for GPS receiver"));
82                 break;
83         case RCVR_UP:
84                 if (connect_banner) {
85                         gtk_widget_destroy(connect_banner);
86                         connect_banner=NULL;
87                 }
88                 if (!fix_banner)
89                         fix_banner=hildon_banner_show_progress(_window, NULL, _("Establishing GPS fix"));
90                 break;
91         default:;               /* to quell warning. */
92 }
93 }
94
95 void
96 gps_conn_set_progress(Gps *gps, gdouble fix)
97 {
98 #ifdef WITH_HILDON
99 hildon_banner_set_fraction(fix_banner, fix);
100 #else
101 gtk_progress_bar_set_fraction(_progress_item, fix);
102 #endif
103 }