diff options
author | Matthias Clasen <mclasen@redhat.com> | 2011-06-24 21:18:07 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2011-07-05 16:08:08 -0400 |
commit | c2d1e3eeb0feb86b1cdd3803862c7a7b38a94ba8 (patch) | |
tree | 5d32f82b45432fd375a0f0f73ae779a667d8f7e3 /gtk/gtklabel.c | |
parent | ca5db10bda35f64bccfc2a6b5324828c789ba2e1 (diff) | |
download | gtk+-c2d1e3eeb0feb86b1cdd3803862c7a7b38a94ba8.tar.gz |
Avoid warnings in clipboard code
The a11y selection tests poke the selection on unrealized
labels. Don't spew warnings in this case.
Diffstat (limited to 'gtk/gtklabel.c')
-rw-r--r-- | gtk/gtklabel.c | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c index 45a7508605..e16ea33368 100644 --- a/gtk/gtklabel.c +++ b/gtk/gtklabel.c @@ -5428,14 +5428,17 @@ gtk_label_select_region_index (GtkLabel *label, GtkClipboard *clipboard; if (priv->select_info->selection_anchor == anchor_index && - priv->select_info->selection_end == end_index) - return; + priv->select_info->selection_end == end_index) + return; priv->select_info->selection_anchor = anchor_index; priv->select_info->selection_end = end_index; - clipboard = gtk_widget_get_clipboard (GTK_WIDGET (label), - GDK_SELECTION_PRIMARY); + if (gtk_widget_has_screen (GTK_WIDGET (label))) + clipboard = gtk_widget_get_clipboard (GTK_WIDGET (label), + GDK_SELECTION_PRIMARY); + else + clipboard = NULL; if (anchor_index != end_index) { @@ -5447,18 +5450,20 @@ gtk_label_select_region_index (GtkLabel *label, gtk_target_list_add_text_targets (list, 0); targets = gtk_target_table_new_from_list (list, &n_targets); - gtk_clipboard_set_with_owner (clipboard, - targets, n_targets, - get_text_callback, - clear_text_callback, - G_OBJECT (label)); + if (clipboard) + gtk_clipboard_set_with_owner (clipboard, + targets, n_targets, + get_text_callback, + clear_text_callback, + G_OBJECT (label)); gtk_target_table_free (targets, n_targets); gtk_target_list_unref (list); } else { - if (gtk_clipboard_get_owner (clipboard) == G_OBJECT (label)) + if (clipboard && + gtk_clipboard_get_owner (clipboard) == G_OBJECT (label)) gtk_clipboard_clear (clipboard); } |