]> git.street.me.uk Git - andy/viking.git/blobdiff - src/clipboard.c
Fix internal tile locking
[andy/viking.git] / src / clipboard.c
index 1206331a55af4a5ec39836da17591a910ecbf57e..3a6f4910ea6707135525204d91601b0738d1c298 100644 (file)
  *
  */
 
  *
  */
 
-#include <stdio.h>
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include <string.h>
 #include <stdlib.h>
 #include <string.h>
 #include <stdlib.h>
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#include <glib/gi18n.h>
+
 #include "viking.h"
 
 
 #include "viking.h"
 
 
@@ -51,11 +63,6 @@ static void clip_get ( GtkClipboard *c, GtkSelectionData *selection_data, guint
     //    g_print("clip_get: vc = %p, size = %d\n", vc, sizeof(*vc) + vc->len);
     gtk_selection_data_set ( selection_data, selection_data->target, 8, (void *)vc, sizeof(*vc) + vc->len );
   }
     //    g_print("clip_get: vc = %p, size = %d\n", vc, sizeof(*vc) + vc->len);
     gtk_selection_data_set ( selection_data, selection_data->target, 8, (void *)vc, sizeof(*vc) + vc->len );
   }
-  if (info==1) {
-    if (vc->type == VIK_CLIPBOARD_DATA_LAYER) {
-      gtk_selection_data_set_text ( selection_data, VIK_LAYER(vc->clipboard)->name, -1 );
-    } 
-  }
 }
 
 static void clip_clear ( GtkClipboard *c, gpointer p )
 }
 
 static void clip_clear ( GtkClipboard *c, gpointer p )
@@ -74,7 +81,7 @@ static void clip_receive_viking ( GtkClipboard *c, GtkSelectionData *sd, gpointe
   VikLayersPanel *vlp = p;
   vik_clipboard_t *vc;
   if (sd->length == -1) {
   VikLayersPanel *vlp = p;
   vik_clipboard_t *vc;
   if (sd->length == -1) {
-    g_warning ( "paste failed" );
+    g_warning ( _("paste failed") );
     return;
   } 
   //  g_print("clip receive: target = %s, type = %s\n", gdk_atom_name(sd->target), gdk_atom_name(sd->type));
     return;
   } 
   //  g_print("clip receive: target = %s, type = %s\n", gdk_atom_name(sd->target), gdk_atom_name(sd->type));
@@ -84,7 +91,7 @@ static void clip_receive_viking ( GtkClipboard *c, GtkSelectionData *sd, gpointe
   //  g_print("  sd->data = %p, sd->length = %d, vc->len = %d\n", sd->data, sd->length, vc->len);
 
   if (sd->length != sizeof(*vc) + vc->len) {
   //  g_print("  sd->data = %p, sd->length = %d, vc->len = %d\n", sd->data, sd->length, vc->len);
 
   if (sd->length != sizeof(*vc) + vc->len) {
-    g_warning ( "wrong clipboard data size" );
+    g_warning ( _("wrong clipboard data size") );
     return;
   }
 
     return;
   }
 
@@ -102,7 +109,10 @@ static void clip_receive_viking ( GtkClipboard *c, GtkSelectionData *sd, gpointe
         vik_layer_get_interface(vc->layer_type)->paste_item ( sel, vc->subtype, vc->data, vc->len);
     }
     else
         vik_layer_get_interface(vc->layer_type)->paste_item ( sel, vc->subtype, vc->data, vc->len);
     }
     else
-      a_dialog_error_msg_extra ( VIK_GTK_WINDOW_FROM_WIDGET(GTK_WIDGET(vlp)), "The clipboard contains sublayer data for a %s layers. You must select a layer of this type to paste the clipboard data.", vik_layer_get_interface(vc->layer_type)->name );
+      a_dialog_error_msg_extra ( VIK_GTK_WINDOW_FROM_WIDGET(GTK_WIDGET(vlp)),
+                                _("The clipboard contains sublayer data for %s layers. "
+                                  "You must select a layer of this type to paste the clipboard data."),
+                                vik_layer_get_interface(vc->layer_type)->name );
   }
 }
 
   }
 }
 
@@ -145,8 +155,6 @@ static gboolean clip_parse_latlon ( const gchar *text, struct LatLon *coord )
       gint j, k;
       cand = s+i;
 
       gint j, k;
       cand = s+i;
 
-      //      printf("Trying >>>>> %s\n", cand);
-
       for (j=0; j<2; j++) {
        for (k=0; k<2; k++) {
          gchar fmt1[] = "N %d%*[ ]%lf W %d%*[ ]%lf";
       for (j=0; j<2; j++) {
        for (k=0; k<2; k++) {
          gchar fmt1[] = "N %d%*[ ]%lf W %d%*[ ]%lf";
@@ -208,7 +216,7 @@ static void clip_add_wp(VikLayersPanel *vlp, struct LatLon *coord)
   if (sel && sel->type == VIK_LAYER_TRW) {
     vik_trw_layer_new_waypoint ( VIK_TRW_LAYER(sel), VIK_GTK_WINDOW_FROM_LAYER(sel), &vc );
   } else {
   if (sel && sel->type == VIK_LAYER_TRW) {
     vik_trw_layer_new_waypoint ( VIK_TRW_LAYER(sel), VIK_GTK_WINDOW_FROM_LAYER(sel), &vc );
   } else {
-    a_dialog_error_msg_extra ( VIK_GTK_WINDOW_FROM_WIDGET(GTK_WIDGET(vlp)), "In order to paste a waypoint, please select an appropriate layer to paste into.", NULL);
+    a_dialog_error_msg_extra ( VIK_GTK_WINDOW_FROM_WIDGET(GTK_WIDGET(vlp)), _("In order to paste a waypoint, please select an appropriate layer to paste into."), NULL);
   }
 }
 
   }
 }
 
@@ -313,10 +321,10 @@ void a_clipboard_copy_selected ( VikLayersPanel *vlp )
     return;
 
   vik_treeview_get_selected_iter ( sel->vt, &iter );
     return;
 
   vik_treeview_get_selected_iter ( sel->vt, &iter );
+  layer_type = sel->type;
 
   if ( vik_treeview_item_get_type ( sel->vt, &iter ) == VIK_TREEVIEW_TYPE_SUBLAYER ) {
     type = VIK_CLIPBOARD_DATA_SUBLAYER;
 
   if ( vik_treeview_item_get_type ( sel->vt, &iter ) == VIK_TREEVIEW_TYPE_SUBLAYER ) {
     type = VIK_CLIPBOARD_DATA_SUBLAYER;
-    layer_type = sel->type;
     if ( vik_layer_get_interface(layer_type)->copy_item) {
       subtype = vik_treeview_item_get_data(sel->vt, &iter);
       vik_layer_get_interface(layer_type)->copy_item(sel, subtype, vik_treeview_item_get_pointer(sel->vt, &iter), &data, &len );
     if ( vik_layer_get_interface(layer_type)->copy_item) {
       subtype = vik_treeview_item_get_data(sel->vt, &iter);
       vik_layer_get_interface(layer_type)->copy_item(sel, subtype, vik_treeview_item_get_pointer(sel->vt, &iter), &data, &len );
@@ -324,8 +332,10 @@ void a_clipboard_copy_selected ( VikLayersPanel *vlp )
   }
   else
   {
   }
   else
   {
+    gint ilen;
     type = VIK_CLIPBOARD_DATA_LAYER;
     type = VIK_CLIPBOARD_DATA_LAYER;
-    vik_layer_marshall ( sel, &data, &len );
+    vik_layer_marshall ( sel, &data, &ilen );
+    len = ilen;
   }
 
   if (data)
   }
 
   if (data)