void PasteboardHelper::getClipboardContents(GtkClipboard* clipboard) { DataObjectGtk* dataObject = DataObjectGtk::forClipboard(clipboard); ASSERT(dataObject); if (gtk_clipboard_wait_is_text_available(clipboard)) { GOwnPtr<gchar> textData(gtk_clipboard_wait_for_text(clipboard)); if (textData) dataObject->setText(String::fromUTF8(textData.get())); } if (gtk_clipboard_wait_is_target_available(clipboard, markupAtom)) { if (GtkSelectionData* data = gtk_clipboard_wait_for_contents(clipboard, markupAtom)) { String markup(selectionDataToUTF8String(data)); removeMarkupPrefix(markup); dataObject->setMarkup(markup); gtk_selection_data_free(data); } } if (gtk_clipboard_wait_is_target_available(clipboard, uriListAtom)) { if (GtkSelectionData* data = gtk_clipboard_wait_for_contents(clipboard, uriListAtom)) { dataObject->setURIList(selectionDataToUTF8String(data)); gtk_selection_data_free(data); } } }
void Pasteboard::writeURL(const KURL& url, const String& label, Frame* frame) { if (url.isEmpty()) return; GtkClipboard* clipboard = PasteboardHelper::clipboardForFrame(frame); ASSERT(clipboard); DataObjectGtk* dataObject = DataObjectGtk::forClipboard(clipboard); ASSERT(dataObject); String actualLabel(label); if (actualLabel.isEmpty()) actualLabel = url; Vector<KURL> uriList; uriList.append(url); dataObject->setURIList(uriList); dataObject->setText(actualLabel); PasteboardHelper::helper()->writeClipboardContents(clipboard); }