diff options
author | Paolo Borelli <pborelli@gnome.org> | 2015-03-29 12:22:42 +0200 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2015-04-05 07:54:00 -0400 |
commit | 6b977e68702021f075eb17a8aaa15ec1ba50e7ff (patch) | |
tree | de7d23022ca9367d6c7649cf9a0d9fd14bd1c61c /gtk/gtktextbuffer.c | |
parent | 49ec67c7eb52a8b20a7a18c37c63020c5612df0e (diff) | |
download | gtk+-6b977e68702021f075eb17a8aaa15ec1ba50e7ff.tar.gz |
gtktextbuffer: small cleanup in clipboard handling
Make code shorter and also more efficient since we move the
selection check out of the loop
https://bugzilla.gnome.org/show_bug.cgi?id=747096
Diffstat (limited to 'gtk/gtktextbuffer.c')
-rw-r--r-- | gtk/gtktextbuffer.c | 32 |
1 files changed, 14 insertions, 18 deletions
diff --git a/gtk/gtktextbuffer.c b/gtk/gtktextbuffer.c index 1428fe20b9..5bb9a210b8 100644 --- a/gtk/gtktextbuffer.c +++ b/gtk/gtktextbuffer.c @@ -3626,40 +3626,36 @@ static void update_selection_clipboards (GtkTextBuffer *buffer) { GtkTextBufferPrivate *priv; - GSList *tmp_list = buffer->priv->selection_clipboards; + gboolean has_selection; + GtkTextIter start; + GtkTextIter end; + GSList *tmp_list; priv = buffer->priv; gtk_text_buffer_get_copy_target_list (buffer); + has_selection = gtk_text_buffer_get_selection_bounds (buffer, &start, &end); + tmp_list = buffer->priv->selection_clipboards; while (tmp_list) { - GtkTextIter start; - GtkTextIter end; - SelectionClipboard *selection_clipboard = tmp_list->data; GtkClipboard *clipboard = selection_clipboard->clipboard; - /* Determine whether we have a selection and adjust X selection - * accordingly. - */ - if (!gtk_text_buffer_get_selection_bounds (buffer, &start, &end)) - { - if (gtk_clipboard_get_owner (clipboard) == G_OBJECT (buffer)) - gtk_clipboard_clear (clipboard); - } - else - { - /* Even if we already have the selection, we need to update our - * timestamp. - */ + if (has_selection) + { + /* Even if we already have the selection, we need to update our + * timestamp. + */ gtk_clipboard_set_with_owner (clipboard, priv->copy_target_entries, priv->n_copy_target_entries, clipboard_get_selection_cb, clipboard_clear_selection_cb, G_OBJECT (buffer)); - } + } + else if (gtk_clipboard_get_owner (clipboard) == G_OBJECT (buffer)) + gtk_clipboard_clear (clipboard); tmp_list = tmp_list->next; } |