PROP_LONGITUDE,
PROP_LATITUDE,
PROP_ZOOM_LEVEL,
- PROP_MAP_SOURCE
+ PROP_MAP_SOURCE,
+ PROP_OFFLINE
};
static guint champlain_view_signals[LAST_SIGNAL] = { 0, };
#define CHAMPLAIN_VIEW_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), CHAMPLAIN_TYPE_VIEW, ChamplainViewPrivate))
+
#define CHAMPLAIN_PARAM_READABLE \
(G_PARAM_READABLE | \
G_PARAM_STATIC_NICK | G_PARAM_STATIC_NAME | G_PARAM_STATIC_BLURB)
ClutterActor *fingerScroll;
GdkRectangle viewportSize;
Map *map;
+
+ gboolean offline;
};
case PROP_MAP_SOURCE:
g_value_set_int(value, priv->mapSource);
break;
+ case PROP_OFFLINE:
+ g_value_set_boolean(value, priv->offline);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
}
currentLevel = priv->map->zoom_levels;
map_load_level(priv->map, currentLevel);
- map_load_visible_tiles (priv->map, priv->viewportSize);
+ map_load_visible_tiles (priv->map, priv->viewportSize, priv->offline);
clutter_container_add_actor (CLUTTER_CONTAINER (priv->viewport), priv->map->current_level->group);
}
}
break;
}
+ case PROP_OFFLINE:
+ priv->offline = g_value_get_boolean(value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
*/
g_object_class_install_property(objectClass, PROP_ZOOM_LEVEL,
g_param_spec_int("zoom-level",
- "Zoom level",
- "The level of zoom of the map",
- 0,
- 20,
- 1.0f,
- CHAMPLAIN_PARAM_READWRITE));
+ "Zoom level",
+ "The level of zoom of the map",
+ 0,
+ 20,
+ 1.0f,
+ CHAMPLAIN_PARAM_READWRITE));
/**
*/
g_object_class_install_property(objectClass, PROP_MAP_SOURCE,
g_param_spec_int("map-source",
- "Map source",
- "The map source being displayed",
- 0,
- CHAMPLAIN_MAP_SOURCE_COUNT,
- CHAMPLAIN_MAP_SOURCE_OPENSTREETMAP,
- CHAMPLAIN_PARAM_READWRITE));
+ "Map source",
+ "The map source being displayed",
+ 0,
+ CHAMPLAIN_MAP_SOURCE_COUNT,
+ CHAMPLAIN_MAP_SOURCE_OPENSTREETMAP,
+ 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(objectClass, PROP_OFFLINE,
+ g_param_spec_boolean("offline",
+ "Offline Mode",
+ "If viewer is in offline mode.",
+ FALSE,
+ CHAMPLAIN_PARAM_READWRITE));
}
static void
champlain_view_init (ChamplainView *champlainView)
{
ChamplainViewPrivate *priv = CHAMPLAIN_VIEW_GET_PRIVATE (champlainView);
+
priv->mapSource = CHAMPLAIN_MAP_SOURCE_OPENSTREETMAP;
priv->zoomLevel = 0;
+ priv->offline = FALSE;
}
static void
-viewport_x_changed_cb(GObject *gobject,
- GParamSpec *arg1,
- ChamplainView *champlainView)
+viewport_x_changed_cb(GObject *gobject, GParamSpec *arg1, ChamplainView *champlainView)
{
ChamplainViewPrivate *priv = CHAMPLAIN_VIEW_GET_PRIVATE (champlainView);
priv->viewportSize.x = rect.x;
priv->viewportSize.y = rect.y;
- map_load_visible_tiles (priv->map, priv->viewportSize);
+ map_load_visible_tiles (priv->map, priv->viewportSize, priv->offline);
g_object_notify(G_OBJECT(champlainView), "longitude");
g_object_notify(G_OBJECT(champlainView), "latitude");
priv->viewportSize.height = allocation->height;
resize_viewport(champlainView);
- map_load_visible_tiles (priv->map, priv->viewportSize);
+ map_load_visible_tiles (priv->map, priv->viewportSize, priv->offline);
}
/**
g_object_notify(G_OBJECT(champlainView), "longitude");
g_object_notify(G_OBJECT(champlainView), "latitude");
- map_load_visible_tiles (priv->map, priv->viewportSize);
+ map_load_visible_tiles (priv->map, priv->viewportSize, priv->offline);
}
/**
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="256"
+ height="256"
+ id="svg2"
+ sodipodi:version="0.32"
+ inkscape:version="0.46"
+ version="1.0"
+ sodipodi:docname="error.svg"
+ inkscape:output_extension="org.inkscape.output.svg.inkscape">
+ <defs
+ id="defs4">
+ <linearGradient
+ id="linearGradient3200">
+ <stop
+ style="stop-color:#b3b3b3;stop-opacity:1;"
+ offset="0"
+ id="stop3202" />
+ <stop
+ style="stop-color:#ececec;stop-opacity:1;"
+ offset="1"
+ id="stop3204" />
+ </linearGradient>
+ <inkscape:perspective
+ sodipodi:type="inkscape:persp3d"
+ inkscape:vp_x="0 : 526.18109 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_z="744.09448 : 526.18109 : 1"
+ inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
+ id="perspective10" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient3200"
+ id="linearGradient3206"
+ x1="122.23481"
+ y1="0.032388873"
+ x2="257.81464"
+ y2="135.61221"
+ gradientUnits="userSpaceOnUse"
+ spreadMethod="reflect" />
+ </defs>
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="1.235"
+ inkscape:cx="150.26644"
+ inkscape:cy="92.575521"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="false"
+ inkscape:window-width="1023"
+ inkscape:window-height="719"
+ inkscape:window-x="1"
+ inkscape:window-y="49" />
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Calque 1"
+ inkscape:groupmode="layer"
+ id="layer1">
+ <rect
+ style="opacity:1;fill:url(#linearGradient3206);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1.25000000000000000;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ id="rect3198"
+ width="256"
+ height="256"
+ x="0"
+ y="0"
+ rx="0"
+ ry="0" />
+ <path
+ style="opacity:1;fill:#6c1414;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1.25;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ d="M 17.691061,21.608585 C 15.787881,23.511765 15.809981,26.577605 17.713151,28.480785 L 25.734401,36.502025 L 17.713151,44.523265 C 15.809981,46.426445 15.787881,49.492285 17.691061,51.395465 L 19.989151,53.693555 C 21.892331,55.596735 24.958171,55.574635 26.861351,53.671465 L 34.882591,45.650215 L 42.903831,53.671465 C 44.807011,55.574635 47.872851,55.596735 49.776031,53.693555 L 52.074121,51.395465 C 53.977301,49.492285 53.955201,46.426445 52.052031,44.523265 L 44.030781,36.502025 L 52.052031,28.480785 C 53.955201,26.577605 53.977301,23.511765 52.074121,21.608585 L 49.776031,19.310495 C 47.872851,17.407315 44.807021,17.429405 42.903831,19.332585 L 34.882591,27.353835 L 26.861351,19.332585 C 24.958171,17.429415 21.892331,17.407315 19.989151,19.310495 L 17.691061,21.608585 z"
+ id="rect2383" />
+ </g>
+</svg>
}
void
-map_load_visible_tiles (Map* map, GdkRectangle viewport)
+map_load_visible_tiles (Map* map, GdkRectangle viewport, gboolean offline)
{
gint x_count = ceil((float)viewport.width / map->tile_size) + 1;
gint y_count = ceil((float)viewport.height / map->tile_size) + 1;
if(!exist)
{
- Tile* tile = tile_load(map, map->current_level->level, i, j);
+ Tile* tile = tile_load(map, map->current_level->level, i, j, offline);
g_ptr_array_add (map->current_level->tiles, tile);
}
}
Map* map_new (ChamplainMapSource source);
-void map_load_visible_tiles (Map* map, GdkRectangle viewport);
+void map_load_visible_tiles (Map* map, GdkRectangle viewport, gboolean offline);
void map_free (Map* map);
}
Tile*
-tile_load (Map* map, guint zoom_level, guint x, guint y)
+tile_load (Map* map, guint zoom_level, guint x, guint y, gboolean offline)
{
static SoupSession * session;
gchar* filename, *map_filename;
clutter_container_add (CLUTTER_CONTAINER (map->current_level->group), tile->actor, NULL);
}
- else
+ else if (!offline)
{
SoupMessage *msg;
if (!session)
soup_session_queue_message (session, msg,
file_loaded_cb,
ptr);
- }
+ }
+ // If a tile is neither in cache or can be fetched, do nothing, it'll show up as empty
g_free (filename);
g_free (map_filename);