don't start GPS when there is no working connection
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Tue, 1 Jun 2010 16:47:18 +0000 (18:47 +0200)
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Tue, 1 Jun 2010 16:51:56 +0000 (18:51 +0200)
src/azimuth.c

index 06daa08..adb73a2 100644 (file)
@@ -55,7 +55,9 @@ update_gps (Azimuth *self)
   start_gps = gconf_client_get_bool (priv->gconf,
       AZIMUTH_GCONF_KEY_START_GPS, NULL);
 
-  if (priv->publisher != NULL && start_gps)
+  if (priv->publisher != NULL &&
+      start_gps &&
+      position_publisher_has_connections (priv->publisher))
     {
       g_print ("starting GPS\n");
       location_gpsd_control_start (priv->gps_control);
@@ -83,11 +85,22 @@ update_blur (Azimuth *self)
 }
 
 static void
+has_connections_changed_cb (PositionPublisher *publisher,
+    gboolean has_connections,
+    Azimuth *self)
+{
+  update_gps (self);
+}
+
+static void
 create_publisher (Azimuth *self)
 {
   AzimuthPrivate *priv = AZIMUTH_GET_PRIVATE (self);
 
   priv->publisher = position_publisher_new ();
+
+  g_signal_connect (priv->publisher, "has-connections-changed",
+      G_CALLBACK (has_connections_changed_cb), self);
 }
 
 static void