Avoid warnings in clipboard code

The a11y selection tests poke the selection on unrealized
labels. Don't spew warnings in this case.
This commit is contained in:
Matthias Clasen 2011-06-24 21:18:07 -04:00
parent ca5db10bda
commit c2d1e3eeb0

View File

@ -5434,8 +5434,11 @@ gtk_label_select_region_index (GtkLabel *label,
priv->select_info->selection_anchor = anchor_index; priv->select_info->selection_anchor = anchor_index;
priv->select_info->selection_end = end_index; priv->select_info->selection_end = end_index;
if (gtk_widget_has_screen (GTK_WIDGET (label)))
clipboard = gtk_widget_get_clipboard (GTK_WIDGET (label), clipboard = gtk_widget_get_clipboard (GTK_WIDGET (label),
GDK_SELECTION_PRIMARY); GDK_SELECTION_PRIMARY);
else
clipboard = NULL;
if (anchor_index != end_index) if (anchor_index != end_index)
{ {
@ -5447,6 +5450,7 @@ gtk_label_select_region_index (GtkLabel *label,
gtk_target_list_add_text_targets (list, 0); gtk_target_list_add_text_targets (list, 0);
targets = gtk_target_table_new_from_list (list, &n_targets); targets = gtk_target_table_new_from_list (list, &n_targets);
if (clipboard)
gtk_clipboard_set_with_owner (clipboard, gtk_clipboard_set_with_owner (clipboard,
targets, n_targets, targets, n_targets,
get_text_callback, get_text_callback,
@ -5458,7 +5462,8 @@ gtk_label_select_region_index (GtkLabel *label,
} }
else else
{ {
if (gtk_clipboard_get_owner (clipboard) == G_OBJECT (label)) if (clipboard &&
gtk_clipboard_get_owner (clipboard) == G_OBJECT (label))
gtk_clipboard_clear (clipboard); gtk_clipboard_clear (clipboard);
} }