*
* Copyright (C) 2005, Alex Foobarian <foobarian@gmail.com>
* Copyright (C) 2003-2007, Evan Battaglia <gtoevan@gmx.net>
+ * Copyright (C) 2013, Rob Norris <rw_norris@hotmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
extern VikLayerInterface vik_georef_layer_interface;
extern VikLayerInterface vik_gps_layer_interface;
extern VikLayerInterface vik_dem_layer_interface;
+#ifdef HAVE_LIBMAPNIK
+extern VikLayerInterface vik_mapnik_layer_interface;
+#endif
enum {
VL_UPDATE_SIGNAL,
void vik_layer_emit_update ( VikLayer *vl )
{
if ( vl->visible && vl->realized ) {
+ GThread *thread = vik_window_get_thread ( VIK_WINDOW(VIK_GTK_WINDOW_FROM_LAYER(vl)) );
+ if ( !thread )
+ // Do nothing
+ return;
+
vik_window_set_redraw_trigger(vl);
// Only ever draw when there is time to do so
- if ( g_thread_self() != vik_window_get_thread (VIK_WINDOW(VIK_GTK_WINDOW_FROM_LAYER(vl))) )
+ if ( g_thread_self() != thread )
// Drawing requested from another (background) thread, so handle via the gdk thread method
gdk_threads_add_idle ( (GSourceFunc) idle_draw, vl );
else
&vik_gps_layer_interface,
&vik_maps_layer_interface,
&vik_dem_layer_interface,
+#ifdef HAVE_LIBMAPNIK
+ &vik_mapnik_layer_interface,
+#endif
};
VikLayerInterface *vik_layer_get_interface ( VikLayerTypeEnum type )
return l->name;
}
-VikLayer *vik_layer_create ( VikLayerTypeEnum type, VikViewport *vp, GtkWindow *w, gboolean interactive )
+time_t vik_layer_get_timestamp ( VikLayer *vl )
+{
+ if ( vik_layer_interfaces[vl->type]->get_timestamp )
+ return vik_layer_interfaces[vl->type]->get_timestamp ( vl );
+ return 0;
+}
+
+VikLayer *vik_layer_create ( VikLayerTypeEnum type, VikViewport *vp, gboolean interactive )
{
VikLayer *new_layer = NULL;
g_assert ( type < VIK_LAYER_NUM_TYPES );
g_byte_array_append ( b, (guint8 *)&len, sizeof(len) ); \
g_byte_array_append ( b, (guint8 *)(obj), len );
+ // Store the internal properties first
+ vlm_append(&vl->visible, sizeof(vl->visible));
vlm_append(vl->name, strlen(vl->name));
+ // Now the actual parameters
if ( params && get_param )
{
VikLayerParamData d;
#define vlm_read(obj) \
memcpy((obj), b+sizeof(gint), vlm_size); \
b += sizeof(gint) + vlm_size;
-
+
+ vlm_read(&vl->visible);
+
s = g_malloc(vlm_size + 1);
s[vlm_size]=0;
vlm_read(s);
-
vik_layer_rename(vl, s);
-
g_free(s);
if ( params && set_param )
*/
void vik_layer_set_defaults ( VikLayer *vl, VikViewport *vvp )
{
+ // Sneaky initialize of the viewport value here
+ vl->vvp = vvp;
VikLayerInterface *vli = vik_layer_get_interface ( vl->type );
const gchar *layer_name = vli->fixed_layer_name;
VikLayerParamData data;