static VikLayerParamData mapzoom_default ( void ) { return VIK_LPD_UINT ( 0 ); }
VikLayerParam maps_layer_params[] = {
- { VIK_LAYER_MAPS, "mode", VIK_LAYER_PARAM_UINT, VIK_LAYER_GROUP_NONE, N_("Map Type:"), VIK_LAYER_WIDGET_COMBOBOX, NULL, NULL, NULL, mode_default },
- { VIK_LAYER_MAPS, "directory", VIK_LAYER_PARAM_STRING, VIK_LAYER_GROUP_NONE, N_("Maps Directory:"), VIK_LAYER_WIDGET_FOLDERENTRY, NULL, NULL, NULL, directory_default },
+ { VIK_LAYER_MAPS, "mode", VIK_LAYER_PARAM_UINT, VIK_LAYER_GROUP_NONE, N_("Map Type:"), VIK_LAYER_WIDGET_COMBOBOX, NULL, NULL, NULL, mode_default, NULL, NULL },
+ { VIK_LAYER_MAPS, "directory", VIK_LAYER_PARAM_STRING, VIK_LAYER_GROUP_NONE, N_("Maps Directory:"), VIK_LAYER_WIDGET_FOLDERENTRY, NULL, NULL, NULL, directory_default, NULL, NULL },
{ VIK_LAYER_MAPS, "alpha", VIK_LAYER_PARAM_UINT, VIK_LAYER_GROUP_NONE, N_("Alpha:"), VIK_LAYER_WIDGET_HSCALE, params_scales, NULL,
- N_("Control the Alpha value for transparency effects"), alpha_default },
- { VIK_LAYER_MAPS, "autodownload", VIK_LAYER_PARAM_BOOLEAN, VIK_LAYER_GROUP_NONE, N_("Autodownload maps:"), VIK_LAYER_WIDGET_CHECKBUTTON, NULL, NULL, NULL, vik_lpd_true_default },
+ N_("Control the Alpha value for transparency effects"), alpha_default, NULL, NULL },
+ { VIK_LAYER_MAPS, "autodownload", VIK_LAYER_PARAM_BOOLEAN, VIK_LAYER_GROUP_NONE, N_("Autodownload maps:"), VIK_LAYER_WIDGET_CHECKBUTTON, NULL, NULL, NULL, vik_lpd_true_default, NULL, NULL },
{ VIK_LAYER_MAPS, "adlonlymissing", VIK_LAYER_PARAM_BOOLEAN, VIK_LAYER_GROUP_NONE, N_("Autodownload Only Gets Missing Maps:"), VIK_LAYER_WIDGET_CHECKBUTTON, NULL, NULL,
- N_("Using this option avoids attempting to update already acquired tiles. This can be useful if you want to restrict the network usage, without having to resort to manual control. Only applies when 'Autodownload Maps' is on."), vik_lpd_false_default },
+ N_("Using this option avoids attempting to update already acquired tiles. This can be useful if you want to restrict the network usage, without having to resort to manual control. Only applies when 'Autodownload Maps' is on."), vik_lpd_false_default, NULL, NULL },
{ VIK_LAYER_MAPS, "mapzoom", VIK_LAYER_PARAM_UINT, VIK_LAYER_GROUP_NONE, N_("Zoom Level:"), VIK_LAYER_WIDGET_COMBOBOX, params_mapzooms, NULL,
N_("Determines the method of displaying map tiles for the current zoom level. 'Viking Zoom Level' uses the best matching level, otherwise setting a fixed value will always use map tiles of the specified value regardless of the actual zoom level."),
- mapzoom_default },
+ mapzoom_default, NULL, NULL },
};
enum {
GtkMenu *dl_right_click_menu;
VikCoord redownload_ul, redownload_br; /* right click menu only */
VikViewport *redownload_vvp;
-
- gboolean license_notice_shown; // FALSE for new maps only, otherwise
- // TRUE for saved maps & other layer changes as we don't need to show it again
};
enum { REDOWNLOAD_NONE = 0, /* download only missing maps */
/******** MAPS LAYER TYPES **************/
/****************************************/
-int _get_index_for_id ( guint id )
-{
- int index = 0 ;
- while (params_maptypes_ids[index] != 0)
- {
- if (params_maptypes_ids[index] == id)
- return index;
- index++;
- }
- return -1;
-}
-
void _add_map_source ( guint id, const char *label, VikMapSource *map )
{
gsize len = 0;
/************** PARAMETERS **************/
/****************************************/
-static guint map_index_to_uniq_id (guint8 index)
+static guint map_index_to_uniq_id (guint16 index)
{
g_assert ( index < NUM_MAP_TYPES );
return vik_map_source_get_uniq_id(MAPS_LAYER_NTH_TYPE(index));
return NUM_MAP_TYPES; /* no such thing */
}
-void vik_maps_layer_pretend_licence_shown ( VikMapsLayer *vml )
+#define VIK_SETTINGS_MAP_LICENSE_SHOWN "map_license_shown"
+
+/**
+ * Convenience function to display the license
+ */
+static void maps_show_license ( GtkWindow *parent, VikMapSource *map )
{
- vml->license_notice_shown = TRUE;
+ a_dialog_license ( parent,
+ vik_map_source_get_label (map),
+ vik_map_source_get_license (map),
+ vik_map_source_get_license_url (map) );
}
static gboolean maps_layer_set_param ( VikMapsLayer *vml, guint16 id, VikLayerParamData data, VikViewport *vvp, gboolean is_file_operation )
{
- // When loading from a file don't need the license reminder
- if ( is_file_operation )
- vml->license_notice_shown = TRUE;
-
switch ( id )
{
case PARAM_CACHE_DIR: maps_layer_set_cache_dir ( vml, data.s ); break;
case PARAM_MAPTYPE: {
gint maptype = map_uniq_id_to_index(data.u);
- if ( maptype == NUM_MAP_TYPES ) g_warning(_("Unknown map type"));
- else vml->maptype = maptype;
+ if ( maptype == NUM_MAP_TYPES )
+ g_warning(_("Unknown map type"));
+ else {
+ vml->maptype = maptype;
+
+ // When loading from a file don't need the license reminder - ensure it's saved into the 'seen' list
+ if ( is_file_operation ) {
+ a_settings_set_integer_list_containing ( VIK_SETTINGS_MAP_LICENSE_SHOWN, maptype );
+ }
+ else {
+ VikMapSource *map = MAPS_LAYER_NTH_TYPE(vml->maptype);
+ if (vik_map_source_get_license (map) != NULL) {
+ // Check if licence for this map type has been shown before
+ if ( ! a_settings_get_integer_list_contains ( VIK_SETTINGS_MAP_LICENSE_SHOWN, maptype ) ) {
+ if ( vvp )
+ maps_show_license ( VIK_GTK_WINDOW_FROM_WIDGET(vvp), map );
+ a_settings_set_integer_list_containing ( VIK_SETTINGS_MAP_LICENSE_SHOWN, maptype );
+ }
+ }
+ }
+ }
break;
}
case PARAM_ALPHA: if ( data.u <= 255 ) vml->alpha = data.u; break;
vml->last_ympp = 0.0;
vml->dl_right_click_menu = NULL;
- vml->license_notice_shown = FALSE;
+ //vml->license_notice_shown = FALSE;
return vml;
}
a_dialog_warning_msg ( VIK_GTK_WINDOW_FROM_WIDGET(vp), msg );
g_free(msg);
}
-
- if (vik_map_source_get_license (map) != NULL) {
- if ( ! vml->license_notice_shown ) {
- a_dialog_license (VIK_GTK_WINDOW_FROM_WIDGET(vp), vik_map_source_get_label (map),
- vik_map_source_get_license (map), vik_map_source_get_license_url (map) );
- vml->license_notice_shown = TRUE;
- }
- }
}
}
GdkPixbuf *tmp = gdk_pixbuf_add_alpha(pixbuf,FALSE,0,0,0);
g_object_unref(G_OBJECT(pixbuf));
pixbuf = tmp;
+ if ( !pixbuf )
+ return NULL;
}
pixels = gdk_pixbuf_get_pixels(pixbuf);
if ( xshrinkfactor != 1.0 || yshrinkfactor != 1.0 )
pixbuf = pixbuf_shrink ( pixbuf, xshrinkfactor, yshrinkfactor );
- a_mapcache_add ( pixbuf, mapcoord->x, mapcoord->y,
- mapcoord->z, vik_map_source_get_uniq_id(MAPS_LAYER_NTH_TYPE(vml->maptype)),
- mapcoord->scale, vml->alpha, xshrinkfactor, yshrinkfactor );
+ if ( pixbuf )
+ a_mapcache_add ( pixbuf, mapcoord->x, mapcoord->y,
+ mapcoord->z, vik_map_source_get_uniq_id(MAPS_LAYER_NTH_TYPE(vml->maptype)),
+ mapcoord->scale, vml->alpha, xshrinkfactor, yshrinkfactor );
}
}
}
download_onscreen_maps( vml_vvp, REDOWNLOAD_ALL);
}
+static void maps_layers_about ( gpointer vml_vvp[2] )
+{
+ VikMapsLayer *vml = vml_vvp[0];
+ VikMapSource *map = MAPS_LAYER_NTH_TYPE(vml->maptype);
+
+ if ( vik_map_source_get_license (map) )
+ maps_show_license ( VIK_GTK_WINDOW_FROM_LAYER(vml), map );
+ else
+ a_dialog_info_msg ( VIK_GTK_WINDOW_FROM_LAYER(vml),
+ vik_map_source_get_label (map) );
+}
+
/**
* maps_layer_how_many_maps:
* Copied from maps_layer_download_section but without the actual download and this returns a value
g_signal_connect_swapped ( G_OBJECT(item), "activate", G_CALLBACK(maps_layer_download_all), pass_along );
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
gtk_widget_show ( item );
+
+ item = gtk_image_menu_item_new_from_stock ( GTK_STOCK_ABOUT, NULL );
+ g_signal_connect_swapped ( G_OBJECT(item), "activate", G_CALLBACK(maps_layers_about), pass_along );
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+ gtk_widget_show ( item );
}
/**