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
This commit is contained in:
parent
49ec67c7eb
commit
6b977e6870
@ -3626,29 +3626,23 @@ static void
|
|||||||
update_selection_clipboards (GtkTextBuffer *buffer)
|
update_selection_clipboards (GtkTextBuffer *buffer)
|
||||||
{
|
{
|
||||||
GtkTextBufferPrivate *priv;
|
GtkTextBufferPrivate *priv;
|
||||||
GSList *tmp_list = buffer->priv->selection_clipboards;
|
gboolean has_selection;
|
||||||
|
GtkTextIter start;
|
||||||
|
GtkTextIter end;
|
||||||
|
GSList *tmp_list;
|
||||||
|
|
||||||
priv = buffer->priv;
|
priv = buffer->priv;
|
||||||
|
|
||||||
gtk_text_buffer_get_copy_target_list (buffer);
|
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)
|
while (tmp_list)
|
||||||
{
|
{
|
||||||
GtkTextIter start;
|
|
||||||
GtkTextIter end;
|
|
||||||
|
|
||||||
SelectionClipboard *selection_clipboard = tmp_list->data;
|
SelectionClipboard *selection_clipboard = tmp_list->data;
|
||||||
GtkClipboard *clipboard = selection_clipboard->clipboard;
|
GtkClipboard *clipboard = selection_clipboard->clipboard;
|
||||||
|
|
||||||
/* Determine whether we have a selection and adjust X selection
|
if (has_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
|
/* Even if we already have the selection, we need to update our
|
||||||
* timestamp.
|
* timestamp.
|
||||||
@ -3660,6 +3654,8 @@ update_selection_clipboards (GtkTextBuffer *buffer)
|
|||||||
clipboard_clear_selection_cb,
|
clipboard_clear_selection_cb,
|
||||||
G_OBJECT (buffer));
|
G_OBJECT (buffer));
|
||||||
}
|
}
|
||||||
|
else if (gtk_clipboard_get_owner (clipboard) == G_OBJECT (buffer))
|
||||||
|
gtk_clipboard_clear (clipboard);
|
||||||
|
|
||||||
tmp_list = tmp_list->next;
|
tmp_list = tmp_list->next;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user