+/**
+ *
+ * Detect our own data types
+ */
+static void clip_determine_viking_type ( GtkClipboard *c, GtkSelectionData *sd, gpointer p )
+{
+ VikClipboardDataType *vdct = p;
+ // Default value
+ *vdct = VIK_CLIPBOARD_DATA_NONE;
+ vik_clipboard_t *vc;
+ if (gtk_selection_data_get_length(sd) == -1) {
+ g_warning ("DETERMINING TYPE: length failure");
+ return;
+ }
+
+ vc = (vik_clipboard_t *)gtk_selection_data_get_data(sd);
+
+ if ( !vc->type )
+ return;
+
+ if ( vc->type == VIK_CLIPBOARD_DATA_LAYER ) {
+ *vdct = VIK_CLIPBOARD_DATA_LAYER;
+ }
+ else if ( vc->type == VIK_CLIPBOARD_DATA_SUBLAYER ) {
+ *vdct = VIK_CLIPBOARD_DATA_SUBLAYER;
+ }
+ else {
+ g_warning ("DETERMINING TYPE: THIS SHOULD NEVER HAPPEN");
+ }
+}
+
+static void clip_determine_type ( GtkClipboard *c, GdkAtom *a, gint n, gpointer p )
+{
+ gint i;
+ for (i=0; i<n; i++) {
+ // g_print(" ""%s""\n", gdk_atom_name(a[i]));
+ if (!strcmp(gdk_atom_name(a[i]), "application/viking")) {
+ gtk_clipboard_request_contents ( c, gdk_atom_intern("application/viking", TRUE), clip_determine_viking_type, p );
+ break;
+ }
+ }
+}
+
+/**
+ * a_clipboard_type:
+ *
+ * Return the type of data held in the clipboard if any
+ */
+VikClipboardDataType a_clipboard_type ( )
+{
+ GtkClipboard *c = gtk_clipboard_get ( GDK_SELECTION_CLIPBOARD );
+ VikClipboardDataType *vcdt = g_malloc ( sizeof (VikClipboardDataType) );
+
+ gtk_clipboard_request_targets ( c, clip_determine_type, vcdt );
+ gint answer = *vcdt;
+ g_free ( vcdt );
+ return answer;
+}