Originally Posted by
MTK
I guess that xclipboard would be better because it it would be desktop manager-independent. But would it be able to copy and paste with my GNOME applications?
GNOME uses gtk, which is (I think) the stuff abachler refers to is, altho I don't have a DE installed so can't confirm that.
Code:
void copytoX (GtkWidget *ignored, int opt) {
GdkDisplay *display = gdk_display_get_default();
GtkClipboard *clipboard = gtk_clipboard_get_for_display(display,GDK_SELECTION_CLIPBOARD);
if (opt) { gtk_text_buffer_get_bounds(Tbuf,&start,&finish);
gtk_text_buffer_select_range(Tbuf,(const GtkTextIter*)&start,(const GtkTextIter*)&finish); }
gtk_text_buffer_copy_clipboard(Tbuf,clipboard);
}
This is the xclipboard; if you use xclipboard you can check the contents, they are the same. There is, in fact, another clipboard which does not rely on the GUI or the use of cut n' paste in a menu. I think many linux users may be unaware of it, but if you simply highlight some text somewhere, leave it highlighted, then go somewhere else and click button 3/both buttons, you will get the contents of the highlighted region. However, that text is not in the xclipboard. I have never investigated how to program it, but I make use of this a lot (the fact that you can have two different clipboard buffers and access them with different methods), but the uncommon one (no GUI interaction using mouse button 3) is not consistent, and that is not what you want. Sorry if that is unnecessarily confusing.
Anyway, I think the GNOME clipboard viewer is just a "nicer" GUI for xclipboard, it is not really separate, so don't worry -- it is all, in fact, the xclipboard. Which presumably you can access it with Xlib() as well as gtk, and I suppose any other GUI toolkit. But they will all be using the same clipboard, the xclipboard.