* Copyright (C) 2007 Richard Nelson <wabz@whatsbeef.net> * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA #define PLUGIN_STATIC_NAME GntClipboard static gulong sig_handle; XSelectionRequestEvent *req; Display *dpy = XOpenDisplay(NULL); ids = getenv("WINDOWID"); XSetSelectionOwner(dpy, XA_PRIMARY, w, CurrentTime); XSelectInput(dpy, w, StructureNotifyMask); XNextEvent(dpy, &e); /* this blocks. */ req = &e.xselectionrequest; if (e.type == SelectionRequest) { respond.xselection.property = req->property; respond.xselection.type = SelectionNotify; respond.xselection.display = req->display; respond.xselection.requestor = req->requestor; respond.xselection.selection = req->selection; respond.xselection.target= req->target; respond.xselection.time = req->time; XSendEvent(dpy, req->requestor, 0, 0, &respond); } else if (e.type == SelectionClear) { clipboard_changed(GntWM *wm, gchar *string) if ((child = fork() == 0)) { plugin_load(PurplePlugin *plugin) if (!XOpenDisplay(NULL)) { purple_debug_warning("gntclipboard", "Couldn't find X display\n"); purple_notify_error(NULL, _("Error"), _("Error loading the plugin."), _("Couldn't find X display")); if (!getenv("WINDOWID")) { purple_debug_warning("gntclipboard", "Couldn't find window\n"); purple_notify_error(NULL, _("Error"), _("Error loading the plugin."), _("Couldn't find window")); sig_handle = g_signal_connect(G_OBJECT(gnt_get_clipboard()), "clipboard_changed", G_CALLBACK(clipboard_changed), NULL); purple_notify_error(NULL, _("Error"), _("Error loading the plugin."), _("This plugin cannot be loaded because it was not built with X11 support.")); plugin_unload(PurplePlugin *plugin) g_signal_handler_disconnect(G_OBJECT(gnt_get_clipboard()), sig_handle); static PurplePluginInfo info = N_("When the gnt clipboard contents change, " "the contents are made available to X, if possible."), "Richard Nelson <wabz@whatsbeef.net>", init_plugin(PurplePlugin *plugin) PURPLE_INIT_PLUGIN(PLUGIN_STATIC_NAME, init_plugin, info)