Advertisement
Guest User

Untitled

a guest
Sep 15th, 2013
453
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. #!/usr/bin/python
  2.  
  3. import glib, gtk
  4.  
  5. def test_clipboard():
  6. clipboard = gtk.Clipboard()
  7. targets = clipboard.wait_for_targets()
  8. print "Targets available:", ", ".join(map(str, targets))
  9. for target in targets:
  10. print "Trying '%s'..." % str(target)
  11. contents = clipboard.wait_for_contents(target)
  12. if contents:
  13. print contents.data
  14.  
  15. def main():
  16. mainloop = glib.MainLoop()
  17. def cb():
  18. test_clipboard()
  19. mainloop.quit()
  20. glib.idle_add(cb)
  21. mainloop.run()
  22.  
  23. if __name__ == "__main__":
  24. main()
  25.  
  26. $ ./clipboard.py
  27. Targets available: TIMESTAMP, TARGETS, MULTIPLE, text/html, text/_moz_htmlcontext, text/_moz_htmlinfo, UTF8_STRING, COMPOUND_TEXT, TEXT, STRING, text/x-moz-url-priv
  28. ...
  29. Trying 'text/html'...
  30. I asked <a href="http://superuser.com/questions/144185/getting-html-source-or-rich-text-from-the-x-clipboard">the same question on superuser.com</a>, because I was hoping there was a utility to do this, but I didn't get any informative responses.
  31. Trying 'text/_moz_htmlcontext'...
  32. <html><body class="question-page"><div class="container"><div id="content"><div id="mainbar"><div id="question"><table><tbody><tr><td class="postcell"><div><div class="post-text"><p></p></div></div></td></tr></tbody></table></div></div></div></div></body></html>
  33. ...
  34. Trying 'STRING'...
  35. I asked the same question on superuser.com, because I was hoping there was a utility to do this, but I didn't get any informative responses.
  36. Trying 'text/x-moz-url-priv'...
  37. http://stackoverflow.com/questions/3261379/getting-html-source-or-rich-text-from-the-x-clipboard
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement