diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-02 22:30:26 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-02 22:30:26 +0000 |
commit | 2e417c8257e0007ef3fb6929a507268d0450bd4a (patch) | |
tree | 756cbb26e6225ef36abddb2cf59a73800587dcbd /tools/gtk_clipboard_dump | |
parent | 0cac83aa1536b90dd25db93808c4371c675e4cf2 (diff) | |
download | chromium_src-2e417c8257e0007ef3fb6929a507268d0450bd4a.zip chromium_src-2e417c8257e0007ef3fb6929a507268d0450bd4a.tar.gz chromium_src-2e417c8257e0007ef3fb6929a507268d0450bd4a.tar.bz2 |
Copy selection to x clipboard.
Review URL: http://codereview.chromium.org/55052
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@13044 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/gtk_clipboard_dump')
-rw-r--r-- | tools/gtk_clipboard_dump/gtk_clipboard_dump.cc | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/tools/gtk_clipboard_dump/gtk_clipboard_dump.cc b/tools/gtk_clipboard_dump/gtk_clipboard_dump.cc index e74cf8d..f0f6016 100644 --- a/tools/gtk_clipboard_dump/gtk_clipboard_dump.cc +++ b/tools/gtk_clipboard_dump/gtk_clipboard_dump.cc @@ -6,17 +6,11 @@ #include <stdio.h> #include <string.h> -/* Small program to dump the contents of GTK's clipboard to the terminal. - * Feel free to add to it or improve formatting or whatnot. - */ -int main(int argc, char* argv[]) { - gtk_init(&argc, &argv); +namespace { + +void PrintClipboardContents(GtkClipboard* clip) { GdkAtom* targets; int num_targets = 0; - // For now only look at GDK_SELECTION_CLIPBOARD. This could be extended - // to look at GDK_SELECTION_PRIMARY (the X clipboard). - GtkClipboard* clip = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD); - gtk_clipboard_wait_for_targets(clip, &targets, &num_targets); printf("Available targets:\n---------------\n"); @@ -34,6 +28,10 @@ int main(int argc, char* argv[]) { if (strstr(gdk_atom_name(targets[i]), "image")) { printf("(image omitted)\n\n"); continue; + } else if (strstr(gdk_atom_name(targets[i]), "TIMESTAMP")) { + // TODO(estade): Print the time stamp in human readable format. + printf("(time omitted)\n\n"); + continue; } for (int j = 0; j < data->length; j++) { @@ -44,3 +42,18 @@ int main(int argc, char* argv[]) { printf("\n\n"); } } + +} + +/* Small program to dump the contents of GTK's clipboards to the terminal. + * Feel free to add to it or improve formatting or whatnot. + */ +int main(int argc, char* argv[]) { + gtk_init(&argc, &argv); + + printf("Desktop clipboard\n"); + PrintClipboardContents(gtk_clipboard_get(GDK_SELECTION_CLIPBOARD)); + + printf("X clipboard\n"); + PrintClipboardContents(gtk_clipboard_get(GDK_SELECTION_PRIMARY)); +} |