* viking -- GPS Data and Topo Analyzer, Explorer, and Manager
*
* Copyright (C) 2003-2005, Evan Battaglia <gtoevan@gmx.net>
+ * Copyright (C) 2005, Alex Foobarian <foobarian@gmail.com>
+ * Copyright (C) 2008, Quy Tonthat <qtonthat@gmail.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
}
static GdkPixbuf *get_wp_sym_from_index ( gint i ) {
- if ( !garmin_syms[i].icon &&
- ((vik_use_small_wp_icons && garmin_syms[i].data) ||
- (!vik_use_small_wp_icons && garmin_syms[i].data_large))) {
- garmin_syms[i].icon = gdk_pixbuf_from_pixdata (
- vik_use_small_wp_icons ? garmin_syms[i].data : garmin_syms[i].data_large,
- FALSE, NULL );
+ // Ensure data exists to either directly load icon or scale from the other set
+ if ( !garmin_syms[i].icon && ( garmin_syms[i].data || garmin_syms[i].data_large) ) {
+ if ( a_vik_get_use_large_waypoint_icons() ) {
+ if ( garmin_syms[i].data_large )
+ // Directly load icon
+ garmin_syms[i].icon = gdk_pixbuf_from_pixdata ( garmin_syms[i].data_large, FALSE, NULL );
+ else
+ // Up sample from small image
+ garmin_syms[i].icon = gdk_pixbuf_scale_simple ( gdk_pixbuf_from_pixdata ( garmin_syms[i].data, FALSE, NULL ), 30, 30, GDK_INTERP_BILINEAR );
+ }
+ else {
+ if ( garmin_syms[i].data )
+ // Directly use small symbol
+ garmin_syms[i].icon = gdk_pixbuf_from_pixdata ( garmin_syms[i].data, FALSE, NULL );
+ else
+ // Down size large image
+ garmin_syms[i].icon = gdk_pixbuf_scale_simple ( gdk_pixbuf_from_pixdata ( garmin_syms[i].data_large, FALSE, NULL ), 18, 18, GDK_INTERP_BILINEAR );
+ }
}
return garmin_syms[i].icon;
}
void a_populate_sym_list ( GtkListStore *list ) {
gint i;
for (i=0; i<G_N_ELEMENTS(garmin_syms); i++) {
- if ((vik_use_small_wp_icons && garmin_syms[i].data) ||
- (!vik_use_small_wp_icons && garmin_syms[i].data_large)) {
+ // Ensure at least one symbol available - the other can be auto generated
+ if ( garmin_syms[i].data || garmin_syms[i].data_large ) {
GtkTreeIter iter;
gtk_list_store_append(list, &iter);
gtk_list_store_set(list, &iter, 0, garmin_syms[i].sym, 1, get_wp_sym_from_index(i), -1);
}
+/* Use when preferences have changed to reset icons*/
+void clear_garmin_icon_syms () {
+ g_debug("garminsymbols: clear_garmin_icon_syms");
+ gint i;
+ for (i=0; i<G_N_ELEMENTS(garmin_syms); i++) {
+ if (garmin_syms[i].icon) {
+ g_object_unref (garmin_syms[i].icon);
+ garmin_syms[i].icon = NULL;
+ }
+ }
+}