RE: copy text the to the clipboard
- From: Owen Taylor <otaylor redhat com>
- To: Murray Cumming Comneon com
- Cc: uidzer0 hotmail com, gtk-list gnome org
- Subject: RE: copy text the to the clipboard
- Date: 04 Apr 2003 10:35:27 -0500
On Fri, 2003-04-04 at 02:34, Murray Cumming Comneon com wrote:
> It depends on the widget. For simple text, gtk_editable_copy_clipboard()
> might be what you need. Or there's something similar for GtkTextView.
>
> For custom data you'll need to understand the concepts. Here are some C++
> examples:
> http://www.gtkmm.org/gtkmm2/docs/tutorial/html/ch16.html
Since that's pretty complicated, let me point out, to copy a string to
the clipboard, all you need is:
GtkClipboard *clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD);
gtk_clipboard_set_text (clipboard, "My Text", -1);
Getting the text on the clipboard can be as simple as:
char *my_text = gtk_clipboard_wait_for_text (clipboard);
/* use text */
g_free (my_text);
[ Note, gtk_clipboard_wait_for_text() runs a recursive main loop,
so any of your applications callbacks could be invoked while
it is running ]
Regards,
Owen
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]