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.
(VikLayerFuncWriteFileData) NULL,
(VikLayerFuncDeleteItem) NULL,
+ (VikLayerFuncCutItem) NULL,
(VikLayerFuncCopyItem) NULL,
(VikLayerFuncPasteItem) NULL,
(VikLayerFuncFreeCopiedItem) NULL,
(VikLayerFuncWriteFileData) NULL,
(VikLayerFuncDeleteItem) NULL,
+ (VikLayerFuncCutItem) NULL,
(VikLayerFuncCopyItem) NULL,
(VikLayerFuncPasteItem) NULL,
(VikLayerFuncFreeCopiedItem) NULL,
(VikLayerFuncWriteFileData) NULL,
(VikLayerFuncDeleteItem) NULL,
+ (VikLayerFuncCutItem) NULL,
(VikLayerFuncCopyItem) NULL,
(VikLayerFuncPasteItem) NULL,
(VikLayerFuncFreeCopiedItem) NULL,
(VikLayerFuncWriteFileData) NULL,
(VikLayerFuncDeleteItem) NULL,
+ (VikLayerFuncCutItem) NULL,
(VikLayerFuncCopyItem) NULL,
(VikLayerFuncPasteItem) NULL,
(VikLayerFuncFreeCopiedItem) NULL,
(VikLayerFuncWriteFileData) NULL,
(VikLayerFuncDeleteItem) NULL,
+ (VikLayerFuncCutItem) NULL,
(VikLayerFuncCopyItem) NULL,
(VikLayerFuncPasteItem) NULL,
(VikLayerFuncFreeCopiedItem) NULL,
/* 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);
VikLayerFuncWriteFileData write_file_data;
VikLayerFuncDeleteItem delete_item;
+ VikLayerFuncCutItem cut_item;
VikLayerFuncCopyItem copy_item;
VikLayerFuncPasteItem paste_item;
VikLayerFuncFreeCopiedItem free_copied_item;
gint type;
GtkTreeIter iter;
- g_debug(__FUNCTION__);
if ( ! vik_treeview_get_selected_iter ( vlp->vt, &iter ) )
/* Nothing to do */
return;
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 )
(VikLayerFuncWriteFileData) NULL,
(VikLayerFuncDeleteItem) NULL,
+ (VikLayerFuncCutItem) NULL,
(VikLayerFuncCopyItem) NULL,
(VikLayerFuncPasteItem) NULL,
(VikLayerFuncFreeCopiedItem) NULL,
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 );
(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,
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]);