| Index: tools/gtk_clipboard_dump/gtk_clipboard_dump.cc
|
| diff --git a/tools/gtk_clipboard_dump/gtk_clipboard_dump.cc b/tools/gtk_clipboard_dump/gtk_clipboard_dump.cc
|
| index c96ee0083693da327190e572246883d8bf7be3a4..4ddf1a2a73af7d806314a2bc93a45f6e3938386f 100644
|
| --- a/tools/gtk_clipboard_dump/gtk_clipboard_dump.cc
|
| +++ b/tools/gtk_clipboard_dump/gtk_clipboard_dump.cc
|
| @@ -5,6 +5,7 @@
|
| #include <gtk/gtk.h>
|
| #include <stdio.h>
|
| #include <string.h>
|
| +#include <string>
|
|
|
| namespace {
|
|
|
| @@ -29,7 +30,10 @@ void PrintClipboardContents(GtkClipboard* clip) {
|
| printf("%d available targets:\n---------------\n", num_targets);
|
|
|
| for (int i = 0; i < num_targets; i++) {
|
| - printf(" [format: %s", gdk_atom_name(targets[i]));
|
| + gchar* target_name_cstr = gdk_atom_name(targets[i]);
|
| + std::string target_name(target_name_cstr);
|
| + g_free(target_name_cstr);
|
| + printf(" [format: %s", target_name.c_str());
|
| GtkSelectionData* data = gtk_clipboard_wait_for_contents(clip, targets[i]);
|
| if (!data) {
|
| printf("]: NULL\n\n");
|
| @@ -38,21 +42,20 @@ void PrintClipboardContents(GtkClipboard* clip) {
|
|
|
| printf(" / length: %d / bits %d]: ", data->length, data->format);
|
|
|
| - if (strstr(gdk_atom_name(targets[i]), "image")) {
|
| + if (strstr(target_name.c_str(), "image")) {
|
| printf("(image omitted)\n\n");
|
| - continue;
|
| - } else if (strstr(gdk_atom_name(targets[i]), "TIMESTAMP")) {
|
| + } else if (strstr(target_name.c_str(), "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++) {
|
| - // Output data one byte at a time. Currently wide strings look
|
| - // pretty weird.
|
| - printf("%c", (data->data[j] == 0 ? '_' : data->data[j]));
|
| + } else {
|
| + for (int j = 0; j < data->length; j++) {
|
| + // Output data one byte at a time. Currently wide strings look
|
| + // pretty weird.
|
| + printf("%c", (data->data[j] == 0 ? '_' : data->data[j]));
|
| + }
|
| + printf("\n\n");
|
| }
|
| - printf("\n\n");
|
| + gtk_selection_data_free(data);
|
| }
|
|
|
| if (num_targets <= 0) {
|
| @@ -63,6 +66,7 @@ void PrintClipboardContents(GtkClipboard* clip) {
|
| }
|
|
|
| g_free(targets);
|
| + gtk_selection_data_free(target_data);
|
| }
|
|
|
| }
|
|
|