PDA

View Full Version : [SOLVED] How can one access clipboard from a program?



TheHimself
February 2nd, 2011, 04:50 PM
It seems that I can't find the answer in libc or GTK documentation. I'd like an answer which doesn't depend on the desktop used.

cgroza
February 2nd, 2011, 11:12 PM
This is only useful when programming a GUI program, so I know that every GUI toolkit will offer some classes to access the clipboard. In wxPython for example, this is done in a similar way as in opening a file, drop the text and close it back.

TheHimself
February 3rd, 2011, 04:09 PM
I use GTK but it doesn't seem to have such a thing even though it supports in-application clipboards. I want to be able to access the system (X?) clipboard.

nvteighen
February 3rd, 2011, 07:44 PM
I use GTK but it doesn't seem to have such a thing even though it supports in-application clipboards. I want to be able to access the system (X?) clipboard.

There's no such thing as a system-wide clipboard. The closest thing I've seen is the KDE desktop-wide clipboard, but that's only for KDE, GNOME doesn't have that and I don't think the GTK+ API can communicate to the KDE clipboard.

TheHimself
February 3rd, 2011, 09:19 PM
But you can "copy" text in one application and paste it in another one. This means that there is a clipboard which is independent of individual applications. Doesn't? I think it has to do with X but as I browse the X library docs I can't find what I'm looking for.

TheHimself
February 6th, 2011, 11:37 AM
I found the answer in the following function:

gtk_clipboard_get_for_display ()