]> git.street.me.uk Git - andy/viking.git/commitdiff
Fix incorrect cut/copy of sublayers when accessed via the layers panel buttons.
authorRob Norris <rw_norris@hotmail.com>
Thu, 20 Jan 2011 00:08:05 +0000 (00:08 +0000)
committerRob Norris <rw_norris@hotmail.com>
Fri, 21 Jan 2011 18:32:00 +0000 (18:32 +0000)
For cut: need to specifically handle the sublayer request, thus needing to add the VikLayerFuncCutItem layer interface and an implementation in the TrackWaypoint layer.

For copy: handler already present, but the layers panel does not call it when a sublayer. The clipboard function already handles layer/sublayer logic, so always call that.

src/vikaggregatelayer.c
src/vikcoordlayer.c
src/vikdemlayer.c
src/vikgeoreflayer.c
src/vikgpslayer.c
src/viklayer.h
src/viklayerspanel.c
src/vikmapslayer.c
src/viktrwlayer.c

index 9a77ff8c6e5070a6758828da8a8effd671b5f030..084e662687db1a2e1c60a889feb88913b2e3c647 100644 (file)
@@ -75,6 +75,7 @@ VikLayerInterface vik_aggregate_layer_interface = {
   (VikLayerFuncWriteFileData)           NULL,
 
   (VikLayerFuncDeleteItem)              NULL,
+  (VikLayerFuncCutItem)                 NULL,
   (VikLayerFuncCopyItem)                NULL,
   (VikLayerFuncPasteItem)               NULL,
   (VikLayerFuncFreeCopiedItem)          NULL,
index e12ef448509620d36bb03c68be5e124a39012e59..2e681a2a3f8ea6b70341a4e27c03a946c2342325 100644 (file)
@@ -95,6 +95,7 @@ VikLayerInterface vik_coord_layer_interface = {
   (VikLayerFuncWriteFileData)           NULL,
 
   (VikLayerFuncDeleteItem)              NULL,
+  (VikLayerFuncCutItem)                 NULL,
   (VikLayerFuncCopyItem)                NULL,
   (VikLayerFuncPasteItem)               NULL,
   (VikLayerFuncFreeCopiedItem)          NULL,
index c10f646ceeea63f5d626395ec39ce5e813799fa0..90fcf3d13ef5e7fa318a04ba1cd6311cf195f5cb 100644 (file)
@@ -226,6 +226,7 @@ VikLayerInterface vik_dem_layer_interface = {
   (VikLayerFuncWriteFileData)           NULL,
 
   (VikLayerFuncDeleteItem)              NULL,
+  (VikLayerFuncCutItem)                 NULL,
   (VikLayerFuncCopyItem)                NULL,
   (VikLayerFuncPasteItem)               NULL,
   (VikLayerFuncFreeCopiedItem)          NULL,
index e1447e8f6524b4152e4263c4c36b02f13238a568..41c4be96d9369ce24e1c8930810adcbdbca7412e 100644 (file)
@@ -119,6 +119,7 @@ VikLayerInterface vik_georef_layer_interface = {
   (VikLayerFuncWriteFileData)           NULL,
 
   (VikLayerFuncDeleteItem)              NULL,
+  (VikLayerFuncCutItem)                 NULL,
   (VikLayerFuncCopyItem)                NULL,
   (VikLayerFuncPasteItem)               NULL,
   (VikLayerFuncFreeCopiedItem)          NULL,
index 88fe07e4a5c892cd3c6588d2fdcd2af446b15198..8ccec1350ede979e06792ce74aef7f323721eaf1 100644 (file)
@@ -212,6 +212,7 @@ VikLayerInterface vik_gps_layer_interface = {
   (VikLayerFuncWriteFileData)           NULL,
 
   (VikLayerFuncDeleteItem)              NULL,
+  (VikLayerFuncCutItem)                 NULL,
   (VikLayerFuncCopyItem)                NULL,
   (VikLayerFuncPasteItem)               NULL,
   (VikLayerFuncFreeCopiedItem)          NULL,
index cf10b78f107d61b8c0e01434e09f532cc2186edc..4ea846868d95dac441df5a027857527e803734d2 100644 (file)
@@ -171,6 +171,7 @@ typedef void          (*VikLayerFuncWriteFileData)         (VikLayer *, FILE *);
 /* item manipulation */
 typedef void          (*VikLayerFuncDeleteItem)            (VikLayer *, gint, gpointer);
                                                          /*      layer, subtype, pointer to sub-item */
+typedef void          (*VikLayerFuncCutItem)               (VikLayer *, gint, gpointer);
 typedef void          (*VikLayerFuncCopyItem)              (VikLayer *, gint, gpointer, guint8 **, guint *);
                                                          /*      layer, subtype, pointer to sub-item, return pointer, return len */
 typedef gboolean      (*VikLayerFuncPasteItem)             (VikLayer *, gint, guint8 *, guint);
@@ -240,6 +241,7 @@ struct _VikLayerInterface {
   VikLayerFuncWriteFileData         write_file_data;
 
   VikLayerFuncDeleteItem            delete_item;
+  VikLayerFuncCutItem               cut_item;
   VikLayerFuncCopyItem              copy_item;
   VikLayerFuncPasteItem             paste_item;
   VikLayerFuncFreeCopiedItem        free_copied_item;
index 39914144eeddb3a0c5f9272796a3f35932c18c00..adc6f72ccdc5b1d1b28f50d28c7296eda6833752 100644 (file)
@@ -519,7 +519,6 @@ void vik_layers_panel_cut_selected ( VikLayersPanel *vlp )
   gint type;
   GtkTreeIter iter;
   
-  g_debug(__FUNCTION__);
   if ( ! vik_treeview_get_selected_iter ( vlp->vt, &iter ) )
     /* Nothing to do */
     return;
@@ -545,22 +544,23 @@ void vik_layers_panel_cut_selected ( VikLayersPanel *vlp )
     else
       a_dialog_info_msg ( VIK_GTK_WINDOW_FROM_WIDGET(vlp), _("You cannot cut the Top Layer.") );
   }
+  else if (type == VIK_TREEVIEW_TYPE_SUBLAYER) {
+    VikLayer *sel = vik_layers_panel_get_selected ( vlp );
+    if ( vik_layer_get_interface(sel->type)->cut_item ) {
+      gint subtype = vik_treeview_item_get_data( vlp->vt, &iter);
+      vik_layer_get_interface(sel->type)->cut_item ( sel, subtype, vik_treeview_item_get_pointer(sel->vt, &iter) );
+    }
+  }
 }
 
 void vik_layers_panel_copy_selected ( VikLayersPanel *vlp )
 {
-  gint type;
   GtkTreeIter iter;
-  
   if ( ! vik_treeview_get_selected_iter ( vlp->vt, &iter ) )
     /* Nothing to do */
     return;
-
-  type = vik_treeview_item_get_type ( vlp->vt, &iter );
-
-  if ( type == VIK_TREEVIEW_TYPE_LAYER ) {
-    a_clipboard_copy_selected ( vlp );
-  }
+  // NB clipboard contains layer vs sublayer logic, so don't need to do it here
+  a_clipboard_copy_selected ( vlp );
 }
 
 void vik_layers_panel_paste_selected ( VikLayersPanel *vlp )
index c36e1f469c845a9f21dddd1dd6f316ce78696af7..572eef81bf7700f50772782dee694401c0667661 100644 (file)
@@ -180,6 +180,7 @@ VikLayerInterface vik_maps_layer_interface = {
   (VikLayerFuncWriteFileData)           NULL,
 
   (VikLayerFuncDeleteItem)              NULL,
+  (VikLayerFuncCutItem)                 NULL,
   (VikLayerFuncCopyItem)                NULL,
   (VikLayerFuncPasteItem)               NULL,
   (VikLayerFuncFreeCopiedItem)          NULL,
index ec4a04637537da0b43b2420e357a91e01e4c3aea..59f2f0c2c5a35dde685ca3c47e8fdc3c57afdd8b 100644 (file)
@@ -265,6 +265,8 @@ static gboolean trw_layer_set_param ( VikTrwLayer *vtl, guint16 id, VikLayerPara
 static VikLayerParamData trw_layer_get_param ( VikTrwLayer *vtl, guint16 id, gboolean is_file_operation );
 
 static void trw_layer_del_item ( VikTrwLayer *vtl, gint subtype, gpointer sublayer );
+static void trw_layer_cut_item ( VikTrwLayer *vtl, gint subtype, gpointer sublayer );
+
 static void trw_layer_copy_item ( VikTrwLayer *vtl, gint subtype, gpointer sublayer, guint8 **item, guint *len );
 static gboolean trw_layer_paste_item ( VikTrwLayer *vtl, gint subtype, guint8 *item, guint len );
 static void trw_layer_free_copied_item ( gint subtype, gpointer item );
@@ -457,6 +459,7 @@ VikLayerInterface vik_trw_layer_interface = {
   (VikLayerFuncWriteFileData)           a_gpspoint_write_file,
 
   (VikLayerFuncDeleteItem)              trw_layer_del_item,
+  (VikLayerFuncCutItem)                 trw_layer_cut_item,
   (VikLayerFuncCopyItem)                trw_layer_copy_item,
   (VikLayerFuncPasteItem)               trw_layer_paste_item,
   (VikLayerFuncFreeCopiedItem)          trw_layer_free_copied_item,
@@ -512,6 +515,23 @@ static void trw_layer_del_item ( VikTrwLayer *vtl, gint subtype, gpointer sublay
   trw_layer_delete_item ( pass_along );
 }
 
+static void trw_layer_cut_item ( VikTrwLayer *vtl, gint subtype, gpointer sublayer )
+{
+  static gpointer pass_along[5];
+  if (!sublayer) {
+    return;
+  }
+
+  pass_along[0] = vtl;
+  pass_along[1] = NULL;
+  pass_along[2] = GINT_TO_POINTER (subtype);
+  pass_along[3] = sublayer;
+  pass_along[4] = NULL;
+
+  trw_layer_copy_item_cb(pass_along);
+  trw_layer_cut_item_cb(pass_along);
+}
+
 static void trw_layer_copy_item_cb( gpointer pass_along[5])
 {
   VikTrwLayer *vtl = VIK_TRW_LAYER(pass_along[0]);