From 8b01c1b9ec8e702abfc015848ef28228986b1e66 Mon Sep 17 00:00:00 2001 From: Pierre-Luc Beaudoin Date: Fri, 6 Mar 2009 10:23:49 +0200 Subject: [PATCH] Offline is a ChamplainNetworkMapSource property --- champlain/Makefile.am | 9 +++---- champlain/champlain-map-source.c | 1 - champlain/champlain-network-map-source.c | 26 +++++++++++++++--- champlain/champlain-settings.c | 34 ------------------------ champlain/champlain-settings.h | 31 --------------------- champlain/champlain-view.c | 25 +---------------- champlain/champlain.h | 1 - 7 files changed, 27 insertions(+), 100 deletions(-) delete mode 100644 champlain/champlain-settings.c delete mode 100644 champlain/champlain-settings.h diff --git a/champlain/Makefile.am b/champlain/Makefile.am index 8d2ca15..a774ef9 100644 --- a/champlain/Makefile.am +++ b/champlain/Makefile.am @@ -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 diff --git a/champlain/champlain-map-source.c b/champlain/champlain-map-source.c index 77915e0..7ba3a76 100644 --- a/champlain/champlain-map-source.c +++ b/champlain/champlain-map-source.c @@ -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 diff --git a/champlain/champlain-network-map-source.c b/champlain/champlain-network-map-source.c index 6b4c7f4..34dd971 100644 --- a/champlain/champlain-network-map-source.c +++ b/champlain/champlain-network-map-source.c @@ -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 @@ -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 index 73a3c84..0000000 --- a/champlain/champlain-settings.c +++ /dev/null @@ -1,34 +0,0 @@ - -/* - * Copyright (C) 2009 Pierre-Luc Beaudoin - * - * 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 index 2544c76..0000000 --- a/champlain/champlain-settings.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (C) 2008 Pierre-Luc Beaudoin - * - * 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 can be included directly." -#endif - -#ifndef CHAMPLAIN_SETTINGS_H -#define CHAMPLAIN_SETTINGS_H - -#include - -gboolean champlain_settings_is_online (); -gboolean champlain_settings_set_online (gboolean value); - -#endif diff --git a/champlain/champlain-view.c b/champlain/champlain-view.c index c37d422..6fb93c1 100644 --- a/champlain/champlain-view.c +++ b/champlain/champlain-view.c @@ -38,8 +38,7 @@ * url="http://www.openstreetmap.org">OpenStreetMap). 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: * diff --git a/champlain/champlain.h b/champlain/champlain.h index 9df678b..e8598a1 100644 --- a/champlain/champlain.h +++ b/champlain/champlain.h @@ -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__ -- 2.39.5