summaryrefslogtreecommitdiff
path: root/gtk/gtkselection.c
diff options
context:
space:
mode:
Diffstat (limited to 'gtk/gtkselection.c')
-rw-r--r--gtk/gtkselection.c41
1 files changed, 30 insertions, 11 deletions
diff --git a/gtk/gtkselection.c b/gtk/gtkselection.c
index eb3c652a9b..1d62d7dc7a 100644
--- a/gtk/gtkselection.c
+++ b/gtk/gtkselection.c
@@ -177,12 +177,17 @@ gtk_target_list_new (const GtkTargetEntry *targets,
void
gtk_target_list_ref (GtkTargetList *list)
{
+ g_return_if_fail (list != NULL);
+
list->ref_count++;
}
void
gtk_target_list_unref (GtkTargetList *list)
{
+ g_return_if_fail (list != NULL);
+ g_return_if_fail (list->ref_count > 0);
+
list->ref_count--;
if (list->ref_count == 0)
{
@@ -253,7 +258,7 @@ gtk_target_list_remove (GtkTargetList *list,
{
g_free (pair);
- list->list = g_list_remove (list->list, tmp_list);
+ list->list = g_list_remove_link (list->list, tmp_list);
g_list_free_1 (tmp_list);
return;
@@ -683,7 +688,7 @@ void
gtk_selection_data_set (GtkSelectionData *selection_data,
GdkAtom type,
gint format,
- guchar *data,
+ const guchar *data,
gint length)
{
if (selection_data->data)
@@ -840,6 +845,8 @@ gtk_selection_request (GtkWidget *widget,
gint length;
mult_atoms = NULL;
+
+ 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))
@@ -850,6 +857,7 @@ gtk_selection_request (GtkWidget *widget,
g_free (info);
return TRUE;
}
+ gdk_error_trap_pop();
info->num_conversions = length / (2*sizeof (GdkAtom));
info->conversions = g_new (GtkIncrConversion, info->num_conversions);
@@ -960,9 +968,19 @@ gtk_selection_request (GtkWidget *widget,
mult_atoms, 2*info->num_conversions);
g_free (mult_atoms);
}
-
- gdk_selection_send_notify (event->requestor, event->selection, event->target,
- event->property, event->time);
+
+ if (info->num_conversions == 1 &&
+ info->conversions[0].property == GDK_NONE)
+ {
+ /* Reject the entire conversion */
+ gdk_selection_send_notify (event->requestor, event->selection,
+ event->target, GDK_NONE, event->time);
+ }
+ else
+ {
+ gdk_selection_send_notify (event->requestor, event->selection,
+ event->target, event->property, event->time);
+ }
if (info->num_incrs == 0)
{
@@ -1165,7 +1183,7 @@ gtk_selection_notify (GtkWidget *widget,
{
GList *tmp_list;
GtkRetrievalInfo *info = NULL;
- guchar *buffer;
+ guchar *buffer = NULL;
gint length;
GdkAtom type;
gint format;
@@ -1186,8 +1204,12 @@ gtk_selection_notify (GtkWidget *widget,
if (!tmp_list) /* no retrieval in progress */
return FALSE;
-
- if (event->property == GDK_NONE)
+
+ if (event->property != GDK_NONE)
+ length = gdk_selection_property_get (widget->window, &buffer,
+ &type, &format);
+
+ if (event->property == GDK_NONE || buffer == NULL)
{
current_retrievals = g_list_remove_link (current_retrievals, tmp_list);
g_list_free (tmp_list);
@@ -1198,9 +1220,6 @@ gtk_selection_notify (GtkWidget *widget,
return TRUE;
}
- length = gdk_selection_property_get (widget->window, &buffer,
- &type, &format);
-
if (type == gtk_selection_atoms[INCR])
{
/* The remainder of the selection will come through PropertyNotify