]> git.street.me.uk Git - andy/viking.git/blobdiff - src/garminsymbols.c
Fix CPU usage going to 100% when statusbar items update is called.
[andy/viking.git] / src / garminsymbols.c
index 147f4fe2bb9de3bb2af2223c64a27a6baf1e552a..b0b2cdbbe42a59e145c853080c30ee0b9f404540 100644 (file)
@@ -2,6 +2,8 @@
  * viking -- GPS Data and Topo Analyzer, Explorer, and Manager
  *
  * Copyright (C) 2003-2005, Evan Battaglia <gtoevan@gmx.net>
  * 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
  *
  * 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
@@ -330,12 +332,24 @@ static void init_icons() {
 }
 
 static GdkPixbuf *get_wp_sym_from_index ( gint i ) {
 }
 
 static GdkPixbuf *get_wp_sym_from_index ( gint i ) {
-  if ( !garmin_syms[i].icon &&
-      ((!a_vik_get_use_large_waypoint_icons() && garmin_syms[i].data) ||
-       (a_vik_get_use_large_waypoint_icons() && garmin_syms[i].data_large))) {
-    garmin_syms[i].icon = gdk_pixbuf_from_pixdata (
-       a_vik_get_use_large_waypoint_icons() ? garmin_syms[i].data_large : garmin_syms[i].data,
-       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;
 }
   }
   return garmin_syms[i].icon;
 }
@@ -361,8 +375,8 @@ GdkPixbuf *a_get_wp_sym ( const gchar *sym ) {
 void a_populate_sym_list ( GtkListStore *list ) {
   gint i;
   for (i=0; i<G_N_ELEMENTS(garmin_syms); i++) {
 void a_populate_sym_list ( GtkListStore *list ) {
   gint i;
   for (i=0; i<G_N_ELEMENTS(garmin_syms); i++) {
-    if ((!a_vik_get_use_large_waypoint_icons() && garmin_syms[i].data) ||
-        (a_vik_get_use_large_waypoint_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);
       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);