a11y: Port to GdkClipboard

This commit is contained in:
Benjamin Otte 2017-11-26 07:35:19 +01:00
parent 54c8a4b3b7
commit 825612b419
2 changed files with 28 additions and 22 deletions

View File

@ -1257,7 +1257,7 @@ gtk_entry_accessible_copy_text (AtkEditableText *text,
GtkWidget *widget;
GtkEditable *editable;
gchar *str;
GtkClipboard *clipboard;
GdkClipboard *clipboard;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (text));
if (widget == NULL)
@ -1265,8 +1265,8 @@ gtk_entry_accessible_copy_text (AtkEditableText *text,
editable = GTK_EDITABLE (widget);
str = gtk_editable_get_chars (editable, start_pos, end_pos);
clipboard = gtk_widget_get_old_clipboard (widget, GDK_SELECTION_CLIPBOARD);
gtk_clipboard_set_text (clipboard, str, -1);
clipboard = gtk_widget_get_clipboard (widget);
gdk_clipboard_set_text (clipboard, str);
g_free (str);
}
@ -1278,7 +1278,7 @@ gtk_entry_accessible_cut_text (AtkEditableText *text,
GtkWidget *widget;
GtkEditable *editable;
gchar *str;
GtkClipboard *clipboard;
GdkClipboard *clipboard;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (text));
if (widget == NULL)
@ -1289,8 +1289,8 @@ gtk_entry_accessible_cut_text (AtkEditableText *text,
return;
str = gtk_editable_get_chars (editable, start_pos, end_pos);
clipboard = gtk_widget_get_old_clipboard (widget, GDK_SELECTION_CLIPBOARD);
gtk_clipboard_set_text (clipboard, str, -1);
clipboard = gtk_widget_get_clipboard (widget);
gdk_clipboard_set_text (clipboard, str);
gtk_editable_delete_text (editable, start_pos, end_pos);
}
@ -1320,18 +1320,21 @@ typedef struct
} PasteData;
static void
paste_received_cb (GtkClipboard *clipboard,
const gchar *text,
paste_received_cb (GObject *clipboard,
GAsyncResult *result,
gpointer data)
{
PasteData *paste = data;
char *text;
text = gdk_clipboard_read_text_finish (GDK_CLIPBOARD (clipboard), result, NULL);
if (text)
gtk_editable_insert_text (GTK_EDITABLE (paste->entry), text, -1,
&paste->position);
g_object_unref (paste->entry);
g_free (paste);
g_free (text);
}
static void
@ -1341,7 +1344,7 @@ gtk_entry_accessible_paste_text (AtkEditableText *text,
GtkWidget *widget;
GtkEditable *editable;
PasteData *paste;
GtkClipboard *clipboard;
GdkClipboard *clipboard;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (text));
if (widget == NULL)
@ -1356,8 +1359,8 @@ gtk_entry_accessible_paste_text (AtkEditableText *text,
paste->position = position;
g_object_ref (paste->entry);
clipboard = gtk_widget_get_old_clipboard (widget, GDK_SELECTION_CLIPBOARD);
gtk_clipboard_request_text (clipboard, paste_received_cb, paste);
clipboard = gtk_widget_get_clipboard (widget);
gdk_clipboard_read_text_async (clipboard, NULL, paste_received_cb, paste);
}
static void

View File

@ -1600,7 +1600,7 @@ gtk_text_view_accessible_copy_text (AtkEditableText *text,
GtkTextBuffer *buffer;
GtkTextIter start, end;
gchar *str;
GtkClipboard *clipboard;
GdkClipboard *clipboard;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (text));
if (widget == NULL)
@ -1612,8 +1612,8 @@ gtk_text_view_accessible_copy_text (AtkEditableText *text,
gtk_text_buffer_get_iter_at_offset (buffer, &end, end_pos);
str = gtk_text_buffer_get_text (buffer, &start, &end, FALSE);
clipboard = gtk_widget_get_old_clipboard (widget, GDK_SELECTION_CLIPBOARD);
gtk_clipboard_set_text (clipboard, str, -1);
clipboard = gtk_widget_get_clipboard (widget);
gdk_clipboard_set_text (clipboard, str);
}
static void
@ -1626,7 +1626,7 @@ gtk_text_view_accessible_cut_text (AtkEditableText *text,
GtkTextBuffer *buffer;
GtkTextIter start, end;
gchar *str;
GtkClipboard *clipboard;
GdkClipboard *clipboard;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (text));
if (widget == NULL)
@ -1640,8 +1640,8 @@ gtk_text_view_accessible_cut_text (AtkEditableText *text,
gtk_text_buffer_get_iter_at_offset (buffer, &start, start_pos);
gtk_text_buffer_get_iter_at_offset (buffer, &end, end_pos);
str = gtk_text_buffer_get_text (buffer, &start, &end, FALSE);
clipboard = gtk_widget_get_old_clipboard (widget, GDK_SELECTION_CLIPBOARD);
gtk_clipboard_set_text (clipboard, str, -1);
clipboard = gtk_widget_get_clipboard (widget);
gdk_clipboard_set_text (clipboard, str);
gtk_text_buffer_delete (buffer, &start, &end);
}
@ -1677,17 +1677,20 @@ typedef struct
} PasteData;
static void
paste_received (GtkClipboard *clipboard,
const gchar *text,
paste_received (GObject *clipboard,
GAsyncResult *result,
gpointer data)
{
PasteData* paste = data;
GtkTextIter pos_itr;
char *text;
text = gdk_clipboard_read_text_finish (GDK_CLIPBOARD (clipboard), result, NULL);
if (text)
{
gtk_text_buffer_get_iter_at_offset (paste->buffer, &pos_itr, paste->position);
gtk_text_buffer_insert (paste->buffer, &pos_itr, text, -1);
g_free (text);
}
g_object_unref (paste->buffer);
@ -1701,7 +1704,7 @@ gtk_text_view_accessible_paste_text (AtkEditableText *text,
GtkWidget *widget;
GtkTextBuffer *buffer;
PasteData paste;
GtkClipboard *clipboard;
GdkClipboard *clipboard;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (text));
if (widget == NULL)
@ -1716,8 +1719,8 @@ gtk_text_view_accessible_paste_text (AtkEditableText *text,
paste.position = position;
g_object_ref (paste.buffer);
clipboard = gtk_widget_get_old_clipboard (widget, GDK_SELECTION_CLIPBOARD);
gtk_clipboard_request_text (clipboard, paste_received, &paste);
clipboard = gtk_widget_get_clipboard (widget);
gdk_clipboard_read_text_async (clipboard, NULL, paste_received, &paste);
}
static void