summaryrefslogtreecommitdiffstats
path: root/tools/gtk_clipboard_dump
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-21 01:21:54 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-21 01:21:54 +0000
commit27f3d73d16b6b041e06a39451d2cda51562ce1c6 (patch)
tree308e836cd5f03a1809a3296ab69e1ddadcabfcca /tools/gtk_clipboard_dump
parent4b32fe696f8a3b84a4feb16f1ce8dfa5d5f41a9a (diff)
downloadchromium_src-27f3d73d16b6b041e06a39451d2cda51562ce1c6.zip
chromium_src-27f3d73d16b6b041e06a39451d2cda51562ce1c6.tar.gz
chromium_src-27f3d73d16b6b041e06a39451d2cda51562ce1c6.tar.bz2
Support pasting text from a clipboard that has no published targets.
BUG=16887 TEST=paste from intellij into chrome render view Review URL: http://codereview.chromium.org/159107 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21142 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/gtk_clipboard_dump')
-rw-r--r--tools/gtk_clipboard_dump/gtk_clipboard_dump.cc21
1 files changed, 19 insertions, 2 deletions
diff --git a/tools/gtk_clipboard_dump/gtk_clipboard_dump.cc b/tools/gtk_clipboard_dump/gtk_clipboard_dump.cc
index f0f6016..a064792 100644
--- a/tools/gtk_clipboard_dump/gtk_clipboard_dump.cc
+++ b/tools/gtk_clipboard_dump/gtk_clipboard_dump.cc
@@ -11,9 +11,17 @@ namespace {
void PrintClipboardContents(GtkClipboard* clip) {
GdkAtom* targets;
int num_targets = 0;
- gtk_clipboard_wait_for_targets(clip, &targets, &num_targets);
- printf("Available targets:\n---------------\n");
+ // This call is bugged, the cache it checks is often stale; see
+ // <http://bugzilla.gnome.org/show_bug.cgi?id=557315>.
+ // gtk_clipboard_wait_for_targets(clip, &targets, &num_targets);
+
+ GtkSelectionData* target_data =
+ gtk_clipboard_wait_for_contents(clip,
+ gdk_atom_intern("TARGETS", false));
+ gtk_selection_data_get_targets(target_data, &targets, &num_targets);
+
+ printf("%d available targets:\n---------------\n", num_targets);
for (int i = 0; i < num_targets; i++) {
printf(" [format: %s", gdk_atom_name(targets[i]));
@@ -41,6 +49,15 @@ void PrintClipboardContents(GtkClipboard* clip) {
}
printf("\n\n");
}
+
+ if (num_targets <= 0) {
+ printf("No targets advertised. Text is: ");
+ gchar* text = gtk_clipboard_wait_for_text(clip);
+ printf("%s\n", text ? text : "NULL");
+ g_free(text);
+ }
+
+ g_free(targets);
}
}