#include <string.h>
#include "gdk.h"
-#if defined (GDK_WINDOWING_X11)
-#include "x11/gdkx.h" /* For gdk_window_lookup() */
-#elif defined (GDK_WINDOWING_WIN32)
-#include "win32/gdkwin32.h" /* For gdk_window_lookup() */
-#elif defined (GDK_WINDOWING_FB)
-#include "linux-fb/gdkfb.h" /* For gdk_window_lookup() */
-#elif defined (GDK_WINDOWING_NANOX)
-#include "nanox/gdkprivate-nanox.h" /* For gdk_window_lookup() */
-#endif
-
#include "gtkmain.h"
#include "gtkselection.h"
#include "gtksignal.h"
* The string is converted to the form determined by
* @selection_data->target.
*
- * Return value: %TRUE if the selection was succesfully set,
+ * Return value: %TRUE if the selection was successfully set,
* otherwise %FALSE.
**/
gboolean
return result;
}
+/**
+ * gtk_selection_data_get_targets:
+ * @selection_data: a #GtkSelectionData object
+ * @targets: location to store an array of targets. The result
+ * stored here must be freed with g_free().
+ * @n_atoms: location to store number of items in @targets.
+ *
+ * Get the contents of @selection_data as an array of targets.
+ * This can be used to interpret the results of getting
+ * the standard TARGETS target that is always supplied for
+ * any selection.
+ *
+ * Return value: %TRUE if @selection_data contains a valid
+ * array of targets, otherwise %FALSE.
+ **/
+gboolean
+gtk_selection_data_get_targets (GtkSelectionData *selection_data,
+ GdkAtom **targets,
+ gint *n_atoms)
+{
+ if (selection_data->length >= 0 &&
+ selection_data->format == 32 &&
+ selection_data->type == GDK_SELECTION_TYPE_ATOM)
+ {
+ if (targets)
+ *targets = g_memdup (selection_data->data, selection_data->length);
+ if (n_atoms)
+ *n_atoms = selection_data->length / sizeof (GdkAtom);
+
+ return TRUE;
+ }
+ else
+ {
+ if (targets)
+ *targets = NULL;
+ if (n_atoms)
+ *n_atoms = -1;
+
+ return FALSE;
+ }
+}
+
+/**
+ * gtk_selection_data_targets_include_text:
+ * @selection_data: a #GtkSelectionData object
+ *
+ * Given a #GtkSelectionData object holding a list of targets,
+ * Determines if any of the targets in @targets can be used to
+ * provide text.
+ *
+ * Return value: %TRUE if @selection_data holds a list of targets,
+ * and a suitable target for text is included, otherwise %FALSE.
+ **/
+gboolean
+gtk_selection_data_targets_include_text (GtkSelectionData *selection_data)
+{
+ GdkAtom *targets;
+ gint n_targets;
+ gint i;
+ gboolean result = FALSE;
+
+ if (gtk_selection_data_get_targets (selection_data, &targets, &n_targets))
+ {
+ for (i=0; i < n_targets; i++)
+ {
+ if (targets[i] == gdk_atom_intern ("STRING", FALSE) ||
+ targets[i] == gdk_atom_intern ("TEXT", FALSE) ||
+ targets[i] == gdk_atom_intern ("COMPOUND_TEXT", FALSE) ||
+ targets[i] == gdk_atom_intern ("UTF8_STRING", FALSE))
+ result = TRUE;
+ }
+
+ g_free (targets);
+ }
+
+ return result;
+}
+
/*************************************************************
* gtk_selection_init:
* Initialize local variables
if (tmp_list == NULL)
return FALSE;
- info = g_new(GtkIncrInfo, 1);
+ info = g_new (GtkIncrInfo, 1);
info->widget = widget;
info->selection = event->selection;
info->num_incrs = 0;
/* Create GdkWindow structure for the requestor */
-
-#if defined(GDK_WINDOWING_WIN32) || defined(GDK_WINDOWING_X11) || defined(GDK_WINDOWING_FB)
info->requestor = gdk_window_lookup (event->requestor);
if (!info->requestor)
info->requestor = gdk_window_foreign_new (event->requestor);
-#else
- info->requestor = NULL;
-#endif
/* Determine conversions we need to perform */
mult_atoms = NULL;
- gdk_error_trap_push();
+ gdk_error_trap_push ();
if (!gdk_property_get (info->requestor, event->property, 0, /* AnyPropertyType */
0, GTK_SELECTION_MAX_SIZE, FALSE,
&type, &format, &length, &mult_atoms))
g_free (info);
return TRUE;
}
- gdk_error_trap_pop();
+ gdk_error_trap_pop ();
info->num_conversions = length / (2*sizeof (GdkAtom));
info->conversions = g_new (GtkIncrConversion, info->num_conversions);
#ifdef DEBUG_SELECTION
g_message ("Selection %ld, target %ld (%s) requested by 0x%x (property = %ld)",
event->selection, info->conversions[i].target,
- gdk_atom_name(info->conversions[i].target),
+ gdk_atom_name (info->conversions[i].target),
event->requestor, event->property);
#endif
if (event->property != GDK_NONE)
length = gdk_selection_property_get (widget->window, &buffer,
&type, &format);
-
+ else
+ length = 0; /* silence gcc */
+
if (event->property == GDK_NONE || buffer == NULL)
{
current_retrievals = g_list_remove_link (current_retrievals, tmp_list);
#if defined(GDK_WINDOWING_WIN32) || defined(GDK_WINDOWING_X11)
if ((event->state != GDK_PROPERTY_NEW_VALUE) || /* property was deleted */
- (event->atom != gdk_selection_property)) /* not the right property */
+ (event->atom != gdk_atom_intern ("GDK_SELECTION", FALSE))) /* not the right property */
#endif
return FALSE;