How to paste HTML to clipboard with GTK+

巧了我就是萌 提交于 2019-12-19 08:54:16

问题


How do I paste HTML to the clipboard so that it is recognized as HTML in applications such as Open Office and MS Word? It is possible when using gtkhtml or gecko if you've already rendered it, but I need a straight GTK+ solution.


回答1:


You call gtk_clipboard_set_with_data or gtk_clipboard_set_with_owner, passing a GtkTargetEntry with "text/html" as the value for the target field.

It's good practice to also provide "UTF8_STRING" and "STRING" targets for applications that don't support HTML.

Here's an example of some code that does this: GEdit HTML clipboard plugin.



来源:https://stackoverflow.com/questions/1992869/how-to-paste-html-to-clipboard-with-gtk

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!