From: http://www.bravegnu.org/gtktext/x234.html
3. Cut, Copy and Paste
In this section you will learn how to do common clipboard related activities like cut, copy and paste. First, you will have to get hold of a clipboard object using
GtkClipboard *gtk_clipboard_get( GdkAtom selection );Usually, a value of GDK_NONE is passed to selection, which gives the default clipboard. A value of GDK_SELECTION_PRIMARY identifies the primary X selection.
Selected text can be then copied to the clipboard using
void gtk_text_buffer_copy_clipboard( GtkTextBuffer *buffer,
GtkClipboard *clipboard );
The
clipboard is a clipboard object obtained from
gtk_clipboard_get.
Selected text can be cut to the clipboard using
void gtk_text_buffer_cut_clipboard( GtkTextBuffer *buffer,
GtkClipboard *clipboard,
gboolean default_editable );
For portions of the selected text that do not have the editable tag applied, the edit-ability is assumed from
default_editable.
Text can be pasted from the clipboard using
void gtk_text_buffer_paste_clipboard( GtkTextBuffer *buffer,
GtkClipboard *clipboard,
GtkTextIter *override_location,
gboolean default_editable );
If
override_location is not
NULL, text is inserted at the iter specified by
override_location. Else, text is inserted at the current cursor location.
博客介绍了GTK文本中与剪贴板相关的常见操作,如剪切、复制和粘贴。需先获取剪贴板对象,然后可将选中文本复制或剪切到剪贴板,也能从剪贴板粘贴文本。
3815

被折叠的 条评论
为什么被折叠?



