]> err.no Git - libchamplain/commitdiff
Offline is a ChamplainNetworkMapSource property
authorPierre-Luc Beaudoin <pierre-luc@pierlux.com>
Fri, 6 Mar 2009 08:23:49 +0000 (10:23 +0200)
committerPierre-Luc Beaudoin <pierre-luc@pierlux.com>
Fri, 6 Mar 2009 08:23:49 +0000 (10:23 +0200)
champlain/Makefile.am
champlain/champlain-map-source.c
champlain/champlain-network-map-source.c
champlain/champlain-settings.c [deleted file]
champlain/champlain-settings.h [deleted file]
champlain/champlain-view.c
champlain/champlain.h

index 8d2ca1508872cb16616fd545bce2b392a88b0381..a774ef9690984775b08b1f1bf6af8be288a117b4 100644 (file)
@@ -24,8 +24,7 @@ libchamplain_headers = \
        champlain-enum-types.h          \
        champlain-tile.h                \
        champlain-map-source.h          \
-       champlain-network-map-source.h  \
-       champlain-settings.h
+       champlain-network-map-source.h
 
 
 libchamplain_0_3_la_SOURCES = \
@@ -39,8 +38,7 @@ libchamplain_0_3_la_SOURCES = \
        champlain-zoom-level.c          \
        champlain-tile.c                \
        champlain-map-source.c          \
-       champlain-network-map-source.c  \
-       champlain-settings.c
+       champlain-network-map-source.c
 
 noinst_HEADERS = \
        champlain-debug.h               \
@@ -63,8 +61,7 @@ libchamplain_include_HEADERS = \
        champlain-network-map-source.h  \
        champlain-tile.h                \
        champlain-zoom-level.h          \
-       champlain-marker.h              \
-       champlain-settings.h
+       champlain-marker.h
 
 libchamplain_0_3_la_LIBADD = $(DEPS_LIBS) ../tidy/libtidy-1.0.la
 
index 77915e0541f534b76144c6c768a8e29e03565484..7ba3a76d05689753b53ca14f9287b769b0f70608 100644 (file)
@@ -27,7 +27,6 @@
 #include "champlain-map-source.h"
 #include "champlain-marshal.h"
 #include "champlain-private.h"
-#include "champlain-settings.h"
 #include "champlain-zoom-level.h"
 
 #include <glib.h>
index 6b4c7f48a1707e5c669c0a712a145a4382b83597..34dd9716b973fe8c5b9d9ee9fe3e1f5267250cc8 100644 (file)
@@ -29,7 +29,6 @@
 #include "champlain-map-source.h"
 #include "champlain-marshal.h"
 #include "champlain-private.h"
-#include "champlain-settings.h"
 #include "champlain-zoom-level.h"
 
 #include <errno.h>
@@ -50,7 +49,8 @@ enum
 enum
 {
   PROP_0,
-  PROP_URI_FORMAT
+  PROP_URI_FORMAT,
+  PROP_OFFLINE
 };
 
 /* static guint champlain_network_map_source_signals[LAST_SIGNAL] = { 0, }; */
@@ -64,6 +64,7 @@ static SoupSession * soup_session;
 
 struct _ChamplainNetworkMapSourcePrivate
 {
+  gboolean offline;
   gchar *uri_format;
 };
 
@@ -81,6 +82,9 @@ champlain_network_map_source_get_property (GObject *object,
       case PROP_URI_FORMAT:
         g_value_set_string (value, priv->uri_format);
         break;
+      case PROP_OFFLINE:
+        g_value_set_boolean (value, priv->offline);
+        break;
       default:
         G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
     }
@@ -100,6 +104,9 @@ champlain_network_map_source_set_property (GObject *object,
       case PROP_URI_FORMAT:
         priv->uri_format = g_value_dup_string (value);
         break;
+      case PROP_OFFLINE:
+        priv->offline = g_value_get_boolean (value);
+        break;
       default:
         G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
     }
@@ -144,6 +151,19 @@ champlain_network_map_source_class_init (ChamplainNetworkMapSourceClass *klass)
                                (G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
   g_object_class_install_property (object_class, PROP_URI_FORMAT, pspec);
 
+  /**
+  * ChamplainNetworkMapSource:offline
+  *
+  * If the network map source can access network
+  *
+  * Since: 0.4
+  */
+  pspec = g_param_spec_boolean ("offline",
+                                "Offline",
+                                "Offline",
+                                FALSE,
+                                (G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+  g_object_class_install_property (object_class, PROP_OFFLINE, pspec);
 }
 
 static void
@@ -425,7 +445,7 @@ champlain_network_map_source_get_tile (ChamplainMapSource *map_source,
       g_object_unref (tile);
       g_object_unref (zoom_level);
     }
-  else if (champlain_settings_is_online ())
+  else if (!priv->offline)
     {
       SoupMessage *msg;
       gchar *uri;
diff --git a/champlain/champlain-settings.c b/champlain/champlain-settings.c
deleted file mode 100644 (file)
index 73a3c84..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-
-/*
- * Copyright (C) 2009 Pierre-Luc Beaudoin <pierre-luc@pierlux.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#include "champlain-settings.h"
-
-static gboolean global_offline = TRUE;
-
-gboolean
-champlain_settings_is_online ()
-{
-  return global_offline;
-}
-
-gboolean
-champlain_settings_set_online (gboolean value)
-{
-  global_offline = value;
-}
diff --git a/champlain/champlain-settings.h b/champlain/champlain-settings.h
deleted file mode 100644 (file)
index 2544c76..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (C) 2008 Pierre-Luc Beaudoin <pierre-luc@pierlux.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#if !defined (__CHAMPLAIN_CHAMPLAIN_H_INSIDE__) && !defined (CHAMPLAIN_COMPILATION)
-#error "Only <champlain/champlain.h> can be included directly."
-#endif
-
-#ifndef CHAMPLAIN_SETTINGS_H
-#define CHAMPLAIN_SETTINGS_H
-
-#include <glib.h>
-
-gboolean champlain_settings_is_online ();
-gboolean champlain_settings_set_online (gboolean value);
-
-#endif
index c37d422f95f8d1e18fa9ea3cd803d97c33cd51cf..6fb93c1ce29be96367d2418ec6e340ec1bc1c3fe 100644 (file)
@@ -38,8 +38,7 @@
  * url="http://www.openstreetmap.org">OpenStreetMap</ulink>).  Maps are divided
  * in tiles for each zoom level.  When a tile is requested, #ChamplainView will
  * first check if it is in cache (in the user's cache dir under champlain). If
- * an error occurs during download, an error tile will be displayed (if not in
- * offline mode).
+ * an error occurs during download, an error tile will be displayed.
  *
  * The button-press-event and button-release-event signals are emitted each
  * time a mouse button is pressed on the @view.  Coordinates can be converted
@@ -82,7 +81,6 @@ enum
   PROP_LATITUDE,
   PROP_ZOOM_LEVEL,
   PROP_MAP_SOURCE,
-  PROP_OFFLINE,
   PROP_DECEL_RATE,
   PROP_SCROLL_MODE,
   PROP_KEEP_CENTER_ON_RESIZE,
@@ -451,9 +449,6 @@ champlain_view_get_property (GObject *object,
       case PROP_SCROLL_MODE:
         g_value_set_enum (value, priv->scroll_mode);
         break;
-      case PROP_OFFLINE:
-        g_value_set_boolean (value, !champlain_settings_is_online ());
-        break;
       case PROP_DECEL_RATE:
         {
           gdouble decel;
@@ -512,9 +507,6 @@ champlain_view_set_property (GObject *object,
       g_object_set (G_OBJECT (priv->finger_scroll), "mode",
           priv->scroll_mode, NULL);
       break;
-    case PROP_OFFLINE:
-      champlain_settings_set_online (!g_value_get_boolean (value));
-      break;
     case PROP_DECEL_RATE:
       {
         gdouble decel = g_value_get_double (value);
@@ -612,21 +604,6 @@ champlain_view_class_init (ChamplainViewClass *champlainViewClass)
            CHAMPLAIN_TYPE_MAP_SOURCE,
            CHAMPLAIN_PARAM_READWRITE));
 
-  /**
-  * ChamplainView:offline:
-  *
-  * If true, will fetch tiles from the Internet, otherwise, will only use
-  * cached content.
-  *
-  * Since: 0.2
-  */
-  g_object_class_install_property (object_class,
-      PROP_OFFLINE,
-      g_param_spec_boolean ("offline",
-           "Offline Mode",
-           "If viewer is in offline mode.",
-           FALSE, CHAMPLAIN_PARAM_READWRITE));
-
   /**
   * ChamplainView:scroll-mode:
   *
index 9df678b0558b23f7d4999f05ce3b2296471426d8..e8598a15e24f417ce2b671715bf9941df72c8294 100644 (file)
@@ -35,7 +35,6 @@
 #include "champlain/champlain-enum-types.h"
 #include "champlain/champlain-map-source.h"
 #include "champlain/champlain-network-map-source.h"
-#include "champlain/champlain-settings.h"
 
 #undef __CHAMPLAIN_CHAMPLAIN_H_INSIDE__