[gtk+] a11y: Port to GdkClipboard
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] a11y: Port to GdkClipboard
- Date: Sun, 3 Dec 2017 04:53:35 +0000 (UTC)
commit 825612b4199badf3327b923647d2a114389dc3b6
Author: Benjamin Otte <otte redhat com>
Date: Sun Nov 26 07:35:19 2017 +0100
a11y: Port to GdkClipboard
gtk/a11y/gtkentryaccessible.c | 25 ++++++++++++++-----------
gtk/a11y/gtktextviewaccessible.c | 25 ++++++++++++++-----------
2 files changed, 28 insertions(+), 22 deletions(-)
---
diff --git a/gtk/a11y/gtkentryaccessible.c b/gtk/a11y/gtkentryaccessible.c
index eceaacd..88f3917 100644
--- a/gtk/a11y/gtkentryaccessible.c
+++ b/gtk/a11y/gtkentryaccessible.c
@@ -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
diff --git a/gtk/a11y/gtktextviewaccessible.c b/gtk/a11y/gtktextviewaccessible.c
index e99df0b..c50439e 100644
--- a/gtk/a11y/gtktextviewaccessible.c
+++ b/gtk/a11y/gtktextviewaccessible.c
@@ -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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]