]> git.street.me.uk Git - andy/viking.git/blobdiff - src/vikdemlayer.c
[QA] Remove unusable constructor
[andy/viking.git] / src / vikdemlayer.c
index 0dce1854c63f6403fc893b4066ef4dc2d36831dc..e39e61baaabb9a7430628f0d258665df0ad3bea1 100644 (file)
@@ -94,7 +94,6 @@ static gchar *params_source[] = {
 #ifdef VIK_CONFIG_DEM24K
        "USA 10m (USGS 24k)",
 #endif
-        "None",
        NULL
        };
 
@@ -108,7 +107,6 @@ enum { DEM_SOURCE_SRTM,
 #ifdef VIK_CONFIG_DEM24K
        DEM_SOURCE_DEM24K,
 #endif
-       DEM_SOURCE_NONE,
      };
 
 enum { DEM_TYPE_HEIGHT = 0,
@@ -133,9 +131,12 @@ static gboolean dem_layer_download_release ( VikDEMLayer *vdl, GdkEventButton *e
 static gboolean dem_layer_download_click ( VikDEMLayer *vdl, GdkEventButton *event, VikViewport *vvp );
 
 static VikToolInterface dem_tools[] = {
-  { N_("DEM Download/Import"), (VikToolConstructorFunc) dem_layer_download_create, NULL, NULL, NULL,
+  { { "DEMDownload", "vik-icon-DEM Download", N_("_DEM Download"), NULL, N_("DEM Download"), 0 },
+    (VikToolConstructorFunc) dem_layer_download_create, NULL, NULL, NULL,
     (VikToolMouseFunc) dem_layer_download_click, NULL,  (VikToolMouseFunc) dem_layer_download_release,
-    (VikToolKeyFunc) NULL, GDK_CURSOR_IS_PIXMAP, &cursor_demdl_pixbuf },
+    (VikToolKeyFunc) NULL,
+    FALSE,
+    GDK_CURSOR_IS_PIXMAP, &cursor_demdl_pixbuf },
 };
 
 
@@ -184,6 +185,8 @@ static const guint DEM_N_GRADIENT_COLORS = sizeof(dem_gradient_colors)/sizeof(de
 
 VikLayerInterface vik_dem_layer_interface = {
   "DEM",
+  N_("DEM"),
+  "<control><shift>D",
   &vikdemlayer_pixbuf,
 
   dem_tools,
@@ -232,6 +235,11 @@ VikLayerInterface vik_dem_layer_interface = {
   (VikLayerFuncPasteItem)               NULL,
   (VikLayerFuncFreeCopiedItem)          NULL,
   (VikLayerFuncDragDropRequest)                NULL,
+
+  (VikLayerFuncSelectClick)             NULL,
+  (VikLayerFuncSelectMove)              NULL,
+  (VikLayerFuncSelectRelease)           NULL,
+  (VikLayerFuncSelectedViewportMenu)    NULL,
 };
 
 struct _VikDEMLayer {
@@ -317,11 +325,11 @@ static int dem_layer_load_list_thread ( dem_load_thread_data *dltd, gpointer thr
 
   // ATM as each file is processed the screen is not updated (no mechanism exposed to a_dems_load_list)
   // Thus force draw only at the end, as loading is complete/aborted
-  gdk_threads_enter();
+  //gdk_threads_enter();
   // Test is helpful to prevent Gtk-CRITICAL warnings if the program is exitted whilst loading
   if ( IS_VIK_LAYER(dltd->vdl) )
-    vik_layer_emit_update ( VIK_LAYER(dltd->vdl) );
-  gdk_threads_leave();
+    vik_layer_emit_update ( VIK_LAYER(dltd->vdl), TRUE ); // Yes update from background thread
+  //gdk_threads_leave();
 
   return result;
 }
@@ -424,7 +432,7 @@ VikDEMLayer *vik_dem_layer_new ( )
 {
   VikDEMLayer *vdl = VIK_DEM_LAYER ( g_object_new ( VIK_DEM_LAYER_TYPE, NULL ) );
 
-  vik_layer_init ( VIK_LAYER(vdl), VIK_LAYER_DEM );
+  vik_layer_set_type ( VIK_LAYER(vdl), VIK_LAYER_DEM );
 
   vdl->files = NULL;
 
@@ -975,6 +983,7 @@ static void dem24k_dem_download_thread ( DEMDownloadParams *p, gpointer threadda
        ceil(p->lon*8)/8 );
   /* FIX: don't use system, use execv or something. check for existence */
   system(cmdline);
+  g_free ( cmdline );
 }
 
 static gchar *dem24k_lat_lon_to_dest_fn ( gdouble lat, gdouble lon )
@@ -1065,7 +1074,6 @@ static gboolean dem_layer_add_file ( VikDEMLayer *vdl, const gchar *full_path )
       vdl->files = g_list_prepend ( vdl->files, duped_path );
       a_dems_load ( duped_path );
       g_debug("%s: %s", __FUNCTION__, duped_path);
-      vik_layer_emit_update ( VIK_LAYER(vdl) );
     }
     return TRUE;
   } else
@@ -1080,17 +1088,19 @@ static void dem_download_thread ( DEMDownloadParams *p, gpointer threaddata )
   else if ( p->source == DEM_SOURCE_DEM24K )
     dem24k_dem_download_thread ( p, threaddata );
 #endif
+  else
+    return;
 
-  gdk_threads_enter();
+  //gdk_threads_enter();
   g_mutex_lock ( p->mutex );
   if ( p->vdl ) {
     g_object_weak_unref ( G_OBJECT(p->vdl), weak_ref_cb, p );
 
     if ( dem_layer_add_file ( p->vdl, p->dest ) )
-      vik_layer_emit_update ( VIK_LAYER(p->vdl) );
+      vik_layer_emit_update ( VIK_LAYER(p->vdl), TRUE ); // Yes update from background thread
   }
   g_mutex_unlock ( p->mutex );
-  gdk_threads_leave();
+  //gdk_threads_leave();
 }
 
 
@@ -1115,9 +1125,6 @@ static gboolean dem_layer_download_release ( VikDEMLayer *vdl, GdkEventButton *e
   gchar *full_path;
   gchar *dem_file = NULL;
 
-  if ( vdl->source == DEM_SOURCE_NONE )
-    a_dialog_error_msg ( VIK_GTK_WINDOW_FROM_LAYER(vdl), _("No download source selected. Edit layer properties.") );
-
   vik_viewport_screen_to_coord ( vvp, event->x, event->y, &coord );
   vik_coord_to_latlon ( &coord, &ll );
 
@@ -1155,6 +1162,8 @@ static gboolean dem_layer_download_release ( VikDEMLayer *vdl, GdkEventButton *e
 
     g_free ( tmp );
   }
+  else
+    vik_layer_emit_update ( VIK_LAYER(vdl), FALSE );
 
   g_free ( dem_file );
   g_free ( full_path );