Add support for reading from clipboard

This commit is contained in:
Kevin Sawicki
2012-06-04 20:41:18 -07:00
parent 0cf96c97b0
commit c28b93c51b
2 changed files with 15 additions and 0 deletions

View File

@@ -171,6 +171,15 @@ void NativeHandler::WriteToPasteboard(const CefString& name,
gtk_clipboard_set_text(clipboard, content.c_str(), content.length());
}
void NativeHandler::ReadFromPasteboard(const CefString& name,
CefRefPtr<CefV8Value> object, const CefV8ValueList& arguments,
CefRefPtr<CefV8Value>& retval, CefString& exception) {
GtkClipboard* clipboard = gtk_clipboard_get_for_display(
gdk_display_get_default(), GDK_NONE);
char* content = gtk_clipboard_wait_for_text(clipboard);
retval = CefV8Value::CreateString(content);
}
bool NativeHandler::Execute(const CefString& name, CefRefPtr<CefV8Value> object,
const CefV8ValueList& arguments, CefRefPtr<CefV8Value>& retval,
CefString& exception) {
@@ -197,6 +206,8 @@ bool NativeHandler::Execute(const CefString& name, CefRefPtr<CefV8Value> object,
Write(name, object, arguments, retval, exception);
else if (name == "writeToPasteboard")
WriteToPasteboard(name, object, arguments, retval, exception);
else if (name == "readFromPasteboard")
ReadFromPasteboard(name, object, arguments, retval, exception);
else
cout << "Unhandled -> " + name.ToString() << " : "
<< arguments[0]->GetStringValue().ToString() << endl;

View File

@@ -62,6 +62,10 @@ private:
void WriteToPasteboard(const CefString& name, CefRefPtr<CefV8Value> object,
const CefV8ValueList& arguments, CefRefPtr<CefV8Value>& retval,
CefString& exception);
void ReadFromPasteboard(const CefString& name, CefRefPtr<CefV8Value> object,
const CefV8ValueList& arguments, CefRefPtr<CefV8Value>& retval,
CefString& exception);
};
#endif